@vocab/cli 1.1.0 → 1.3.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 +66 -4
- package/dist/vocab-cli.cjs.dev.js +6 -1
- package/dist/vocab-cli.cjs.prod.js +6 -1
- package/dist/vocab-cli.esm.js +6 -1
- package/package.json +7 -3
- package/CHANGELOG.md +0 -187
- package/src/index.ts +0 -65
package/README.md
CHANGED
|
@@ -422,19 +422,81 @@ Or to re-run the compiler when files change use:
|
|
|
422
422
|
$ vocab compile --watch
|
|
423
423
|
```
|
|
424
424
|
|
|
425
|
-
## External
|
|
425
|
+
## External Translation Tooling
|
|
426
426
|
|
|
427
427
|
Vocab can be used to synchronize your translations with translations from a remote translation platform.
|
|
428
428
|
|
|
429
|
-
| Platform
|
|
430
|
-
|
|
|
431
|
-
| [Phrase]
|
|
429
|
+
| Platform | Environment Variables |
|
|
430
|
+
| -------- | ----------------------------------- |
|
|
431
|
+
| [Phrase] | PHRASE_PROJECT_ID, PHRASE_API_TOKEN |
|
|
432
432
|
|
|
433
433
|
```bash
|
|
434
434
|
$ vocab push --branch my-branch
|
|
435
435
|
$ vocab pull --branch my-branch
|
|
436
436
|
```
|
|
437
437
|
|
|
438
|
+
### [Phrase] Platform Features
|
|
439
|
+
|
|
440
|
+
#### Delete Unused keys
|
|
441
|
+
|
|
442
|
+
When uploading translations, Phrase identifies keys that exist in the Phrase project, but were not
|
|
443
|
+
referenced in the upload. These keys can be deleted from Phrase by providing the
|
|
444
|
+
`---delete-unused-keys` flag to `vocab push`. E.g.
|
|
445
|
+
|
|
446
|
+
```sh
|
|
447
|
+
$ vocab push --branch my-branch --delete-unused-keys
|
|
448
|
+
```
|
|
449
|
+
|
|
450
|
+
[phrase]: https://developers.phrase.com/api/
|
|
451
|
+
|
|
452
|
+
#### [Tags]
|
|
453
|
+
|
|
454
|
+
`vocab push` supports uploading [tags] to Phrase.
|
|
455
|
+
|
|
456
|
+
Tags can be added to an individual key via the `tags` property:
|
|
457
|
+
|
|
458
|
+
```jsonc
|
|
459
|
+
// translations.json
|
|
460
|
+
{
|
|
461
|
+
"Hello": {
|
|
462
|
+
"message": "Hello",
|
|
463
|
+
"tags": ["greeting", "home_page"]
|
|
464
|
+
},
|
|
465
|
+
"Goodbye": {
|
|
466
|
+
"message": "Goodbye",
|
|
467
|
+
"tags": ["home_page"]
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
```
|
|
471
|
+
|
|
472
|
+
Tags can also be added under a top-level `_meta` field. This will result in the tags applying to all
|
|
473
|
+
keys specified in the file:
|
|
474
|
+
|
|
475
|
+
```jsonc
|
|
476
|
+
// translations.json
|
|
477
|
+
{
|
|
478
|
+
"_meta": {
|
|
479
|
+
"tags": ["home_page"]
|
|
480
|
+
},
|
|
481
|
+
"Hello": {
|
|
482
|
+
"message": "Hello",
|
|
483
|
+
"tags": ["greeting"]
|
|
484
|
+
},
|
|
485
|
+
"Goodbye": {
|
|
486
|
+
"message": "Goodbye"
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
```
|
|
490
|
+
|
|
491
|
+
In the above example, both the `Hello` and `Goodbye` keys would have the `home_page` tag attached to
|
|
492
|
+
them, but only the `Hello` key would have the `usage_greeting` tag attached to it.
|
|
493
|
+
|
|
494
|
+
**NOTE**: Only tags specified on keys in your [`devLanguage`][configuration] will be uploaded.
|
|
495
|
+
Tags on keys in other languages will be ignored.
|
|
496
|
+
|
|
497
|
+
[tags]: https://support.phrase.com/hc/en-us/articles/5822598372252-Tags-Strings-
|
|
498
|
+
[configuration]: #Configuration
|
|
499
|
+
|
|
438
500
|
## Troubleshooting
|
|
439
501
|
|
|
440
502
|
### Problem: Passed locale is being ignored or using en-US instead
|
|
@@ -32,7 +32,12 @@ yargs__default['default'](process.argv.slice(2)).scriptName('vocab').option('con
|
|
|
32
32
|
}).command({
|
|
33
33
|
command: 'push',
|
|
34
34
|
builder: () => yargs__default['default'].options({
|
|
35
|
-
branch: branchDefinition
|
|
35
|
+
branch: branchDefinition,
|
|
36
|
+
'delete-unused-keys': {
|
|
37
|
+
type: 'boolean',
|
|
38
|
+
describe: 'Whether or not to delete unused keys after pushing',
|
|
39
|
+
default: false
|
|
40
|
+
}
|
|
36
41
|
}),
|
|
37
42
|
handler: async options => {
|
|
38
43
|
await phrase.push(options, config);
|
|
@@ -32,7 +32,12 @@ yargs__default['default'](process.argv.slice(2)).scriptName('vocab').option('con
|
|
|
32
32
|
}).command({
|
|
33
33
|
command: 'push',
|
|
34
34
|
builder: () => yargs__default['default'].options({
|
|
35
|
-
branch: branchDefinition
|
|
35
|
+
branch: branchDefinition,
|
|
36
|
+
'delete-unused-keys': {
|
|
37
|
+
type: 'boolean',
|
|
38
|
+
describe: 'Whether or not to delete unused keys after pushing',
|
|
39
|
+
default: false
|
|
40
|
+
}
|
|
36
41
|
}),
|
|
37
42
|
handler: async options => {
|
|
38
43
|
await phrase.push(options, config);
|
package/dist/vocab-cli.esm.js
CHANGED
|
@@ -25,7 +25,12 @@ yargs(process.argv.slice(2)).scriptName('vocab').option('config', {
|
|
|
25
25
|
}).command({
|
|
26
26
|
command: 'push',
|
|
27
27
|
builder: () => yargs.options({
|
|
28
|
-
branch: branchDefinition
|
|
28
|
+
branch: branchDefinition,
|
|
29
|
+
'delete-unused-keys': {
|
|
30
|
+
type: 'boolean',
|
|
31
|
+
describe: 'Whether or not to delete unused keys after pushing',
|
|
32
|
+
default: false
|
|
33
|
+
}
|
|
29
34
|
}),
|
|
30
35
|
handler: async options => {
|
|
31
36
|
await push(options, config);
|
package/package.json
CHANGED
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vocab/cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"main": "dist/vocab-cli.cjs.js",
|
|
5
5
|
"module": "dist/vocab-cli.esm.js",
|
|
6
6
|
"bin": {
|
|
7
7
|
"vocab": "bin.js"
|
|
8
8
|
},
|
|
9
|
+
"files": [
|
|
10
|
+
"dist",
|
|
11
|
+
"bin.js"
|
|
12
|
+
],
|
|
9
13
|
"author": "SEEK",
|
|
10
14
|
"license": "MIT",
|
|
11
15
|
"dependencies": {
|
|
12
16
|
"@types/env-ci": "^3.1.0",
|
|
13
|
-
"@vocab/core": "^1.
|
|
14
|
-
"@vocab/phrase": "^1.
|
|
17
|
+
"@vocab/core": "^1.2.0",
|
|
18
|
+
"@vocab/phrase": "^1.2.0",
|
|
15
19
|
"env-ci": "^5.0.2",
|
|
16
20
|
"fast-glob": "^3.2.4",
|
|
17
21
|
"form-data": "^3.0.0",
|
package/CHANGELOG.md
DELETED
|
@@ -1,187 +0,0 @@
|
|
|
1
|
-
# @vocab/cli
|
|
2
|
-
|
|
3
|
-
## 1.1.0
|
|
4
|
-
|
|
5
|
-
### Minor Changes
|
|
6
|
-
|
|
7
|
-
- [`87333d7`](https://github.com/seek-oss/vocab/commit/87333d79c4a883b07d7d8f2c272b16e2243c49bd) [#80](https://github.com/seek-oss/vocab/pull/80) Thanks [@askoufis](https://github.com/askoufis)! - Enable the creation of generated languages via the `generatedLanguages` config.
|
|
8
|
-
See [the docs] for more information and examples.
|
|
9
|
-
|
|
10
|
-
[the docs]: https://github.com/seek-oss/vocab#generated-languages
|
|
11
|
-
|
|
12
|
-
### Patch Changes
|
|
13
|
-
|
|
14
|
-
- Updated dependencies [[`87333d7`](https://github.com/seek-oss/vocab/commit/87333d79c4a883b07d7d8f2c272b16e2243c49bd)]:
|
|
15
|
-
- @vocab/core@1.1.0
|
|
16
|
-
|
|
17
|
-
## 1.0.1
|
|
18
|
-
|
|
19
|
-
### Patch Changes
|
|
20
|
-
|
|
21
|
-
- [`3ec6dba`](https://github.com/seek-oss/vocab/commit/3ec6dbaad590299cc33e2d9d4a877576eb05853a) [#63](https://github.com/seek-oss/vocab/pull/63) Thanks [@jahredhope](https://github.com/jahredhope)! - Migrate to new @formatjs/icu-messageformat-parser as intl-messageformat-parser has been deprecated
|
|
22
|
-
|
|
23
|
-
- Updated dependencies [[`3ec6dba`](https://github.com/seek-oss/vocab/commit/3ec6dbaad590299cc33e2d9d4a877576eb05853a)]:
|
|
24
|
-
- @vocab/core@1.0.2
|
|
25
|
-
|
|
26
|
-
## 1.0.0
|
|
27
|
-
|
|
28
|
-
### Major Changes
|
|
29
|
-
|
|
30
|
-
- [`3031054`](https://github.com/seek-oss/vocab/commit/303105440851db6126f0606e1607745b27dd981c) [#51](https://github.com/seek-oss/vocab/pull/51) Thanks [@jahredhope](https://github.com/jahredhope)! - Release v1.0.0
|
|
31
|
-
|
|
32
|
-
Release Vocab as v1.0.0 to signify a stable API and support future [semver versioning](https://semver.org/) releases.
|
|
33
|
-
|
|
34
|
-
Vocab has seen a lot of iteration and changes since it was first published on 20 November 2020. We are now confident with the API and believe Vocab is ready for common use.
|
|
35
|
-
|
|
36
|
-
### Patch Changes
|
|
37
|
-
|
|
38
|
-
- Updated dependencies [[`0074382`](https://github.com/seek-oss/vocab/commit/007438273ef70f5d5ded45777933651ad8df36f6), [`3031054`](https://github.com/seek-oss/vocab/commit/303105440851db6126f0606e1607745b27dd981c)]:
|
|
39
|
-
- @vocab/core@1.0.0
|
|
40
|
-
- @vocab/phrase@1.0.0
|
|
41
|
-
|
|
42
|
-
## 0.0.16
|
|
43
|
-
|
|
44
|
-
### Patch Changes
|
|
45
|
-
|
|
46
|
-
- Updated dependencies [[`5b1fdc0`](https://github.com/seek-oss/vocab/commit/5b1fdc019522b12e7ef94b2fec57b54a9310d41c)]:
|
|
47
|
-
- @vocab/core@0.0.11
|
|
48
|
-
- @vocab/phrase@0.0.11
|
|
49
|
-
|
|
50
|
-
## 0.0.15
|
|
51
|
-
|
|
52
|
-
### Patch Changes
|
|
53
|
-
|
|
54
|
-
- Updated dependencies [[`7c96a14`](https://github.com/seek-oss/vocab/commit/7c96a142f602132d38c1df1a47a1f4657dc5c94c)]:
|
|
55
|
-
- @vocab/core@0.0.10
|
|
56
|
-
- @vocab/phrase@0.0.10
|
|
57
|
-
|
|
58
|
-
## 0.0.14
|
|
59
|
-
|
|
60
|
-
### Patch Changes
|
|
61
|
-
|
|
62
|
-
- Updated dependencies [[`3034bd3`](https://github.com/seek-oss/vocab/commit/3034bd3de610a9d1f3bfbd8caefa27064dee2710), [`c110745`](https://github.com/seek-oss/vocab/commit/c110745b79df1a8ade6b1d8a49e798b04a7b95e1)]:
|
|
63
|
-
- @vocab/core@0.0.9
|
|
64
|
-
- @vocab/phrase@0.0.9
|
|
65
|
-
|
|
66
|
-
## 0.0.13
|
|
67
|
-
|
|
68
|
-
### Patch Changes
|
|
69
|
-
|
|
70
|
-
- Updated dependencies [[`f2fca67`](https://github.com/seek-oss/vocab/commit/f2fca679c66ae65405a0aa24f0a0e472026aad0d)]:
|
|
71
|
-
- @vocab/core@0.0.8
|
|
72
|
-
- @vocab/phrase@0.0.8
|
|
73
|
-
|
|
74
|
-
## 0.0.12
|
|
75
|
-
|
|
76
|
-
### Patch Changes
|
|
77
|
-
|
|
78
|
-
- Updated dependencies [[`283bcad`](https://github.com/seek-oss/vocab/commit/283bcada06e622ab14ed891743ed3f55cf09e245), [`ad0d240`](https://github.com/seek-oss/vocab/commit/ad0d2404545ded8e11621eae8f29467ff3352366), [`f3992ef`](https://github.com/seek-oss/vocab/commit/f3992efbf08939ebf853fac650a49cc46dc51dfb), [`f3992ef`](https://github.com/seek-oss/vocab/commit/f3992efbf08939ebf853fac650a49cc46dc51dfb)]:
|
|
79
|
-
- @vocab/core@0.0.7
|
|
80
|
-
- @vocab/phrase@0.0.7
|
|
81
|
-
|
|
82
|
-
## 0.0.11
|
|
83
|
-
|
|
84
|
-
### Patch Changes
|
|
85
|
-
|
|
86
|
-
- Updated dependencies [[`80a46c0`](https://github.com/seek-oss/vocab/commit/80a46c01a55408675f5822c3618519f80136c3ab), [`80a46c0`](https://github.com/seek-oss/vocab/commit/80a46c01a55408675f5822c3618519f80136c3ab)]:
|
|
87
|
-
- @vocab/core@0.0.6
|
|
88
|
-
- @vocab/phrase@0.0.6
|
|
89
|
-
|
|
90
|
-
## 0.0.10
|
|
91
|
-
|
|
92
|
-
### Patch Changes
|
|
93
|
-
|
|
94
|
-
- Updated dependencies [[`371ed16`](https://github.com/seek-oss/vocab/commit/371ed16a232a04dab13afa7e2b352dfb6724eea4), [`c222d68`](https://github.com/seek-oss/vocab/commit/c222d68a3c0c24723a338eccb959798881f6a118)]:
|
|
95
|
-
- @vocab/core@0.0.5
|
|
96
|
-
- @vocab/phrase@0.0.5
|
|
97
|
-
|
|
98
|
-
## 0.0.9
|
|
99
|
-
|
|
100
|
-
### Patch Changes
|
|
101
|
-
|
|
102
|
-
- [`5f5c581`](https://github.com/seek-oss/vocab/commit/5f5c581a65bff28729ee19e1ec0bdea488a9d6c2) [#19](https://github.com/seek-oss/vocab/pull/19) Thanks [@jahredhope](https://github.com/jahredhope)! - Compile useable TypeScript importable files with `vocab compile`.
|
|
103
|
-
|
|
104
|
-
The new `vocab compile` step replaces `vocab generate-types` in creating a fully functional **translations.ts** file.
|
|
105
|
-
|
|
106
|
-
This allows vocab to be used **without the Webpack Plugin**, however use of the plugin is still heavily advised to ensure optimal loading of translation content on the web.
|
|
107
|
-
|
|
108
|
-
Support for unit testing is now better than ever! The newly created **translations.ts** means your unit test code will see the same code as available while rendering.
|
|
109
|
-
|
|
110
|
-
See the [documentation](https://github.com/seek-oss/vocab) for further usage details.
|
|
111
|
-
|
|
112
|
-
- Updated dependencies [[`5f5c581`](https://github.com/seek-oss/vocab/commit/5f5c581a65bff28729ee19e1ec0bdea488a9d6c2), [`02f943c`](https://github.com/seek-oss/vocab/commit/02f943ca892913b41f9e4720a72400777cf14b3d)]:
|
|
113
|
-
- @vocab/core@0.0.4
|
|
114
|
-
- @vocab/phrase@0.0.4
|
|
115
|
-
|
|
116
|
-
## 0.0.8
|
|
117
|
-
|
|
118
|
-
### Patch Changes
|
|
119
|
-
|
|
120
|
-
- [`ed6cf40`](https://github.com/seek-oss/vocab/commit/ed6cf408973f2e9c4d07a71fcb52f40294ebaf65) [#13](https://github.com/seek-oss/vocab/pull/13) Thanks [@mattcompiles](https://github.com/mattcompiles)! - Add validation script for identifying missing keys
|
|
121
|
-
|
|
122
|
-
* [`b5a5a05`](https://github.com/seek-oss/vocab/commit/b5a5a05a5bb87b48e6e9160af75f555728143ea2) [#15](https://github.com/seek-oss/vocab/pull/15) Thanks [@mattcompiles](https://github.com/mattcompiles)! - Added watch mode to generate-types
|
|
123
|
-
|
|
124
|
-
* Updated dependencies [[`08de30d`](https://github.com/seek-oss/vocab/commit/08de30d338c2a5ebdcf14da7c736dddf22e7ca9e), [`ed6cf40`](https://github.com/seek-oss/vocab/commit/ed6cf408973f2e9c4d07a71fcb52f40294ebaf65), [`26b52f4`](https://github.com/seek-oss/vocab/commit/26b52f4878ded440841e08c858bdc9e685500c2a), [`b5a5a05`](https://github.com/seek-oss/vocab/commit/b5a5a05a5bb87b48e6e9160af75f555728143ea2)]:
|
|
125
|
-
- @vocab/core@0.0.3
|
|
126
|
-
- @vocab/phrase@0.0.3
|
|
127
|
-
|
|
128
|
-
## 0.0.7
|
|
129
|
-
|
|
130
|
-
### Patch Changes
|
|
131
|
-
|
|
132
|
-
- [`4710f34`](https://github.com/seek-oss/vocab/commit/4710f341f2827643e3eff69ef7e26d44ec6e8a2b) [#8](https://github.com/seek-oss/vocab/pull/8) Thanks [@mattcompiles](https://github.com/mattcompiles)! - Infer `t` return type more intelligently
|
|
133
|
-
|
|
134
|
-
The translate key function (`t`) will now infer the return type as ReactNode only when the tag syntax is used.
|
|
135
|
-
|
|
136
|
-
- Updated dependencies [[`4710f34`](https://github.com/seek-oss/vocab/commit/4710f341f2827643e3eff69ef7e26d44ec6e8a2b)]:
|
|
137
|
-
- @vocab/core@0.0.2
|
|
138
|
-
- @vocab/phrase@0.0.2
|
|
139
|
-
|
|
140
|
-
## 0.0.6
|
|
141
|
-
|
|
142
|
-
### Patch Changes
|
|
143
|
-
|
|
144
|
-
- [`45c4fe2`](https://github.com/seek-oss/vocab/commit/45c4fe273c5157475cb03ca57db662956ad5cbc9) Thanks [@mattcompiles](https://github.com/mattcompiles)! - Improved type definitions for `t` function
|
|
145
|
-
|
|
146
|
-
* [`33aeb0f`](https://github.com/seek-oss/vocab/commit/33aeb0f210687b8ce57417e963bba9db7c7cb4e3) Thanks [@mattcompiles](https://github.com/mattcompiles)! - Respect prettier config for generated typescript declarations
|
|
147
|
-
|
|
148
|
-
* Updated dependencies [[`2c7779f`](https://github.com/seek-oss/vocab/commit/2c7779f5384793af6a178f5ab4d56b6a9f09bc02)]:
|
|
149
|
-
- @vocab/utils@0.0.6
|
|
150
|
-
|
|
151
|
-
## 0.0.5
|
|
152
|
-
|
|
153
|
-
### Patch Changes
|
|
154
|
-
|
|
155
|
-
- Updated dependencies [[`f7b6b5c`](https://github.com/seek-oss/vocab/commit/f7b6b5c1cdb3f72bb0a3d0c5c7a3da844b2a1c87)]:
|
|
156
|
-
- @vocab/utils@0.0.5
|
|
157
|
-
|
|
158
|
-
## 0.0.4
|
|
159
|
-
|
|
160
|
-
### Patch Changes
|
|
161
|
-
|
|
162
|
-
- [`4589bce`](https://github.com/seek-oss/vocab/commit/4589bce912b7a8fb869e1c3a65d0c4c417043faf) Thanks [@mattcompiles](https://github.com/mattcompiles)! - Support language fallbacks through `extends` config
|
|
163
|
-
|
|
164
|
-
* [`bf36f86`](https://github.com/seek-oss/vocab/commit/bf36f86a74ced4f42271b2f8fb128e995bb8c849) Thanks [@mattcompiles](https://github.com/mattcompiles)! - Use config location as CWD
|
|
165
|
-
|
|
166
|
-
- [`f41c8f6`](https://github.com/seek-oss/vocab/commit/f41c8f67d78994bc071aca6eb20ef63421be2e96) Thanks [@mattcompiles](https://github.com/mattcompiles)! - Access TranslationFile type from @vocab/cli instead of @vocab/types
|
|
167
|
-
|
|
168
|
-
* [`870a74b`](https://github.com/seek-oss/vocab/commit/870a74b9a15ec2cb493c3de526c599b24fd5830d) Thanks [@mattcompiles](https://github.com/mattcompiles)! - Support custom config file locations
|
|
169
|
-
|
|
170
|
-
* Updated dependencies [[`4589bce`](https://github.com/seek-oss/vocab/commit/4589bce912b7a8fb869e1c3a65d0c4c417043faf), [`215eeba`](https://github.com/seek-oss/vocab/commit/215eeba619260b349a39d99a79fc69503dba5ccf), [`bf36f86`](https://github.com/seek-oss/vocab/commit/bf36f86a74ced4f42271b2f8fb128e995bb8c849), [`870a74b`](https://github.com/seek-oss/vocab/commit/870a74b9a15ec2cb493c3de526c599b24fd5830d)]:
|
|
171
|
-
- @vocab/utils@0.0.4
|
|
172
|
-
|
|
173
|
-
## 0.0.3
|
|
174
|
-
|
|
175
|
-
### Patch Changes
|
|
176
|
-
|
|
177
|
-
- Updated dependencies [[`6f2c084`](https://github.com/seek-oss/vocab/commit/6f2c08419ce5773c589901fafa7bec7a1c94d2a5)]:
|
|
178
|
-
- @vocab/utils@0.0.3
|
|
179
|
-
|
|
180
|
-
## 0.0.2
|
|
181
|
-
|
|
182
|
-
### Patch Changes
|
|
183
|
-
|
|
184
|
-
- [`9f99ea7`](https://github.com/seek-oss/vocab/commit/9f99ea7c827ec4d7c21a485e17e3adbbd1c49319) Thanks [@jahredhope](https://github.com/jahredhope)! - Remove React as dependency and target node
|
|
185
|
-
|
|
186
|
-
- Updated dependencies [[`9f99ea7`](https://github.com/seek-oss/vocab/commit/9f99ea7c827ec4d7c21a485e17e3adbbd1c49319)]:
|
|
187
|
-
- @vocab/utils@0.0.2
|
package/src/index.ts
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-console */
|
|
2
|
-
import type { UserConfig } from '@vocab/types';
|
|
3
|
-
import { pull, push } from '@vocab/phrase';
|
|
4
|
-
import { resolveConfig, compile, validate } from '@vocab/core';
|
|
5
|
-
import yargs from 'yargs';
|
|
6
|
-
|
|
7
|
-
import envCi from 'env-ci';
|
|
8
|
-
|
|
9
|
-
const { branch } = envCi();
|
|
10
|
-
|
|
11
|
-
const branchDefinition = {
|
|
12
|
-
type: 'string',
|
|
13
|
-
describe: 'The Phrase branch to target',
|
|
14
|
-
default: branch || 'local-development',
|
|
15
|
-
} as const;
|
|
16
|
-
|
|
17
|
-
let config: UserConfig | null = null;
|
|
18
|
-
|
|
19
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
|
|
20
|
-
yargs(process.argv.slice(2))
|
|
21
|
-
.scriptName('vocab')
|
|
22
|
-
.option('config', {
|
|
23
|
-
type: 'string',
|
|
24
|
-
describe: 'Path to config file',
|
|
25
|
-
})
|
|
26
|
-
.middleware(async ({ config: configPath }) => {
|
|
27
|
-
config = await resolveConfig(configPath);
|
|
28
|
-
console.log('Loaded config from', configPath || process.cwd());
|
|
29
|
-
})
|
|
30
|
-
.command({
|
|
31
|
-
command: 'push',
|
|
32
|
-
builder: () => yargs.options({ branch: branchDefinition }),
|
|
33
|
-
handler: async (options) => {
|
|
34
|
-
await push(options, config!);
|
|
35
|
-
},
|
|
36
|
-
})
|
|
37
|
-
.command({
|
|
38
|
-
command: 'pull',
|
|
39
|
-
builder: () => yargs.options({ branch: branchDefinition }),
|
|
40
|
-
handler: async (options) => {
|
|
41
|
-
await pull(options, config!);
|
|
42
|
-
},
|
|
43
|
-
})
|
|
44
|
-
.command({
|
|
45
|
-
command: 'compile',
|
|
46
|
-
builder: () =>
|
|
47
|
-
yargs.options({
|
|
48
|
-
watch: { type: 'boolean', default: false },
|
|
49
|
-
}),
|
|
50
|
-
handler: async ({ watch }) => {
|
|
51
|
-
await compile({ watch }, config!);
|
|
52
|
-
},
|
|
53
|
-
})
|
|
54
|
-
.command({
|
|
55
|
-
command: 'validate',
|
|
56
|
-
handler: async () => {
|
|
57
|
-
const valid = await validate(config!);
|
|
58
|
-
|
|
59
|
-
if (!valid) {
|
|
60
|
-
throw new Error('Project invalid');
|
|
61
|
-
}
|
|
62
|
-
},
|
|
63
|
-
})
|
|
64
|
-
.help()
|
|
65
|
-
.wrap(72).argv;
|