@knocklabs/cli 0.1.14 → 0.1.16
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 +34 -319
- package/dist/commands/translation/get.js +15 -3
- package/dist/commands/translation/pull.js +18 -4
- package/dist/commands/translation/push.js +2 -1
- package/dist/commands/translation/validate.js +2 -1
- package/dist/lib/api-v1.js +3 -1
- package/dist/lib/helpers/liquid.js +1 -0
- package/dist/lib/marshal/partial/index.js +19 -0
- package/dist/lib/marshal/partial/processor.isomorphic.js +122 -0
- package/dist/lib/marshal/partial/types.js +17 -0
- package/dist/lib/marshal/translation/helpers.js +33 -8
- package/dist/lib/marshal/translation/processor.isomorphic.js +25 -5
- package/dist/lib/marshal/translation/reader.js +56 -5
- package/dist/lib/marshal/translation/types.js +0 -1
- package/dist/lib/marshal/translation/writer.js +21 -6
- package/oclif.manifest.json +25 -1
- package/package.json +11 -13
package/README.md
CHANGED
|
@@ -16,7 +16,7 @@ $ npm install -g @knocklabs/cli
|
|
|
16
16
|
$ knock COMMAND
|
|
17
17
|
running command...
|
|
18
18
|
$ knock (--version)
|
|
19
|
-
@knocklabs/cli/0.1.
|
|
19
|
+
@knocklabs/cli/0.1.16 linux-x64 node-v18.20.3
|
|
20
20
|
$ knock --help [COMMAND]
|
|
21
21
|
USAGE
|
|
22
22
|
$ knock COMMAND
|
|
@@ -31,22 +31,12 @@ USAGE
|
|
|
31
31
|
* [`knock commit get ID`](#knock-commit-get-id)
|
|
32
32
|
* [`knock commit list`](#knock-commit-list)
|
|
33
33
|
* [`knock commit promote`](#knock-commit-promote)
|
|
34
|
-
* [`knock help [
|
|
34
|
+
* [`knock help [COMMAND]`](#knock-help-command)
|
|
35
35
|
* [`knock layout get EMAILLAYOUTKEY`](#knock-layout-get-emaillayoutkey)
|
|
36
36
|
* [`knock layout list`](#knock-layout-list)
|
|
37
37
|
* [`knock layout pull [EMAILLAYOUTKEY]`](#knock-layout-pull-emaillayoutkey)
|
|
38
38
|
* [`knock layout push [EMAILLAYOUTKEY]`](#knock-layout-push-emaillayoutkey)
|
|
39
39
|
* [`knock layout validate [EMAILLAYOUTKEY]`](#knock-layout-validate-emaillayoutkey)
|
|
40
|
-
* [`knock plugins`](#knock-plugins)
|
|
41
|
-
* [`knock plugins:install PLUGIN...`](#knock-pluginsinstall-plugin)
|
|
42
|
-
* [`knock plugins:inspect PLUGIN...`](#knock-pluginsinspect-plugin)
|
|
43
|
-
* [`knock plugins:install PLUGIN...`](#knock-pluginsinstall-plugin-1)
|
|
44
|
-
* [`knock plugins:link PLUGIN`](#knock-pluginslink-plugin)
|
|
45
|
-
* [`knock plugins:uninstall PLUGIN...`](#knock-pluginsuninstall-plugin)
|
|
46
|
-
* [`knock plugins reset`](#knock-plugins-reset)
|
|
47
|
-
* [`knock plugins:uninstall PLUGIN...`](#knock-pluginsuninstall-plugin-1)
|
|
48
|
-
* [`knock plugins:uninstall PLUGIN...`](#knock-pluginsuninstall-plugin-2)
|
|
49
|
-
* [`knock plugins update`](#knock-plugins-update)
|
|
50
40
|
* [`knock translation get TRANSLATIONREF`](#knock-translation-get-translationref)
|
|
51
41
|
* [`knock translation list`](#knock-translation-list)
|
|
52
42
|
* [`knock translation pull [TRANSLATIONREF]`](#knock-translation-pull-translationref)
|
|
@@ -78,7 +68,7 @@ FLAGS
|
|
|
78
68
|
--service-token=<value> (required) The service token to authenticate with.
|
|
79
69
|
```
|
|
80
70
|
|
|
81
|
-
_See code: [src/commands/commit/index.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.
|
|
71
|
+
_See code: [src/commands/commit/index.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.16/src/commands/commit/index.ts)_
|
|
82
72
|
|
|
83
73
|
## `knock commit get ID`
|
|
84
74
|
|
|
@@ -95,7 +85,7 @@ GLOBAL FLAGS
|
|
|
95
85
|
--json Format output as json.
|
|
96
86
|
```
|
|
97
87
|
|
|
98
|
-
_See code: [src/commands/commit/get.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.
|
|
88
|
+
_See code: [src/commands/commit/get.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.16/src/commands/commit/get.ts)_
|
|
99
89
|
|
|
100
90
|
## `knock commit list`
|
|
101
91
|
|
|
@@ -119,7 +109,7 @@ GLOBAL FLAGS
|
|
|
119
109
|
--json Format output as json.
|
|
120
110
|
```
|
|
121
111
|
|
|
122
|
-
_See code: [src/commands/commit/list.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.
|
|
112
|
+
_See code: [src/commands/commit/list.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.16/src/commands/commit/list.ts)_
|
|
123
113
|
|
|
124
114
|
## `knock commit promote`
|
|
125
115
|
|
|
@@ -136,18 +126,18 @@ FLAGS
|
|
|
136
126
|
--to=<value> The destination environment to promote all changes from the preceding environment.
|
|
137
127
|
```
|
|
138
128
|
|
|
139
|
-
_See code: [src/commands/commit/promote.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.
|
|
129
|
+
_See code: [src/commands/commit/promote.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.16/src/commands/commit/promote.ts)_
|
|
140
130
|
|
|
141
|
-
## `knock help [
|
|
131
|
+
## `knock help [COMMAND]`
|
|
142
132
|
|
|
143
133
|
Display help for knock.
|
|
144
134
|
|
|
145
135
|
```
|
|
146
136
|
USAGE
|
|
147
|
-
$ knock help [
|
|
137
|
+
$ knock help [COMMAND...] [-n]
|
|
148
138
|
|
|
149
139
|
ARGUMENTS
|
|
150
|
-
|
|
140
|
+
COMMAND... Command to show help for.
|
|
151
141
|
|
|
152
142
|
FLAGS
|
|
153
143
|
-n, --nested-commands Include all nested commands in the output.
|
|
@@ -156,7 +146,7 @@ DESCRIPTION
|
|
|
156
146
|
Display help for knock.
|
|
157
147
|
```
|
|
158
148
|
|
|
159
|
-
_See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v6.
|
|
149
|
+
_See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v6.2.3/src/commands/help.ts)_
|
|
160
150
|
|
|
161
151
|
## `knock layout get EMAILLAYOUTKEY`
|
|
162
152
|
|
|
@@ -176,7 +166,7 @@ GLOBAL FLAGS
|
|
|
176
166
|
--json Format output as json.
|
|
177
167
|
```
|
|
178
168
|
|
|
179
|
-
_See code: [src/commands/layout/get.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.
|
|
169
|
+
_See code: [src/commands/layout/get.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.16/src/commands/layout/get.ts)_
|
|
180
170
|
|
|
181
171
|
## `knock layout list`
|
|
182
172
|
|
|
@@ -199,7 +189,7 @@ GLOBAL FLAGS
|
|
|
199
189
|
--json Format output as json.
|
|
200
190
|
```
|
|
201
191
|
|
|
202
|
-
_See code: [src/commands/layout/list.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.
|
|
192
|
+
_See code: [src/commands/layout/list.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.16/src/commands/layout/list.ts)_
|
|
203
193
|
|
|
204
194
|
## `knock layout pull [EMAILLAYOUTKEY]`
|
|
205
195
|
|
|
@@ -219,7 +209,7 @@ FLAGS
|
|
|
219
209
|
--service-token=<value> (required) The service token to authenticate with.
|
|
220
210
|
```
|
|
221
211
|
|
|
222
|
-
_See code: [src/commands/layout/pull.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.
|
|
212
|
+
_See code: [src/commands/layout/pull.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.16/src/commands/layout/pull.ts)_
|
|
223
213
|
|
|
224
214
|
## `knock layout push [EMAILLAYOUTKEY]`
|
|
225
215
|
|
|
@@ -241,7 +231,7 @@ FLAGS
|
|
|
241
231
|
--service-token=<value> (required) The service token to authenticate with.
|
|
242
232
|
```
|
|
243
233
|
|
|
244
|
-
_See code: [src/commands/layout/push.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.
|
|
234
|
+
_See code: [src/commands/layout/push.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.16/src/commands/layout/push.ts)_
|
|
245
235
|
|
|
246
236
|
## `knock layout validate [EMAILLAYOUTKEY]`
|
|
247
237
|
|
|
@@ -260,286 +250,7 @@ FLAGS
|
|
|
260
250
|
--service-token=<value> (required) The service token to authenticate with.
|
|
261
251
|
```
|
|
262
252
|
|
|
263
|
-
_See code: [src/commands/layout/validate.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.
|
|
264
|
-
|
|
265
|
-
## `knock plugins`
|
|
266
|
-
|
|
267
|
-
List installed plugins.
|
|
268
|
-
|
|
269
|
-
```
|
|
270
|
-
USAGE
|
|
271
|
-
$ knock plugins [--json] [--core]
|
|
272
|
-
|
|
273
|
-
FLAGS
|
|
274
|
-
--core Show core plugins.
|
|
275
|
-
|
|
276
|
-
GLOBAL FLAGS
|
|
277
|
-
--json Format output as json.
|
|
278
|
-
|
|
279
|
-
DESCRIPTION
|
|
280
|
-
List installed plugins.
|
|
281
|
-
|
|
282
|
-
EXAMPLES
|
|
283
|
-
$ knock plugins
|
|
284
|
-
```
|
|
285
|
-
|
|
286
|
-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v4.3.3/src/commands/plugins/index.ts)_
|
|
287
|
-
|
|
288
|
-
## `knock plugins:install PLUGIN...`
|
|
289
|
-
|
|
290
|
-
Installs a plugin into the CLI.
|
|
291
|
-
|
|
292
|
-
```
|
|
293
|
-
USAGE
|
|
294
|
-
$ knock plugins add plugins:install PLUGIN...
|
|
295
|
-
|
|
296
|
-
ARGUMENTS
|
|
297
|
-
PLUGIN... Plugin to install.
|
|
298
|
-
|
|
299
|
-
FLAGS
|
|
300
|
-
-f, --force Run yarn install with force flag.
|
|
301
|
-
-h, --help Show CLI help.
|
|
302
|
-
-s, --silent Silences yarn output.
|
|
303
|
-
-v, --verbose Show verbose yarn output.
|
|
304
|
-
|
|
305
|
-
GLOBAL FLAGS
|
|
306
|
-
--json Format output as json.
|
|
307
|
-
|
|
308
|
-
DESCRIPTION
|
|
309
|
-
Installs a plugin into the CLI.
|
|
310
|
-
Can be installed from npm or a git url.
|
|
311
|
-
|
|
312
|
-
Installation of a user-installed plugin will override a core plugin.
|
|
313
|
-
|
|
314
|
-
e.g. If you have a core plugin that has a 'hello' command, installing a user-installed plugin with a 'hello' command
|
|
315
|
-
will override the core plugin implementation. This is useful if a user needs to update core plugin functionality in
|
|
316
|
-
the CLI without the need to patch and update the whole CLI.
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
ALIASES
|
|
320
|
-
$ knock plugins add
|
|
321
|
-
|
|
322
|
-
EXAMPLES
|
|
323
|
-
$ knock plugins add myplugin
|
|
324
|
-
|
|
325
|
-
$ knock plugins add https://github.com/someuser/someplugin
|
|
326
|
-
|
|
327
|
-
$ knock plugins add someuser/someplugin
|
|
328
|
-
```
|
|
329
|
-
|
|
330
|
-
## `knock plugins:inspect PLUGIN...`
|
|
331
|
-
|
|
332
|
-
Displays installation properties of a plugin.
|
|
333
|
-
|
|
334
|
-
```
|
|
335
|
-
USAGE
|
|
336
|
-
$ knock plugins inspect PLUGIN...
|
|
337
|
-
|
|
338
|
-
ARGUMENTS
|
|
339
|
-
PLUGIN... [default: .] Plugin to inspect.
|
|
340
|
-
|
|
341
|
-
FLAGS
|
|
342
|
-
-h, --help Show CLI help.
|
|
343
|
-
-v, --verbose
|
|
344
|
-
|
|
345
|
-
GLOBAL FLAGS
|
|
346
|
-
--json Format output as json.
|
|
347
|
-
|
|
348
|
-
DESCRIPTION
|
|
349
|
-
Displays installation properties of a plugin.
|
|
350
|
-
|
|
351
|
-
EXAMPLES
|
|
352
|
-
$ knock plugins inspect myplugin
|
|
353
|
-
```
|
|
354
|
-
|
|
355
|
-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v4.3.3/src/commands/plugins/inspect.ts)_
|
|
356
|
-
|
|
357
|
-
## `knock plugins:install PLUGIN...`
|
|
358
|
-
|
|
359
|
-
Installs a plugin into the CLI.
|
|
360
|
-
|
|
361
|
-
```
|
|
362
|
-
USAGE
|
|
363
|
-
$ knock plugins install PLUGIN...
|
|
364
|
-
|
|
365
|
-
ARGUMENTS
|
|
366
|
-
PLUGIN... Plugin to install.
|
|
367
|
-
|
|
368
|
-
FLAGS
|
|
369
|
-
-f, --force Run yarn install with force flag.
|
|
370
|
-
-h, --help Show CLI help.
|
|
371
|
-
-s, --silent Silences yarn output.
|
|
372
|
-
-v, --verbose Show verbose yarn output.
|
|
373
|
-
|
|
374
|
-
GLOBAL FLAGS
|
|
375
|
-
--json Format output as json.
|
|
376
|
-
|
|
377
|
-
DESCRIPTION
|
|
378
|
-
Installs a plugin into the CLI.
|
|
379
|
-
Can be installed from npm or a git url.
|
|
380
|
-
|
|
381
|
-
Installation of a user-installed plugin will override a core plugin.
|
|
382
|
-
|
|
383
|
-
e.g. If you have a core plugin that has a 'hello' command, installing a user-installed plugin with a 'hello' command
|
|
384
|
-
will override the core plugin implementation. This is useful if a user needs to update core plugin functionality in
|
|
385
|
-
the CLI without the need to patch and update the whole CLI.
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
ALIASES
|
|
389
|
-
$ knock plugins add
|
|
390
|
-
|
|
391
|
-
EXAMPLES
|
|
392
|
-
$ knock plugins install myplugin
|
|
393
|
-
|
|
394
|
-
$ knock plugins install https://github.com/someuser/someplugin
|
|
395
|
-
|
|
396
|
-
$ knock plugins install someuser/someplugin
|
|
397
|
-
```
|
|
398
|
-
|
|
399
|
-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v4.3.3/src/commands/plugins/install.ts)_
|
|
400
|
-
|
|
401
|
-
## `knock plugins:link PLUGIN`
|
|
402
|
-
|
|
403
|
-
Links a plugin into the CLI for development.
|
|
404
|
-
|
|
405
|
-
```
|
|
406
|
-
USAGE
|
|
407
|
-
$ knock plugins link PLUGIN
|
|
408
|
-
|
|
409
|
-
ARGUMENTS
|
|
410
|
-
PATH [default: .] path to plugin
|
|
411
|
-
|
|
412
|
-
FLAGS
|
|
413
|
-
-h, --help Show CLI help.
|
|
414
|
-
-v, --verbose
|
|
415
|
-
--[no-]install Install dependencies after linking the plugin.
|
|
416
|
-
|
|
417
|
-
DESCRIPTION
|
|
418
|
-
Links a plugin into the CLI for development.
|
|
419
|
-
Installation of a linked plugin will override a user-installed or core plugin.
|
|
420
|
-
|
|
421
|
-
e.g. If you have a user-installed or core plugin that has a 'hello' command, installing a linked plugin with a 'hello'
|
|
422
|
-
command will override the user-installed or core plugin implementation. This is useful for development work.
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
EXAMPLES
|
|
426
|
-
$ knock plugins link myplugin
|
|
427
|
-
```
|
|
428
|
-
|
|
429
|
-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v4.3.3/src/commands/plugins/link.ts)_
|
|
430
|
-
|
|
431
|
-
## `knock plugins:uninstall PLUGIN...`
|
|
432
|
-
|
|
433
|
-
Removes a plugin from the CLI.
|
|
434
|
-
|
|
435
|
-
```
|
|
436
|
-
USAGE
|
|
437
|
-
$ knock plugins remove plugins:uninstall PLUGIN...
|
|
438
|
-
|
|
439
|
-
ARGUMENTS
|
|
440
|
-
PLUGIN... plugin to uninstall
|
|
441
|
-
|
|
442
|
-
FLAGS
|
|
443
|
-
-h, --help Show CLI help.
|
|
444
|
-
-v, --verbose
|
|
445
|
-
|
|
446
|
-
DESCRIPTION
|
|
447
|
-
Removes a plugin from the CLI.
|
|
448
|
-
|
|
449
|
-
ALIASES
|
|
450
|
-
$ knock plugins unlink
|
|
451
|
-
$ knock plugins remove
|
|
452
|
-
|
|
453
|
-
EXAMPLES
|
|
454
|
-
$ knock plugins remove myplugin
|
|
455
|
-
```
|
|
456
|
-
|
|
457
|
-
## `knock plugins reset`
|
|
458
|
-
|
|
459
|
-
Remove all user-installed and linked plugins.
|
|
460
|
-
|
|
461
|
-
```
|
|
462
|
-
USAGE
|
|
463
|
-
$ knock plugins reset [--hard] [--reinstall]
|
|
464
|
-
|
|
465
|
-
FLAGS
|
|
466
|
-
--hard Delete node_modules and package manager related files in addition to uninstalling plugins.
|
|
467
|
-
--reinstall Reinstall all plugins after uninstalling.
|
|
468
|
-
```
|
|
469
|
-
|
|
470
|
-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v4.3.3/src/commands/plugins/reset.ts)_
|
|
471
|
-
|
|
472
|
-
## `knock plugins:uninstall PLUGIN...`
|
|
473
|
-
|
|
474
|
-
Removes a plugin from the CLI.
|
|
475
|
-
|
|
476
|
-
```
|
|
477
|
-
USAGE
|
|
478
|
-
$ knock plugins uninstall PLUGIN...
|
|
479
|
-
|
|
480
|
-
ARGUMENTS
|
|
481
|
-
PLUGIN... plugin to uninstall
|
|
482
|
-
|
|
483
|
-
FLAGS
|
|
484
|
-
-h, --help Show CLI help.
|
|
485
|
-
-v, --verbose
|
|
486
|
-
|
|
487
|
-
DESCRIPTION
|
|
488
|
-
Removes a plugin from the CLI.
|
|
489
|
-
|
|
490
|
-
ALIASES
|
|
491
|
-
$ knock plugins unlink
|
|
492
|
-
$ knock plugins remove
|
|
493
|
-
|
|
494
|
-
EXAMPLES
|
|
495
|
-
$ knock plugins uninstall myplugin
|
|
496
|
-
```
|
|
497
|
-
|
|
498
|
-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v4.3.3/src/commands/plugins/uninstall.ts)_
|
|
499
|
-
|
|
500
|
-
## `knock plugins:uninstall PLUGIN...`
|
|
501
|
-
|
|
502
|
-
Removes a plugin from the CLI.
|
|
503
|
-
|
|
504
|
-
```
|
|
505
|
-
USAGE
|
|
506
|
-
$ knock plugins unlink plugins:uninstall PLUGIN...
|
|
507
|
-
|
|
508
|
-
ARGUMENTS
|
|
509
|
-
PLUGIN... plugin to uninstall
|
|
510
|
-
|
|
511
|
-
FLAGS
|
|
512
|
-
-h, --help Show CLI help.
|
|
513
|
-
-v, --verbose
|
|
514
|
-
|
|
515
|
-
DESCRIPTION
|
|
516
|
-
Removes a plugin from the CLI.
|
|
517
|
-
|
|
518
|
-
ALIASES
|
|
519
|
-
$ knock plugins unlink
|
|
520
|
-
$ knock plugins remove
|
|
521
|
-
|
|
522
|
-
EXAMPLES
|
|
523
|
-
$ knock plugins unlink myplugin
|
|
524
|
-
```
|
|
525
|
-
|
|
526
|
-
## `knock plugins update`
|
|
527
|
-
|
|
528
|
-
Update installed plugins.
|
|
529
|
-
|
|
530
|
-
```
|
|
531
|
-
USAGE
|
|
532
|
-
$ knock plugins update [-h] [-v]
|
|
533
|
-
|
|
534
|
-
FLAGS
|
|
535
|
-
-h, --help Show CLI help.
|
|
536
|
-
-v, --verbose
|
|
537
|
-
|
|
538
|
-
DESCRIPTION
|
|
539
|
-
Update installed plugins.
|
|
540
|
-
```
|
|
541
|
-
|
|
542
|
-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v4.3.3/src/commands/plugins/update.ts)_
|
|
253
|
+
_See code: [src/commands/layout/validate.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.16/src/commands/layout/validate.ts)_
|
|
543
254
|
|
|
544
255
|
## `knock translation get TRANSLATIONREF`
|
|
545
256
|
|
|
@@ -548,7 +259,7 @@ Display a single translation from an environment.
|
|
|
548
259
|
```
|
|
549
260
|
USAGE
|
|
550
261
|
$ knock translation get TRANSLATIONREF --service-token <value> [--json] [--environment <value>]
|
|
551
|
-
[--hide-uncommitted-changes]
|
|
262
|
+
[--hide-uncommitted-changes] [--format json|po]
|
|
552
263
|
|
|
553
264
|
ARGUMENTS
|
|
554
265
|
TRANSLATIONREF Translation ref is a identifier string that refers to a unique translation.
|
|
@@ -557,6 +268,8 @@ ARGUMENTS
|
|
|
557
268
|
|
|
558
269
|
FLAGS
|
|
559
270
|
--environment=<value> [default: development] The environment to use.
|
|
271
|
+
--format=<option> [default: json] Specify the output format of the returned translations.
|
|
272
|
+
<options: json|po>
|
|
560
273
|
--hide-uncommitted-changes Hide any uncommitted changes.
|
|
561
274
|
--service-token=<value> (required) The service token to authenticate with.
|
|
562
275
|
|
|
@@ -564,7 +277,7 @@ GLOBAL FLAGS
|
|
|
564
277
|
--json Format output as json.
|
|
565
278
|
```
|
|
566
279
|
|
|
567
|
-
_See code: [src/commands/translation/get.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.
|
|
280
|
+
_See code: [src/commands/translation/get.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.16/src/commands/translation/get.ts)_
|
|
568
281
|
|
|
569
282
|
## `knock translation list`
|
|
570
283
|
|
|
@@ -587,7 +300,7 @@ GLOBAL FLAGS
|
|
|
587
300
|
--json Format output as json.
|
|
588
301
|
```
|
|
589
302
|
|
|
590
|
-
_See code: [src/commands/translation/list.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.
|
|
303
|
+
_See code: [src/commands/translation/list.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.16/src/commands/translation/list.ts)_
|
|
591
304
|
|
|
592
305
|
## `knock translation pull [TRANSLATIONREF]`
|
|
593
306
|
|
|
@@ -596,7 +309,7 @@ Pull one or more translations from an environment into a local file system.
|
|
|
596
309
|
```
|
|
597
310
|
USAGE
|
|
598
311
|
$ knock translation pull [TRANSLATIONREF] --service-token <value> [--environment <value>] [--translations-dir
|
|
599
|
-
<value> --all] [--hide-uncommitted-changes] [--force]
|
|
312
|
+
<value> --all] [--hide-uncommitted-changes] [--force] [--format json|po]
|
|
600
313
|
|
|
601
314
|
ARGUMENTS
|
|
602
315
|
TRANSLATIONREF Translation ref is a identifier string that refers to a unique translation.
|
|
@@ -607,12 +320,14 @@ FLAGS
|
|
|
607
320
|
--all Whether to pull all translations from the specified environment.
|
|
608
321
|
--environment=<value> [default: development] The environment to use.
|
|
609
322
|
--force Remove the confirmation prompt.
|
|
323
|
+
--format=<option> [default: json] Specify the output format of the returned translations.
|
|
324
|
+
<options: json|po>
|
|
610
325
|
--hide-uncommitted-changes Hide any uncommitted changes.
|
|
611
326
|
--service-token=<value> (required) The service token to authenticate with.
|
|
612
327
|
--translations-dir=<value> The target directory path to pull all translations into.
|
|
613
328
|
```
|
|
614
329
|
|
|
615
|
-
_See code: [src/commands/translation/pull.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.
|
|
330
|
+
_See code: [src/commands/translation/pull.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.16/src/commands/translation/pull.ts)_
|
|
616
331
|
|
|
617
332
|
## `knock translation push [TRANSLATIONREF]`
|
|
618
333
|
|
|
@@ -639,7 +354,7 @@ FLAGS
|
|
|
639
354
|
--translations-dir=<value> The target directory path to find all translations to push.
|
|
640
355
|
```
|
|
641
356
|
|
|
642
|
-
_See code: [src/commands/translation/push.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.
|
|
357
|
+
_See code: [src/commands/translation/push.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.16/src/commands/translation/push.ts)_
|
|
643
358
|
|
|
644
359
|
## `knock translation validate [TRANSLATIONREF]`
|
|
645
360
|
|
|
@@ -664,7 +379,7 @@ FLAGS
|
|
|
664
379
|
--translations-dir=<value> The target directory path to find all translations to validate.
|
|
665
380
|
```
|
|
666
381
|
|
|
667
|
-
_See code: [src/commands/translation/validate.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.
|
|
382
|
+
_See code: [src/commands/translation/validate.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.16/src/commands/translation/validate.ts)_
|
|
668
383
|
|
|
669
384
|
## `knock whoami`
|
|
670
385
|
|
|
@@ -681,7 +396,7 @@ GLOBAL FLAGS
|
|
|
681
396
|
--json Format output as json.
|
|
682
397
|
```
|
|
683
398
|
|
|
684
|
-
_See code: [src/commands/whoami.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.
|
|
399
|
+
_See code: [src/commands/whoami.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.16/src/commands/whoami.ts)_
|
|
685
400
|
|
|
686
401
|
## `knock workflow activate WORKFLOWKEY`
|
|
687
402
|
|
|
@@ -708,7 +423,7 @@ DESCRIPTION
|
|
|
708
423
|
with `false` in order to deactivate it.
|
|
709
424
|
```
|
|
710
425
|
|
|
711
|
-
_See code: [src/commands/workflow/activate.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.
|
|
426
|
+
_See code: [src/commands/workflow/activate.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.16/src/commands/workflow/activate.ts)_
|
|
712
427
|
|
|
713
428
|
## `knock workflow get WORKFLOWKEY`
|
|
714
429
|
|
|
@@ -728,7 +443,7 @@ GLOBAL FLAGS
|
|
|
728
443
|
--json Format output as json.
|
|
729
444
|
```
|
|
730
445
|
|
|
731
|
-
_See code: [src/commands/workflow/get.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.
|
|
446
|
+
_See code: [src/commands/workflow/get.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.16/src/commands/workflow/get.ts)_
|
|
732
447
|
|
|
733
448
|
## `knock workflow list`
|
|
734
449
|
|
|
@@ -751,7 +466,7 @@ GLOBAL FLAGS
|
|
|
751
466
|
--json Format output as json.
|
|
752
467
|
```
|
|
753
468
|
|
|
754
|
-
_See code: [src/commands/workflow/list.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.
|
|
469
|
+
_See code: [src/commands/workflow/list.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.16/src/commands/workflow/list.ts)_
|
|
755
470
|
|
|
756
471
|
## `knock workflow pull [WORKFLOWKEY]`
|
|
757
472
|
|
|
@@ -771,7 +486,7 @@ FLAGS
|
|
|
771
486
|
--workflows-dir=<value> The target directory path to pull all workflows into.
|
|
772
487
|
```
|
|
773
488
|
|
|
774
|
-
_See code: [src/commands/workflow/pull.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.
|
|
489
|
+
_See code: [src/commands/workflow/pull.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.16/src/commands/workflow/pull.ts)_
|
|
775
490
|
|
|
776
491
|
## `knock workflow push [WORKFLOWKEY]`
|
|
777
492
|
|
|
@@ -792,7 +507,7 @@ FLAGS
|
|
|
792
507
|
--workflows-dir=<value> The target directory path to find all workflows to push.
|
|
793
508
|
```
|
|
794
509
|
|
|
795
|
-
_See code: [src/commands/workflow/push.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.
|
|
510
|
+
_See code: [src/commands/workflow/push.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.16/src/commands/workflow/push.ts)_
|
|
796
511
|
|
|
797
512
|
## `knock workflow run WORKFLOWKEY`
|
|
798
513
|
|
|
@@ -813,7 +528,7 @@ FLAGS
|
|
|
813
528
|
--tenant=<value> A tenant id for the workflow run.
|
|
814
529
|
```
|
|
815
530
|
|
|
816
|
-
_See code: [src/commands/workflow/run.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.
|
|
531
|
+
_See code: [src/commands/workflow/run.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.16/src/commands/workflow/run.ts)_
|
|
817
532
|
|
|
818
533
|
## `knock workflow validate [WORKFLOWKEY]`
|
|
819
534
|
|
|
@@ -832,5 +547,5 @@ FLAGS
|
|
|
832
547
|
--workflows-dir=<value> The target directory path to find all workflows to validate.
|
|
833
548
|
```
|
|
834
549
|
|
|
835
|
-
_See code: [src/commands/workflow/validate.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.
|
|
550
|
+
_See code: [src/commands/workflow/validate.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.16/src/commands/workflow/validate.ts)_
|
|
836
551
|
<!-- commandsstop -->
|
|
@@ -85,7 +85,7 @@ class TranslationGet extends _basecommand.default {
|
|
|
85
85
|
}
|
|
86
86
|
render(translation) {
|
|
87
87
|
const { translationRef } = this.props.args;
|
|
88
|
-
const { environment: env, "hide-uncommitted-changes": commitedOnly } = this.props.flags;
|
|
88
|
+
const { environment: env, "hide-uncommitted-changes": commitedOnly, format } = this.props.flags;
|
|
89
89
|
const qualifier = env === "development" && !commitedOnly ? "(including uncommitted)" : "";
|
|
90
90
|
this.log(`‣ Showing translation \`${translationRef}\` in \`${env}\` environment ${qualifier}\n`);
|
|
91
91
|
/*
|
|
@@ -123,7 +123,11 @@ class TranslationGet extends _basecommand.default {
|
|
|
123
123
|
}
|
|
124
124
|
});
|
|
125
125
|
this.log("");
|
|
126
|
-
|
|
126
|
+
if (format === "json") {
|
|
127
|
+
_core.ux.styledJSON(JSON.parse(translation.content));
|
|
128
|
+
} else {
|
|
129
|
+
_core.ux.log(translation.content);
|
|
130
|
+
}
|
|
127
131
|
}
|
|
128
132
|
}
|
|
129
133
|
_define_property(TranslationGet, "summary", "Display a single translation from an environment.");
|
|
@@ -134,7 +138,15 @@ _define_property(TranslationGet, "flags", {
|
|
|
134
138
|
}),
|
|
135
139
|
"hide-uncommitted-changes": _core.Flags.boolean({
|
|
136
140
|
summary: "Hide any uncommitted changes."
|
|
137
|
-
})
|
|
141
|
+
}),
|
|
142
|
+
format: _core.Flags.option({
|
|
143
|
+
summary: "Specify the output format of the returned translations.",
|
|
144
|
+
options: [
|
|
145
|
+
"json",
|
|
146
|
+
"po"
|
|
147
|
+
],
|
|
148
|
+
default: "json"
|
|
149
|
+
})()
|
|
138
150
|
});
|
|
139
151
|
_define_property(TranslationGet, "args", {
|
|
140
152
|
translationRef: _core.Args.string({
|
|
@@ -102,7 +102,9 @@ class TranslationPull extends _basecommand.default {
|
|
|
102
102
|
if (!input) return;
|
|
103
103
|
}
|
|
104
104
|
const resp = await (0, _request.withSpinner)(()=>this.apiV1.getTranslation(this.props, targetCtx));
|
|
105
|
-
await _translation.writeTranslationFile(targetCtx, resp.data
|
|
105
|
+
await _translation.writeTranslationFile(targetCtx, resp.data, {
|
|
106
|
+
format: flags.format
|
|
107
|
+
});
|
|
106
108
|
const actioned = targetCtx.exists ? "updated" : "created";
|
|
107
109
|
this.log(`‣ Successfully ${actioned} \`${targetCtx.ref}\` at ${targetCtx.abspath}`);
|
|
108
110
|
}
|
|
@@ -120,7 +122,9 @@ class TranslationPull extends _basecommand.default {
|
|
|
120
122
|
localeCode: targetCtx.key
|
|
121
123
|
};
|
|
122
124
|
const translations = await this.listAllTranslations(filters);
|
|
123
|
-
await _translation.writeTranslationFiles(targetCtx, translations
|
|
125
|
+
await _translation.writeTranslationFiles(targetCtx, translations, {
|
|
126
|
+
format: flags.format
|
|
127
|
+
});
|
|
124
128
|
_ux.spinner.stop();
|
|
125
129
|
const actioned = targetCtx.exists ? "updated" : "created";
|
|
126
130
|
this.log(`‣ Successfully ${actioned} the \`${targetCtx.key}\` translations directory at ${targetCtx.abspath}`);
|
|
@@ -135,7 +139,9 @@ class TranslationPull extends _basecommand.default {
|
|
|
135
139
|
// Fetch all translations then write them to the local file system.
|
|
136
140
|
_ux.spinner.start(`‣ Loading`);
|
|
137
141
|
const translations = await this.listAllTranslations();
|
|
138
|
-
await _translation.writeTranslationFiles(targetCtx, translations
|
|
142
|
+
await _translation.writeTranslationFiles(targetCtx, translations, {
|
|
143
|
+
format: flags.format
|
|
144
|
+
});
|
|
139
145
|
_ux.spinner.stop();
|
|
140
146
|
const action = targetCtx.exists ? "updated" : "created";
|
|
141
147
|
this.log(`‣ Successfully ${action} the translations directory at ${targetCtx.abspath}`);
|
|
@@ -182,7 +188,15 @@ _define_property(TranslationPull, "flags", {
|
|
|
182
188
|
}),
|
|
183
189
|
force: _core.Flags.boolean({
|
|
184
190
|
summary: "Remove the confirmation prompt."
|
|
185
|
-
})
|
|
191
|
+
}),
|
|
192
|
+
format: _core.Flags.option({
|
|
193
|
+
summary: "Specify the output format of the returned translations.",
|
|
194
|
+
options: [
|
|
195
|
+
"json",
|
|
196
|
+
"po"
|
|
197
|
+
],
|
|
198
|
+
default: "json"
|
|
199
|
+
})()
|
|
186
200
|
});
|
|
187
201
|
_define_property(TranslationPull, "args", {
|
|
188
202
|
translationRef: _core.Args.string({
|
|
@@ -107,7 +107,8 @@ class TranslationPush extends _basecommand.default {
|
|
|
107
107
|
const resp = await this.apiV1.upsertTranslation(this.props, {
|
|
108
108
|
locale_code: translation.localeCode,
|
|
109
109
|
namespace: translation.namespace,
|
|
110
|
-
content: translation.content
|
|
110
|
+
content: translation.content,
|
|
111
|
+
format: translation.format
|
|
111
112
|
});
|
|
112
113
|
if ((0, _request.isSuccessResp)(resp)) continue;
|
|
113
114
|
const message = (0, _request.formatErrorRespMessage)(resp);
|
|
@@ -106,7 +106,8 @@ class TranslationValidate extends _basecommand.default {
|
|
|
106
106
|
const resp = await api.validateTranslation(props, {
|
|
107
107
|
locale_code: translation.localeCode,
|
|
108
108
|
namespace: translation.namespace,
|
|
109
|
-
content: translation.content
|
|
109
|
+
content: translation.content,
|
|
110
|
+
format: translation.format
|
|
110
111
|
});
|
|
111
112
|
if ((0, _request.isSuccessResp)(resp)) return;
|
|
112
113
|
const message = (0, _request.formatErrorRespMessage)(resp);
|
package/dist/lib/api-v1.js
CHANGED
|
@@ -149,6 +149,7 @@ class ApiV1 {
|
|
|
149
149
|
hide_uncommitted_changes: flags["hide-uncommitted-changes"],
|
|
150
150
|
locale_code: filters.localeCode,
|
|
151
151
|
namespace: filters.namespace,
|
|
152
|
+
format: flags.format,
|
|
152
153
|
...(0, _page.toPageParams)(flags)
|
|
153
154
|
});
|
|
154
155
|
return this.get("/translations", {
|
|
@@ -159,7 +160,8 @@ class ApiV1 {
|
|
|
159
160
|
const params = (0, _objectisomorphic.prune)({
|
|
160
161
|
environment: flags.environment,
|
|
161
162
|
hide_uncommitted_changes: flags["hide-uncommitted-changes"],
|
|
162
|
-
namespace: translation.namespace
|
|
163
|
+
namespace: translation.namespace,
|
|
164
|
+
format: flags.format
|
|
163
165
|
});
|
|
164
166
|
return this.get(`/translations/${translation.localeCode}`, {
|
|
165
167
|
params
|
|
@@ -19,6 +19,7 @@ const disabled = {
|
|
|
19
19
|
throw new Error(`"${token.name}" tag is not supported in Knock`);
|
|
20
20
|
}
|
|
21
21
|
};
|
|
22
|
+
// TODO(KNO-6058) - Enable render tag for partials
|
|
22
23
|
engine.registerTag("render", disabled);
|
|
23
24
|
engine.registerTag("include", disabled);
|
|
24
25
|
function validateLiquidSyntax(input) {
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
_export_star(require("./processor.isomorphic"), exports);
|
|
6
|
+
_export_star(require("./types"), exports);
|
|
7
|
+
function _export_star(from, to) {
|
|
8
|
+
Object.keys(from).forEach(function(k) {
|
|
9
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
10
|
+
Object.defineProperty(to, k, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function() {
|
|
13
|
+
return from[k];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
return from;
|
|
19
|
+
}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: all[name]
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
PARTIAL_JSON: function() {
|
|
13
|
+
return PARTIAL_JSON;
|
|
14
|
+
},
|
|
15
|
+
buildPartialDirBundle: function() {
|
|
16
|
+
return buildPartialDirBundle;
|
|
17
|
+
},
|
|
18
|
+
toPartialJson: function() {
|
|
19
|
+
return toPartialJson;
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
const _lodash = require("lodash");
|
|
23
|
+
const _objectisomorphic = require("../../helpers/object.isomorphic");
|
|
24
|
+
const _constisomorphic = require("../shared/const.isomorphic");
|
|
25
|
+
const _types = require("./types");
|
|
26
|
+
const PARTIAL_JSON = "partial.json";
|
|
27
|
+
/*
|
|
28
|
+
* Sanitize the partial content into a format that's appropriate for reading
|
|
29
|
+
* and writing, by stripping out any annotation fields and handling readonly
|
|
30
|
+
* fields.
|
|
31
|
+
*/ const toPartialJson = (partial)=>{
|
|
32
|
+
var _partial___annotation;
|
|
33
|
+
// Move read only field under the dedicated field "__readonly".
|
|
34
|
+
const readonlyFields = ((_partial___annotation = partial.__annotation) === null || _partial___annotation === void 0 ? void 0 : _partial___annotation.readonly_fields) || [];
|
|
35
|
+
const [readonly, remainder] = (0, _objectisomorphic.split)(partial, readonlyFields);
|
|
36
|
+
const partialjson = {
|
|
37
|
+
...remainder,
|
|
38
|
+
__readonly: readonly
|
|
39
|
+
};
|
|
40
|
+
// Strip out all schema annotations, so not to expose them to end users.
|
|
41
|
+
return (0, _objectisomorphic.omitDeep)(partialjson, [
|
|
42
|
+
"__annotation"
|
|
43
|
+
]);
|
|
44
|
+
};
|
|
45
|
+
// Maps the partial type to the correct file extension. Defaults to 'txt'
|
|
46
|
+
const partialTypeToFileExt = (type)=>{
|
|
47
|
+
switch(type){
|
|
48
|
+
case _types.PartialType.Html:
|
|
49
|
+
return "html";
|
|
50
|
+
case _types.PartialType.Json:
|
|
51
|
+
return "json";
|
|
52
|
+
case _types.PartialType.Markdown:
|
|
53
|
+
return "md";
|
|
54
|
+
case _types.PartialType.Text:
|
|
55
|
+
default:
|
|
56
|
+
return "txt";
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
const compileExtractionSettings = (partial)=>{
|
|
60
|
+
const extractableFields = (0, _lodash.get)(partial, [
|
|
61
|
+
"__annotation",
|
|
62
|
+
"extractable_fields"
|
|
63
|
+
], {});
|
|
64
|
+
const map = new Map();
|
|
65
|
+
for (const key of Object.keys(partial)){
|
|
66
|
+
// If the field we are on is extractable, then add its extraction
|
|
67
|
+
// settings to the map with the current object path.
|
|
68
|
+
//
|
|
69
|
+
// NOTE: Partial content type is dynamically set based on the partial type
|
|
70
|
+
// rather than being explicitly set in the annotation.
|
|
71
|
+
if (key in extractableFields) {
|
|
72
|
+
const file_ext = partialTypeToFileExt(partial.type);
|
|
73
|
+
const extractable_settings = {
|
|
74
|
+
...extractableFields[key],
|
|
75
|
+
file_ext
|
|
76
|
+
};
|
|
77
|
+
map.set([
|
|
78
|
+
key
|
|
79
|
+
], extractable_settings);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return map;
|
|
83
|
+
};
|
|
84
|
+
const buildPartialDirBundle = (remotePartial, localPartial = {})=>{
|
|
85
|
+
const bundle = {};
|
|
86
|
+
const mutRemotePartial = (0, _lodash.cloneDeep)(remotePartial);
|
|
87
|
+
// A map of extraction settings of every field in the partial
|
|
88
|
+
const compiledExtractionSettings = compileExtractionSettings(mutRemotePartial);
|
|
89
|
+
// Iterate through each extractable field, determine whether we need to
|
|
90
|
+
// extract the field content, and if so, perform the
|
|
91
|
+
// extraction.
|
|
92
|
+
for (const [objPathParts, extractionSettings] of compiledExtractionSettings){
|
|
93
|
+
// If this partial doesn't have this field path, then we don't extract.
|
|
94
|
+
if (!(0, _lodash.has)(mutRemotePartial, objPathParts)) continue;
|
|
95
|
+
// If the field at this path is extracted in the local partial, then
|
|
96
|
+
// always extract; otherwise extract based on the field settings default.
|
|
97
|
+
const objPathStr = _objectisomorphic.ObjPath.stringify(objPathParts);
|
|
98
|
+
const extractedFilePath = (0, _lodash.get)(localPartial, `${objPathStr}${_constisomorphic.FILEPATH_MARKER}`);
|
|
99
|
+
const { default: extractByDefault, file_ext: fileExt } = extractionSettings;
|
|
100
|
+
if (!extractedFilePath && !extractByDefault) continue;
|
|
101
|
+
// By this point, we have a field where we need to extract its content.
|
|
102
|
+
const data = (0, _lodash.get)(mutRemotePartial, objPathParts);
|
|
103
|
+
const fileName = objPathParts.pop();
|
|
104
|
+
// If we have an extracted file path from the local partial, we use that.
|
|
105
|
+
// In the other case we use the default path.
|
|
106
|
+
const relpath = typeof extractedFilePath === "string" ? extractedFilePath : `${fileName}.${fileExt}`;
|
|
107
|
+
// Perform the extraction by adding the content and its file path to the
|
|
108
|
+
// bundle for writing to the file system later. Then replace the field
|
|
109
|
+
// content with the extracted file path and mark the field as extracted
|
|
110
|
+
// with @ suffix.
|
|
111
|
+
(0, _lodash.set)(bundle, [
|
|
112
|
+
relpath
|
|
113
|
+
], data);
|
|
114
|
+
(0, _lodash.set)(mutRemotePartial, `${objPathStr}${_constisomorphic.FILEPATH_MARKER}`, relpath);
|
|
115
|
+
(0, _lodash.unset)(mutRemotePartial, objPathStr);
|
|
116
|
+
}
|
|
117
|
+
// At this point the bundle contains all extractable files, so we finally add
|
|
118
|
+
// the partial JSON relative path + the file content.
|
|
119
|
+
return (0, _lodash.set)(bundle, [
|
|
120
|
+
PARTIAL_JSON
|
|
121
|
+
], toPartialJson(mutRemotePartial));
|
|
122
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "PartialType", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return PartialType;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
var PartialType;
|
|
12
|
+
(function(PartialType) {
|
|
13
|
+
PartialType["Html"] = "HTML";
|
|
14
|
+
PartialType["Json"] = "JSON";
|
|
15
|
+
PartialType["Markdown"] = "MARKDOWN";
|
|
16
|
+
PartialType["Text"] = "TEXT";
|
|
17
|
+
})(PartialType || (PartialType = {}));
|
|
@@ -104,15 +104,15 @@ const isTranslationDir = (dirPath)=>{
|
|
|
104
104
|
const locale = _nodepath.basename(dirPath);
|
|
105
105
|
return isValidLocale(locale);
|
|
106
106
|
};
|
|
107
|
-
const buildTranslationFileCtx = async (dirPath,
|
|
108
|
-
const ref = (0, _processorisomorphic.formatRef)(localeCode, namespace);
|
|
109
|
-
const filename = (0, _processorisomorphic.formatFileName)(ref);
|
|
107
|
+
const buildTranslationFileCtx = async (dirPath, translationIdentifier, options)=>{
|
|
108
|
+
const ref = (0, _processorisomorphic.formatRef)(translationIdentifier.localeCode, translationIdentifier.namespace);
|
|
109
|
+
const filename = (0, _processorisomorphic.formatFileName)(ref, options);
|
|
110
110
|
const abspath = _nodepath.resolve(dirPath, filename);
|
|
111
111
|
const exists = await _fsextra.pathExists(abspath);
|
|
112
112
|
return {
|
|
113
113
|
ref,
|
|
114
|
-
localeCode,
|
|
115
|
-
namespace,
|
|
114
|
+
localeCode: translationIdentifier.localeCode,
|
|
115
|
+
namespace: translationIdentifier.namespace,
|
|
116
116
|
abspath,
|
|
117
117
|
exists
|
|
118
118
|
};
|
|
@@ -182,10 +182,34 @@ const ensureValidCommandTarget = async (props, runContext)=>{
|
|
|
182
182
|
// Got translationRef arg but no --all flag, which means target only a single
|
|
183
183
|
// translation file.
|
|
184
184
|
if (!flags.all) {
|
|
185
|
-
|
|
185
|
+
// If specified, check the given format; otherwise check for all supported formats
|
|
186
|
+
const formats = flags.format ? [
|
|
187
|
+
flags.format
|
|
188
|
+
] : _processorisomorphic.SUPPORTED_TRANSLATION_FORMATS;
|
|
189
|
+
const translationFileCtxs = await Promise.all(formats.map(async (format)=>buildTranslationFileCtx(targetDirPath, {
|
|
190
|
+
localeCode,
|
|
191
|
+
namespace
|
|
192
|
+
}, {
|
|
193
|
+
format
|
|
194
|
+
})));
|
|
195
|
+
if (flags.format) {
|
|
196
|
+
return {
|
|
197
|
+
type: "translationFile",
|
|
198
|
+
context: translationFileCtxs[0]
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
// If no format is specified, look for the first existing file and return that context
|
|
202
|
+
const existingFileCtx = translationFileCtxs.find((ctx)=>ctx.exists);
|
|
203
|
+
if (existingFileCtx) {
|
|
204
|
+
return {
|
|
205
|
+
type: "translationFile",
|
|
206
|
+
context: existingFileCtx
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
// If no file exists, fall back to the file context with the default format (json)
|
|
186
210
|
return {
|
|
187
211
|
type: "translationFile",
|
|
188
|
-
context:
|
|
212
|
+
context: translationFileCtxs[0]
|
|
189
213
|
};
|
|
190
214
|
}
|
|
191
215
|
// From this point on, we have both translationRef and --all flag used
|
|
@@ -212,7 +236,8 @@ const lsTranslationDir = async (pathToDir)=>{
|
|
|
212
236
|
return dirents.filter((dirent)=>{
|
|
213
237
|
if (dirent.isDirectory()) return false;
|
|
214
238
|
const filename = dirent.name.toLowerCase();
|
|
215
|
-
|
|
239
|
+
const isValidExtension = _processorisomorphic.SUPPORTED_TRANSLATION_FORMATS.some((extension)=>filename.endsWith(`${localeCode}.${extension}`));
|
|
240
|
+
if (!isValidExtension) return false;
|
|
216
241
|
const { name: translationRef } = _nodepath.parse(filename);
|
|
217
242
|
const parsedRef = parseTranslationRef(translationRef);
|
|
218
243
|
if (!parsedRef) return false;
|
|
@@ -9,6 +9,12 @@ function _export(target, all) {
|
|
|
9
9
|
});
|
|
10
10
|
}
|
|
11
11
|
_export(exports, {
|
|
12
|
+
DEFAULT_TRANSLATION_FORMAT: function() {
|
|
13
|
+
return DEFAULT_TRANSLATION_FORMAT;
|
|
14
|
+
},
|
|
15
|
+
SUPPORTED_TRANSLATION_FORMATS: function() {
|
|
16
|
+
return SUPPORTED_TRANSLATION_FORMATS;
|
|
17
|
+
},
|
|
12
18
|
buildTranslationDirBundle: function() {
|
|
13
19
|
return buildTranslationDirBundle;
|
|
14
20
|
},
|
|
@@ -19,21 +25,35 @@ _export(exports, {
|
|
|
19
25
|
return formatRef;
|
|
20
26
|
}
|
|
21
27
|
});
|
|
28
|
+
const SUPPORTED_TRANSLATION_FORMATS = [
|
|
29
|
+
"json",
|
|
30
|
+
"po"
|
|
31
|
+
];
|
|
32
|
+
const DEFAULT_TRANSLATION_FORMAT = "json";
|
|
22
33
|
const formatRef = (localeCode, namespace)=>namespace ? `${namespace}.${localeCode}` : localeCode;
|
|
23
|
-
const formatFileName = (input)=>{
|
|
34
|
+
const formatFileName = (input, options)=>{
|
|
35
|
+
var _options_format;
|
|
36
|
+
const extension = (_options_format = options === null || options === void 0 ? void 0 : options.format) !== null && _options_format !== void 0 ? _options_format : DEFAULT_TRANSLATION_FORMAT;
|
|
24
37
|
const ref = typeof input === "string" ? input : formatRef(input.locale_code, input.namespace);
|
|
25
|
-
return `${ref}
|
|
38
|
+
return `${ref}.${extension}`;
|
|
26
39
|
};
|
|
27
|
-
const buildTranslationDirBundle = (input)=>{
|
|
40
|
+
const buildTranslationDirBundle = (input, options)=>{
|
|
41
|
+
var _options_format;
|
|
42
|
+
const format = (_options_format = options === null || options === void 0 ? void 0 : options.format) !== null && _options_format !== void 0 ? _options_format : DEFAULT_TRANSLATION_FORMAT;
|
|
28
43
|
if (Array.isArray(input)) {
|
|
29
44
|
const translations = input;
|
|
30
45
|
return Object.fromEntries(translations.map((translation)=>[
|
|
31
|
-
formatFileName(translation
|
|
46
|
+
formatFileName(translation, {
|
|
47
|
+
format
|
|
48
|
+
}),
|
|
32
49
|
JSON.parse(translation.content)
|
|
33
50
|
]));
|
|
34
51
|
}
|
|
35
52
|
const translation = input;
|
|
53
|
+
const content = format === "json" ? JSON.parse(translation.content) : translation.content;
|
|
36
54
|
return {
|
|
37
|
-
[formatFileName(translation
|
|
55
|
+
[formatFileName(translation, {
|
|
56
|
+
format
|
|
57
|
+
})]: content
|
|
38
58
|
};
|
|
39
59
|
};
|
|
@@ -14,6 +14,7 @@ const _fsextra = /*#__PURE__*/ _interop_require_wildcard(require("fs-extra"));
|
|
|
14
14
|
const _error = require("../../helpers/error");
|
|
15
15
|
const _json = require("../../helpers/json");
|
|
16
16
|
const _helpers = require("./helpers");
|
|
17
|
+
const _processorisomorphic = require("./processor.isomorphic");
|
|
17
18
|
function _getRequireWildcardCache(nodeInterop) {
|
|
18
19
|
if (typeof WeakMap !== "function") return null;
|
|
19
20
|
var cacheBabelInterop = new WeakMap();
|
|
@@ -76,10 +77,9 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
76
77
|
// push commands. Consider making this an option in the future.
|
|
77
78
|
if (namespace === _helpers.SYSTEM_NAMESPACE) continue;
|
|
78
79
|
// eslint-disable-next-line no-await-in-loop
|
|
79
|
-
const [content,
|
|
80
|
-
if (
|
|
81
|
-
|
|
82
|
-
errors.push(e);
|
|
80
|
+
const [content, sourceError, format] = await readTranslationFile(abspath);
|
|
81
|
+
if (sourceError) {
|
|
82
|
+
errors.push(sourceError);
|
|
83
83
|
continue;
|
|
84
84
|
}
|
|
85
85
|
translations.push({
|
|
@@ -88,7 +88,8 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
88
88
|
namespace,
|
|
89
89
|
abspath,
|
|
90
90
|
exists: true,
|
|
91
|
-
content
|
|
91
|
+
content,
|
|
92
|
+
format
|
|
92
93
|
});
|
|
93
94
|
}
|
|
94
95
|
return [
|
|
@@ -96,6 +97,56 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
96
97
|
errors
|
|
97
98
|
];
|
|
98
99
|
};
|
|
100
|
+
const readTranslationFile = async (filePath)=>{
|
|
101
|
+
// Get translation format from file extension
|
|
102
|
+
const format = getFormatFromFilePath(filePath);
|
|
103
|
+
switch(format){
|
|
104
|
+
case "json":
|
|
105
|
+
{
|
|
106
|
+
const [jsonContent, readErrors] = await (0, _json.readJson)(filePath);
|
|
107
|
+
if (readErrors.length > 0) {
|
|
108
|
+
const e = new _error.SourceError((0, _error.formatErrors)(readErrors), filePath);
|
|
109
|
+
return [
|
|
110
|
+
undefined,
|
|
111
|
+
e,
|
|
112
|
+
format
|
|
113
|
+
];
|
|
114
|
+
}
|
|
115
|
+
const content = JSON.stringify(jsonContent);
|
|
116
|
+
return [
|
|
117
|
+
content,
|
|
118
|
+
undefined,
|
|
119
|
+
format
|
|
120
|
+
];
|
|
121
|
+
}
|
|
122
|
+
case "po":
|
|
123
|
+
{
|
|
124
|
+
try {
|
|
125
|
+
const content = await _fsextra.readFile(filePath, "utf8");
|
|
126
|
+
return [
|
|
127
|
+
content,
|
|
128
|
+
undefined,
|
|
129
|
+
format
|
|
130
|
+
];
|
|
131
|
+
} catch (error) {
|
|
132
|
+
const e = new _error.SourceError(error.message, filePath);
|
|
133
|
+
return [
|
|
134
|
+
undefined,
|
|
135
|
+
e,
|
|
136
|
+
format
|
|
137
|
+
];
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
default:
|
|
141
|
+
throw new Error(`unsupported translation file extension: ${filePath}`);
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
const getFormatFromFilePath = (filePath)=>{
|
|
145
|
+
// Path.extname returns the extension with a period (e.g. .json)
|
|
146
|
+
// so we use slice to get just the name
|
|
147
|
+
const extension = _nodepath.extname(filePath).slice(1);
|
|
148
|
+
return _processorisomorphic.SUPPORTED_TRANSLATION_FORMATS.includes(extension) ? extension : undefined;
|
|
149
|
+
};
|
|
99
150
|
const readAllForCommandTarget = async (target)=>{
|
|
100
151
|
const { type: targetType, context: targetCtx } = target;
|
|
101
152
|
if (!targetCtx.exists) {
|
|
@@ -22,6 +22,7 @@ const _lodash = require("lodash");
|
|
|
22
22
|
const _const = require("../../helpers/const");
|
|
23
23
|
const _json = require("../../helpers/json");
|
|
24
24
|
const _helpers = require("./helpers");
|
|
25
|
+
const _processorisomorphic = require("./processor.isomorphic");
|
|
25
26
|
function _getRequireWildcardCache(nodeInterop) {
|
|
26
27
|
if (typeof WeakMap !== "function") return null;
|
|
27
28
|
var cacheBabelInterop = new WeakMap();
|
|
@@ -63,10 +64,21 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
63
64
|
}
|
|
64
65
|
return newObj;
|
|
65
66
|
}
|
|
66
|
-
const writeTranslationFile = async (translationFileCtx, translation
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
67
|
+
const writeTranslationFile = async (translationFileCtx, translation, options)=>{
|
|
68
|
+
var _options_format;
|
|
69
|
+
const format = (_options_format = options === null || options === void 0 ? void 0 : options.format) !== null && _options_format !== void 0 ? _options_format : _processorisomorphic.DEFAULT_TRANSLATION_FORMAT;
|
|
70
|
+
switch(format){
|
|
71
|
+
case "json":
|
|
72
|
+
return _fsextra.outputJson(translationFileCtx.abspath, JSON.parse(translation.content), {
|
|
73
|
+
spaces: _json.DOUBLE_SPACES
|
|
74
|
+
});
|
|
75
|
+
case "po":
|
|
76
|
+
return _fsextra.outputFile(translationFileCtx.abspath, translation.content);
|
|
77
|
+
default:
|
|
78
|
+
throw new Error(`Invalid translation file format: ${options === null || options === void 0 ? void 0 : options.format}`);
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
const writeTranslationFiles = async (targetDirCtx, translations, options)=>{
|
|
70
82
|
const backupDirPath = _nodepath.resolve(_const.sandboxDir, (0, _lodash.uniqueId)("backup"));
|
|
71
83
|
try {
|
|
72
84
|
// If the index directory already exists, back it up in the temp sandbox
|
|
@@ -81,8 +93,11 @@ const writeTranslationFiles = async (targetDirCtx, translations)=>{
|
|
|
81
93
|
// to write translation files in; otherwise for translations index
|
|
82
94
|
// directory, we want to nest translation files under each locale dir.
|
|
83
95
|
const localeDirPath = "key" in targetDirCtx ? targetDirCtx.abspath : _nodepath.resolve(targetDirCtx.abspath, translation.locale_code);
|
|
84
|
-
const translationFileCtx = await (0, _helpers.buildTranslationFileCtx)(localeDirPath,
|
|
85
|
-
|
|
96
|
+
const translationFileCtx = await (0, _helpers.buildTranslationFileCtx)(localeDirPath, {
|
|
97
|
+
localeCode: translation.locale_code,
|
|
98
|
+
namespace: translation.namespace
|
|
99
|
+
}, options);
|
|
100
|
+
return writeTranslationFile(translationFileCtx, translation, options);
|
|
86
101
|
});
|
|
87
102
|
await Promise.all(writeTranslationDirPromises);
|
|
88
103
|
} catch (error) {
|
package/oclif.manifest.json
CHANGED
|
@@ -817,6 +817,18 @@
|
|
|
817
817
|
"summary": "Hide any uncommitted changes.",
|
|
818
818
|
"allowNo": false,
|
|
819
819
|
"type": "boolean"
|
|
820
|
+
},
|
|
821
|
+
"format": {
|
|
822
|
+
"name": "format",
|
|
823
|
+
"summary": "Specify the output format of the returned translations.",
|
|
824
|
+
"default": "json",
|
|
825
|
+
"hasDynamicHelp": false,
|
|
826
|
+
"multiple": false,
|
|
827
|
+
"options": [
|
|
828
|
+
"json",
|
|
829
|
+
"po"
|
|
830
|
+
],
|
|
831
|
+
"type": "option"
|
|
820
832
|
}
|
|
821
833
|
},
|
|
822
834
|
"hasDynamicHelp": false,
|
|
@@ -979,6 +991,18 @@
|
|
|
979
991
|
"summary": "Remove the confirmation prompt.",
|
|
980
992
|
"allowNo": false,
|
|
981
993
|
"type": "boolean"
|
|
994
|
+
},
|
|
995
|
+
"format": {
|
|
996
|
+
"name": "format",
|
|
997
|
+
"summary": "Specify the output format of the returned translations.",
|
|
998
|
+
"default": "json",
|
|
999
|
+
"hasDynamicHelp": false,
|
|
1000
|
+
"multiple": false,
|
|
1001
|
+
"options": [
|
|
1002
|
+
"json",
|
|
1003
|
+
"po"
|
|
1004
|
+
],
|
|
1005
|
+
"type": "option"
|
|
982
1006
|
}
|
|
983
1007
|
},
|
|
984
1008
|
"hasDynamicHelp": false,
|
|
@@ -1758,5 +1782,5 @@
|
|
|
1758
1782
|
]
|
|
1759
1783
|
}
|
|
1760
1784
|
},
|
|
1761
|
-
"version": "0.1.
|
|
1785
|
+
"version": "0.1.16"
|
|
1762
1786
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@knocklabs/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.16",
|
|
4
4
|
"description": "Knock CLI",
|
|
5
5
|
"author": "@knocklabs",
|
|
6
6
|
"bin": {
|
|
@@ -19,26 +19,25 @@
|
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"@oclif/core": "^3",
|
|
21
21
|
"@oclif/plugin-help": "^6",
|
|
22
|
-
"@oclif/plugin-plugins": "^4",
|
|
23
22
|
"@prantlf/jsonlint": "^14.0.3",
|
|
24
|
-
"axios": "^1.
|
|
23
|
+
"axios": "^1.6.8",
|
|
25
24
|
"date-fns": "^2.30.0",
|
|
26
25
|
"enquirer": "^2.4.1",
|
|
27
26
|
"fs-extra": "^11.2.0",
|
|
28
|
-
"liquidjs": "^10.
|
|
27
|
+
"liquidjs": "^10.13.1",
|
|
29
28
|
"locale-codes": "^1.3.1",
|
|
30
29
|
"lodash": "^4.17.21",
|
|
31
30
|
"yup": "^1.4.0"
|
|
32
31
|
},
|
|
33
32
|
"devDependencies": {
|
|
34
33
|
"@oclif/test": "^3",
|
|
35
|
-
"@swc/cli": "^0.3.
|
|
36
|
-
"@swc/core": "^1.
|
|
37
|
-
"@swc/helpers": "^0.5.
|
|
34
|
+
"@swc/cli": "^0.3.12",
|
|
35
|
+
"@swc/core": "^1.5.7",
|
|
36
|
+
"@swc/helpers": "^0.5.11",
|
|
38
37
|
"@types/chai": "^4",
|
|
39
38
|
"@types/fs-extra": "^11.0.4",
|
|
40
39
|
"@types/mocha": "^10.0.6",
|
|
41
|
-
"@types/node": "^20.
|
|
40
|
+
"@types/node": "^20.14.8",
|
|
42
41
|
"chai": "^4",
|
|
43
42
|
"eslint": "^7.32.0",
|
|
44
43
|
"eslint-config-oclif": "^4",
|
|
@@ -47,23 +46,22 @@
|
|
|
47
46
|
"eslint-plugin-prettier": "^4.2.1",
|
|
48
47
|
"eslint-plugin-simple-import-sort": "^10.0.0",
|
|
49
48
|
"mocha": "^10",
|
|
50
|
-
"nock": "^13.5.
|
|
49
|
+
"nock": "^13.5.4",
|
|
51
50
|
"oclif": "^4",
|
|
52
51
|
"prettier": "2.8.8",
|
|
53
52
|
"shx": "^0.3.4",
|
|
54
53
|
"sinon": "^16.1.3",
|
|
55
54
|
"ts-node": "^10.9.1",
|
|
56
55
|
"tsconfig-paths": "^4.2.0",
|
|
57
|
-
"tslib": "^2.6.
|
|
58
|
-
"typescript": "^5.
|
|
56
|
+
"tslib": "^2.6.3",
|
|
57
|
+
"typescript": "^5.5.2"
|
|
59
58
|
},
|
|
60
59
|
"oclif": {
|
|
61
60
|
"bin": "knock",
|
|
62
61
|
"dirname": "knock",
|
|
63
62
|
"commands": "./dist/commands",
|
|
64
63
|
"plugins": [
|
|
65
|
-
"@oclif/plugin-help"
|
|
66
|
-
"@oclif/plugin-plugins"
|
|
64
|
+
"@oclif/plugin-help"
|
|
67
65
|
],
|
|
68
66
|
"topicSeparator": " ",
|
|
69
67
|
"topics": {
|