mirror of
https://github.com/noodlapp/noodl.git
synced 2026-01-10 14:22:51 +01:00
Co-Authored-By: Eric Tuvesson <eric.tuvesson@gmail.com> Co-Authored-By: mikaeltellhed <2311083+mikaeltellhed@users.noreply.github.com> Co-Authored-By: kotte <14197736+mrtamagotchi@users.noreply.github.com> Co-Authored-By: Anders Larsson <64838990+anders-topp@users.noreply.github.com> Co-Authored-By: Johan <4934465+joolsus@users.noreply.github.com> Co-Authored-By: Tore Knudsen <18231882+torekndsn@users.noreply.github.com> Co-Authored-By: victoratndl <99176179+victoratndl@users.noreply.github.com>
91 lines
2.3 KiB
TypeScript
91 lines
2.3 KiB
TypeScript
/// ---------------------------------------------------------------------------
|
|
/// This file is designed to be small, and reflect how GitHub Actions is setup.
|
|
/// ---------------------------------------------------------------------------
|
|
|
|
import { execSync } from 'child_process';
|
|
import { argv } from 'node:process';
|
|
import path from 'path';
|
|
import rimraf from 'rimraf';
|
|
|
|
import { getCurrentPlatform } from './helper';
|
|
|
|
// Inputs
|
|
const [_nodeExecPath, _executedFilePath, ...args] = argv;
|
|
const SKIP_GIT_CHECK = args.includes('--skip-git');
|
|
|
|
const WORKSPACE_PATH = path.resolve(__dirname, '..');
|
|
const TARGET_PLATFORM = process.env.TARGET_PLATFORM || getCurrentPlatform();
|
|
|
|
// Debug Configuration
|
|
console.log('--- Configuration');
|
|
console.log('> WORKSPACE_PATH: ', WORKSPACE_PATH);
|
|
console.log('> TARGET_PLATFORM: ', TARGET_PLATFORM);
|
|
console.log('---');
|
|
|
|
console.log('--- Verify git status');
|
|
if (SKIP_GIT_CHECK) {
|
|
console.log('* --- SKIP GIT CHECK (--skip-git)');
|
|
} else {
|
|
try {
|
|
const gitDiff = execSync('git diff --numstat', {
|
|
env: process.env
|
|
}).toString();
|
|
|
|
if (gitDiff !== '') {
|
|
console.log();
|
|
console.log('--- You have local git changes, please commit them before building.');
|
|
console.log();
|
|
throw new Error();
|
|
}
|
|
} catch (error) {
|
|
console.error('git diff failed.');
|
|
throw error;
|
|
}
|
|
}
|
|
|
|
// Start clean!
|
|
console.log('---> clean');
|
|
execSync('npx lerna clean --yes', {
|
|
stdio: 'inherit',
|
|
env: process.env
|
|
});
|
|
|
|
// Delete dist folders
|
|
console.log("--- delete 'dist' folders");
|
|
rimraf.sync('./dist');
|
|
rimraf.sync('./packages/noodl-editor/dist');
|
|
|
|
// Build Viewer
|
|
console.log('---> build viewer');
|
|
execSync('npm run build:editor:_viewer', {
|
|
stdio: 'inherit',
|
|
env: {
|
|
...process.env,
|
|
WORKSPACE_PATH
|
|
}
|
|
});
|
|
|
|
try {
|
|
// Build Editor
|
|
console.log('---> build editor');
|
|
execSync('npm run build:editor:_editor', {
|
|
stdio: 'inherit',
|
|
env: {
|
|
...process.env,
|
|
WORKSPACE_PATH,
|
|
}
|
|
});
|
|
} catch (error) {
|
|
console.error(error);
|
|
// I would like it to continue and collect the other information,
|
|
// it could be useful for debugging.
|
|
|
|
if (process.platform === 'darwin') {
|
|
// NOTE: /node_modules/app-builder-lib/templates/entitlements.mac.plist is missing
|
|
execSync(`ls /node_modules/app-builder-lib/templates`, {
|
|
stdio: 'inherit',
|
|
env: process.env
|
|
});
|
|
}
|
|
}
|