@optimizely/ocp-cli-v2 2.0.3 → 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 +133 -32
- 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/lib/suggestDisplayName.d.ts +12 -0
- package/dist/lib/suggestDisplayName.js +27 -0
- package/dist/lib/suggestDisplayName.js.map +1 -0
- package/dist/oclif.manifest.json +431 -51
- package/package.json +8 -4
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* TypeScript scaffold templates for each component type.
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.schemaYmlTemplate = exports.destinationSchemaFunctionTemplate = exports.sourceSchemaFunctionTemplate = exports.destinationTemplate = exports.jobTemplate = exports.functionTemplate = void 0;
|
|
7
|
+
function functionTemplate(className, global) {
|
|
8
|
+
if (global) {
|
|
9
|
+
return `import { GlobalFunction, Response } from '@zaiusinc/app-sdk';
|
|
10
|
+
|
|
11
|
+
export class ${className} extends GlobalFunction {
|
|
12
|
+
public async perform(): Promise<Response> {
|
|
13
|
+
// TODO: implement
|
|
14
|
+
return new Response(200, 'OK');
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
`;
|
|
18
|
+
}
|
|
19
|
+
return `import { Function, Response } from '@zaiusinc/app-sdk';
|
|
20
|
+
|
|
21
|
+
export class ${className} extends Function {
|
|
22
|
+
public async perform(): Promise<Response> {
|
|
23
|
+
// TODO: implement
|
|
24
|
+
return new Response(200, 'OK');
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
`;
|
|
28
|
+
}
|
|
29
|
+
exports.functionTemplate = functionTemplate;
|
|
30
|
+
function jobTemplate(className) {
|
|
31
|
+
return `import { Job, JobStatus, ValueHash } from '@zaiusinc/app-sdk';
|
|
32
|
+
|
|
33
|
+
export class ${className} extends Job {
|
|
34
|
+
public async prepare(params: ValueHash, status?: JobStatus, resuming?: boolean): Promise<JobStatus> {
|
|
35
|
+
return { complete: false, state: {} };
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
public async perform(status: JobStatus): Promise<JobStatus> {
|
|
39
|
+
// TODO: implement
|
|
40
|
+
return { ...status, complete: true };
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
`;
|
|
44
|
+
}
|
|
45
|
+
exports.jobTemplate = jobTemplate;
|
|
46
|
+
function destinationTemplate(className) {
|
|
47
|
+
return `import * as App from '@zaiusinc/app-sdk';
|
|
48
|
+
|
|
49
|
+
export class ${className} extends App.Destination<Record<string, unknown>> {
|
|
50
|
+
public async ready(): Promise<App.DestinationReadyResult> {
|
|
51
|
+
// TODO: validate connection
|
|
52
|
+
return { ready: true };
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
public async deliver(batch: App.DestinationBatch<Record<string, unknown>>): Promise<App.DestinationDeliverResult> {
|
|
56
|
+
// TODO: implement delivery
|
|
57
|
+
return { success: true };
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
`;
|
|
61
|
+
}
|
|
62
|
+
exports.destinationTemplate = destinationTemplate;
|
|
63
|
+
function sourceSchemaFunctionTemplate(className, name, displayName) {
|
|
64
|
+
return `import * as App from '@zaiusinc/app-sdk';
|
|
65
|
+
|
|
66
|
+
export class ${className} extends App.SourceSchemaFunction {
|
|
67
|
+
public async getSourcesSchema(): Promise<App.SourceSchema> {
|
|
68
|
+
return {
|
|
69
|
+
name: '${name}',
|
|
70
|
+
description: '${displayName}',
|
|
71
|
+
display_name: '${displayName}',
|
|
72
|
+
fields: [
|
|
73
|
+
{
|
|
74
|
+
name: 'id',
|
|
75
|
+
display_name: 'ID',
|
|
76
|
+
description: 'Unique identifier',
|
|
77
|
+
type: 'string',
|
|
78
|
+
primary: true,
|
|
79
|
+
},
|
|
80
|
+
],
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
`;
|
|
85
|
+
}
|
|
86
|
+
exports.sourceSchemaFunctionTemplate = sourceSchemaFunctionTemplate;
|
|
87
|
+
function destinationSchemaFunctionTemplate(className, name, displayName) {
|
|
88
|
+
return `import * as App from '@zaiusinc/app-sdk';
|
|
89
|
+
|
|
90
|
+
export class ${className} extends App.DestinationSchemaFunction {
|
|
91
|
+
public async getDestinationsSchema(): Promise<App.DestinationSchema> {
|
|
92
|
+
return {
|
|
93
|
+
name: '${name}',
|
|
94
|
+
description: '${displayName}',
|
|
95
|
+
display_name: '${displayName}',
|
|
96
|
+
fields: [
|
|
97
|
+
{
|
|
98
|
+
name: 'id',
|
|
99
|
+
display_name: 'ID',
|
|
100
|
+
description: 'Unique identifier',
|
|
101
|
+
type: 'string',
|
|
102
|
+
primary: true,
|
|
103
|
+
},
|
|
104
|
+
],
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
`;
|
|
109
|
+
}
|
|
110
|
+
exports.destinationSchemaFunctionTemplate = destinationSchemaFunctionTemplate;
|
|
111
|
+
function schemaYmlTemplate(name, displayName) {
|
|
112
|
+
return `name: ${name}
|
|
113
|
+
description: "${displayName}"
|
|
114
|
+
display_name: "${displayName}"
|
|
115
|
+
fields:
|
|
116
|
+
- name: id
|
|
117
|
+
display_name: ID
|
|
118
|
+
description: Unique identifier
|
|
119
|
+
type: string
|
|
120
|
+
primary: true
|
|
121
|
+
- name: name
|
|
122
|
+
display_name: Name
|
|
123
|
+
description: Display name
|
|
124
|
+
type: string
|
|
125
|
+
`;
|
|
126
|
+
}
|
|
127
|
+
exports.schemaYmlTemplate = schemaYmlTemplate;
|
|
128
|
+
//# sourceMappingURL=templates.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"templates.js","sourceRoot":"","sources":["../../../src/lib/scaffolding/templates.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,SAAgB,gBAAgB,CAAC,SAAiB,EAAE,MAAe;IACjE,IAAI,MAAM,EAAE;QACV,OAAO;;eAEI,SAAS;;;;;;CAMvB,CAAC;KACC;IACD,OAAO;;eAEM,SAAS;;;;;;CAMvB,CAAC;AACF,CAAC;AArBD,4CAqBC;AAED,SAAgB,WAAW,CAAC,SAAiB;IAC3C,OAAO;;eAEM,SAAS;;;;;;;;;;CAUvB,CAAC;AACF,CAAC;AAdD,kCAcC;AAED,SAAgB,mBAAmB,CAAC,SAAiB;IACnD,OAAO;;eAEM,SAAS;;;;;;;;;;;CAWvB,CAAC;AACF,CAAC;AAfD,kDAeC;AAED,SAAgB,4BAA4B,CAAC,SAAiB,EAAE,IAAY,EAAE,WAAmB;IAC/F,OAAO;;eAEM,SAAS;;;eAGT,IAAI;sBACG,WAAW;uBACV,WAAW;;;;;;;;;;;;;CAajC,CAAC;AACF,CAAC;AAtBD,oEAsBC;AAED,SAAgB,iCAAiC,CAAC,SAAiB,EAAE,IAAY,EAAE,WAAmB;IACpG,OAAO;;eAEM,SAAS;;;eAGT,IAAI;sBACG,WAAW;uBACV,WAAW;;;;;;;;;;;;;CAajC,CAAC;AACF,CAAC;AAtBD,8EAsBC;AAED,SAAgB,iBAAiB,CAAC,IAAY,EAAE,WAAmB;IACjE,OAAO,SAAS,IAAI;gBACN,WAAW;iBACV,WAAW;;;;;;;;;;;CAW3B,CAAC;AACF,CAAC;AAfD,8CAeC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Suggest a default `display_name` for `app init` when the user hasn't typed
|
|
3
|
+
* one yet. We only suggest when there's something obvious to base it on:
|
|
4
|
+
* - an explicit arg passed to `app init`, or
|
|
5
|
+
* - an empty cwd whose folder name is a sensible starting point.
|
|
6
|
+
*
|
|
7
|
+
* The title-case import here intentionally uses `import x = require(...)`.
|
|
8
|
+
* `import x from 'title-case'` compiles to a broken `require(...).default`
|
|
9
|
+
* call under our tsconfig (esModuleInterop: false), which we shipped in
|
|
10
|
+
* production once and crashed `app init` for customers in empty dirs.
|
|
11
|
+
*/
|
|
12
|
+
export declare function suggestDisplayName(argId: string | undefined, cwd: string): string;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.suggestDisplayName = void 0;
|
|
4
|
+
const fs = require("fs");
|
|
5
|
+
const path = require("path");
|
|
6
|
+
const titleCase = require("title-case");
|
|
7
|
+
/**
|
|
8
|
+
* Suggest a default `display_name` for `app init` when the user hasn't typed
|
|
9
|
+
* one yet. We only suggest when there's something obvious to base it on:
|
|
10
|
+
* - an explicit arg passed to `app init`, or
|
|
11
|
+
* - an empty cwd whose folder name is a sensible starting point.
|
|
12
|
+
*
|
|
13
|
+
* The title-case import here intentionally uses `import x = require(...)`.
|
|
14
|
+
* `import x from 'title-case'` compiles to a broken `require(...).default`
|
|
15
|
+
* call under our tsconfig (esModuleInterop: false), which we shipped in
|
|
16
|
+
* production once and crashed `app init` for customers in empty dirs.
|
|
17
|
+
*/
|
|
18
|
+
function suggestDisplayName(argId, cwd) {
|
|
19
|
+
if (!argId && fs.readdirSync(cwd).length > 0)
|
|
20
|
+
return '';
|
|
21
|
+
const source = argId || path.basename(cwd).replace(/[^a-zA-Z0-9]+/g, ' ').trim();
|
|
22
|
+
if (!source)
|
|
23
|
+
return '';
|
|
24
|
+
return titleCase(source);
|
|
25
|
+
}
|
|
26
|
+
exports.suggestDisplayName = suggestDisplayName;
|
|
27
|
+
//# sourceMappingURL=suggestDisplayName.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"suggestDisplayName.js","sourceRoot":"","sources":["../../src/lib/suggestDisplayName.ts"],"names":[],"mappings":";;;AAAA,yBAAyB;AACzB,6BAA6B;AAC7B,wCAAyC;AAEzC;;;;;;;;;;GAUG;AACH,SAAgB,kBAAkB,CAAC,KAAyB,EAAE,GAAW;IACvE,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO,EAAE,CAAC;IACxD,MAAM,MAAM,GAAG,KAAK,IAAI,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,gBAAgB,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;IACjF,IAAI,CAAC,MAAM;QAAE,OAAO,EAAE,CAAC;IACvB,OAAO,SAAS,CAAC,MAAM,CAAC,CAAC;AAC3B,CAAC;AALD,gDAKC"}
|