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 | await helpers_1.copyFiles(this, 'generate/integration_specs', targetFolder, {});
|
17 | this.success('Spec file successfully generated! 🎉');
|
18 | }
|
19 | catch (e) {
|
20 | this.error(e);
|
21 | }
|
22 | }
|
23 | else {
|
24 | this.warn('Spec file already exists, use --force flag to overwrite existing one.');
|
25 | }
|
26 | }
|
27 | }
|
28 | GenerateSpec.description = 'Generate spec file for bearer integration';
|
29 | GenerateSpec.hidden = true;
|
30 | GenerateSpec.flags = Object.assign({}, base_command_1.default.flags, { force: command_1.flags.boolean({}) });
|
31 | GenerateSpec.args = [];
|
32 | tslib_1.__decorate([
|
33 | decorators_1.skipIfNoViews(),
|
34 | decorators_1.RequireIntegrationFolder()
|
35 | ], GenerateSpec.prototype, "run", null);
|
36 | exports.default = GenerateSpec;
|
37 |
|
38 | function specExists(location) {
|
39 | return fs.existsSync(path.join(location, 'spec.ts'));
|
40 | }
|