@vocab/cli 0.0.0-delete-unused-keys-20228144520 → 0.0.0-global-key-support-20231025223328

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ ### MIT License
2
+
3
+ Copyright (c) 2020 SEEK
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -1 +1 @@
1
- export {};
1
+ export {};
@@ -13,15 +13,16 @@ var envCi__default = /*#__PURE__*/_interopDefault(envCi);
13
13
  /* eslint-disable no-console */
14
14
  const {
15
15
  branch
16
- } = envCi__default['default']();
16
+ } = envCi__default["default"]();
17
17
  const branchDefinition = {
18
18
  type: 'string',
19
19
  describe: 'The Phrase branch to target',
20
20
  default: branch || 'local-development'
21
21
  };
22
- let config = null; // eslint-disable-next-line @typescript-eslint/no-unused-expressions
22
+ let config = null;
23
23
 
24
- yargs__default['default'](process.argv.slice(2)).scriptName('vocab').option('config', {
24
+ // eslint-disable-next-line @typescript-eslint/no-unused-expressions
25
+ yargs__default["default"](process.argv.slice(2)).scriptName('vocab').option('config', {
25
26
  type: 'string',
26
27
  describe: 'Path to config file'
27
28
  }).middleware(async ({
@@ -31,9 +32,9 @@ yargs__default['default'](process.argv.slice(2)).scriptName('vocab').option('con
31
32
  console.log('Loaded config from', configPath || process.cwd());
32
33
  }).command({
33
34
  command: 'push',
34
- builder: () => yargs__default['default'].options({
35
+ builder: () => yargs__default["default"].options({
35
36
  branch: branchDefinition,
36
- deleteUnusedKeys: {
37
+ 'delete-unused-keys': {
37
38
  type: 'boolean',
38
39
  describe: 'Whether or not to delete unused keys after pushing',
39
40
  default: false
@@ -44,15 +45,20 @@ yargs__default['default'](process.argv.slice(2)).scriptName('vocab').option('con
44
45
  }
45
46
  }).command({
46
47
  command: 'pull',
47
- builder: () => yargs__default['default'].options({
48
- branch: branchDefinition
48
+ builder: () => yargs__default["default"].options({
49
+ branch: branchDefinition,
50
+ 'error-on-no-global-key-translation': {
51
+ type: 'boolean',
52
+ describe: 'Throw an error when there is no translation for a global key',
53
+ default: false
54
+ }
49
55
  }),
50
56
  handler: async options => {
51
57
  await phrase.pull(options, config);
52
58
  }
53
59
  }).command({
54
60
  command: 'compile',
55
- builder: () => yargs__default['default'].options({
61
+ builder: () => yargs__default["default"].options({
56
62
  watch: {
57
63
  type: 'boolean',
58
64
  default: false
@@ -69,7 +75,6 @@ yargs__default['default'](process.argv.slice(2)).scriptName('vocab').option('con
69
75
  command: 'validate',
70
76
  handler: async () => {
71
77
  const valid = await core.validate(config);
72
-
73
78
  if (!valid) {
74
79
  throw new Error('Project invalid');
75
80
  }
@@ -13,15 +13,16 @@ var envCi__default = /*#__PURE__*/_interopDefault(envCi);
13
13
  /* eslint-disable no-console */
14
14
  const {
15
15
  branch
16
- } = envCi__default['default']();
16
+ } = envCi__default["default"]();
17
17
  const branchDefinition = {
18
18
  type: 'string',
19
19
  describe: 'The Phrase branch to target',
20
20
  default: branch || 'local-development'
21
21
  };
22
- let config = null; // eslint-disable-next-line @typescript-eslint/no-unused-expressions
22
+ let config = null;
23
23
 
24
- yargs__default['default'](process.argv.slice(2)).scriptName('vocab').option('config', {
24
+ // eslint-disable-next-line @typescript-eslint/no-unused-expressions
25
+ yargs__default["default"](process.argv.slice(2)).scriptName('vocab').option('config', {
25
26
  type: 'string',
26
27
  describe: 'Path to config file'
27
28
  }).middleware(async ({
@@ -31,9 +32,9 @@ yargs__default['default'](process.argv.slice(2)).scriptName('vocab').option('con
31
32
  console.log('Loaded config from', configPath || process.cwd());
32
33
  }).command({
33
34
  command: 'push',
34
- builder: () => yargs__default['default'].options({
35
+ builder: () => yargs__default["default"].options({
35
36
  branch: branchDefinition,
36
- deleteUnusedKeys: {
37
+ 'delete-unused-keys': {
37
38
  type: 'boolean',
38
39
  describe: 'Whether or not to delete unused keys after pushing',
39
40
  default: false
@@ -44,15 +45,20 @@ yargs__default['default'](process.argv.slice(2)).scriptName('vocab').option('con
44
45
  }
45
46
  }).command({
46
47
  command: 'pull',
47
- builder: () => yargs__default['default'].options({
48
- branch: branchDefinition
48
+ builder: () => yargs__default["default"].options({
49
+ branch: branchDefinition,
50
+ 'error-on-no-global-key-translation': {
51
+ type: 'boolean',
52
+ describe: 'Throw an error when there is no translation for a global key',
53
+ default: false
54
+ }
49
55
  }),
50
56
  handler: async options => {
51
57
  await phrase.pull(options, config);
52
58
  }
53
59
  }).command({
54
60
  command: 'compile',
55
- builder: () => yargs__default['default'].options({
61
+ builder: () => yargs__default["default"].options({
56
62
  watch: {
57
63
  type: 'boolean',
58
64
  default: false
@@ -69,7 +75,6 @@ yargs__default['default'](process.argv.slice(2)).scriptName('vocab').option('con
69
75
  command: 'validate',
70
76
  handler: async () => {
71
77
  const valid = await core.validate(config);
72
-
73
78
  if (!valid) {
74
79
  throw new Error('Project invalid');
75
80
  }
@@ -12,8 +12,9 @@ const branchDefinition = {
12
12
  describe: 'The Phrase branch to target',
13
13
  default: branch || 'local-development'
14
14
  };
15
- let config = null; // eslint-disable-next-line @typescript-eslint/no-unused-expressions
15
+ let config = null;
16
16
 
17
+ // eslint-disable-next-line @typescript-eslint/no-unused-expressions
17
18
  yargs(process.argv.slice(2)).scriptName('vocab').option('config', {
18
19
  type: 'string',
19
20
  describe: 'Path to config file'
@@ -26,7 +27,7 @@ yargs(process.argv.slice(2)).scriptName('vocab').option('config', {
26
27
  command: 'push',
27
28
  builder: () => yargs.options({
28
29
  branch: branchDefinition,
29
- deleteUnusedKeys: {
30
+ 'delete-unused-keys': {
30
31
  type: 'boolean',
31
32
  describe: 'Whether or not to delete unused keys after pushing',
32
33
  default: false
@@ -38,7 +39,12 @@ yargs(process.argv.slice(2)).scriptName('vocab').option('config', {
38
39
  }).command({
39
40
  command: 'pull',
40
41
  builder: () => yargs.options({
41
- branch: branchDefinition
42
+ branch: branchDefinition,
43
+ 'error-on-no-global-key-translation': {
44
+ type: 'boolean',
45
+ describe: 'Throw an error when there is no translation for a global key',
46
+ default: false
47
+ }
42
48
  }),
43
49
  handler: async options => {
44
50
  await pull(options, config);
@@ -62,7 +68,6 @@ yargs(process.argv.slice(2)).scriptName('vocab').option('config', {
62
68
  command: 'validate',
63
69
  handler: async () => {
64
70
  const valid = await validate(config);
65
-
66
71
  if (!valid) {
67
72
  throw new Error('Project invalid');
68
73
  }
package/package.json CHANGED
@@ -1,17 +1,21 @@
1
1
  {
2
2
  "name": "@vocab/cli",
3
- "version": "0.0.0-delete-unused-keys-20228144520",
3
+ "version": "0.0.0-global-key-support-20231025223328",
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.1.0",
14
- "@vocab/phrase": "^0.0.0-delete-unused-keys-20228144520",
17
+ "@vocab/core": "0.0.0-global-key-support-20231025223328",
18
+ "@vocab/phrase": "0.0.0-global-key-support-20231025223328",
15
19
  "env-ci": "^5.0.2",
16
20
  "fast-glob": "^3.2.4",
17
21
  "form-data": "^3.0.0",
@@ -24,4 +28,4 @@
24
28
  "@types/prettier": "^2.1.5",
25
29
  "@types/yargs": "^15.0.9"
26
30
  }
27
- }
31
+ }
package/CHANGELOG.md DELETED
@@ -1,198 +0,0 @@
1
- # @vocab/cli
2
-
3
- ## 0.0.0-delete-unused-keys-20228144520
4
-
5
- ### Minor Changes
6
-
7
- - [`fcd1482`](https://github.com/seek-oss/vocab/commit/fcd1482753e74274935f00ac0fc3afe1bf7f1989) Thanks [@askoufis](https://github.com/askoufis)! - Add an optional `deleteUnusedKeys` flag to the `push` function. If set to `true`, unused keys will be deleted from Phrase after translations are pushed.
8
-
9
- ### Patch Changes
10
-
11
- - Updated dependencies [[`fcd1482`](https://github.com/seek-oss/vocab/commit/fcd1482753e74274935f00ac0fc3afe1bf7f1989)]:
12
- - @vocab/phrase@0.0.0-delete-unused-keys-20228144520
13
-
14
- ## 1.1.0
15
-
16
- ### Minor Changes
17
-
18
- - [`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.
19
- See [the docs] for more information and examples.
20
-
21
- [the docs]: https://github.com/seek-oss/vocab#generated-languages
22
-
23
- ### Patch Changes
24
-
25
- - Updated dependencies [[`87333d7`](https://github.com/seek-oss/vocab/commit/87333d79c4a883b07d7d8f2c272b16e2243c49bd)]:
26
- - @vocab/core@1.1.0
27
-
28
- ## 1.0.1
29
-
30
- ### Patch Changes
31
-
32
- - [`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
33
-
34
- - Updated dependencies [[`3ec6dba`](https://github.com/seek-oss/vocab/commit/3ec6dbaad590299cc33e2d9d4a877576eb05853a)]:
35
- - @vocab/core@1.0.2
36
-
37
- ## 1.0.0
38
-
39
- ### Major Changes
40
-
41
- - [`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
42
-
43
- Release Vocab as v1.0.0 to signify a stable API and support future [semver versioning](https://semver.org/) releases.
44
-
45
- 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.
46
-
47
- ### Patch Changes
48
-
49
- - Updated dependencies [[`0074382`](https://github.com/seek-oss/vocab/commit/007438273ef70f5d5ded45777933651ad8df36f6), [`3031054`](https://github.com/seek-oss/vocab/commit/303105440851db6126f0606e1607745b27dd981c)]:
50
- - @vocab/core@1.0.0
51
- - @vocab/phrase@1.0.0
52
-
53
- ## 0.0.16
54
-
55
- ### Patch Changes
56
-
57
- - Updated dependencies [[`5b1fdc0`](https://github.com/seek-oss/vocab/commit/5b1fdc019522b12e7ef94b2fec57b54a9310d41c)]:
58
- - @vocab/core@0.0.11
59
- - @vocab/phrase@0.0.11
60
-
61
- ## 0.0.15
62
-
63
- ### Patch Changes
64
-
65
- - Updated dependencies [[`7c96a14`](https://github.com/seek-oss/vocab/commit/7c96a142f602132d38c1df1a47a1f4657dc5c94c)]:
66
- - @vocab/core@0.0.10
67
- - @vocab/phrase@0.0.10
68
-
69
- ## 0.0.14
70
-
71
- ### Patch Changes
72
-
73
- - Updated dependencies [[`3034bd3`](https://github.com/seek-oss/vocab/commit/3034bd3de610a9d1f3bfbd8caefa27064dee2710), [`c110745`](https://github.com/seek-oss/vocab/commit/c110745b79df1a8ade6b1d8a49e798b04a7b95e1)]:
74
- - @vocab/core@0.0.9
75
- - @vocab/phrase@0.0.9
76
-
77
- ## 0.0.13
78
-
79
- ### Patch Changes
80
-
81
- - Updated dependencies [[`f2fca67`](https://github.com/seek-oss/vocab/commit/f2fca679c66ae65405a0aa24f0a0e472026aad0d)]:
82
- - @vocab/core@0.0.8
83
- - @vocab/phrase@0.0.8
84
-
85
- ## 0.0.12
86
-
87
- ### Patch Changes
88
-
89
- - 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)]:
90
- - @vocab/core@0.0.7
91
- - @vocab/phrase@0.0.7
92
-
93
- ## 0.0.11
94
-
95
- ### Patch Changes
96
-
97
- - Updated dependencies [[`80a46c0`](https://github.com/seek-oss/vocab/commit/80a46c01a55408675f5822c3618519f80136c3ab), [`80a46c0`](https://github.com/seek-oss/vocab/commit/80a46c01a55408675f5822c3618519f80136c3ab)]:
98
- - @vocab/core@0.0.6
99
- - @vocab/phrase@0.0.6
100
-
101
- ## 0.0.10
102
-
103
- ### Patch Changes
104
-
105
- - Updated dependencies [[`371ed16`](https://github.com/seek-oss/vocab/commit/371ed16a232a04dab13afa7e2b352dfb6724eea4), [`c222d68`](https://github.com/seek-oss/vocab/commit/c222d68a3c0c24723a338eccb959798881f6a118)]:
106
- - @vocab/core@0.0.5
107
- - @vocab/phrase@0.0.5
108
-
109
- ## 0.0.9
110
-
111
- ### Patch Changes
112
-
113
- - [`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`.
114
-
115
- The new `vocab compile` step replaces `vocab generate-types` in creating a fully functional **translations.ts** file.
116
-
117
- 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.
118
-
119
- 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.
120
-
121
- See the [documentation](https://github.com/seek-oss/vocab) for further usage details.
122
-
123
- - Updated dependencies [[`5f5c581`](https://github.com/seek-oss/vocab/commit/5f5c581a65bff28729ee19e1ec0bdea488a9d6c2), [`02f943c`](https://github.com/seek-oss/vocab/commit/02f943ca892913b41f9e4720a72400777cf14b3d)]:
124
- - @vocab/core@0.0.4
125
- - @vocab/phrase@0.0.4
126
-
127
- ## 0.0.8
128
-
129
- ### Patch Changes
130
-
131
- - [`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
132
-
133
- * [`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
134
-
135
- * 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)]:
136
- - @vocab/core@0.0.3
137
- - @vocab/phrase@0.0.3
138
-
139
- ## 0.0.7
140
-
141
- ### Patch Changes
142
-
143
- - [`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
144
-
145
- The translate key function (`t`) will now infer the return type as ReactNode only when the tag syntax is used.
146
-
147
- - Updated dependencies [[`4710f34`](https://github.com/seek-oss/vocab/commit/4710f341f2827643e3eff69ef7e26d44ec6e8a2b)]:
148
- - @vocab/core@0.0.2
149
- - @vocab/phrase@0.0.2
150
-
151
- ## 0.0.6
152
-
153
- ### Patch Changes
154
-
155
- - [`45c4fe2`](https://github.com/seek-oss/vocab/commit/45c4fe273c5157475cb03ca57db662956ad5cbc9) Thanks [@mattcompiles](https://github.com/mattcompiles)! - Improved type definitions for `t` function
156
-
157
- * [`33aeb0f`](https://github.com/seek-oss/vocab/commit/33aeb0f210687b8ce57417e963bba9db7c7cb4e3) Thanks [@mattcompiles](https://github.com/mattcompiles)! - Respect prettier config for generated typescript declarations
158
-
159
- * Updated dependencies [[`2c7779f`](https://github.com/seek-oss/vocab/commit/2c7779f5384793af6a178f5ab4d56b6a9f09bc02)]:
160
- - @vocab/utils@0.0.6
161
-
162
- ## 0.0.5
163
-
164
- ### Patch Changes
165
-
166
- - Updated dependencies [[`f7b6b5c`](https://github.com/seek-oss/vocab/commit/f7b6b5c1cdb3f72bb0a3d0c5c7a3da844b2a1c87)]:
167
- - @vocab/utils@0.0.5
168
-
169
- ## 0.0.4
170
-
171
- ### Patch Changes
172
-
173
- - [`4589bce`](https://github.com/seek-oss/vocab/commit/4589bce912b7a8fb869e1c3a65d0c4c417043faf) Thanks [@mattcompiles](https://github.com/mattcompiles)! - Support language fallbacks through `extends` config
174
-
175
- * [`bf36f86`](https://github.com/seek-oss/vocab/commit/bf36f86a74ced4f42271b2f8fb128e995bb8c849) Thanks [@mattcompiles](https://github.com/mattcompiles)! - Use config location as CWD
176
-
177
- - [`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
178
-
179
- * [`870a74b`](https://github.com/seek-oss/vocab/commit/870a74b9a15ec2cb493c3de526c599b24fd5830d) Thanks [@mattcompiles](https://github.com/mattcompiles)! - Support custom config file locations
180
-
181
- * 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)]:
182
- - @vocab/utils@0.0.4
183
-
184
- ## 0.0.3
185
-
186
- ### Patch Changes
187
-
188
- - Updated dependencies [[`6f2c084`](https://github.com/seek-oss/vocab/commit/6f2c08419ce5773c589901fafa7bec7a1c94d2a5)]:
189
- - @vocab/utils@0.0.3
190
-
191
- ## 0.0.2
192
-
193
- ### Patch Changes
194
-
195
- - [`9f99ea7`](https://github.com/seek-oss/vocab/commit/9f99ea7c827ec4d7c21a485e17e3adbbd1c49319) Thanks [@jahredhope](https://github.com/jahredhope)! - Remove React as dependency and target node
196
-
197
- - Updated dependencies [[`9f99ea7`](https://github.com/seek-oss/vocab/commit/9f99ea7c827ec4d7c21a485e17e3adbbd1c49319)]:
198
- - @vocab/utils@0.0.2
package/src/index.ts DELETED
@@ -1,73 +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: () =>
33
- yargs.options({
34
- branch: branchDefinition,
35
- deleteUnusedKeys: {
36
- type: 'boolean',
37
- describe: 'Whether or not to delete unused keys after pushing',
38
- default: false,
39
- },
40
- }),
41
- handler: async (options) => {
42
- await push(options, config!);
43
- },
44
- })
45
- .command({
46
- command: 'pull',
47
- builder: () => yargs.options({ branch: branchDefinition }),
48
- handler: async (options) => {
49
- await pull(options, config!);
50
- },
51
- })
52
- .command({
53
- command: 'compile',
54
- builder: () =>
55
- yargs.options({
56
- watch: { type: 'boolean', default: false },
57
- }),
58
- handler: async ({ watch }) => {
59
- await compile({ watch }, config!);
60
- },
61
- })
62
- .command({
63
- command: 'validate',
64
- handler: async () => {
65
- const valid = await validate(config!);
66
-
67
- if (!valid) {
68
- throw new Error('Project invalid');
69
- }
70
- },
71
- })
72
- .help()
73
- .wrap(72).argv;