@tolgee/cli 2.8.4 → 2.10.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.
Files changed (56) hide show
  1. package/dist/cli.js +116 -94
  2. package/dist/client/ApiClient.js +40 -32
  3. package/dist/client/ExportClient.js +24 -11
  4. package/dist/client/ImportClient.js +25 -16
  5. package/dist/client/TolgeeClient.js +1 -5
  6. package/dist/client/errorFromLoadable.js +3 -2
  7. package/dist/client/getApiKeyInformation.js +16 -6
  8. package/dist/commands/extract/check.js +38 -27
  9. package/dist/commands/extract/print.js +46 -35
  10. package/dist/commands/login.js +39 -26
  11. package/dist/commands/pull.js +60 -43
  12. package/dist/commands/push.js +167 -117
  13. package/dist/commands/sync/compare.js +43 -31
  14. package/dist/commands/sync/sync.js +118 -99
  15. package/dist/commands/sync/syncUtils.js +2 -1
  16. package/dist/commands/tag.js +52 -38
  17. package/dist/config/credentials.js +110 -93
  18. package/dist/config/tolgeerc.js +51 -35
  19. package/dist/extractor/extractor.js +45 -31
  20. package/dist/extractor/parser/extractComment.js +1 -1
  21. package/dist/extractor/parser/generateReport.js +8 -6
  22. package/dist/extractor/parser/iterator.js +2 -1
  23. package/dist/extractor/parser/mergerMachine.js +2 -11
  24. package/dist/extractor/parser/nodeUtils.js +1 -1
  25. package/dist/extractor/parser/parser.js +4 -2
  26. package/dist/extractor/parser/rules/tNsSourceGeneral.js +1 -1
  27. package/dist/extractor/parser/tree/getTranslateProps.js +21 -16
  28. package/dist/extractor/parser/tree/getValue.js +1 -1
  29. package/dist/extractor/parser/tree/parseTag.js +1 -1
  30. package/dist/extractor/parserNgx/ParserNgx.js +1 -3
  31. package/dist/extractor/parserNgx/ngxMapper.js +2 -1
  32. package/dist/extractor/parserNgx/ngxTreeTransform.js +3 -2
  33. package/dist/extractor/parserNgx/rules/translatePipe.js +1 -1
  34. package/dist/extractor/parserReact/ParserReact.js +1 -3
  35. package/dist/extractor/parserSvelte/ParserSvelte.js +1 -3
  36. package/dist/extractor/parserVue/ParserVue.js +1 -3
  37. package/dist/extractor/parserVue/tokenMergers/hyphenPropsMerger.js +1 -4
  38. package/dist/extractor/parserVue/vueTreeTransform.js +13 -2
  39. package/dist/extractor/runner.js +53 -39
  40. package/dist/extractor/tokenizer.js +50 -35
  41. package/dist/extractor/visualizers/printTokens.js +2 -1
  42. package/dist/extractor/visualizers/visualizeRules.js +4 -7
  43. package/dist/extractor/warnings.js +3 -2
  44. package/dist/extractor/worker.js +29 -16
  45. package/dist/options.js +2 -1
  46. package/dist/utils/apiKeyList.js +31 -19
  47. package/dist/utils/ask.js +35 -21
  48. package/dist/utils/checkPathNotAFile.js +22 -11
  49. package/dist/utils/filesTemplate.js +147 -0
  50. package/dist/utils/mapExportFormat.js +2 -0
  51. package/dist/utils/mapImportFormat.js +1 -1
  52. package/dist/utils/moduleLoader.js +37 -23
  53. package/dist/utils/prepareDir.js +20 -9
  54. package/dist/utils/valueToArray.js +8 -0
  55. package/package.json +2 -2
  56. package/schema.json +20 -4
@@ -2,7 +2,7 @@ import { parseGeneral } from './parseGeneral.js';
2
2
  export function getValue(context) {
3
3
  const token = context.tokens.current();
4
4
  const line = context.getCurrentLine();
5
- switch (token?.customType) {
5
+ switch (token === null || token === void 0 ? void 0 : token.customType) {
6
6
  case 'string':
7
7
  case 'primitive.null':
8
8
  return { type: 'primitive', line, value: token.token };
@@ -8,7 +8,7 @@ export const parseTag = (context) => {
8
8
  const props = extractProps(context);
9
9
  let child;
10
10
  const currentTag = tokens.current();
11
- if (currentTag?.customType === 'tag.regular.end') {
11
+ if ((currentTag === null || currentTag === void 0 ? void 0 : currentTag.customType) === 'tag.regular.end') {
12
12
  tokens.next();
13
13
  // it's not self-closing and there are children
14
14
  const extracted = parseGeneral(context, {
@@ -19,9 +19,7 @@ export const ngxMergers = pipeMachines([
19
19
  export const ParserNgx = () => {
20
20
  return Parser({
21
21
  mappers: ngxMappers,
22
- blocks: {
23
- ...DEFAULT_BLOCKS,
24
- },
22
+ blocks: Object.assign({}, DEFAULT_BLOCKS),
25
23
  rules: [componentWithT, translatePipe, translateFunction],
26
24
  merger: ngxMergers,
27
25
  treeTransform: ngxTreeTransform,
@@ -1,6 +1,7 @@
1
1
  export const ngxMapper = (token) => {
2
+ var _a;
2
3
  // custom tag names have dynamic token names
3
- if (token.type?.startsWith('entity.name.tag.html.ng.')) {
4
+ if ((_a = token.type) === null || _a === void 0 ? void 0 : _a.startsWith('entity.name.tag.html.ng.')) {
4
5
  return 'tag.name';
5
6
  }
6
7
  switch (token.type) {
@@ -7,13 +7,14 @@ function transformRecursive(root) {
7
7
  case 'expr':
8
8
  case 'array':
9
9
  root.values.forEach((item, i) => {
10
+ var _a, _b;
10
11
  if (item.type === 'keyInfo' && item.keyName === undefined) {
11
12
  const nodeBefore = simplifyNode(root.values[i - 1]);
12
13
  if (nodeBefore.type === 'dict') {
13
14
  item.keyName = nodeBefore.value['key'];
14
- item.namespace = nodeBefore.value['ns'] ?? item.namespace;
15
+ item.namespace = (_a = nodeBefore.value['ns']) !== null && _a !== void 0 ? _a : item.namespace;
15
16
  item.defaultValue =
16
- nodeBefore.value['defaultValue'] ?? item.defaultValue;
17
+ (_b = nodeBefore.value['defaultValue']) !== null && _b !== void 0 ? _b : item.defaultValue;
17
18
  }
18
19
  else {
19
20
  item.keyName = nodeBefore;
@@ -37,7 +37,7 @@ export const translatePipe = {
37
37
  keyNode.defaultValue = args.values.shift();
38
38
  keyNode.values = args.values;
39
39
  }
40
- if (options?.type === 'dict') {
40
+ if ((options === null || options === void 0 ? void 0 : options.type) === 'dict') {
41
41
  for (const [key, value] of Object.entries(options.value)) {
42
42
  switch (key) {
43
43
  case 'ns':
@@ -21,9 +21,7 @@ export const reactMergers = pipeMachines([
21
21
  export const ParserReact = () => {
22
22
  return Parser({
23
23
  mappers: reactMappers,
24
- blocks: {
25
- ...DEFAULT_BLOCKS,
26
- },
24
+ blocks: Object.assign({}, DEFAULT_BLOCKS),
27
25
  rules: [reactCreateElement, tComponent, tFunction, useTranslate],
28
26
  merger: reactMergers,
29
27
  });
@@ -22,9 +22,7 @@ export const svelteMergers = pipeMachines([
22
22
  export const ParserSvelte = () => {
23
23
  return Parser({
24
24
  mappers: svelteMappers,
25
- blocks: {
26
- ...DEFAULT_BLOCKS,
27
- },
25
+ blocks: Object.assign({}, DEFAULT_BLOCKS),
28
26
  rules: [tFunction, getTranslate, tComponent, scriptTag],
29
27
  treeTransform: svelteTreeTransform,
30
28
  merger: svelteMergers,
@@ -30,9 +30,7 @@ export const vueMergers = pipeMachines([
30
30
  export const ParserVue = () => {
31
31
  return Parser({
32
32
  mappers: vueMappers,
33
- blocks: {
34
- ...DEFAULT_BLOCKS,
35
- },
33
+ blocks: Object.assign({}, DEFAULT_BLOCKS),
36
34
  rules: [
37
35
  globalTFunction,
38
36
  tFunction,
@@ -12,9 +12,6 @@ export const hyphenPropsMerger = {
12
12
  break;
13
13
  }
14
14
  },
15
- resultToken: (tokens) => tokens.map((t) => ({
16
- ...t,
17
- token: t.token.replace(/-([a-z])/g, (g) => g[1].toUpperCase()),
18
- }))[0],
15
+ resultToken: (tokens) => tokens.map((t) => (Object.assign(Object.assign({}, t), { token: t.token.replace(/-([a-z])/g, (g) => g[1].toUpperCase()) })))[0],
19
16
  customType: 'tag.attribute.name',
20
17
  };
@@ -1,3 +1,14 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
1
12
  import { VUE_SCRIPT_REGULAR, VUE_SCRIPT_SETUP, VUE_COMPONENT_CONFIG, } from './contextConstants.js';
2
13
  /*
3
14
  * We get this
@@ -33,7 +44,7 @@ function bringSetupToTopLevel(context, node) {
33
44
  const setupContent = [];
34
45
  for (const item of node.values) {
35
46
  if (item.type === 'dict' && item.context === VUE_COMPONENT_CONFIG) {
36
- const { setup, ...rest } = item.value;
47
+ const _a = item.value, { setup } = _a, rest = __rest(_a, ["setup"]);
37
48
  if (setup.type === 'expr') {
38
49
  if (setup.values.length === 0) {
39
50
  context.warnings.push({
@@ -42,7 +53,7 @@ function bringSetupToTopLevel(context, node) {
42
53
  });
43
54
  }
44
55
  setupContent.push(...flattenOneLevel(setup.values));
45
- item.value = { ...rest };
56
+ item.value = Object.assign({}, rest);
46
57
  }
47
58
  }
48
59
  }
@@ -1,3 +1,12 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
1
10
  import { glob } from 'tinyglobby';
2
11
  import { extname } from 'path';
3
12
  import { callWorker } from './worker.js';
@@ -6,22 +15,24 @@ export const NullNamespace = Symbol('namespace.null');
6
15
  function parseVerbose(v) {
7
16
  return Array.isArray(v) ? v : v ? [] : undefined;
8
17
  }
9
- export async function extractKeysFromFile(file, parserType, options, extractor) {
10
- if (typeof extractor !== 'undefined') {
11
- return callWorker({
12
- extractor,
13
- file,
14
- options,
15
- });
16
- }
17
- else if (typeof parserType !== 'undefined') {
18
- return callWorker({
19
- parserType,
20
- file,
21
- options,
22
- });
23
- }
24
- throw new Error('Internal error: neither the parser type nor a custom extractors have been defined! Please report this.');
18
+ export function extractKeysFromFile(file, parserType, options, extractor) {
19
+ return __awaiter(this, void 0, void 0, function* () {
20
+ if (typeof extractor !== 'undefined') {
21
+ return callWorker({
22
+ extractor,
23
+ file,
24
+ options,
25
+ });
26
+ }
27
+ else if (typeof parserType !== 'undefined') {
28
+ return callWorker({
29
+ parserType,
30
+ file,
31
+ options,
32
+ });
33
+ }
34
+ throw new Error('Internal error: neither the parser type nor a custom extractors have been defined! Please report this.');
35
+ });
25
36
  }
26
37
  export function findPossibleFrameworks(fileNames) {
27
38
  const possibleFrameworks = [];
@@ -59,29 +70,32 @@ function detectParserType(fileNames) {
59
70
  exitWithError(`Detected multiple possible frameworks used (${possibleFrameworks.join(', ')}), use '--parser' or 'config.parser' options`);
60
71
  }
61
72
  }
62
- export async function extractKeysOfFiles(opts) {
63
- if (!opts.patterns?.length) {
64
- exitWithError("Missing '--patterns' or 'config.patterns' option");
65
- }
66
- const files = await glob(opts.patterns, { onlyFiles: true });
67
- if (files.length === 0) {
68
- exitWithError('No files were matched for extraction');
69
- }
70
- let parserType = opts.parser;
71
- if (!parserType && !opts.extractor) {
72
- parserType = detectParserType(files);
73
- }
74
- const result = new Map();
75
- const options = {
76
- strictNamespace: Boolean(opts.strictNamespace),
77
- defaultNamespace: opts.defaultNamespace,
78
- verbose: parseVerbose(opts.verbose),
79
- };
80
- await Promise.all(files.map(async (file) => {
81
- const keys = await extractKeysFromFile(file, parserType, options, opts.extractor);
82
- result.set(file, keys);
83
- }));
84
- return result;
73
+ export function extractKeysOfFiles(opts) {
74
+ return __awaiter(this, void 0, void 0, function* () {
75
+ var _a;
76
+ if (!((_a = opts.patterns) === null || _a === void 0 ? void 0 : _a.length)) {
77
+ exitWithError("Missing '--patterns' or 'config.patterns' option");
78
+ }
79
+ const files = yield glob(opts.patterns, { onlyFiles: true });
80
+ if (files.length === 0) {
81
+ exitWithError('No files were matched for extraction');
82
+ }
83
+ let parserType = opts.parser;
84
+ if (!parserType && !opts.extractor) {
85
+ parserType = detectParserType(files);
86
+ }
87
+ const result = new Map();
88
+ const options = {
89
+ strictNamespace: Boolean(opts.strictNamespace),
90
+ defaultNamespace: opts.defaultNamespace,
91
+ verbose: parseVerbose(opts.verbose),
92
+ };
93
+ yield Promise.all(files.map((file) => __awaiter(this, void 0, void 0, function* () {
94
+ const keys = yield extractKeysFromFile(file, parserType, options, opts.extractor);
95
+ result.set(file, keys);
96
+ })));
97
+ return result;
98
+ });
85
99
  }
86
100
  export function filterExtractionResult(data) {
87
101
  const result = Object.create(null);
@@ -1,3 +1,12 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
1
10
  import { extname } from 'path';
2
11
  import { readFile } from 'fs/promises';
3
12
  import { createRequire } from 'module';
@@ -15,24 +24,28 @@ const GrammarFiles = {
15
24
  };
16
25
  let oniguruma;
17
26
  let registry;
18
- async function initializeOniguruma() {
19
- const require = createRequire(import.meta.url);
20
- const wasmBlobPath = require
21
- .resolve('vscode-oniguruma')
22
- .replace('main.js', 'onig.wasm');
23
- const wasmBlob = await readFile(wasmBlobPath);
24
- await Oniguruma.loadWASM(wasmBlob);
25
- return {
26
- createOnigScanner: (patterns) => new Oniguruma.OnigScanner(patterns),
27
- createOnigString: (s) => new Oniguruma.OnigString(s),
28
- };
27
+ function initializeOniguruma() {
28
+ return __awaiter(this, void 0, void 0, function* () {
29
+ const require = createRequire(import.meta.url);
30
+ const wasmBlobPath = require
31
+ .resolve('vscode-oniguruma')
32
+ .replace('main.js', 'onig.wasm');
33
+ const wasmBlob = yield readFile(wasmBlobPath);
34
+ yield Oniguruma.loadWASM(wasmBlob);
35
+ return {
36
+ createOnigScanner: (patterns) => new Oniguruma.OnigScanner(patterns),
37
+ createOnigString: (s) => new Oniguruma.OnigString(s),
38
+ };
39
+ });
29
40
  }
30
- async function loadGrammar(scope) {
31
- const file = GrammarFiles[scope];
32
- if (!file)
33
- return null;
34
- const grammar = await readFile(file, 'utf8');
35
- return JSON.parse(grammar);
41
+ function loadGrammar(scope) {
42
+ return __awaiter(this, void 0, void 0, function* () {
43
+ const file = GrammarFiles[scope];
44
+ if (!file)
45
+ return null;
46
+ const grammar = yield readFile(file, 'utf8');
47
+ return JSON.parse(grammar);
48
+ });
36
49
  }
37
50
  function fileNameToGrammar(fileName) {
38
51
  const ext = extname(fileName);
@@ -96,22 +109,24 @@ function tokenize(code, grammar) {
96
109
  }
97
110
  return tokens;
98
111
  }
99
- export default async function (code, fileName) {
100
- if (!oniguruma) {
101
- // Lazily initialize the WebAssembly runtime
102
- oniguruma = initializeOniguruma();
103
- registry = new TextMate.Registry({
104
- onigLib: oniguruma,
105
- loadGrammar: loadGrammar,
106
- });
107
- }
108
- const grammarName = fileNameToGrammar(fileName);
109
- if (!grammarName) {
110
- throw new Error(`Cannot find grammar for file type ${fileName}`);
111
- }
112
- const grammar = await registry.loadGrammar(grammarName);
113
- if (!grammar) {
114
- throw new Error(`Cannot load grammar ${grammarName}`);
115
- }
116
- return tokenize(code, grammar);
112
+ export default function (code, fileName) {
113
+ return __awaiter(this, void 0, void 0, function* () {
114
+ if (!oniguruma) {
115
+ // Lazily initialize the WebAssembly runtime
116
+ oniguruma = initializeOniguruma();
117
+ registry = new TextMate.Registry({
118
+ onigLib: oniguruma,
119
+ loadGrammar: loadGrammar,
120
+ });
121
+ }
122
+ const grammarName = fileNameToGrammar(fileName);
123
+ if (!grammarName) {
124
+ throw new Error(`Cannot find grammar for file type ${fileName}`);
125
+ }
126
+ const grammar = yield registry.loadGrammar(grammarName);
127
+ if (!grammar) {
128
+ throw new Error(`Cannot load grammar ${grammarName}`);
129
+ }
130
+ return tokenize(code, grammar);
131
+ });
117
132
  }
@@ -1,7 +1,8 @@
1
1
  export const tokensList = (tokens) => {
2
+ var _a;
2
3
  const result = [];
3
4
  for (const t of tokens) {
4
- result.push(`${JSON.stringify(t.token).padEnd(30)} ${t.type.padEnd(40)} ${t.customType ?? ''}`);
5
+ result.push(`${JSON.stringify(t.token).padEnd(30)} ${t.type.padEnd(40)} ${(_a = t.customType) !== null && _a !== void 0 ? _a : ''}`);
5
6
  }
6
7
  return result.join('\n');
7
8
  };
@@ -28,13 +28,10 @@ export const visualizeRules = (tokens, originalString) => {
28
28
  });
29
29
  return (colorized +
30
30
  '\n\n' +
31
- Object.entries({
32
- ...colors,
33
- ...{
34
- unknown: ansi.white,
35
- ignored: ansi.grey,
36
- },
37
- })
31
+ Object.entries(Object.assign(Object.assign({}, colors), {
32
+ unknown: ansi.white,
33
+ ignored: ansi.grey,
34
+ }))
38
35
  .map(([rule, paint]) => paint(rule))
39
36
  .join('\n'));
40
37
  };
@@ -50,7 +50,7 @@ export const WarningMessages = {
50
50
  export function dumpWarnings(extractionResult) {
51
51
  let warningCount = 0;
52
52
  for (const [file, { warnings }] of extractionResult.entries()) {
53
- if (warnings?.length) {
53
+ if (warnings === null || warnings === void 0 ? void 0 : warnings.length) {
54
54
  if (!warningCount) {
55
55
  console.error('Warnings were emitted during extraction.');
56
56
  }
@@ -72,9 +72,10 @@ export function dumpWarnings(extractionResult) {
72
72
  return warningCount;
73
73
  }
74
74
  export function emitGitHubWarning(warning, file, line) {
75
+ var _a;
75
76
  if (!process.env.GITHUB_ACTIONS)
76
77
  return;
77
- file = relative(process.env.GITHUB_WORKSPACE ?? process.cwd(), file);
78
+ file = relative((_a = process.env.GITHUB_WORKSPACE) !== null && _a !== void 0 ? _a : process.cwd(), file);
78
79
  if (warning in WarningMessages) {
79
80
  const warn = warning;
80
81
  const { name, description } = WarningMessages[warn];
@@ -1,3 +1,12 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
1
10
  import { fileURLToPath } from 'url';
2
11
  import { extname, resolve } from 'path';
3
12
  import { isMainThread, parentPort, SHARE_ENV, Worker } from 'worker_threads';
@@ -9,16 +18,18 @@ const FILE_TIME_LIMIT = 60 * 1000; // one minute
9
18
  const IS_TSX = extname(import.meta.url) === '.ts';
10
19
  // --- Worker functions
11
20
  let extractor;
12
- async function handleJob(args) {
13
- const file = resolve(args.file);
14
- const code = readFileSync(file, 'utf8');
15
- if ('extractor' in args) {
16
- if (!extractor) {
17
- extractor = await loadModule(args.extractor).then((mdl) => mdl.default);
21
+ function handleJob(args) {
22
+ return __awaiter(this, void 0, void 0, function* () {
23
+ const file = resolve(args.file);
24
+ const code = readFileSync(file, 'utf8');
25
+ if ('extractor' in args) {
26
+ if (!extractor) {
27
+ extractor = yield loadModule(args.extractor).then((mdl) => mdl.default);
28
+ }
29
+ return extractor(code, file, args.options);
18
30
  }
19
- return extractor(code, file, args.options);
20
- }
21
- return internalExtractor(code, file, args.parserType, args.options);
31
+ return internalExtractor(code, file, args.parserType, args.options);
32
+ });
22
33
  }
23
34
  function workerInit() {
24
35
  parentPort.on('message', (params) => {
@@ -73,11 +84,13 @@ function createWorker() {
73
84
  workOrDie();
74
85
  return worker;
75
86
  }
76
- export async function callWorker(params) {
77
- const deferred = createDeferred();
78
- jobQueue.push([params, deferred]);
79
- if (!worker) {
80
- worker = createWorker();
81
- }
82
- return deferred.promise;
87
+ export function callWorker(params) {
88
+ return __awaiter(this, void 0, void 0, function* () {
89
+ const deferred = createDeferred();
90
+ jobQueue.push([params, deferred]);
91
+ if (!worker) {
92
+ worker = createWorker();
93
+ }
94
+ return deferred.promise;
95
+ });
83
96
  }
package/dist/options.js CHANGED
@@ -12,7 +12,7 @@ function parseUrlArgument(v) {
12
12
  try {
13
13
  return new URL(v);
14
14
  }
15
- catch {
15
+ catch (_a) {
16
16
  throw new InvalidArgumentError('Malformed URL.');
17
17
  }
18
18
  }
@@ -44,6 +44,7 @@ export const FORMAT_OPT = new Option('--format <format>', 'Localization files fo
44
44
  'PO_PYTHON',
45
45
  'APPLE_STRINGS',
46
46
  'APPLE_XLIFF',
47
+ 'APPLE_XCSTRINGS',
47
48
  'PROPERTIES_ICU',
48
49
  'PROPERTIES_JAVA',
49
50
  'ANDROID_XML',
@@ -1,13 +1,23 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
1
10
  import ansi from 'ansi-colors';
2
11
  import { loadStore } from '../config/credentials.js';
3
12
  function getProjectName(projectId, projectDetails) {
4
- return projectDetails?.[projectId]?.name;
13
+ var _a;
14
+ return (_a = projectDetails === null || projectDetails === void 0 ? void 0 : projectDetails[projectId]) === null || _a === void 0 ? void 0 : _a.name;
5
15
  }
6
16
  function printToken(type, token, projectId, projectDetails) {
7
17
  let result = type === 'PAK' ? ansi.green('PAK') : ansi.blue('PAT');
8
18
  if (projectId !== undefined) {
9
19
  const projectName = getProjectName(projectId, projectDetails);
10
- result += '\t ' + ansi.red(`#${projectId}` + ' ' + (projectName ?? ''));
20
+ result += '\t ' + ansi.red(`#${projectId}` + ' ' + (projectName !== null && projectName !== void 0 ? projectName : ''));
11
21
  }
12
22
  else {
13
23
  result += '\t ' + ansi.yellow('<all projects>');
@@ -22,25 +32,27 @@ function printToken(type, token, projectId, projectDetails) {
22
32
  }
23
33
  console.log(result);
24
34
  }
25
- export async function printApiKeyLists() {
26
- const store = await loadStore();
27
- const list = Object.entries(store);
28
- if (list.length === 0) {
29
- console.log(ansi.gray('No records\n'));
30
- }
31
- for (const [origin, server] of list) {
32
- console.log(ansi.white('[') + ansi.red(origin) + ansi.white(']'));
33
- if (server.user) {
34
- printToken('PAT', server.user);
35
+ export function printApiKeyLists() {
36
+ return __awaiter(this, void 0, void 0, function* () {
37
+ const store = yield loadStore();
38
+ const list = Object.entries(store);
39
+ if (list.length === 0) {
40
+ console.log(ansi.gray('No records\n'));
35
41
  }
36
- if (server.projects) {
37
- for (const [project, token] of Object.entries(server.projects)) {
38
- if (token) {
39
- printToken('PAK', token, project, server.projectDetails);
42
+ for (const [origin, server] of list) {
43
+ console.log(ansi.white('[') + ansi.red(origin) + ansi.white(']'));
44
+ if (server.user) {
45
+ printToken('PAT', server.user);
46
+ }
47
+ if (server.projects) {
48
+ for (const [project, token] of Object.entries(server.projects)) {
49
+ if (token) {
50
+ printToken('PAK', token, project, server.projectDetails);
51
+ }
40
52
  }
41
53
  }
54
+ console.log('\n');
42
55
  }
43
- console.log('\n');
44
- }
45
- return;
56
+ return;
57
+ });
46
58
  }
package/dist/utils/ask.js CHANGED
@@ -1,26 +1,40 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
1
10
  import readline from 'readline'; // readline/promises is Node 17, currently supporting Node 16+
2
- export async function askString(question) {
3
- return new Promise((resolve) => {
4
- const rl = readline.createInterface({
5
- input: process.stdin,
6
- output: process.stdout,
7
- });
8
- rl.question(`${question} `, (a) => {
9
- resolve(a);
10
- rl.close();
11
+ export function askString(question) {
12
+ return __awaiter(this, void 0, void 0, function* () {
13
+ return new Promise((resolve) => {
14
+ const rl = readline.createInterface({
15
+ input: process.stdin,
16
+ output: process.stdout,
17
+ });
18
+ rl.question(`${question} `, (a) => {
19
+ resolve(a);
20
+ rl.close();
21
+ });
11
22
  });
12
23
  });
13
24
  }
14
- export async function askBoolean(question, def = false) {
15
- const yn = def === true ? '[Y/n]' : '[y/N]';
16
- let res = def;
17
- const str = await askString(`${question} ${yn}`);
18
- const strRes = str[0]?.toLowerCase();
19
- if (strRes === 'y') {
20
- res = true;
21
- }
22
- else if (strRes === 'n') {
23
- res = false;
24
- }
25
- return res;
25
+ export function askBoolean(question_1) {
26
+ return __awaiter(this, arguments, void 0, function* (question, def = false) {
27
+ var _a;
28
+ const yn = def === true ? '[Y/n]' : '[y/N]';
29
+ let res = def;
30
+ const str = yield askString(`${question} ${yn}`);
31
+ const strRes = (_a = str[0]) === null || _a === void 0 ? void 0 : _a.toLowerCase();
32
+ if (strRes === 'y') {
33
+ res = true;
34
+ }
35
+ else if (strRes === 'n') {
36
+ res = false;
37
+ }
38
+ return res;
39
+ });
26
40
  }