@remkoj/optimizely-cms-cli
Advanced tools
+4
-3
@@ -5,3 +5,3 @@ { | ||
| "type": "module", | ||
| "version": "5.2.0", | ||
| "version": "5.3.0", | ||
| "bin": { | ||
@@ -21,3 +21,3 @@ "opti-cms": "./dist/index.js" | ||
| "devDependencies": { | ||
| "@remkoj/optimizely-cms-api": "5.2.0", | ||
| "@remkoj/optimizely-cms-api": "5.3.0", | ||
| "@rollup/plugin-json": "^6.1.0", | ||
@@ -32,3 +32,3 @@ "@rollup/plugin-typescript": "^12.3.0", | ||
| "peerDependencies": { | ||
| "@remkoj/optimizely-cms-api": "^5.2.0", | ||
| "@remkoj/optimizely-cms-api": "^5.3.0", | ||
| "@types/node": "*" | ||
@@ -40,2 +40,3 @@ }, | ||
| "cli-table3": "^0.6.5", | ||
| "deep-object-diff": "^1.1.9", | ||
| "dotenv": "^17.2.3", | ||
@@ -42,0 +43,0 @@ "dotenv-expand": "^12.0.3", |
+230
-30
@@ -15,4 +15,17 @@ # Optimizely CMS Command Line Toolkit <!-- omit in toc --> | ||
| - [3. Available commands](#3-available-commands) | ||
| - [3.1. Generate React Component Factory](#31-generate-react-component-factory) | ||
| - [3.2. Check build and CMS Versions](#32-check-build-and-cms-versions) | ||
| - [`cms:reset`](#cmsreset) | ||
| - [`cms:version`](#cmsversion) | ||
| - [`nextjs:components`](#nextjscomponents) | ||
| - [`nextjs:create`](#nextjscreate) | ||
| - [`nextjs:factory`](#nextjsfactory) | ||
| - [`nextjs:fragments`](#nextjsfragments) | ||
| - [`nextjs:queries`](#nextjsqueries) | ||
| - [`nextjs:visualbuilder`](#nextjsvisualbuilder) | ||
| - [`style:create`](#stylecreate) | ||
| - [`styles:delete`](#stylesdelete) | ||
| - [`styles:list`](#styleslist) | ||
| - [`styles:pull`](#stylespull) | ||
| - [`styles:push`](#stylespush) | ||
| - [`types:pull`](#typespull) | ||
| - [`types:push`](#typespush) | ||
@@ -51,38 +64,225 @@ | ||
| ## 3. Available commands | ||
| The following commands are available, you can always run `opti-cms --help` or `opti-cms [command] --help` to see all information for the CLI utility or command. If the command is omitted, the CLI will assume the `cms:version` command. | ||
| The following commands are available. You can run `opti-cms --help` or `opti-cms [command] --help` to view all options. If the command is omitted, the CLI defaults to `cms:version`. | ||
| | Command | Description | | ||
| | --- | --- | | ||
| |`cms:version`| Fetch the version of the CMS from the endpoint. See [3.2. Check build and CMS Versions](#32-check-build-and-cms-versions) | | ||
| |`cms:reset` | Reset the CMS instance by removing all Content, Content Types and Display Templates.<br/>***Note:*** This currently requires some manual steps, the CLI will provide the needed guidance on these manual steps. | | ||
| |`types:pull`| Read all existing content types from the Optimizely CMS and create their representation within the codebase. Use the parameters of this method to control which types will be pulled and to allow overwriting of existing files. | | ||
| |`types:push`| Create or overwrite the content type defintions from the codebase into Optimizely CMS, use the parameters of this method to control which types will be transferred and whether destructive changes are allowed. | | ||
| | `nextjs:factory` | Generate the component factories needed for suggested implementation pattern of Optimizely CMS in Next.JS. See [3.1. Generate React Component Factory](#31-generate-react-component-factory) | | ||
| | Command | Description | Usage | | ||
| | --- | --- | --- | | ||
| | `cms:reset` | Completely clear & reset the CMS Database | [See usage](#cmd-cms-reset) | | ||
| | `cms:version` | Get the CMS Version information | [See usage](#cmd-cms-version) | | ||
| | `nextjs:components` | Create the React Components for a Next.JS / Optimizely Graph structure | [See usage](#cmd-nextjs-components) | | ||
| | `nextjs:create` | Scaffold a complete Next.JS / Optimizely Graph structure | [See usage](#cmd-nextjs-create) | | ||
| | `nextjs:factory` | Create the ComponentFactory for a Next.JS / Optimizely Graph structure | [See usage](#cmd-nextjs-factory) | | ||
| | `nextjs:fragments` | Create the GrapQL Fragments for a Next.JS / Optimizely Graph structure | [See usage](#cmd-nextjs-fragments) | | ||
| | `nextjs:queries` | Create the GrapQL Queries to use two queries to load content | [See usage](#cmd-nextjs-queries) | | ||
| | `nextjs:visualbuilder` | Create the React Components for Visual Builder in a Next.JS / Optimizely Graph structure | [See usage](#cmd-nextjs-visualbuilder) | | ||
| | `style:create` | Create a new style definition | [See usage](#cmd-style-create) | | ||
| | `styles:delete` | Remove Visual Builder style definitions from the CMS | [See usage](#cmd-styles-delete) | | ||
| | `styles:list` | List Visual Builder style definitions from the CMS | [See usage](#cmd-styles-list) | | ||
| | `styles:pull` | Create Visual Builder style definitions from the CMS | [See usage](#cmd-styles-pull) | | ||
| | `styles:push` | Push Visual Builder style definitions into the CMS (create/patch) | [See usage](#cmd-styles-push) | | ||
| | `types:pull` | Pull content type definition files into the project | [See usage](#cmd-types-pull) | | ||
| | `types:push` | Push content type definition into Optimizely CMS (create / replace) | [See usage](#cmd-types-push) | | ||
| ### 3.1. Generate React Component Factory | ||
| This is a companion method to the ComponentFactory / DefaultComponentFactory implementation within [@remkoj/optimizely-cms-react](https://www.npmjs.com/package/@remkoj/optimizely-cms-react) that is used to resolve content types within Optimizely CMS into React Components. This method will create the needed files to easily construct the factory from the components in the frontend. | ||
| <a id="cmd-cms-reset"></a> | ||
| ### `cms:reset` | ||
| ```bash | ||
| yarn opti-cms cms:reset | ||
| ``` | ||
| #### Usage & example<!-- omit in toc --> | ||
| Command: `nextjs:factory` | ||
| ```Bash | ||
| yarn opti-cms nextjs:factory -f | ||
| Command-specific parameters: none. This command only uses [global parameters](#21-global-parameters). | ||
| <a id="cmd-cms-version"></a> | ||
| ### `cms:version` | ||
| ```bash | ||
| yarn opti-cms cms:version | ||
| ``` | ||
| #### Command line parameters<!-- omit in toc --> | ||
| | Parameter | Alias | Usage | Default | | ||
| Command-specific parameters: none. This command only uses [global parameters](#21-global-parameters). | ||
| <a id="cmd-nextjs-components"></a> | ||
| ### `nextjs:components` | ||
| ```bash | ||
| yarn opti-cms nextjs:components | ||
| ``` | ||
| | Parameter | Alias | Usage | Example | | ||
| | --- | --- | --- | --- | | ||
| | --excludeTypes | --ect | Key of content type to exclude. Can be used multiple times to exclude a list of content types | [] | | ||
| | --excludeBaseTypes | --ebt | Exclude all content types, with one of these base types. If provided it will replace the default. Add multiple times to build a list | ["folder","media","image","video"] | | ||
| | --baseTypes | -b | Select only content types with one of these base types. Add multiple times to build a list | [] | | ||
| | --types | -t | Select content types with this key. Add multiple times to build a list | [] | | ||
| | --all | -a | Include non-supported base types, non supported base types are skipped by default | | | ||
| | --force | -f | By default, this method is none-destructive. Set this parameter to overwrite existing files. | | | ||
| | `--excludeTypes` | `--ect` | Exclude specific content type keys | `yarn opti-cms nextjs:components --excludeTypes StartPage --excludeTypes LandingPage` | | ||
| | `--excludeBaseTypes` | `--ebt` | Exclude specific base types | `yarn opti-cms nextjs:components --excludeBaseTypes media` | | ||
| | `--baseTypes` | `-b` | Include only the selected base types | `yarn opti-cms nextjs:components -b page -b section` | | ||
| | `--types` | `-t` | Include only the selected content type keys | `yarn opti-cms nextjs:components -t StartPage` | | ||
| | `--all` | `-a` | Include non-supported base types | `yarn opti-cms nextjs:components -a` | | ||
| | `--force` | `-f` | Overwrite existing generated files | `yarn opti-cms nextjs:components -f` | | ||
| ### 3.2. Check build and CMS Versions | ||
| Connect to the Optimizely CMS Service to fetch service health and version information. | ||
| <a id="cmd-nextjs-create"></a> | ||
| ### `nextjs:create` | ||
| ```bash | ||
| yarn opti-cms nextjs:create | ||
| ``` | ||
| #### Usage & example<!-- omit in toc --> | ||
| Command: `cms:version` | ||
| ```Bash | ||
| yarn opti-cms cms:version | ||
| | Parameter | Alias | Usage | Example | | ||
| | --- | --- | --- | --- | | ||
| | `--excludeTypes` | `--ect` | Exclude specific content type keys | `yarn opti-cms nextjs:create --excludeTypes StartPage` | | ||
| | `--excludeBaseTypes` | `--ebt` | Exclude specific base types | `yarn opti-cms nextjs:create --excludeBaseTypes media` | | ||
| | `--baseTypes` | `-b` | Include only the selected base types | `yarn opti-cms nextjs:create -b page -b experience` | | ||
| | `--types` | `-t` | Include only the selected content type keys | `yarn opti-cms nextjs:create -t StartPage` | | ||
| | `--all` | `-a` | Include non-supported base types | `yarn opti-cms nextjs:create -a` | | ||
| | `--force` | `-f` | Overwrite existing generated files | `yarn opti-cms nextjs:create -f` | | ||
| <a id="cmd-nextjs-factory"></a> | ||
| ### `nextjs:factory` | ||
| ```bash | ||
| yarn opti-cms nextjs:factory | ||
| ``` | ||
| | Parameter | Alias | Usage | Example | | ||
| | --- | --- | --- | --- | | ||
| | `--excludeTypes` | `--ect` | Exclude specific content type keys | `yarn opti-cms nextjs:factory --excludeTypes StartPage` | | ||
| | `--excludeBaseTypes` | `--ebt` | Exclude specific base types | `yarn opti-cms nextjs:factory --excludeBaseTypes media` | | ||
| | `--baseTypes` | `-b` | Include only the selected base types | `yarn opti-cms nextjs:factory -b page` | | ||
| | `--types` | `-t` | Include only the selected content type keys | `yarn opti-cms nextjs:factory -t StartPage` | | ||
| | `--all` | `-a` | Include non-supported base types | `yarn opti-cms nextjs:factory -a` | | ||
| | `--force` | `-f` | Overwrite existing generated files | `yarn opti-cms nextjs:factory -f` | | ||
| <a id="cmd-nextjs-fragments"></a> | ||
| ### `nextjs:fragments` | ||
| ```bash | ||
| yarn opti-cms nextjs:fragments | ||
| ``` | ||
| | Parameter | Alias | Usage | Example | | ||
| | --- | --- | --- | --- | | ||
| | `--excludeTypes` | `--ect` | Exclude specific content type keys | `yarn opti-cms nextjs:fragments --excludeTypes StartPage` | | ||
| | `--excludeBaseTypes` | `--ebt` | Exclude specific base types | `yarn opti-cms nextjs:fragments --excludeBaseTypes media` | | ||
| | `--baseTypes` | `-b` | Include only the selected base types | `yarn opti-cms nextjs:fragments -b page -b section` | | ||
| | `--types` | `-t` | Include only the selected content type keys | `yarn opti-cms nextjs:fragments -t StartPage` | | ||
| | `--all` | `-a` | Include non-supported base types | `yarn opti-cms nextjs:fragments -a` | | ||
| | `--force` | `-f` | Overwrite existing generated files | `yarn opti-cms nextjs:fragments -f` | | ||
| <a id="cmd-nextjs-queries"></a> | ||
| ### `nextjs:queries` | ||
| ```bash | ||
| yarn opti-cms nextjs:queries | ||
| ``` | ||
| | Parameter | Alias | Usage | Example | | ||
| | --- | --- | --- | --- | | ||
| | `--excludeTypes` | `--ect` | Exclude specific content type keys | `yarn opti-cms nextjs:queries --excludeTypes StartPage` | | ||
| | `--excludeBaseTypes` | `--ebt` | Exclude specific base types | `yarn opti-cms nextjs:queries --excludeBaseTypes media` | | ||
| | `--baseTypes` | `-b` | Include only selected base types (defaults to `page` and `experience`) | `yarn opti-cms nextjs:queries -b page` | | ||
| | `--types` | `-t` | Include only the selected content type keys | `yarn opti-cms nextjs:queries -t StartPage` | | ||
| | `--all` | `-a` | Include non-supported base types | `yarn opti-cms nextjs:queries -a` | | ||
| | `--force` | `-f` | Overwrite existing generated files | `yarn opti-cms nextjs:queries -f` | | ||
| <a id="cmd-nextjs-visualbuilder"></a> | ||
| ### `nextjs:visualbuilder` | ||
| ```bash | ||
| yarn opti-cms nextjs:visualbuilder | ||
| ``` | ||
| | Parameter | Alias | Usage | Example | | ||
| | --- | --- | --- | --- | | ||
| | `--excludeTypes` | `--ect` | Exclude specific content type keys | `yarn opti-cms nextjs:visualbuilder --excludeTypes StartPage` | | ||
| | `--excludeBaseTypes` | `--ebt` | Exclude specific base types | `yarn opti-cms nextjs:visualbuilder --excludeBaseTypes media` | | ||
| | `--baseTypes` | `-b` | Include only the selected base types | `yarn opti-cms nextjs:visualbuilder -b section` | | ||
| | `--types` | `-t` | Include only the selected content type keys | `yarn opti-cms nextjs:visualbuilder -t StandardPage` | | ||
| | `--all` | `-a` | Include non-supported base types | `yarn opti-cms nextjs:visualbuilder -a` | | ||
| | `--force` | `-f` | Overwrite existing generated files | `yarn opti-cms nextjs:visualbuilder -f` | | ||
| <a id="cmd-style-create"></a> | ||
| ### `style:create` | ||
| ```bash | ||
| yarn opti-cms style:create | ||
| ``` | ||
| Command-specific parameters: none. This command is interactive and prompts for all required values. | ||
| <a id="cmd-styles-delete"></a> | ||
| ### `styles:delete` | ||
| ```bash | ||
| yarn opti-cms styles:delete | ||
| ``` | ||
| | Parameter | Alias | Usage | Example | | ||
| | --- | --- | --- | --- | | ||
| | `--excludeTypes` | `--ect` | Exclude content types when resolving style targets | `yarn opti-cms styles:delete --excludeTypes StartPage` | | ||
| | `--excludeBaseTypes` | `--ebt` | Exclude base types when resolving style targets | `yarn opti-cms styles:delete --excludeBaseTypes media` | | ||
| | `--baseTypes` | `-b` | Include only styles targeting selected base types | `yarn opti-cms styles:delete -b section` | | ||
| | `--types` | `-t` | Include only styles targeting selected content types | `yarn opti-cms styles:delete -t StartPage` | | ||
| | `--all` | `-a` | Include non-supported base types | `yarn opti-cms styles:delete -a` | | ||
| | `--excludeNodeTypes` | `--ent` | Exclude specific node types | `yarn opti-cms styles:delete --excludeNodeTypes row` | | ||
| | `--excludeTemplates` | `--et` | Exclude specific style template keys | `yarn opti-cms styles:delete --excludeTemplates hero` | | ||
| | `--nodes` | `-n` | Include only selected node types | `yarn opti-cms styles:delete -n row` | | ||
| | `--templates` | `-d` | Include only selected style template keys | `yarn opti-cms styles:delete -d hero -d article` | | ||
| | `--templateTypes` | `--tt` | Include only selected style target types (`node`, `base`, `component`) | `yarn opti-cms styles:delete --tt node --tt base` | | ||
| | `--force` | `-f` | Actually perform delete; without this the command shows a dry preview | `yarn opti-cms styles:delete -f` | | ||
| | `--withStyleFile` | `-w` | Also delete local `.opti-style.json` files | `yarn opti-cms styles:delete -f -w` | | ||
| | `--definitions` | `-u` | Update/delete generated TypeScript display template helpers | `yarn opti-cms styles:delete -f -u` | | ||
| <a id="cmd-styles-list"></a> | ||
| ### `styles:list` | ||
| ```bash | ||
| yarn opti-cms styles:list | ||
| ``` | ||
| Command-specific parameters: none. This command only uses [global parameters](#21-global-parameters). | ||
| <a id="cmd-styles-pull"></a> | ||
| ### `styles:pull` | ||
| ```bash | ||
| yarn opti-cms styles:pull | ||
| ``` | ||
| | Parameter | Alias | Usage | Example | | ||
| | --- | --- | --- | --- | | ||
| | `--excludeTypes` | `--ect` | Exclude content types when resolving style targets | `yarn opti-cms styles:pull --excludeTypes StartPage` | | ||
| | `--excludeBaseTypes` | `--ebt` | Exclude base types when resolving style targets | `yarn opti-cms styles:pull --excludeBaseTypes media` | | ||
| | `--baseTypes` | `-b` | Include only styles targeting selected base types | `yarn opti-cms styles:pull -b section -b element` | | ||
| | `--types` | `-t` | Include only styles targeting selected content types | `yarn opti-cms styles:pull -t StartPage` | | ||
| | `--all` | `-a` | Include non-supported base types | `yarn opti-cms styles:pull -a` | | ||
| | `--excludeNodeTypes` | `--ent` | Exclude specific node types | `yarn opti-cms styles:pull --excludeNodeTypes row` | | ||
| | `--excludeTemplates` | `--et` | Exclude specific style template keys | `yarn opti-cms styles:pull --excludeTemplates hero` | | ||
| | `--nodes` | `-n` | Include only selected node types | `yarn opti-cms styles:pull -n row` | | ||
| | `--templates` | `-d` | Include only selected style template keys | `yarn opti-cms styles:pull -d hero -d article` | | ||
| | `--templateTypes` | `--tt` | Include only selected style target types (`node`, `base`, `component`) | `yarn opti-cms styles:pull --tt component` | | ||
| | `--force` | `-f` | Overwrite existing generated files | `yarn opti-cms styles:pull -f` | | ||
| | `--definitions` | `-u` | Create or update generated TypeScript definitions | `yarn opti-cms styles:pull -u` | | ||
| <a id="cmd-styles-push"></a> | ||
| ### `styles:push` | ||
| ```bash | ||
| yarn opti-cms styles:push | ||
| ``` | ||
| | Parameter | Alias | Usage | Example | | ||
| | --- | --- | --- | --- | | ||
| | `--excludeTemplates` | `-e` | Exclude style template keys from push | `yarn opti-cms styles:push -e hero` | | ||
| | `--templates` | `-t` | Push only selected style template keys | `yarn opti-cms styles:push -t hero -t article` | | ||
| <a id="cmd-types-pull"></a> | ||
| ### `types:pull` | ||
| ```bash | ||
| yarn opti-cms types:pull | ||
| ``` | ||
| | Parameter | Alias | Usage | Example | | ||
| | --- | --- | --- | --- | | ||
| | `--excludeTypes` | `--ect` | Exclude specific content type keys | `yarn opti-cms types:pull --excludeTypes StartPage` | | ||
| | `--excludeBaseTypes` | `--ebt` | Exclude specific base types | `yarn opti-cms types:pull --excludeBaseTypes media` | | ||
| | `--baseTypes` | `-b` | Include only selected base types | `yarn opti-cms types:pull -b page -b section` | | ||
| | `--types` | `-t` | Include only selected content type keys | `yarn opti-cms types:pull -t StartPage` | | ||
| | `--all` | `-a` | Include non-supported base types | `yarn opti-cms types:pull -a` | | ||
| | `--force` | `-f` | Overwrite existing generated files | `yarn opti-cms types:pull -f` | | ||
| <a id="cmd-types-push"></a> | ||
| ### `types:push` | ||
| ```bash | ||
| yarn opti-cms types:push | ||
| ``` | ||
| | Parameter | Alias | Usage | Example | | ||
| | --- | --- | --- | --- | | ||
| | `--force` | `-f` | Force overwrite/replace while pushing to CMS | `yarn opti-cms types:push -f` | | ||
| | `--excludeTypes` | `--ect` | Exclude specific content type keys from push | `yarn opti-cms types:push --excludeTypes StartPage` | | ||
| | `--excludeBaseTypes` | `--ebt` | Exclude content type base types from push | `yarn opti-cms types:push --excludeBaseTypes media` | | ||
| | `--baseTypes` | `-b` | Push only content types with selected base types | `yarn opti-cms types:push -b page` | | ||
| | `--types` | `-t` | Push only selected content type keys | `yarn opti-cms types:push -t StartPage -t ArticlePage` | |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
251759
9.33%2347
8.81%287
229.89%11
10%+ Added
+ Added