@extrahorizon/exh-cli 1.12.0 → 1.13.0-dev-164-e39f2f4
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/CHANGELOG.md +2 -0
- package/build/commands/dispatchers/init.d.ts +16 -0
- package/build/commands/dispatchers/init.js +25 -0
- package/build/commands/sync.d.ts +1 -1
- package/build/commands/templates/init.d.ts +16 -0
- package/build/commands/templates/init.js +25 -0
- package/build/index.js +2 -0
- package/build/services/dispatchers/index.d.ts +2 -0
- package/build/services/dispatchers/index.js +7 -0
- package/build/services/dispatchers/init.d.ts +1 -0
- package/build/services/dispatchers/init.js +40 -0
- package/build/services/{dispatchers.js → dispatchers/sync.js} +3 -20
- package/build/services/dispatchers/util/readDispatcherFile.d.ts +5 -0
- package/build/services/dispatchers/util/readDispatcherFile.js +22 -0
- package/build/services/templates/index.d.ts +1 -0
- package/build/services/templates/index.js +3 -1
- package/build/services/templates/init.d.ts +1 -0
- package/build/services/templates/init.js +40 -0
- package/package.json +1 -1
- /package/build/services/{dispatchers.d.ts → dispatchers/sync.d.ts} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# Extra Horizon CLI changelog
|
|
2
2
|
|
|
3
|
+
### v1.13.0
|
|
4
|
+
|
|
3
5
|
### v1.12.0
|
|
4
6
|
* Now adding `$schema` as the last property when creating a new schema via `exh data schemas init`
|
|
5
7
|
* The `exh tasks create-repo` command now creates `package.json` and `task-config.json` files with 2 spaces indentation instead of 4 spaces.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/// <reference types="yargs" />
|
|
2
|
+
export declare const command = "init <name>";
|
|
3
|
+
export declare const desc = "Create a basic Dispatcher";
|
|
4
|
+
export declare const builder: (yargs: any) => import("yargs").Argv<import("yargs").Omit<{
|
|
5
|
+
name: string;
|
|
6
|
+
}, "path"> & import("yargs").InferredOptionTypes<{
|
|
7
|
+
path: {
|
|
8
|
+
description: string;
|
|
9
|
+
type: "string";
|
|
10
|
+
default: string;
|
|
11
|
+
};
|
|
12
|
+
}>>;
|
|
13
|
+
export declare const handler: ({ name, path }: {
|
|
14
|
+
name: string;
|
|
15
|
+
path: string;
|
|
16
|
+
}) => Promise<void>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.handler = exports.builder = exports.desc = exports.command = void 0;
|
|
4
|
+
const util_1 = require("../../helpers/util");
|
|
5
|
+
const dispatcherService = require("../../services/dispatchers");
|
|
6
|
+
exports.command = 'init <name>';
|
|
7
|
+
exports.desc = 'Create a basic Dispatcher';
|
|
8
|
+
const builder = (yargs) => (0, util_1.epilogue)(yargs)
|
|
9
|
+
.positional('name', {
|
|
10
|
+
demandOption: true,
|
|
11
|
+
description: 'The name of the new Dispatcher',
|
|
12
|
+
type: 'string',
|
|
13
|
+
})
|
|
14
|
+
.options({
|
|
15
|
+
path: {
|
|
16
|
+
description: 'The path to the folder where the Dispatchers file should be created',
|
|
17
|
+
type: 'string',
|
|
18
|
+
default: './',
|
|
19
|
+
},
|
|
20
|
+
});
|
|
21
|
+
exports.builder = builder;
|
|
22
|
+
const handler = async function init({ name, path }) {
|
|
23
|
+
await dispatcherService.init(name, path);
|
|
24
|
+
};
|
|
25
|
+
exports.handler = handler;
|
package/build/commands/sync.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="yargs" />
|
|
2
2
|
export declare const command = "sync";
|
|
3
3
|
export declare const desc = "Sync your ExH configuration to the cloud environment";
|
|
4
|
-
export declare const builder: (yargs: any) => import("yargs").Argv<import("yargs").Omit<{}, "path" | "schemas" | "
|
|
4
|
+
export declare const builder: (yargs: any) => import("yargs").Argv<import("yargs").Omit<{}, "path" | "schemas" | "dispatchers" | "tasks" | "templates" | "localizations" | "cleanDispatchers" | "ignoreSchemaVerificationErrors"> & import("yargs").InferredOptionTypes<{
|
|
5
5
|
path: {
|
|
6
6
|
demandOption: false;
|
|
7
7
|
describe: string;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/// <reference types="yargs" />
|
|
2
|
+
export declare const command = "init <name>";
|
|
3
|
+
export declare const desc = "Create a basic Template";
|
|
4
|
+
export declare const builder: (yargs: any) => import("yargs").Argv<import("yargs").Omit<{
|
|
5
|
+
name: string;
|
|
6
|
+
}, "path"> & import("yargs").InferredOptionTypes<{
|
|
7
|
+
path: {
|
|
8
|
+
description: string;
|
|
9
|
+
type: "string";
|
|
10
|
+
default: string;
|
|
11
|
+
};
|
|
12
|
+
}>>;
|
|
13
|
+
export declare const handler: ({ name, path }: {
|
|
14
|
+
name: string;
|
|
15
|
+
path: string;
|
|
16
|
+
}) => Promise<void>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.handler = exports.builder = exports.desc = exports.command = void 0;
|
|
4
|
+
const util_1 = require("../../helpers/util");
|
|
5
|
+
const templateService = require("../../services/templates");
|
|
6
|
+
exports.command = 'init <name>';
|
|
7
|
+
exports.desc = 'Create a basic Template';
|
|
8
|
+
const builder = (yargs) => (0, util_1.epilogue)(yargs)
|
|
9
|
+
.positional('name', {
|
|
10
|
+
demandOption: true,
|
|
11
|
+
description: 'The name of the new template',
|
|
12
|
+
type: 'string',
|
|
13
|
+
})
|
|
14
|
+
.options({
|
|
15
|
+
path: {
|
|
16
|
+
description: 'The path to the folder where the template should be created',
|
|
17
|
+
type: 'string',
|
|
18
|
+
default: './templates',
|
|
19
|
+
},
|
|
20
|
+
});
|
|
21
|
+
exports.builder = builder;
|
|
22
|
+
const handler = async function init({ name, path }) {
|
|
23
|
+
await templateService.init(name, path);
|
|
24
|
+
};
|
|
25
|
+
exports.handler = handler;
|
package/build/index.js
CHANGED
|
@@ -12,7 +12,9 @@ yargs((0, helpers_1.hideBin)(process.argv))
|
|
|
12
12
|
if ((0, lodash_1.isEqual)(argv._, ['login']) ||
|
|
13
13
|
(0, lodash_1.isEqual)(argv._, ['data', 'schemas', 'init']) ||
|
|
14
14
|
(0, lodash_1.isEqual)(argv._, ['data', 'schemas', 'verify']) ||
|
|
15
|
+
(0, lodash_1.isEqual)(argv._, ['dispatchers', 'init']) ||
|
|
15
16
|
(0, lodash_1.isEqual)(argv._, ['tasks', 'create-repo']) ||
|
|
17
|
+
(0, lodash_1.isEqual)(argv._, ['templates', 'init']) ||
|
|
16
18
|
(0, lodash_1.isEqual)(argv._, ['completion']) ||
|
|
17
19
|
(0, lodash_1.isEqual)(argv._, ['generate_completion']) ||
|
|
18
20
|
process.env.NO_SDK) {
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.sync = exports.init = void 0;
|
|
4
|
+
var init_1 = require("./init");
|
|
5
|
+
Object.defineProperty(exports, "init", { enumerable: true, get: function () { return init_1.init; } });
|
|
6
|
+
var sync_1 = require("./sync");
|
|
7
|
+
Object.defineProperty(exports, "sync", { enumerable: true, get: function () { return sync_1.sync; } });
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function init(name: string, path: string): Promise<void>;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.init = void 0;
|
|
4
|
+
const fs_1 = require("fs");
|
|
5
|
+
const promises_1 = require("fs/promises");
|
|
6
|
+
const osPath = require("path");
|
|
7
|
+
const javascript_sdk_1 = require("@extrahorizon/javascript-sdk");
|
|
8
|
+
const util_1 = require("../../helpers/util");
|
|
9
|
+
const readDispatcherFile_1 = require("./util/readDispatcherFile");
|
|
10
|
+
async function init(name, path) {
|
|
11
|
+
const filePath = osPath.join(path, 'dispatchers.json');
|
|
12
|
+
const exists = (0, fs_1.existsSync)(filePath);
|
|
13
|
+
const fileContent = {
|
|
14
|
+
dispatchers: [createDispatcher(name)],
|
|
15
|
+
$schema: (0, util_1.getSwaggerDocumentationUrl)('config-json-schemas/Dispatchers.json'),
|
|
16
|
+
};
|
|
17
|
+
if (exists) {
|
|
18
|
+
const existingDispatchers = await (0, readDispatcherFile_1.readAndValidateDispatcherConfig)(filePath);
|
|
19
|
+
fileContent.dispatchers.push(...existingDispatchers);
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
await (0, promises_1.mkdir)(`${path}`, { recursive: true });
|
|
23
|
+
}
|
|
24
|
+
await (0, promises_1.writeFile)(filePath, JSON.stringify(fileContent, null, 2));
|
|
25
|
+
console.log(`✅ Successfully ${exists ? 'updated' : 'created'} ${filePath}`);
|
|
26
|
+
}
|
|
27
|
+
exports.init = init;
|
|
28
|
+
function createDispatcher(name) {
|
|
29
|
+
return {
|
|
30
|
+
eventType: 'my-custom-event',
|
|
31
|
+
name,
|
|
32
|
+
actions: [
|
|
33
|
+
{
|
|
34
|
+
type: javascript_sdk_1.ActionType.TASK,
|
|
35
|
+
name: 'task-action',
|
|
36
|
+
functionName: 'my-function-name',
|
|
37
|
+
},
|
|
38
|
+
],
|
|
39
|
+
};
|
|
40
|
+
}
|
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.sync = exports.cliManagedTag = void 0;
|
|
4
|
-
const promises_1 = require("fs/promises");
|
|
5
4
|
const javascript_sdk_1 = require("@extrahorizon/javascript-sdk");
|
|
6
5
|
const chalk_1 = require("chalk");
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const dispatcherRepository = require("../repositories/dispatchers");
|
|
6
|
+
const dispatcherRepository = require("../../repositories/dispatchers");
|
|
7
|
+
const readDispatcherFile_1 = require("./util/readDispatcherFile");
|
|
10
8
|
exports.cliManagedTag = 'EXH_CLI_MANAGED';
|
|
11
9
|
async function sync(path, clean = false) {
|
|
12
10
|
console.log((0, chalk_1.yellow)(`Synchronizing Dispatchers from ${path}`));
|
|
13
|
-
const localDispatchers = await readAndValidateDispatcherConfig(path);
|
|
11
|
+
const localDispatchers = await (0, readDispatcherFile_1.readAndValidateDispatcherConfig)(path);
|
|
14
12
|
const rql = (0, javascript_sdk_1.rqlBuilder)().eq('tags', exports.cliManagedTag).build();
|
|
15
13
|
const exhDispatchers = await dispatcherRepository.findAll(rql);
|
|
16
14
|
console.group((0, chalk_1.blue)('Synchronizing Dispatchers:'));
|
|
@@ -87,18 +85,3 @@ async function synchronizeActions(localDispatcher, exhDispatcher) {
|
|
|
87
85
|
}
|
|
88
86
|
}
|
|
89
87
|
}
|
|
90
|
-
async function readAndValidateDispatcherConfig(path) {
|
|
91
|
-
let config;
|
|
92
|
-
try {
|
|
93
|
-
const buffer = await (0, promises_1.readFile)(path);
|
|
94
|
-
config = JSON.parse(buffer.toString());
|
|
95
|
-
}
|
|
96
|
-
catch (error) {
|
|
97
|
-
throw new Error(`Failed to read Dispatchers from ${path}: ${error.message}`);
|
|
98
|
-
}
|
|
99
|
-
(0, util_1.ajvValidate)(dispatcherSchema, config);
|
|
100
|
-
if (Array.isArray(config)) {
|
|
101
|
-
return config;
|
|
102
|
-
}
|
|
103
|
-
return config.dispatchers;
|
|
104
|
-
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { DispatcherCreation } from '@extrahorizon/javascript-sdk';
|
|
2
|
+
export declare type DispatchersFile = DispatcherCreation[] | {
|
|
3
|
+
dispatchers: DispatcherCreation[];
|
|
4
|
+
};
|
|
5
|
+
export declare function readAndValidateDispatcherConfig(path: string): Promise<DispatcherCreation[]>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.readAndValidateDispatcherConfig = void 0;
|
|
4
|
+
const promises_1 = require("fs/promises");
|
|
5
|
+
const dispatcherSchema = require("../../../config-json-schemas/Dispatchers.json");
|
|
6
|
+
const util_1 = require("../../../helpers/util");
|
|
7
|
+
async function readAndValidateDispatcherConfig(path) {
|
|
8
|
+
let config;
|
|
9
|
+
try {
|
|
10
|
+
const buffer = await (0, promises_1.readFile)(path);
|
|
11
|
+
config = JSON.parse(buffer.toString());
|
|
12
|
+
}
|
|
13
|
+
catch (error) {
|
|
14
|
+
throw new Error(`Failed to read Dispatchers from ${path}: ${error.message}`);
|
|
15
|
+
}
|
|
16
|
+
(0, util_1.ajvValidate)(dispatcherSchema, config);
|
|
17
|
+
if (Array.isArray(config)) {
|
|
18
|
+
return config;
|
|
19
|
+
}
|
|
20
|
+
return config.dispatchers;
|
|
21
|
+
}
|
|
22
|
+
exports.readAndValidateDispatcherConfig = readAndValidateDispatcherConfig;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.remove = exports.list = exports.get = exports.sync = void 0;
|
|
3
|
+
exports.init = exports.remove = exports.list = exports.get = exports.sync = void 0;
|
|
4
4
|
var sync_1 = require("./sync");
|
|
5
5
|
Object.defineProperty(exports, "sync", { enumerable: true, get: function () { return sync_1.sync; } });
|
|
6
6
|
var get_1 = require("./get");
|
|
@@ -9,3 +9,5 @@ var list_1 = require("./list");
|
|
|
9
9
|
Object.defineProperty(exports, "list", { enumerable: true, get: function () { return list_1.list; } });
|
|
10
10
|
var remove_1 = require("./remove");
|
|
11
11
|
Object.defineProperty(exports, "remove", { enumerable: true, get: function () { return remove_1.remove; } });
|
|
12
|
+
var init_1 = require("./init");
|
|
13
|
+
Object.defineProperty(exports, "init", { enumerable: true, get: function () { return init_1.init; } });
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function init(name: string, path: string): Promise<void>;
|
|
@@ -0,0 +1,40 @@
|
|
|
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}/${name}`, { recursive: true });
|
|
9
|
+
const templatePath = osPath.join(path, `/${name}/template.json`);
|
|
10
|
+
const bodyPath = osPath.join(path, `/${name}/body.hbs`);
|
|
11
|
+
await (0, promises_1.writeFile)(templatePath, JSON.stringify(createTemplate(name), null, 2));
|
|
12
|
+
await (0, promises_1.writeFile)(bodyPath, createBody());
|
|
13
|
+
console.log(`✅ Successfully created ${templatePath}`);
|
|
14
|
+
console.log(`✅ Successfully created ${bodyPath}`);
|
|
15
|
+
}
|
|
16
|
+
exports.init = init;
|
|
17
|
+
function createTemplate(name) {
|
|
18
|
+
return {
|
|
19
|
+
description: `The ${name} template`,
|
|
20
|
+
inputs: {
|
|
21
|
+
first_name: {
|
|
22
|
+
type: 'string',
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
outputs: {
|
|
26
|
+
subject: 'Welcome {{@inputs.first_name}}',
|
|
27
|
+
},
|
|
28
|
+
$schema: (0, util_1.getSwaggerDocumentationUrl)('config-json-schemas/Template.json'),
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
function createBody() {
|
|
32
|
+
return `<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
33
|
+
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
34
|
+
<body>
|
|
35
|
+
<p>Hello {{@inputs.first_name}},</p>
|
|
36
|
+
<p>Welcome to our application!</p>
|
|
37
|
+
<p>– The Team</p>
|
|
38
|
+
</body>
|
|
39
|
+
</html>`;
|
|
40
|
+
}
|
package/package.json
CHANGED
|
File without changes
|