-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
/
update-core-mode.ts
73 lines (60 loc) · 2.15 KB
/
update-core-mode.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
/* -----------------------------------------------------------------------------
| Copyright (c) Jupyter Development Team.
| Distributed under the terms of the Modified BSD License.
|----------------------------------------------------------------------------*/
import * as fs from 'fs-extra';
import * as path from 'path';
import * as utils from './utils';
// Run integrity to update the dev_mode package.json
utils.run('jlpm integrity');
// Get the dev mode package.json file.
const data = utils.readJSONFile('./dev_mode/package.json');
// Update the values that need to change and write to staging.
data['jupyterlab']['buildDir'] = './build';
data['jupyterlab']['outputDir'] = '..';
data['jupyterlab']['staticDir'] = '../static';
data['jupyterlab']['linkedPackages'] = {};
const staging = './jupyterlab/staging';
// Ensure a clean staging directory.
const keep = ['yarn.js', '.yarnrc'];
fs.readdirSync(staging).forEach(name => {
if (keep.indexOf(name) === -1) {
fs.removeSync(path.join(staging, name));
}
});
fs.ensureDirSync(staging);
fs.ensureFileSync(path.join(staging, 'package.json'));
utils.writePackageData(path.join(staging, 'package.json'), data);
// Update our staging files.
const notice =
'// This file is auto-generated from the corresponding file in /dev_mode\n';
[
'index.js',
'bootstrap.js',
'publicpath.js',
'webpack.config.js',
'webpack.prod.config.js',
'webpack.prod.minimize.config.js',
'webpack.prod.release.config.js',
'templates'
].forEach(name => {
const dest = path.join('.', 'jupyterlab', 'staging', name);
fs.copySync(path.join('.', 'dev_mode', name), dest);
if (path.extname(name) === '.js') {
const oldContent = fs.readFileSync(dest);
const newContent = notice + oldContent;
fs.writeFileSync(dest, newContent);
}
});
// Create a new yarn.lock file to ensure it is correct.
utils.run('jlpm', { cwd: staging });
try {
utils.run('jlpm yarn-deduplicate -s fewer --fail', { cwd: staging });
} catch {
// re-run install if we deduped packages!
utils.run('jlpm', { cwd: staging });
}
// Build the core assets.
utils.run('jlpm run build:prod:release', { cwd: staging });
// Run integrity
utils.run('jlpm integrity');