@optimizely/ocp-cli-v2 2.0.4 → 2.0.5-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commands/add/destination.d.ts +12 -0
- package/dist/commands/add/destination.js +106 -0
- package/dist/commands/add/destination.js.map +1 -0
- package/dist/commands/add/function.d.ts +11 -0
- package/dist/commands/add/function.js +71 -0
- package/dist/commands/add/function.js.map +1 -0
- package/dist/commands/add/job.d.ts +11 -0
- package/dist/commands/add/job.js +71 -0
- package/dist/commands/add/job.js.map +1 -0
- package/dist/commands/add/source.d.ts +12 -0
- package/dist/commands/add/source.js +93 -0
- package/dist/commands/add/source.js.map +1 -0
- package/dist/commands/app/init.d.ts +16 -0
- package/dist/commands/app/init.js +129 -21
- package/dist/commands/app/init.js.map +1 -1
- package/dist/commands/app/register.d.ts +7 -0
- package/dist/commands/app/register.js +26 -4
- package/dist/commands/app/register.js.map +1 -1
- package/dist/commands/app/setLogLevel.js +1 -0
- package/dist/commands/app/setLogLevel.js.map +1 -1
- package/dist/commands/autocomplete/options.d.ts +18 -0
- package/dist/commands/autocomplete/options.js +228 -0
- package/dist/commands/autocomplete/options.js.map +1 -0
- package/dist/commands/env/set.js +1 -0
- package/dist/commands/env/set.js.map +1 -1
- package/dist/commands/jobs/list.js +3 -0
- package/dist/commands/jobs/list.js.map +1 -1
- package/dist/hooks/autocomplete-refresh.d.ts +3 -0
- package/dist/hooks/autocomplete-refresh.js +11 -0
- package/dist/hooks/autocomplete-refresh.js.map +1 -0
- package/dist/hooks/postrun-autocomplete-patch.d.ts +8 -0
- package/dist/hooks/postrun-autocomplete-patch.js +274 -0
- package/dist/hooks/postrun-autocomplete-patch.js.map +1 -0
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/lib/autocomplete/cache.d.ts +5 -0
- package/dist/lib/autocomplete/cache.js +88 -0
- package/dist/lib/autocomplete/cache.js.map +1 -0
- package/dist/lib/autocomplete/completions.d.ts +22 -0
- package/dist/lib/autocomplete/completions.js +144 -0
- package/dist/lib/autocomplete/completions.js.map +1 -0
- package/dist/lib/autocomplete/spinner.d.ts +16 -0
- package/dist/lib/autocomplete/spinner.js +50 -0
- package/dist/lib/autocomplete/spinner.js.map +1 -0
- package/dist/lib/autocomplete/types.d.ts +13 -0
- package/dist/lib/autocomplete/types.js +3 -0
- package/dist/lib/autocomplete/types.js.map +1 -0
- package/dist/lib/autocomplete/warm-cache.d.ts +6 -0
- package/dist/lib/autocomplete/warm-cache.js +83 -0
- package/dist/lib/autocomplete/warm-cache.js.map +1 -0
- package/dist/lib/scaffolding/appYml.d.ts +23 -0
- package/dist/lib/scaffolding/appYml.js +110 -0
- package/dist/lib/scaffolding/appYml.js.map +1 -0
- package/dist/lib/scaffolding/files.d.ts +10 -0
- package/dist/lib/scaffolding/files.js +45 -0
- package/dist/lib/scaffolding/files.js.map +1 -0
- package/dist/lib/scaffolding/naming.d.ts +12 -0
- package/dist/lib/scaffolding/naming.js +32 -0
- package/dist/lib/scaffolding/naming.js.map +1 -0
- package/dist/lib/scaffolding/templates.d.ts +9 -0
- package/dist/lib/scaffolding/templates.js +128 -0
- package/dist/lib/scaffolding/templates.js.map +1 -0
- package/dist/oclif.manifest.json +431 -51
- package/package.json +6 -3
- package/dist/lib/suggestDisplayName.test.d.ts +0 -1
- package/dist/lib/suggestDisplayName.test.js +0 -44
- package/dist/lib/suggestDisplayName.test.js.map +0 -1
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Command } from '@oclif/core';
|
|
2
|
+
export default class AddDestination extends Command {
|
|
3
|
+
static description: string;
|
|
4
|
+
static flags: {
|
|
5
|
+
name: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
6
|
+
description: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
7
|
+
schema: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
8
|
+
'schema-name': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
9
|
+
};
|
|
10
|
+
run(): Promise<void>;
|
|
11
|
+
private resolveName;
|
|
12
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const chalk = require("chalk");
|
|
4
|
+
const core_1 = require("@oclif/core");
|
|
5
|
+
const prompts_1 = require("@inquirer/prompts");
|
|
6
|
+
const appYml_1 = require("../../lib/scaffolding/appYml");
|
|
7
|
+
const naming_1 = require("../../lib/scaffolding/naming");
|
|
8
|
+
const files_1 = require("../../lib/scaffolding/files");
|
|
9
|
+
const templates_1 = require("../../lib/scaffolding/templates");
|
|
10
|
+
const die_1 = require("../../lib/die");
|
|
11
|
+
const formatError_1 = require("../../lib/formatError");
|
|
12
|
+
const path = require("path");
|
|
13
|
+
class AddDestination extends core_1.Command {
|
|
14
|
+
async run() {
|
|
15
|
+
var _a, _b, _c;
|
|
16
|
+
try {
|
|
17
|
+
const { flags } = await this.parse(AddDestination);
|
|
18
|
+
const appRoot = (0, appYml_1.requireAppRoot)();
|
|
19
|
+
const name = await this.resolveName(flags.name);
|
|
20
|
+
const description = (_a = flags.description) !== null && _a !== void 0 ? _a : await (0, prompts_1.input)({ message: 'Destination description:', default: '' });
|
|
21
|
+
const schemaType = (_b = flags.schema) !== null && _b !== void 0 ? _b : await (0, prompts_1.select)({
|
|
22
|
+
message: 'Schema type:',
|
|
23
|
+
choices: [
|
|
24
|
+
{ name: 'static - YAML schema file', value: 'static' },
|
|
25
|
+
{ name: 'dynamic - TypeScript schema function', value: 'dynamic' },
|
|
26
|
+
],
|
|
27
|
+
});
|
|
28
|
+
const doc = (0, appYml_1.readAppYml)(appRoot);
|
|
29
|
+
if ((0, appYml_1.componentExists)(doc, 'destinations', name)) {
|
|
30
|
+
(0, die_1.die)(`Destination '${name}' already exists in app.yml`);
|
|
31
|
+
}
|
|
32
|
+
const className = (0, naming_1.toPascalCase)(name);
|
|
33
|
+
const sourceDir = (0, files_1.detectSourceDir)(appRoot);
|
|
34
|
+
const entry = {
|
|
35
|
+
entry_point: className,
|
|
36
|
+
description,
|
|
37
|
+
};
|
|
38
|
+
if (schemaType === 'dynamic') {
|
|
39
|
+
const schemaClassName = (_c = flags['schema-name']) !== null && _c !== void 0 ? _c : await (0, prompts_1.input)({ message: 'Schema class name:', default: (0, naming_1.toPascalCase)(name) + 'Schema' });
|
|
40
|
+
const schemaDisplayName = schemaClassName.replace(/([a-z])([A-Z])/g, '$1 $2');
|
|
41
|
+
entry.schema = { entry_point: schemaClassName };
|
|
42
|
+
const schemaFilePath = path.join(sourceDir, 'destinations', `${schemaClassName}.ts`);
|
|
43
|
+
const tmpl = (0, templates_1.destinationSchemaFunctionTemplate)(schemaClassName, name, schemaDisplayName);
|
|
44
|
+
if (!(0, files_1.writeScaffoldFile)(schemaFilePath, tmpl)) {
|
|
45
|
+
this.log(chalk.yellow(`File already exists: ${schemaFilePath}`));
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
this.log(chalk.gray(`Created ${schemaFilePath}`));
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
const schemaName = flags['schema-name']
|
|
53
|
+
? (0, naming_1.toSnakeCase)(flags['schema-name'])
|
|
54
|
+
: await (0, prompts_1.input)({ message: 'Schema file name:', default: name });
|
|
55
|
+
const schemaDisplayName = (0, naming_1.toPascalCase)(schemaName).replace(/([a-z])([A-Z])/g, '$1 $2');
|
|
56
|
+
entry.schema = schemaName;
|
|
57
|
+
const schemaFilePath = path.join(sourceDir, 'destinations', 'schema', `${schemaName}.yml`);
|
|
58
|
+
if (!(0, files_1.writeScaffoldFile)(schemaFilePath, (0, templates_1.schemaYmlTemplate)(schemaName, schemaDisplayName))) {
|
|
59
|
+
this.log(chalk.yellow(`File already exists: ${schemaFilePath}`));
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
this.log(chalk.gray(`Created ${schemaFilePath}`));
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
// Create the destination handler class
|
|
66
|
+
const handlerFilePath = path.join(sourceDir, 'destinations', `${className}.ts`);
|
|
67
|
+
if (!(0, files_1.writeScaffoldFile)(handlerFilePath, (0, templates_1.destinationTemplate)(className))) {
|
|
68
|
+
this.log(chalk.yellow(`File already exists: ${handlerFilePath}`));
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
this.log(chalk.gray(`Created ${handlerFilePath}`));
|
|
72
|
+
}
|
|
73
|
+
(0, appYml_1.addComponent)(doc, 'destinations', name, entry);
|
|
74
|
+
(0, appYml_1.writeAppYml)(appRoot, doc);
|
|
75
|
+
this.log(chalk.green(`Destination '${name}' added to app.yml`));
|
|
76
|
+
}
|
|
77
|
+
catch (error) {
|
|
78
|
+
if ((error === null || error === void 0 ? void 0 : error.name) === 'ExitPromptError') {
|
|
79
|
+
(0, die_1.die)((0, formatError_1.formatError)(new Error('Command interrupted. No changes were made')));
|
|
80
|
+
}
|
|
81
|
+
(0, die_1.die)((0, formatError_1.formatError)(error));
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
async resolveName(flagValue) {
|
|
85
|
+
let name = flagValue ? (0, naming_1.toSnakeCase)(flagValue) : '';
|
|
86
|
+
if (!name) {
|
|
87
|
+
name = (0, naming_1.toSnakeCase)(await (0, prompts_1.input)({ message: 'Destination name (snake_case):' }));
|
|
88
|
+
}
|
|
89
|
+
if (!(0, naming_1.isValidName)(name)) {
|
|
90
|
+
(0, die_1.die)(`Invalid name '${name}'. Must be snake_case starting with a letter.`);
|
|
91
|
+
}
|
|
92
|
+
return name;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
exports.default = AddDestination;
|
|
96
|
+
AddDestination.description = 'Add a new destination to an OCP app';
|
|
97
|
+
AddDestination.flags = {
|
|
98
|
+
name: core_1.Flags.string({ description: 'Destination name (snake_case)' }),
|
|
99
|
+
description: core_1.Flags.string({ description: 'Destination description' }),
|
|
100
|
+
schema: core_1.Flags.string({
|
|
101
|
+
description: 'Schema type: static (YAML file) or dynamic (TypeScript class)',
|
|
102
|
+
options: ['static', 'dynamic'],
|
|
103
|
+
}),
|
|
104
|
+
'schema-name': core_1.Flags.string({ description: 'Schema file or class name (defaults to destination name)' }),
|
|
105
|
+
};
|
|
106
|
+
//# sourceMappingURL=destination.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"destination.js","sourceRoot":"","sources":["../../../src/commands/add/destination.ts"],"names":[],"mappings":";;AAAA,+BAA+B;AAC/B,sCAA2C;AAC3C,+CAAgD;AAChD,yDAAoH;AACpH,yDAAoF;AACpF,uDAA+E;AAC/E,+DAA0H;AAC1H,uCAAkC;AAClC,uDAAkD;AAClD,6BAA6B;AAE7B,MAAqB,cAAe,SAAQ,cAAO;IAa1C,KAAK,CAAC,GAAG;;QACd,IAAI;YACF,MAAM,EAAC,KAAK,EAAC,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;YAEjD,MAAM,OAAO,GAAG,IAAA,uBAAc,GAAE,CAAC;YAEjC,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YAChD,MAAM,WAAW,GAAG,MAAA,KAAK,CAAC,WAAW,mCAAI,MAAM,IAAA,eAAK,EAAC,EAAC,OAAO,EAAE,0BAA0B,EAAE,OAAO,EAAE,EAAE,EAAC,CAAC,CAAC;YACzG,MAAM,UAAU,GAAG,MAAA,KAAK,CAAC,MAAM,mCAAI,MAAM,IAAA,gBAAM,EAAC;gBAC9C,OAAO,EAAE,cAAc;gBACvB,OAAO,EAAE;oBACP,EAAC,IAAI,EAAE,2BAA2B,EAAE,KAAK,EAAE,QAAQ,EAAC;oB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EAAE,+BAA+B,EAAC,CAAC;IAClE,WAAW,EAAE,YAAK,CAAC,MAAM,CAAC,EAAC,WAAW,EAAE,yBAAyB,EAAC,CAAC;IACnE,MAAM,EAAE,YAAK,CAAC,MAAM,CAAC;QACnB,WAAW,EAAE,+DAA+D;QAC5E,OAAO,EAAE,CAAC,QAAQ,EAAE,SAAS,CAAC;KAC/B,CAAC;IACF,aAAa,EAAE,YAAK,CAAC,MAAM,CAAC,EAAC,WAAW,EAAE,0DAA0D,EAAC,CAAC;CACvG,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Command } from '@oclif/core';
|
|
2
|
+
export default class AddFunction extends Command {
|
|
3
|
+
static description: string;
|
|
4
|
+
static flags: {
|
|
5
|
+
name: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
6
|
+
description: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
7
|
+
global: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
8
|
+
};
|
|
9
|
+
run(): Promise<void>;
|
|
10
|
+
private resolveName;
|
|
11
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const chalk = require("chalk");
|
|
4
|
+
const core_1 = require("@oclif/core");
|
|
5
|
+
const prompts_1 = require("@inquirer/prompts");
|
|
6
|
+
const appYml_1 = require("../../lib/scaffolding/appYml");
|
|
7
|
+
const naming_1 = require("../../lib/scaffolding/naming");
|
|
8
|
+
const files_1 = require("../../lib/scaffolding/files");
|
|
9
|
+
const templates_1 = require("../../lib/scaffolding/templates");
|
|
10
|
+
const die_1 = require("../../lib/die");
|
|
11
|
+
const formatError_1 = require("../../lib/formatError");
|
|
12
|
+
const path = require("path");
|
|
13
|
+
class AddFunction extends core_1.Command {
|
|
14
|
+
async run() {
|
|
15
|
+
var _a;
|
|
16
|
+
try {
|
|
17
|
+
const { flags } = await this.parse(AddFunction);
|
|
18
|
+
const appRoot = (0, appYml_1.requireAppRoot)();
|
|
19
|
+
const name = await this.resolveName(flags.name);
|
|
20
|
+
const description = (_a = flags.description) !== null && _a !== void 0 ? _a : await (0, prompts_1.input)({ message: 'Function description:', default: '' });
|
|
21
|
+
const isGlobal = flags.global;
|
|
22
|
+
const doc = (0, appYml_1.readAppYml)(appRoot);
|
|
23
|
+
if ((0, appYml_1.componentExists)(doc, 'functions', name)) {
|
|
24
|
+
(0, die_1.die)(`Function '${name}' already exists in app.yml`);
|
|
25
|
+
}
|
|
26
|
+
const className = (0, naming_1.toPascalCase)(name);
|
|
27
|
+
const entry = {
|
|
28
|
+
entry_point: className,
|
|
29
|
+
description,
|
|
30
|
+
};
|
|
31
|
+
if (isGlobal) {
|
|
32
|
+
entry.global = true;
|
|
33
|
+
}
|
|
34
|
+
(0, appYml_1.addComponent)(doc, 'functions', name, entry);
|
|
35
|
+
(0, appYml_1.writeAppYml)(appRoot, doc);
|
|
36
|
+
const sourceDir = (0, files_1.detectSourceDir)(appRoot);
|
|
37
|
+
const filePath = path.join(sourceDir, 'functions', `${className}.ts`);
|
|
38
|
+
if (!(0, files_1.writeScaffoldFile)(filePath, (0, templates_1.functionTemplate)(className, isGlobal))) {
|
|
39
|
+
this.log(chalk.yellow(`File already exists: ${filePath}`));
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
this.log(chalk.gray(`Created ${filePath}`));
|
|
43
|
+
}
|
|
44
|
+
this.log(chalk.green(`Function '${name}' added to app.yml`));
|
|
45
|
+
}
|
|
46
|
+
catch (error) {
|
|
47
|
+
if ((error === null || error === void 0 ? void 0 : error.name) === 'ExitPromptError') {
|
|
48
|
+
(0, die_1.die)((0, formatError_1.formatError)(new Error('Command interrupted. No changes were made')));
|
|
49
|
+
}
|
|
50
|
+
(0, die_1.die)((0, formatError_1.formatError)(error));
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
async resolveName(flagValue) {
|
|
54
|
+
let name = flagValue ? (0, naming_1.toSnakeCase)(flagValue) : '';
|
|
55
|
+
if (!name) {
|
|
56
|
+
name = (0, naming_1.toSnakeCase)(await (0, prompts_1.input)({ message: 'Function name (snake_case):' }));
|
|
57
|
+
}
|
|
58
|
+
if (!(0, naming_1.isValidName)(name)) {
|
|
59
|
+
(0, die_1.die)(`Invalid name '${name}'. Must be snake_case starting with a letter.`);
|
|
60
|
+
}
|
|
61
|
+
return name;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
exports.default = AddFunction;
|
|
65
|
+
AddFunction.description = 'Add a new function to an OCP app';
|
|
66
|
+
AddFunction.flags = {
|
|
67
|
+
name: core_1.Flags.string({ description: 'Function name (snake_case)' }),
|
|
68
|
+
description: core_1.Flags.string({ description: 'Function description' }),
|
|
69
|
+
global: core_1.Flags.boolean({ description: 'Use GlobalFunction base class', default: false }),
|
|
70
|
+
};
|
|
71
|
+
//# sourceMappingURL=function.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"function.js","sourceRoot":"","sources":["../../../src/commands/add/function.ts"],"names":[],"mappings":";;AAAA,+BAA+B;AAC/B,sCAA2C;AAC3C,+CAAwC;AACxC,yDAAoH;AACpH,yDAAoF;AACpF,uDAA+E;AAC/E,+DAAiE;AACjE,uCAAkC;AAClC,uDAAkD;AAClD,6BAA6B;AAE7B,MAAqB,WAAY,SAAQ,cAAO;IASvC,KAAK,CAAC,GAAG;;QACd,IAAI;YACF,MAAM,EAAC,KAAK,EAAC,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;YAE9C,MAAM,OAAO,GAAG,IAAA,uBAAc,GAAE,CAAC;YAEjC,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YAChD,MAAM,WAAW,GAAG,MAAA,KAAK,CAAC,WAAW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|
+
static description: string;
|
|
4
|
+
static flags: {
|
|
5
|
+
name: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
6
|
+
description: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
7
|
+
cron: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
8
|
+
};
|
|
9
|
+
run(): Promise<void>;
|
|
10
|
+
private resolveName;
|
|
11
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const chalk = require("chalk");
|
|
4
|
+
const core_1 = require("@oclif/core");
|
|
5
|
+
const prompts_1 = require("@inquirer/prompts");
|
|
6
|
+
const appYml_1 = require("../../lib/scaffolding/appYml");
|
|
7
|
+
const naming_1 = require("../../lib/scaffolding/naming");
|
|
8
|
+
const files_1 = require("../../lib/scaffolding/files");
|
|
9
|
+
const templates_1 = require("../../lib/scaffolding/templates");
|
|
10
|
+
const die_1 = require("../../lib/die");
|
|
11
|
+
const formatError_1 = require("../../lib/formatError");
|
|
12
|
+
const path = require("path");
|
|
13
|
+
class AddJob extends core_1.Command {
|
|
14
|
+
async run() {
|
|
15
|
+
var _a;
|
|
16
|
+
try {
|
|
17
|
+
const { flags } = await this.parse(AddJob);
|
|
18
|
+
const appRoot = (0, appYml_1.requireAppRoot)();
|
|
19
|
+
const name = await this.resolveName(flags.name);
|
|
20
|
+
const description = (_a = flags.description) !== null && _a !== void 0 ? _a : await (0, prompts_1.input)({ message: 'Job description:', default: '' });
|
|
21
|
+
const cron = flags.cron;
|
|
22
|
+
const doc = (0, appYml_1.readAppYml)(appRoot);
|
|
23
|
+
if ((0, appYml_1.componentExists)(doc, 'jobs', name)) {
|
|
24
|
+
(0, die_1.die)(`Job '${name}' already exists in app.yml`);
|
|
25
|
+
}
|
|
26
|
+
const className = (0, naming_1.toPascalCase)(name);
|
|
27
|
+
const entry = {
|
|
28
|
+
entry_point: className,
|
|
29
|
+
description,
|
|
30
|
+
};
|
|
31
|
+
if (cron) {
|
|
32
|
+
entry.cron = cron;
|
|
33
|
+
}
|
|
34
|
+
(0, appYml_1.addComponent)(doc, 'jobs', name, entry);
|
|
35
|
+
(0, appYml_1.writeAppYml)(appRoot, doc);
|
|
36
|
+
const sourceDir = (0, files_1.detectSourceDir)(appRoot);
|
|
37
|
+
const filePath = path.join(sourceDir, 'jobs', `${className}.ts`);
|
|
38
|
+
if (!(0, files_1.writeScaffoldFile)(filePath, (0, templates_1.jobTemplate)(className))) {
|
|
39
|
+
this.log(chalk.yellow(`File already exists: ${filePath}`));
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
this.log(chalk.gray(`Created ${filePath}`));
|
|
43
|
+
}
|
|
44
|
+
this.log(chalk.green(`Job '${name}' added to app.yml`));
|
|
45
|
+
}
|
|
46
|
+
catch (error) {
|
|
47
|
+
if ((error === null || error === void 0 ? void 0 : error.name) === 'ExitPromptError') {
|
|
48
|
+
(0, die_1.die)((0, formatError_1.formatError)(new Error('Command interrupted. No changes were made')));
|
|
49
|
+
}
|
|
50
|
+
(0, die_1.die)((0, formatError_1.formatError)(error));
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
async resolveName(flagValue) {
|
|
54
|
+
let name = flagValue ? (0, naming_1.toSnakeCase)(flagValue) : '';
|
|
55
|
+
if (!name) {
|
|
56
|
+
name = (0, naming_1.toSnakeCase)(await (0, prompts_1.input)({ message: 'Job name (snake_case):' }));
|
|
57
|
+
}
|
|
58
|
+
if (!(0, naming_1.isValidName)(name)) {
|
|
59
|
+
(0, die_1.die)(`Invalid name '${name}'. Must be snake_case starting with a letter.`);
|
|
60
|
+
}
|
|
61
|
+
return name;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
exports.default = AddJob;
|
|
65
|
+
AddJob.description = 'Add a new job to an OCP app';
|
|
66
|
+
AddJob.flags = {
|
|
67
|
+
name: core_1.Flags.string({ description: 'Job name (snake_case)' }),
|
|
68
|
+
description: core_1.Flags.string({ description: 'Job description' }),
|
|
69
|
+
cron: core_1.Flags.string({ description: 'Cron schedule expression (e.g., "0 0 * * *")' }),
|
|
70
|
+
};
|
|
71
|
+
//# sourceMappingURL=job.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"job.js","sourceRoot":"","sources":["../../../src/commands/add/job.ts"],"names":[],"mappings":";;AAAA,+BAA+B;AAC/B,sCAA2C;AAC3C,+CAAwC;AACxC,yDAAoH;AACpH,yDAAoF;AACpF,uDAA+E;AAC/E,+DAA4D;AAC5D,uCAAkC;AAClC,uDAAkD;AAClD,6BAA6B;AAE7B,MAAqB,MAAO,SAAQ,cAAO;IASlC,KAAK,CAAC,GAAG;;QACd,IAAI;YACF,MAAM,EAAC,KAAK,EAAC,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;YAEzC,MAAM,OAAO,GAAG,IAAA,uBAAc,GAAE,CAAC;YAEjC,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YAChD,MAAM,WAAW,GAAG,MAAA,KAAK,CAAC,WAAW,mCAAI,MAAM,IAAA,eAAK,EAAC,EAAC,OAAO,EAAE,kBAAkB,EAAE,OAAO,EAAE,EAAE,EAAC,CAAC,CAAC;YACjG,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC;YAExB,MAAM,GAAG,GAAG,IAAA,mBAAU,EAAC,OAAO,CAAC,CAAC;YAChC,IAAI,IAAA,wBAAe,EAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE;gBACtC,IAAA,SAAG,EAAC,QAAQ,IAAI,6BAA6B,CAAC,CAAC;aAChD;YAED,MAAM,SAAS,GAAG,IAAA,qBAAY,EAAC,IAAI,C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CAAC,IAAA,oBAAW,EAAC,SAAS,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QACnD,IAAI,CAAC,IAAI,EAAE;YACT,IAAI,GAAG,IAAA,oBAAW,EAAC,MAAM,IAAA,eAAK,EAAC,EAAC,OAAO,EAAE,wBAAwB,EAAC,CAAC,CAAC,CAAC;SACtE;QACD,IAAI,CAAC,IAAA,oBAAW,EAAC,IAAI,CAAC,EAAE;YACtB,IAAA,SAAG,EAAC,iBAAiB,IAAI,+CAA+C,CAAC,CAAC;SAC3E;QACD,OAAO,IAAI,CAAC;IACd,CAAC;;AA9DH,yBA+DC;AA9De,kBAAW,GAAG,6BAA6B,CAAC;AAE5C,YAAK,GAAG;IACpB,IAAI,EAAE,YAAK,CAAC,MAAM,CAAC,EAAC,WAAW,EAAE,uBAAuB,EAAC,CAAC;IAC1D,WAAW,EAAE,YAAK,CAAC,MAAM,CAAC,EAAC,WAAW,EAAE,iBAAiB,EAAC,CAAC;IAC3D,IAAI,EAAE,YAAK,CAAC,MAAM,CAAC,EAAC,WAAW,EAAE,8CAA8C,EAAC,CAAC;CAClF,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Command } from '@oclif/core';
|
|
2
|
+
export default class AddSource extends Command {
|
|
3
|
+
static description: string;
|
|
4
|
+
static flags: {
|
|
5
|
+
name: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
6
|
+
description: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
7
|
+
schema: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
8
|
+
'schema-name': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
9
|
+
};
|
|
10
|
+
run(): Promise<void>;
|
|
11
|
+
private resolveName;
|
|
12
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const chalk = require("chalk");
|
|
4
|
+
const core_1 = require("@oclif/core");
|
|
5
|
+
const prompts_1 = require("@inquirer/prompts");
|
|
6
|
+
const appYml_1 = require("../../lib/scaffolding/appYml");
|
|
7
|
+
const naming_1 = require("../../lib/scaffolding/naming");
|
|
8
|
+
const files_1 = require("../../lib/scaffolding/files");
|
|
9
|
+
const templates_1 = require("../../lib/scaffolding/templates");
|
|
10
|
+
const die_1 = require("../../lib/die");
|
|
11
|
+
const formatError_1 = require("../../lib/formatError");
|
|
12
|
+
const path = require("path");
|
|
13
|
+
class AddSource extends core_1.Command {
|
|
14
|
+
async run() {
|
|
15
|
+
var _a, _b, _c;
|
|
16
|
+
try {
|
|
17
|
+
const { flags } = await this.parse(AddSource);
|
|
18
|
+
const appRoot = (0, appYml_1.requireAppRoot)();
|
|
19
|
+
const name = await this.resolveName(flags.name);
|
|
20
|
+
const description = (_a = flags.description) !== null && _a !== void 0 ? _a : await (0, prompts_1.input)({ message: 'Source description:', default: '' });
|
|
21
|
+
const schemaType = (_b = flags.schema) !== null && _b !== void 0 ? _b : await (0, prompts_1.select)({
|
|
22
|
+
message: 'Schema type:',
|
|
23
|
+
choices: [
|
|
24
|
+
{ name: 'static - YAML schema file', value: 'static' },
|
|
25
|
+
{ name: 'dynamic - TypeScript schema function', value: 'dynamic' },
|
|
26
|
+
],
|
|
27
|
+
});
|
|
28
|
+
const doc = (0, appYml_1.readAppYml)(appRoot);
|
|
29
|
+
if ((0, appYml_1.componentExists)(doc, 'sources', name)) {
|
|
30
|
+
(0, die_1.die)(`Source '${name}' already exists in app.yml`);
|
|
31
|
+
}
|
|
32
|
+
const sourceDir = (0, files_1.detectSourceDir)(appRoot);
|
|
33
|
+
const entry = { description };
|
|
34
|
+
if (schemaType === 'dynamic') {
|
|
35
|
+
const schemaClassName = (_c = flags['schema-name']) !== null && _c !== void 0 ? _c : await (0, prompts_1.input)({ message: 'Schema class name:', default: (0, naming_1.toPascalCase)(name) + 'Schema' });
|
|
36
|
+
const displayName = schemaClassName.replace(/([a-z])([A-Z])/g, '$1 $2');
|
|
37
|
+
entry.schema = { entry_point: schemaClassName };
|
|
38
|
+
const filePath = path.join(sourceDir, 'sources', `${schemaClassName}.ts`);
|
|
39
|
+
if (!(0, files_1.writeScaffoldFile)(filePath, (0, templates_1.sourceSchemaFunctionTemplate)(schemaClassName, name, displayName))) {
|
|
40
|
+
this.log(chalk.yellow(`File already exists: ${filePath}`));
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
this.log(chalk.gray(`Created ${filePath}`));
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
const schemaName = flags['schema-name']
|
|
48
|
+
? (0, naming_1.toSnakeCase)(flags['schema-name'])
|
|
49
|
+
: await (0, prompts_1.input)({ message: 'Schema file name:', default: name });
|
|
50
|
+
const displayName = (0, naming_1.toPascalCase)(schemaName).replace(/([a-z])([A-Z])/g, '$1 $2');
|
|
51
|
+
entry.schema = schemaName;
|
|
52
|
+
const filePath = path.join(sourceDir, 'sources', 'schema', `${schemaName}.yml`);
|
|
53
|
+
if (!(0, files_1.writeScaffoldFile)(filePath, (0, templates_1.schemaYmlTemplate)(schemaName, displayName))) {
|
|
54
|
+
this.log(chalk.yellow(`File already exists: ${filePath}`));
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
this.log(chalk.gray(`Created ${filePath}`));
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
(0, appYml_1.addComponent)(doc, 'sources', name, entry);
|
|
61
|
+
(0, appYml_1.writeAppYml)(appRoot, doc);
|
|
62
|
+
this.log(chalk.green(`Source '${name}' added to app.yml`));
|
|
63
|
+
}
|
|
64
|
+
catch (error) {
|
|
65
|
+
if ((error === null || error === void 0 ? void 0 : error.name) === 'ExitPromptError') {
|
|
66
|
+
(0, die_1.die)((0, formatError_1.formatError)(new Error('Command interrupted. No changes were made')));
|
|
67
|
+
}
|
|
68
|
+
(0, die_1.die)((0, formatError_1.formatError)(error));
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
async resolveName(flagValue) {
|
|
72
|
+
let name = flagValue ? (0, naming_1.toSnakeCase)(flagValue) : '';
|
|
73
|
+
if (!name) {
|
|
74
|
+
name = (0, naming_1.toSnakeCase)(await (0, prompts_1.input)({ message: 'Source name (snake_case):' }));
|
|
75
|
+
}
|
|
76
|
+
if (!(0, naming_1.isValidName)(name)) {
|
|
77
|
+
(0, die_1.die)(`Invalid name '${name}'. Must be snake_case starting with a letter.`);
|
|
78
|
+
}
|
|
79
|
+
return name;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
exports.default = AddSource;
|
|
83
|
+
AddSource.description = 'Add a new source to an OCP app';
|
|
84
|
+
AddSource.flags = {
|
|
85
|
+
name: core_1.Flags.string({ description: 'Source name (snake_case)' }),
|
|
86
|
+
description: core_1.Flags.string({ description: 'Source description' }),
|
|
87
|
+
schema: core_1.Flags.string({
|
|
88
|
+
description: 'Schema type: static (YAML file) or dynamic (TypeScript class)',
|
|
89
|
+
options: ['static', 'dynamic'],
|
|
90
|
+
}),
|
|
91
|
+
'schema-name': core_1.Flags.string({ description: 'Schema file or class name (defaults to source name)' }),
|
|
92
|
+
};
|
|
93
|
+
//# sourceMappingURL=source.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"source.js","sourceRoot":"","sources":["../../../src/commands/add/source.ts"],"names":[],"mappings":";;AAAA,+BAA+B;AAC/B,sCAA2C;AAC3C,+CAAgD;AAChD,yDAAoH;AACpH,yDAAoF;AACpF,uDAA+E;AAC/E,+DAAgG;AAChG,uCAAkC;AAClC,uDAAkD;AAClD,6BAA6B;AAE7B,MAAqB,SAAU,SAAQ,cAAO;IAarC,KAAK,CAAC,GAAG;;QACd,IAAI;YACF,MAAM,EAAC,KAAK,EAA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0B,EAAC,CAAC;IAC7D,WAAW,EAAE,YAAK,CAAC,MAAM,CAAC,EAAC,WAAW,EAAE,oBAAoB,EAAC,CAAC;IAC9D,MAAM,EAAE,YAAK,CAAC,MAAM,CAAC;QACnB,WAAW,EAAE,+DAA+D;QAC5E,OAAO,EAAE,CAAC,QAAQ,EAAE,SAAS,CAAC;KAC/B,CAAC;IACF,aAAa,EAAE,YAAK,CAAC,MAAM,CAAC,EAAC,WAAW,EAAE,qDAAqD,EAAC,CAAC;CAClG,CAAC"}
|
|
@@ -6,12 +6,28 @@ export default class Create extends Command {
|
|
|
6
6
|
static args: {
|
|
7
7
|
id: import("@oclif/core/lib/interfaces").Arg<string | undefined, Record<string, unknown>>;
|
|
8
8
|
};
|
|
9
|
+
static flags: {
|
|
10
|
+
'display-name': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
11
|
+
'app-id': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
12
|
+
version: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
13
|
+
summary: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
14
|
+
'support-url': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
15
|
+
'contact-email': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
16
|
+
category: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
17
|
+
template: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
18
|
+
'package-manager': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
19
|
+
directory: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
20
|
+
'no-prompt': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
21
|
+
};
|
|
22
|
+
private static readonly FLAG_TO_VAR;
|
|
9
23
|
private variables;
|
|
10
24
|
private variableId;
|
|
11
25
|
private manifest;
|
|
12
26
|
private substitutions;
|
|
13
27
|
private warnings;
|
|
14
28
|
private packageManager;
|
|
29
|
+
private flagValues;
|
|
30
|
+
private noPrompt;
|
|
15
31
|
run(): Promise<void>;
|
|
16
32
|
private renderTemplate;
|
|
17
33
|
private get variable();
|