UNPKG

2.65 kBJavaScriptView Raw
1"use strict";
2/* -----------------------------------------------------------------------------
3| Copyright (c) Jupyter Development Team.
4| Distributed under the terms of the Modified BSD License.
5|----------------------------------------------------------------------------*/
6var __importStar = (this && this.__importStar) || function (mod) {
7 if (mod && mod.__esModule) return mod;
8 var result = {};
9 if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
10 result["default"] = mod;
11 return result;
12};
13Object.defineProperty(exports, "__esModule", { value: true });
14const fs = __importStar(require("fs-extra"));
15const path = __importStar(require("path"));
16const utils = __importStar(require("./utils"));
17// Run integrity to update the dev_mode package.json
18utils.run('jlpm integrity');
19// Get the dev mode package.json file.
20const data = utils.readJSONFile('./dev_mode/package.json');
21// Update the values that need to change and write to staging.
22data['jupyterlab']['buildDir'] = './build';
23data['jupyterlab']['outputDir'] = '..';
24data['jupyterlab']['staticDir'] = '../static';
25data['jupyterlab']['linkedPackages'] = {};
26const staging = './jupyterlab/staging';
27// Ensure a clean staging directory.
28const keep = ['yarn.js', '.yarnrc'];
29fs.readdirSync(staging).forEach(name => {
30 if (keep.indexOf(name) === -1) {
31 fs.removeSync(path.join(staging, name));
32 }
33});
34fs.ensureDirSync(staging);
35fs.ensureFileSync(path.join(staging, 'package.json'));
36utils.writePackageData(path.join(staging, 'package.json'), data);
37// Update our staging files.
38const notice = '// This file is auto-generated from the corresponding file in /dev_mode\n';
39[
40 'index.js',
41 'webpack.config.js',
42 'webpack.prod.config.js',
43 'webpack.prod.minimize.config.js',
44 'webpack.prod.release.config.js',
45 'templates'
46].forEach(name => {
47 const dest = path.join('.', 'jupyterlab', 'staging', name);
48 fs.copySync(path.join('.', 'dev_mode', name), dest);
49 if (path.extname(name) === '.js') {
50 const oldContent = fs.readFileSync(dest);
51 const newContent = notice + oldContent;
52 fs.writeFileSync(dest, newContent);
53 }
54});
55// Create a new yarn.lock file to ensure it is correct.
56utils.run('jlpm', { cwd: staging });
57try {
58 utils.run('jlpm yarn-deduplicate -s fewer --fail', { cwd: staging });
59}
60catch (_a) {
61 // re-run install if we deduped packages!
62 utils.run('jlpm', { cwd: staging });
63}
64// Build the core assets.
65utils.run('jlpm run build:prod:release', { cwd: staging });
66// Run integrity
67utils.run('jlpm integrity');
68//# sourceMappingURL=update-core-mode.js.map
\No newline at end of file