@extrahorizon/exh-cli 1.13.0-dev-175-2fcbbbb → 1.13.0-dev-177-a0805f5
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/build/commands/tasks/{createrepo.d.ts → create-repo.d.ts} +8 -2
- package/build/commands/tasks/{createrepo.js → create-repo.js} +7 -2
- package/build/config-json-schemas/Template.json +26 -198
- package/build/services/tasks/createRepo.d.ts +2 -1
- package/build/services/tasks/createRepo.js +16 -13
- package/build/services/templates/util/readTemplateFiles.js +3 -1
- package/build/services/templates/util/utils.js +1 -2
- package/package.json +1 -1
|
@@ -3,7 +3,7 @@ export declare const command = "create-repo <name>";
|
|
|
3
3
|
export declare const desc = "Create a new task repository";
|
|
4
4
|
export declare const builder: (yargs: any) => import("yargs").Argv<import("yargs").Omit<{
|
|
5
5
|
name: string;
|
|
6
|
-
}, "repo" | "git"> & import("yargs").InferredOptionTypes<{
|
|
6
|
+
}, "path" | "repo" | "git"> & import("yargs").InferredOptionTypes<{
|
|
7
7
|
repo: {
|
|
8
8
|
description: string;
|
|
9
9
|
type: "string";
|
|
@@ -14,9 +14,15 @@ export declare const builder: (yargs: any) => import("yargs").Argv<import("yargs
|
|
|
14
14
|
type: "boolean";
|
|
15
15
|
default: boolean;
|
|
16
16
|
};
|
|
17
|
+
path: {
|
|
18
|
+
description: string;
|
|
19
|
+
type: "string";
|
|
20
|
+
default: string;
|
|
21
|
+
};
|
|
17
22
|
}>>;
|
|
18
|
-
export declare const handler: ({ name, repo, git }: {
|
|
23
|
+
export declare const handler: ({ name, repo, git, path }: {
|
|
19
24
|
name: any;
|
|
20
25
|
repo: any;
|
|
21
26
|
git: any;
|
|
27
|
+
path: any;
|
|
22
28
|
}) => Promise<void>;
|
|
@@ -22,9 +22,14 @@ const builder = (yargs) => (0, util_1.epilogue)(yargs)
|
|
|
22
22
|
type: 'boolean',
|
|
23
23
|
default: false,
|
|
24
24
|
},
|
|
25
|
+
path: {
|
|
26
|
+
description: 'the path where the new repo/task should be created',
|
|
27
|
+
type: 'string',
|
|
28
|
+
default: './',
|
|
29
|
+
},
|
|
25
30
|
});
|
|
26
31
|
exports.builder = builder;
|
|
27
|
-
const handler = async ({ name, repo, git }) => {
|
|
28
|
-
await tasksService.createRepo({ name, repo, git });
|
|
32
|
+
const handler = async ({ name, repo, git, path }) => {
|
|
33
|
+
await tasksService.createRepo({ name, repo, git, path });
|
|
29
34
|
};
|
|
30
35
|
exports.handler = handler;
|
|
@@ -1,67 +1,38 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
-
"
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
"required": ["schema"],
|
|
14
|
-
"properties": {
|
|
15
|
-
"version": { "const": 1 },
|
|
16
|
-
"schema": true
|
|
17
|
-
}
|
|
18
|
-
},
|
|
19
|
-
{
|
|
20
|
-
"type": "object",
|
|
21
|
-
"required": ["fields"],
|
|
22
|
-
"properties": {
|
|
23
|
-
"version": { "const": 1 },
|
|
24
|
-
"fields": true
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
]
|
|
28
|
-
},
|
|
29
|
-
"then": { "$ref": "#/definitions/TemplateV1" },
|
|
30
|
-
"else": { "$ref": "#/definitions/TemplateV2" },
|
|
31
|
-
"definitions": {
|
|
32
|
-
"TemplateV2": {
|
|
3
|
+
"type": "object",
|
|
4
|
+
"additionalProperties": false,
|
|
5
|
+
"properties": {
|
|
6
|
+
"$schema": { "type": "string" },
|
|
7
|
+
"description": {
|
|
8
|
+
"type": "string",
|
|
9
|
+
"minLength": 1
|
|
10
|
+
},
|
|
11
|
+
"extendsTemplate": { "type": "string" },
|
|
12
|
+
"inputs": {
|
|
33
13
|
"type": "object",
|
|
34
|
-
"additionalProperties":
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
},
|
|
42
|
-
"extendsTemplate": { "type": "string" },
|
|
43
|
-
"inputs": {
|
|
44
|
-
"type": "object",
|
|
45
|
-
"additionalProperties": { "$ref": "#/definitions/TypeConfigurationV2" }
|
|
46
|
-
},
|
|
47
|
-
"outputs": {
|
|
48
|
-
"type": "object",
|
|
49
|
-
"additionalProperties": {
|
|
50
|
-
"type": "string",
|
|
51
|
-
"minLength": 1
|
|
52
|
-
}
|
|
53
|
-
},
|
|
54
|
-
"variables": {
|
|
55
|
-
"type": "object",
|
|
56
|
-
"additionalProperties": { "type": "string" }
|
|
57
|
-
}
|
|
14
|
+
"additionalProperties": { "$ref": "#/definitions/TypeConfigurationV2" }
|
|
15
|
+
},
|
|
16
|
+
"outputs": {
|
|
17
|
+
"type": "object",
|
|
18
|
+
"additionalProperties": {
|
|
19
|
+
"type": "string",
|
|
20
|
+
"minLength": 1
|
|
58
21
|
}
|
|
59
22
|
},
|
|
23
|
+
"variables": {
|
|
24
|
+
"type": "object",
|
|
25
|
+
"additionalProperties": { "type": "string" }
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
"definitions": {
|
|
60
29
|
"TypeConfigurationV2": {
|
|
61
30
|
"type": "object",
|
|
62
31
|
"required": ["type"],
|
|
63
32
|
"properties": {
|
|
64
|
-
"type": {
|
|
33
|
+
"type": {
|
|
34
|
+
"enum": ["object", "array", "string", "number", "boolean"]
|
|
35
|
+
}
|
|
65
36
|
},
|
|
66
37
|
"allOf": [
|
|
67
38
|
{
|
|
@@ -155,149 +126,6 @@
|
|
|
155
126
|
"properties": {
|
|
156
127
|
"type": { "const": "boolean" }
|
|
157
128
|
}
|
|
158
|
-
},
|
|
159
|
-
"TemplateV1": {
|
|
160
|
-
"type": "object",
|
|
161
|
-
"required": ["description", "schema", "fields"],
|
|
162
|
-
"properties": {
|
|
163
|
-
"version": { "const": 1 },
|
|
164
|
-
"$schema": { "type": "string" },
|
|
165
|
-
"extends_template": { "type": "string" },
|
|
166
|
-
"description": { "type": "string" },
|
|
167
|
-
"schema": { "$ref": "#/definitions/ObjectConfiguration" },
|
|
168
|
-
"fields": {
|
|
169
|
-
"type": "object",
|
|
170
|
-
"additionalProperties": { "type": "string" }
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
},
|
|
174
|
-
"TypeConfiguration": {
|
|
175
|
-
"type": "object",
|
|
176
|
-
"required": ["type"],
|
|
177
|
-
"properties": {
|
|
178
|
-
"type": { "enum": ["object", "array", "string", "number", "boolean", "object_id", "date"] }
|
|
179
|
-
},
|
|
180
|
-
"allOf": [
|
|
181
|
-
{
|
|
182
|
-
"if": {
|
|
183
|
-
"type": "object",
|
|
184
|
-
"properties": {
|
|
185
|
-
"type": { "const": "object" }
|
|
186
|
-
}
|
|
187
|
-
},
|
|
188
|
-
"then": { "$ref": "#/definitions/ObjectConfiguration" }
|
|
189
|
-
},
|
|
190
|
-
{
|
|
191
|
-
"if": {
|
|
192
|
-
"type": "object",
|
|
193
|
-
"properties": {
|
|
194
|
-
"type": { "const": "array" }
|
|
195
|
-
}
|
|
196
|
-
},
|
|
197
|
-
"then": { "$ref": "#/definitions/ArrayConfiguration" }
|
|
198
|
-
},
|
|
199
|
-
{
|
|
200
|
-
"if": {
|
|
201
|
-
"type": "object",
|
|
202
|
-
"properties": {
|
|
203
|
-
"type": { "const": "string" }
|
|
204
|
-
}
|
|
205
|
-
},
|
|
206
|
-
"then": { "$ref": "#/definitions/StringConfiguration" }
|
|
207
|
-
},
|
|
208
|
-
{
|
|
209
|
-
"if": {
|
|
210
|
-
"type": "object",
|
|
211
|
-
"properties": {
|
|
212
|
-
"type": { "const": "number" }
|
|
213
|
-
}
|
|
214
|
-
},
|
|
215
|
-
"then": { "$ref": "#/definitions/NumberConfiguration" }
|
|
216
|
-
},
|
|
217
|
-
{
|
|
218
|
-
"if": {
|
|
219
|
-
"type": "object",
|
|
220
|
-
"properties": {
|
|
221
|
-
"type": { "const": "boolean" }
|
|
222
|
-
}
|
|
223
|
-
},
|
|
224
|
-
"then": { "$ref": "#/definitions/BooleanConfiguration" }
|
|
225
|
-
},
|
|
226
|
-
{
|
|
227
|
-
"if": {
|
|
228
|
-
"type": "object",
|
|
229
|
-
"properties": {
|
|
230
|
-
"type": { "const": "object_id" }
|
|
231
|
-
}
|
|
232
|
-
},
|
|
233
|
-
"then": { "$ref": "#/definitions/ObjectIdConfiguration" }
|
|
234
|
-
},
|
|
235
|
-
{
|
|
236
|
-
"if": {
|
|
237
|
-
"type": "object",
|
|
238
|
-
"properties": {
|
|
239
|
-
"type": { "const": "date" }
|
|
240
|
-
}
|
|
241
|
-
},
|
|
242
|
-
"then": { "$ref": "#/definitions/DateConfiguration" }
|
|
243
|
-
}
|
|
244
|
-
]
|
|
245
|
-
},
|
|
246
|
-
"ObjectConfiguration": {
|
|
247
|
-
"type": "object",
|
|
248
|
-
"required": ["type"],
|
|
249
|
-
"properties": {
|
|
250
|
-
"type": { "const": "object" },
|
|
251
|
-
"fields": {
|
|
252
|
-
"type": "object",
|
|
253
|
-
"additionalProperties": {
|
|
254
|
-
"$ref": "#/definitions/TypeConfiguration"
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
},
|
|
259
|
-
"ArrayConfiguration": {
|
|
260
|
-
"type": "object",
|
|
261
|
-
"required": ["type", "type_configuration"],
|
|
262
|
-
"properties": {
|
|
263
|
-
"type": { "const": "array" },
|
|
264
|
-
"type_configuration": { "$ref": "#/definitions/TypeConfiguration" }
|
|
265
|
-
}
|
|
266
|
-
},
|
|
267
|
-
"StringConfiguration": {
|
|
268
|
-
"type": "object",
|
|
269
|
-
"required": ["type"],
|
|
270
|
-
"properties": {
|
|
271
|
-
"type": { "const": "string" }
|
|
272
|
-
}
|
|
273
|
-
},
|
|
274
|
-
"NumberConfiguration": {
|
|
275
|
-
"type": "object",
|
|
276
|
-
"required": ["type"],
|
|
277
|
-
"properties": {
|
|
278
|
-
"type": { "const": "number" }
|
|
279
|
-
}
|
|
280
|
-
},
|
|
281
|
-
"BooleanConfiguration": {
|
|
282
|
-
"type": "object",
|
|
283
|
-
"required": ["type"],
|
|
284
|
-
"properties": {
|
|
285
|
-
"type": { "const": "boolean" }
|
|
286
|
-
}
|
|
287
|
-
},
|
|
288
|
-
"ObjectIdConfiguration": {
|
|
289
|
-
"type": "object",
|
|
290
|
-
"required": ["type"],
|
|
291
|
-
"properties": {
|
|
292
|
-
"type": { "const": "object_id" }
|
|
293
|
-
}
|
|
294
|
-
},
|
|
295
|
-
"DateConfiguration": {
|
|
296
|
-
"type": "object",
|
|
297
|
-
"required": ["type"],
|
|
298
|
-
"properties": {
|
|
299
|
-
"type": { "const": "date" }
|
|
300
|
-
}
|
|
301
129
|
}
|
|
302
130
|
}
|
|
303
131
|
}
|
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createRepo = void 0;
|
|
4
4
|
const promises_1 = require("fs/promises");
|
|
5
|
+
const path_1 = require("path");
|
|
5
6
|
const chalk = require("chalk");
|
|
6
7
|
const util_1 = require("../../helpers/util");
|
|
7
|
-
async function createRepo({ name, repo, git }) {
|
|
8
|
+
async function createRepo({ name, repo, git, path }) {
|
|
8
9
|
try {
|
|
9
10
|
await (0, util_1.asyncExec)('git --version');
|
|
10
11
|
}
|
|
@@ -13,40 +14,42 @@ async function createRepo({ name, repo, git }) {
|
|
|
13
14
|
}
|
|
14
15
|
console.log(`Creating new repo ${chalk.green(name)}...`);
|
|
15
16
|
try {
|
|
16
|
-
|
|
17
|
+
const repoPath = (0, path_1.join)(path || '', name);
|
|
18
|
+
await (0, util_1.asyncExec)(`git clone ${repo} ${repoPath}`);
|
|
17
19
|
try {
|
|
18
|
-
await changePackageFile(name);
|
|
20
|
+
await changePackageFile(repoPath, name);
|
|
19
21
|
}
|
|
20
22
|
catch (err) { }
|
|
21
|
-
await (0, util_1.asyncExec)(`cd ${
|
|
23
|
+
await (0, util_1.asyncExec)(`cd ${repoPath} && rm -rf .git`);
|
|
22
24
|
if (git) {
|
|
23
25
|
console.log('Initializing git');
|
|
24
|
-
await (0, util_1.asyncExec)(`cd ${
|
|
26
|
+
await (0, util_1.asyncExec)(`cd ${repoPath} && git init . && git add . && git commit -m "First commit"`);
|
|
25
27
|
}
|
|
26
28
|
console.log('Done! 🎉');
|
|
27
29
|
}
|
|
28
30
|
catch (err) {
|
|
29
|
-
await (0, util_1.asyncExec)(`rm -rf ${name}`);
|
|
30
31
|
console.log(chalk.red('Failed to create repo'));
|
|
31
32
|
console.log(err);
|
|
32
33
|
}
|
|
33
34
|
}
|
|
34
35
|
exports.createRepo = createRepo;
|
|
35
|
-
async function changePackageFile(name) {
|
|
36
|
+
async function changePackageFile(repoPath, name) {
|
|
36
37
|
try {
|
|
37
|
-
const pkg = JSON.parse((await (0, promises_1.readFile)(`${
|
|
38
|
+
const pkg = JSON.parse((await (0, promises_1.readFile)(`${repoPath}/package.json`)).toString());
|
|
38
39
|
pkg.name = name;
|
|
39
|
-
await (0, promises_1.writeFile)(`${
|
|
40
|
+
await (0, promises_1.writeFile)(`${repoPath}/package.json`, JSON.stringify(pkg, null, 2));
|
|
40
41
|
}
|
|
41
42
|
catch (err) {
|
|
42
|
-
console.log('WARN: package.json not found. (possibly not a javascript repository');
|
|
43
|
+
console.log('WARN: package.json not found. (possibly not a javascript repository)');
|
|
43
44
|
}
|
|
44
45
|
try {
|
|
45
|
-
const taskConfig = JSON.parse((await (0, promises_1.readFile)(`${
|
|
46
|
+
const taskConfig = JSON.parse((await (0, promises_1.readFile)(`${repoPath}/task-config.json`)).toString());
|
|
46
47
|
taskConfig.$schema = (0, util_1.getSwaggerDocumentationUrl)('config-json-schemas/TaskConfig.json');
|
|
47
48
|
taskConfig.name = name;
|
|
48
49
|
taskConfig.description = `${name} task`;
|
|
49
|
-
await (0, promises_1.writeFile)(`${
|
|
50
|
+
await (0, promises_1.writeFile)(`${repoPath}/task-config.json`, JSON.stringify(taskConfig, null, 2));
|
|
51
|
+
}
|
|
52
|
+
catch (err) {
|
|
53
|
+
console.log('WARN: task-config.json not found.');
|
|
50
54
|
}
|
|
51
|
-
catch (err) { }
|
|
52
55
|
}
|
|
@@ -25,7 +25,9 @@ exports.readTemplateFiles = readTemplateFiles;
|
|
|
25
25
|
async function readAndValidateTemplateJson(fileName) {
|
|
26
26
|
try {
|
|
27
27
|
const content = await (0, utils_1.readJsonFile)(fileName);
|
|
28
|
-
(0,
|
|
28
|
+
if (!(0, utils_1.isV1Template)(content)) {
|
|
29
|
+
(0, util_1.ajvValidate)(templateConfigSchema, content);
|
|
30
|
+
}
|
|
29
31
|
return content;
|
|
30
32
|
}
|
|
31
33
|
catch (error) {
|
|
@@ -21,8 +21,7 @@ function removeFileNameExtension(fileName) {
|
|
|
21
21
|
}
|
|
22
22
|
exports.removeFileNameExtension = removeFileNameExtension;
|
|
23
23
|
function isV1Template(template) {
|
|
24
|
-
return (template.
|
|
25
|
-
!!template.schema ||
|
|
24
|
+
return (!!template.schema ||
|
|
26
25
|
!!template.fields);
|
|
27
26
|
}
|
|
28
27
|
exports.isV1Template = isV1Template;
|