@extrahorizon/exh-cli 1.12.0-dev-142-82cc6de → 1.12.0-dev-144-b9d0b5a
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/data/schemas/delete.js +2 -14
- package/build/commands/data/schemas/init.js +2 -30
- package/build/commands/data/schemas/list.js +2 -15
- package/build/commands/data/schemas/sync.d.ts +3 -5
- package/build/commands/data/schemas/sync.js +4 -40
- package/build/commands/data/schemas/verify.js +6 -51
- package/build/commands/sync.js +12 -11
- package/build/commands/templates/delete.js +6 -26
- package/build/commands/templates/get.js +6 -16
- package/build/commands/templates/list.js +2 -18
- package/build/commands/templates/sync.d.ts +0 -1
- package/build/commands/templates/sync.js +7 -31
- package/build/services/schemas/index.d.ts +5 -0
- package/build/services/schemas/index.js +43 -0
- package/build/services/schemas/init.d.ts +1 -0
- package/build/services/schemas/init.js +37 -0
- package/build/services/schemas/sync.d.ts +3 -0
- package/build/services/schemas/sync.js +44 -0
- package/build/{commands/data → services}/schemas/util/syncSchema.js +1 -1
- package/build/services/schemas/verify.d.ts +1 -0
- package/build/services/schemas/verify.js +56 -0
- package/build/services/templates/index.d.ts +4 -0
- package/build/services/templates/index.js +66 -0
- package/build/services/templates/sync.d.ts +2 -0
- package/build/services/templates/sync.js +36 -0
- package/package.json +1 -1
- /package/build/{commands/data → services}/schemas/sync/statusHelpers.d.ts +0 -0
- /package/build/{commands/data → services}/schemas/sync/statusHelpers.js +0 -0
- /package/build/{commands/data → services}/schemas/util/listFilesInDir.d.ts +0 -0
- /package/build/{commands/data → services}/schemas/util/listFilesInDir.js +0 -0
- /package/build/{commands/data → services}/schemas/util/readJson.d.ts +0 -0
- /package/build/{commands/data → services}/schemas/util/readJson.js +0 -0
- /package/build/{commands/data → services}/schemas/util/schemaverify.d.ts +0 -0
- /package/build/{commands/data → services}/schemas/util/schemaverify.js +0 -0
- /package/build/{commands/data → services}/schemas/util/stripUnsupportedDescriptionFields.d.ts +0 -0
- /package/build/{commands/data → services}/schemas/util/stripUnsupportedDescriptionFields.js +0 -0
- /package/build/{commands/data → services}/schemas/util/syncSchema.d.ts +0 -0
- /package/build/{commands/data → services}/schemas/util/tests/listFilesInDir.test.d.ts +0 -0
- /package/build/{commands/data → services}/schemas/util/tests/listFilesInDir.test.js +0 -0
- /package/build/{commands → services}/templates/util/buildTemplates.d.ts +0 -0
- /package/build/{commands → services}/templates/util/buildTemplates.js +0 -0
- /package/build/{commands → services}/templates/util/readTemplateFiles.d.ts +0 -0
- /package/build/{commands → services}/templates/util/readTemplateFiles.js +0 -0
- /package/build/{commands → services}/templates/util/uploadTemplate.d.ts +0 -0
- /package/build/{commands → services}/templates/util/uploadTemplate.js +0 -0
- /package/build/{commands → services}/templates/util/utils.d.ts +0 -0
- /package/build/{commands → services}/templates/util/utils.js +0 -0
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.handler = exports.builder = exports.desc = exports.command = void 0;
|
|
4
|
-
const chalk = require("chalk");
|
|
5
4
|
const util_1 = require("../../../helpers/util");
|
|
6
|
-
const
|
|
5
|
+
const schemaService = require("../../../services/schemas");
|
|
7
6
|
exports.command = 'delete';
|
|
8
7
|
exports.desc = 'Delete a schema';
|
|
9
8
|
const builder = (yargs) => (0, util_1.epilogue)(yargs).option('id', {
|
|
@@ -13,17 +12,6 @@ const builder = (yargs) => (0, util_1.epilogue)(yargs).option('id', {
|
|
|
13
12
|
});
|
|
14
13
|
exports.builder = builder;
|
|
15
14
|
const handler = async ({ id }) => {
|
|
16
|
-
|
|
17
|
-
if (disableResponse.affectedRecords !== 1) {
|
|
18
|
-
console.log(chalk.red('Failed to delete schema', id));
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
const deleteResponse = await schemaRepository.remove(id);
|
|
22
|
-
if (deleteResponse.affectedRecords) {
|
|
23
|
-
console.log(chalk.green('Successfully deleted schema', id));
|
|
24
|
-
}
|
|
25
|
-
else {
|
|
26
|
-
console.log(chalk.red('Failed to delete schema', id));
|
|
27
|
-
}
|
|
15
|
+
await schemaService.remove(id);
|
|
28
16
|
};
|
|
29
17
|
exports.handler = handler;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.handler = exports.builder = exports.desc = exports.command = void 0;
|
|
4
|
-
const promises_1 = require("fs/promises");
|
|
5
|
-
const osPath = require("path");
|
|
6
4
|
const util_1 = require("../../../helpers/util");
|
|
5
|
+
const schemaService = require("../../../services/schemas");
|
|
7
6
|
exports.command = 'init <name>';
|
|
8
7
|
exports.desc = 'Create a basic schema configuration file';
|
|
9
8
|
const builder = (yargs) => (0, util_1.epilogue)(yargs)
|
|
@@ -21,33 +20,6 @@ const builder = (yargs) => (0, util_1.epilogue)(yargs)
|
|
|
21
20
|
});
|
|
22
21
|
exports.builder = builder;
|
|
23
22
|
const handler = async function init({ name, path }) {
|
|
24
|
-
await (
|
|
25
|
-
const filePath = osPath.join(path, `${name}.json`);
|
|
26
|
-
await (0, promises_1.writeFile)(filePath, JSON.stringify(createSchema(name), null, 2));
|
|
27
|
-
console.log(`✅ Successfully created ${filePath}`);
|
|
23
|
+
await schemaService.init(name, path);
|
|
28
24
|
};
|
|
29
25
|
exports.handler = handler;
|
|
30
|
-
function createSchema(name) {
|
|
31
|
-
return {
|
|
32
|
-
name,
|
|
33
|
-
description: `The ${name} schema`,
|
|
34
|
-
createMode: 'allUsers',
|
|
35
|
-
readMode: ['creator'],
|
|
36
|
-
updateMode: ['creator'],
|
|
37
|
-
deleteMode: ['creator'],
|
|
38
|
-
statuses: {
|
|
39
|
-
new: {},
|
|
40
|
-
},
|
|
41
|
-
creationTransition: {
|
|
42
|
-
type: 'manual',
|
|
43
|
-
toStatus: 'new',
|
|
44
|
-
},
|
|
45
|
-
transitions: [],
|
|
46
|
-
properties: {
|
|
47
|
-
firstProperty: {
|
|
48
|
-
type: 'string',
|
|
49
|
-
},
|
|
50
|
-
},
|
|
51
|
-
$schema: (0, util_1.getSwaggerDocumentationUrl)('config-json-schemas/Schema.json'),
|
|
52
|
-
};
|
|
53
|
-
}
|
|
@@ -2,25 +2,12 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.handler = exports.builder = exports.desc = exports.command = void 0;
|
|
4
4
|
const util_1 = require("../../../helpers/util");
|
|
5
|
-
const
|
|
5
|
+
const schemaService = require("../../../services/schemas");
|
|
6
6
|
exports.command = 'list';
|
|
7
7
|
exports.desc = 'List all schemas';
|
|
8
8
|
const builder = (yargs) => (0, util_1.epilogue)(yargs);
|
|
9
9
|
exports.builder = builder;
|
|
10
10
|
const handler = async function list({ isTTY }) {
|
|
11
|
-
|
|
12
|
-
if (schemas.length < 1) {
|
|
13
|
-
return;
|
|
14
|
-
}
|
|
15
|
-
if (isTTY) {
|
|
16
|
-
console.table(schemas.map(schema => ({
|
|
17
|
-
Id: schema.id,
|
|
18
|
-
Name: schema.name,
|
|
19
|
-
Description: schema.description || '<none>',
|
|
20
|
-
})));
|
|
21
|
-
}
|
|
22
|
-
else {
|
|
23
|
-
schemas.forEach(schema => console.log([schema.id, schema.name].join(',')));
|
|
24
|
-
}
|
|
11
|
+
await schemaService.list(isTTY);
|
|
25
12
|
};
|
|
26
13
|
exports.handler = handler;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="yargs" />
|
|
2
2
|
export declare const command = "sync";
|
|
3
3
|
export declare const desc = "Sync all schemas in a directory with the ExH cloud";
|
|
4
|
-
export declare const builder: (yargs: any) => import("yargs").Argv<import("yargs").Omit<{}, "file" | "dir" | "
|
|
4
|
+
export declare const builder: (yargs: any) => import("yargs").Argv<import("yargs").Omit<{}, "file" | "dir" | "dry" | "ignoreVerificationErrors"> & import("yargs").InferredOptionTypes<{
|
|
5
5
|
dir: {
|
|
6
6
|
demandOption: false;
|
|
7
7
|
describe: string;
|
|
@@ -24,11 +24,9 @@ export declare const builder: (yargs: any) => import("yargs").Argv<import("yargs
|
|
|
24
24
|
default: boolean;
|
|
25
25
|
};
|
|
26
26
|
}>>;
|
|
27
|
-
export declare const handler: ({
|
|
28
|
-
dir: any;
|
|
27
|
+
export declare const handler: ({ file, dir, dry, ignoreVerificationErrors }: {
|
|
29
28
|
file: any;
|
|
29
|
+
dir: any;
|
|
30
30
|
dry: any;
|
|
31
31
|
ignoreVerificationErrors: any;
|
|
32
32
|
}) => Promise<void>;
|
|
33
|
-
export declare function syncTargetFile(targetFile: string, dry?: boolean, ignoreVerificationErrors?: boolean): Promise<void>;
|
|
34
|
-
export declare function syncTargetDir(targetDir: string, dry?: boolean, ignoreVerificationErrors?: boolean): Promise<void>;
|
|
@@ -1,13 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
const path = require("path");
|
|
5
|
-
const chalk = require("chalk");
|
|
3
|
+
exports.handler = exports.builder = exports.desc = exports.command = void 0;
|
|
6
4
|
const util_1 = require("../../../helpers/util");
|
|
7
|
-
const
|
|
8
|
-
const readJson_1 = require("./util/readJson");
|
|
9
|
-
const syncSchema_1 = require("./util/syncSchema");
|
|
10
|
-
const verify_1 = require("./verify");
|
|
5
|
+
const schemaService = require("../../../services/schemas");
|
|
11
6
|
exports.command = 'sync';
|
|
12
7
|
exports.desc = 'Sync all schemas in a directory with the ExH cloud';
|
|
13
8
|
const builder = (yargs) => (0, util_1.epilogue)(yargs).options({
|
|
@@ -34,38 +29,7 @@ const builder = (yargs) => (0, util_1.epilogue)(yargs).options({
|
|
|
34
29
|
},
|
|
35
30
|
});
|
|
36
31
|
exports.builder = builder;
|
|
37
|
-
const handler = async ({
|
|
38
|
-
|
|
39
|
-
console.log(chalk.red('No target is chosen to be synced. Please use flags "--file" or "--dir" when syncing'));
|
|
40
|
-
process.exit(1);
|
|
41
|
-
}
|
|
42
|
-
if (dir) {
|
|
43
|
-
await syncTargetDir(path.resolve(dir || '.'), dry, ignoreVerificationErrors);
|
|
44
|
-
}
|
|
45
|
-
if (file) {
|
|
46
|
-
await syncTargetFile(path.resolve(file), dry, ignoreVerificationErrors);
|
|
47
|
-
}
|
|
32
|
+
const handler = async ({ file, dir, dry, ignoreVerificationErrors }) => {
|
|
33
|
+
await schemaService.sync(file, dir, dry, ignoreVerificationErrors);
|
|
48
34
|
};
|
|
49
35
|
exports.handler = handler;
|
|
50
|
-
async function syncTargetFile(targetFile, dry, ignoreVerificationErrors) {
|
|
51
|
-
await (0, verify_1.handler)({ dir: null, file: targetFile, ignoreVerificationErrors });
|
|
52
|
-
const filePath = path.resolve(targetFile);
|
|
53
|
-
if (!filePath.endsWith('.json')) {
|
|
54
|
-
console.log(`Ignored ${path.basename(filePath)}, not a JSON file (needs .json extension)`);
|
|
55
|
-
}
|
|
56
|
-
else {
|
|
57
|
-
console.log(chalk.bold(`Synchronizing ${path.basename(filePath)}`));
|
|
58
|
-
const targetSchema = await (0, readJson_1.readJsonFile)(filePath);
|
|
59
|
-
const syncSchema = syncSchema_1.SyncSchema.createSchemaSync(dry);
|
|
60
|
-
await syncSchema.sync(targetSchema);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
exports.syncTargetFile = syncTargetFile;
|
|
64
|
-
async function syncTargetDir(targetDir, dry, ignoreVerificationErrors) {
|
|
65
|
-
const targetFiles = (0, listFilesInDir_1.flatListFiles)(targetDir, '.json');
|
|
66
|
-
for (const filePath of targetFiles) {
|
|
67
|
-
await syncTargetFile(filePath, dry, ignoreVerificationErrors);
|
|
68
|
-
process.stdout.write('\n');
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
exports.syncTargetDir = syncTargetDir;
|
|
@@ -3,16 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.handler = exports.builder = exports.desc = exports.command = void 0;
|
|
4
4
|
const fs = require("fs");
|
|
5
5
|
const path = require("path");
|
|
6
|
-
const ajv_1 = require("ajv");
|
|
7
|
-
const chalk = require("chalk");
|
|
8
|
-
const metaschema = require("../../../config-json-schemas/Schema.json");
|
|
9
|
-
const error_1 = require("../../../helpers/error");
|
|
10
6
|
const util_1 = require("../../../helpers/util");
|
|
11
|
-
const
|
|
12
|
-
const schemaverify_1 = require("./util/schemaverify");
|
|
7
|
+
const schemaService = require("../../../services/schemas");
|
|
13
8
|
exports.command = 'verify';
|
|
14
9
|
exports.desc = 'Syntactically verify a local schema';
|
|
15
|
-
const builder = (yargs) => (0, util_1.epilogue)(yargs)
|
|
10
|
+
const builder = (yargs) => (0, util_1.epilogue)(yargs)
|
|
11
|
+
.options({
|
|
16
12
|
file: {
|
|
17
13
|
describe: 'schema json file which needs to be verified',
|
|
18
14
|
type: 'string',
|
|
@@ -21,7 +17,8 @@ const builder = (yargs) => (0, util_1.epilogue)(yargs).options({
|
|
|
21
17
|
describe: 'directory containing schemas to be verified',
|
|
22
18
|
type: 'string',
|
|
23
19
|
},
|
|
24
|
-
})
|
|
20
|
+
})
|
|
21
|
+
.check(({ file, dir }) => {
|
|
25
22
|
if (file && (!fs.existsSync(path.resolve(file)) || !fs.lstatSync(path.resolve(file)).isFile())) {
|
|
26
23
|
throw new Error('Schema file does not exist, please make sure you provided the correct file path');
|
|
27
24
|
}
|
|
@@ -35,48 +32,6 @@ const builder = (yargs) => (0, util_1.epilogue)(yargs).options({
|
|
|
35
32
|
});
|
|
36
33
|
exports.builder = builder;
|
|
37
34
|
const handler = async ({ file, dir, ignoreVerificationErrors }) => {
|
|
38
|
-
|
|
39
|
-
if (dir) {
|
|
40
|
-
files = await (0, listFilesInDir_1.flatListFiles)(dir, '.json');
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
43
|
-
files = [file];
|
|
44
|
-
}
|
|
45
|
-
const checkFile = (schemaPath) => {
|
|
46
|
-
let schema = {};
|
|
47
|
-
console.log(chalk.bold('Checking', schemaPath));
|
|
48
|
-
try {
|
|
49
|
-
schema = require(path.resolve(schemaPath));
|
|
50
|
-
}
|
|
51
|
-
catch (err) {
|
|
52
|
-
console.log(chalk.red(`Failed to load schema file ${file}. Possibly not a valid JSON file`));
|
|
53
|
-
console.log(err);
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
const ajv = new ajv_1.default();
|
|
57
|
-
for (const result of (new schemaverify_1.SchemaVerify(ajv, schema, metaschema)).RunChecks()) {
|
|
58
|
-
if (result.ok) {
|
|
59
|
-
console.log(chalk.green(`${result.test}... ✓`));
|
|
60
|
-
}
|
|
61
|
-
else {
|
|
62
|
-
console.log(chalk.red(`${result.test}... x`));
|
|
63
|
-
for (const error of result.errors) {
|
|
64
|
-
if (typeof error === 'object') {
|
|
65
|
-
console.log('\t', chalk.red(JSON.stringify(error, null, 4)));
|
|
66
|
-
}
|
|
67
|
-
else {
|
|
68
|
-
console.log('\t', chalk.red(error));
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
if (!ignoreVerificationErrors) {
|
|
72
|
-
throw new error_1.CommandError(`Schema ${schemaPath} contains error, please fix`);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
console.log();
|
|
77
|
-
};
|
|
78
|
-
for (const f of files) {
|
|
79
|
-
checkFile(f);
|
|
80
|
-
}
|
|
35
|
+
await schemaService.verify(file, dir, ignoreVerificationErrors);
|
|
81
36
|
};
|
|
82
37
|
exports.handler = handler;
|
package/build/commands/sync.js
CHANGED
|
@@ -7,11 +7,11 @@ const ospath = require("path");
|
|
|
7
7
|
const chalk = require("chalk");
|
|
8
8
|
const repoConfig_1 = require("../helpers/repoConfig");
|
|
9
9
|
const util_1 = require("../helpers/util");
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const
|
|
10
|
+
const dispatcherService = require("../services/dispatchers");
|
|
11
|
+
const localizationService = require("../services/localizations");
|
|
12
|
+
const schemaService = require("../services/schemas");
|
|
13
|
+
const taskService = require("../services/tasks");
|
|
14
|
+
const templateService = require("../services/templates");
|
|
15
15
|
exports.command = 'sync';
|
|
16
16
|
exports.desc = 'Sync your ExH configuration to the cloud environment';
|
|
17
17
|
const builder = (yargs) => (0, util_1.epilogue)(yargs)
|
|
@@ -63,7 +63,8 @@ If not, the local directory is assumed with a default configuration which assume
|
|
|
63
63
|
type: 'boolean',
|
|
64
64
|
default: false,
|
|
65
65
|
},
|
|
66
|
-
})
|
|
66
|
+
})
|
|
67
|
+
.check(async ({ path }) => {
|
|
67
68
|
if (path !== undefined) {
|
|
68
69
|
try {
|
|
69
70
|
await fs.access(ospath.join(process.cwd(), path, repoConfig_1.REPO_CONFIG_FILE));
|
|
@@ -85,25 +86,25 @@ const handler = async ({ path, schemas, tasks, templates, dispatchers, cleanDisp
|
|
|
85
86
|
if ((syncAll || schemas) && cfg.schemas) {
|
|
86
87
|
console.log(chalk.green('\n ⚙️ Syncing schemas ...'));
|
|
87
88
|
for (const schema of cfg.schemas) {
|
|
88
|
-
await
|
|
89
|
+
await schemaService.sync(ospath.join(targetPath, schema), undefined, false, ignoreSchemaVerificationErrors);
|
|
89
90
|
}
|
|
90
91
|
}
|
|
91
92
|
if ((syncAll || templates) && cfg.templates) {
|
|
92
93
|
console.log(chalk.green('\n ⚙️ Syncing templates...'));
|
|
93
94
|
for (const template of cfg.templates) {
|
|
94
|
-
await
|
|
95
|
+
await templateService.sync(ospath.join(targetPath, template));
|
|
95
96
|
}
|
|
96
97
|
}
|
|
97
98
|
if ((syncAll || tasks) && cfg.tasks) {
|
|
98
99
|
console.log(chalk.green('\n ⚙️ Syncing tasks...'));
|
|
99
100
|
for (const task of cfg.tasks) {
|
|
100
|
-
await
|
|
101
|
+
await taskService.sync({ path: ospath.join(targetPath, task) });
|
|
101
102
|
}
|
|
102
103
|
}
|
|
103
104
|
if ((syncAll || localizations) && cfg.localizations) {
|
|
104
105
|
console.log(chalk.green('\n ⚙️ Syncing localizations...'));
|
|
105
106
|
for (const localization of cfg.localizations) {
|
|
106
|
-
await
|
|
107
|
+
await localizationService.sync(ospath.join(targetPath, localization));
|
|
107
108
|
}
|
|
108
109
|
}
|
|
109
110
|
if ((syncAll || dispatchers)) {
|
|
@@ -111,7 +112,7 @@ const handler = async ({ path, schemas, tasks, templates, dispatchers, cleanDisp
|
|
|
111
112
|
const isValidPath = (0, fs_1.existsSync)(dispatchersPath);
|
|
112
113
|
if (isValidPath) {
|
|
113
114
|
console.log(chalk.green('\n ⚙️ Syncing dispatchers...'));
|
|
114
|
-
await
|
|
115
|
+
await dispatcherService.sync(dispatchersPath, cleanDispatchers);
|
|
115
116
|
}
|
|
116
117
|
else if (dispatchers) {
|
|
117
118
|
console.log(chalk.yellow('Warning: dispatchers.json not found'));
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.handler = exports.builder = exports.desc = exports.command = void 0;
|
|
4
|
-
const chalk = require("chalk");
|
|
5
4
|
const util_1 = require("../../helpers/util");
|
|
6
|
-
const
|
|
5
|
+
const templateService = require("../../services/templates");
|
|
7
6
|
exports.command = 'delete';
|
|
8
7
|
exports.desc = 'Delete a template';
|
|
9
|
-
const builder = (yargs) => (0, util_1.epilogue)(yargs)
|
|
8
|
+
const builder = (yargs) => (0, util_1.epilogue)(yargs)
|
|
9
|
+
.options({
|
|
10
10
|
name: {
|
|
11
11
|
describe: 'Name of the template to delete',
|
|
12
12
|
type: 'string',
|
|
@@ -15,7 +15,8 @@ const builder = (yargs) => (0, util_1.epilogue)(yargs).options({
|
|
|
15
15
|
describe: 'ID of the template to delete',
|
|
16
16
|
type: 'string',
|
|
17
17
|
},
|
|
18
|
-
})
|
|
18
|
+
})
|
|
19
|
+
.check(({ id, name }) => {
|
|
19
20
|
if ((!id && !name) || (id && name)) {
|
|
20
21
|
throw new Error('Either id or name needs to be provided');
|
|
21
22
|
}
|
|
@@ -23,27 +24,6 @@ const builder = (yargs) => (0, util_1.epilogue)(yargs).options({
|
|
|
23
24
|
});
|
|
24
25
|
exports.builder = builder;
|
|
25
26
|
const handler = async function list({ name, id }) {
|
|
26
|
-
|
|
27
|
-
if (name) {
|
|
28
|
-
template = await templateRepository.findByName(name);
|
|
29
|
-
}
|
|
30
|
-
if (id) {
|
|
31
|
-
template = await templateRepository.findById(id);
|
|
32
|
-
}
|
|
33
|
-
if (!template) {
|
|
34
|
-
console.log(chalk.red('Template not found!'));
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
try {
|
|
38
|
-
const { affectedRecords } = await templateRepository.remove(template.id);
|
|
39
|
-
if (!affectedRecords) {
|
|
40
|
-
console.log(chalk.red('Failed to remove template', name));
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
console.log('Template deleted');
|
|
44
|
-
}
|
|
45
|
-
catch (err) {
|
|
46
|
-
console.log(chalk.red('Failed to remove template', name));
|
|
47
|
-
}
|
|
27
|
+
await templateService.remove(name, id);
|
|
48
28
|
};
|
|
49
29
|
exports.handler = handler;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.handler = exports.builder = exports.desc = exports.command = void 0;
|
|
4
|
-
const chalk = require("chalk");
|
|
5
4
|
const util_1 = require("../../helpers/util");
|
|
6
|
-
const
|
|
5
|
+
const templateService = require("../../services/templates");
|
|
7
6
|
exports.command = 'get';
|
|
8
7
|
exports.desc = 'Fetch a template';
|
|
9
|
-
const builder = (yargs) => (0, util_1.epilogue)(yargs)
|
|
8
|
+
const builder = (yargs) => (0, util_1.epilogue)(yargs)
|
|
9
|
+
.options({
|
|
10
10
|
name: {
|
|
11
11
|
describe: 'Name of the template',
|
|
12
12
|
type: 'string',
|
|
@@ -15,7 +15,8 @@ const builder = (yargs) => (0, util_1.epilogue)(yargs).options({
|
|
|
15
15
|
describe: 'ID of the template',
|
|
16
16
|
type: 'string',
|
|
17
17
|
},
|
|
18
|
-
})
|
|
18
|
+
})
|
|
19
|
+
.check(({ name, id }) => {
|
|
19
20
|
if ((name && id) || (!name && !id)) {
|
|
20
21
|
throw new Error('Either name or id should be specified (but not both at the same time)');
|
|
21
22
|
}
|
|
@@ -23,17 +24,6 @@ const builder = (yargs) => (0, util_1.epilogue)(yargs).options({
|
|
|
23
24
|
});
|
|
24
25
|
exports.builder = builder;
|
|
25
26
|
const handler = async function list({ name, id }) {
|
|
26
|
-
|
|
27
|
-
if (name) {
|
|
28
|
-
template = await templateRepository.findByName(name);
|
|
29
|
-
}
|
|
30
|
-
else if (id) {
|
|
31
|
-
template = await templateRepository.findById(id);
|
|
32
|
-
}
|
|
33
|
-
if (!template) {
|
|
34
|
-
console.log(chalk.red('Failed to get template!'));
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
console.log(JSON.stringify(template, null, 4));
|
|
27
|
+
await templateService.get(name, id);
|
|
38
28
|
};
|
|
39
29
|
exports.handler = handler;
|
|
@@ -1,29 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.handler = exports.builder = exports.desc = exports.command = void 0;
|
|
4
|
-
const chalk = require("chalk");
|
|
5
4
|
const util_1 = require("../../helpers/util");
|
|
6
|
-
const
|
|
5
|
+
const templateService = require("../../services/templates");
|
|
7
6
|
exports.command = 'list';
|
|
8
7
|
exports.desc = 'List all templates';
|
|
9
8
|
const builder = (yargs) => (0, util_1.epilogue)(yargs);
|
|
10
9
|
exports.builder = builder;
|
|
11
10
|
const handler = async function list({ isTTY }) {
|
|
12
|
-
|
|
13
|
-
if (templates.length < 1) {
|
|
14
|
-
console.log(chalk.red('No templates found'));
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
17
|
-
if (isTTY) {
|
|
18
|
-
console.table(templates.map(template => ({
|
|
19
|
-
Id: template.id,
|
|
20
|
-
Name: template.name,
|
|
21
|
-
Description: template.description || '<none>',
|
|
22
|
-
'Last updated': template.updateTimestamp.toISOString(),
|
|
23
|
-
})));
|
|
24
|
-
}
|
|
25
|
-
else {
|
|
26
|
-
templates.forEach(template => console.log(template));
|
|
27
|
-
}
|
|
11
|
+
await templateService.list(isTTY);
|
|
28
12
|
};
|
|
29
13
|
exports.handler = handler;
|
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.handler = exports.builder = exports.desc = exports.command = void 0;
|
|
4
4
|
const fs = require("fs");
|
|
5
5
|
const ospath = require("path");
|
|
6
6
|
const util_1 = require("../../helpers/util");
|
|
7
|
-
const
|
|
8
|
-
const readTemplateFiles_1 = require("./util/readTemplateFiles");
|
|
9
|
-
const uploadTemplate_1 = require("./util/uploadTemplate");
|
|
10
|
-
const utils_1 = require("./util/utils");
|
|
7
|
+
const templateService = require("../../services/templates");
|
|
11
8
|
exports.command = 'sync';
|
|
12
9
|
exports.desc = 'Sync all templates in a directory with the ExH cloud';
|
|
13
|
-
const builder = (yargs) => (0, util_1.epilogue)(yargs)
|
|
10
|
+
const builder = (yargs) => (0, util_1.epilogue)(yargs)
|
|
11
|
+
.options({
|
|
14
12
|
path: {
|
|
15
13
|
demandOption: false,
|
|
16
14
|
describe: 'Directory containing the templates which need to be synced',
|
|
@@ -21,7 +19,8 @@ const builder = (yargs) => (0, util_1.epilogue)(yargs).options({
|
|
|
21
19
|
describe: 'Template file to sync',
|
|
22
20
|
type: 'string',
|
|
23
21
|
},
|
|
24
|
-
})
|
|
22
|
+
})
|
|
23
|
+
.check(({ path, template }) => {
|
|
25
24
|
if (template && !fs.existsSync(ospath.join(process.cwd(), template))) {
|
|
26
25
|
throw new Error('please provide a valid file path for your template');
|
|
27
26
|
}
|
|
@@ -35,29 +34,6 @@ const builder = (yargs) => (0, util_1.epilogue)(yargs).options({
|
|
|
35
34
|
});
|
|
36
35
|
exports.builder = builder;
|
|
37
36
|
const handler = async ({ path, template }) => {
|
|
38
|
-
|
|
39
|
-
await syncTargetDir(ospath.resolve(path));
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
let templ = null;
|
|
43
|
-
if (fs.statSync(ospath.join(process.cwd(), template)).isFile()) {
|
|
44
|
-
templ = await (0, readTemplateFiles_1.readTemplateJson)(template);
|
|
45
|
-
}
|
|
46
|
-
else {
|
|
47
|
-
templ = await (0, readTemplateFiles_1.readTemplateFolder)(template);
|
|
48
|
-
}
|
|
49
|
-
const templateName = (0, utils_1.removeFileNameExtension)(ospath.basename(template));
|
|
50
|
-
await buildAndUploadTemplates({ [templateName]: templ });
|
|
37
|
+
await templateService.sync(path, template);
|
|
51
38
|
};
|
|
52
39
|
exports.handler = handler;
|
|
53
|
-
async function buildAndUploadTemplates(templateObject) {
|
|
54
|
-
const templates = await (0, buildTemplates_1.buildTemplates)(templateObject);
|
|
55
|
-
for (const template of templates) {
|
|
56
|
-
await (0, uploadTemplate_1.uploadTemplate)(template);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
async function syncTargetDir(targetDir) {
|
|
60
|
-
const templateFilesByName = await (0, readTemplateFiles_1.readTemplateFiles)(targetDir);
|
|
61
|
-
await buildAndUploadTemplates(templateFilesByName);
|
|
62
|
-
}
|
|
63
|
-
exports.syncTargetDir = syncTargetDir;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.remove = exports.list = exports.sync = exports.verify = exports.init = void 0;
|
|
4
|
+
const chalk = require("chalk");
|
|
5
|
+
const schemaRepository = require("../../repositories/schemas");
|
|
6
|
+
var init_1 = require("./init");
|
|
7
|
+
Object.defineProperty(exports, "init", { enumerable: true, get: function () { return init_1.init; } });
|
|
8
|
+
var verify_1 = require("./verify");
|
|
9
|
+
Object.defineProperty(exports, "verify", { enumerable: true, get: function () { return verify_1.verify; } });
|
|
10
|
+
var sync_1 = require("./sync");
|
|
11
|
+
Object.defineProperty(exports, "sync", { enumerable: true, get: function () { return sync_1.sync; } });
|
|
12
|
+
async function list(isTTY) {
|
|
13
|
+
const schemas = await schemaRepository.fetchAll();
|
|
14
|
+
if (schemas.length < 1) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
if (isTTY) {
|
|
18
|
+
console.table(schemas.map(schema => ({
|
|
19
|
+
Id: schema.id,
|
|
20
|
+
Name: schema.name,
|
|
21
|
+
Description: schema.description || '<none>',
|
|
22
|
+
})));
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
schemas.forEach(schema => console.log([schema.id, schema.name].join(',')));
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
exports.list = list;
|
|
29
|
+
async function remove(id) {
|
|
30
|
+
const disableResponse = await schemaRepository.disable(id);
|
|
31
|
+
if (disableResponse.affectedRecords !== 1) {
|
|
32
|
+
console.log(chalk.red('Failed to delete schema', id));
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
const deleteResponse = await schemaRepository.remove(id);
|
|
36
|
+
if (deleteResponse.affectedRecords) {
|
|
37
|
+
console.log(chalk.green('Successfully deleted schema', id));
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
console.log(chalk.red('Failed to delete schema', id));
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
exports.remove = remove;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function init(name: string, path: string): Promise<void>;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.init = void 0;
|
|
4
|
+
const promises_1 = require("fs/promises");
|
|
5
|
+
const osPath = require("path");
|
|
6
|
+
const util_1 = require("../../helpers/util");
|
|
7
|
+
async function init(name, path) {
|
|
8
|
+
await (0, promises_1.mkdir)(path, { recursive: true });
|
|
9
|
+
const filePath = osPath.join(path, `${name}.json`);
|
|
10
|
+
await (0, promises_1.writeFile)(filePath, JSON.stringify(createSchema(name), null, 2));
|
|
11
|
+
console.log(`✅ Successfully created ${filePath}`);
|
|
12
|
+
}
|
|
13
|
+
exports.init = init;
|
|
14
|
+
function createSchema(name) {
|
|
15
|
+
return {
|
|
16
|
+
name,
|
|
17
|
+
description: `The ${name} schema`,
|
|
18
|
+
createMode: 'allUsers',
|
|
19
|
+
readMode: ['creator'],
|
|
20
|
+
updateMode: ['creator'],
|
|
21
|
+
deleteMode: ['creator'],
|
|
22
|
+
statuses: {
|
|
23
|
+
new: {},
|
|
24
|
+
},
|
|
25
|
+
creationTransition: {
|
|
26
|
+
type: 'manual',
|
|
27
|
+
toStatus: 'new',
|
|
28
|
+
},
|
|
29
|
+
transitions: [],
|
|
30
|
+
properties: {
|
|
31
|
+
firstProperty: {
|
|
32
|
+
type: 'string',
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
$schema: (0, util_1.getSwaggerDocumentationUrl)('config-json-schemas/Schema.json'),
|
|
36
|
+
};
|
|
37
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export declare function sync(file?: string, dir?: string, dry?: boolean, ignoreVerificationErrors?: boolean): Promise<void>;
|
|
2
|
+
export declare function syncTargetFile(targetFile: string, dry?: boolean, ignoreVerificationErrors?: boolean): Promise<void>;
|
|
3
|
+
export declare function syncTargetDir(targetDir: string, dry?: boolean, ignoreVerificationErrors?: boolean): Promise<void>;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.syncTargetDir = exports.syncTargetFile = exports.sync = void 0;
|
|
4
|
+
const path = require("path");
|
|
5
|
+
const chalk = require("chalk");
|
|
6
|
+
const listFilesInDir_1 = require("./util/listFilesInDir");
|
|
7
|
+
const readJson_1 = require("./util/readJson");
|
|
8
|
+
const syncSchema_1 = require("./util/syncSchema");
|
|
9
|
+
const verify_1 = require("./verify");
|
|
10
|
+
async function sync(file, dir, dry, ignoreVerificationErrors) {
|
|
11
|
+
if (!file && !dir) {
|
|
12
|
+
console.log(chalk.red('No target is chosen to be synced. Please use flags "--file" or "--dir" when syncing'));
|
|
13
|
+
process.exit(1);
|
|
14
|
+
}
|
|
15
|
+
if (dir) {
|
|
16
|
+
await syncTargetDir(path.resolve(dir || '.'), dry, ignoreVerificationErrors);
|
|
17
|
+
}
|
|
18
|
+
if (file) {
|
|
19
|
+
await syncTargetFile(path.resolve(file), dry, ignoreVerificationErrors);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.sync = sync;
|
|
23
|
+
async function syncTargetFile(targetFile, dry, ignoreVerificationErrors) {
|
|
24
|
+
await (0, verify_1.verify)(targetFile, null, ignoreVerificationErrors);
|
|
25
|
+
const filePath = path.resolve(targetFile);
|
|
26
|
+
if (!filePath.endsWith('.json')) {
|
|
27
|
+
console.log(`Ignored ${path.basename(filePath)}, not a JSON file (needs .json extension)`);
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
console.log(chalk.bold(`Synchronizing ${path.basename(filePath)}`));
|
|
31
|
+
const targetSchema = await (0, readJson_1.readJsonFile)(filePath);
|
|
32
|
+
const syncSchema = syncSchema_1.SyncSchema.createSchemaSync(dry);
|
|
33
|
+
await syncSchema.sync(targetSchema);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
exports.syncTargetFile = syncTargetFile;
|
|
37
|
+
async function syncTargetDir(targetDir, dry, ignoreVerificationErrors) {
|
|
38
|
+
const targetFiles = (0, listFilesInDir_1.flatListFiles)(targetDir, '.json');
|
|
39
|
+
for (const filePath of targetFiles) {
|
|
40
|
+
await syncTargetFile(filePath, dry, ignoreVerificationErrors);
|
|
41
|
+
process.stdout.write('\n');
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
exports.syncTargetDir = syncTargetDir;
|
|
@@ -9,7 +9,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
9
9
|
exports.compareSchemaKey = exports.SyncSchema = void 0;
|
|
10
10
|
const chalk = require("chalk");
|
|
11
11
|
const _ = require("lodash");
|
|
12
|
-
const schemaRepository = require("
|
|
12
|
+
const schemaRepository = require("../../../repositories/schemas");
|
|
13
13
|
const statusHelpers_1 = require("../sync/statusHelpers");
|
|
14
14
|
const stripUnsupportedDescriptionFields_1 = require("./stripUnsupportedDescriptionFields");
|
|
15
15
|
class SyncSchema {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function verify(file?: string, dir?: string, ignoreVerificationErrors?: boolean): Promise<void>;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.verify = void 0;
|
|
4
|
+
const path = require("path");
|
|
5
|
+
const ajv_1 = require("ajv");
|
|
6
|
+
const chalk = require("chalk");
|
|
7
|
+
const metaschema = require("../../config-json-schemas/Schema.json");
|
|
8
|
+
const error_1 = require("../../helpers/error");
|
|
9
|
+
const listFilesInDir_1 = require("./util/listFilesInDir");
|
|
10
|
+
const schemaverify_1 = require("./util/schemaverify");
|
|
11
|
+
async function verify(file, dir, ignoreVerificationErrors) {
|
|
12
|
+
let files = [];
|
|
13
|
+
if (dir) {
|
|
14
|
+
files = await (0, listFilesInDir_1.flatListFiles)(dir, '.json');
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
files = [file];
|
|
18
|
+
}
|
|
19
|
+
const checkFile = (schemaPath) => {
|
|
20
|
+
let schema = {};
|
|
21
|
+
console.log(chalk.bold('Checking', schemaPath));
|
|
22
|
+
try {
|
|
23
|
+
schema = require(path.resolve(schemaPath));
|
|
24
|
+
}
|
|
25
|
+
catch (err) {
|
|
26
|
+
console.log(chalk.red(`Failed to load schema file ${file}. Possibly not a valid JSON file`));
|
|
27
|
+
console.log(err);
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
const ajv = new ajv_1.default();
|
|
31
|
+
for (const result of (new schemaverify_1.SchemaVerify(ajv, schema, metaschema)).RunChecks()) {
|
|
32
|
+
if (result.ok) {
|
|
33
|
+
console.log(chalk.green(`${result.test}... ✓`));
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
console.log(chalk.red(`${result.test}... x`));
|
|
37
|
+
for (const error of result.errors) {
|
|
38
|
+
if (typeof error === 'object') {
|
|
39
|
+
console.log('\t', chalk.red(JSON.stringify(error, null, 4)));
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
console.log('\t', chalk.red(error));
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
if (!ignoreVerificationErrors) {
|
|
46
|
+
throw new error_1.CommandError(`Schema ${schemaPath} contains error, please fix`);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
console.log();
|
|
51
|
+
};
|
|
52
|
+
for (const f of files) {
|
|
53
|
+
checkFile(f);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
exports.verify = verify;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.remove = exports.get = exports.list = exports.sync = void 0;
|
|
4
|
+
const chalk = require("chalk");
|
|
5
|
+
const templateRepository = require("../../repositories/templates");
|
|
6
|
+
var sync_1 = require("./sync");
|
|
7
|
+
Object.defineProperty(exports, "sync", { enumerable: true, get: function () { return sync_1.sync; } });
|
|
8
|
+
async function list(isTTY) {
|
|
9
|
+
const templates = await templateRepository.findAll();
|
|
10
|
+
if (templates.length < 1) {
|
|
11
|
+
console.log(chalk.red('No templates found'));
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
if (isTTY) {
|
|
15
|
+
console.table(templates.map(template => ({
|
|
16
|
+
Id: template.id,
|
|
17
|
+
Name: template.name,
|
|
18
|
+
Description: template.description || '<none>',
|
|
19
|
+
'Last updated': template.updateTimestamp.toISOString(),
|
|
20
|
+
})));
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
templates.forEach(template => console.log(template));
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
exports.list = list;
|
|
27
|
+
async function get(name, id) {
|
|
28
|
+
let template;
|
|
29
|
+
if (name) {
|
|
30
|
+
template = await templateRepository.findByName(name);
|
|
31
|
+
}
|
|
32
|
+
else if (id) {
|
|
33
|
+
template = await templateRepository.findById(id);
|
|
34
|
+
}
|
|
35
|
+
if (!template) {
|
|
36
|
+
console.log(chalk.red('Failed to get template!'));
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
console.log(JSON.stringify(template, null, 4));
|
|
40
|
+
}
|
|
41
|
+
exports.get = get;
|
|
42
|
+
async function remove(name, id) {
|
|
43
|
+
let template = null;
|
|
44
|
+
if (name) {
|
|
45
|
+
template = await templateRepository.findByName(name);
|
|
46
|
+
}
|
|
47
|
+
if (id) {
|
|
48
|
+
template = await templateRepository.findById(id);
|
|
49
|
+
}
|
|
50
|
+
if (!template) {
|
|
51
|
+
console.log(chalk.red('Template not found!'));
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
try {
|
|
55
|
+
const { affectedRecords } = await templateRepository.remove(template.id);
|
|
56
|
+
if (!affectedRecords) {
|
|
57
|
+
console.log(chalk.red('Failed to remove template', name));
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
console.log('Template deleted');
|
|
61
|
+
}
|
|
62
|
+
catch (err) {
|
|
63
|
+
console.log(chalk.red('Failed to remove template', name));
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
exports.remove = remove;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.syncTargetDir = exports.sync = void 0;
|
|
4
|
+
const fs = require("fs");
|
|
5
|
+
const ospath = require("path");
|
|
6
|
+
const buildTemplates_1 = require("./util/buildTemplates");
|
|
7
|
+
const readTemplateFiles_1 = require("./util/readTemplateFiles");
|
|
8
|
+
const uploadTemplate_1 = require("./util/uploadTemplate");
|
|
9
|
+
const utils_1 = require("./util/utils");
|
|
10
|
+
async function sync(path, template) {
|
|
11
|
+
if (path) {
|
|
12
|
+
await syncTargetDir(ospath.resolve(path));
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
let templ = null;
|
|
16
|
+
if (fs.statSync(ospath.join(process.cwd(), template)).isFile()) {
|
|
17
|
+
templ = await (0, readTemplateFiles_1.readTemplateJson)(template);
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
templ = await (0, readTemplateFiles_1.readTemplateFolder)(template);
|
|
21
|
+
}
|
|
22
|
+
const templateName = (0, utils_1.removeFileNameExtension)(ospath.basename(template));
|
|
23
|
+
await buildAndUploadTemplates({ [templateName]: templ });
|
|
24
|
+
}
|
|
25
|
+
exports.sync = sync;
|
|
26
|
+
async function buildAndUploadTemplates(templateObject) {
|
|
27
|
+
const templates = await (0, buildTemplates_1.buildTemplates)(templateObject);
|
|
28
|
+
for (const template of templates) {
|
|
29
|
+
await (0, uploadTemplate_1.uploadTemplate)(template);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
async function syncTargetDir(targetDir) {
|
|
33
|
+
const templateFilesByName = await (0, readTemplateFiles_1.readTemplateFiles)(targetDir);
|
|
34
|
+
await buildAndUploadTemplates(templateFilesByName);
|
|
35
|
+
}
|
|
36
|
+
exports.syncTargetDir = syncTargetDir;
|
package/package.json
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/build/{commands/data → services}/schemas/util/stripUnsupportedDescriptionFields.d.ts
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|