@tolgee/cli 1.1.0 โ†’ 1.1.2

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.
Files changed (43) hide show
  1. package/README.md +11 -8
  2. package/dist/client/errors.js +1 -5
  3. package/dist/client/export.js +1 -4
  4. package/dist/client/import.js +5 -11
  5. package/dist/client/index.js +17 -23
  6. package/dist/client/internal/requester.js +14 -20
  7. package/dist/client/internal/schema.generated.js +1 -2
  8. package/dist/client/internal/schema.utils.js +1 -2
  9. package/dist/client/languages.js +1 -4
  10. package/dist/client/project.js +1 -4
  11. package/dist/commands/extract/check.js +11 -13
  12. package/dist/commands/extract/print.js +10 -12
  13. package/dist/commands/extract.js +8 -13
  14. package/dist/commands/login.js +16 -22
  15. package/dist/commands/pull.js +12 -14
  16. package/dist/commands/push.js +28 -30
  17. package/dist/commands/sync/compare.js +18 -23
  18. package/dist/commands/sync/sync.js +34 -39
  19. package/dist/commands/sync/syncUtils.js +10 -18
  20. package/dist/config/credentials.js +16 -25
  21. package/dist/config/tolgeerc.js +11 -14
  22. package/dist/constants.js +11 -18
  23. package/dist/extractor/extractor.js +13 -19
  24. package/dist/extractor/index.js +1 -2
  25. package/dist/extractor/machines/comments.js +10 -15
  26. package/dist/extractor/machines/react.js +36 -41
  27. package/dist/extractor/machines/shared/comments.js +3 -6
  28. package/dist/extractor/machines/shared/properties.js +13 -15
  29. package/dist/extractor/machines/svelte.js +43 -48
  30. package/dist/extractor/runner.js +8 -16
  31. package/dist/extractor/tokenizer.js +20 -21
  32. package/dist/extractor/warnings.js +9 -14
  33. package/dist/extractor/worker.js +23 -28
  34. package/dist/index.js +53 -58
  35. package/dist/options.js +14 -17
  36. package/dist/utils/ask.js +4 -12
  37. package/dist/utils/configPath.js +10 -10
  38. package/dist/utils/deferred.js +1 -5
  39. package/dist/utils/logger.js +8 -19
  40. package/dist/utils/moduleLoader.js +7 -15
  41. package/dist/utils/overwriteDir.js +13 -17
  42. package/dist/utils/zip.js +11 -16
  43. package/package.json +33 -30
package/README.md CHANGED
@@ -1,22 +1,25 @@
1
1
  # Tolgee CLI ๐Ÿ
2
2
 
3
- An experimental ๐Ÿงช command line tool to interact with Tolgee directly from your terminal.
3
+ A CLI tool to interact with Tolgee directly from your terminal.
4
4
 
5
- The CLI lets you pull strings from the Tolgee platform into your projects, push local strings to the Tolgee platform,
5
+ The Tolgee CLI lets you pull strings from the Tolgee platform into your projects, push local strings to the Tolgee platform,
6
6
  extract strings from your code, and much more!
7
7
 
8
- - Pull requests welcome! ๐Ÿคฉ
8
+ ![Tolgee CLI screenshot](tolgee-cli-screenshot.png)
9
9
 
10
10
  ## Installation
11
11
  The Tolgee CLI is published as a NPM package. You simply need to install it, and you're good to go!
12
+
12
13
  ```sh
14
+ # npm
13
15
  npm i --global @tolgee/cli
14
- ```
15
16
 
16
- > **Warning**: The Tolgee CLI is currently experimental and subject to bugs. Breaking changes may happen before stable release!
17
- >
18
- > Help us reach stable version faster by reporting any bug you encounter on the [issue tracker](https://github.com/tolgee/tolgee-cli/issues/new?labels=bug).
19
- > Feedback is also greatly appreciated!
17
+ # Yarn
18
+ yarn global add @tolgee/cli
19
+
20
+ # pnpm
21
+ pnpm add --global @tolgee/cli
22
+ ```
20
23
 
21
24
  See our [documentation](https://tolgee.io/tolgee-cli/installation) for more information.
22
25
 
@@ -1,7 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.HttpError = void 0;
4
- class HttpError extends Error {
1
+ export class HttpError extends Error {
5
2
  request;
6
3
  response;
7
4
  constructor(request, response, options) {
@@ -33,4 +30,3 @@ class HttpError extends Error {
33
30
  return `Unknown error (HTTP ${this.response.status})`;
34
31
  }
35
32
  }
36
- exports.HttpError = HttpError;
@@ -1,6 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- class ExportClient {
1
+ export default class ExportClient {
4
2
  requester;
5
3
  constructor(requester) {
6
4
  this.requester = requester;
@@ -20,4 +18,3 @@ class ExportClient {
20
18
  });
21
19
  }
22
20
  }
23
- exports.default = ExportClient;
@@ -1,17 +1,12 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const form_data_1 = __importDefault(require("form-data"));
7
- const errors_1 = require("./errors");
8
- class ImportClient {
1
+ import FormData from 'form-data';
2
+ import { HttpError } from './errors.js';
3
+ export default class ImportClient {
9
4
  requester;
10
5
  constructor(requester) {
11
6
  this.requester = requester;
12
7
  }
13
8
  async addFiles(req) {
14
- const body = new form_data_1.default();
9
+ const body = new FormData();
15
10
  for (const file of req.files) {
16
11
  body.append('files', file.data, { filepath: file.name });
17
12
  }
@@ -52,10 +47,9 @@ class ImportClient {
52
47
  await this.deleteImport();
53
48
  }
54
49
  catch (e) {
55
- if (e instanceof errors_1.HttpError && e.response.status === 404)
50
+ if (e instanceof HttpError && e.response.status === 404)
56
51
  return;
57
52
  throw e;
58
53
  }
59
54
  }
60
55
  }
61
- exports.default = ImportClient;
@@ -1,16 +1,11 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const base32_decode_1 = __importDefault(require("base32-decode"));
7
- const requester_1 = __importDefault(require("./internal/requester"));
8
- const project_1 = __importDefault(require("./project"));
9
- const languages_1 = __importDefault(require("./languages"));
10
- const import_1 = __importDefault(require("./import"));
11
- const export_1 = __importDefault(require("./export"));
12
- const constants_1 = require("../constants");
13
- class RestClient {
1
+ import base32Decode from 'base32-decode';
2
+ import Requester from './internal/requester.js';
3
+ import ProjectClient from './project.js';
4
+ import LanguagesClient from './languages.js';
5
+ import ImportClient from './import.js';
6
+ import ExportClient from './export.js';
7
+ import { API_KEY_PAK_PREFIX } from '../constants.js';
8
+ export default class RestClient {
14
9
  params;
15
10
  requester;
16
11
  project;
@@ -19,11 +14,11 @@ class RestClient {
19
14
  export;
20
15
  constructor(params) {
21
16
  this.params = params;
22
- this.requester = new requester_1.default(params);
23
- this.project = new project_1.default(this.requester);
24
- this.languages = new languages_1.default(this.requester);
25
- this.import = new import_1.default(this.requester);
26
- this.export = new export_1.default(this.requester);
17
+ this.requester = new Requester(params);
18
+ this.project = new ProjectClient(this.requester);
19
+ this.languages = new LanguagesClient(this.requester);
20
+ this.import = new ImportClient(this.requester);
21
+ this.export = new ExportClient(this.requester);
27
22
  }
28
23
  async getProjectApiKeyInformation() {
29
24
  return this.requester.requestJson({
@@ -35,24 +30,24 @@ class RestClient {
35
30
  return this.params.projectId;
36
31
  }
37
32
  static projectIdFromKey(key) {
38
- const keyBuffer = (0, base32_decode_1.default)(key.slice(constants_1.API_KEY_PAK_PREFIX.length).toUpperCase(), 'RFC4648');
33
+ const keyBuffer = base32Decode(key.slice(API_KEY_PAK_PREFIX.length).toUpperCase(), 'RFC4648');
39
34
  const decoded = Buffer.from(keyBuffer).toString('utf8');
40
35
  return Number(decoded.split('_')[0]);
41
36
  }
42
37
  static getProjectApiKeyInformation(api, key) {
43
- return new requester_1.default({ apiUrl: api, apiKey: key }).requestJson({
38
+ return new Requester({ apiUrl: api, apiKey: key }).requestJson({
44
39
  path: '/v2/api-keys/current',
45
40
  method: 'GET',
46
41
  });
47
42
  }
48
43
  static getPersonalAccessTokenInformation(api, key) {
49
- return new requester_1.default({ apiUrl: api, apiKey: key }).requestJson({
44
+ return new Requester({ apiUrl: api, apiKey: key }).requestJson({
50
45
  path: '/v2/pats/current',
51
46
  method: 'GET',
52
47
  });
53
48
  }
54
49
  static async getApiKeyInformation(api, key) {
55
- if (key.startsWith(constants_1.API_KEY_PAK_PREFIX)) {
50
+ if (key.startsWith(API_KEY_PAK_PREFIX)) {
56
51
  const info = await RestClient.getProjectApiKeyInformation(api, key);
57
52
  const username = info.userFullName || info.username || '<unknown user>';
58
53
  return {
@@ -76,4 +71,3 @@ class RestClient {
76
71
  };
77
72
  }
78
73
  }
79
- exports.default = RestClient;
@@ -1,15 +1,10 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const undici_1 = require("undici");
7
- const undici_2 = require("undici");
8
- const form_data_1 = __importDefault(require("form-data"));
9
- const errors_1 = require("../errors");
10
- const logger_1 = require("../../utils/logger");
11
- const constants_1 = require("../../constants");
12
- class Requester {
1
+ import { Request } from 'undici';
2
+ import { fetch } from 'undici';
3
+ import FormData from 'form-data';
4
+ import { HttpError } from '../errors.js';
5
+ import { debug } from '../../utils/logger.js';
6
+ import { USER_AGENT } from '../../constants.js';
7
+ export default class Requester {
13
8
  params;
14
9
  constructor(params) {
15
10
  this.params = params;
@@ -44,12 +39,12 @@ class Requester {
44
39
  }
45
40
  const headers = {
46
41
  ...(req.headers || {}),
47
- 'user-agent': constants_1.USER_AGENT,
42
+ 'user-agent': USER_AGENT,
48
43
  'x-api-key': this.params.apiKey,
49
44
  };
50
45
  let body = undefined;
51
46
  if (req.body) {
52
- if (req.body instanceof form_data_1.default) {
47
+ if (req.body instanceof FormData) {
53
48
  const header = `multipart/form-data; boundary=${req.body.getBoundary()}`;
54
49
  headers['content-type'] = header;
55
50
  body = req.body.getBuffer();
@@ -59,16 +54,16 @@ class Requester {
59
54
  body = JSON.stringify(req.body);
60
55
  }
61
56
  }
62
- const request = new undici_1.Request(url, {
57
+ const request = new Request(url, {
63
58
  method: req.method,
64
59
  headers: headers,
65
60
  body: body,
66
61
  });
67
- (0, logger_1.debug)(`[HTTP] Requesting: ${request.method} ${request.url}`);
68
- const response = await (0, undici_2.fetch)(request);
69
- (0, logger_1.debug)(`[HTTP] ${request.method} ${request.url} -> ${response.status} ${response.statusText}`);
62
+ debug(`[HTTP] Requesting: ${request.method} ${request.url}`);
63
+ const response = await fetch(request);
64
+ debug(`[HTTP] ${request.method} ${request.url} -> ${response.status} ${response.statusText}`);
70
65
  if (!response.ok)
71
- throw new errors_1.HttpError(request, response);
66
+ throw new HttpError(request, response);
72
67
  return response;
73
68
  }
74
69
  /**
@@ -142,4 +137,3 @@ class Requester {
142
137
  return view;
143
138
  }
144
139
  }
145
- exports.default = Requester;
@@ -1,6 +1,5 @@
1
- "use strict";
2
1
  /**
3
2
  * This file was auto-generated by openapi-typescript.
4
3
  * Do not make direct changes to the file.
5
4
  */
6
- Object.defineProperty(exports, "__esModule", { value: true });
5
+ export {};
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -1,6 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- class LanguagesClient {
1
+ export default class LanguagesClient {
4
2
  requester;
5
3
  constructor(requester) {
6
4
  this.requester = requester;
@@ -13,4 +11,3 @@ class LanguagesClient {
13
11
  });
14
12
  }
15
13
  }
16
- exports.default = LanguagesClient;
@@ -1,6 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- class ProjectClient {
1
+ export default class ProjectClient {
4
2
  requester;
5
3
  constructor(requester) {
6
4
  this.requester = requester;
@@ -41,4 +39,3 @@ class ProjectClient {
41
39
  });
42
40
  }
43
41
  }
44
- exports.default = ProjectClient;
@@ -1,30 +1,28 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const path_1 = require("path");
4
- const commander_1 = require("commander");
5
- const runner_1 = require("../../extractor/runner");
6
- const warnings_1 = require("../../extractor/warnings");
7
- const logger_1 = require("../../utils/logger");
1
+ import { relative } from 'path';
2
+ import { Command } from 'commander';
3
+ import { extractKeysOfFiles } from '../../extractor/runner.js';
4
+ import { WarningMessages, emitGitHubWarning, } from '../../extractor/warnings.js';
5
+ import { loading } from '../../utils/logger.js';
8
6
  async function lintHandler(filesPattern) {
9
7
  const opts = this.optsWithGlobals();
10
- const extracted = await (0, logger_1.loading)('Analyzing code...', (0, runner_1.extractKeysOfFiles)(filesPattern, opts.extractor));
8
+ const extracted = await loading('Analyzing code...', extractKeysOfFiles(filesPattern, opts.extractor));
11
9
  let warningCount = 0;
12
10
  let filesCount = 0;
13
11
  for (const [file, { warnings }] of extracted) {
14
12
  if (warnings.length) {
15
13
  warningCount += warnings.length;
16
14
  filesCount++;
17
- const relFile = (0, path_1.relative)(process.cwd(), file);
15
+ const relFile = relative(process.cwd(), file);
18
16
  console.log('%s:', relFile);
19
17
  for (const warning of warnings) {
20
- if (warning.warning in warnings_1.WarningMessages) {
21
- const { name } = warnings_1.WarningMessages[warning.warning];
18
+ if (warning.warning in WarningMessages) {
19
+ const { name } = WarningMessages[warning.warning];
22
20
  console.log('\tline %d: %s', warning.line, name);
23
21
  }
24
22
  else {
25
23
  console.log('\tline %d: %s', warning.line, warning.warning);
26
24
  }
27
- (0, warnings_1.emitGitHubWarning)(warning.warning, file, warning.line);
25
+ emitGitHubWarning(warning.warning, file, warning.line);
28
26
  }
29
27
  }
30
28
  }
@@ -35,7 +33,7 @@ async function lintHandler(filesPattern) {
35
33
  }
36
34
  console.log('No issues found.');
37
35
  }
38
- exports.default = new commander_1.Command('check')
36
+ export default new Command('check')
39
37
  .description('Checks if the keys can be extracted automatically, and reports problems if any')
40
38
  .argument('<pattern>', 'File pattern to include (hint: make sure to escape it in quotes, or your shell might attempt to unroll some tokens like *)')
41
39
  .action(lintHandler);
@@ -1,18 +1,16 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const path_1 = require("path");
4
- const commander_1 = require("commander");
5
- const runner_1 = require("../../extractor/runner");
6
- const warnings_1 = require("../../extractor/warnings");
7
- const logger_1 = require("../../utils/logger");
1
+ import { relative } from 'path';
2
+ import { Command } from 'commander';
3
+ import { extractKeysOfFiles } from '../../extractor/runner.js';
4
+ import { WarningMessages } from '../../extractor/warnings.js';
5
+ import { loading } from '../../utils/logger.js';
8
6
  async function printHandler(filesPattern) {
9
7
  const opts = this.optsWithGlobals();
10
- const extracted = await (0, logger_1.loading)('Analyzing code...', (0, runner_1.extractKeysOfFiles)(filesPattern, opts.extractor));
8
+ const extracted = await loading('Analyzing code...', extractKeysOfFiles(filesPattern, opts.extractor));
11
9
  let warningCount = 0;
12
10
  const keySet = new Set();
13
11
  for (const [file, { keys, warnings }] of extracted) {
14
12
  if (keys.length) {
15
- const relFile = (0, path_1.relative)(process.cwd(), file);
13
+ const relFile = relative(process.cwd(), file);
16
14
  console.log('%d key%s found in %s:', keys.length, keys.length !== 1 ? 's' : '', relFile);
17
15
  for (const key of keys) {
18
16
  keySet.add(key);
@@ -29,8 +27,8 @@ async function printHandler(filesPattern) {
29
27
  warningCount += warnings.length;
30
28
  console.log('%d warning%s %s emitted during extraction:', warnings.length, warnings.length !== 1 ? 's' : '', warnings.length !== 1 ? 'were' : 'was');
31
29
  for (const warning of warnings) {
32
- if (warning.warning in warnings_1.WarningMessages) {
33
- const { name } = warnings_1.WarningMessages[warning.warning];
30
+ if (warning.warning in WarningMessages) {
31
+ const { name } = WarningMessages[warning.warning];
34
32
  console.log('\tline %d: %s', warning.line, name);
35
33
  }
36
34
  else {
@@ -45,7 +43,7 @@ async function printHandler(filesPattern) {
45
43
  console.log('Total unique keys found: %d', keySet.size);
46
44
  console.log('Total warnings: %d', warningCount);
47
45
  }
48
- exports.default = new commander_1.Command('print')
46
+ export default new Command('print')
49
47
  .description('Prints extracted data to the console')
50
48
  .argument('<pattern>', 'File glob pattern to include (hint: make sure to escape it in quotes, or your shell might attempt to unroll some tokens like *)')
51
49
  .action(printHandler);
@@ -1,14 +1,9 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const commander_1 = require("commander");
7
- const print_1 = __importDefault(require("./extract/print"));
8
- const check_1 = __importDefault(require("./extract/check"));
9
- const options_1 = require("../options");
10
- exports.default = new commander_1.Command('extract')
1
+ import { Command } from 'commander';
2
+ import extractPrint from './extract/print.js';
3
+ import extractCheck from './extract/check.js';
4
+ import { EXTRACTOR } from '../options.js';
5
+ export default new Command('extract')
11
6
  .description('Extracts strings from your projects')
12
- .addOption(options_1.EXTRACTOR)
13
- .addCommand(print_1.default)
14
- .addCommand(check_1.default);
7
+ .addOption(EXTRACTOR)
8
+ .addCommand(extractPrint)
9
+ .addCommand(extractCheck);
@@ -1,48 +1,42 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.Logout = exports.Login = void 0;
7
- const commander_1 = require("commander");
8
- const client_1 = __importDefault(require("../client"));
9
- const errors_1 = require("../client/errors");
10
- const credentials_1 = require("../config/credentials");
11
- const logger_1 = require("../utils/logger");
1
+ import { Command } from 'commander';
2
+ import RestClient from '../client/index.js';
3
+ import { HttpError } from '../client/errors.js';
4
+ import { saveApiKey, removeApiKeys, clearAuthStore, } from '../config/credentials.js';
5
+ import { success, error } from '../utils/logger.js';
12
6
  async function loginHandler(key) {
13
7
  const opts = this.optsWithGlobals();
14
8
  let keyInfo;
15
9
  try {
16
- keyInfo = await client_1.default.getApiKeyInformation(opts.apiUrl, key);
10
+ keyInfo = await RestClient.getApiKeyInformation(opts.apiUrl, key);
17
11
  }
18
12
  catch (e) {
19
- if (e instanceof errors_1.HttpError && e.response.status === 403) {
20
- (0, logger_1.error)("Couldn't log in: the API key you provided is invalid.");
13
+ if (e instanceof HttpError && e.response.status === 403) {
14
+ error("Couldn't log in: the API key you provided is invalid.");
21
15
  process.exit(1);
22
16
  }
23
17
  throw e;
24
18
  }
25
- await (0, credentials_1.saveApiKey)(opts.apiUrl, keyInfo);
26
- (0, logger_1.success)(keyInfo.type === 'PAK'
19
+ await saveApiKey(opts.apiUrl, keyInfo);
20
+ success(keyInfo.type === 'PAK'
27
21
  ? `Logged in as ${keyInfo.username} on ${opts.apiUrl.hostname} for project ${keyInfo.project.name} (#${keyInfo.project.id}). Welcome back!`
28
22
  : `Logged in as ${keyInfo.username} on ${opts.apiUrl.hostname}. Welcome back!`);
29
23
  }
30
24
  async function logoutHandler() {
31
25
  const opts = this.optsWithGlobals();
32
26
  if (opts.all) {
33
- await (0, credentials_1.clearAuthStore)();
34
- (0, logger_1.success)("You've been logged out of all Tolgee instances you were logged in.");
27
+ await clearAuthStore();
28
+ success("You've been logged out of all Tolgee instances you were logged in.");
35
29
  return;
36
30
  }
37
- await (0, credentials_1.removeApiKeys)(opts.apiUrl);
38
- (0, logger_1.success)(`You're now logged out of ${opts.apiUrl.hostname}.`);
31
+ await removeApiKeys(opts.apiUrl);
32
+ success(`You're now logged out of ${opts.apiUrl.hostname}.`);
39
33
  }
40
- exports.Login = new commander_1.Command()
34
+ export const Login = new Command()
41
35
  .name('login')
42
36
  .description('Login to Tolgee with an API key. You can be logged into multiple Tolgee instances at the same time by using --api-url')
43
37
  .argument('<API Key>', 'The API key. Can be either a personal access token, or a project key')
44
38
  .action(loginHandler);
45
- exports.Logout = new commander_1.Command()
39
+ export const Logout = new Command()
46
40
  .name('logout')
47
41
  .description('Logs out of Tolgee')
48
42
  .option('--all', "Log out of *ALL* Tolgee instances you're logged into")
@@ -1,9 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const commander_1 = require("commander");
4
- const zip_1 = require("../utils/zip");
5
- const overwriteDir_1 = require("../utils/overwriteDir");
6
- const logger_1 = require("../utils/logger");
1
+ import { Command, Option } from 'commander';
2
+ import { unzipBuffer } from '../utils/zip.js';
3
+ import { overwriteDir } from '../utils/overwriteDir.js';
4
+ import { loading, success } from '../utils/logger.js';
7
5
  async function fetchZipBlob(opts) {
8
6
  return opts.client.export.export({
9
7
  format: opts.format,
@@ -14,24 +12,24 @@ async function fetchZipBlob(opts) {
14
12
  }
15
13
  async function pullHandler(path) {
16
14
  const opts = this.optsWithGlobals();
17
- await (0, overwriteDir_1.overwriteDir)(path, opts.overwrite);
18
- const zipBlob = await (0, logger_1.loading)('Fetching strings from Tolgee...', fetchZipBlob(opts));
19
- await (0, logger_1.loading)('Extracting strings...', (0, zip_1.unzipBuffer)(zipBlob, path));
20
- (0, logger_1.success)('Done!');
15
+ 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!');
21
19
  }
22
- exports.default = new commander_1.Command()
20
+ export default new Command()
23
21
  .name('pull')
24
22
  .description('Pulls translations to Tolgee')
25
23
  .argument('<path>', 'Destination path where translation files will be stored in')
26
- .addOption(new commander_1.Option('-f, --format <format>', 'Format of the exported files')
24
+ .addOption(new Option('-f, --format <format>', 'Format of the exported files')
27
25
  .choices(['JSON', 'XLIFF'])
28
26
  .default('JSON')
29
27
  .argParser((v) => v.toUpperCase()))
30
28
  .option('-l, --languages <languages...>', 'List of languages to pull. Leave unspecified to export them all')
31
- .addOption(new commander_1.Option('-s, --states <states...>', 'List of translation states to include. Defaults all except untranslated')
29
+ .addOption(new Option('-s, --states <states...>', 'List of translation states to include. Defaults all except untranslated')
32
30
  .choices(['UNTRANSLATED', 'TRANSLATED', 'REVIEWED'])
33
31
  .argParser((v, a) => [v.toUpperCase(), ...(a || [])]))
34
- .addOption(new commander_1.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')
32
+ .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')
35
33
  .default('.')
36
34
  .argParser((v) => v || ''))
37
35
  .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')