@remkoj/optimizely-cms-cli 6.0.0-pre1 → 6.0.0-pre11

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
@@ -3,21 +3,50 @@ A collection of Command Line tools used to increase productivity when working wi
3
3
 
4
4
  The defaults and methods are based upon using a Next.JS application with the conventions introduced by the [Create Next App template](https://github.com/remkoj/optimizely-saas-starter)
5
5
 
6
- - [1. Installing](#1-installing)
6
+ - [1. Installing / using](#1-installing--using)
7
+ - [1.1. Installing as development dependency](#11-installing-as-development-dependency)
8
+ - [1.2. Usage through direct execution](#12-usage-through-direct-execution)
7
9
  - [2. General usage and parameters](#2-general-usage-and-parameters)
8
10
  - [2.1. Global parameters](#21-global-parameters)
9
11
  - [2.2. Environment variables](#22-environment-variables)
10
12
  - [3. Available commands](#3-available-commands)
11
- - [3.1. Generate React Component Factory](#31-generate-react-component-factory)
12
- - [3.2. Check build and CMS Versions](#32-check-build-and-cms-versions)
13
+ - [3.1. General CMS Commands](#31-general-cms-commands)
14
+ - [3.2. JSON Schema's and Schema Validation](#32-json-schemas-and-schema-validation)
15
+ - [3.3. Display Templates (Styles)](#33-display-templates-styles)
16
+ - [3.4. Content Types](#34-content-types)
17
+ - [3.5. Next.JS Project support](#35-nextjs-project-support)
18
+ - [4. Detailed command descriptions](#4-detailed-command-descriptions)
19
+ - [4.1. Generate React Component Factory](#41-generate-react-component-factory)
13
20
 
14
21
 
15
- ## 1. Installing
22
+ ## 1. Installing / using
23
+ This package has been tested through `npx`, `yarn dlx` as well as development dependency within a Yarn managed project. Though there *should not* be a any dependency on Yarn as package manager for your project it has not been verified.
24
+
25
+ The usage examples through this readme are assuming the package has been installed as development dependency in a Yarn managed project, you must adjust these based upon your project.
26
+
27
+ ### 1.1. Installing as development dependency
16
28
  This package has been designed to work in a Yarn PnP / Zero-install environment, it may or may not work with other package managers.
17
29
  ```bash
18
30
  yarn add --dev @remkoj/optimizely-cms-cli
19
31
  ```
20
32
 
33
+ ### 1.2. Usage through direct execution
34
+ Instead of using the `yarn opti-cms` as shown in the examples, which is available as short-hand after installation as development dependency, you may use one of these as well.
35
+
36
+ ```bash
37
+ # Execution through NPX, latest version
38
+ npx @remkoj/optimizely-cms-cli
39
+
40
+ # Execution through Yarn DLX, latest version
41
+ yarn dlx @remkoj/optimizely-cms-cli
42
+
43
+ # Execution through NPX, explicit version 5.1.1
44
+ npx @remkoj/optimizely-cms-cli@5.1.1
45
+
46
+ # Execution through Yarn DLX, explicit version 5.1.1
47
+ yarn dlx @remkoj/optimizely-cms-cli@5.1.1
48
+ ```
49
+
21
50
  ## 2. General usage and parameters
22
51
 
23
52
  - **List all commands and global parameters:** `yarn opti-cms --help`
@@ -45,15 +74,39 @@ This CLI tool shares the environment variables with [@remkoj/optimizely-cms-api]
45
74
  ## 3. Available commands
46
75
  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.
47
76
 
77
+ ### 3.1. General CMS Commands
48
78
  | Command | Description |
49
79
  | --- | --- |
50
- |`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) |
80
+ |`cms:version`| Fetch and display the version of the CMS from the endpoint, allowing validation of the connection with Optimizely CMS. |
51
81
  |`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. |
82
+
83
+ ### 3.2. JSON Schema's and Schema Validation
84
+ | Command | Description |
85
+ | --- | --- |
86
+ | `schema:download` | Download schema definitions into a `.schema` folder within your project to facilitate JSON Schema validation by your IDE of choice. Use one or more `-s [schemaName]` parameters to override the schemas that must be downloaded. The `-d [relativePath]` to change where the location where the schema files must be stored. Using `-f` enables overwriting of existing schema files. |
87
+ | `schema:list` | Display a list of all schema's available within the Optimizely CMS instance.
88
+ | `schema:validate` | Downloads the OpenAPI Specification from the configured Optimizely CMS instance, extracts the appropriate types from it and uses those to validate all `*.opti-style.json` and `*.opti-type.json` files in the project. The output provides detailled error messages for each file that is not valid. |
89
+ | `schema:vscode` | Updates the `.vscode` folder to include the JSON Schema for both Content Type defintions and Display Templates. This will also create or update the `settings.json` to enable code-completion and validation on `*.opti-style.json` and `*.opti-type.json` files, using these schema's. Rerun this command to ensure that the definitions remain in sync with the OpenAPI specification of the CMS API. |
90
+
91
+ ### 3.3. Display Templates (Styles)
92
+ | Command | Description |
93
+ | --- | --- |
94
+ | `style:create` | Create a new Style definition file *(and optionally create it immediately within the CMS as well)* using a CLI interface, that will guide you through the process of setting the required properties.<br/>***Visual Studio Code users:*** Running `yarn opti-cms schema:vscode` will enable VS-Code to provide validation and completion for the generated `*.opti-style.json` file. |
95
+
96
+ ### 3.4. Content Types
97
+ | Command | Description |
98
+ | --- | --- |
52
99
  |`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. |
53
100
  |`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. |
54
- | `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) |
55
101
 
56
- ### 3.1. Generate React Component Factory
102
+ ### 3.5. Next.JS Project support
103
+ | Command | Description |
104
+ | --- | --- |
105
+ | `nextjs:factory` | Generate the component factories needed for suggested implementation pattern of Optimizely CMS in Next.JS. See [4.1. Generate React Component Factory](#41-generate-react-component-factory) |
106
+ | `nextjs:create` | An conveniance command, that will run the appropriate commands from the CLI in the right order to fully scaffold a frontend based upon the Content Types and Display Templates that already exist within the Optimizely CMS instance.<br/>It runs these commands: `types:pull`, `styles:pull`, `nextjs:fragments` `nextjs:components`, `nextjs:visualbuilder` and `nextjs:factory`. The command line arguments you provide to `nextjs:create` will be forwarded to each of these commands. |
107
+
108
+ ## 4. Detailed command descriptions
109
+ ### 4.1. Generate React Component Factory
57
110
  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.
58
111
 
59
112
  #### Usage & example<!-- omit in toc -->
@@ -70,13 +123,4 @@ yarn opti-cms nextjs:factory -f
70
123
  | --baseTypes | -b | Select only content types with one of these base types. Add multiple times to build a list | [] |
71
124
  | --types | -t | Select content types with this key. Add multiple times to build a list | [] |
72
125
  | --all | -a | Include non-supported base types, non supported base types are skipped by default | |
73
- | --force | -f | By default, this method is none-destructive. Set this parameter to overwrite existing files. | |
74
-
75
- ### 3.2. Check build and CMS Versions
76
- Connect to the Optimizely CMS Service to fetch service health and version information.
77
-
78
- #### Usage & example<!-- omit in toc -->
79
- Command: `cms:version`
80
- ```Bash
81
- yarn opti-cms cms:version
82
- ```
126
+ | --force | -f | By default, this method is none-destructive. Set this parameter to overwrite existing files. | |