i18nexus-cli 3.7.0 → 3.8.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 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,17 @@ 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
+ )
50
54
  .action(options => {
51
55
  pull({
52
56
  apiKey: options.apiKey,
53
57
  version: options.ver,
54
58
  path: options.path,
55
59
  clean: options.clean,
60
+ compact: options.compact,
56
61
  confirmed: options.confirmed
57
62
  });
58
63
  });
@@ -268,10 +273,15 @@ program
268
273
  '-p, --path <path>',
269
274
  'The path to the destination folder in which translation files will be downloaded'
270
275
  )
276
+ .option(
277
+ '--compact',
278
+ 'Output JSON without extra whitespace (default is pretty-printed)'
279
+ )
271
280
  .action(options => {
272
281
  listen({
273
282
  apiKey: options.apiKey,
274
- path: options.path
283
+ path: options.path,
284
+ compact: options.compact
275
285
  });
276
286
  });
277
287
 
@@ -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 = false }) => {
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
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "i18nexus-cli",
3
- "version": "3.7.0",
3
+ "version": "3.8.0",
4
4
  "description": "Command line interface (CLI) for accessing the i18nexus API",
5
5
  "main": "index.js",
6
6
  "bin": {