UNPKG

2.11 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3const tslib_1 = require("tslib");
4const command_1 = require("@oclif/command");
5const fs = require("fs");
6const path = require("path");
7const base_command_1 = require("../../base-command");
8const decorators_1 = require("../../utils/decorators");
9const helpers_1 = require("../../utils/helpers");
10class GenerateSpec extends base_command_1.default {
11 async run() {
12 const { flags } = this.parse(GenerateSpec);
13 const targetFolder = this.locator.integrationRoot;
14 if (flags.force || !specExists(targetFolder)) {
15 try {
16 const setup = `
17 {
18 classname: 'SetupAction',
19 isRoot: true,
20 initialTagName: 'setup-action',
21 name: 'setup-action',
22 label: 'Setup Action Component'
23 },
24 {
25 classname: 'SetupDisplay',
26 isRoot: true,
27 initialTagName: 'setup-view',
28 name: 'setup-view',
29 label: 'Setup Display Component'
30 },`;
31 const authType = this.integrationAuthConfig.authType;
32 const vars = authType === 'noAuth' || authType === 'NONE' ? {} : { setup };
33 await helpers_1.copyFiles(this, 'generate/integration_specs', targetFolder, vars);
34 this.success('Spec file successfully generated! 🎉');
35 }
36 catch (e) {
37 this.error(e);
38 }
39 }
40 else {
41 this.warn('Spec file already exists, use --force flag to overwrite existing one.');
42 }
43 }
44}
45GenerateSpec.description = 'Generate spec file for bearer integration';
46GenerateSpec.hidden = true;
47GenerateSpec.flags = Object.assign({}, base_command_1.default.flags, { force: command_1.flags.boolean({}) });
48GenerateSpec.args = [];
49tslib_1.__decorate([
50 decorators_1.RequireIntegrationFolder()
51], GenerateSpec.prototype, "run", null);
52exports.default = GenerateSpec;
53// Note: using Or condition in case the developer delete one but customized the other component
54function specExists(location) {
55 return fs.existsSync(path.join(location, 'spec.ts'));
56}