@extrahorizon/exh-cli 1.13.0-feat-168-eab0ce8 → 1.13.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.
Files changed (63) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/build/commands/data/schemas/sync.d.ts +4 -4
  3. package/build/commands/data/schemas/sync.js +4 -4
  4. package/build/commands/data/schemas/verify.d.ts +2 -2
  5. package/build/commands/data/schemas/verify.js +2 -2
  6. package/build/commands/dispatchers/init.d.ts +4 -4
  7. package/build/commands/dispatchers/init.js +5 -5
  8. package/build/commands/dispatchers/sync.d.ts +4 -3
  9. package/build/commands/dispatchers/sync.js +4 -3
  10. package/build/commands/localizations/sync.d.ts +1 -1
  11. package/build/commands/localizations/sync.js +1 -1
  12. package/build/commands/login.d.ts +5 -5
  13. package/build/commands/login.js +5 -5
  14. package/build/commands/settings/sync.d.ts +11 -2
  15. package/build/commands/settings/sync.js +10 -5
  16. package/build/commands/sync.d.ts +9 -9
  17. package/build/commands/sync.js +9 -9
  18. package/build/commands/tasks/{createrepo.d.ts → create-repo.d.ts} +10 -3
  19. package/build/commands/tasks/{createrepo.js → create-repo.js} +10 -4
  20. package/build/commands/tasks/init.d.ts +22 -0
  21. package/build/commands/tasks/init.js +30 -0
  22. package/build/commands/tasks/sync.d.ts +9 -9
  23. package/build/commands/tasks/sync.js +9 -9
  24. package/build/commands/templates/delete.d.ts +2 -2
  25. package/build/commands/templates/delete.js +2 -2
  26. package/build/commands/templates/get.d.ts +2 -2
  27. package/build/commands/templates/get.js +2 -2
  28. package/build/commands/templates/sync.d.ts +2 -2
  29. package/build/commands/templates/sync.js +2 -2
  30. package/build/config-json-schemas/Dispatchers.json +14 -2
  31. package/build/config-json-schemas/Template.json +26 -198
  32. package/build/exh.d.ts +2 -1
  33. package/build/exh.js +58 -17
  34. package/build/helpers/repoConfig.d.ts +1 -1
  35. package/build/helpers/repoConfig.js +41 -35
  36. package/build/helpers/util.d.ts +0 -1
  37. package/build/helpers/util.js +1 -31
  38. package/build/index.js +1 -0
  39. package/build/repositories/auth.d.ts +1 -1
  40. package/build/repositories/auth.js +1 -2
  41. package/build/repositories/functions.js +1 -1
  42. package/build/repositories/schemas.d.ts +1 -1
  43. package/build/repositories/schemas.js +1 -1
  44. package/build/repositories/user.d.ts +1 -1
  45. package/build/services/auth.js +7 -17
  46. package/build/services/dispatchers/init.d.ts +1 -1
  47. package/build/services/dispatchers/init.js +4 -4
  48. package/build/services/dispatchers/sync.js +32 -7
  49. package/build/services/settings/sync.js +1 -1
  50. package/build/services/settings/util/readServiceSettingsFile.js +1 -1
  51. package/build/services/sync.js +1 -1
  52. package/build/services/tasks/index.d.ts +1 -1
  53. package/build/services/tasks/index.js +3 -3
  54. package/build/services/tasks/init.d.ts +8 -0
  55. package/build/services/tasks/init.js +55 -0
  56. package/build/services/tasks/util.d.ts +2 -2
  57. package/build/services/tasks/util.js +2 -1
  58. package/build/services/templates/util/readTemplateFiles.js +3 -1
  59. package/build/services/templates/util/utils.js +1 -2
  60. package/package.json +2 -2
  61. package/build/services/tasks/createRepo.d.ts +0 -5
  62. package/build/services/tasks/createRepo.js +0 -52
  63. /package/build/config-json-schemas/{SettingsConfig.json → ServiceSettings.json} +0 -0
@@ -1,12 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getAjvErrorStrings = exports.ajvValidate = exports.getSwaggerDocumentationUrl = exports.loadAndAssertCredentials = exports.asyncExec = exports.epilogue = void 0;
3
+ exports.getAjvErrorStrings = exports.ajvValidate = exports.getSwaggerDocumentationUrl = exports.asyncExec = exports.epilogue = void 0;
4
4
  const child_process_1 = require("child_process");
5
5
  const fs = require("fs");
6
6
  const path = require("path");
7
7
  const ajv_1 = require("ajv");
8
8
  const chalk = require("chalk");
9
- const constants_1 = require("../constants");
10
9
  const error_1 = require("./error");
11
10
  function epilogue(y) {
12
11
  return y.epilogue('Visit https://docs.extrahorizon.com/extrahorizon-cli/ for more information.').fail((msg, err, argv) => {
@@ -38,35 +37,6 @@ async function asyncExec(cmd) {
38
37
  });
39
38
  }
40
39
  exports.asyncExec = asyncExec;
41
- function loadAndAssertCredentials() {
42
- const credentials = {};
43
- let errorMessage = '';
44
- try {
45
- const credentialsFile = fs.readFileSync(constants_1.EXH_CONFIG_FILE, 'utf-8');
46
- const credentialFileLines = credentialsFile.split(/\r?\n/);
47
- for (const credentialFileLine of credentialFileLines) {
48
- const [key, value] = credentialFileLine.split('=');
49
- if (key && value) {
50
- credentials[key.trim()] = value.trim();
51
- }
52
- }
53
- }
54
- catch (e) {
55
- errorMessage += 'Couldn\'t open ~/.exh/credentials. ';
56
- }
57
- const requiredEnvVariables = ['API_HOST', 'API_OAUTH_CONSUMER_KEY', 'API_OAUTH_CONSUMER_SECRET', 'API_OAUTH_TOKEN', 'API_OAUTH_TOKEN_SECRET'];
58
- for (const key of requiredEnvVariables) {
59
- if (credentials[key] && !process.env[key]) {
60
- process.env[key] = credentials[key];
61
- }
62
- }
63
- const missingEnvironmentVariables = requiredEnvVariables.filter(key => !process.env[key]);
64
- if (missingEnvironmentVariables.length > 0) {
65
- errorMessage += `Missing environment variables: ${missingEnvironmentVariables.join(',')}`;
66
- throw new Error(`Failed to retrieve all credentials. ${errorMessage}`);
67
- }
68
- }
69
- exports.loadAndAssertCredentials = loadAndAssertCredentials;
70
40
  function getSwaggerDocumentationUrl(subPath) {
71
41
  const packageJsonPath = path.join(__dirname, '../../package.json');
72
42
  const packageJsonString = fs.readFileSync(packageJsonPath, 'utf-8');
package/build/index.js CHANGED
@@ -13,6 +13,7 @@ yargs((0, helpers_1.hideBin)(process.argv))
13
13
  (0, lodash_1.isEqual)(argv._, ['data', 'schemas', 'init']) ||
14
14
  (0, lodash_1.isEqual)(argv._, ['data', 'schemas', 'verify']) ||
15
15
  (0, lodash_1.isEqual)(argv._, ['dispatchers', 'init']) ||
16
+ (0, lodash_1.isEqual)(argv._, ['tasks', 'init']) ||
16
17
  (0, lodash_1.isEqual)(argv._, ['tasks', 'create-repo']) ||
17
18
  (0, lodash_1.isEqual)(argv._, ['templates', 'init']) ||
18
19
  (0, lodash_1.isEqual)(argv._, ['completion']) ||
@@ -1,3 +1,3 @@
1
1
  export declare function getHost(): string;
2
- export declare function createOAuth1Tokens(email: string, password: string): Promise<any>;
2
+ export declare function createOAuth1Tokens(email: string, password: string): Promise<import("@extrahorizon/javascript-sdk").TokenDataOauth1>;
3
3
  export declare function fetchMe(): Promise<import("@extrahorizon/javascript-sdk").UserData>;
@@ -7,8 +7,7 @@ function getHost() {
7
7
  }
8
8
  exports.getHost = getHost;
9
9
  async function createOAuth1Tokens(email, password) {
10
- const response = await (0, exh_1.getSdk)().raw.post('/auth/v2/oauth1/tokens', { email, password });
11
- return response.data;
10
+ return (0, exh_1.getNewSdkInstance)().auth.authenticate({ email, password });
12
11
  }
13
12
  exports.createOAuth1Tokens = createOAuth1Tokens;
14
13
  async function fetchMe() {
@@ -10,7 +10,7 @@ async function find() {
10
10
  exports.find = find;
11
11
  async function findByName(name) {
12
12
  try {
13
- return (0, exh_1.getSdk)().tasks.functions.getByName(name);
13
+ return await (0, exh_1.getSdk)().tasks.functions.getByName(name);
14
14
  }
15
15
  catch (e) {
16
16
  if (e instanceof javascript_sdk_1.ResourceUnknownError) {
@@ -15,7 +15,7 @@ export declare function createStatus(id: string, name: string, data: StatusData)
15
15
  export declare function updateStatus(id: string, name: string, data: StatusData): Promise<import("@extrahorizon/javascript-sdk").AffectedRecords>;
16
16
  export declare function deleteStatus(id: string, name: string): Promise<import("@extrahorizon/javascript-sdk").AffectedRecords>;
17
17
  export declare function updateCreationTransition(id: string, data: CreationTransition): Promise<import("@extrahorizon/javascript-sdk").AffectedRecords>;
18
- export declare function createTransition(id: string, data: TransitionInput): Promise<import("@extrahorizon/javascript-sdk").AffectedRecords>;
18
+ export declare function createTransition(id: string, data: TransitionInput): Promise<import("@extrahorizon/javascript-sdk").Transition>;
19
19
  export declare function updateTransition(schemaId: string, transitionId: string, data: TransitionInput): Promise<import("@extrahorizon/javascript-sdk").AffectedRecords>;
20
20
  export declare function deleteTransition(schemaId: string, transitionId: string): Promise<import("@extrahorizon/javascript-sdk").AffectedRecords>;
21
21
  export declare function createIndex(schemaId: string, index: IndexInput): Promise<import("@extrahorizon/javascript-sdk").Index>;
@@ -48,7 +48,7 @@ async function createStatus(id, name, data) {
48
48
  }
49
49
  exports.createStatus = createStatus;
50
50
  async function updateStatus(id, name, data) {
51
- return (0, exh_1.getSdk)().data.statuses.update(id, name, data);
51
+ return (0, exh_1.getSdk)().data.statuses.update(id, name, { data });
52
52
  }
53
53
  exports.updateStatus = updateStatus;
54
54
  async function deleteStatus(id, name) {
@@ -9,4 +9,4 @@ export declare function removePermissionsFromGlobalRole(name: string, permission
9
9
  export declare function addGlobalRoleToUser(userId: string, roleId: string): Promise<import("@extrahorizon/javascript-sdk").AffectedRecords>;
10
10
  export declare function updateVerificationSettings(settings: Partial<VerificationSettings>): Promise<VerificationSettings>;
11
11
  export declare function updateEmailTemplates(emailTemplates: Partial<EmailTemplates>): Promise<EmailTemplates>;
12
- export declare function updatePasswordPolicy(passwordPolicy: Partial<PasswordPolicy>): Promise<PasswordPolicy>;
12
+ export declare function updatePasswordPolicy(passwordPolicy: Partial<PasswordPolicy>): Promise<import("@extrahorizon/javascript-sdk").PasswordPolicyUpdate>;
@@ -1,30 +1,20 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.whoami = exports.login = void 0;
4
- const fs = require("fs/promises");
5
- const chalk = require("chalk");
6
- const constants_1 = require("../constants");
4
+ const javascript_sdk_1 = require("@extrahorizon/javascript-sdk");
7
5
  const exh_1 = require("../exh");
8
6
  const authRepository = require("../repositories/auth");
9
7
  async function login(host, email, password, consumerKey, consumerSecret) {
10
- const sdk = (0, exh_1.sdkInitOnly)(host, consumerKey, consumerSecret);
8
+ const sdk = (0, javascript_sdk_1.createOAuth1Client)({
9
+ consumerKey,
10
+ consumerSecret,
11
+ host,
12
+ });
11
13
  const response = await sdk.auth.authenticate({
12
14
  email,
13
15
  password,
14
16
  });
15
- try {
16
- await fs.stat(constants_1.EXH_CONFIG_FILE_DIR);
17
- }
18
- catch (err) {
19
- await fs.mkdir(constants_1.EXH_CONFIG_FILE_DIR);
20
- }
21
- await fs.writeFile(constants_1.EXH_CONFIG_FILE, `API_HOST=${host}
22
- API_OAUTH_CONSUMER_KEY=${consumerKey}
23
- API_OAUTH_CONSUMER_SECRET=${consumerSecret}
24
- API_OAUTH_TOKEN=${response.token}
25
- API_OAUTH_TOKEN_SECRET=${response.tokenSecret}
26
- `);
27
- console.log(chalk.green('Wrote credentials to', constants_1.EXH_CONFIG_FILE));
17
+ (0, exh_1.writeCredentialsToFile)(host, consumerKey, consumerSecret, response.token, response.tokenSecret);
28
18
  }
29
19
  exports.login = login;
30
20
  async function whoami() {
@@ -1 +1 @@
1
- export declare function init(name: string, path: string): Promise<void>;
1
+ export declare function init(name: string, filePath: string): Promise<void>;
@@ -3,12 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.init = void 0;
4
4
  const fs_1 = require("fs");
5
5
  const promises_1 = require("fs/promises");
6
- const osPath = require("path");
6
+ const path = require("path");
7
7
  const javascript_sdk_1 = require("@extrahorizon/javascript-sdk");
8
8
  const util_1 = require("../../helpers/util");
9
9
  const readDispatcherFile_1 = require("./util/readDispatcherFile");
10
- async function init(name, path) {
11
- const filePath = osPath.join(path, 'dispatchers.json');
10
+ async function init(name, filePath) {
12
11
  const exists = (0, fs_1.existsSync)(filePath);
13
12
  const fileContent = {
14
13
  dispatchers: [createDispatcher(name)],
@@ -19,7 +18,8 @@ async function init(name, path) {
19
18
  fileContent.dispatchers.push(...existingDispatchers);
20
19
  }
21
20
  else {
22
- await (0, promises_1.mkdir)(`${path}`, { recursive: true });
21
+ const dirPath = path.dirname(filePath);
22
+ await (0, promises_1.mkdir)(dirPath, { recursive: true });
23
23
  }
24
24
  await (0, promises_1.writeFile)(filePath, JSON.stringify(fileContent, null, 2));
25
25
  console.log(`✅ Successfully ${exists ? 'updated' : 'created'} ${filePath}`);
@@ -4,6 +4,7 @@ exports.sync = exports.cliManagedTag = void 0;
4
4
  const javascript_sdk_1 = require("@extrahorizon/javascript-sdk");
5
5
  const chalk_1 = require("chalk");
6
6
  const dispatcherRepository = require("../../repositories/dispatchers");
7
+ const templateRepository = require("../../repositories/templatesV2");
7
8
  const readDispatcherFile_1 = require("./util/readDispatcherFile");
8
9
  exports.cliManagedTag = 'EXH_CLI_MANAGED';
9
10
  async function sync(path, clean = false) {
@@ -23,17 +24,41 @@ async function sync(path, clean = false) {
23
24
  }
24
25
  exports.sync = sync;
25
26
  async function synchronizeDispatcher(localDispatcher, exhDispatcher) {
26
- localDispatcher.tags = localDispatcher.tags || [];
27
- const hasCliManagedTag = localDispatcher.tags.includes(exports.cliManagedTag);
28
- if (!hasCliManagedTag) {
29
- localDispatcher.tags.push(exports.cliManagedTag);
30
- }
27
+ const dispatcherWithTag = ensureCliManagedTag(localDispatcher);
28
+ const dispatcherWithResolvedTemplateIds = await resolveTemplateIds(dispatcherWithTag);
31
29
  if (!exhDispatcher) {
32
- await createDispatcher(localDispatcher);
30
+ await createDispatcher(dispatcherWithResolvedTemplateIds);
33
31
  }
34
32
  else {
35
- await updateDispatcher(localDispatcher, exhDispatcher);
33
+ await updateDispatcher(dispatcherWithResolvedTemplateIds, exhDispatcher);
34
+ }
35
+ }
36
+ function ensureCliManagedTag(dispatcher) {
37
+ const tags = dispatcher.tags ?? [];
38
+ if (tags.includes(exports.cliManagedTag)) {
39
+ return dispatcher;
40
+ }
41
+ return { ...dispatcher, tags: [...tags, exports.cliManagedTag] };
42
+ }
43
+ async function resolveTemplateIds(dispatcher) {
44
+ const resolvedActions = [];
45
+ for (const action of dispatcher.actions) {
46
+ if (action.type !== 'mail') {
47
+ resolvedActions.push(action);
48
+ continue;
49
+ }
50
+ const mailAction = action;
51
+ if (!mailAction.templateName) {
52
+ resolvedActions.push(action);
53
+ continue;
54
+ }
55
+ const template = await templateRepository.findByName(mailAction.templateName);
56
+ if (!template) {
57
+ throw new Error(`Template "${mailAction.templateName}" not found for Action "${action.name}"`);
58
+ }
59
+ resolvedActions.push({ ...action, templateId: template.id });
36
60
  }
61
+ return { ...dispatcher, actions: resolvedActions };
37
62
  }
38
63
  async function createDispatcher(dispatcher) {
39
64
  console.group((0, chalk_1.blue)(`Creating Dispatcher: ${dispatcher.name}`));
@@ -15,7 +15,7 @@ async function sync(path) {
15
15
  }
16
16
  exports.sync = sync;
17
17
  async function syncUserSettings(userServiceSettings) {
18
- if (!userServiceSettings) {
18
+ if (!userServiceSettings || Object.keys(userServiceSettings).length === 0) {
19
19
  return;
20
20
  }
21
21
  console.group((0, chalk_1.blue)('Syncing user service settings:'));
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.readAndValidateServiceSettingsConfig = void 0;
4
4
  const promises_1 = require("fs/promises");
5
- const serviceSettingsSchema = require("../../../config-json-schemas/SettingsConfig.json");
5
+ const serviceSettingsSchema = require("../../../config-json-schemas/ServiceSettings.json");
6
6
  const util_1 = require("../../../helpers/util");
7
7
  async function readAndValidateServiceSettingsConfig(path) {
8
8
  let config;
@@ -13,7 +13,7 @@ const taskService = require("../services/tasks");
13
13
  const templateService = require("../services/templates");
14
14
  async function sync({ path, schemas, tasks, templates, dispatchers, cleanDispatchers, localizations, settings, ignoreSchemaVerificationErrors, }) {
15
15
  const targetPath = path || '.';
16
- const cfg = await (0, repoConfig_1.getRepoConfig)(targetPath);
16
+ const cfg = (0, repoConfig_1.getRepoConfig)(targetPath);
17
17
  const syncAll = !(schemas || tasks || templates || dispatchers || localizations || settings);
18
18
  if ((syncAll || schemas) && cfg.schemas) {
19
19
  console.log(chalk.green('\n ⚙️ Syncing schemas ...'));
@@ -1,5 +1,5 @@
1
1
  export { sync } from './sync';
2
- export { createRepo } from './createRepo';
2
+ export { init } from './init';
3
3
  export { assertExecutionPermission } from './taskConfig';
4
4
  export declare function list(isTTY: boolean): Promise<void>;
5
5
  export declare function remove(name: string): Promise<void>;
@@ -1,12 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.remove = exports.list = exports.assertExecutionPermission = exports.createRepo = exports.sync = void 0;
3
+ exports.remove = exports.list = exports.assertExecutionPermission = exports.init = exports.sync = void 0;
4
4
  const chalk = require("chalk");
5
5
  const functionRepository = require("../../repositories/functions");
6
6
  var sync_1 = require("./sync");
7
7
  Object.defineProperty(exports, "sync", { enumerable: true, get: function () { return sync_1.sync; } });
8
- var createRepo_1 = require("./createRepo");
9
- Object.defineProperty(exports, "createRepo", { enumerable: true, get: function () { return createRepo_1.createRepo; } });
8
+ var init_1 = require("./init");
9
+ Object.defineProperty(exports, "init", { enumerable: true, get: function () { return init_1.init; } });
10
10
  var taskConfig_1 = require("./taskConfig");
11
11
  Object.defineProperty(exports, "assertExecutionPermission", { enumerable: true, get: function () { return taskConfig_1.assertExecutionPermission; } });
12
12
  async function list(isTTY) {
@@ -0,0 +1,8 @@
1
+ interface InitFunctionOptions {
2
+ name: string;
3
+ repo: string;
4
+ path: string;
5
+ git?: boolean;
6
+ }
7
+ export declare function init({ name, repo, git, path }: InitFunctionOptions): Promise<void>;
8
+ export {};
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.init = void 0;
4
+ const promises_1 = require("fs/promises");
5
+ const path_1 = require("path");
6
+ const chalk = require("chalk");
7
+ const util_1 = require("../../helpers/util");
8
+ async function init({ name, repo, git, path }) {
9
+ try {
10
+ await (0, util_1.asyncExec)('git --version');
11
+ }
12
+ catch (err) {
13
+ console.log(chalk.red('Git is not installed. Please install git first.'));
14
+ }
15
+ console.log(`Creating new task ${chalk.green(name)}...`);
16
+ try {
17
+ const repoPath = (0, path_1.join)(path || '', name);
18
+ await (0, util_1.asyncExec)(`git clone ${repo} ${repoPath}`);
19
+ try {
20
+ await changePackageFile(repoPath, name);
21
+ }
22
+ catch (err) { }
23
+ await (0, util_1.asyncExec)(`cd ${repoPath} && rm -rf .git`);
24
+ if (git) {
25
+ console.log('Initializing git');
26
+ await (0, util_1.asyncExec)(`cd ${repoPath} && git init . && git add . && git commit -m "First commit"`);
27
+ }
28
+ console.log('Done! 🎉');
29
+ }
30
+ catch (err) {
31
+ console.log(chalk.red('Failed to create task'));
32
+ console.log(err);
33
+ }
34
+ }
35
+ exports.init = init;
36
+ async function changePackageFile(repoPath, name) {
37
+ try {
38
+ const pkg = JSON.parse((await (0, promises_1.readFile)(`${repoPath}/package.json`)).toString());
39
+ pkg.name = name;
40
+ await (0, promises_1.writeFile)(`${repoPath}/package.json`, JSON.stringify(pkg, null, 2));
41
+ }
42
+ catch (err) {
43
+ console.log('WARN: package.json not found. (possibly not a javascript repository)');
44
+ }
45
+ try {
46
+ const taskConfig = JSON.parse((await (0, promises_1.readFile)(`${repoPath}/task-config.json`)).toString());
47
+ taskConfig.$schema = (0, util_1.getSwaggerDocumentationUrl)('config-json-schemas/TaskConfig.json');
48
+ taskConfig.name = name;
49
+ taskConfig.description = `${name} task`;
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.');
54
+ }
55
+ }
@@ -4,6 +4,6 @@ export declare function syncFunctionUser(data: {
4
4
  targetEmail?: string;
5
5
  targetPermissions: string[];
6
6
  }): Promise<{
7
- token: any;
8
- tokenSecret: any;
7
+ token: string;
8
+ tokenSecret: string;
9
9
  }>;
@@ -42,7 +42,8 @@ async function syncFunctionUser(data) {
42
42
  if (!user) {
43
43
  console.log(chalk.white('⚙️ Creating the user...'));
44
44
  user = await userRepository.createUser({
45
- firstName: `${taskName}`,
45
+ activationMode: 'manual',
46
+ firstName: taskName,
46
47
  lastName: 'exh.tasks',
47
48
  email,
48
49
  password,
@@ -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, util_1.ajvValidate)(templateConfigSchema, content);
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.version === 1 ||
25
- !!template.schema ||
24
+ return (!!template.schema ||
26
25
  !!template.fields);
27
26
  }
28
27
  exports.isV1Template = isV1Template;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@extrahorizon/exh-cli",
3
- "version": "1.13.0-feat-168-eab0ce8",
3
+ "version": "1.13.0",
4
4
  "main": "build/index.js",
5
5
  "exports": "./build/index.js",
6
6
  "license": "MIT",
@@ -41,7 +41,7 @@
41
41
  "typescript": "4.5.5"
42
42
  },
43
43
  "dependencies": {
44
- "@extrahorizon/javascript-sdk": "8.9.1-dev-152-3f69109",
44
+ "@extrahorizon/javascript-sdk": "8.9.1",
45
45
  "ajv": "8.18.0",
46
46
  "archiver": "^7.0.1",
47
47
  "chalk": "^4.0.0",
@@ -1,5 +0,0 @@
1
- export declare function createRepo({ name, repo, git }: {
2
- name: any;
3
- repo: any;
4
- git: any;
5
- }): Promise<void>;
@@ -1,52 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createRepo = void 0;
4
- const promises_1 = require("fs/promises");
5
- const chalk = require("chalk");
6
- const util_1 = require("../../helpers/util");
7
- async function createRepo({ name, repo, git }) {
8
- try {
9
- await (0, util_1.asyncExec)('git --version');
10
- }
11
- catch (err) {
12
- console.log(chalk.red('Git is not installed. Please install git first.'));
13
- }
14
- console.log(`Creating new repo ${chalk.green(name)}...`);
15
- try {
16
- await (0, util_1.asyncExec)(`git clone ${repo} ${name}`);
17
- try {
18
- await changePackageFile(name);
19
- }
20
- catch (err) { }
21
- await (0, util_1.asyncExec)(`cd ${name} && rm -rf .git`);
22
- if (git) {
23
- console.log('Initializing git');
24
- await (0, util_1.asyncExec)(`cd ${name} && git init . && git add . && git commit -m "First commit"`);
25
- }
26
- console.log('Done! 🎉');
27
- }
28
- catch (err) {
29
- await (0, util_1.asyncExec)(`rm -rf ${name}`);
30
- console.log(chalk.red('Failed to create repo'));
31
- console.log(err);
32
- }
33
- }
34
- exports.createRepo = createRepo;
35
- async function changePackageFile(name) {
36
- try {
37
- const pkg = JSON.parse((await (0, promises_1.readFile)(`${name}/package.json`)).toString());
38
- pkg.name = name;
39
- await (0, promises_1.writeFile)(`${name}/package.json`, JSON.stringify(pkg, null, 2));
40
- }
41
- catch (err) {
42
- console.log('WARN: package.json not found. (possibly not a javascript repository');
43
- }
44
- try {
45
- const taskConfig = JSON.parse((await (0, promises_1.readFile)(`${name}/task-config.json`)).toString());
46
- taskConfig.$schema = (0, util_1.getSwaggerDocumentationUrl)('config-json-schemas/TaskConfig.json');
47
- taskConfig.name = name;
48
- taskConfig.description = `${name} task`;
49
- await (0, promises_1.writeFile)(`${name}/task-config.json`, JSON.stringify(taskConfig, null, 2));
50
- }
51
- catch (err) { }
52
- }