@constructor-io/constructorio-connect-cli 1.1.2 → 1.2.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.
@@ -1 +1 @@
1
- {"version":3,"file":"execute.d.ts","sourceRoot":"","sources":["../../src/commands/execute.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,OAAO,EAAM,MAAM,aAAa,CAAC;AA2BjD,eAAO,MAAM,qBAAqB;;;;;CAKxB,CAAC;AAEX;;;GAGG;AACH,UAAU,iBAAiB;IACzB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,oBAAoB,CAAC,EAAE,MAAM,CAAC;CAC/B;AAYD,qBAAa,OAAQ,SAAQ,OAAO;IAClC,MAAM,CAAC,KAAK;;;;;MAgBV;IAEF,MAAM,CAAC,WAAW,SACkK;IAEpL,MAAM,CAAC,QAAQ,WAOb;IAEF,KAAK,EAAE,iBAAiB,CAAM;IAExB,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;YAgCZ,UAAU;YAsBV,oBAAoB;YA6CpB,qBAAqB;YA0BrB,wBAAwB;CAevC"}
1
+ {"version":3,"file":"execute.d.ts","sourceRoot":"","sources":["../../src/commands/execute.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,OAAO,EAAM,MAAM,aAAa,CAAC;AA6BjD,eAAO,MAAM,qBAAqB;;;;;CAKxB,CAAC;AAEX;;;GAGG;AACH,UAAU,iBAAiB;IACzB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,oBAAoB,CAAC,EAAE,MAAM,CAAC;CAC/B;AAYD,qBAAa,OAAQ,SAAQ,OAAO;IAClC,MAAM,CAAC,KAAK;;;;;MAgBV;IAEF,MAAM,CAAC,WAAW,SACkK;IAEpL,MAAM,CAAC,QAAQ,WAOb;IAEF,KAAK,EAAE,iBAAiB,CAAM;IAExB,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;YAoCZ,UAAU;YAsBV,oBAAoB;YA6CpB,qBAAqB;YA0BrB,wBAAwB;CAevC"}
@@ -14,6 +14,9 @@ const render_prompt_1 = require("../prompt-data/render-prompt");
14
14
  const render_repeat_input_1 = require("../rendering/render-repeat-input");
15
15
  const render_template_result_1 = require("../rendering/render-template-result");
16
16
  const path_1 = require("../customer/path");
17
+ const config_1 = require("../customer/config");
18
+ const template_source_code_1 = require("../customer/template-source-code");
19
+ const ux_action_1 = require("../helpers/ux-action");
17
20
  exports.executePromptMessages = {
18
21
  template: "Select a template to execute",
19
22
  fixture: "Select a catalog fixture to run the template against",
@@ -49,10 +52,13 @@ class Execute extends core_1.Command {
49
52
  let result = null;
50
53
  try {
51
54
  const templateInput = await this.getTemplateExecInput();
55
+ const config = await (0, ux_action_1.uxAction)("📡 Reading your config", async () => {
56
+ return await (0, config_1.getRepositoryConfigFile)();
57
+ })();
52
58
  core_1.ux.log("\n");
53
59
  result = await (0, execute_templates_request_1.executeTemplates)({
54
60
  template: (0, file_loaders_1.getJSONataTemplate)(templateInput.templatePath, "utf-8").toString(),
55
- helpers: (0, file_loaders_1.getTemplateHelpers)("helpers.jsonata", "utf-8").toString(),
61
+ helpers: (await (0, template_source_code_1.getHelpersSourceCode)(config.helpers)) ?? "",
56
62
  targetData: (0, file_loaders_1.getCatalogFixture)(templateInput.fixturePath),
57
63
  externalData: templateInput.externalDataPath
58
64
  ? (0, file_loaders_1.getExternalDataFixture)(templateInput.externalDataPath)
@@ -6,9 +6,6 @@ export declare const getExternalDataFixture: (name: string, options?: fs.JsonRea
6
6
  export declare const getJSONataTemplate: (name: string, options?: BufferEncoding | (fs.ObjectEncodingOptions & {
7
7
  flag?: string | undefined;
8
8
  }) | null | undefined) => string | Buffer;
9
- export declare const getTemplateHelpers: (name: string, options?: BufferEncoding | (fs.ObjectEncodingOptions & {
10
- flag?: string | undefined;
11
- }) | null | undefined) => string | Buffer;
12
9
  export declare function createFileLoader<T, S extends any[]>({ prefix, fileLoader, suggestions, }: Args<T, S>): (name: string, ...args: S) => T;
13
10
  interface Args<T, S extends any[]> {
14
11
  prefix: string;
@@ -1 +1 @@
1
- {"version":3,"file":"file-loaders.d.ts","sourceRoot":"","sources":["../../src/helpers/file-loaders.ts"],"names":[],"mappings":";;AAGA,OAAO,EAAE,MAAM,UAAU,CAAC;AAI1B,eAAO,MAAM,iBAAiB,SA0BP,MAAM,sCAtB3B,CAAC;AAEH,eAAO,MAAM,sBAAsB,SAoBZ,MAAM,sCAhB3B,CAAC;AAEH,eAAO,MAAM,kBAAkB,SAcR,MAAM;;yCAX3B,CAAC;AAEH,eAAO,MAAM,kBAAkB,SASR,MAAM;;yCAN3B,CAAC;AAEH,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,CAAC,SAAS,GAAG,EAAE,EAAE,EACnD,MAAM,EACN,UAAU,EACV,WAAgB,GACjB,EAAE,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,CAAC,KAAK,CAAC,CAc9C;AAED,UAAU,IAAI,CAAC,CAAC,EAAE,CAAC,SAAS,GAAG,EAAE;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC;IAC9C,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;CACxB"}
1
+ {"version":3,"file":"file-loaders.d.ts","sourceRoot":"","sources":["../../src/helpers/file-loaders.ts"],"names":[],"mappings":";;AAGA,OAAO,EAAE,MAAM,UAAU,CAAC;AAI1B,eAAO,MAAM,iBAAiB,SAqBP,MAAM,sCAjB3B,CAAC;AAEH,eAAO,MAAM,sBAAsB,SAeZ,MAAM,sCAX3B,CAAC;AAEH,eAAO,MAAM,kBAAkB,SASR,MAAM;;yCAN3B,CAAC;AAEH,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,CAAC,SAAS,GAAG,EAAE,EAAE,EACnD,MAAM,EACN,UAAU,EACV,WAAgB,GACjB,EAAE,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,CAAC,KAAK,CAAC,CAc9C;AAED,UAAU,IAAI,CAAC,CAAC,EAAE,CAAC,SAAS,GAAG,EAAE;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC;IAC9C,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;CACxB"}
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.createFileLoader = exports.getTemplateHelpers = exports.getJSONataTemplate = exports.getExternalDataFixture = exports.getCatalogFixture = void 0;
6
+ exports.createFileLoader = exports.getJSONataTemplate = exports.getExternalDataFixture = exports.getCatalogFixture = void 0;
7
7
  const path_1 = __importDefault(require("path"));
8
8
  const errors_1 = require("@oclif/core/lib/errors");
9
9
  const fs_extra_1 = __importDefault(require("fs-extra"));
@@ -22,10 +22,6 @@ exports.getJSONataTemplate = createFileLoader({
22
22
  prefix: "src/templates",
23
23
  fileLoader: fs_extra_1.default.readFileSync,
24
24
  });
25
- exports.getTemplateHelpers = createFileLoader({
26
- prefix: "src/templates",
27
- fileLoader: fs_extra_1.default.readFileSync,
28
- });
29
25
  function createFileLoader({ prefix, fileLoader, suggestions = [], }) {
30
26
  return function (name, ...args) {
31
27
  const filePath = (0, path_2.getCustomerPath)(path_1.default.join(prefix, name));
@@ -1 +1 @@
1
- {"version":3,"file":"get-candidate-fixtures.d.ts","sourceRoot":"","sources":["../../src/prompt-data/get-candidate-fixtures.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,UAAU,CAAC;AAI9C,wBAAgB,oBAAoB,CAClC,YAAY,EAAE,MAAM,GACnB,aAAa,CAAC,MAAM,CAAC,CA4CvB"}
1
+ {"version":3,"file":"get-candidate-fixtures.d.ts","sourceRoot":"","sources":["../../src/prompt-data/get-candidate-fixtures.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,UAAU,CAAC;AAI9C,wBAAgB,oBAAoB,CAClC,YAAY,EAAE,MAAM,GACnB,aAAa,CAAC,MAAM,CAAC,CA+CvB"}
@@ -9,9 +9,9 @@ const errors_1 = require("@oclif/core/lib/errors");
9
9
  const find_deep_files_1 = require("../helpers/find-deep-files");
10
10
  const get_template_files_1 = require("./get-template-files");
11
11
  function getCandidateFixtures(templatePath) {
12
- const templateType = templatePath.split("/")[0];
13
- if (!get_template_files_1.templateTypes.includes(templateType)) {
14
- throw new errors_1.CLIError(`Invalid template type: ${templateType}`, {
12
+ const templateType = extractTemplateType(templatePath);
13
+ if (!templateType) {
14
+ throw new errors_1.CLIError(`Couldn't find the template type by looking at its path: ${templatePath}`, {
15
15
  suggestions: [
16
16
  "Check that the template file path is correct",
17
17
  "Check that your templates are in the correctly named directory for their type (e.g. 'item.jsonata' in the 'templates/item' directory",
@@ -47,3 +47,13 @@ function getCandidateFixtures(templatePath) {
47
47
  });
48
48
  }
49
49
  exports.getCandidateFixtures = getCandidateFixtures;
50
+ /**
51
+ * Checks for any nested folder that matches a known template type.
52
+ */
53
+ function extractTemplateType(templatePath) {
54
+ for (const type of get_template_files_1.templateTypes) {
55
+ if (templatePath.includes(`${type}/`)) {
56
+ return type;
57
+ }
58
+ }
59
+ }
package/dist/version.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- declare const _default: "1.1.2";
1
+ declare const _default: "1.2.0";
2
2
  export default _default;
3
3
  //# sourceMappingURL=version.d.ts.map
package/dist/version.js CHANGED
@@ -1,3 +1,3 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = '1.1.2';
3
+ exports.default = '1.2.0';
@@ -125,5 +125,5 @@
125
125
  ]
126
126
  }
127
127
  },
128
- "version": "1.1.2"
128
+ "version": "1.2.0"
129
129
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@constructor-io/constructorio-connect-cli",
3
- "version": "1.1.2",
3
+ "version": "1.2.0",
4
4
  "description": "CLI tool to enable users to interface with the Constructor Connect Ecosystem",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",