UNPKG

@constructor-io/constructorio-connect-cli

Version:

CLI tool to enable users to interface with the Constructor Connect Ecosystem

214 lines (134 loc) 7.72 kB
# Constructor.io Connect CLI [![npm](https://img.shields.io/npm/v/@constructor-io/constructorio-connect-cli)](https://www.npmjs.com/package/@constructor-io/constructorio-connect-cli) [![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/Constructor-io/constructorio-connect-cli/blob/master/LICENSE) Constructor.io is an e-commerce first product discovery service that optimizes results using artificial intelligence (including natural language processing, re-ranking to optimize for business metrics, and end user personalization). This package is a CLI tool that helps you **build, test and deploy your connector templates**. By using templates, you can customize your catalog integration to shape your data the way you want it. > If you're looking for a package to consume our API, please use [@constructor-io/constructorio-node](https://github.com/Constructor-io/constructorio-node) instead. Alternatively, if you want a JavaScript client for client side (i.e. front end) integrations please use [@constructor-io/constructorio-client-javascript](https://github.com/Constructor-io/constructorio-client-javascript). ## 1. Review the Requirements Before you begin, note that this package is intended for use with partner connections. If you don't have a connector running yet, please take a look at [our documentation](https://docs.constructor.com/docs/integrating-with-constructor-platform-connectors) to see how you can get started. Finally, make sure you have your **Index Key** and **API token** available. If you don't have this yet, please get in touch with our team and we'll set this up. ## 2. Install You can initialize a new working repo with the following command: ```bash npx @constructor-io/constructorio-connect-cli init my-repo ``` Where `my-repo` is the name of the folder and repository you want to create. With the new repository initialized, you can start developing your catalog integration. Please refer to our [documentation](https://docs.constructor.com/docs/integrating-with-constructor-platform-connectors) for more information on how to build your templates. ## 3. Commands <!-- Generated code below. Do not update! --> <!-- commands --> * [`constructorio-connect-cli deploy ENV`](#constructorio-connect-cli-deploy-env) * [`constructorio-connect-cli execute`](#constructorio-connect-cli-execute) * [`constructorio-connect-cli generate-fixture`](#constructorio-connect-cli-generate-fixture) * [`constructorio-connect-cli help [COMMAND]`](#constructorio-connect-cli-help-command) * [`constructorio-connect-cli init NAME`](#constructorio-connect-cli-init-name) * [`constructorio-connect-cli refresh-connections-command`](#constructorio-connect-cli-refresh-connections-command) * [`constructorio-connect-cli trigger-catalog-sync`](#constructorio-connect-cli-trigger-catalog-sync) ## `constructorio-connect-cli deploy ENV` Deploys all templates defined on the `connectrc.js` file to the specified environment, after running tests ('--force' to skip). ``` USAGE $ constructorio-connect-cli deploy ENV [-f] ARGUMENTS ENV (development|qa|production|demo) The target Constructor environment to deploy to. FLAGS -f, --force Skip tests before deploying DESCRIPTION Deploys all templates defined on the `connectrc.js` file to the specified environment, after running tests ('--force' to skip). The script will use the `CONNECT_AUTH_TOKEN` environment variable to authenticate with Constructor. EXAMPLES $ constructorio-connect-cli deploy development $ constructorio-connect-cli deploy qa $ constructorio-connect-cli deploy production $ constructorio-connect-cli deploy production --force ``` ## `constructorio-connect-cli execute` Execute a template against a connection and fixture to see the resulting transformed data. Each value not provided as a flag will be prompted for when the command is executed. ``` USAGE $ constructorio-connect-cli execute [--template-path <value>] [--fixture-path <value>] [--external-data-path <value>] [--connection-id <value>] FLAGS --connection-id=<value> The ID of the connection to execute the template against. --external-data-path=<value> The path to the external data to execute the template against. Must be in the 'src/fixtures/external_data' directory. --fixture-path=<value> The path to the fixture to execute the template against. Must be in the 'src/fixtures' directory. --template-path=<value> The path to the template to execute. Must be in the 'src/templates' directory. DESCRIPTION Execute a template against a connection and fixture to see the resulting transformed data. Each value not provided as a flag will be prompted for when the command is executed. EXAMPLES $ constructorio-connect-cli execute $ constructorio-connect-cli execute --template-path=item/item.jsonata $ constructorio-connect-cli execute --template-path=variation/variation.jsonata $ constructorio-connect-cli execute --template-path=item_group/item_group.jsonata --fixture-path=item_group.json $ constructorio-connect-cli execute --template-path=grouping/grouping.jsonata --connection-id=example-connection-id $ constructorio-connect-cli execute --template-path=mapping/mapping.jsonata ``` ## `constructorio-connect-cli generate-fixture` This command will fetch one fixture from the server and save it into a specified file. This fixture file will be an example of how the data would be passed to the connector when executing the templates. ``` USAGE $ constructorio-connect-cli generate-fixture DESCRIPTION This command will fetch one fixture from the server and save it into a specified file. This fixture file will be an example of how the data would be passed to the connector when executing the templates. You are expected to customize this file to match the data you expect to cover in a template execution (e.g. an item with stock, a variation with missing data), etc. Note that you can have multiple fixtures of the same type to cover different scenarios. Finally, if the file already exists you'll be prompted to overwrite it. EXAMPLES $ constructorio-connect-cli generate-fixture ``` ## `constructorio-connect-cli help [COMMAND]` Display help for constructorio-connect-cli. ``` USAGE $ constructorio-connect-cli help [COMMAND...] [-n] ARGUMENTS COMMAND... Command to show help for. FLAGS -n, --nested-commands Include all nested commands in the output. DESCRIPTION Display help for constructorio-connect-cli. ``` ## `constructorio-connect-cli init NAME` Bootstrap a new Constructor.io Connect CLI repository. ``` USAGE $ constructorio-connect-cli init NAME ARGUMENTS NAME name of the new folder DESCRIPTION Bootstrap a new Constructor.io Connect CLI repository. EXAMPLES $ constructorio-connect-cli init $ constructorio-connect-cli init new-repo-name ``` ## `constructorio-connect-cli refresh-connections-command` ``` USAGE $ constructorio-connect-cli refresh-connections-command ``` ## `constructorio-connect-cli trigger-catalog-sync` Triggers a catalog sync for selected connection. ``` USAGE $ constructorio-connect-cli trigger-catalog-sync DESCRIPTION Triggers a catalog sync for selected connection. The script will use the `CONNECT_AUTH_TOKEN` environment variable to authenticate with Constructor. EXAMPLES $ constructorio-connect-cli ``` <!-- commandsstop --> ## Development Here's some useful npm scripts: ```bash npm run lint # run lint on source code and tests npm run test # run tests npm run test:cov # run tests with coverage report ```