@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
@@ -11,46 +11,46 @@ const builder = (yargs) => (0, util_1.epilogue)(yargs)
11
11
  .options({
12
12
  path: {
13
13
  demandOption: false,
14
- describe: `Path of the configuration json file containing task parameters. If a directory is given instead, all sub-directories will be searched for a task-config.json file & synced.
14
+ description: `Path of the configuration json file containing task parameters. If a directory is given instead, all sub-directories will be searched for a task-config.json file & synced.
15
15
  If this option is not used, each parameter (name, code, entryPoint, runtime, ...) will need to be supplied separately`,
16
16
  type: 'string',
17
17
  },
18
18
  name: {
19
19
  demandOption: false,
20
- describe: 'Name of the task',
20
+ description: 'Name of the task',
21
21
  type: 'string',
22
22
  },
23
23
  code: {
24
24
  demandOption: false,
25
- describe: 'The path to a directory containing the built task. exh-cli will compress the directory and upload it',
25
+ description: 'The path to a directory containing the built task. exh-cli will compress the directory and upload it',
26
26
  type: 'string',
27
27
  },
28
28
  entryPoint: {
29
29
  demandOption: false,
30
- describe: "The code function that should be invoked. For example 'index.handler' for Nodejs",
30
+ description: "The code function that should be invoked. For example 'index.handler' for Nodejs",
31
31
  type: 'string',
32
32
  },
33
33
  runtime: {
34
34
  demandOption: false,
35
- describe: 'Runtime to use for the task',
35
+ description: 'Runtime to use for the task',
36
36
  choices: constants_1.runtimeChoices,
37
37
  type: 'string',
38
38
  },
39
39
  description: {
40
- describe: 'A description for this task',
40
+ description: 'A description for this task',
41
41
  type: 'string',
42
42
  default: '',
43
43
  },
44
44
  timeLimit: {
45
- describe: 'The execution time limit for this task (in seconds). Min: 3 max: 900',
45
+ description: 'The execution time limit for this task (in seconds). Min: 3 max: 900',
46
46
  type: 'number',
47
47
  },
48
48
  memoryLimit: {
49
- describe: 'The allocated memory for this task (in MB). Min: 128 max: 10240',
49
+ description: 'The allocated memory for this task (in MB). Min: 128 max: 10240',
50
50
  type: 'number',
51
51
  },
52
52
  env: {
53
- describe: 'Environment Variables set for this task. This option can be used multiple times.',
53
+ description: 'Environment Variables set for this task. This option can be used multiple times.',
54
54
  type: 'string',
55
55
  default: [],
56
56
  },
@@ -3,11 +3,11 @@ export declare const command = "delete";
3
3
  export declare const desc = "Delete a template";
4
4
  export declare const builder: (yargs: any) => import("yargs").Argv<import("yargs").Omit<{}, "id" | "name"> & import("yargs").InferredOptionTypes<{
5
5
  name: {
6
- describe: string;
6
+ description: string;
7
7
  type: "string";
8
8
  };
9
9
  id: {
10
- describe: string;
10
+ description: string;
11
11
  type: "string";
12
12
  };
13
13
  }>>;
@@ -8,11 +8,11 @@ exports.desc = 'Delete a template';
8
8
  const builder = (yargs) => (0, util_1.epilogue)(yargs)
9
9
  .options({
10
10
  name: {
11
- describe: 'Name of the template to delete',
11
+ description: 'Name of the template to delete',
12
12
  type: 'string',
13
13
  },
14
14
  id: {
15
- describe: 'ID of the template to delete',
15
+ description: 'ID of the template to delete',
16
16
  type: 'string',
17
17
  },
18
18
  })
@@ -3,11 +3,11 @@ export declare const command = "get";
3
3
  export declare const desc = "Fetch a template";
4
4
  export declare const builder: (yargs: any) => import("yargs").Argv<import("yargs").Omit<{}, "id" | "name"> & import("yargs").InferredOptionTypes<{
5
5
  name: {
6
- describe: string;
6
+ description: string;
7
7
  type: "string";
8
8
  };
9
9
  id: {
10
- describe: string;
10
+ description: string;
11
11
  type: "string";
12
12
  };
13
13
  }>>;
@@ -8,11 +8,11 @@ exports.desc = 'Fetch a template';
8
8
  const builder = (yargs) => (0, util_1.epilogue)(yargs)
9
9
  .options({
10
10
  name: {
11
- describe: 'Name of the template',
11
+ description: 'Name of the template',
12
12
  type: 'string',
13
13
  },
14
14
  id: {
15
- describe: 'ID of the template',
15
+ description: 'ID of the template',
16
16
  type: 'string',
17
17
  },
18
18
  })
@@ -4,12 +4,12 @@ export declare const desc = "Sync all templates in a directory with the ExH clou
4
4
  export declare const builder: (yargs: any) => import("yargs").Argv<import("yargs").Omit<{}, "template" | "path"> & import("yargs").InferredOptionTypes<{
5
5
  path: {
6
6
  demandOption: false;
7
- describe: string;
7
+ description: string;
8
8
  type: "string";
9
9
  };
10
10
  template: {
11
11
  demandOption: false;
12
- describe: string;
12
+ description: string;
13
13
  type: "string";
14
14
  };
15
15
  }>>;
@@ -11,12 +11,12 @@ const builder = (yargs) => (0, util_1.epilogue)(yargs)
11
11
  .options({
12
12
  path: {
13
13
  demandOption: false,
14
- describe: 'Directory containing the templates which need to be synced',
14
+ description: 'Directory containing the templates which need to be synced',
15
15
  type: 'string',
16
16
  },
17
17
  template: {
18
18
  demandOption: false,
19
- describe: 'Template file to sync',
19
+ description: 'Template file to sync',
20
20
  type: 'string',
21
21
  },
22
22
  })
@@ -71,7 +71,11 @@
71
71
  },
72
72
  "MailAction": {
73
73
  "type": "object",
74
- "required": ["type", "name", "recipients", "templateId"],
74
+ "required": ["type", "name", "recipients"],
75
+ "anyOf": [
76
+ { "required": ["templateId"] },
77
+ { "required": ["templateName"] }
78
+ ],
75
79
  "properties": {
76
80
  "type": { "const": "mail" },
77
81
  "name": { "type": "string" },
@@ -94,7 +98,15 @@
94
98
  }
95
99
  }
96
100
  },
97
- "templateId": { "type": "string" }
101
+ "templateId": {
102
+ "deprecated": true,
103
+ "description": "Deprecated, use templateName instead to target a V2 template by its name.",
104
+ "type": "string"
105
+ },
106
+ "templateName": {
107
+ "description": "The name of a V2 template",
108
+ "type": "string"
109
+ }
98
110
  }
99
111
  },
100
112
  "TaskAction": {
@@ -1,67 +1,38 @@
1
1
  {
2
2
  "$schema": "http://json-schema.org/draft-07/schema#",
3
- "if": {
4
- "description": "Try to determine if we have V1 schema",
5
- "anyOf": [
6
- {
7
- "type": "object",
8
- "required": ["version"],
9
- "properties": { "version": { "const": 1 } }
10
- },
11
- {
12
- "type": "object",
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": false,
35
- "properties": {
36
- "version": { "const": 2 },
37
- "$schema": { "type": "string" },
38
- "description": {
39
- "type": "string",
40
- "minLength": 1
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": { "enum": ["object", "array", "string", "number", "boolean"] }
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
  }
package/build/exh.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { OAuth1Client } from '@extrahorizon/javascript-sdk';
2
- export declare function sdkInitOnly(apiHost: string, consumerKey: string, consumerSecret: string): OAuth1Client;
3
2
  export declare function sdkAuth(): Promise<OAuth1Client>;
4
3
  export declare function getSdk(): OAuth1Client;
4
+ export declare function getNewSdkInstance(): OAuth1Client;
5
+ export declare function writeCredentialsToFile(host: string, consumerKey: string, consumerSecret: string, token: string, tokenSecret: string): void;
package/build/exh.js CHANGED
@@ -1,25 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getSdk = exports.sdkAuth = exports.sdkInitOnly = void 0;
3
+ exports.writeCredentialsToFile = exports.getNewSdkInstance = exports.getSdk = exports.sdkAuth = void 0;
4
+ const fs = require("fs");
4
5
  const javascript_sdk_1 = require("@extrahorizon/javascript-sdk");
5
- const util_1 = require("./helpers/util");
6
+ const chalk = require("chalk");
7
+ const constants_1 = require("./constants");
6
8
  let sdk = null;
7
- function sdkInitOnly(apiHost, consumerKey, consumerSecret) {
8
- sdk = (0, javascript_sdk_1.createOAuth1Client)({
9
- consumerKey,
10
- consumerSecret,
11
- host: apiHost,
12
- });
13
- return sdk;
14
- }
15
- exports.sdkInitOnly = sdkInitOnly;
16
9
  async function sdkAuth() {
17
- (0, util_1.loadAndAssertCredentials)();
18
- sdk = (0, javascript_sdk_1.createOAuth1Client)({
19
- host: process.env.API_HOST,
20
- consumerKey: process.env.API_OAUTH_CONSUMER_KEY,
21
- consumerSecret: process.env.API_OAUTH_CONSUMER_SECRET,
22
- });
10
+ loadAndAssertCredentials();
11
+ sdk = getNewSdkInstance();
23
12
  try {
24
13
  await sdk.auth.authenticate({
25
14
  token: process.env.API_OAUTH_TOKEN,
@@ -39,3 +28,55 @@ function getSdk() {
39
28
  return sdk;
40
29
  }
41
30
  exports.getSdk = getSdk;
31
+ function getNewSdkInstance() {
32
+ return (0, javascript_sdk_1.createOAuth1Client)({
33
+ host: process.env.API_HOST,
34
+ consumerKey: process.env.API_OAUTH_CONSUMER_KEY,
35
+ consumerSecret: process.env.API_OAUTH_CONSUMER_SECRET,
36
+ });
37
+ }
38
+ exports.getNewSdkInstance = getNewSdkInstance;
39
+ function loadAndAssertCredentials() {
40
+ const credentials = {};
41
+ let errorMessage = '';
42
+ try {
43
+ const credentialsFile = fs.readFileSync(constants_1.EXH_CONFIG_FILE, 'utf-8');
44
+ const credentialFileLines = credentialsFile.split(/\r?\n/);
45
+ for (const credentialFileLine of credentialFileLines) {
46
+ const [key, value] = credentialFileLine.split('=');
47
+ if (key && value) {
48
+ credentials[key.trim()] = value.trim();
49
+ }
50
+ }
51
+ }
52
+ catch (e) {
53
+ errorMessage += 'Couldn\'t open ~/.exh/credentials. ';
54
+ }
55
+ const requiredEnvVariables = ['API_HOST', 'API_OAUTH_CONSUMER_KEY', 'API_OAUTH_CONSUMER_SECRET', 'API_OAUTH_TOKEN', 'API_OAUTH_TOKEN_SECRET'];
56
+ for (const key of requiredEnvVariables) {
57
+ if (credentials[key] && !process.env[key]) {
58
+ process.env[key] = credentials[key];
59
+ }
60
+ }
61
+ const missingEnvironmentVariables = requiredEnvVariables.filter(key => !process.env[key]);
62
+ if (missingEnvironmentVariables.length > 0) {
63
+ errorMessage += `Missing environment variables: ${missingEnvironmentVariables.join(',')}`;
64
+ throw new Error(`Failed to retrieve all credentials. ${errorMessage}`);
65
+ }
66
+ }
67
+ function writeCredentialsToFile(host, consumerKey, consumerSecret, token, tokenSecret) {
68
+ try {
69
+ fs.statSync(constants_1.EXH_CONFIG_FILE_DIR);
70
+ }
71
+ catch (err) {
72
+ fs.mkdirSync(constants_1.EXH_CONFIG_FILE_DIR);
73
+ }
74
+ fs.writeFileSync(constants_1.EXH_CONFIG_FILE, `API_HOST=${host}
75
+ API_OAUTH_CONSUMER_KEY=${consumerKey}
76
+ API_OAUTH_CONSUMER_SECRET=${consumerSecret}
77
+ API_OAUTH_TOKEN=${token}
78
+ API_OAUTH_TOKEN_SECRET=${tokenSecret}
79
+ `);
80
+ console.log(chalk.green('Wrote credentials to', constants_1.EXH_CONFIG_FILE));
81
+ }
82
+ exports.writeCredentialsToFile = writeCredentialsToFile;
@@ -1,2 +1,2 @@
1
1
  export declare const REPO_CONFIG_FILE = "repo-config.json";
2
- export declare function getRepoConfig(targetPath: string): Promise<any>;
2
+ export declare function getRepoConfig(targetPath: string): any;
@@ -1,57 +1,63 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getRepoConfig = exports.REPO_CONFIG_FILE = void 0;
4
- const fs = require("fs/promises");
4
+ const fs = require("fs");
5
5
  const ospath = require("path");
6
6
  const chalk = require("chalk");
7
7
  exports.REPO_CONFIG_FILE = 'repo-config.json';
8
- async function getDefaultConfig(targetPath) {
8
+ function getRepoConfig(targetPath) {
9
+ let cfg = getDefaultConfig(targetPath);
10
+ try {
11
+ const fileContent = fs.readFileSync(ospath.join(targetPath, exports.REPO_CONFIG_FILE), 'utf-8');
12
+ cfg = JSON.parse(fileContent);
13
+ }
14
+ catch (err) { }
15
+ return validateRepoConfig(targetPath, cfg);
16
+ }
17
+ exports.getRepoConfig = getRepoConfig;
18
+ function getDefaultConfig(targetPath) {
9
19
  const config = {};
10
20
  const sections = ['schemas', 'templates', 'tasks', 'localizations'];
11
21
  for (const s of sections) {
12
- try {
13
- await fs.access(ospath.join(targetPath, s));
22
+ if (pathExists(ospath.join(targetPath, s))) {
14
23
  config[s] = [s];
15
24
  }
16
- catch (err) {
17
- continue;
18
- }
19
25
  }
20
26
  return config;
21
27
  }
22
- async function validateRepoConfig(targetPath, config) {
23
- const checkDirAccess = async (basePath, paths) => {
24
- const result = [];
25
- if (!Array.isArray(paths)) {
26
- throw new Error('Not an array');
27
- }
28
- for (const p of paths) {
29
- try {
30
- await fs.access(ospath.join(basePath, p));
31
- }
32
- catch (err) {
33
- console.log(chalk.yellow(`Warning: '${p}' directory not found`));
34
- continue;
35
- }
36
- if (!(await fs.stat(ospath.join(basePath, p))).isDirectory()) {
37
- throw new Error(`${p} is not a directory`);
38
- }
39
- result.push(p);
40
- }
41
- return result;
42
- };
28
+ function validateRepoConfig(targetPath, config) {
43
29
  const newConfig = { ...config };
44
30
  for (const [key] of Object.entries(config)) {
45
- newConfig[key] = await checkDirAccess(targetPath, config[key]);
31
+ newConfig[key] = checkDirAccess(targetPath, config[key]);
46
32
  }
47
33
  return newConfig;
48
34
  }
49
- async function getRepoConfig(targetPath) {
50
- let cfg = await getDefaultConfig(targetPath);
35
+ function checkDirAccess(basePath, paths) {
36
+ const result = [];
37
+ if (!Array.isArray(paths)) {
38
+ throw new Error('Not an array');
39
+ }
40
+ for (const p of paths) {
41
+ if (!pathExists(ospath.join(basePath, p))) {
42
+ console.log(chalk.yellow(`Warning: '${p}' directory not found`));
43
+ continue;
44
+ }
45
+ if (!isDirectory(ospath.join(basePath, p))) {
46
+ throw new Error(`${p} is not a directory`);
47
+ }
48
+ result.push(p);
49
+ }
50
+ return result;
51
+ }
52
+ function pathExists(p) {
51
53
  try {
52
- cfg = JSON.parse((await fs.readFile(ospath.join(targetPath, exports.REPO_CONFIG_FILE))).toString());
54
+ fs.accessSync(p);
55
+ return true;
56
+ }
57
+ catch {
58
+ return false;
53
59
  }
54
- catch (err) { }
55
- return await validateRepoConfig(targetPath, cfg);
56
60
  }
57
- exports.getRepoConfig = getRepoConfig;
61
+ function isDirectory(path) {
62
+ return fs.statSync(path).isDirectory();
63
+ }
@@ -1,7 +1,6 @@
1
1
  import * as yargs from 'yargs';
2
2
  export declare function epilogue(y: yargs.Argv): yargs.Argv;
3
3
  export declare function asyncExec(cmd: string): Promise<string>;
4
- export declare function loadAndAssertCredentials(): void;
5
4
  export declare function getSwaggerDocumentationUrl(subPath: string): string;
6
5
  export declare function ajvValidate<T>(schema: any, data: any): asserts data is T;
7
6
  export declare function getAjvErrorStrings(errors: any[]): string[];