i18nexus-cli 3.7.0 → 3.8.1
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 +8 -0
- package/bin/index.js +13 -1
- package/commands/listen.js +5 -3
- package/commands/pull.js +4 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -92,6 +92,7 @@ If you wish to download your files to a different directory, you can use the `--
|
|
|
92
92
|
| `--ver` or `-v` | `latest` |
|
|
93
93
|
| `--confirmed` | `false` |
|
|
94
94
|
| `--clean` | `false` |
|
|
95
|
+
| `--compact` | `false` |
|
|
95
96
|
|
|
96
97
|
### Notes
|
|
97
98
|
|
|
@@ -110,6 +111,9 @@ Downloads only translations that have been confirmed in i18nexus
|
|
|
110
111
|
`--clean`
|
|
111
112
|
Before download, clears your destination folder specified in --path. As a safety precaution, this only deletes folders with names that match a simple language code regex. You should still ensure you are not storing any files in your destination folder that you do not want deleted.
|
|
112
113
|
|
|
114
|
+
`--compact`
|
|
115
|
+
Output JSON without extra whitespace (default is pretty-printed)
|
|
116
|
+
|
|
113
117
|
## Personal Access Tokens
|
|
114
118
|
|
|
115
119
|
The following commands require a Personal Access Token (PAT) because they write data to your i18nexus project. PATs are created in your i18nexus account dashboard.
|
|
@@ -336,6 +340,7 @@ Many developers prefer to run this automatically alongside their development ser
|
|
|
336
340
|
| ------------------- | --------- | ----------------------- |
|
|
337
341
|
| `--api-key` or `-k` | ✔ | |
|
|
338
342
|
| `--path` or `-p` | | See `pull` default path |
|
|
343
|
+
| `--compact` | | `false` |
|
|
339
344
|
|
|
340
345
|
### Notes
|
|
341
346
|
|
|
@@ -344,3 +349,6 @@ Your project API key (Can also be set using environment variable `I18NEXUS_API_K
|
|
|
344
349
|
|
|
345
350
|
`--path`
|
|
346
351
|
The path to the destination folder in which translation files will be downloaded
|
|
352
|
+
|
|
353
|
+
`--compact`
|
|
354
|
+
Output JSON without extra whitespace (default is pretty-printed)
|
package/bin/index.js
CHANGED
|
@@ -47,12 +47,18 @@ program
|
|
|
47
47
|
'Removes and rebuilds destination folder before download',
|
|
48
48
|
false
|
|
49
49
|
)
|
|
50
|
+
.option(
|
|
51
|
+
'--compact',
|
|
52
|
+
'Output JSON without extra whitespace (default is pretty-printed)',
|
|
53
|
+
false
|
|
54
|
+
)
|
|
50
55
|
.action(options => {
|
|
51
56
|
pull({
|
|
52
57
|
apiKey: options.apiKey,
|
|
53
58
|
version: options.ver,
|
|
54
59
|
path: options.path,
|
|
55
60
|
clean: options.clean,
|
|
61
|
+
compact: options.compact,
|
|
56
62
|
confirmed: options.confirmed
|
|
57
63
|
});
|
|
58
64
|
});
|
|
@@ -268,10 +274,16 @@ program
|
|
|
268
274
|
'-p, --path <path>',
|
|
269
275
|
'The path to the destination folder in which translation files will be downloaded'
|
|
270
276
|
)
|
|
277
|
+
.option(
|
|
278
|
+
'--compact',
|
|
279
|
+
'Output JSON without extra whitespace (default is pretty-printed)',
|
|
280
|
+
false
|
|
281
|
+
)
|
|
271
282
|
.action(options => {
|
|
272
283
|
listen({
|
|
273
284
|
apiKey: options.apiKey,
|
|
274
|
-
path: options.path
|
|
285
|
+
path: options.path,
|
|
286
|
+
compact: options.compact
|
|
275
287
|
});
|
|
276
288
|
});
|
|
277
289
|
|
package/commands/listen.js
CHANGED
|
@@ -5,14 +5,15 @@ const pull = require('../commands/pull');
|
|
|
5
5
|
const baseUrl = require('../baseUrl');
|
|
6
6
|
const { URL } = require('url');
|
|
7
7
|
|
|
8
|
-
const listen = async ({ apiKey, path }) => {
|
|
8
|
+
const listen = async ({ apiKey, path, compact }) => {
|
|
9
9
|
await pull(
|
|
10
10
|
{
|
|
11
11
|
apiKey,
|
|
12
12
|
version: 'latest',
|
|
13
13
|
path,
|
|
14
14
|
clean: false,
|
|
15
|
-
confirmed: false
|
|
15
|
+
confirmed: false,
|
|
16
|
+
compact
|
|
16
17
|
},
|
|
17
18
|
{
|
|
18
19
|
logging: false,
|
|
@@ -52,7 +53,8 @@ const listen = async ({ apiKey, path }) => {
|
|
|
52
53
|
version: 'latest',
|
|
53
54
|
path,
|
|
54
55
|
clean: false,
|
|
55
|
-
confirmed: false
|
|
56
|
+
confirmed: false,
|
|
57
|
+
compact
|
|
56
58
|
},
|
|
57
59
|
{
|
|
58
60
|
logging: false,
|
package/commands/pull.js
CHANGED
|
@@ -127,13 +127,15 @@ const pull = async (opt, internalOptions = {}) => {
|
|
|
127
127
|
cleanDirectory(path);
|
|
128
128
|
}
|
|
129
129
|
|
|
130
|
+
const spacing = opt.compact ? 0 : 2;
|
|
131
|
+
|
|
130
132
|
if (projectLibrary === 'next-intl') {
|
|
131
133
|
for (let lng in translations) {
|
|
132
134
|
fs.mkdirSync(path, { recursive: true });
|
|
133
135
|
|
|
134
136
|
fs.writeFileSync(
|
|
135
137
|
`${path}/${lng}.json`,
|
|
136
|
-
JSON.stringify(translations[lng])
|
|
138
|
+
JSON.stringify(translations[lng], null, spacing)
|
|
137
139
|
);
|
|
138
140
|
}
|
|
139
141
|
} else {
|
|
@@ -144,7 +146,7 @@ const pull = async (opt, internalOptions = {}) => {
|
|
|
144
146
|
for (let namespace in translations[lng]) {
|
|
145
147
|
fs.writeFileSync(
|
|
146
148
|
`${lngFilePath}/${namespace}.json`,
|
|
147
|
-
JSON.stringify(translations[lng][namespace])
|
|
149
|
+
JSON.stringify(translations[lng][namespace], null, spacing)
|
|
148
150
|
);
|
|
149
151
|
}
|
|
150
152
|
}
|