mirror of
https://github.com/anidl/multi-downloader-nx.git
synced 2026-03-11 17:45:30 +00:00
Build GUI and CLI
This commit is contained in:
parent
6fabaf489e
commit
0a948788a4
6 changed files with 70 additions and 1163 deletions
10
.github/workflows/release-matrix.yml
vendored
10
.github/workflows/release-matrix.yml
vendored
|
|
@ -6,14 +6,12 @@ on:
|
|||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
build_type: [ linux64, macos64, win64 ]
|
||||
build_type: [ ubuntu, macos, windows ]
|
||||
gui: [ true, false ]
|
||||
runs-on: ${{ matrix.build_type }}-latest
|
||||
steps:
|
||||
- name: Set build type
|
||||
run: |
|
||||
echo BUILD_TYPE=${{ matrix.build_type }} >> $GITHUB_ENV
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
|
||||
|
|
@ -35,7 +33,7 @@ jobs:
|
|||
echo PACKAGE_NAME=$(node -p -e "require('./package.json').name") >> $GITHUB_ENV &&
|
||||
echo PACKAGE_VERSION=$(node -p -e "require('./package.json').version") >> $GITHUB_ENV || exit 1
|
||||
- name: Make build
|
||||
run: npm run build-${{ env.BUILD_TYPE }}
|
||||
run: npm run build-${{ matrix.build_type }}-${{ matrix.gui }}
|
||||
|
||||
- name: Upload release
|
||||
uses: actions/upload-release-asset@v1
|
||||
|
|
|
|||
1144
gui/react/package-lock.json
generated
1144
gui/react/package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
|
@ -11,7 +11,6 @@
|
|||
"@testing-library/jest-dom": "^5.16.1",
|
||||
"@testing-library/react": "^12.1.2",
|
||||
"@testing-library/user-event": "^13.5.0",
|
||||
"@types/electron": "^1.6.10",
|
||||
"@types/jest": "^27.4.0",
|
||||
"@types/node": "^16.11.21",
|
||||
"@types/react": "^17.0.38",
|
||||
|
|
|
|||
|
|
@ -8,11 +8,25 @@ import { execSync } from 'child_process';
|
|||
const buildsDir = './_builds';
|
||||
const nodeVer = 'node16-';
|
||||
|
||||
(async () => {
|
||||
const buildType = process.argv[2];
|
||||
const isGUI = process.argv[3] === 'true';
|
||||
|
||||
if (isGUI) {
|
||||
buildGUI();
|
||||
} else {
|
||||
buildBinary(buildType);
|
||||
}
|
||||
})();
|
||||
|
||||
async function buildGUI() {
|
||||
execSync('npx electron-forge make');
|
||||
}
|
||||
|
||||
// main
|
||||
(async function(){
|
||||
async function buildBinary(buildType: string) {
|
||||
const buildStr = `${pkg.name}-${pkg.version}`;
|
||||
const acceptableBuilds = ['win64','linux64','macos64'];
|
||||
const buildType = process.argv[2];
|
||||
if(!acceptableBuilds.includes(buildType)){
|
||||
console.error('[ERROR] unknown build type!');
|
||||
process.exit(1);
|
||||
|
|
@ -54,7 +68,7 @@ const nodeVer = 'node16-';
|
|||
fs.removeSync(`${buildsDir}/${buildFull}.7z`);
|
||||
}
|
||||
execSync(`7z a -t7z "${buildsDir}/${buildFull}.7z" "${buildDir}"`,{stdio:[0,1,2]});
|
||||
}());
|
||||
};
|
||||
|
||||
function getTarget(bt: string) : string {
|
||||
switch(bt){
|
||||
|
|
|
|||
18
package.json
18
package.json
|
|
@ -76,12 +76,18 @@
|
|||
"start": "cd lib && electron-forge start",
|
||||
"docs": "ts-node modules/build-docs.ts",
|
||||
"tsc": "ts-node tsc.ts",
|
||||
"prebuild-win64": "npm run tsc",
|
||||
"prebuild-linux64": "npm run tsc",
|
||||
"prebuild-macos64": "npm run tsc",
|
||||
"build-win64": "cd lib && node modules/build win64",
|
||||
"build-linux64": "cd lib && node modules/build linux64",
|
||||
"build-macos64": "cd lib && node modules/build macos64",
|
||||
"prebuild-windows-false": "npm run tsc false false",
|
||||
"prebuild-ubuntu-false": "npm run tsc false false",
|
||||
"prebuild-macos-false": "npm run tsc false false",
|
||||
"build-windows-false": "cd lib && node modules/build win64",
|
||||
"build-ubuntu-false": "cd lib && node modules/build linux64",
|
||||
"build-macos-false": "cd lib && node modules/build macos64",
|
||||
"prebuild-windows-true": "npm run tsc",
|
||||
"prebuild-ubuntu-true": "npm run tsc",
|
||||
"prebuild-macos-true": "npm run tsc",
|
||||
"build-windows-true": "cd lib && node modules/build true",
|
||||
"build-ubuntu-true": "cd lib && node modules/build true",
|
||||
"build-macos-true": "cd lib && node modules/build true",
|
||||
"eslint": "eslint *.js modules",
|
||||
"eslint-fix": "eslint *.js modules --fix",
|
||||
"pretest": "npm run tsc",
|
||||
|
|
|
|||
40
tsc.ts
40
tsc.ts
|
|
@ -1,18 +1,27 @@
|
|||
import { ChildProcess, exec } from 'child_process';
|
||||
import fs from 'fs';
|
||||
import fs from 'fs-extra';
|
||||
import path from 'path';
|
||||
import { removeSync, copyFileSync } from 'fs-extra';
|
||||
import packageJSON from './package.json';
|
||||
|
||||
const argv = process.argv.slice(2);
|
||||
let buildIgnore: string[] = [];
|
||||
|
||||
const isTest = argv.length > 0 && argv[0] === 'test';
|
||||
const isGUI = !(argv.length > 1 && argv[1] === 'false');
|
||||
|
||||
if (!isTest)
|
||||
buildIgnore = [
|
||||
'*/\\.env'
|
||||
'*/\\.env',
|
||||
'*/node_modules/*'
|
||||
];
|
||||
|
||||
if (!isGUI)
|
||||
buildIgnore = buildIgnore.concat([
|
||||
'./gui*'
|
||||
])
|
||||
|
||||
|
||||
const ignore = [
|
||||
...buildIgnore,
|
||||
'*/\\.git*',
|
||||
|
|
@ -50,8 +59,14 @@ export { ignore };
|
|||
|
||||
await waitForProcess(tsc);
|
||||
|
||||
if (!isTest) {
|
||||
if (!isGUI) {
|
||||
fs.emptyDirSync(path.join('lib', 'gui'));
|
||||
fs.rmdirSync(path.join('lib', 'gui'));
|
||||
}
|
||||
|
||||
if (!isTest && isGUI) {
|
||||
process.stdout.write('✓\nBuilding react... ');
|
||||
|
||||
const installReactDependencies = exec('npm install', {
|
||||
cwd: path.join(__dirname, 'gui', 'react'),
|
||||
});
|
||||
|
|
@ -64,9 +79,9 @@ export { ignore };
|
|||
|
||||
await waitForProcess(react);
|
||||
}
|
||||
|
||||
|
||||
process.stdout.write('✓\nCopying files... ');
|
||||
if (!isTest) {
|
||||
if (!isTest && isGUI) {
|
||||
copyDir(path.join(__dirname, 'gui', 'react', 'build'), path.join(__dirname, 'lib', 'gui', 'electron', 'build'));
|
||||
}
|
||||
|
||||
|
|
@ -80,9 +95,24 @@ export { ignore };
|
|||
copyFileSync(item.path, itemPath);
|
||||
}
|
||||
});
|
||||
|
||||
process.stdout.write('✓\nInstalling dependencies');
|
||||
if (!isTest && !isGUI) {
|
||||
alterJSON();
|
||||
}
|
||||
const dependencies = exec(`npm install ${isGUI ? '' : '--production'}`, {
|
||||
cwd: path.join(__dirname, 'lib')
|
||||
});
|
||||
await waitForProcess(dependencies);
|
||||
|
||||
process.stdout.write('✓\n');
|
||||
})();
|
||||
|
||||
function alterJSON() {
|
||||
packageJSON.main = 'index.js';
|
||||
fs.writeFileSync(path.join('lib', 'package.json'), JSON.stringify(packageJSON, null, 4));
|
||||
}
|
||||
|
||||
function readDir (dir: string): {
|
||||
path: string,
|
||||
stats: fs.Stats
|
||||
|
|
|
|||
Loading…
Reference in a new issue