@constructor-io/constructorio-connect-cli 1.14.0 → 1.15.1

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/README.md CHANGED
@@ -43,18 +43,22 @@ With the new repository initialized, you can start developing your catalog integ
43
43
 
44
44
  ## `constructorio-connect-cli deploy ENV`
45
45
 
46
- Deploys all templates defined on the `connectrc.js` file to the specified environment.
46
+ Deploys all templates defined on the `connectrc.js` file to the specified environment, after running tests ('--force' to skip).
47
47
 
48
48
  ```
49
49
  USAGE
50
- $ constructorio-connect-cli deploy ENV
50
+ $ constructorio-connect-cli deploy ENV [-f]
51
51
 
52
52
  ARGUMENTS
53
53
  ENV (development|qa|production|demo) The target Constructor environment to deploy to.
54
54
 
55
+ FLAGS
56
+ -f, --force Skip tests before deploying
57
+
55
58
  DESCRIPTION
56
59
 
57
- Deploys all templates defined on the `connectrc.js` file to the specified environment.
60
+ Deploys all templates defined on the `connectrc.js` file to the specified environment, after running tests ('--force'
61
+ to skip).
58
62
 
59
63
  The script will use the `CONNECT_AUTH_TOKEN` environment variable to authenticate with Constructor.
60
64
 
@@ -64,6 +68,8 @@ EXAMPLES
64
68
  $ constructorio-connect-cli deploy qa
65
69
 
66
70
  $ constructorio-connect-cli deploy production
71
+
72
+ $ constructorio-connect-cli deploy production --force
67
73
  ```
68
74
 
69
75
 
@@ -5,7 +5,7 @@
5
5
  #
6
6
  # This workflow can be triggered from the GitHub Actions tab. Just open the actions tab,
7
7
  # select the workflow, and click the "Run workflow" button. Then, select your desired
8
- # environment and confirm the deployment.
8
+ # environment, select if you want to skip tests and confirm the deployment.
9
9
  #
10
10
  # Only one deployment per environment can run at a time. If a deployment is already in
11
11
  # progress, triggering a new deployment will cancel the previous one.
@@ -27,6 +27,11 @@ on:
27
27
  - qa
28
28
  - production
29
29
  - demo
30
+ force:
31
+ description: Skip tests during deployment
32
+ required: false
33
+ type: boolean
34
+ default: false
30
35
 
31
36
  concurrency:
32
37
  group: deploy-${{ github.event.inputs.environment }}
@@ -48,12 +53,12 @@ jobs:
48
53
  - name: Setup node
49
54
  uses: actions/setup-node@v4
50
55
  with:
51
- node-version: '18.18.0'
56
+ node-version: "18.18.0"
52
57
 
53
58
  - name: Install dependencies
54
59
  run: npm ci
55
60
 
56
61
  - name: Deploy
57
- run: IS_CI=true npm run deploy ${{ github.event.inputs.environment }}
62
+ run: IS_CI=true npm run deploy ${{ github.event.inputs.environment }} ${{ github.event.inputs.force && '--force' || '' }}
58
63
  env:
59
64
  CONNECT_AUTH_TOKEN: ${{ secrets.CONNECT_AUTH_TOKEN }}
@@ -1,10 +1,18 @@
1
1
  /**
2
2
  * Check out the documentation to see how to write and maintain tests:
3
3
  * @see https://docs.constructor.com/docs/integrating-with-constructor-connect-cli-development-flow#step-3-test-your-templates
4
- */
4
+ */
5
+
6
+ import { executeTemplate, buildFixture } from "@constructor-io/constructorio-connect-cli";
5
7
 
6
8
  describe("item", () => {
7
- it("should be defined", async () => {
8
- expect(true).toBe(true);
9
+ it("should match snapshot", async () => {
10
+ const result = await executeTemplate({
11
+ type: "item",
12
+ name: "item.jsonata",
13
+ fixture: buildFixture("item", "item.json"),
14
+ });
15
+
16
+ expect(result).toMatchSnapshot();
9
17
  });
10
18
  });
@@ -1,10 +1,18 @@
1
1
  /**
2
2
  * Check out the documentation to see how to write and maintain tests:
3
3
  * @see https://docs.constructor.com/docs/integrating-with-constructor-connect-cli-development-flow#step-3-test-your-templates
4
- */
4
+ */
5
+
6
+ import { executeTemplate, buildFixture } from "@constructor-io/constructorio-connect-cli";
5
7
 
6
8
  describe("item_group", () => {
7
- it("should be defined", async () => {
8
- expect(true).toBe(true);
9
+ it("should match snapshot", async () => {
10
+ const result = await executeTemplate({
11
+ type: "item_group",
12
+ name: "item_group.jsonata",
13
+ fixture: buildFixture("item_group", "item_group.json"),
14
+ });
15
+
16
+ expect(result).toMatchSnapshot();
9
17
  });
10
18
  });
@@ -1,10 +1,38 @@
1
1
  /**
2
2
  * Check out the documentation to see how to write and maintain tests:
3
3
  * @see https://docs.constructor.com/docs/integrating-with-constructor-connect-cli-development-flow#step-3-test-your-templates
4
- */
4
+ */
5
+
6
+ import { executeTemplate, buildFixture } from "@constructor-io/constructorio-connect-cli";
5
7
 
6
8
  describe("mapping", () => {
7
- it("should be defined", async () => {
8
- expect(true).toBe(true);
9
+ it("should map item groups", async () => {
10
+ const result = await executeTemplate({
11
+ type: "mapping",
12
+ name: "mapping.jsonata",
13
+ fixture: buildFixture("mapping", "mapping.json"),
14
+ });
15
+
16
+ expect(result.item_groups).toMatchSnapshot();
17
+ });
18
+
19
+ it("should map items", async () => {
20
+ const result = await executeTemplate({
21
+ type: "mapping",
22
+ name: "mapping.jsonata",
23
+ fixture: buildFixture("mapping", "mapping.json"),
24
+ });
25
+
26
+ expect(result.items).toMatchSnapshot();
27
+ });
28
+
29
+ it("should map variations", async () => {
30
+ const result = await executeTemplate({
31
+ type: "mapping",
32
+ name: "mapping.jsonata",
33
+ fixture: buildFixture("mapping", "mapping.json"),
34
+ });
35
+
36
+ expect(result.variations).toMatchSnapshot();
9
37
  });
10
38
  });
@@ -1,10 +1,18 @@
1
1
  /**
2
2
  * Check out the documentation to see how to write and maintain tests:
3
3
  * @see https://docs.constructor.com/docs/integrating-with-constructor-connect-cli-development-flow#step-3-test-your-templates
4
- */
4
+ */
5
+
6
+ import { executeTemplate, buildFixture } from "@constructor-io/constructorio-connect-cli";
5
7
 
6
8
  describe("variation", () => {
7
- it("should be defined", async () => {
8
- expect(true).toBe(true);
9
+ it("should match snapshot", async () => {
10
+ const result = await executeTemplate({
11
+ type: "variation",
12
+ name: "variation.jsonata",
13
+ fixture: buildFixture("variation", "variation.json"),
14
+ });
15
+
16
+ expect(result).toMatchSnapshot();
9
17
  });
10
18
  });
@@ -3,6 +3,9 @@ export default class Deploy extends RefreshConnectionsCommand {
3
3
  static args: {
4
4
  env: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
5
5
  };
6
+ static flags: {
7
+ force: import("@oclif/core/interfaces").BooleanFlag<boolean>;
8
+ };
6
9
  static description: string;
7
10
  static examples: string[];
8
11
  runCommand(): Promise<any>;
@@ -1 +1 @@
1
- {"version":3,"file":"deploy.d.ts","sourceRoot":"","sources":["../../src/commands/deploy.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAC;AAC1E,MAAM,CAAC,OAAO,OAAO,MAAO,SAAQ,yBAAyB;IAC3D,MAAM,CAAC,IAAI;;MAMT;IAEF,MAAM,CAAC,WAAW,SAGqF;IAEvG,MAAM,CAAC,QAAQ,WAIb;IAEI,UAAU,IAAI,OAAO,CAAC,GAAG,CAAC;CAgDjC"}
1
+ {"version":3,"file":"deploy.d.ts","sourceRoot":"","sources":["../../src/commands/deploy.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAC;AAE1E,MAAM,CAAC,OAAO,OAAO,MAAO,SAAQ,yBAAyB;IAC3D,MAAM,CAAC,IAAI;;MAMT;IAEF,MAAM,CAAC,KAAK;;MAKV;IAEF,MAAM,CAAC,WAAW,SAGqF;IAEvG,MAAM,CAAC,QAAQ,WAKb;IAEI,UAAU,IAAI,OAAO,CAAC,GAAG,CAAC;CA+DjC"}
@@ -13,6 +13,7 @@ const ux_action_1 = require("../helpers/ux-action");
13
13
  const deploy_request_1 = require("../http/deploy-request");
14
14
  const render_tip_1 = require("../rendering/render-tip");
15
15
  const refresh_connections_command_1 = require("./refresh-connections-command");
16
+ const child_process_1 = require("child_process");
16
17
  class Deploy extends refresh_connections_command_1.RefreshConnectionsCommand {
17
18
  static args = {
18
19
  env: core_1.Args.string({
@@ -21,17 +22,37 @@ class Deploy extends refresh_connections_command_1.RefreshConnectionsCommand {
21
22
  required: true,
22
23
  }),
23
24
  };
25
+ static flags = {
26
+ force: core_1.Flags.boolean({
27
+ char: "f",
28
+ description: "Skip tests before deploying",
29
+ }),
30
+ };
24
31
  static description = `
25
- Deploys all templates defined on the \`connectrc.js\` file to the specified environment.
32
+ Deploys all templates defined on the \`connectrc.js\` file to the specified environment, after running tests ('--force' to skip).
26
33
 
27
34
  The script will use the \`CONNECT_AUTH_TOKEN\` environment variable to authenticate with Constructor.`;
28
35
  static examples = [
29
36
  "$ <%= config.bin %> deploy development",
30
37
  "$ <%= config.bin %> deploy qa",
31
38
  "$ <%= config.bin %> deploy production",
39
+ "$ <%= config.bin %> deploy production --force",
32
40
  ];
33
41
  async runCommand() {
34
- const { args } = await this.parse(Deploy);
42
+ const { flags, args } = await this.parse(Deploy);
43
+ if (!flags.force) {
44
+ try {
45
+ (0, child_process_1.execSync)("npm run test", {
46
+ stdio: "inherit",
47
+ cwd: process.cwd(),
48
+ });
49
+ this.log(`\n`);
50
+ }
51
+ catch (_) {
52
+ this.log(`\n${kleur_1.default.red("❌ Tests failed!")}\n`);
53
+ throw new errors_1.CLIError(`Tests failed. Fix the tests or use --force to deploy anyway.`);
54
+ }
55
+ }
35
56
  const config = await (0, ux_action_1.uxAction)("📡 Reading your config", async () => {
36
57
  return await (0, config_1.getRepositoryConfigFile)();
37
58
  })();
package/dist/version.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- declare const _default: "1.14.0";
1
+ declare const _default: "1.15.1";
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.14.0';
3
+ exports.default = '1.15.1';
@@ -15,13 +15,22 @@
15
15
  "required": true
16
16
  }
17
17
  },
18
- "description": "\n Deploys all templates defined on the `connectrc.js` file to the specified environment.\n\n The script will use the `CONNECT_AUTH_TOKEN` environment variable to authenticate with Constructor.",
18
+ "description": "\n Deploys all templates defined on the `connectrc.js` file to the specified environment, after running tests ('--force' to skip).\n\n The script will use the `CONNECT_AUTH_TOKEN` environment variable to authenticate with Constructor.",
19
19
  "examples": [
20
20
  "$ <%= config.bin %> deploy development",
21
21
  "$ <%= config.bin %> deploy qa",
22
- "$ <%= config.bin %> deploy production"
22
+ "$ <%= config.bin %> deploy production",
23
+ "$ <%= config.bin %> deploy production --force"
23
24
  ],
24
- "flags": {},
25
+ "flags": {
26
+ "force": {
27
+ "char": "f",
28
+ "description": "Skip tests before deploying",
29
+ "name": "force",
30
+ "allowNo": false,
31
+ "type": "boolean"
32
+ }
33
+ },
25
34
  "hasDynamicHelp": false,
26
35
  "hiddenAliases": [],
27
36
  "id": "deploy",
@@ -190,5 +199,5 @@
190
199
  ]
191
200
  }
192
201
  },
193
- "version": "1.14.0"
202
+ "version": "1.15.1"
194
203
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@constructor-io/constructorio-connect-cli",
3
- "version": "1.14.0",
3
+ "version": "1.15.1",
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",