UNPKG

3.35 kBJavaScriptView Raw
1"use strict";
2// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
3// See LICENSE in the project root for license information.
4var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
5 if (k2 === undefined) k2 = k;
6 var desc = Object.getOwnPropertyDescriptor(m, k);
7 if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
8 desc = { enumerable: true, get: function() { return m[k]; } };
9 }
10 Object.defineProperty(o, k2, desc);
11}) : (function(o, m, k, k2) {
12 if (k2 === undefined) k2 = k;
13 o[k2] = m[k];
14}));
15var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
16 Object.defineProperty(o, "default", { enumerable: true, value: v });
17}) : function(o, v) {
18 o["default"] = v;
19});
20var __importStar = (this && this.__importStar) || function (mod) {
21 if (mod && mod.__esModule) return mod;
22 var result = {};
23 if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
24 __setModuleDefault(result, mod);
25 return result;
26};
27var __importDefault = (this && this.__importDefault) || function (mod) {
28 return (mod && mod.__esModule) ? mod : { "default": mod };
29};
30Object.defineProperty(exports, "__esModule", { value: true });
31exports.InitAction = void 0;
32const colors_1 = __importDefault(require("colors"));
33const path = __importStar(require("path"));
34const node_core_library_1 = require("@rushstack/node-core-library");
35const ts_command_line_1 = require("@rushstack/ts-command-line");
36const ExtractorConfig_1 = require("../api/ExtractorConfig");
37class InitAction extends ts_command_line_1.CommandLineAction {
38 constructor(parser) {
39 super({
40 actionName: 'init',
41 summary: `Create an ${ExtractorConfig_1.ExtractorConfig.FILENAME} config file`,
42 documentation: `Use this command when setting up API Extractor for a new project. It writes an` +
43 ` ${ExtractorConfig_1.ExtractorConfig.FILENAME} config file template with code comments that describe all the settings.` +
44 ` The file will be written in the current directory.`
45 });
46 }
47 onDefineParameters() {
48 // override
49 // No parameters yet
50 }
51 async onExecute() {
52 // override
53 const inputFilePath = path.resolve(__dirname, '../schemas/api-extractor-template.json');
54 const outputFilePath = path.resolve(ExtractorConfig_1.ExtractorConfig.FILENAME);
55 if (node_core_library_1.FileSystem.exists(outputFilePath)) {
56 console.log(colors_1.default.red('The output file already exists:'));
57 console.log('\n ' + outputFilePath + '\n');
58 throw new Error('Unable to write output file');
59 }
60 console.log(colors_1.default.green('Writing file: ') + outputFilePath);
61 node_core_library_1.FileSystem.copyFile({
62 sourcePath: inputFilePath,
63 destinationPath: outputFilePath
64 });
65 console.log('\nThe recommended location for this file is in the project\'s "config" subfolder,\n' +
66 'or else in the top-level folder with package.json.');
67 }
68}
69exports.InitAction = InitAction;
70//# sourceMappingURL=InitAction.js.map
\No newline at end of file