1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | const tslib_1 = require("tslib");
|
4 | const command_1 = require("@oclif/command");
|
5 | const fs = require("fs");
|
6 | const path = require("path");
|
7 | const base_command_1 = require("../../base-command");
|
8 | const decorators_1 = require("../../utils/decorators");
|
9 | const helpers_1 = require("../../utils/helpers");
|
10 | class 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 | }
|
45 | GenerateSpec.description = 'Generate spec file for bearer integration';
|
46 | GenerateSpec.hidden = true;
|
47 | GenerateSpec.flags = Object.assign({}, base_command_1.default.flags, { force: command_1.flags.boolean({}) });
|
48 | GenerateSpec.args = [];
|
49 | tslib_1.__decorate([
|
50 | decorators_1.RequireIntegrationFolder()
|
51 | ], GenerateSpec.prototype, "run", null);
|
52 | exports.default = GenerateSpec;
|
53 |
|
54 | function specExists(location) {
|
55 | return fs.existsSync(path.join(location, 'spec.ts'));
|
56 | }
|