contensis-cli 1.6.1-beta.2 → 1.6.1-beta.20
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/dist/index.js +58301 -11
- package/dist/index.js.map +4 -4
- package/dist/shell.js +58040 -52
- package/dist/shell.js.map +4 -4
- package/esbuild.config.js +8 -13
- package/package.json +3 -2
- package/src/commands/create.ts +48 -0
- package/src/commands/dev.ts +12 -2
- package/src/commands/globalOptions.ts +5 -3
- package/src/commands/import.ts +46 -5
- package/src/commands/push.ts +8 -1
- package/src/commands/set.ts +69 -1
- package/src/factories/RequestHandlerFactory.ts +19 -8
- package/src/localisation/en-GB.ts +22 -4
- package/src/mappers/DevRequests-to-RequestHanderCliArgs.ts +25 -17
- package/src/models/CliService.d.ts +5 -1
- package/src/providers/GitHubCliModuleProvider.ts +8 -8
- package/src/providers/HttpProvider.ts +2 -2
- package/src/providers/file-provider.ts +3 -0
- package/src/services/ContensisCliService.ts +265 -23
- package/src/services/ContensisDevService.ts +99 -35
- package/src/shell.ts +7 -1
- package/src/util/console.printer.ts +52 -0
- package/src/util/logger.ts +3 -4
- package/src/util/os.ts +5 -3
- package/src/version.ts +1 -1
- package/dist/commands/connect.js +0 -44
- package/dist/commands/connect.js.map +0 -7
- package/dist/commands/copy.js +0 -78
- package/dist/commands/copy.js.map +0 -7
- package/dist/commands/create.js +0 -170
- package/dist/commands/create.js.map +0 -7
- package/dist/commands/dev.js +0 -78
- package/dist/commands/dev.js.map +0 -7
- package/dist/commands/diff.js +0 -57
- package/dist/commands/diff.js.map +0 -7
- package/dist/commands/execute.js +0 -103
- package/dist/commands/execute.js.map +0 -7
- package/dist/commands/get.js +0 -330
- package/dist/commands/get.js.map +0 -7
- package/dist/commands/globalOptions.js +0 -252
- package/dist/commands/globalOptions.js.map +0 -7
- package/dist/commands/import.js +0 -229
- package/dist/commands/import.js.map +0 -7
- package/dist/commands/index.js +0 -107
- package/dist/commands/index.js.map +0 -7
- package/dist/commands/list.js +0 -195
- package/dist/commands/list.js.map +0 -7
- package/dist/commands/login.js +0 -55
- package/dist/commands/login.js.map +0 -7
- package/dist/commands/push.js +0 -229
- package/dist/commands/push.js.map +0 -7
- package/dist/commands/remove.js +0 -193
- package/dist/commands/remove.js.map +0 -7
- package/dist/commands/set.js +0 -180
- package/dist/commands/set.js.map +0 -7
- package/dist/commands/update.js +0 -70
- package/dist/commands/update.js.map +0 -7
- package/dist/factories/RequestHandlerFactory.js +0 -221
- package/dist/factories/RequestHandlerFactory.js.map +0 -7
- package/dist/localisation/en-GB.js +0 -552
- package/dist/localisation/en-GB.js.map +0 -7
- package/dist/mappers/ContensisCliService-to-RequestHanderSiteConfigYaml.js +0 -56
- package/dist/mappers/ContensisCliService-to-RequestHanderSiteConfigYaml.js.map +0 -7
- package/dist/mappers/DevInit-to-CIWorkflow.js +0 -409
- package/dist/mappers/DevInit-to-CIWorkflow.js.map +0 -7
- package/dist/mappers/DevInit-to-RolePermissions.js +0 -56
- package/dist/mappers/DevInit-to-RolePermissions.js.map +0 -7
- package/dist/mappers/DevRequests-to-RequestHanderCliArgs.js +0 -161
- package/dist/mappers/DevRequests-to-RequestHanderCliArgs.js.map +0 -7
- package/dist/mappers/MixedFileData.js +0 -83
- package/dist/mappers/MixedFileData.js.map +0 -7
- package/dist/models/AppError.d.js +0 -2
- package/dist/models/AppError.d.js.map +0 -7
- package/dist/models/Cache.d.js +0 -2
- package/dist/models/Cache.d.js.map +0 -7
- package/dist/models/CliService.d.js +0 -17
- package/dist/models/CliService.d.js.map +0 -7
- package/dist/models/DevService.d.js +0 -17
- package/dist/models/DevService.d.js.map +0 -7
- package/dist/models/JsModules.d.js +0 -2
- package/dist/models/JsModules.d.js.map +0 -7
- package/dist/providers/CredentialProvider.js +0 -126
- package/dist/providers/CredentialProvider.js.map +0 -7
- package/dist/providers/GitHubCliModuleProvider.js +0 -115
- package/dist/providers/GitHubCliModuleProvider.js.map +0 -7
- package/dist/providers/HttpProvider.js +0 -73
- package/dist/providers/HttpProvider.js.map +0 -7
- package/dist/providers/ManifestProvider.js +0 -50
- package/dist/providers/ManifestProvider.js.map +0 -7
- package/dist/providers/SessionCacheProvider.js +0 -132
- package/dist/providers/SessionCacheProvider.js.map +0 -7
- package/dist/providers/file-provider.js +0 -174
- package/dist/providers/file-provider.js.map +0 -7
- package/dist/services/ContensisAuthService.js +0 -88
- package/dist/services/ContensisAuthService.js.map +0 -7
- package/dist/services/ContensisCliService.js +0 -2598
- package/dist/services/ContensisCliService.js.map +0 -7
- package/dist/services/ContensisDevService.js +0 -387
- package/dist/services/ContensisDevService.js.map +0 -7
- package/dist/services/ContensisRoleService.js +0 -112
- package/dist/services/ContensisRoleService.js.map +0 -7
- package/dist/util/api-ids.js +0 -110
- package/dist/util/api-ids.js.map +0 -7
- package/dist/util/assert.js +0 -62
- package/dist/util/assert.js.map +0 -7
- package/dist/util/console.printer.js +0 -425
- package/dist/util/console.printer.js.map +0 -7
- package/dist/util/csv.formatter.js +0 -118
- package/dist/util/csv.formatter.js.map +0 -7
- package/dist/util/debug.js +0 -29
- package/dist/util/debug.js.map +0 -7
- package/dist/util/diff.js +0 -118
- package/dist/util/diff.js.map +0 -7
- package/dist/util/dotenv.js +0 -56
- package/dist/util/dotenv.js.map +0 -7
- package/dist/util/error.js +0 -36
- package/dist/util/error.js.map +0 -7
- package/dist/util/fetch.js +0 -69
- package/dist/util/fetch.js.map +0 -7
- package/dist/util/find.js +0 -39
- package/dist/util/find.js.map +0 -7
- package/dist/util/git.js +0 -145
- package/dist/util/git.js.map +0 -7
- package/dist/util/gitignore.js +0 -61
- package/dist/util/gitignore.js.map +0 -7
- package/dist/util/html.formatter.js +0 -70
- package/dist/util/html.formatter.js.map +0 -7
- package/dist/util/index.js +0 -68
- package/dist/util/index.js.map +0 -7
- package/dist/util/json.formatter.js +0 -66
- package/dist/util/json.formatter.js.map +0 -7
- package/dist/util/logger.js +0 -304
- package/dist/util/logger.js.map +0 -7
- package/dist/util/os.js +0 -46
- package/dist/util/os.js.map +0 -7
- package/dist/util/timers.js +0 -49
- package/dist/util/timers.js.map +0 -7
- package/dist/util/xml.formatter.js +0 -62
- package/dist/util/xml.formatter.js.map +0 -7
- package/dist/util/yaml.js +0 -44
- package/dist/util/yaml.js.map +0 -7
- package/dist/version.js +0 -29
- package/dist/version.js.map +0 -7
package/esbuild.config.js
CHANGED
|
@@ -5,7 +5,6 @@ const { globPlugin } = require('esbuild-plugin-glob');
|
|
|
5
5
|
const { nodeExternalsPlugin } = require('esbuild-node-externals');
|
|
6
6
|
const { replaceTscAliasPaths } = require('tsc-alias');
|
|
7
7
|
|
|
8
|
-
// const watch = !!process.argv.includes('--watch');
|
|
9
8
|
const completed = `${chalk.green('[contensis-cli]')} Build successful 👍\n`;
|
|
10
9
|
|
|
11
10
|
console.time(completed);
|
|
@@ -16,9 +15,9 @@ rimraf('./dist').then(() => {
|
|
|
16
15
|
console.time(' - esbuild complete');
|
|
17
16
|
esbuild
|
|
18
17
|
.build({
|
|
19
|
-
entryPoints: ['src
|
|
18
|
+
entryPoints: ['src/index.ts', 'src/shell.ts'],
|
|
20
19
|
outdir: 'dist',
|
|
21
|
-
bundle:
|
|
20
|
+
bundle: true,
|
|
22
21
|
minify: false,
|
|
23
22
|
platform: 'node',
|
|
24
23
|
format: 'cjs',
|
|
@@ -26,16 +25,12 @@ rimraf('./dist').then(() => {
|
|
|
26
25
|
// needs to be node12 to transform dynamic imports into requires
|
|
27
26
|
// so the bundles are compatible with the pkg exe builds
|
|
28
27
|
target: 'node12',
|
|
29
|
-
plugins: [globPlugin(), nodeExternalsPlugin(
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
// 'esbuild watch build succeeded, waiting for changes...'
|
|
36
|
-
// );
|
|
37
|
-
// },
|
|
38
|
-
// },
|
|
28
|
+
plugins: [globPlugin(), nodeExternalsPlugin({
|
|
29
|
+
allowList: [/^@inquirer\//],
|
|
30
|
+
dependencies: true,
|
|
31
|
+
forceExternalList: ['enterprise-fetch']
|
|
32
|
+
// forceExternalList: ['keytar', '@action-validator/core', 'figlet', 'node-fetch', 'enterprise-fetch']
|
|
33
|
+
})],
|
|
39
34
|
})
|
|
40
35
|
.then(() => {
|
|
41
36
|
console.timeEnd(' - esbuild complete');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "contensis-cli",
|
|
3
|
-
"version": "1.6.1-beta.
|
|
3
|
+
"version": "1.6.1-beta.20",
|
|
4
4
|
"description": "A fully featured Contensis command line interface with a shell UI provides simple and intuitive ways to manage or profile your content in any NodeJS terminal.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
"license": "ISC",
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@action-validator/core": "^0.6.0",
|
|
31
|
+
"@inquirer/prompts": "^8.2.0",
|
|
31
32
|
"adm-zip": "^0.5.16",
|
|
32
33
|
"app-root-path": "^3.1.0",
|
|
33
34
|
"chalk": "^4.1.2",
|
|
@@ -42,7 +43,7 @@
|
|
|
42
43
|
"inquirer-command-prompt": "^0.1.0",
|
|
43
44
|
"keytar": "^7.9.0",
|
|
44
45
|
"lodash": "^4.17.21",
|
|
45
|
-
"migratortron": "^1.0.0-beta.
|
|
46
|
+
"migratortron": "^1.0.0-beta.86",
|
|
46
47
|
"nanospinner": "^1.2.0",
|
|
47
48
|
"node-fetch": "^2.6.7",
|
|
48
49
|
"parse-git-config": "^3.0.0",
|
package/src/commands/create.ts
CHANGED
|
@@ -71,6 +71,54 @@ Example call:
|
|
|
71
71
|
);
|
|
72
72
|
});
|
|
73
73
|
|
|
74
|
+
create
|
|
75
|
+
.command('node')
|
|
76
|
+
.description('create a new site view node')
|
|
77
|
+
.argument('<"node path or id">', 'the path or id of the node to create')
|
|
78
|
+
.argument(
|
|
79
|
+
'["display name"]',
|
|
80
|
+
'provide a separate display name for the node (optional)'
|
|
81
|
+
)
|
|
82
|
+
.argument(
|
|
83
|
+
'["slug"]',
|
|
84
|
+
'provide a slug for the node (defaults to slug from provided node path)'
|
|
85
|
+
)
|
|
86
|
+
.option(
|
|
87
|
+
'--include-in-menu',
|
|
88
|
+
'set include in menu flag on the created node',
|
|
89
|
+
false
|
|
90
|
+
)
|
|
91
|
+
.option(
|
|
92
|
+
'--language <language>',
|
|
93
|
+
'language of the node to create (defaults to current project primary language)'
|
|
94
|
+
)
|
|
95
|
+
.option('--entry-id <entryId>', 'attach an entry to the node')
|
|
96
|
+
.usage(
|
|
97
|
+
'<"node path or id"> ["display name"] (both args in "double quotes")'
|
|
98
|
+
)
|
|
99
|
+
.addHelpText(
|
|
100
|
+
'after',
|
|
101
|
+
`
|
|
102
|
+
Example call:
|
|
103
|
+
> create node /test "Test Node" --include-in-menu\n`
|
|
104
|
+
)
|
|
105
|
+
.action(
|
|
106
|
+
async (
|
|
107
|
+
pathOrId: string,
|
|
108
|
+
displayName: string,
|
|
109
|
+
slug: string,
|
|
110
|
+
opts: any
|
|
111
|
+
) => {
|
|
112
|
+
await cliCommand(['create', 'node', pathOrId], opts).CreateOrUpdateNode(
|
|
113
|
+
pathOrId,
|
|
114
|
+
opts,
|
|
115
|
+
displayName,
|
|
116
|
+
slug,
|
|
117
|
+
opts.language
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
);
|
|
121
|
+
|
|
74
122
|
create
|
|
75
123
|
.command('role')
|
|
76
124
|
.description('create a new role')
|
package/src/commands/dev.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Command } from 'commander';
|
|
1
|
+
import { Command, Option } from 'commander';
|
|
2
2
|
import { devCommand } from '~/services/ContensisDevService';
|
|
3
3
|
|
|
4
4
|
export const makeDevCommand = () => {
|
|
@@ -58,6 +58,16 @@ Example call:
|
|
|
58
58
|
'--release <release>',
|
|
59
59
|
'launch a specific release version of the request handler'
|
|
60
60
|
)
|
|
61
|
+
.option(
|
|
62
|
+
'--override [override...]',
|
|
63
|
+
'override configurations for other blocks'
|
|
64
|
+
)
|
|
65
|
+
.addOption(
|
|
66
|
+
new Option(
|
|
67
|
+
'-ll --log-level <logLevel>',
|
|
68
|
+
'set the request handler logging level'
|
|
69
|
+
).choices(['debug', 'information', 'warning', 'error', 'none'])
|
|
70
|
+
)
|
|
61
71
|
.usage('[block-id] [local-uri]')
|
|
62
72
|
.addHelpText(
|
|
63
73
|
'after',
|
|
@@ -70,7 +80,7 @@ Example call:
|
|
|
70
80
|
await devCommand(
|
|
71
81
|
['dev', 'requests', blockId.join(' ')],
|
|
72
82
|
opts
|
|
73
|
-
).ExecRequestHandler(blockId, opts?.args, opts.release);
|
|
83
|
+
).ExecRequestHandler(blockId, opts?.override, opts?.args, opts.release);
|
|
74
84
|
});
|
|
75
85
|
|
|
76
86
|
return dev;
|
|
@@ -54,11 +54,13 @@ export const mapContensisOpts = (opts: any = {}): MigrateRequest => ({
|
|
|
54
54
|
noPublish: !opts.publish, // arg is inverted automatically from `--no-publish` to `publish: false`
|
|
55
55
|
outputLogs: opts.logLevel,
|
|
56
56
|
stopLevel:
|
|
57
|
-
typeof opts.stopLevel === 'number'
|
|
57
|
+
typeof opts.stopLevel === 'number' // stopLevel is used with `import entries`
|
|
58
58
|
? Number(opts.stopLevel)
|
|
59
|
-
: typeof opts.dependents === 'number'
|
|
59
|
+
: typeof opts.dependents === 'number' // dependents is used with `get entries`
|
|
60
60
|
? Number(opts.dependents)
|
|
61
|
-
:
|
|
61
|
+
: typeof opts.depth === 'number' // depth is used with `import nodes`
|
|
62
|
+
? Number(opts.depth)
|
|
63
|
+
: undefined,
|
|
62
64
|
});
|
|
63
65
|
|
|
64
66
|
/* Output options */
|
package/src/commands/import.ts
CHANGED
|
@@ -36,10 +36,7 @@ export const makeImportCommand = () => {
|
|
|
36
36
|
'-nod --no-defaults',
|
|
37
37
|
'ignore any default entries or nodes attached to content types or fields'
|
|
38
38
|
)
|
|
39
|
-
.option(
|
|
40
|
-
'-nov --no-validations',
|
|
41
|
-
'import fields with validations removed'
|
|
42
|
-
)
|
|
39
|
+
.option('-nov --no-validations', 'import fields with validations removed')
|
|
43
40
|
.option(
|
|
44
41
|
'-preserve --preserve-guids',
|
|
45
42
|
'import any default entries or nodes using the same id as the source'
|
|
@@ -153,7 +150,7 @@ Example call:
|
|
|
153
150
|
'after',
|
|
154
151
|
`
|
|
155
152
|
Example call:
|
|
156
|
-
> import entries --source-
|
|
153
|
+
> import entries --source-alias example-dev --source-project-id microsite --zenql "sys.contentTypeId = blog"
|
|
157
154
|
> import entries --from-file myImportData.json --preserve-guids
|
|
158
155
|
`
|
|
159
156
|
)
|
|
@@ -175,6 +172,12 @@ Example call:
|
|
|
175
172
|
.command('nodes')
|
|
176
173
|
.description('import nodes')
|
|
177
174
|
.argument('[root]', 'import nodes from the specified path e.g. /blog', '/')
|
|
175
|
+
.addOption(
|
|
176
|
+
new Option(
|
|
177
|
+
'-d --depth <depth>',
|
|
178
|
+
'import nodes with children to a specified depth'
|
|
179
|
+
).argParser(parseInt)
|
|
180
|
+
)
|
|
178
181
|
.option(
|
|
179
182
|
'-preserve --preserve-guids',
|
|
180
183
|
'include this flag when you are importing nodes that you have previously exported and wish to update'
|
|
@@ -301,6 +304,44 @@ Example call:
|
|
|
301
304
|
});
|
|
302
305
|
});
|
|
303
306
|
|
|
307
|
+
program
|
|
308
|
+
.command('webhooks')
|
|
309
|
+
.description('import webhooks')
|
|
310
|
+
.argument('[name]', 'import webhooks with this name')
|
|
311
|
+
.option('-i --id <ids...>', 'limit to the supplied webhook id(s)')
|
|
312
|
+
.option('--enabled', 'import enabled webhooks only')
|
|
313
|
+
.option('--disabled', 'import disabled webhooks only')
|
|
314
|
+
.addOption(commit)
|
|
315
|
+
.addOption(
|
|
316
|
+
new Option(
|
|
317
|
+
'-od --output-detail <outputDetail>',
|
|
318
|
+
'how much detail to output from the import'
|
|
319
|
+
)
|
|
320
|
+
.choices(['errors', 'changes', 'all'])
|
|
321
|
+
.default('changes')
|
|
322
|
+
)
|
|
323
|
+
.addHelpText(
|
|
324
|
+
'after',
|
|
325
|
+
`
|
|
326
|
+
Example call:
|
|
327
|
+
> import webhooks --source-cms example-dev --source-project-id microsite
|
|
328
|
+
> import webhooks --from-file myImportData.json
|
|
329
|
+
`
|
|
330
|
+
)
|
|
331
|
+
.action(async (name, opts) => {
|
|
332
|
+
await cliCommand(
|
|
333
|
+
['import', 'webhooks'],
|
|
334
|
+
opts,
|
|
335
|
+
mapContensisOpts({ ...opts, id: opts.ids, search: name })
|
|
336
|
+
).ImportWebhooks({
|
|
337
|
+
commit: opts.commit,
|
|
338
|
+
fromFile: opts.fromFile,
|
|
339
|
+
logOutput: opts.outputDetail,
|
|
340
|
+
enabled: opts.enabled,
|
|
341
|
+
disabled: opts.disabled,
|
|
342
|
+
});
|
|
343
|
+
});
|
|
344
|
+
|
|
304
345
|
return program;
|
|
305
346
|
};
|
|
306
347
|
|
package/src/commands/push.ts
CHANGED
|
@@ -149,6 +149,11 @@ Example call:
|
|
|
149
149
|
'whether to release the pushed block version',
|
|
150
150
|
false
|
|
151
151
|
)
|
|
152
|
+
.option(
|
|
153
|
+
'--make-live',
|
|
154
|
+
'whether to make the pushed block version live immediately',
|
|
155
|
+
false
|
|
156
|
+
)
|
|
152
157
|
.option(
|
|
153
158
|
'-cid --commit-id <commitId>',
|
|
154
159
|
'the id of the source git commit for the supplied image uri'
|
|
@@ -196,6 +201,7 @@ Example call:
|
|
|
196
201
|
|
|
197
202
|
const blockRequest = mapJson(mapSourceVars, {
|
|
198
203
|
release: { $path: 'release', $default: () => false },
|
|
204
|
+
makeLive: { $path: 'makeLive', $default: () => false },
|
|
199
205
|
id: ['blockId'],
|
|
200
206
|
image: () => {
|
|
201
207
|
const lastIndexOfColon = imageUri.lastIndexOf(':');
|
|
@@ -217,7 +223,8 @@ Example call:
|
|
|
217
223
|
repositoryUrl: {
|
|
218
224
|
$path: ['repositoryUrl', 'CI_PROJECT_URL', 'GITHUB_REPOSITORY'],
|
|
219
225
|
$formatting: (url: string, { GITHUB_ACTIONS }) => {
|
|
220
|
-
if (GITHUB_ACTIONS
|
|
226
|
+
if (GITHUB_ACTIONS && !url.startsWith(`https://`))
|
|
227
|
+
url = `https://github.com/${url}`;
|
|
221
228
|
|
|
222
229
|
if (url && !url.endsWith('.git')) return `${url}.git`;
|
|
223
230
|
return url;
|
package/src/commands/set.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Argument, Command } from 'commander';
|
|
1
|
+
import { Argument, Command, Option } from 'commander';
|
|
2
2
|
import { cliCommand } from '~/services/ContensisCliService';
|
|
3
3
|
import { shell } from '~/shell';
|
|
4
4
|
|
|
@@ -10,6 +10,56 @@ export const makeSetCommand = () => {
|
|
|
10
10
|
.showHelpAfterError(true)
|
|
11
11
|
.exitOverride();
|
|
12
12
|
|
|
13
|
+
const node = set.command('node').description('update a site view node');
|
|
14
|
+
|
|
15
|
+
node
|
|
16
|
+
.command('entry')
|
|
17
|
+
.description('assign an entry to a node')
|
|
18
|
+
.argument('<"node path or id">', 'the path or id of the node to update')
|
|
19
|
+
.argument('<entryId>', 'the new entry id to assign to the node')
|
|
20
|
+
.usage('<"node path or id"> <entryId>')
|
|
21
|
+
.addHelpText(
|
|
22
|
+
'after',
|
|
23
|
+
`
|
|
24
|
+
Example call:
|
|
25
|
+
> set node entry /path 1502f64e-e9b1-436b-b62f-e273f639ecb6\n`
|
|
26
|
+
)
|
|
27
|
+
.action(async (nodePathOrId: string, entryId: string, opts) => {
|
|
28
|
+
await cliCommand(['set', 'node', 'entry'], opts).CreateOrUpdateNode(
|
|
29
|
+
nodePathOrId,
|
|
30
|
+
{ entryId }
|
|
31
|
+
);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
node
|
|
35
|
+
.command('renderer')
|
|
36
|
+
.description('assign a renderer to a node')
|
|
37
|
+
.argument('<"node path or id">', 'the path or id of the node to update')
|
|
38
|
+
.argument('<rendererUuid>', 'the renderer uuid to assign to the node')
|
|
39
|
+
.option(
|
|
40
|
+
'--is-partial-match-root',
|
|
41
|
+
'should the renderer be used as the partial match root for the node',
|
|
42
|
+
false
|
|
43
|
+
)
|
|
44
|
+
.usage('<"node path or id"> <rendererUuid>')
|
|
45
|
+
.addHelpText(
|
|
46
|
+
'after',
|
|
47
|
+
`
|
|
48
|
+
Example call:
|
|
49
|
+
> set node renderer /path 1502f64e-e9b1-436b-b62f-e273f639ecb6 --is-partial-match-root\n`
|
|
50
|
+
)
|
|
51
|
+
.action(async (nodePathOrId: string, rendererId: string, opts) => {
|
|
52
|
+
await cliCommand(['set', 'node', 'renderer'], opts).CreateOrUpdateNode(
|
|
53
|
+
nodePathOrId,
|
|
54
|
+
{
|
|
55
|
+
renderer: {
|
|
56
|
+
id: rendererId,
|
|
57
|
+
isPartialMatchRoot: opts.isPartialMatchRoot,
|
|
58
|
+
},
|
|
59
|
+
}
|
|
60
|
+
);
|
|
61
|
+
});
|
|
62
|
+
|
|
13
63
|
const project = set
|
|
14
64
|
.command('project')
|
|
15
65
|
.description('set current working project')
|
|
@@ -178,6 +228,21 @@ Example call:
|
|
|
178
228
|
'--entry-languages [entry-languages...]',
|
|
179
229
|
'the entry languages to add to the role permissions'
|
|
180
230
|
)
|
|
231
|
+
.addOption(
|
|
232
|
+
new Option(
|
|
233
|
+
'--block-actions [block-actions...]',
|
|
234
|
+
'the block actions to add to the role permissions'
|
|
235
|
+
).choices([
|
|
236
|
+
'push',
|
|
237
|
+
'release',
|
|
238
|
+
'manageLive',
|
|
239
|
+
'manualStartStop',
|
|
240
|
+
'markAsBroken',
|
|
241
|
+
'delete',
|
|
242
|
+
'view',
|
|
243
|
+
'*',
|
|
244
|
+
])
|
|
245
|
+
)
|
|
181
246
|
.addHelpText(
|
|
182
247
|
'after',
|
|
183
248
|
`
|
|
@@ -194,6 +259,9 @@ Example call:
|
|
|
194
259
|
actions: opts.entryActions || [],
|
|
195
260
|
languages: opts.entryLanguages || [],
|
|
196
261
|
})),
|
|
262
|
+
blocks: opts.blockActions
|
|
263
|
+
? { actions: opts.blockActions }
|
|
264
|
+
: undefined,
|
|
197
265
|
},
|
|
198
266
|
}
|
|
199
267
|
);
|
|
@@ -6,7 +6,7 @@ import { LogMessages } from '~/localisation/en-GB';
|
|
|
6
6
|
import GitHubCliModuleProvider from '~/providers/GitHubCliModuleProvider';
|
|
7
7
|
|
|
8
8
|
import ManifestProvider from '~/providers/ManifestProvider';
|
|
9
|
-
import { appRootDir,
|
|
9
|
+
import { appRootDir, joinPath, pathExists } from '~/providers/file-provider';
|
|
10
10
|
import { isDebug } from '~/util/debug';
|
|
11
11
|
import { Logger } from '~/util/logger';
|
|
12
12
|
|
|
@@ -117,10 +117,10 @@ export class RequestHandlerFactory {
|
|
|
117
117
|
await new Promise(resolve => setTimeout(resolve, 2000));
|
|
118
118
|
|
|
119
119
|
// keep the method running until we can return
|
|
120
|
-
while (
|
|
121
|
-
if (!isRunning) return;
|
|
120
|
+
while (isRunning) {
|
|
122
121
|
await new Promise(resolve => setTimeout(resolve, 1000));
|
|
123
122
|
}
|
|
123
|
+
return;
|
|
124
124
|
};
|
|
125
125
|
}
|
|
126
126
|
|
|
@@ -146,8 +146,8 @@ export class RequestHandlerFactory {
|
|
|
146
146
|
else
|
|
147
147
|
log.warning(messages.devrequests.install.notFound(moduleInfo.github));
|
|
148
148
|
|
|
149
|
-
|
|
150
|
-
|
|
149
|
+
// checkDir(this.exePath);
|
|
150
|
+
const downloadSpecificRelease = version && release?.tag_name;
|
|
151
151
|
|
|
152
152
|
// Should we download an update?
|
|
153
153
|
if (
|
|
@@ -177,9 +177,12 @@ export class RequestHandlerFactory {
|
|
|
177
177
|
path: downloadPath,
|
|
178
178
|
// Map NodeJS os platform to release asset name
|
|
179
179
|
platforms: [
|
|
180
|
-
['win32', 'win-
|
|
181
|
-
['
|
|
182
|
-
['
|
|
180
|
+
['win32', 'arm64', 'win-arm64'],
|
|
181
|
+
['win32', 'x64', 'win-x64'],
|
|
182
|
+
['darwin', 'arm64', 'osx-arm64'],
|
|
183
|
+
['darwin', 'x64', 'osx-x64'],
|
|
184
|
+
['linux', 'arm64', 'linux-arm64'],
|
|
185
|
+
['linux', 'x64', 'linux-x64'],
|
|
183
186
|
],
|
|
184
187
|
});
|
|
185
188
|
} catch (ex: any) {
|
|
@@ -238,6 +241,14 @@ export class RequestHandlerFactory {
|
|
|
238
241
|
|
|
239
242
|
// TODO: clean up user folder by deleting old version(s)}
|
|
240
243
|
}
|
|
244
|
+
} else if (moduleInfo.version) {
|
|
245
|
+
// Validate the installed version exists
|
|
246
|
+
if (!pathExists(this.exePath)) {
|
|
247
|
+
// If not, set the version to force re-download and recreate
|
|
248
|
+
Logger.warning(messages.devrequests.missingBinary(moduleInfo.version));
|
|
249
|
+
this.version = moduleInfo.version;
|
|
250
|
+
await this.Create();
|
|
251
|
+
}
|
|
241
252
|
}
|
|
242
253
|
}
|
|
243
254
|
}
|
|
@@ -188,6 +188,14 @@ export const LogMessages = {
|
|
|
188
188
|
depth ? ` to a depth of ${depth}` : ``
|
|
189
189
|
}\n`,
|
|
190
190
|
noChange: (env: string) => `[${env}] No changes to be made`,
|
|
191
|
+
setPayload: () => `Updating node with details\n`,
|
|
192
|
+
set: (env: string) => `[${env}] Succesfully updated node\n`,
|
|
193
|
+
failedSet: (env: string, name?: string) =>
|
|
194
|
+
`[${env}] Unable to update node ${Logger.highlightText(name)}`,
|
|
195
|
+
created: (env: string, name: string) =>
|
|
196
|
+
`[${env}] Created node ${Logger.highlightText(name)}\n`,
|
|
197
|
+
failedCreate: (env: string, name?: string) =>
|
|
198
|
+
`[${env}] Unable to create node ${Logger.highlightText(name)}`,
|
|
191
199
|
},
|
|
192
200
|
contenttypes: {
|
|
193
201
|
list: (projectId: string) =>
|
|
@@ -521,12 +529,17 @@ export const LogMessages = {
|
|
|
521
529
|
list: (env: string) => `[${env}] Webhook subscriptions:`,
|
|
522
530
|
noList: (env: string) => `[${env}] Cannot retrieve webhook subscriptions`,
|
|
523
531
|
noneExist: () => `No webhook subscriptions exist`,
|
|
532
|
+
imported: (env: string, commit: boolean, webhooks: number) =>
|
|
533
|
+
LogMessages.migrate.imported(env, commit, { webhook: webhooks }),
|
|
534
|
+
noChange: (env: string) => `[${env}] No changes to be made`,
|
|
524
535
|
created: (env: string, name: string) =>
|
|
525
536
|
`[${env}] Created Webhook subscription ${Logger.highlightText(name)}`,
|
|
526
|
-
failedCreate: (env: string, name
|
|
527
|
-
`[${env}] Unable to create
|
|
528
|
-
|
|
529
|
-
|
|
537
|
+
failedCreate: (env: string, name?: string) =>
|
|
538
|
+
`[${env}] Unable to create ${name ? `webhook ${Logger.highlightText(name)}` : 'webhooks'}`,
|
|
539
|
+
// failedCreate: (env: string, name: string) =>
|
|
540
|
+
// `[${env}] Unable to create Webhook subscription ${Logger.highlightText(
|
|
541
|
+
// name
|
|
542
|
+
// )}`,
|
|
530
543
|
deleted: (env: string, id: string) =>
|
|
531
544
|
`[${env}] Deleted Webhook subscription ${Logger.highlightText(id)}`,
|
|
532
545
|
failedDelete: (env: string, id: string) =>
|
|
@@ -707,11 +720,16 @@ export const LogMessages = {
|
|
|
707
720
|
launch: () => `Launching request handler for local development`,
|
|
708
721
|
overrideBlock: () => `Which block will you be running?`,
|
|
709
722
|
overrideUri: () => `How to access your development site`,
|
|
723
|
+
overrideBlocks: () => `Which blocks will you be overriding?`,
|
|
724
|
+
overrideBranch: (blockId: string) =>
|
|
725
|
+
`Which branch would you like ${blockId} to target?`,
|
|
710
726
|
spawn: () =>
|
|
711
727
|
`If you see a firewall popup requesting network access, it is safe to approve`,
|
|
712
728
|
exited: (code: number | null) =>
|
|
713
729
|
`Request handler exited with code ${code}\n`,
|
|
714
730
|
errored: (error: Error) =>
|
|
715
731
|
`Could not launch request handler due to error \n${error}`,
|
|
732
|
+
missingBinary: (version: string) =>
|
|
733
|
+
`Could not locate request handler module ${version}, attempting to reinstall`,
|
|
716
734
|
},
|
|
717
735
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ContensisMigrationService } from 'migratortron';
|
|
1
|
+
import { Block, ContensisMigrationService } from 'migratortron';
|
|
2
2
|
import PQueue from 'p-queue';
|
|
3
3
|
import ContensisCli from '~/services/ContensisCliService';
|
|
4
4
|
|
|
@@ -43,11 +43,14 @@ interface ISiteConfigYaml {
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
class RequestHandlerArgs {
|
|
46
|
-
private cli;
|
|
47
46
|
args?: string[];
|
|
48
47
|
siteConfig?: ISiteConfigYaml;
|
|
49
48
|
|
|
50
|
-
constructor(
|
|
49
|
+
constructor(
|
|
50
|
+
public blocks: Block[],
|
|
51
|
+
public blockBranches: Map<string, string>,
|
|
52
|
+
private cli: ContensisCli
|
|
53
|
+
) {
|
|
51
54
|
this.cli = cli;
|
|
52
55
|
}
|
|
53
56
|
|
|
@@ -59,7 +62,6 @@ class RequestHandlerArgs {
|
|
|
59
62
|
|
|
60
63
|
buildSiteConfig = async () => {
|
|
61
64
|
const { currentEnv, currentProject, env, log, messages, urls } = this.cli;
|
|
62
|
-
const contensis = await this.cli.ConnectContensis();
|
|
63
65
|
|
|
64
66
|
const siteConfig: ISiteConfigYaml = {
|
|
65
67
|
alias: currentEnv,
|
|
@@ -73,28 +75,31 @@ class RequestHandlerArgs {
|
|
|
73
75
|
renderers: [],
|
|
74
76
|
};
|
|
75
77
|
|
|
76
|
-
const
|
|
77
|
-
const [err, blocksRaw] = await contensis.blocks.GetBlocks();
|
|
78
|
-
if (err)
|
|
79
|
-
log.error(messages.blocks.noList(currentEnv, env.currentProject));
|
|
80
|
-
|
|
81
|
-
// const blocksRaw = await cli.PrintBlocks();
|
|
82
|
-
|
|
78
|
+
const getBlockVersions = async (contensis: ContensisMigrationService) => {
|
|
83
79
|
const blocks: BlockJson[] = [];
|
|
84
80
|
const queue = new PQueue({ concurrency: 4 });
|
|
85
|
-
for (const block of
|
|
81
|
+
for (const block of this.blocks || []) {
|
|
86
82
|
queue.add(async () => {
|
|
87
83
|
// Retrieve block version
|
|
84
|
+
const branch =
|
|
85
|
+
// If we've set an override branch
|
|
86
|
+
this.blockBranches.get(block.id) ||
|
|
87
|
+
// If the block has no master/main branch, use the first branch
|
|
88
|
+
!block.branches.find(br => ['master', 'main'].includes(br.id))
|
|
89
|
+
? block.branches[0]?.id
|
|
90
|
+
: // Else use default for Contensis to fetch master or main
|
|
91
|
+
'default';
|
|
92
|
+
|
|
88
93
|
const [err, versions] = await contensis.blocks.GetBlockVersions(
|
|
89
94
|
block.id,
|
|
90
|
-
|
|
95
|
+
branch,
|
|
91
96
|
'latest'
|
|
92
97
|
);
|
|
93
98
|
if (err || versions?.length === 0)
|
|
94
99
|
log.warning(
|
|
95
100
|
messages.blocks.noGet(
|
|
96
101
|
block.id,
|
|
97
|
-
|
|
102
|
+
branch,
|
|
98
103
|
'latest',
|
|
99
104
|
currentEnv,
|
|
100
105
|
env.currentProject
|
|
@@ -118,10 +123,10 @@ class RequestHandlerArgs {
|
|
|
118
123
|
return blocks;
|
|
119
124
|
};
|
|
120
125
|
|
|
121
|
-
if (contensis) {
|
|
126
|
+
if (this.cli.contensis) {
|
|
122
127
|
const [blocks, renderers] = await Promise.all([
|
|
123
|
-
|
|
124
|
-
contensis.renderers.GetRenderers(),
|
|
128
|
+
getBlockVersions(this.cli.contensis),
|
|
129
|
+
this.cli.contensis.renderers.GetRenderers(),
|
|
125
130
|
]);
|
|
126
131
|
|
|
127
132
|
siteConfig.blocks = blocks;
|
|
@@ -174,6 +179,9 @@ class RequestHandlerArgs {
|
|
|
174
179
|
args.push('--password', client.password);
|
|
175
180
|
}
|
|
176
181
|
|
|
182
|
+
if (cli.logLevel && !args.find(a => a === '--log-level'))
|
|
183
|
+
args.push('--log-level', cli.logLevel);
|
|
184
|
+
|
|
177
185
|
return args;
|
|
178
186
|
};
|
|
179
187
|
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import ContensisCli from '~/services/ContensisCliService';
|
|
2
|
+
|
|
1
3
|
export type CliUrls =
|
|
2
4
|
| {
|
|
3
5
|
api: string;
|
|
@@ -33,7 +35,9 @@ export interface IImportOptions {
|
|
|
33
35
|
sourceProjectId?: string;
|
|
34
36
|
}
|
|
35
37
|
|
|
36
|
-
export type OutputOptionsConstructorArg =
|
|
38
|
+
export type OutputOptionsConstructorArg = {
|
|
39
|
+
logLevel?: ContensisCli['logLevel'];
|
|
40
|
+
} & OutputOptions &
|
|
37
41
|
IConnectOptions &
|
|
38
42
|
IImportOptions;
|
|
39
43
|
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
removeFile,
|
|
11
11
|
} from './file-provider';
|
|
12
12
|
import { doRetry } from '~/util/fetch';
|
|
13
|
+
import { isWindows } from '~/util/os';
|
|
13
14
|
|
|
14
15
|
type GitHubApiRelease =
|
|
15
16
|
Endpoints['GET /repos/{owner}/{repo}/releases/latest']['response']['data'];
|
|
@@ -85,17 +86,16 @@ class GitHubCliModuleProvider {
|
|
|
85
86
|
cmd: string;
|
|
86
87
|
path: string;
|
|
87
88
|
unzip?: boolean;
|
|
88
|
-
platforms: [NodeJS.Platform, string][];
|
|
89
|
+
platforms: [NodeJS.Platform, NodeJS.Architecture, string][];
|
|
89
90
|
}
|
|
90
91
|
) {
|
|
91
92
|
// find os-specific asset
|
|
92
|
-
const platform = platforms.find(
|
|
93
|
-
os.platform()
|
|
94
|
-
|
|
95
|
-
];
|
|
93
|
+
const platform = platforms.find(
|
|
94
|
+
p => p[0] === os.platform() && p[1] === os.arch()
|
|
95
|
+
) || [os.platform(), os.arch(), `${os.platform()}-${os.arch()}`];
|
|
96
96
|
|
|
97
97
|
const asset = release.assets.find(r =>
|
|
98
|
-
r.name.toLowerCase().includes(platform[
|
|
98
|
+
r.name.toLowerCase().includes(platform[2])
|
|
99
99
|
);
|
|
100
100
|
|
|
101
101
|
// download asset
|
|
@@ -114,12 +114,12 @@ class GitHubCliModuleProvider {
|
|
|
114
114
|
removeFile(filePath);
|
|
115
115
|
}
|
|
116
116
|
|
|
117
|
-
if (
|
|
117
|
+
if (!isWindows()) addExecutePermission(joinPath(path, cmd));
|
|
118
118
|
} else
|
|
119
119
|
throw new Error(
|
|
120
120
|
`no asset found in release ${
|
|
121
121
|
release.tag_name
|
|
122
|
-
} for platform ${os.platform()}\n${release.html_url}`
|
|
122
|
+
} for platform ${os.platform()} and architecture ${os.arch()}\n${release.html_url}`
|
|
123
123
|
);
|
|
124
124
|
}
|
|
125
125
|
}
|
|
@@ -2,7 +2,7 @@ import to from 'await-to-js';
|
|
|
2
2
|
import { FetchInit } from 'enterprise-fetch';
|
|
3
3
|
import fs from 'fs';
|
|
4
4
|
import { Readable } from 'stream';
|
|
5
|
-
import {
|
|
5
|
+
import { pipeline } from 'stream/promises';
|
|
6
6
|
|
|
7
7
|
import { isJson, tryParse } from '~/util/assert';
|
|
8
8
|
import { enhancedFetch } from '~/util/fetch';
|
|
@@ -42,7 +42,7 @@ class HttpProvider {
|
|
|
42
42
|
const res = await fetch(url);
|
|
43
43
|
if (res.ok && res.body !== null) {
|
|
44
44
|
const fileStream = fs.createWriteStream(destination, { flags: 'wx' });
|
|
45
|
-
await
|
|
45
|
+
await pipeline(Readable.from(res.body), fileStream);
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
}
|