Skip to content

Commit 1c876b0

Browse files
committed
Explicitly declare each build task
1 parent 95c074e commit 1c876b0

File tree

2 files changed

+53
-22
lines changed

2 files changed

+53
-22
lines changed

package.json

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,24 @@
99
"type": "git",
1010
"url": "https://github.com/jupyter/nbclassic.git"
1111
},
12-
"scripts": {
13-
"bower:copy-marked": "node tools/copy-marked.js",
14-
"bower": "bower install && npm run bower:copy-marked",
15-
"build": "npm run bower && node tools/build.js",
16-
"build:clean": "node tools/build.js clean",
17-
"build:webpack": "node tools/build.js webpack",
18-
"build:notebook": "node tools/build.js notebook",
19-
"build:css": "node tools/build.js ipythonCss && node tools/build.js styleCss",
20-
"build:translations": "node tools/build.js translations",
21-
"watch": "npm-run-all --parallel watch:*"
22-
},
12+
"scripts": {
13+
"bower:copy-marked": "node tools/copy-marked.js",
14+
"bower": "bower install && npm run bower:copy-marked",
15+
"build:webpack": "node tools/build.js webpack",
16+
"build:notebook": "node tools/build.js notebook",
17+
"build:tree": "node tools/build.js tree",
18+
"build:edit": "node tools/build.js edit",
19+
"build:terminal": "node tools/build.js terminal",
20+
"build:auth": "node tools/build.js auth",
21+
"build:translations": "node tools/build.js translations",
22+
"build:js": "npm run build:notebook && npm run build:tree && npm run build:edit && npm run build:terminal && npm run build:auth && npm run build:translations",
23+
"build:css": "node tools/build.js ipythonCss && node tools/build.js styleCss",
24+
"build": "npm run bower && npm run build:webpack && npm run build:js && npm run build:css",
25+
"build:clean": "node tools/build.js clean",
26+
"watch:css": "onchange 'nbclassic/static/**/*.less' -- npm run build:css",
27+
"watch:js": "onchange 'nbclassic/static/**/!(*.min).js' 'bower.json' -- npm run build:js",
28+
"watch": "npm-run-all --parallel watch:*"
29+
},
2330
"devDependencies": {
2431
"@babel/core": "^7.15.0",
2532
"@babel/preset-env": "^7.15.0",

tools/build.js

Lines changed: 35 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,22 @@ const tasks = {
1010
output: 'nbclassic/static/notebook/js/main.min.js',
1111
command: ['node', 'tools/build-main.js', 'notebook'],
1212
},
13+
tree: {
14+
output: 'nbclassic/static/tree/js/main.min.js',
15+
command: ['node', 'tools/build-main.js', 'tree'],
16+
},
17+
edit: {
18+
output: 'nbclassic/static/edit/js/main.min.js',
19+
command: ['node', 'tools/build-main.js', 'edit'],
20+
},
21+
terminal: {
22+
output: 'nbclassic/static/terminal/js/main.min.js',
23+
command: ['node', 'tools/build-main.js', 'terminal'],
24+
},
25+
auth: {
26+
output: 'nbclassic/static/auth/js/main.min.js',
27+
command: ['node', 'tools/build-main.js', 'auth'],
28+
},
1329
ipythonCss: {
1430
output: 'nbclassic/static/style/ipython.min.css',
1531
command: ['lessc', '--source-map', '--include-path=nbclassic/static/style',
@@ -31,13 +47,11 @@ const tasks = {
3147
const langPath = lang.includes('_') ? lang : lang;
3248
const input = `nbclassic/i18n/${langPath}/LC_MESSAGES/nbjs.po`;
3349
const output = `nbclassic/i18n/${langPath}/LC_MESSAGES/nbjs.json`;
34-
3550
console.log(`Building translation for ${lang}...`);
3651
const proc = spawn('po2json', [
3752
'-p', '-F', '-f', 'jed1.x', '-d', 'nbjs',
3853
input, output
3954
], { stdio: 'inherit' });
40-
4155
await new Promise((resolve, reject) => {
4256
proc.on('close', code => {
4357
if (code === 0) resolve();
@@ -54,7 +68,6 @@ async function runTask(taskName) {
5468
if (!task) {
5569
throw new Error(`Unknown task: ${taskName}`);
5670
}
57-
5871
console.log(`Building ${taskName}...`);
5972
if (task.buildFn) {
6073
await task.buildFn();
@@ -87,15 +100,26 @@ async function clean() {
87100
}
88101
}
89102

103+
// Define the build order explicitly
104+
const buildOrder = [
105+
'webpack',
106+
'notebook',
107+
'tree',
108+
'edit',
109+
'terminal',
110+
'auth',
111+
'translations',
112+
'ipythonCss',
113+
'styleCss'
114+
];
115+
90116
async function runAll() {
91-
for (const taskName of Object.keys(tasks)) {
92-
if (taskName !== 'bower') {
93-
try {
94-
await runTask(taskName);
95-
} catch (err) {
96-
console.error(`Error in task ${taskName}:`, err);
97-
process.exit(1);
98-
}
117+
for (const taskName of buildOrder) {
118+
try {
119+
await runTask(taskName);
120+
} catch (err) {
121+
console.error(`Error in task ${taskName}:`, err);
122+
process.exit(1);
99123
}
100124
}
101125
}

0 commit comments

Comments
 (0)