1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | const identity_1 = require("../../commons/identity");
|
4 | const License_1 = require("../../inc/License");
|
5 | const Fixture_1 = require("../Fixture");
|
6 | const Git_1 = require("../Git");
|
7 | const Log_1 = require("../Log");
|
8 | const ObjectWriter_1 = require("../ObjectWriter");
|
9 | exports.options = {
|
10 | license: {
|
11 | choices: License_1.LICENSE_VALUES,
|
12 | describe: 'License to use',
|
13 | type: 'string'
|
14 | },
|
15 | 'skip-license': {
|
16 | default: false,
|
17 | describe: 'Skip creating a license',
|
18 | type: 'boolean'
|
19 | }
|
20 | };
|
21 | identity_1.addName(exports.options);
|
22 | identity_1.addGhRepo(exports.options);
|
23 | identity_1.addEmail(exports.options);
|
24 | identity_1.addUserWebsite(exports.options);
|
25 | function handle(c) {
|
26 | if (!c.get('skipLicense')) {
|
27 | Log_1.Log.info('Setting license');
|
28 | const tpl = {
|
29 | name: c.promptedName(),
|
30 | year: new Date().getFullYear()
|
31 | };
|
32 | switch (c.promptedLicense()) {
|
33 | case License_1.License.MIT:
|
34 | tpl.email = c.promptedEmail();
|
35 | tpl.url = c.promptedUserWebsite();
|
36 | break;
|
37 | case License_1.License.GPL3:
|
38 | tpl.ghRepo = c.promptedGhRepo();
|
39 | }
|
40 | new Fixture_1.Fixture('init/license')
|
41 | .template(`${c.promptedLicense()}.txt`, tpl, 'LICENSE');
|
42 | new ObjectWriter_1.ObjectWriter('package.json', 0 )
|
43 | .set('license', c.promptedLicense())
|
44 | .save();
|
45 | Git_1.Git.add('LICENSE', 'package.json');
|
46 | Log_1.Log.success('License set');
|
47 | }
|
48 | else {
|
49 | Log_1.Log.info('Skipping license');
|
50 | }
|
51 | }
|
52 | exports.handle = handle;
|