-
Notifications
You must be signed in to change notification settings - Fork 309
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
65107ae
commit 0f706de
Showing
8 changed files
with
118 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
const { spawn } = require('./spawn') | ||
const path = require('path') | ||
|
||
const base = path.join(__dirname, '../') | ||
process.chdir(base) | ||
async function main() { | ||
const prepareCommands = getCommands(` | ||
yarn install --link-duplicates --frozen-lockfile | ||
yarn lint:report${ | ||
/** | ||
* Let's do a quick TypeScript check. | ||
*/ '' | ||
} | ||
yarn tsc -p tsconfig_cjs.json | ||
sudo apt-get install zip | ||
`) | ||
for (const [commands, ...args] of prepareCommands) { | ||
await spawn(commands, args) | ||
} | ||
const currentBranch = (await getCurrentGITBranchName()).toLowerCase() | ||
for (const [first, ...args] of getCommands(buildTypes(currentBranch))) { | ||
await spawn(first, args) | ||
} | ||
} | ||
main().catch(e => { | ||
console.error(e) | ||
process.exit(1) | ||
}) | ||
|
||
/** | ||
* @param {string} branchName | ||
*/ | ||
function buildTypes(branchName) { | ||
if (branchName.match(/full/)) return getBuildCommand(['base', 'chromium', 'firefox', 'gecko', 'iOS']) | ||
if (branchName.match(/ios/)) return getBuildCommand(['iOS']) | ||
if (branchName.match(/android|gecko/)) return getBuildCommand(['firefox', 'gecko']) | ||
return getBuildCommand(['base', 'chromium', 'firefox']) | ||
} | ||
|
||
/** | ||
* @param {('base' | 'iOS' | 'chromium' | 'firefox' | 'gecko')[]} platforms | ||
*/ | ||
function getBuildCommand(platforms) { | ||
return platforms | ||
.map(x => x.toLowerCase()) | ||
.map(generateCommand) | ||
.join('\n') | ||
function generateCommand(type) { | ||
return ` | ||
yarn build:${type} | ||
cd build | ||
zip -r ../Maskbook.${type}.zip ./* | ||
cd .. | ||
rm -rf build | ||
` | ||
} | ||
} | ||
|
||
async function getCurrentGITBranchName() { | ||
const [git, ...args] = getCommands(`git rev-parse --abbrev-ref HEAD`)[0] | ||
const branch = await spawn(git, args, { stdio: 'pipe' }) | ||
return branch.split('\n')[0] | ||
} | ||
|
||
/** | ||
* @param {string} string | ||
*/ | ||
function getCommands(string) { | ||
return string | ||
.split('\n') | ||
.filter(x => x) | ||
.map(x => x.split(' ').filter(x => x)) | ||
.filter(x => x.length) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters