UNPKG

1.71 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3const identity_1 = require("../../commons/identity");
4const License_1 = require("../../inc/License");
5const Fixture_1 = require("../Fixture");
6const Git_1 = require("../Git");
7const Log_1 = require("../Log");
8const ObjectWriter_1 = require("../ObjectWriter");
9exports.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};
21identity_1.addName(exports.options);
22identity_1.addGhRepo(exports.options);
23identity_1.addEmail(exports.options);
24identity_1.addUserWebsite(exports.options);
25function 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 /* JSON */)
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}
52exports.handle = handle;