UNPKG

1.61 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 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}
28GenerateSpec.description = 'Generate spec file for bearer integration';
29GenerateSpec.hidden = true;
30GenerateSpec.flags = Object.assign({}, base_command_1.default.flags, { force: command_1.flags.boolean({}) });
31GenerateSpec.args = [];
32tslib_1.__decorate([
33 decorators_1.skipIfNoViews(),
34 decorators_1.RequireIntegrationFolder()
35], GenerateSpec.prototype, "run", null);
36exports.default = GenerateSpec;
37// Note: using Or condition in case the developer delete one but customized the other component
38function specExists(location) {
39 return fs.existsSync(path.join(location, 'spec.ts'));
40}