forked from noodlapp/noodl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild-editor.ts
90 lines (78 loc) · 2.32 KB
/
build-editor.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
/// ---------------------------------------------------------------------------
/// 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
});
}
}