forked from jupyterlab/jupyterlab
/
create-package.ts
42 lines (39 loc) · 1.24 KB
/
create-package.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
/*-----------------------------------------------------------------------------
| Copyright (c) Jupyter Development Team.
| Distributed under the terms of the Modified BSD License.
|----------------------------------------------------------------------------*/
import * as fs from 'fs-extra';
import * as inquirer from 'inquirer';
import * as path from 'path';
import * as utils from './utils';
let questions = [
{
type: 'input',
name: 'name',
message: 'name: '
},
{
type: 'input',
name: 'description',
message: 'description: '
}
];
inquirer.prompt(questions).then(answers => {
let { name, description } = answers;
let dest = path.resolve(path.join('.', 'packages', name));
if (fs.existsSync(dest)) {
console.error('Package already exists: ', name);
process.exit(1);
}
fs.copySync(path.resolve(path.join(__dirname, '..', 'template')), dest);
let jsonPath = path.join(dest, 'package.json');
let data = utils.readJSONFile(jsonPath);
if (name.indexOf('@jupyterlab/') === -1) {
name = '@jupyterlab/' + name;
}
data.name = name;
data.description = description;
utils.writePackageData(jsonPath, data);
// Use npm here so this file can be used outside of JupyterLab.
utils.run('npm run integrity');
});