@dynamicweb/cli 1.0.16 → 1.1.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.
package/README.md CHANGED
@@ -1,222 +1,244 @@
1
- # DynamicWeb CLI
2
-
3
- ## What is it?
4
- DynamicWeb CLI is a powerful command line tool designed to help developers quickly and efficiently manage any given DynamicWeb 10 solution they may have access to. These tools inclues an easy setup and handling of different environments, access to the Management API and an easy way to update a Swift solution.
5
-
6
- Logging into a DynamicWeb 10 solution through the DynamicWeb CLI will create an API Key for the given user, which in turn lets you use any Queries and Commands the solution had, meaning you can control everything you can do in the backend, from your command line.
7
- With this, you can hook it up to your own build pipelines and processes, if certain requests needs to happen before or after deployments or changes.
8
-
9
- The DynamicWeb CLI can also help with active development of custom addins to solutions. With a simple `dw install` command it will upload and install your custom code to a solution.
10
-
11
- Extracting files from solutions is just as easy as well, with the DynamicWeb CLI you can list out the structure of a solution and get full exports of the files structure and the database. Importing files into a solution is just as easy as well, as long as you have access to the files and the solution, they can be imported with a simple command using the DynamicWeb CLI.
12
-
13
- ## Get started
14
- To install after cloning, move to project dir and run
15
- > $ npm install -g .
16
- >
17
- > $ npm install
18
-
19
- Note that specific installations might be necessary if you're faced with errors such as 'Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'yargs''
20
- In which case try installing that module specifically;
21
- > $ npm install yargs
22
-
23
- ## Commands
24
- All commands and options can be viewed by running
25
- > $ dw --help
26
- >
27
- > $ dw \<command\> --help
28
-
29
- ### Users and environments
30
- As most commands are pulling or pushing data from the DW admin API, the necessary authorization is required.
31
-
32
- To generate an Api-key that the CLI will use, login to your environment
33
- > $ dw login
34
-
35
- This will start an interactive session asking for username and password, as well as the name of the environment, so it's possible to switch between different environments easily.
36
- It will also ask for a host, if you're running a local environment, set this to the host it starts up with, i.e `localhost:6001`.
37
-
38
- Each environment has its own users, and each user has its own Api-key assigned to it, swap between environments by using
39
- > $ dw env \<env\>
40
-
41
- and swap between users by simply supplying the name of the user in the login command
42
- > $ dw login \<username\>
43
-
44
- You can view the current environment and user being used by simply typing
45
- > $ dw
46
-
47
- The configuration will automatically be created when setting up your first environment, but if you already have an Api-key you want to use for a user, you can modify the config directly in the file located in `usr/.dwc`. The structure should look like the following
48
- ```json
49
- {
50
- "env": {
51
- "dev": {
52
- "host": "localhost:6001",
53
- "users": {
54
- "DemoUser": {
55
- "apiKey": "<keyPrefix>.<key>"
56
- }
57
- },
58
- "current": {
59
- "user": "DemoUser"
60
- }
61
- }
62
- },
63
- "current": {
64
- "env": "dev"
65
- }
66
- }
67
- ```
68
-
69
- ### Files
70
- > $ dw files \<dirPath\> \<outPath\>
71
-
72
- The files command is used to list out and export the structure in your Dynamicweb files archive, as such is has multiple options;
73
- - `-l` `--list` This will list the directory given in \<dirPath\>
74
- - `-f` `--includeFiles` The list will now also show all files in the directories
75
- - `-r` `--recursive` By default it only handles the \<dirPath\>, but with this option it will handle all directories under this recursively
76
- - `-e` `--export` It will export \<dirPath\> into \<outPath\> on your local machine, unzipped by default
77
- - `--raw` This will keep the content zipped
78
- - `--iamstupid` This will include the export of the /files/system/log and /files/.cache folders
79
-
80
- #### Examples
81
- Exporting all templates from current environment to local solution
82
- > $ cd DynamicWebSolution/Files
83
- >
84
- > $ dw files templates ./templates -fre
85
-
86
- Listing the system files structure of the current environment
87
- > $ dw files system -lr
88
-
89
- ### Files Source Type Detection
90
- By default, the `dw files` command automatically detects the source type based on the \<dirPath\>:
91
- If the path contains a file extension (e.g., 'templates/Translations.xml'), it is treated as a file.
92
- Otherwise, it is treated as a directory.
93
- In cases where this detection is incorrect, you can force the type using these flags:
94
-
95
- - `-ad` `--asDirectory` Forces the command to treat the path as a directory, even if its name contains a dot.
96
- - `-af` `--asFile` Forces the command to treat the path as a single file, even if it has no extension.
97
-
98
- #### Examples
99
-
100
- Exporting single file from current environment to local solution
101
- > $ dw files templates/Translations.xml ./templates -e
102
-
103
- Exporting a directory that looks like a file
104
- > $ dw files templates/templates.v1 ./templates -e -ad
105
-
106
- Exporting a file that has no extension
107
- > $ dw files templates/testfile ./templates -e -af
108
-
109
- ### Swift
110
- > $ dw swift \<outPath\>
111
-
112
- The swift command is used to easily get your local environment up to date with the latest swift release. It will override all existing directories and content in those, which can then be adjusted in your source control afterwards. It has multiple options to specify which tag or branch to pull;
113
- - `-t` `--tag <tag>` The tag/branch/release to pull
114
- - `-l` `--list` Will list all the release versions
115
- - `-n` `--nightly` Will pull #HEAD, as default is latest release
116
- - `--force` Used if \<outPath\> is not an empty folder, to override all the content
117
-
118
- #### Examples
119
- Getting all the available releases
120
- > $ dw swift -l
121
-
122
- Pulling and overriding local solution with latest nightly build
123
- > $ cd DynamicWebSolution/Swift
124
- >
125
- > $ dw swift . -n --force
126
-
127
- ### Query
128
- > $ dw query \<query\>
129
-
130
- The query command will fire any query towards the admin Api with the given query parameters. This means any query parameter that's necessary for the given query, is required as an option in this command. It's also possible to list which parameters is necessary for the given query through the options;
131
- - `-l` `--list` Will list all the properties for the given \<query\>
132
- - `-i` `--interactive` Will perform the \<query\> but without any parameters, as they will be asked for one by one in interactive mode
133
- - `--<queryParam>` Any parameter the query needs will be sent by '--key value'
134
-
135
- #### Examples
136
- Getting all properties for a query
137
- > $ dw query FileByName -l
138
-
139
- Getting file information on a specific file by name
140
- > $ dw query FileByName --name DefaultMail.html --directorypath /Templates/Forms/Mail
141
-
142
- ### Command
143
- > $ dw command \<command\>
144
-
145
- Using command will, like query, fire any given command in the solution. It works like query, given the query parameters necessary, however if a `DataModel` is required for the command, it is given in a json-format, either through a path to a .json file or a literal json-string in the command.
146
- - `-l` `--list` Lists all the properties for the command, as well as the json model required **currently not working**
147
- - `--json` Takes a path to a .json file or a literal json, i.e --json '{ abc: "123" }'
148
-
149
- #### Examples
150
- Creating a copy of a page using a json-string
151
- > $ dw command PageCopy --json '{ "model": { "SourcePageId": 1189, "DestinationParentPageId": 1129 } }'
152
-
153
- Removing a page using a json file
154
- > $ dw command PageMove --json ./PageMove.json
155
-
156
- Where PageMove.json contains
157
- ```json
158
- { "model": { "SourcePageId": 1383, "DestinationParentPageId": 1376 } }
159
- ```
160
-
161
- Deleting a page
162
- > $ dw command PageDelete --json '{ "id": "1383" }'
163
-
164
- ### Install
165
- > $ dw install \<filePath\>
166
-
167
- Install is somewhat of a shorthand for a few commands. It will upload and install a given .dll or .nupkg addin to your current environment.
168
-
169
- It's meant to be used to easily apply custom dlls to a given project, it being local or otherwise, so after having a dotnet library built locally, this command can be run, pointing to the built .dll and it will handle the rest with all the addin installation, and it will be available in the DynamicWeb solution as soon as the command finishes.
170
-
171
- #### Examples
172
- > $ dw install ./bin/Release/net6.0/CustomProject.dll
173
-
174
- ### Database
175
- > $ dw database \<outPath\>
176
-
177
- This command is used for various actions towards your current environments database.
178
- - `-e` `--export` Exports your current environments database to a .bacpac file at \<outPath\>
179
-
180
- #### Examples
181
- > $ dw database -e ./backup
182
-
183
- ### Config
184
- > $ dw config
185
-
186
- Config is used to manage the .dwc file through the CLI, given any prop it will create the key/value with the path to it.
187
- - `--<property>` The path and name of the property to set
188
-
189
- #### Examples
190
- Changing the host for the dev environment
191
- > $ dw config --env.dev.host localhost:6001
192
-
193
- ## Using Git Bash
194
- If you're using Git Bash, you may encounter issues with path conversion that can interfere with relative paths used in commands.
195
-
196
- ### Path Conversion Issues
197
- Git Bash automatically converts relative paths to absolute paths, which can cause problems.
198
- You'll see a warning message if the conversion setting is not disabled:
199
-
200
- "You appear to have path conversion turned on in your shell.
201
- If you are using relative paths, this may interfere.
202
- Please see https://doc.dynamicweb.dev/documentation/fundamentals/code/CLI.html for more information."
203
-
204
- ### Solution
205
- To resolve this issue, disable path conversion by setting the `MSYS_NO_PATHCONV` environment variable (current session only):
206
-
207
- > $ export MSYS_NO_PATHCONV=1
208
-
209
- #### Examples
210
-
211
- > $ export MSYS_NO_PATHCONV=1
212
- > $ dw files -iro ./ /TestFolder --host \<host\> --apiKey \<apiKey\>
213
-
214
- ### Alternative Solutions
215
- If you prefer not to disable path conversion globally, you can:
216
-
217
- 1. Prefix relative paths with `./` instead of just `/` to prevent conversion for specific commands.
218
- 2. Use PowerShell or CMD instead of Git Bash.
219
-
220
- #### Examples
221
-
222
- > $ dw files -iro ./ ./TestFolder --host \<host\> --apiKey \<apiKey\>
1
+ # DynamicWeb CLI
2
+
3
+ ## What is it?
4
+ DynamicWeb CLI is a powerful command line tool designed to help developers quickly and efficiently manage any given DynamicWeb 10 solution they may have access to. These tools include an easy setup and handling of different environments, access to the Management API and an easy way to update a Swift solution.
5
+
6
+ Logging into a DynamicWeb 10 solution through the DynamicWeb CLI will create an API Key for the given user, which in turn lets you use any Queries and Commands the solution had, meaning you can control everything you can do in the backend, from your command line.
7
+ With this, you can hook it up to your own build pipelines and processes, if certain requests needs to happen before or after deployments or changes.
8
+
9
+ The DynamicWeb CLI can also help with active development of custom addins to solutions. With a simple `dw install` command it will upload and install your custom code to a solution.
10
+
11
+ Extracting files from solutions is just as easy as well, with the DynamicWeb CLI you can list out the structure of a solution and get full exports of the files structure and the database. Importing files into a solution is just as easy as well, as long as you have access to the files and the solution, they can be imported with a simple command using the DynamicWeb CLI.
12
+
13
+ ## Get started
14
+ ### Install from npm
15
+ Install the published CLI globally:
16
+ > $ npm install -g @dynamicweb/cli
17
+
18
+ Then verify the command is available:
19
+ > $ dw --help
20
+
21
+ ### Install from source
22
+ If you're working on the CLI locally, clone the repository, move into the project directory, and run:
23
+ > $ npm install
24
+ >
25
+ > $ npm install -g .
26
+
27
+ This installs dependencies for development and links the current checkout as the global `dw` command.
28
+
29
+ ### Publish a new version
30
+ Before publishing, make sure the version in `package.json` has been bumped:
31
+ > $ npm version patch
32
+
33
+ Log in to npm and publish the scoped package publicly:
34
+ > $ npm login
35
+ >
36
+ > $ npm publish --access public
37
+
38
+ ## Commands
39
+ All commands and options can be viewed by running
40
+ > $ dw --help
41
+ >
42
+ > $ dw \<command\> --help
43
+
44
+ ### Global options
45
+ Most commands support the following global options:
46
+ - `-v` `--verbose` Run with verbose logging
47
+ - `--host` Set the host directly, bypassing environment config (requires `--apiKey`)
48
+ - `--apiKey` Set the API key for an environmentless execution
49
+ - `--protocol` Set the protocol used (only with `--host`, defaults to `https`)
50
+
51
+ ### Users and environments
52
+ As most commands are pulling or pushing data from the DW admin API, the necessary authorization is required.
53
+
54
+ To generate an Api-key that the CLI will use, login to your environment
55
+ > $ dw login
56
+
57
+ This will start an interactive session asking for username and password, as well as the name of the environment, so it's possible to switch between different environments easily.
58
+ It will also ask for a host, if you're running a local environment, set this to the host it starts up with, i.e `localhost:6001`.
59
+
60
+ Each environment has its own users, and each user has its own Api-key assigned to it, swap between environments by using
61
+ > $ dw env \<env\>
62
+
63
+ and swap between users by simply supplying the name of the user in the login command
64
+ > $ dw login \<username\>
65
+
66
+ You can view the current environment and user being used by simply typing
67
+ > $ dw
68
+
69
+ The configuration will automatically be created when setting up your first environment, but if you already have an Api-key you want to use for a user, you can modify the config directly in the file located in `~/.dwc`. The structure should look like the following
70
+ ```json
71
+ {
72
+ "env": {
73
+ "dev": {
74
+ "host": "localhost:6001",
75
+ "users": {
76
+ "DemoUser": {
77
+ "apiKey": "<keyPrefix>.<key>"
78
+ }
79
+ },
80
+ "current": {
81
+ "user": "DemoUser"
82
+ }
83
+ }
84
+ },
85
+ "current": {
86
+ "env": "dev"
87
+ }
88
+ }
89
+ ```
90
+
91
+ ### Files
92
+ > $ dw files \<dirPath\> \<outPath\>
93
+
94
+ The files command is used to list out and export the structure in your Dynamicweb files archive, as such is has multiple options;
95
+ - `-l` `--list` This will list the directory given in \<dirPath\>
96
+ - `-f` `--includeFiles` The list will now also show all files in the directories
97
+ - `-r` `--recursive` By default it only handles the \<dirPath\>, but with this option it will handle all directories under this recursively
98
+ - `-e` `--export` It will export \<dirPath\> into \<outPath\> on your local machine, unzipped by default
99
+ - `--raw` This will keep the content zipped
100
+ - `--iamstupid` This will include the export of the /files/system/log and /files/.cache folders
101
+
102
+ #### Examples
103
+ Exporting all templates from current environment to local solution
104
+ > $ cd DynamicWebSolution/Files
105
+ >
106
+ > $ dw files templates ./templates -fre
107
+
108
+ Listing the system files structure of the current environment
109
+ > $ dw files system -lr
110
+
111
+ ### Files Source Type Detection
112
+ By default, the `dw files` command automatically detects the source type based on the \<dirPath\>:
113
+ If the path contains a file extension (e.g., 'templates/Translations.xml'), it is treated as a file.
114
+ Otherwise, it is treated as a directory.
115
+ In cases where this detection is incorrect, you can force the type using these flags:
116
+
117
+ - `-ad` `--asDirectory` Forces the command to treat the path as a directory, even if its name contains a dot.
118
+ - `-af` `--asFile` Forces the command to treat the path as a single file, even if it has no extension.
119
+
120
+ #### Examples
121
+
122
+ Exporting single file from current environment to local solution
123
+ > $ dw files templates/Translations.xml ./templates -e
124
+
125
+ Exporting a directory that looks like a file
126
+ > $ dw files templates/templates.v1 ./templates -e -ad
127
+
128
+ Exporting a file that has no extension
129
+ > $ dw files templates/testfile ./templates -e -af
130
+
131
+ ### Swift
132
+ > $ dw swift \<outPath\>
133
+
134
+ The swift command is used to easily get your local environment up to date with the latest swift release. It will override all existing directories and content in those, which can then be adjusted in your source control afterwards. It has multiple options to specify which tag or branch to pull;
135
+ - `-t` `--tag <tag>` The tag/branch/release to pull
136
+ - `-l` `--list` Will list all the release versions
137
+ - `-n` `--nightly` Will pull #HEAD, as default is latest release
138
+ - `--force` Used if \<outPath\> is not an empty folder, to override all the content
139
+
140
+ #### Examples
141
+ Getting all the available releases
142
+ > $ dw swift -l
143
+
144
+ Pulling and overriding local solution with latest nightly build
145
+ > $ cd DynamicWebSolution/Swift
146
+ >
147
+ > $ dw swift . -n --force
148
+
149
+ ### Query
150
+ > $ dw query \<query\>
151
+
152
+ The query command will fire any query towards the admin Api with the given query parameters. This means any query parameter that's necessary for the given query, is required as an option in this command. It's also possible to list which parameters is necessary for the given query through the options;
153
+ - `-l` `--list` Will list all the properties for the given \<query\>
154
+ - `-i` `--interactive` Will perform the \<query\> but without any parameters, as they will be asked for one by one in interactive mode
155
+ - `--<queryParam>` Any parameter the query needs will be sent by '--key value'
156
+
157
+ #### Examples
158
+ Getting all properties for a query
159
+ > $ dw query FileByName -l
160
+
161
+ Getting file information on a specific file by name
162
+ > $ dw query FileByName --name DefaultMail.html --directorypath /Templates/Forms/Mail
163
+
164
+ ### Command
165
+ > $ dw command \<command\>
166
+
167
+ Using command will, like query, fire any given command in the solution. It works like query, given the query parameters necessary, however if a `DataModel` is required for the command, it is given in a json-format, either through a path to a .json file or a literal json-string in the command.
168
+ - `-l` `--list` Lists all the properties for the command, as well as the json model required
169
+ - `--json` Takes a path to a .json file or a literal json, i.e --json '{ abc: "123" }'
170
+
171
+ #### Examples
172
+ Creating a copy of a page using a json-string
173
+ > $ dw command PageCopy --json '{ "model": { "SourcePageId": 1189, "DestinationParentPageId": 1129 } }'
174
+
175
+ Removing a page using a json file
176
+ > $ dw command PageMove --json ./PageMove.json
177
+
178
+ Where PageMove.json contains
179
+ ```json
180
+ { "model": { "SourcePageId": 1383, "DestinationParentPageId": 1376 } }
181
+ ```
182
+
183
+ Deleting a page
184
+ > $ dw command PageDelete --json '{ "id": "1383" }'
185
+
186
+ ### Install
187
+ > $ dw install \<filePath\>
188
+
189
+ Install is somewhat of a shorthand for a few commands. It will upload and install a given .dll or .nupkg addin to your current environment.
190
+
191
+ It's meant to be used to easily apply custom dlls to a given project, it being local or otherwise, so after having a dotnet library built locally, this command can be run, pointing to the built .dll and it will handle the rest with all the addin installation, and it will be available in the DynamicWeb solution as soon as the command finishes.
192
+
193
+ #### Examples
194
+ > $ dw install ./bin/Release/net10.0/CustomProject.dll
195
+
196
+ ### Database
197
+ > $ dw database \<outPath\>
198
+
199
+ This command is used for various actions towards your current environments database.
200
+ - `-e` `--export` Exports your current environments database to a .bacpac file at \<outPath\>
201
+
202
+ #### Examples
203
+ > $ dw database -e ./backup
204
+
205
+ ### Config
206
+ > $ dw config
207
+
208
+ Config is used to manage the .dwc file through the CLI, given any prop it will create the key/value with the path to it.
209
+ - `--<property>` The path and name of the property to set
210
+
211
+ #### Examples
212
+ Changing the host for the dev environment
213
+ > $ dw config --env.dev.host localhost:6001
214
+
215
+ ## Using Git Bash
216
+ If you're using Git Bash, you may encounter issues with path conversion that can interfere with relative paths used in commands.
217
+
218
+ ### Path Conversion Issues
219
+ Git Bash automatically converts relative paths to absolute paths, which can cause problems.
220
+ You'll see a warning message if the conversion setting is not disabled:
221
+
222
+ "You appear to have path conversion turned on in your shell.
223
+ If you are using relative paths, this may interfere.
224
+ Please see https://doc.dynamicweb.dev/documentation/fundamentals/code/CLI.html for more information."
225
+
226
+ ### Solution
227
+ To resolve this issue, disable path conversion by setting the `MSYS_NO_PATHCONV` environment variable (current session only):
228
+
229
+ > $ export MSYS_NO_PATHCONV=1
230
+
231
+ #### Examples
232
+
233
+ > $ export MSYS_NO_PATHCONV=1
234
+ > $ dw files -iro ./ /TestFolder --host \<host\> --apiKey \<apiKey\>
235
+
236
+ ### Alternative Solutions
237
+ If you prefer not to disable path conversion globally, you can:
238
+
239
+ 1. Prefix relative paths with `./` instead of just `/` to prevent conversion for specific commands.
240
+ 2. Use PowerShell or CMD instead of Git Bash.
241
+
242
+ #### Examples
243
+
244
+ > $ dw files -iro ./ ./TestFolder --host \<host\> --apiKey \<apiKey\>