@constructor-io/constructorio-connect-cli 1.3.0 → 1.4.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 (78) hide show
  1. package/boilerplate-repo/.github/workflows/test.yml +33 -0
  2. package/boilerplate-repo/.vscode/settings.json +3 -0
  3. package/boilerplate-repo/README.md +31 -2
  4. package/boilerplate-repo/babel.config.json +10 -0
  5. package/boilerplate-repo/eslint.config.js +12 -0
  6. package/boilerplate-repo/jest.config.js +27 -0
  7. package/boilerplate-repo/package.json +8 -8
  8. package/boilerplate-repo/src/fixtures/item_group/item_group.json +1 -1
  9. package/boilerplate-repo/src/templates/item_group/item_group.jsonata +1 -2
  10. package/boilerplate-repo/test/global-setup.js +13 -0
  11. package/boilerplate-repo/test/setup-tests-after-env.js +16 -0
  12. package/boilerplate-repo/test/setup-tests.js +8 -0
  13. package/boilerplate-repo/test/templates/grouping/grouping.spec.mjs +26 -0
  14. package/boilerplate-repo/test/templates/item/item.spec.mjs +86 -0
  15. package/boilerplate-repo/test/templates/item_group/item_group.spec.mjs +23 -0
  16. package/boilerplate-repo/test/templates/mapping/mapping.spec.mjs +78 -0
  17. package/boilerplate-repo/test/templates/variation/variation.spec.mjs +37 -0
  18. package/dist/commands/execute.d.ts.map +1 -1
  19. package/dist/commands/execute.js +6 -4
  20. package/dist/commands/generate-fixture.js +1 -1
  21. package/dist/commands/init.d.ts.map +1 -1
  22. package/dist/commands/init.js +11 -1
  23. package/dist/customer/config.js +1 -2
  24. package/dist/customer/get-connect-token.d.ts.map +1 -1
  25. package/dist/customer/get-connect-token.js +2 -2
  26. package/dist/customer/path.js +4 -5
  27. package/dist/customer/template-source-code.d.ts +5 -0
  28. package/dist/customer/template-source-code.d.ts.map +1 -1
  29. package/dist/customer/template-source-code.js +7 -3
  30. package/dist/functions/build-fixture.d.ts +13 -0
  31. package/dist/functions/build-fixture.d.ts.map +1 -0
  32. package/dist/functions/build-fixture.js +21 -0
  33. package/dist/functions/execute-template.d.ts +22 -0
  34. package/dist/functions/execute-template.d.ts.map +1 -0
  35. package/dist/functions/execute-template.js +89 -0
  36. package/dist/helpers/build-config-file.d.ts.map +1 -1
  37. package/dist/helpers/build-config-file.js +9 -5
  38. package/dist/helpers/file-exists.js +1 -2
  39. package/dist/helpers/file-loaders.d.ts +0 -2
  40. package/dist/helpers/file-loaders.d.ts.map +1 -1
  41. package/dist/helpers/file-loaders.js +2 -2
  42. package/dist/helpers/find-deep-files.js +1 -2
  43. package/dist/helpers/generate-command-input.js +1 -2
  44. package/dist/helpers/is-git-repo-initialized.js +1 -2
  45. package/dist/helpers/ux-action.d.ts.map +1 -1
  46. package/dist/helpers/ux-action.js +1 -2
  47. package/dist/http/deploy-request.js +1 -2
  48. package/dist/http/get-connections-request.d.ts +4 -1
  49. package/dist/http/get-connections-request.d.ts.map +1 -1
  50. package/dist/http/get-connections-request.js +12 -6
  51. package/dist/http/get-fixture.js +1 -2
  52. package/dist/http/http-client.d.ts +8 -0
  53. package/dist/http/http-client.d.ts.map +1 -1
  54. package/dist/http/http-client.js +55 -2
  55. package/dist/http/send-template-execute-request.d.ts +12 -0
  56. package/dist/http/send-template-execute-request.d.ts.map +1 -0
  57. package/dist/http/send-template-execute-request.js +31 -0
  58. package/dist/index.d.ts +3 -0
  59. package/dist/index.d.ts.map +1 -1
  60. package/dist/index.js +9 -1
  61. package/dist/prompt-data/filter-connections-by-template.js +1 -2
  62. package/dist/prompt-data/get-candidate-fixtures.js +1 -2
  63. package/dist/prompt-data/get-external-data-files.js +1 -2
  64. package/dist/prompt-data/get-template-files.js +2 -2
  65. package/dist/prompt-data/render-prompt.js +1 -2
  66. package/dist/rendering/render-repeat-input.js +1 -2
  67. package/dist/rendering/render-template-result.js +1 -2
  68. package/dist/rendering/render-tip.js +1 -2
  69. package/dist/types.d.ts +7 -2
  70. package/dist/types.d.ts.map +1 -1
  71. package/dist/version.d.ts +1 -1
  72. package/dist/version.js +1 -1
  73. package/oclif.manifest.json +1 -1
  74. package/package.json +5 -3
  75. package/boilerplate-repo/.eslintrc.json +0 -11
  76. package/dist/http/execute-templates-request.d.ts +0 -10
  77. package/dist/http/execute-templates-request.d.ts.map +0 -1
  78. package/dist/http/execute-templates-request.js +0 -28
@@ -0,0 +1,33 @@
1
+ name: Test
2
+
3
+ on:
4
+ pull_request:
5
+ branches:
6
+ - "**"
7
+
8
+ concurrency:
9
+ group: test-${{ github.head_ref }}
10
+ cancel-in-progress: true
11
+
12
+ jobs:
13
+ check:
14
+ name: Run tests
15
+ runs-on: ubuntu-latest
16
+
17
+ strategy:
18
+ matrix:
19
+ node: ["20.15.11"]
20
+
21
+ steps:
22
+ - uses: actions/checkout@v3
23
+
24
+ - name: Setup node
25
+ uses: actions/setup-node@v2
26
+ with:
27
+ node-version: ${{ matrix.node }}
28
+
29
+ - name: Install dependencies
30
+ run: npm ci
31
+
32
+ - name: Run unit tests
33
+ run: npm run test
@@ -0,0 +1,3 @@
1
+ {
2
+ "editor.formatOnSave": true
3
+ }
@@ -12,6 +12,7 @@ This repository was created using the [constructorio-connect-cli CLI](https://ww
12
12
  - [Executing Templates](#executing-templates)
13
13
  - [`npm run execute [FLAGS]`](#npm-run-execute-flags)
14
14
  - [Testing templates](#testing-templates)
15
+ - [`npm run test [FLAGS]`](#npm-run-test-flags)
15
16
  - [Deploying Templates](#deploying-templates)
16
17
  - [Deploying via GitHub Actions](#deploying-via-github-actions)
17
18
  - [`npm run deploy ENV`](#npm-run-deploy-env)
@@ -80,7 +81,7 @@ DESCRIPTION
80
81
 
81
82
 
82
83
  EXAMPLES
83
- $ constructorio-connect-cli generate-fixtures
84
+ $ constructorio-connect-cli generate-fixture
84
85
  ```
85
86
 
86
87
  # Executing Templates
@@ -118,7 +119,35 @@ EXAMPLES
118
119
 
119
120
  # Testing templates
120
121
 
121
- _This section is under active development and will be updated soon. Keep an eye out for new versions!_
122
+ This project also includes a test suite that leverages Jest to run tests. To test your templates, you can use the `npm run test` command.
123
+
124
+ By running `npm run test`, Jest will search for all files with the `.test.js` or `.spec.js` extension in the project and execute the corresponding tests.
125
+
126
+ As a best practice, you should have at least one snapshot test to ensure the result of your template. You cna also add any logical tests to cover any rules you add to your templates, such as "calculating the average price of your variations". If you need to, you can update your snapshots with the `--updateSnapshot` flag.
127
+
128
+ Finally, note that console logs are disabled during tests. To see all logs, you can use the `--verbose` flag.
129
+
130
+ ## `npm run test [FLAGS]`
131
+
132
+ ```
133
+ USAGE
134
+ $ npm run test -- [FLAGS]
135
+
136
+ FLAGS
137
+ --verbose Display console logs during tests.
138
+ --updateSnapshot Update the snapshots of the tests.
139
+ Note that any other Jest flags are also supported.
140
+
141
+ DESCRIPTION
142
+ Run the test suite to ensure the correctness of your templates.
143
+
144
+ EXAMPLES
145
+ $ npm run test
146
+
147
+ $ npm run test -- --verbose
148
+
149
+ $ npm run test -- --updateSnapshot
150
+ ```
122
151
 
123
152
  # Deploying Templates
124
153
 
@@ -0,0 +1,10 @@
1
+ {
2
+ "presets": [
3
+ [
4
+ "@babel/preset-env",
5
+ {
6
+ "targets": { "node": "current" }
7
+ }
8
+ ]
9
+ ]
10
+ }
@@ -0,0 +1,12 @@
1
+ const stylisticJs = require('@stylistic/eslint-plugin-js');
2
+
3
+ module.exports = [
4
+ {
5
+ plugins: {
6
+ '@stylistic/js': stylisticJs
7
+ },
8
+ rules: {
9
+ '@stylistic/js/indent': ['error', 2],
10
+ }
11
+ }
12
+ ]
@@ -0,0 +1,27 @@
1
+ /**
2
+ * @type {import('@jest/types').Config.InitialOptions}
3
+ */
4
+ const config = {
5
+ maxWorkers: 1,
6
+ watchPathIgnorePatterns: ["node_modules"],
7
+ moduleFileExtensions: ["mjs", "js", "json"],
8
+ moduleDirectories: ["node_modules", "test", "src"],
9
+ modulePaths: ["<rootDir>"],
10
+ rootDir: ".",
11
+ testRegex: ".*\\.spec\\.mjs$",
12
+ setupFiles: ["./test/setup-tests.js"],
13
+ setupFilesAfterEnv: ["./test/setup-tests-after-env.js"],
14
+ globalSetup: "./test/global-setup.js",
15
+ testEnvironment: "node",
16
+ resetMocks: true,
17
+ restoreMocks: true,
18
+ transform: {
19
+ "^.+\\.m?js$": "babel-jest",
20
+ },
21
+ /**
22
+ * The tests will use http to execute the templates. So this is necessary if the internet connection is slow.
23
+ */
24
+ testTimeout: 30_000,
25
+ };
26
+
27
+ module.exports = config;
@@ -3,21 +3,21 @@
3
3
  "version": "1.0.0",
4
4
  "description": "🔧 Repository to interface with the Constructor Connect ecosystem.",
5
5
  "scripts": {
6
- "test": "echo \"Error: no test specified\" && exit 1",
7
- "lint": "eslint . --ext .js",
8
- "lint:fix": "eslint . --ext .js --fix",
6
+ "test": "TZ=UTC node --trace-warnings node_modules/.bin/jest --runInBand --config=jest.config.js",
7
+ "lint": "eslint",
8
+ "lint:fix": "eslint --fix",
9
9
  "execute": "constructorio-connect-cli execute",
10
10
  "deploy": "constructorio-connect-cli deploy",
11
11
  "generate-fixture": "constructorio-connect-cli generate-fixture"
12
12
  },
13
13
  "devDependencies": {
14
+ "@babel/preset-env": "^7.24.8",
15
+ "@stylistic/eslint-plugin-js": "^2.4.0",
16
+ "@types/jest": "^29.5.12",
14
17
  "eslint": "^8.47.0",
15
- "eslint-config-prettier": "^9.1.0",
16
- "eslint-plugin-prettier": "^5.1.2",
17
- "prettier": "^3.1.1"
18
+ "jest": "^29.7.0"
18
19
  },
19
20
  "keywords": [],
20
21
  "author": "",
21
- "license": "ISC",
22
- "dependencies": {}
22
+ "license": "ISC"
23
23
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "id": 1,
3
- "name": "Root Category",
3
+ "name": "Root",
4
4
  "children": [
5
5
  {
6
6
  "id": 2,
@@ -1,4 +1,3 @@
1
1
  {
2
- /* Completely replace the name */
3
- "name": "Hello, world!"
2
+ "name": $lowercase(targetData.name)
4
3
  }
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Here you can add any setup that will run globally before the tests.
3
+ */
4
+
5
+ import { config } from "dotenv";
6
+ config();
7
+
8
+ import { getConnections } from "@constructor-io/constructorio-connect-cli";
9
+
10
+ export default async () => {
11
+ // Load all connections and store them in a global variable, to reuse across the tests.
12
+ global.__connections = await getConnections({ showLogs: false });
13
+ };
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Here you can add any setup that needs to be done after the environment is set up.
3
+ */
4
+
5
+ beforeEach(() => {
6
+ /**
7
+ * Disable console logs during tests to avoid cluttering the output.
8
+ * Note that this won't happen if executing the tests with the --verbose flag.
9
+ * Example: npm run test -- --verbose
10
+ */
11
+ if (!process.env.VERBOSE) {
12
+ jest.spyOn(console, "log").mockReturnValue();
13
+ jest.spyOn(console, "info").mockReturnValue();
14
+ jest.spyOn(console, "debug").mockReturnValue();
15
+ }
16
+ });
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Here you can add any setup that needs to be done before the environment is set up.
3
+ */
4
+
5
+ import { config } from "dotenv";
6
+ config();
7
+
8
+ process.env.TEST = "true";
@@ -0,0 +1,26 @@
1
+ import {
2
+ executeTemplate,
3
+ buildFixture,
4
+ } from "@constructor-io/constructorio-connect-cli";
5
+
6
+ describe("grouping", () => {
7
+ it("should match file snapshot", async () => {
8
+ const result = await executeTemplate({
9
+ type: "grouping",
10
+ name: "grouping.jsonata",
11
+ fixture: buildFixture("variation", "variation.json", {
12
+ name: "New Variation Name",
13
+ }),
14
+ });
15
+
16
+ // Alternatively, you can also store the snapshot in a file to reduce clutter.
17
+ // expect(result).toMatchSnapshot();
18
+
19
+ expect(result).toMatchInlineSnapshot(`
20
+ {
21
+ "id": "42-red",
22
+ "item_name": "New Variation Name",
23
+ }
24
+ `);
25
+ });
26
+ });
@@ -0,0 +1,86 @@
1
+ import {
2
+ executeTemplate,
3
+ buildFixture,
4
+ } from "@constructor-io/constructorio-connect-cli";
5
+
6
+ describe("item", () => {
7
+ it("should match file snapshot", async () => {
8
+ /**
9
+ * Add a function `executeTemplate` which abstracts all the complexity from
10
+ * running a template and gives you the result back.
11
+ *
12
+ * It will:
13
+ * - Load the template.
14
+ * - Receive the fixture + externalData (optional) as an object.
15
+ * - Automatically load the first `connectionId` to send to the backend.
16
+ * - Execute the template on the backend.
17
+ * - Return an object.
18
+ *
19
+ * In failure:
20
+ * - It will throw an error, not allowing the test to proceed.
21
+ */
22
+ const result = await executeTemplate({
23
+ // Define the template type: item | variation | item_group | mapping | grouping
24
+ type: "item",
25
+
26
+ // Define the template file name, which will be used to load the test
27
+ name: "item.jsonata",
28
+
29
+ /**
30
+ * Add a function `buildFixture` to load a fixture from a type and file name.
31
+ * It can also receive a second param being an object, which will deep merge into
32
+ * the fixture itself - similarly to how a factory pattern works. This way we can
33
+ * have only one fixture with many tests :)
34
+ */
35
+ fixture: buildFixture("item", "item.json", {
36
+ name: "other shoes!",
37
+ variations: [
38
+ {
39
+ name: "other shoes (red)",
40
+ price: 130,
41
+ },
42
+ {
43
+ name: "other shoes (blue)",
44
+ price: 200,
45
+ },
46
+ ],
47
+ }),
48
+ });
49
+
50
+ // Alternatively, you can also store the snapshot in a file to reduce clutter.
51
+ // expect(result).toMatchSnapshot();
52
+
53
+ expect(result).toMatchInlineSnapshot(`
54
+ {
55
+ "facets": [
56
+ {
57
+ "key": "price_average",
58
+ "value": 165,
59
+ },
60
+ ],
61
+ "item_name": "These are my other shoes!!",
62
+ "metadata": [
63
+ {
64
+ "key": "colors",
65
+ },
66
+ ],
67
+ }
68
+ `);
69
+ });
70
+
71
+ it("should compute the average price", async () => {
72
+ const response = await executeTemplate({
73
+ type: "item",
74
+ name: "item.jsonata",
75
+ fixture: buildFixture("item", "item.json", {
76
+ variations: [{ price: 100 }, { price: 200 }],
77
+ }),
78
+ });
79
+
80
+ const priceFacet = response.facets.find(
81
+ (facet) => facet.key === "price_average",
82
+ );
83
+
84
+ expect(priceFacet.value).toBe(150);
85
+ });
86
+ });
@@ -0,0 +1,23 @@
1
+ import {
2
+ executeTemplate,
3
+ buildFixture,
4
+ } from "@constructor-io/constructorio-connect-cli";
5
+
6
+ describe("item_group", () => {
7
+ it("should match file snapshot", async () => {
8
+ const result = await executeTemplate({
9
+ type: "item_group",
10
+ name: "item_group.jsonata",
11
+ fixture: buildFixture("item_group", "item_group.json", { other: "data" }),
12
+ });
13
+
14
+ // Alternatively, you can also store the snapshot in a file to reduce clutter.
15
+ // expect(result).toMatchSnapshot();
16
+
17
+ expect(result).toMatchInlineSnapshot(`
18
+ {
19
+ "name": "root",
20
+ }
21
+ `);
22
+ });
23
+ });
@@ -0,0 +1,78 @@
1
+ import {
2
+ executeTemplate,
3
+ buildFixture,
4
+ } from "@constructor-io/constructorio-connect-cli";
5
+
6
+ describe("mapping", () => {
7
+ it("should match file snapshot", async () => {
8
+ const result = await executeTemplate({
9
+ type: "mapping",
10
+ name: "mapping.jsonata",
11
+ fixture: buildFixture("mapping", "mapping.json", {
12
+ title: "New Title",
13
+ }),
14
+ });
15
+
16
+ // Alternatively, you can also store the snapshot in a file to reduce clutter.
17
+ // expect(result).toMatchSnapshot();
18
+
19
+ expect(result).toMatchInlineSnapshot(`
20
+ {
21
+ "item_groups": [
22
+ {
23
+ "id": "smartphones",
24
+ },
25
+ ],
26
+ "items": [
27
+ {
28
+ "__variations": [
29
+ {
30
+ "color": "midnight-black",
31
+ },
32
+ {
33
+ "color": "fancy-silver",
34
+ },
35
+ {
36
+ "color": "rich-gold",
37
+ },
38
+ {
39
+ "color": "sky-blue",
40
+ },
41
+ {
42
+ "color": "crimson-red",
43
+ },
44
+ {
45
+ "color": "green-forest",
46
+ },
47
+ ],
48
+ "brand": "Apple",
49
+ "category": "smartphones",
50
+ "colors": [
51
+ "midnight-black",
52
+ "fancy-silver",
53
+ "rich-gold",
54
+ "sky-blue",
55
+ "crimson-red",
56
+ "green-forest",
57
+ ],
58
+ "description": "SIM-Free, Model A19211 6.5-inch Super Retina HD display with OLED technology A12 Bionic chip with ...",
59
+ "discountPercentage": 17.94,
60
+ "id": "iphone-x",
61
+ "images": [
62
+ "https://cdn.dummyjson.com/product-images/2/1.jpg",
63
+ "https://cdn.dummyjson.com/product-images/2/2.jpg",
64
+ "https://cdn.dummyjson.com/product-images/2/3.jpg",
65
+ "https://cdn.dummyjson.com/product-images/2/thumbnail.jpg",
66
+ ],
67
+ "price": 899,
68
+ "rating": 4.44,
69
+ "stock": 34,
70
+ "thumbnail": "https://cdn.dummyjson.com/product-images/2/thumbnail.jpg",
71
+ "title": "New Title",
72
+ },
73
+ ],
74
+ "variations": [],
75
+ }
76
+ `);
77
+ });
78
+ });
@@ -0,0 +1,37 @@
1
+ import {
2
+ executeTemplate,
3
+ buildFixture,
4
+ } from "@constructor-io/constructorio-connect-cli";
5
+
6
+ describe("variation", () => {
7
+ it("should match file snapshot", async () => {
8
+ const result = await executeTemplate({
9
+ type: "variation",
10
+ name: "variation.jsonata",
11
+ fixture: buildFixture("variation", "variation.json", {
12
+ name: "stylish boots",
13
+ }),
14
+ });
15
+
16
+ // Alternatively, you can also store the snapshot in a file to reduce clutter.
17
+ // expect(result).toMatchSnapshot();
18
+
19
+ expect(result).toMatchInlineSnapshot(`
20
+ {
21
+ "facets": [
22
+ {
23
+ "key": "price",
24
+ "value": 50,
25
+ },
26
+ ],
27
+ "item_name": "These are my stylish boots!",
28
+ "metadata": [
29
+ {
30
+ "key": "color",
31
+ "value": "red",
32
+ },
33
+ ],
34
+ }
35
+ `);
36
+ });
37
+ });
@@ -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;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"}
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;YAiCZ,UAAU;YAsBV,oBAAoB;YAgDpB,qBAAqB;YA0BrB,wBAAwB;CAevC"}
@@ -4,7 +4,7 @@ exports.Execute = exports.executePromptMessages = void 0;
4
4
  const core_1 = require("@oclif/core");
5
5
  const errors_1 = require("@oclif/core/lib/errors");
6
6
  const file_loaders_1 = require("../helpers/file-loaders");
7
- const execute_templates_request_1 = require("../http/execute-templates-request");
7
+ const send_template_execute_request_1 = require("../http/send-template-execute-request");
8
8
  const get_connections_request_1 = require("../http/get-connections-request");
9
9
  const filter_connections_by_template_1 = require("../prompt-data/filter-connections-by-template");
10
10
  const get_candidate_fixtures_1 = require("../prompt-data/get-candidate-fixtures");
@@ -56,8 +56,8 @@ class Execute extends core_1.Command {
56
56
  return await (0, config_1.getRepositoryConfigFile)();
57
57
  })();
58
58
  core_1.ux.log("\n");
59
- result = await (0, execute_templates_request_1.executeTemplates)({
60
- template: (0, file_loaders_1.getJSONataTemplate)(templateInput.templatePath, "utf-8").toString(),
59
+ result = await (0, send_template_execute_request_1.sendTemplateExecuteRequest)({
60
+ template: (0, file_loaders_1.getJSONataTemplate)(templateInput.templatePath).toString(),
61
61
  helpers: (await (0, template_source_code_1.getHelpersSourceCode)(config.helpers)) ?? "",
62
62
  targetData: (0, file_loaders_1.getCatalogFixture)(templateInput.fixturePath),
63
63
  externalData: templateInput.externalDataPath
@@ -91,7 +91,9 @@ class Execute extends core_1.Command {
91
91
  }
92
92
  }
93
93
  async getTemplateExecInput() {
94
- const allConnections = await (0, get_connections_request_1.getConnectionsForCompany)();
94
+ const allConnections = await (0, get_connections_request_1.getConnections)({
95
+ showLogs: true,
96
+ });
95
97
  await this.parseFlags();
96
98
  if (!this.input["template-path"]) {
97
99
  const choices = await (0, get_template_files_1.getTemplateFiles)();
@@ -21,7 +21,7 @@ Finally, if the file already exists you'll be prompted to overwrite it.
21
21
  static examples = ["$ <%= config.bin %> generate-fixture"];
22
22
  async run() {
23
23
  const connections = await (0, ux_action_1.uxAction)("📡 Reading your connections...", async () => {
24
- return await (0, get_connections_request_1.getConnectionsForCompany)();
24
+ return await (0, get_connections_request_1.getConnections)({ showLogs: true });
25
25
  })();
26
26
  const connectionId = await (0, render_prompt_1.renderPrompt)({
27
27
  promptMessage: "Choose the connection to generate the fixture for",
@@ -1 +1 @@
1
- {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AAMA,OAAO,EAAQ,OAAO,EAAM,MAAM,aAAa,CAAC;AAiBhD,MAAM,CAAC,OAAO,OAAO,IAAK,SAAQ,OAAO;IACvC,MAAM,CAAC,WAAW,SAA4D;IAE9E,MAAM,CAAC,QAAQ,WAGb;IAEF,MAAM,CAAC,IAAI;;MAKT;IAEW,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;YA+BnB,UAAU;IAmBxB,OAAO,CAAC,oBAAoB;YAUd,UAAU;YAsBV,uBAAuB;WAwBvB,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAKvD,OAAO,CAAC,MAAM,CAAC,kBAAkB;IAUjC,OAAO,CAAC,MAAM,CAAC,mBAAmB;IAqBlC,OAAO,CAAC,0BAA0B;CA4BnC"}
1
+ {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AAMA,OAAO,EAAQ,OAAO,EAAM,MAAM,aAAa,CAAC;AAyBhD,MAAM,CAAC,OAAO,OAAO,IAAK,SAAQ,OAAO;IACvC,MAAM,CAAC,WAAW,SAA4D;IAE9E,MAAM,CAAC,QAAQ,WAGb;IAEF,MAAM,CAAC,IAAI;;MAKT;IAEW,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;YA+BnB,UAAU;IAmBxB,OAAO,CAAC,oBAAoB;YAUd,UAAU;YAsBV,uBAAuB;WAwBvB,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAKvD,OAAO,CAAC,MAAM,CAAC,kBAAkB;IAWjC,OAAO,CAAC,MAAM,CAAC,mBAAmB;IAuBlC,OAAO,CAAC,0BAA0B;CA4BnC"}
@@ -40,6 +40,13 @@ const get_connect_token_1 = require("../customer/get-connect-token");
40
40
  const render_tip_1 = require("../rendering/render-tip");
41
41
  const is_git_repo_initialized_1 = require("../helpers/is-git-repo-initialized");
42
42
  const BOILERPLATE_REPO_PATH = "../../boilerplate-repo";
43
+ /**
44
+ * This ensures that the path will be fixed in Windows, since we're using `path.join()` to build the path.
45
+ * @see https://github.com/adamreisnz/replace-in-file/pull/169
46
+ */
47
+ const globConfig = {
48
+ windowsPathsNoEscape: true,
49
+ };
43
50
  class Init extends core_1.Command {
44
51
  static description = "Bootstrap a new Constructor.io Connect CLI repository.";
45
52
  static examples = [
@@ -111,7 +118,7 @@ class Init extends core_1.Command {
111
118
  }
112
119
  async generateRepositoryFiles(args) {
113
120
  core_1.ux.log("\n");
114
- const connections = await (0, get_connections_request_1.getConnectionsForCompany)();
121
+ const connections = await (0, get_connections_request_1.getConnections)({ showLogs: true });
115
122
  const connectionsDict = (0, build_config_file_1.buildConnectionsDictFromList)(connections);
116
123
  const config = (0, build_config_file_1.buildConfigFromConnections)(connections);
117
124
  (0, ux_action_1.uxAction)("🚀 Creating new Constructor.io Connect CLI repository", () => {
@@ -135,6 +142,7 @@ class Init extends core_1.Command {
135
142
  files: packageJsonPath,
136
143
  from: "{{REPLACE_REPO_NAME}}",
137
144
  to: name,
145
+ glob: globConfig,
138
146
  });
139
147
  }
140
148
  static replaceConfigValues(config, connections, repoPath) {
@@ -142,11 +150,13 @@ class Init extends core_1.Command {
142
150
  files: path.join(repoPath, "connectrc.js"),
143
151
  from: '"{{REPLACE_CONFIG}}"',
144
152
  to: (0, build_config_file_1.buildConfigString)(config, connections),
153
+ glob: globConfig,
145
154
  });
146
155
  replace_in_file_1.default.replaceInFileSync({
147
156
  files: path.join(repoPath, "connectrc.js"),
148
157
  from: '"{{REPLACE_CONNECTIONS}}"',
149
158
  to: JSON.stringify(connections, null, 2),
159
+ glob: globConfig,
150
160
  });
151
161
  // Run `lint:fix` to ensure the generated files are properly linted & formatted
152
162
  (0, child_process_1.execSync)(`(cd ${repoPath} && npm run lint:fix)`);
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getRepositoryConfigFile = void 0;
3
+ exports.getRepositoryConfigFile = getRepositoryConfigFile;
4
4
  const errors_1 = require("@oclif/core/lib/errors");
5
5
  const core_1 = require("@oclif/core");
6
6
  const path_1 = require("./path");
@@ -37,4 +37,3 @@ pointing to the correct connectrc.js directory.`,
37
37
  });
38
38
  }
39
39
  }
40
- exports.getRepositoryConfigFile = getRepositoryConfigFile;
@@ -1 +1 @@
1
- {"version":3,"file":"get-connect-token.d.ts","sourceRoot":"","sources":["../../src/customer/get-connect-token.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;GAWG;AACH,wBAAgB,oBAAoB,eAIvB,OAAO,KACf,QAAQ,MAAM,CAAC,CA2BnB;AAED,eAAO,MAAM,eAAe,aA9Bf,OAAO,KACf,QAAQ,MAAM,CA6BkC,CAAC"}
1
+ {"version":3,"file":"get-connect-token.d.ts","sourceRoot":"","sources":["../../src/customer/get-connect-token.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;GAWG;AACH,wBAAgB,oBAAoB,eAIvB,OAAO,KACf,OAAO,CAAC,MAAM,CAAC,CA2BnB;AAED,eAAO,MAAM,eAAe,aA9Bf,OAAO,KACf,OAAO,CAAC,MAAM,CA6BkC,CAAC"}
@@ -23,7 +23,8 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.getConnectToken = exports.getConnectTokenStore = void 0;
26
+ exports.getConnectToken = void 0;
27
+ exports.getConnectTokenStore = getConnectTokenStore;
27
28
  const fs = __importStar(require("fs-extra"));
28
29
  const prompts_1 = require("@inquirer/prompts");
29
30
  const core_1 = require("@oclif/core");
@@ -65,5 +66,4 @@ function getConnectTokenStore() {
65
66
  return connectToken;
66
67
  };
67
68
  }
68
- exports.getConnectTokenStore = getConnectTokenStore;
69
69
  exports.getConnectToken = getConnectTokenStore();
@@ -1,6 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.cleanupExternalDataPath = exports.cleanupFixturePath = exports.cleanupTemplatePath = exports.getCustomerPath = void 0;
3
+ exports.getCustomerPath = getCustomerPath;
4
+ exports.cleanupTemplatePath = cleanupTemplatePath;
5
+ exports.cleanupFixturePath = cleanupFixturePath;
6
+ exports.cleanupExternalDataPath = cleanupExternalDataPath;
4
7
  /* eslint-disable @typescript-eslint/prefer-nullish-coalescing */
5
8
  const path_1 = require("path");
6
9
  /**
@@ -9,7 +12,6 @@ const path_1 = require("path");
9
12
  function getCustomerPath(path) {
10
13
  return (0, path_1.join)(process.cwd(), process.env.REPOSITORY_ROOT_DIRECTORY || "", path);
11
14
  }
12
- exports.getCustomerPath = getCustomerPath;
13
15
  /**
14
16
  * Cleans up the template path, removing the root directory and the 'src/templates' prefix.
15
17
  *
@@ -19,7 +21,6 @@ exports.getCustomerPath = getCustomerPath;
19
21
  function cleanupTemplatePath(path) {
20
22
  return cleanupAbsolutePath(path).replace("/src/templates/", "");
21
23
  }
22
- exports.cleanupTemplatePath = cleanupTemplatePath;
23
24
  /**
24
25
  * Cleans up the fixture path, removing the root directory and the 'src/fixtures' prefix.
25
26
  *
@@ -29,7 +30,6 @@ exports.cleanupTemplatePath = cleanupTemplatePath;
29
30
  function cleanupFixturePath(path) {
30
31
  return cleanupAbsolutePath(path).replace("/src/fixtures/", "");
31
32
  }
32
- exports.cleanupFixturePath = cleanupFixturePath;
33
33
  /**
34
34
  * Cleans up the external data path, removing the root directory and the 'src/external-data' prefix.
35
35
  *
@@ -39,7 +39,6 @@ exports.cleanupFixturePath = cleanupFixturePath;
39
39
  function cleanupExternalDataPath(path) {
40
40
  return cleanupAbsolutePath(path).replace("/src/external-data/", "");
41
41
  }
42
- exports.cleanupExternalDataPath = cleanupExternalDataPath;
43
42
  function cleanupAbsolutePath(path) {
44
43
  if (!path) {
45
44
  return "";