add programatic and command line build tool with TypeScript declaration

This commit is contained in:
cutls 2021-04-14 13:58:21 +09:00
parent 8621b66203
commit a8f060578a
9 changed files with 144 additions and 87 deletions

View File

@ -46,51 +46,31 @@ The icon is provided under [Creative Commons BY-NC-SA](https://creativecommons.o
The default sounds of notifications is provided [Creative Commons BY](https://creativecommons.org/licenses/by/4.0/) The default sounds of notifications is provided [Creative Commons BY](https://creativecommons.org/licenses/by/4.0/)
## Privacy Policy ### Privacy Policy
* [プライバシーポリシー(Privacy Policy(ja))](https://thedesk.top/priv.html) * [プライバシーポリシー(Privacy Policy(ja))](https://thedesk.top/priv.html)
## Language ## Translation
* 日本語(Japanese)
* 日本語, 関西(Japanese, Kansai)
* English
* български(Bulgarian) with [translate project](https://translate.thedesk.top/project/thedesk/bg)
* Česky(Czech) with [translate project](https://translate.thedesk.top/project/thedesk/cs)
* Deutsch(German) with [translate project](https://translate.thedesk.top/project/thedesk/de)
* Español, argentina(Spanish, Argentina) with [translate project](https://translate.thedesk.top/project/thedesk/es-AR)
* italiano(Italian) with [translate project](https://translate.thedesk.top/project/thedesk/it-IT)
and more...
### Translation
Crowdin project is available! Visit: https://translate.thedesk.top Crowdin project is available! Visit: https://translate.thedesk.top
### Run on developer mode ## Development
**you cannot use npm or any other package manager without Yarn.**(it will throw error) to launch developer version with console(if close dev mode, you may press Ctrl+C twice.)
* `yarn` **Strongly recommend to use yarn, not npm**
* `yarn dev`
## Contributors ```sh
git clone https://github.com/cutls/TheDesk
cd TheDesk/app
yarn install
Build for macOS(Now: Travis CI) yarn dev
```
* [toneji](https://minohdon.jp/@toneji)
Build for Linux(Now: Travis CI)
* [popn_ja](https://popon.pptdn.jp/@popn_ja)
Fellow coder
* [kPherox](https://pl.kpherox.dev/kPherox)
## Build ## Build
**you cannot use npm or any other package manager without Yarn.**(it will throw error) **Strongly recommend to use yarn, not npm**
```sh ```sh
git clone https://github.com/cutls/TheDesk git clone https://github.com/cutls/TheDesk
@ -100,7 +80,9 @@ yarn install
yarn build yarn build
``` ```
run `yarn dev` to launch developer version with console(if close dev mode, you may press Ctrl+C twice.) ### Options
Look at `yarn build --help`
### Restriction with macOS build ### Restriction with macOS build
@ -108,7 +90,17 @@ Requires XCode(XCode Command Line Tools) to use iTunes NowPlaying
Built assets should be notarized after building by expensive Apple Developer user. To disable it, see `app/build/notarize.js` (beta) Built assets should be notarized after building by expensive Apple Developer user. To disable it, see `app/build/notarize.js` (beta)
### PWA support ### Programatic build
TheDesk builder has type declaration for TypeScript.
```ts
import build from './app/builder'
build()
```
### PWA build
TheDesk is a web-based app, so you can run it on a browser. Of course, the main stream is as Electron. Some features won't work as well as Electron. TheDesk is a web-based app, so you can run it on a browser. Of course, the main stream is as Electron. Some features won't work as well as Electron.
@ -125,6 +117,16 @@ Did you find a bug with Pleroma accounts?
Pleroma **does not** follow Mastodon API rules completely although Pleroma developers say so. Pleroma **does not** follow Mastodon API rules completely although Pleroma developers say so.
Please write issues to improve TheDesk affinity with Pleroma. Please write issues to improve TheDesk affinity with Pleroma.
## Vulnerabilities when `yarn install`??? ## Contributors
No, if your npm says materialize-css has vulnerabilities(CVE-2019-11002/3/4), look at [here](https://github.com/Dogfalo/materialize/issues/6286) under discussion, but I do not think this report is really fatal. Build for macOS(Now: Travis CI)
* [toneji](https://minohdon.jp/@toneji)
Build for Linux(Now: Travis CI)
* [popn_ja](https://popon.pptdn.jp/@popn_ja)
Fellow coder
* [kPherox](https://pl.kpherox.dev/kPherox)

View File

@ -33,45 +33,33 @@ Download:[TheDesk](https://thedesk.top)
標準の通知音は [Creative Commons BY](https://creativecommons.org/licenses/by/4.0/) で提供されています。 標準の通知音は [Creative Commons BY](https://creativecommons.org/licenses/by/4.0/) で提供されています。
## プライバシーポリシー ### プライバシーポリシー
* [プライバシーポリシー](https://thedesk.top/priv.html) * [プライバシーポリシー](https://thedesk.top/priv.html)
## 言語 ## 翻訳
* 日本語
* 日本語(関西)
* English(英語)
* ドイツ語, チェコ語, ブルガリア語, イタリア語, スペイン語アルゼンチン方言他 (from [Crowdin](https://translate.thedesk.top))
### 翻訳
Crowdinから翻訳に参加してみませんか: https://translate.thedesk.top Crowdinから翻訳に参加してみませんか: https://translate.thedesk.top
**yarnを使ってください。その他(npmなど)を使用するとエラーが出ます** ## ビルドと開発
### デベロッパーモード **npmではなくyarnを使ってください。**
`yarn dev`を`app`フォルダ内で実行。 ### 開発
## 主なコントリビューター コンソールが出る開発モードで起動します。並行して監視が走る関係上、Ctrl+Cを2回押さないと終了しない場合があります。
macOSビルダー(現在はTravis CI) ```sh
git clone https://github.com/cutls/TheDesk
cd TheDesk/app
yarn install
* [とねぢ](https://minohdon.jp/@toneji) yarn dev
```
Linuxビルダー(現在はTravis CI) **npmではなくyarnを使ってください。**
* [ぽぷんじゃ](https://popon.pptdn.jp/@popn_ja)
コーダー
* [kPherox](https://pl.kpherox.dev/kPherox)
## ビルド
**yarnを使ってください。その他(npmなど)を使用するとエラーが出ます**
### ビルド
```sh ```sh
git clone https://github.com/cutls/TheDesk git clone https://github.com/cutls/TheDesk
@ -81,7 +69,9 @@ yarn install
yarn build yarn build
``` ```
`yarn dev`でコンソールが出る開発モードで起動します。並行して監視が走る関係上、Ctrl+Cを2回押さないと終了しない場合があります。 ### オプション
`yarn build --help`参照。
### macOSでビルドするときの制限 ### macOSでビルドするときの制限
@ -93,7 +83,16 @@ Notarizeが入ります。つまり、認証された(課金したとも言う)
フォークを世に出す場合や、Cutlsが信用できない場合、自分でMac AppStoreに出す場合など、[自分でNotarizeする必要があるとき](https://kilianvalkhof.com/2019/electron/notarizing-your-electron-application/)、[それをCI等で自動化するとき](https://qiita.com/ktmouk/items/7fc27c9ad0e3caf7899d)。 フォークを世に出す場合や、Cutlsが信用できない場合、自分でMac AppStoreに出す場合など、[自分でNotarizeする必要があるとき](https://kilianvalkhof.com/2019/electron/notarizing-your-electron-application/)、[それをCI等で自動化するとき](https://qiita.com/ktmouk/items/7fc27c9ad0e3caf7899d)。
### PWAとして実行 ### プログラムでビルド
TypeScript用の型定義を持っています。
```ts
import build from './app/builder'
build()
```
### PWAとしてビルド
TheDeskはウェブ技術を使用して作られているので、ブラウザで動かすこともできます。もちろん、Electron向けに設計されているので一部機能は動きません。 TheDeskはウェブ技術を使用して作られているので、ブラウザで動かすこともできます。もちろん、Electron向けに設計されているので一部機能は動きません。
@ -113,7 +112,17 @@ Issuesに書いてある問題についてはなるべく対処しますので
[TheDesk - マストドン日本語ウィキ](https://ja.mstdn.wiki/TheDesk) [TheDesk - マストドン日本語ウィキ](https://ja.mstdn.wiki/TheDesk)
## `yarn install`したら脆弱性あるって言われた ## 主なコントリビューター
macOSビルダー(現在はTravis CI)
* [とねぢ](https://minohdon.jp/@toneji)
Linuxビルダー(現在はTravis CI)
* [ぽぷんじゃ](https://popon.pptdn.jp/@popn_ja)
コーダー
* [kPherox](https://pl.kpherox.dev/kPherox)
materialize-cssの脆弱性(CVE-2019-11002/3/4)については[こちら](https://github.com/Dogfalo/materialize/issues/6286)で本当に脆弱性かどうか議論しています。
実際には害が無いものと思われます。

7
app/build.d.ts vendored Normal file
View File

@ -0,0 +1,7 @@
declare function _exports(options?: {
onlyStore?: boolean;
withStore?: boolean;
withIa32?: boolean;
withArm64?: boolean;
}): void;
export = _exports;

View File

@ -8,6 +8,7 @@ const version = data.version
const codename = data.codename const codename = data.codename
const ver = `${version} (${codename})` const ver = `${version} (${codename})`
const construct = require('./view/make/make.js') const construct = require('./view/make/make.js')
const { ModuleResolutionKind } = require('typescript')
const { platform, arch } = process const { platform, arch } = process
const Platform = builder.Platform const Platform = builder.Platform
const Arch = builder.Arch const Arch = builder.Arch
@ -62,12 +63,15 @@ async function build(os, arch, config) {
publish: 'never' publish: 'never'
}) })
} }
async function cmd() { async function cmd(options) {
if (isTrue('onlyStore') || isTrue('withStore')) { if (isTrue(options, 'help', 'h')) {
return console.log(help())
}
if (isTrue(options, 'onlyStore') || isTrue(options, 'withStore')) {
console.log('start building for application stores') console.log('start building for application stores')
construct(ver, basefile, false, true) construct(ver, basefile, false, true)
if (platform == 'win32') { if (platform == 'win32') {
if ((isTrue('withIa32') && arch == 'x64') || arch == 'ia32') { if ((isTrue(options, 'withIa32') && arch == 'x64') || arch == 'ia32') {
await build(Platform.WINDOWS, Arch.ia32, config) await build(Platform.WINDOWS, Arch.ia32, config)
fs.renameSync( fs.renameSync(
`../build/TheDesk ${version}.exe`, `../build/TheDesk ${version}.exe`,
@ -93,12 +97,12 @@ async function cmd() {
if (arch == 'ia32') { if (arch == 'ia32') {
await build(Platform.LINUX, Arch.ia32, config) await build(Platform.LINUX, Arch.ia32, config)
} }
if ((isTrue('withIa32') && arch == 'x64')) { if ((isTrue(options, 'withIa32') && arch == 'x64')) {
console.log('snapcraft does not curretly support builing i386 on amd64') console.log('snapcraft does not curretly support builing i386 on amd64')
} }
if (arch == 'x64') { if (arch == 'x64') {
await build(Platform.LINUX, Arch.x64, config) await build(Platform.LINUX, Arch.x64, config)
if (!isTrue('onlyStore')) { if (!isTrue(options, 'onlyStore')) {
fs.renameSync( fs.renameSync(
`../build/thedesk_${version}_amd64.snap`, `../build/thedesk_${version}_amd64.snap`,
`../build/thedesk_${version}_amd64-store.snap` `../build/thedesk_${version}_amd64-store.snap`
@ -111,11 +115,11 @@ async function cmd() {
return false return false
} }
} }
if (!isTrue('onlyStore')) { if (!isTrue(options, 'onlyStore')) {
console.log('start building for normal usage') console.log('start building for normal usage')
construct(ver, basefile, false, false) construct(ver, basefile, false, false)
if (platform == 'win32') { if (platform == 'win32') {
if ((isTrue('withIa32') && arch == 'x64') || arch == 'ia32') { if ((isTrue(options, 'withIa32') && arch == 'x64') || arch == 'ia32') {
await build(Platform.WINDOWS, Arch.ia32, config) await build(Platform.WINDOWS, Arch.ia32, config)
fs.renameSync( fs.renameSync(
`../build/TheDesk ${version}.exe`, `../build/TheDesk ${version}.exe`,
@ -133,7 +137,7 @@ async function cmd() {
'../build/TheDesk.exe' '../build/TheDesk.exe'
) )
} }
if (isTrue('withArm64')) { if ((isTrue(options, 'withArm64') && arch == 'x64') || arch == 'arm64') {
await build(Platform.WINDOWS, Arch.arm64, config) await build(Platform.WINDOWS, Arch.arm64, config)
fs.renameSync( fs.renameSync(
`../build/TheDesk ${version}.exe`, `../build/TheDesk ${version}.exe`,
@ -148,7 +152,7 @@ async function cmd() {
if (arch == 'ia32') { if (arch == 'ia32') {
await build(Platform.LINUX, Arch.ia32, config) await build(Platform.LINUX, Arch.ia32, config)
} }
if ((isTrue('withIa32') && arch == 'x64')) { if (isTrue(options, 'withIa32') && arch == 'x64') {
console.log('snapcraft does not curretly support builing i386 on amd64') console.log('snapcraft does not curretly support builing i386 on amd64')
} }
if (arch == 'x64') { if (arch == 'x64') {
@ -157,7 +161,7 @@ async function cmd() {
`../build/thedesk_${version}_amd64.snap`, `../build/thedesk_${version}_amd64.snap`,
`../build/thedesk_${version}_amd64-normal.snap` `../build/thedesk_${version}_amd64-normal.snap`
) )
if (isTrue('onlyStore') || isTrue('withStore')) { if (isTrue(options, 'onlyStore') || isTrue(options, 'withStore')) {
fs.renameSync( fs.renameSync(
`../build/thedesk_${version}_amd64-store.snap`, `../build/thedesk_${version}_amd64-store.snap`,
`../build/thedesk_${version}_amd64.snap` `../build/thedesk_${version}_amd64.snap`
@ -171,10 +175,42 @@ async function cmd() {
} }
} }
} }
function isTrue(long, short) { function isTrue(options, long, short) {
const { argv } = process const { argv } = process
if (options ? options[long] : 0) return true
if (argv.includes(`--${long}`)) return true if (argv.includes(`--${long}`)) return true
if (short && argv.includes(`-${short}`)) return true if (short && argv.includes(`-${short}`)) return true
return false return false
} }
cmd() function help() {
return `
TheDesk Builder command tool
yarn build [options] (or node build.js [options])
yarn build:[preset] (check package.json)
--help or -h: show help
--onlyStore: App Store of platforms assets(without update check)
--withStore: App Store assets and normal version
[only Windows]
if you pass these args on Linux or macOS, it just will be ignored...
--withIa32: ia32 build on x64 system(if your machine is ia32, it will be built if this arg is not passed)
--withArm64(beta) arm64 build on x64 system(if your machine is arm64, it will be built if this arg is not passed, and not build store build for arm64)
Programatic usage
`
}
/**
* Builder
* @module builder
* @param {Object} [options] - Options
* @param {boolean} [options.onlyStore] - App Store of platforms assets(without update check)
* @param {boolean} [options.withStore] - App Store of platforms assets(without update check) assets and normal version
* @param {boolean} [options.withIa32] - [Windows only] ia32 build on x64 system(if your machine is ia32, it will be built if this arg is not passed)
* @param {boolean} [options.withArm64] - [Windows only(beta)] arm64 build on x64 system(if your machine is arm64, it will be built if this arg is not passed, and not build store build for arm64)
* @return {void}
*/
module.exports = cmd

2
app/buildCli.js Normal file
View File

@ -0,0 +1,2 @@
const cmd = require('./build')
cmd()

View File

@ -15,10 +15,10 @@
"dev": "run-p dev:*", "dev": "run-p dev:*",
"dev:run": "electron ./ --dev", "dev:run": "electron ./ --dev",
"dev:watchview": "node view/make/makeCli.js --watch", "dev:watchview": "node view/make/makeCli.js --watch",
"build": "node build.js", "build": "node buildCli.js",
"build:pwa": "node view/make/makeCli.js --pwa", "build:pwa": "node view/make/makeCli.js --pwa",
"build:all:x64": "node build.js --withStore", "build:all:x64": "node buildCli.js --withStore",
"build:all": "node build.js --withStore --withIa32", "build:all": "node buildCli.js --withStore --withIa32 --withArm64",
"lint:fix": "eslint js --fix", "lint:fix": "eslint js --fix",
"lint": "eslint js" "lint": "eslint js"
}, },
@ -84,8 +84,7 @@
"eslint": "^7.23.0", "eslint": "^7.23.0",
"npm-run-all": "^4.1.5", "npm-run-all": "^4.1.5",
"readline-sync": "1.4.10", "readline-sync": "1.4.10",
"ts-node": "^9.1.1", "ts-node": "^9.1.1"
"typescript": "^4.2.4"
}, },
"resolutions": { "resolutions": {
"@types/fs-extra": "9.0.11" "@types/fs-extra": "9.0.11"

2
app/view/make/make.d.ts vendored Normal file
View File

@ -0,0 +1,2 @@
export = construct;
declare function construct(ver: any, basefile: any, pwa: any, store: any): void;

View File

@ -26,7 +26,7 @@
<body class=""> <body class="">
<script> <script>
var ver = '22.1.2 (Koume)' var ver = '22.1.2 (Koume)'
var gitHash = '4e2f3ad68a68c0b3c180d9106502d8324939b838' var gitHash = '8621b66203e37ac2dd1e6bc6efd861fe9a8e6891'
//betaを入れるとバージョンチェックしない //betaを入れるとバージョンチェックしない
//var ver="beta"; //var ver="beta";
var acct_id = 0 var acct_id = 0

View File

@ -609,7 +609,7 @@
style="width:100%; max-width:40rem;"><img src="../../img/desk_full.svg" class="left" width="25" style="width:100%; max-width:40rem;"><img src="../../img/desk_full.svg" class="left" width="25"
style="padding-top:5px;">Main author: Cutls@cutls.com</a> style="padding-top:5px;">Main author: Cutls@cutls.com</a>
<br> <br>
TheDesk @ <a href="https://github.com/cutls/TheDesk/commits/4e2f3ad68a68c0b3c180d9106502d8324939b838">4e2f3ad68a68c0b3c180d9106502d8324939b838</a> - <a TheDesk @ <a href="https://github.com/cutls/TheDesk/commits/8621b66203e37ac2dd1e6bc6efd861fe9a8e6891">8621b66203e37ac2dd1e6bc6efd861fe9a8e6891</a> - <a
onclick="checkupd(); return localStorage.removeItem('new-ver-skip'); location.href='index.html';" onclick="checkupd(); return localStorage.removeItem('new-ver-skip'); location.href='index.html';"
class="pointer pwa">Sprawdź aktualizacje</a><br> class="pointer pwa">Sprawdź aktualizacje</a><br>
<br> <br>
@ -619,7 +619,7 @@
<img src="https://status.cutls.com/badge-service?site=thedesk.top"> <img src="https://status.cutls.com/badge-service?site=thedesk.top">
</a><br> </a><br>
<h5>OSS License</h5> <h5>OSS License</h5>
<a href="https://app.fossa.com/projects/git%2Bgithub.com%2Fcutls%2FTheDesk/refs/branch/master/4e2f3ad68a68c0b3c180d9106502d8324939b838" <a href="https://app.fossa.com/projects/git%2Bgithub.com%2Fcutls%2FTheDesk/refs/branch/master/8621b66203e37ac2dd1e6bc6efd861fe9a8e6891"
alt="FOSSA Status"><img alt="FOSSA Status"><img
src="https://app.fossa.com/api/projects/git%2Bgithub.com%2Fcutls%2FTheDesk.svg?type=small" /></a> src="https://app.fossa.com/api/projects/git%2Bgithub.com%2Fcutls%2FTheDesk.svg?type=small" /></a>
<br> <br>