@tolgee/cli 1.2.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.
@@ -10,7 +10,7 @@ async function loginHandler(key) {
10
10
  keyInfo = await RestClient.getApiKeyInformation(opts.apiUrl, key);
11
11
  }
12
12
  catch (e) {
13
- if (e instanceof HttpError && e.response.status === 403) {
13
+ if (e instanceof HttpError && e.response.status === 401) {
14
14
  error("Couldn't log in: the API key you provided is invalid.");
15
15
  process.exit(1);
16
16
  }
@@ -1,21 +1,33 @@
1
1
  import { Command, Option } from 'commander';
2
2
  import { unzipBuffer } from '../utils/zip.js';
3
3
  import { overwriteDir } from '../utils/overwriteDir.js';
4
- import { loading, success } from '../utils/logger.js';
4
+ import { error, loading, success } from '../utils/logger.js';
5
+ import { HttpError } from '../client/errors.js';
5
6
  async function fetchZipBlob(opts) {
6
7
  return opts.client.export.export({
7
8
  format: opts.format,
8
9
  languages: opts.languages,
9
10
  filterState: opts.states,
10
11
  structureDelimiter: opts.delimiter,
12
+ filterNamespace: opts.namespaces,
11
13
  });
12
14
  }
13
15
  async function pullHandler(path) {
14
16
  const opts = this.optsWithGlobals();
15
17
  await overwriteDir(path, opts.overwrite);
16
- const zipBlob = await loading('Fetching strings from Tolgee...', fetchZipBlob(opts));
17
- await loading('Extracting strings...', unzipBuffer(zipBlob, path));
18
- success('Done!');
18
+ try {
19
+ const zipBlob = await loading('Fetching strings from Tolgee...', fetchZipBlob(opts));
20
+ await loading('Extracting strings...', unzipBuffer(zipBlob, path));
21
+ success('Done!');
22
+ }
23
+ catch (e) {
24
+ if (e instanceof HttpError && e.response.status === 400) {
25
+ const res = await e.response.json();
26
+ error(`Please check if your parameters, including namespaces, are configured correctly. Tolgee responded with: ${res.code}`);
27
+ return;
28
+ }
29
+ throw e;
30
+ }
19
31
  }
20
32
  export default new Command()
21
33
  .name('pull')
@@ -32,5 +44,6 @@ export default new Command()
32
44
  .addOption(new Option('-d, --delimiter', 'Structure delimiter to use. By default, Tolgee interprets `.` as a nested structure. You can change the delimiter, or disable structure formatting by not specifying any value to the option')
33
45
  .default('.')
34
46
  .argParser((v) => v || ''))
47
+ .addOption(new Option('-n, --namespaces <namespaces...>', 'List of namespaces to pull. Defaults to all namespaces'))
35
48
  .option('-o, --overwrite', 'Whether to automatically overwrite existing files. BE CAREFUL, THIS WILL WIPE *ALL* THE CONTENTS OF THE TARGET FOLDER. If unspecified, the user will be prompted interactively, or the command will fail when in non-interactive')
36
49
  .action(pullHandler);
@@ -49,7 +49,7 @@ function parseConfig(rc) {
49
49
  if (typeof rc.delimiter !== 'string' && rc.delimiter !== null) {
50
50
  throw new Error('Invalid config: delimiter is not a string');
51
51
  }
52
- cfg.delimiter = rc.delimiter || void 0;
52
+ cfg.delimiter = rc.delimiter || '';
53
53
  }
54
54
  return cfg;
55
55
  }
package/dist/constants.js CHANGED
@@ -8,4 +8,4 @@ export const USER_AGENT = `Tolgee-CLI/${VERSION} (+https://github.com/tolgee/tol
8
8
  export const DEFAULT_API_URL = new URL('https://app.tolgee.io');
9
9
  export const API_KEY_PAT_PREFIX = 'tgpat_';
10
10
  export const API_KEY_PAK_PREFIX = 'tgpak_';
11
- export const SDKS = ['react'];
11
+ export const SDKS = ['react', 'vue', 'svelte'];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tolgee/cli",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "type": "module",
5
5
  "description": "A tool to interact with the Tolgee Platform through CLI",
6
6
  "repository": {