UNPKG

2.31 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3const lodash_1 = require("lodash");
4const identity_1 = require("../../commons/identity");
5const Git_1 = require("../Git");
6const Log_1 = require("../Log");
7const ObjectWriter_1 = require("../ObjectWriter");
8exports.options = {
9 'project-desc': {
10 describe: 'Project description',
11 type: 'string'
12 },
13 'project-keywords': {
14 describe: 'Project keywords',
15 type: 'array'
16 },
17 'project-name': {
18 describe: 'Name of the project',
19 type: 'string'
20 }
21};
22identity_1.addGhUser(exports.options);
23identity_1.addGhRepo(exports.options);
24identity_1.addGhToken(exports.options);
25function handle(c) {
26 const w = new ObjectWriter_1.ObjectWriter('package.json', 0 /* JSON */);
27 function setScripts() {
28 w.set('scripts.pretest', 'rimraf coverage', false);
29 w.set('scripts.test', 'nyc mocha --opts ./mocha.opts', false);
30 w.set(['scripts', 'test:watch'], 'npm --scripts-prepend-node-path=auto run test -- --watch', false);
31 w.set('scripts.tslint', 'alo tslint -p tsconfig.test.json', false);
32 w.set(['scripts', 'tslint:fix'], 'npm --scripts-prepend-node-path=auto run tslint -- --fix', false);
33 w.set('scripts.typecheck', 'tsc --noEmit', false);
34 w.set(['scripts', 'typecheck:watch'], 'npm --scripts-prepend-node-path=auto run typecheck -- --watch', false);
35 w.set('scripts.build', 'alo build', false);
36 }
37 if (!w.has('name')) {
38 w.set('name', c.promptedProjectName());
39 Log_1.Log.success('Set project name');
40 }
41 if (!w.has('version')) {
42 w.set('version', '0.0.1');
43 Log_1.Log.success('Set project version');
44 }
45 if (!w.has('description')) {
46 w.set('description', c.promptedProjectDescription());
47 Log_1.Log.success('Set project description');
48 }
49 if (lodash_1.isEmpty(w.get('keywords'))) {
50 w.set('keywords', c.promptedProjectKeywords());
51 Log_1.Log.success('Set project keywords');
52 }
53 setScripts();
54 if (!w.has('repository') && Git_1.Git.originUrl) {
55 w.set('repository', Git_1.Git.originUrl);
56 Log_1.Log.success('Set repository URL');
57 }
58 w.save();
59 Git_1.Git.add('package.json');
60}
61exports.handle = handle;