@terai/dev 0.0.7 → 0.0.8

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 (61) hide show
  1. package/dist/chunk-27YGPZZO.mjs +30 -0
  2. package/dist/chunk-27YGPZZO.mjs.map +1 -0
  3. package/dist/chunk-3ELQZT5F.js +17773 -0
  4. package/dist/chunk-3ELQZT5F.js.map +1 -0
  5. package/dist/chunk-42NIF5EX.js +8 -0
  6. package/dist/chunk-42NIF5EX.js.map +1 -0
  7. package/dist/chunk-6YEMZ7V4.mjs +120 -0
  8. package/dist/chunk-6YEMZ7V4.mjs.map +1 -0
  9. package/dist/chunk-73E3KEZD.js +199 -0
  10. package/dist/chunk-73E3KEZD.js.map +1 -0
  11. package/dist/chunk-7KUNFJIY.mjs +563 -0
  12. package/dist/chunk-7KUNFJIY.mjs.map +1 -0
  13. package/dist/chunk-K2FH2SX6.mjs +17755 -0
  14. package/dist/chunk-K2FH2SX6.mjs.map +1 -0
  15. package/dist/chunk-KYDPPJQL.js +86 -0
  16. package/dist/chunk-KYDPPJQL.js.map +1 -0
  17. package/dist/chunk-LIRTPATK.js +52 -0
  18. package/dist/chunk-LIRTPATK.js.map +1 -0
  19. package/dist/chunk-M6WICIYM.js +571 -0
  20. package/dist/chunk-M6WICIYM.js.map +1 -0
  21. package/dist/chunk-OF7BELAL.js +32 -0
  22. package/dist/chunk-OF7BELAL.js.map +1 -0
  23. package/dist/chunk-QC3QM3MM.mjs +192 -0
  24. package/dist/chunk-QC3QM3MM.mjs.map +1 -0
  25. package/dist/chunk-RKCAHME2.mjs +6 -0
  26. package/dist/chunk-RKCAHME2.mjs.map +1 -0
  27. package/dist/chunk-RWH4GVGM.mjs +83 -0
  28. package/dist/chunk-RWH4GVGM.mjs.map +1 -0
  29. package/dist/chunk-SSJE2GTB.js +123 -0
  30. package/dist/chunk-SSJE2GTB.js.map +1 -0
  31. package/dist/chunk-UOKEQCV3.mjs +50 -0
  32. package/dist/chunk-UOKEQCV3.mjs.map +1 -0
  33. package/dist/cli.default.js +24 -18926
  34. package/dist/cli.default.js.map +1 -1
  35. package/dist/cli.default.mjs +20 -18943
  36. package/dist/cli.default.mjs.map +1 -1
  37. package/dist/cli.js +13 -18920
  38. package/dist/cli.js.map +1 -1
  39. package/dist/cli.mjs +9 -18933
  40. package/dist/cli.mjs.map +1 -1
  41. package/dist/commands/extract.js +12 -688
  42. package/dist/commands/extract.js.map +1 -1
  43. package/dist/commands/extract.mjs +5 -662
  44. package/dist/commands/extract.mjs.map +1 -1
  45. package/dist/commands/index.js +31 -998
  46. package/dist/commands/index.js.map +1 -1
  47. package/dist/commands/index.mjs +8 -966
  48. package/dist/commands/index.mjs.map +1 -1
  49. package/dist/commands/init.js +12 -779
  50. package/dist/commands/init.js.map +1 -1
  51. package/dist/commands/init.mjs +4 -748
  52. package/dist/commands/init.mjs.map +1 -1
  53. package/dist/commands/translate.js +12 -725
  54. package/dist/commands/translate.js.map +1 -1
  55. package/dist/commands/translate.mjs +5 -693
  56. package/dist/commands/translate.mjs.map +1 -1
  57. package/dist/index.js +22 -34
  58. package/dist/index.js.map +1 -1
  59. package/dist/index.mjs +8 -10
  60. package/dist/index.mjs.map +1 -1
  61. package/package.json +8 -8
@@ -1,1005 +1,38 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
1
+ 'use strict';
29
2
 
30
- // src/commands/index.ts
31
- var commands_exports = {};
32
- __export(commands_exports, {
33
- createExtractCommand: () => createExtractCommand,
34
- createInitCommand: () => createInitCommand,
35
- createTranslateCommand: () => createTranslateCommand,
36
- extractCmd: () => extractCmd,
37
- initCmd: () => initCmd,
38
- translateCmd: () => translateCmd
39
- });
40
- module.exports = __toCommonJS(commands_exports);
3
+ require('../chunk-42NIF5EX.js');
4
+ var chunkKYDPPJQL_js = require('../chunk-KYDPPJQL.js');
5
+ var chunk73E3KEZD_js = require('../chunk-73E3KEZD.js');
6
+ var chunkSSJE2GTB_js = require('../chunk-SSJE2GTB.js');
7
+ require('../chunk-OF7BELAL.js');
8
+ require('../chunk-M6WICIYM.js');
9
+ require('../chunk-LIRTPATK.js');
41
10
 
42
- // src/commands/init.ts
43
- var import_runtime = require("@terai/runtime");
44
- var import_prompts = require("@inquirer/prompts");
45
11
 
46
- // ../logger/dist/index.mjs
47
- var import_process = __toESM(require("process"), 1);
48
- var import_process2 = __toESM(require("process"), 1);
49
- var import_os = __toESM(require("os"), 1);
50
- var import_tty = __toESM(require("tty"), 1);
51
- var ANSI_BACKGROUND_OFFSET = 10;
52
- var wrapAnsi16 = (offset = 0) => (code) => `\x1B[${code + offset}m`;
53
- var wrapAnsi256 = (offset = 0) => (code) => `\x1B[${38 + offset};5;${code}m`;
54
- var wrapAnsi16m = (offset = 0) => (red, green, blue) => `\x1B[${38 + offset};2;${red};${green};${blue}m`;
55
- var styles = {
56
- modifier: {
57
- reset: [0, 0],
58
- // 21 isn't widely supported and 22 does the same thing
59
- bold: [1, 22],
60
- dim: [2, 22],
61
- italic: [3, 23],
62
- underline: [4, 24],
63
- overline: [53, 55],
64
- inverse: [7, 27],
65
- hidden: [8, 28],
66
- strikethrough: [9, 29]
67
- },
68
- color: {
69
- black: [30, 39],
70
- red: [31, 39],
71
- green: [32, 39],
72
- yellow: [33, 39],
73
- blue: [34, 39],
74
- magenta: [35, 39],
75
- cyan: [36, 39],
76
- white: [37, 39],
77
- // Bright color
78
- blackBright: [90, 39],
79
- gray: [90, 39],
80
- // Alias of `blackBright`
81
- grey: [90, 39],
82
- // Alias of `blackBright`
83
- redBright: [91, 39],
84
- greenBright: [92, 39],
85
- yellowBright: [93, 39],
86
- blueBright: [94, 39],
87
- magentaBright: [95, 39],
88
- cyanBright: [96, 39],
89
- whiteBright: [97, 39]
90
- },
91
- bgColor: {
92
- bgBlack: [40, 49],
93
- bgRed: [41, 49],
94
- bgGreen: [42, 49],
95
- bgYellow: [43, 49],
96
- bgBlue: [44, 49],
97
- bgMagenta: [45, 49],
98
- bgCyan: [46, 49],
99
- bgWhite: [47, 49],
100
- // Bright color
101
- bgBlackBright: [100, 49],
102
- bgGray: [100, 49],
103
- // Alias of `bgBlackBright`
104
- bgGrey: [100, 49],
105
- // Alias of `bgBlackBright`
106
- bgRedBright: [101, 49],
107
- bgGreenBright: [102, 49],
108
- bgYellowBright: [103, 49],
109
- bgBlueBright: [104, 49],
110
- bgMagentaBright: [105, 49],
111
- bgCyanBright: [106, 49],
112
- bgWhiteBright: [107, 49]
113
- }
114
- };
115
- var modifierNames = Object.keys(styles.modifier);
116
- var foregroundColorNames = Object.keys(styles.color);
117
- var backgroundColorNames = Object.keys(styles.bgColor);
118
- var colorNames = [...foregroundColorNames, ...backgroundColorNames];
119
- function assembleStyles() {
120
- const codes = /* @__PURE__ */ new Map();
121
- for (const [groupName, group] of Object.entries(styles)) {
122
- for (const [styleName, style] of Object.entries(group)) {
123
- styles[styleName] = {
124
- open: `\x1B[${style[0]}m`,
125
- close: `\x1B[${style[1]}m`
126
- };
127
- group[styleName] = styles[styleName];
128
- codes.set(style[0], style[1]);
129
- }
130
- Object.defineProperty(styles, groupName, {
131
- value: group,
132
- enumerable: false
133
- });
134
- }
135
- Object.defineProperty(styles, "codes", {
136
- value: codes,
137
- enumerable: false
138
- });
139
- styles.color.close = "\x1B[39m";
140
- styles.bgColor.close = "\x1B[49m";
141
- styles.color.ansi = wrapAnsi16();
142
- styles.color.ansi256 = wrapAnsi256();
143
- styles.color.ansi16m = wrapAnsi16m();
144
- styles.bgColor.ansi = wrapAnsi16(ANSI_BACKGROUND_OFFSET);
145
- styles.bgColor.ansi256 = wrapAnsi256(ANSI_BACKGROUND_OFFSET);
146
- styles.bgColor.ansi16m = wrapAnsi16m(ANSI_BACKGROUND_OFFSET);
147
- Object.defineProperties(styles, {
148
- rgbToAnsi256: {
149
- value(red, green, blue) {
150
- if (red === green && green === blue) {
151
- if (red < 8) {
152
- return 16;
153
- }
154
- if (red > 248) {
155
- return 231;
156
- }
157
- return Math.round((red - 8) / 247 * 24) + 232;
158
- }
159
- return 16 + 36 * Math.round(red / 255 * 5) + 6 * Math.round(green / 255 * 5) + Math.round(blue / 255 * 5);
160
- },
161
- enumerable: false
162
- },
163
- hexToRgb: {
164
- value(hex) {
165
- const matches = /[a-f\d]{6}|[a-f\d]{3}/i.exec(hex.toString(16));
166
- if (!matches) {
167
- return [0, 0, 0];
168
- }
169
- let [colorString] = matches;
170
- if (colorString.length === 3) {
171
- colorString = [...colorString].map((character) => character + character).join("");
172
- }
173
- const integer = Number.parseInt(colorString, 16);
174
- return [
175
- /* eslint-disable no-bitwise */
176
- integer >> 16 & 255,
177
- integer >> 8 & 255,
178
- integer & 255
179
- /* eslint-enable no-bitwise */
180
- ];
181
- },
182
- enumerable: false
183
- },
184
- hexToAnsi256: {
185
- value: (hex) => styles.rgbToAnsi256(...styles.hexToRgb(hex)),
186
- enumerable: false
187
- },
188
- ansi256ToAnsi: {
189
- value(code) {
190
- if (code < 8) {
191
- return 30 + code;
192
- }
193
- if (code < 16) {
194
- return 90 + (code - 8);
195
- }
196
- let red;
197
- let green;
198
- let blue;
199
- if (code >= 232) {
200
- red = ((code - 232) * 10 + 8) / 255;
201
- green = red;
202
- blue = red;
203
- } else {
204
- code -= 16;
205
- const remainder = code % 36;
206
- red = Math.floor(code / 36) / 5;
207
- green = Math.floor(remainder / 6) / 5;
208
- blue = remainder % 6 / 5;
209
- }
210
- const value = Math.max(red, green, blue) * 2;
211
- if (value === 0) {
212
- return 30;
213
- }
214
- let result = 30 + (Math.round(blue) << 2 | Math.round(green) << 1 | Math.round(red));
215
- if (value === 2) {
216
- result += 60;
217
- }
218
- return result;
219
- },
220
- enumerable: false
221
- },
222
- rgbToAnsi: {
223
- value: (red, green, blue) => styles.ansi256ToAnsi(styles.rgbToAnsi256(red, green, blue)),
224
- enumerable: false
225
- },
226
- hexToAnsi: {
227
- value: (hex) => styles.ansi256ToAnsi(styles.hexToAnsi256(hex)),
228
- enumerable: false
229
- }
230
- });
231
- return styles;
232
- }
233
- var ansiStyles = assembleStyles();
234
- var ansi_styles_default = ansiStyles;
235
- function hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args : import_process2.default.argv) {
236
- const prefix = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--";
237
- const position = argv.indexOf(prefix + flag);
238
- const terminatorPosition = argv.indexOf("--");
239
- return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
240
- }
241
- var { env } = import_process2.default;
242
- var flagForceColor;
243
- if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false") || hasFlag("color=never")) {
244
- flagForceColor = 0;
245
- } else if (hasFlag("color") || hasFlag("colors") || hasFlag("color=true") || hasFlag("color=always")) {
246
- flagForceColor = 1;
247
- }
248
- function envForceColor() {
249
- if ("FORCE_COLOR" in env) {
250
- if (env.FORCE_COLOR === "true") {
251
- return 1;
252
- }
253
- if (env.FORCE_COLOR === "false") {
254
- return 0;
255
- }
256
- return env.FORCE_COLOR.length === 0 ? 1 : Math.min(Number.parseInt(env.FORCE_COLOR, 10), 3);
257
- }
258
- }
259
- function translateLevel(level) {
260
- if (level === 0) {
261
- return false;
262
- }
263
- return {
264
- level,
265
- hasBasic: true,
266
- has256: level >= 2,
267
- has16m: level >= 3
268
- };
269
- }
270
- function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
271
- const noFlagForceColor = envForceColor();
272
- if (noFlagForceColor !== void 0) {
273
- flagForceColor = noFlagForceColor;
274
- }
275
- const forceColor = sniffFlags ? flagForceColor : noFlagForceColor;
276
- if (forceColor === 0) {
277
- return 0;
278
- }
279
- if (sniffFlags) {
280
- if (hasFlag("color=16m") || hasFlag("color=full") || hasFlag("color=truecolor")) {
281
- return 3;
282
- }
283
- if (hasFlag("color=256")) {
284
- return 2;
285
- }
286
- }
287
- if ("TF_BUILD" in env && "AGENT_NAME" in env) {
288
- return 1;
289
- }
290
- if (haveStream && !streamIsTTY && forceColor === void 0) {
291
- return 0;
292
- }
293
- const min = forceColor || 0;
294
- if (env.TERM === "dumb") {
295
- return min;
296
- }
297
- if (import_process2.default.platform === "win32") {
298
- const osRelease = import_os.default.release().split(".");
299
- if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
300
- return Number(osRelease[2]) >= 14931 ? 3 : 2;
301
- }
302
- return 1;
303
- }
304
- if ("CI" in env) {
305
- if (["GITHUB_ACTIONS", "GITEA_ACTIONS", "CIRCLECI"].some((key) => key in env)) {
306
- return 3;
307
- }
308
- if (["TRAVIS", "APPVEYOR", "GITLAB_CI", "BUILDKITE", "DRONE"].some((sign) => sign in env) || env.CI_NAME === "codeship") {
309
- return 1;
310
- }
311
- return min;
312
- }
313
- if ("TEAMCITY_VERSION" in env) {
314
- return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
315
- }
316
- if (env.COLORTERM === "truecolor") {
317
- return 3;
318
- }
319
- if (env.TERM === "xterm-kitty") {
320
- return 3;
321
- }
322
- if (env.TERM === "xterm-ghostty") {
323
- return 3;
324
- }
325
- if (env.TERM === "wezterm") {
326
- return 3;
327
- }
328
- if ("TERM_PROGRAM" in env) {
329
- const version = Number.parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
330
- switch (env.TERM_PROGRAM) {
331
- case "iTerm.app": {
332
- return version >= 3 ? 3 : 2;
333
- }
334
- case "Apple_Terminal": {
335
- return 2;
336
- }
337
- }
338
- }
339
- if (/-256(color)?$/i.test(env.TERM)) {
340
- return 2;
341
- }
342
- if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
343
- return 1;
344
- }
345
- if ("COLORTERM" in env) {
346
- return 1;
347
- }
348
- return min;
349
- }
350
- function createSupportsColor(stream, options = {}) {
351
- const level = _supportsColor(stream, {
352
- streamIsTTY: stream && stream.isTTY,
353
- ...options
354
- });
355
- return translateLevel(level);
356
- }
357
- var supportsColor = {
358
- stdout: createSupportsColor({ isTTY: import_tty.default.isatty(1) }),
359
- stderr: createSupportsColor({ isTTY: import_tty.default.isatty(2) })
360
- };
361
- var supports_color_default = supportsColor;
362
- function stringReplaceAll(string, substring, replacer) {
363
- let index = string.indexOf(substring);
364
- if (index === -1) {
365
- return string;
366
- }
367
- const substringLength = substring.length;
368
- let endIndex = 0;
369
- let returnValue = "";
370
- do {
371
- returnValue += string.slice(endIndex, index) + substring + replacer;
372
- endIndex = index + substringLength;
373
- index = string.indexOf(substring, endIndex);
374
- } while (index !== -1);
375
- returnValue += string.slice(endIndex);
376
- return returnValue;
377
- }
378
- function stringEncaseCRLFWithFirstIndex(string, prefix, postfix, index) {
379
- let endIndex = 0;
380
- let returnValue = "";
381
- do {
382
- const gotCR = string[index - 1] === "\r";
383
- returnValue += string.slice(endIndex, gotCR ? index - 1 : index) + prefix + (gotCR ? "\r\n" : "\n") + postfix;
384
- endIndex = index + 1;
385
- index = string.indexOf("\n", endIndex);
386
- } while (index !== -1);
387
- returnValue += string.slice(endIndex);
388
- return returnValue;
389
- }
390
- var { stdout: stdoutColor, stderr: stderrColor } = supports_color_default;
391
- var GENERATOR = Symbol("GENERATOR");
392
- var STYLER = Symbol("STYLER");
393
- var IS_EMPTY = Symbol("IS_EMPTY");
394
- var levelMapping = [
395
- "ansi",
396
- "ansi",
397
- "ansi256",
398
- "ansi16m"
399
- ];
400
- var styles2 = /* @__PURE__ */ Object.create(null);
401
- var applyOptions = (object, options = {}) => {
402
- if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) {
403
- throw new Error("The `level` option should be an integer from 0 to 3");
404
- }
405
- const colorLevel = stdoutColor ? stdoutColor.level : 0;
406
- object.level = options.level === void 0 ? colorLevel : options.level;
407
- };
408
- var chalkFactory = (options) => {
409
- const chalk2 = (...strings) => strings.join(" ");
410
- applyOptions(chalk2, options);
411
- Object.setPrototypeOf(chalk2, createChalk.prototype);
412
- return chalk2;
413
- };
414
- function createChalk(options) {
415
- return chalkFactory(options);
416
- }
417
- Object.setPrototypeOf(createChalk.prototype, Function.prototype);
418
- for (const [styleName, style] of Object.entries(ansi_styles_default)) {
419
- styles2[styleName] = {
420
- get() {
421
- const builder = createBuilder(this, createStyler(style.open, style.close, this[STYLER]), this[IS_EMPTY]);
422
- Object.defineProperty(this, styleName, { value: builder });
423
- return builder;
424
- }
425
- };
426
- }
427
- styles2.visible = {
428
- get() {
429
- const builder = createBuilder(this, this[STYLER], true);
430
- Object.defineProperty(this, "visible", { value: builder });
431
- return builder;
432
- }
433
- };
434
- var getModelAnsi = (model, level, type, ...arguments_) => {
435
- if (model === "rgb") {
436
- if (level === "ansi16m") {
437
- return ansi_styles_default[type].ansi16m(...arguments_);
438
- }
439
- if (level === "ansi256") {
440
- return ansi_styles_default[type].ansi256(ansi_styles_default.rgbToAnsi256(...arguments_));
441
- }
442
- return ansi_styles_default[type].ansi(ansi_styles_default.rgbToAnsi(...arguments_));
443
- }
444
- if (model === "hex") {
445
- return getModelAnsi("rgb", level, type, ...ansi_styles_default.hexToRgb(...arguments_));
446
- }
447
- return ansi_styles_default[type][model](...arguments_);
448
- };
449
- var usedModels = ["rgb", "hex", "ansi256"];
450
- for (const model of usedModels) {
451
- styles2[model] = {
452
- get() {
453
- const { level } = this;
454
- return function(...arguments_) {
455
- const styler = createStyler(getModelAnsi(model, levelMapping[level], "color", ...arguments_), ansi_styles_default.color.close, this[STYLER]);
456
- return createBuilder(this, styler, this[IS_EMPTY]);
457
- };
458
- }
459
- };
460
- const bgModel = "bg" + model[0].toUpperCase() + model.slice(1);
461
- styles2[bgModel] = {
462
- get() {
463
- const { level } = this;
464
- return function(...arguments_) {
465
- const styler = createStyler(getModelAnsi(model, levelMapping[level], "bgColor", ...arguments_), ansi_styles_default.bgColor.close, this[STYLER]);
466
- return createBuilder(this, styler, this[IS_EMPTY]);
467
- };
468
- }
469
- };
470
- }
471
- var proto = Object.defineProperties(() => {
472
- }, {
473
- ...styles2,
474
- level: {
475
- enumerable: true,
476
- get() {
477
- return this[GENERATOR].level;
478
- },
479
- set(level) {
480
- this[GENERATOR].level = level;
481
- }
482
- }
483
- });
484
- var createStyler = (open, close, parent) => {
485
- let openAll;
486
- let closeAll;
487
- if (parent === void 0) {
488
- openAll = open;
489
- closeAll = close;
490
- } else {
491
- openAll = parent.openAll + open;
492
- closeAll = close + parent.closeAll;
493
- }
494
- return {
495
- open,
496
- close,
497
- openAll,
498
- closeAll,
499
- parent
500
- };
501
- };
502
- var createBuilder = (self, _styler, _isEmpty) => {
503
- const builder = (...arguments_) => applyStyle(builder, arguments_.length === 1 ? "" + arguments_[0] : arguments_.join(" "));
504
- Object.setPrototypeOf(builder, proto);
505
- builder[GENERATOR] = self;
506
- builder[STYLER] = _styler;
507
- builder[IS_EMPTY] = _isEmpty;
508
- return builder;
509
- };
510
- var applyStyle = (self, string) => {
511
- if (self.level <= 0 || !string) {
512
- return self[IS_EMPTY] ? "" : string;
513
- }
514
- let styler = self[STYLER];
515
- if (styler === void 0) {
516
- return string;
517
- }
518
- const { openAll, closeAll } = styler;
519
- if (string.includes("\x1B")) {
520
- while (styler !== void 0) {
521
- string = stringReplaceAll(string, styler.close, styler.open);
522
- styler = styler.parent;
523
- }
524
- }
525
- const lfIndex = string.indexOf("\n");
526
- if (lfIndex !== -1) {
527
- string = stringEncaseCRLFWithFirstIndex(string, closeAll, openAll, lfIndex);
528
- }
529
- return openAll + string + closeAll;
530
- };
531
- Object.defineProperties(createChalk.prototype, styles2);
532
- var chalk = createChalk();
533
- var chalkStderr = createChalk({ level: stderrColor ? stderrColor.level : 0 });
534
- var source_default = chalk;
535
- function log(message) {
536
- return import_process.default.stdout.write(`${message}
537
- `);
538
- }
539
- function logError(message) {
540
- return import_process.default.stderr.write(`${message}
541
- `);
542
- }
543
- function logBullet(logger2, colorizePrefix, colorizeText, symbol, prefix, text) {
544
- const textParts = Array.isArray(text) ? text : [text || ""].filter(Boolean);
545
- const formattedText = textParts.map((textPart) => colorizeText(textPart)).join("");
546
- logger2(
547
- `${" ".repeat(3)} ${colorizePrefix(symbol)} ${colorizePrefix(
548
- prefix
549
- )} ${formattedText}`
550
- );
551
- }
552
- function warn(prefix, text) {
553
- logBullet(log, source_default.yellow, source_default.yellow, "\u25CF", prefix, text);
554
- }
555
- function debug(prefix, text) {
556
- logBullet(log, source_default.yellow, source_default.dim, "\u25CF", prefix, text);
557
- }
558
- function info(prefix, text) {
559
- logBullet(log, source_default.cyan, source_default.dim, "\u25FC", prefix, text);
560
- }
561
- function success(text) {
562
- logBullet(log, source_default.green, source_default.dim, "\u2714", text);
563
- }
564
- function error(prefix, text) {
565
- log("");
566
- logBullet(logError, source_default.red, source_default.red, "\u25B2", prefix, text);
567
- }
568
- function heading(heading2, description) {
569
- return log(
570
- `
571
- ${source_default.bgWhite(` ${source_default.whiteBright(heading2)} `)} ${source_default.bold(
572
- description
573
- )}
574
- `
575
- );
576
- }
577
- var timing = (fn) => () => {
578
- const start = performance.now();
579
- return (msg) => {
580
- const end = performance.now();
581
- const ms = end - start;
582
- fn(`${msg} ${source_default.gray(`(${ms.toFixed(2)}ms)`)}`);
583
- };
584
- };
585
- var logger = {
586
- colors: source_default,
587
- log,
588
- heading,
589
- debug,
590
- info,
591
- warn,
592
- success,
593
- error,
594
- time: {
595
- success: timing(success),
596
- info: timing(info),
597
- debug: timing(debug)
598
- }
599
- };
600
12
 
601
- // ../../node_modules/.pnpm/outdent@0.8.0/node_modules/outdent/lib-module/index.js
602
- function noop() {
603
- var args = [];
604
- for (var _i = 0; _i < arguments.length; _i++) {
605
- args[_i] = arguments[_i];
606
- }
607
- }
608
- function createWeakMap() {
609
- if (typeof WeakMap !== "undefined") {
610
- return /* @__PURE__ */ new WeakMap();
611
- } else {
612
- return fakeSetOrMap();
613
- }
614
- }
615
- function fakeSetOrMap() {
616
- return {
617
- add: noop,
618
- delete: noop,
619
- get: noop,
620
- set: noop,
621
- has: function(k) {
622
- return false;
623
- }
624
- };
625
- }
626
- var hop = Object.prototype.hasOwnProperty;
627
- var has = function(obj, prop) {
628
- return hop.call(obj, prop);
629
- };
630
- function extend(target, source) {
631
- for (var prop in source) {
632
- if (has(source, prop)) {
633
- target[prop] = source[prop];
634
- }
635
- }
636
- return target;
637
- }
638
- var reLeadingNewline = /^[ \t]*(?:\r\n|\r|\n)/;
639
- var reTrailingNewline = /(?:\r\n|\r|\n)[ \t]*$/;
640
- var reStartsWithNewlineOrIsEmpty = /^(?:[\r\n]|$)/;
641
- var reDetectIndentation = /(?:\r\n|\r|\n)([ \t]*)(?:[^ \t\r\n]|$)/;
642
- var reOnlyWhitespaceWithAtLeastOneNewline = /^[ \t]*[\r\n][ \t\r\n]*$/;
643
- function _outdentArray(strings, firstInterpolatedValueSetsIndentationLevel, options) {
644
- var indentationLevel = 0;
645
- var match = strings[0].match(reDetectIndentation);
646
- if (match) {
647
- indentationLevel = match[1].length;
648
- }
649
- var reSource = "(\\r\\n|\\r|\\n).{0," + indentationLevel + "}";
650
- var reMatchIndent = new RegExp(reSource, "g");
651
- if (firstInterpolatedValueSetsIndentationLevel) {
652
- strings = strings.slice(1);
653
- }
654
- var newline = options.newline, trimLeadingNewline = options.trimLeadingNewline, trimTrailingNewline = options.trimTrailingNewline;
655
- var normalizeNewlines = typeof newline === "string";
656
- var l = strings.length;
657
- var outdentedStrings = strings.map(function(v, i) {
658
- v = v.replace(reMatchIndent, "$1");
659
- if (i === 0 && trimLeadingNewline) {
660
- v = v.replace(reLeadingNewline, "");
661
- }
662
- if (i === l - 1 && trimTrailingNewline) {
663
- v = v.replace(reTrailingNewline, "");
664
- }
665
- if (normalizeNewlines) {
666
- v = v.replace(/\r\n|\n|\r/g, function(_) {
667
- return newline;
668
- });
669
- }
670
- return v;
671
- });
672
- return outdentedStrings;
673
- }
674
- function concatStringsAndValues(strings, values) {
675
- var ret = "";
676
- for (var i = 0, l = strings.length; i < l; i++) {
677
- ret += strings[i];
678
- if (i < l - 1) {
679
- ret += values[i];
680
- }
681
- }
682
- return ret;
683
- }
684
- function isTemplateStringsArray(v) {
685
- return has(v, "raw") && has(v, "length");
686
- }
687
- function createInstance(options) {
688
- var arrayAutoIndentCache = createWeakMap();
689
- var arrayFirstInterpSetsIndentCache = createWeakMap();
690
- function outdent(stringsOrOptions) {
691
- var values = [];
692
- for (var _i = 1; _i < arguments.length; _i++) {
693
- values[_i - 1] = arguments[_i];
694
- }
695
- if (isTemplateStringsArray(stringsOrOptions)) {
696
- var strings = stringsOrOptions;
697
- var firstInterpolatedValueSetsIndentationLevel = (values[0] === outdent || values[0] === defaultOutdent) && reOnlyWhitespaceWithAtLeastOneNewline.test(strings[0]) && reStartsWithNewlineOrIsEmpty.test(strings[1]);
698
- var cache = firstInterpolatedValueSetsIndentationLevel ? arrayFirstInterpSetsIndentCache : arrayAutoIndentCache;
699
- var renderedArray = cache.get(strings);
700
- if (!renderedArray) {
701
- renderedArray = _outdentArray(strings, firstInterpolatedValueSetsIndentationLevel, options);
702
- cache.set(strings, renderedArray);
703
- }
704
- if (values.length === 0) {
705
- return renderedArray[0];
706
- }
707
- var rendered = concatStringsAndValues(renderedArray, firstInterpolatedValueSetsIndentationLevel ? values.slice(1) : values);
708
- return rendered;
709
- } else {
710
- return createInstance(extend(extend({}, options), stringsOrOptions || {}));
711
- }
712
- }
713
- var fullOutdent = extend(outdent, {
714
- string: function(str) {
715
- return _outdentArray([str], false, options)[0];
716
- }
717
- });
718
- return fullOutdent;
719
- }
720
- var defaultOutdent = createInstance({
721
- trimLeadingNewline: true,
722
- trimTrailingNewline: true
13
+ Object.defineProperty(exports, "createExtractCommand", {
14
+ enumerable: true,
15
+ get: function () { return chunkKYDPPJQL_js.createExtractCommand; }
723
16
  });
724
- if (typeof module !== "undefined") {
725
- try {
726
- module.exports = defaultOutdent;
727
- Object.defineProperty(defaultOutdent, "__esModule", { value: true });
728
- defaultOutdent.default = defaultOutdent;
729
- defaultOutdent.outdent = defaultOutdent;
730
- } catch (e) {
731
- }
732
- }
733
-
734
- // src/commands/init.ts
735
- var import_preferred_pm = __toESM(require("preferred-pm"));
736
- function createInitCommand(cli, cwd) {
737
- return cli.command("init", "Initialize config file").option("-f, --force", "Force overwrite existing config files").option("--cwd <cwd>", "Current working directory", { default: cwd }).action(initCmd);
738
- }
739
- async function initCmd({ cwd, force }) {
740
- logger.heading("init", "Initialize config file");
741
- const configFile = (0, import_runtime.findConfig)({ cwd });
742
- const pmResult = await (0, import_preferred_pm.default)(cwd);
743
- const pm = pmResult?.name ?? "npm";
744
- const cmd = pm === "npm" ? "npm run" : pm;
745
- if (configFile && !force) {
746
- return logger.log(
747
- defaultOutdent`
748
- It looks like you already have terai created.
749
- You can now run ${logger.colors.cyan(`'${cmd} terai extract --watch'`)}
750
- `
751
- );
752
- }
753
- const projectLocale = await (0, import_prompts.input)({
754
- message: "What locale do you use for development?",
755
- default: "en"
756
- });
757
- const outDir = await (0, import_prompts.input)({
758
- message: "Where do you want to place your generated files?",
759
- default: "./locale-system"
760
- });
761
- const framework = await (0, import_prompts.select)({
762
- message: "Would you like to use any of these templates? (recommended)",
763
- choices: [
764
- {
765
- name: "No",
766
- value: null
767
- },
768
- {
769
- name: "Next",
770
- value: "next"
771
- },
772
- {
773
- name: "Vite",
774
- value: "vite"
775
- }
776
- ]
777
- });
778
- const done = logger.time.success();
779
- await (0, import_runtime.setupConfig)({ cwd, projectLocale, outDir });
780
- if (framework) {
781
- await (0, import_runtime.setupTemplate)({ cwd, outDir, framework });
782
- }
783
- done("Config file created");
784
- logger.log("\u{1F680} You are set up to start using Terai! Thanks for choosing it.");
785
- }
786
-
787
- // src/commands/extract.ts
788
- var import_perfect_debounce = require("perfect-debounce");
789
- var import_extractor = require("@terai/extractor");
790
-
791
- // ../generator/dist/index.mjs
792
- var import_runtime2 = require("@terai/runtime");
793
- var import_utils = require("@terai/utils");
794
- async function generate({
795
- dictionaries,
796
- locale,
797
- cwd,
798
- outDir
799
- }) {
800
- const folderPath = import_runtime2.runtime.path.resolve(cwd, outDir, locale);
801
- const output = [];
802
- for (const id in dictionaries) {
803
- const fileDir = import_runtime2.runtime.path.resolve(folderPath, `${id}.json`);
804
- const fileContent = dictionaries[id];
805
- const idOutput = (0, import_utils.stringify)(fileContent);
806
- import_runtime2.runtime.fs.write(fileDir, idOutput);
807
- output.push(idOutput);
808
- }
809
- return output;
810
- }
811
-
812
- // src/commands/extract.ts
813
- var import_runtime3 = require("@terai/runtime");
814
- var import_utils2 = require("@terai/utils");
815
- function createExtractCommand(cli, cwd) {
816
- return cli.command("extract", "Statically extract messages from your project").option("-w, --watch", "Watch files and rebuild").option("--cwd <cwd>", "Current working directory", { default: cwd }).action(extractCmd);
817
- }
818
- async function extractCmd(options) {
819
- logger.heading("extract", "Statically extract messages from your project");
820
- const done = logger.time.success();
821
- const config = await (0, import_runtime3.loadConfig)(options);
822
- const filesPaths = import_runtime3.runtime.fs.glob({
823
- ...config,
824
- cwd: options.cwd
825
- });
826
- const outDirPath = import_runtime3.runtime.path.resolve(options.cwd, config.outDir);
827
- const projectLocalePath = import_runtime3.runtime.path.resolve(
828
- outDirPath,
829
- config.projectLocale
830
- );
831
- const manifestPath = import_runtime3.runtime.path.resolve(
832
- outDirPath,
833
- ".terai",
834
- "locale-manifest.json"
835
- );
836
- logger.info("Scan:", "Processing files...");
837
- async function extractor(files = filesPaths) {
838
- const extractedMessages = await (0, import_extractor.extract)({
839
- ...config,
840
- filesPaths: files,
841
- cwd: options.cwd
842
- });
843
- const dictionary = (0, import_utils2.convertExtractedMessagesToDictionary)(extractedMessages);
844
- const manifest = {
845
- messages: extractedMessages
846
- };
847
- const dictionaries = (0, import_utils2.groupDictionaryByChunks)(
848
- dictionary,
849
- manifest,
850
- config.projectLocale
851
- );
852
- import_runtime3.runtime.fs.remove(import_runtime3.runtime.path.resolve(projectLocalePath));
853
- await generate({
854
- ...config,
855
- dictionaries,
856
- locale: config.projectLocale,
857
- cwd: options.cwd
858
- });
859
- import_runtime3.runtime.fs.write(manifestPath, (0, import_utils2.stringify)(manifest));
860
- return Object.keys(dictionary).length;
861
- }
862
- logger.info("Extraction:", "Extracting messages...");
863
- const msgCount = await extractor();
864
- done(`Extracted ${msgCount} messages`);
865
- if (options.watch) {
866
- logger.log("");
867
- logger.info("Watch:", "Watching files for changes...\n");
868
- const configWatcher = import_runtime3.runtime.fs.watch({
869
- ...config,
870
- ...options
871
- });
872
- configWatcher.on(
873
- "change",
874
- (0, import_perfect_debounce.debounce)(async () => {
875
- const done2 = logger.time.success();
876
- logger.info("Extraction:", "Files changed, processing messages...");
877
- const msgCount2 = await extractor();
878
- done2(`Extracted ${msgCount2} messages`);
879
- logger.log("");
880
- })
881
- );
882
- }
883
- }
884
-
885
- // src/commands/translate.ts
886
- var import_runtime4 = require("@terai/runtime");
887
- var import_translator = require("@terai/translator");
888
- var import_utils3 = require("@terai/utils");
889
- function createTranslateCommand(cli, cwd) {
890
- return cli.command("translate", "Translate messages from your project").option("--cwd <cwd>", "Current working directory", { default: cwd }).action(translateCmd);
891
- }
892
- async function translateCmd({ cwd }) {
893
- logger.heading("translate", "Translate messages from your project");
894
- const done = logger.time.success();
895
- const config = await (0, import_runtime4.loadConfig)({ cwd });
896
- const outDirPath = import_runtime4.runtime.path.resolve(cwd, config.outDir);
897
- const tmuDirPath = import_runtime4.runtime.path.resolve(cwd, config.outDir, ".terai");
898
- const manifestPath = import_runtime4.runtime.path.resolve(tmuDirPath, "locale-manifest.json");
899
- const existsManifest = import_runtime4.runtime.fs.exists(manifestPath);
900
- if (!existsManifest) {
901
- return logger.error(
902
- "translate",
903
- `No locale-manifest.json found in ${tmuDirPath}. Please run "extract" first.`
904
- );
905
- }
906
- const buildManifest = JSON.parse(
907
- import_runtime4.runtime.fs.readFile(manifestPath)
908
- );
909
- let totalTranslatedMsgs = 0;
910
- let totalCachedMsgs = 0;
911
- await Promise.all(
912
- config.outLocales.map(async (locale) => {
913
- try {
914
- let translatedDictionary = {};
915
- const untranslatedDictionary = {};
916
- const localeDirPath = import_runtime4.runtime.path.resolve(outDirPath, locale);
917
- const localeCachePath = import_runtime4.runtime.path.resolve(
918
- tmuDirPath,
919
- "cache",
920
- `${locale}.cache.json`
921
- );
922
- const cacheExists = import_runtime4.runtime.fs.exists(localeCachePath);
923
- let cache = cacheExists ? JSON.parse(import_runtime4.runtime.fs.readFile(localeCachePath)) : {};
924
- let localeCachedMsgs = 0;
925
- let localeTranslatedMsgs = 0;
926
- for (const id in buildManifest.messages) {
927
- const { value, chunksIds } = buildManifest.messages[id];
928
- const chnks = chunksIds.length ? chunksIds : [locale];
929
- for (const chunkId of chnks) {
930
- const chunkPath = import_runtime4.runtime.path.resolve(
931
- localeDirPath,
932
- `${chunkId}.json`
933
- );
934
- const existsChunk = import_runtime4.runtime.fs.exists(chunkPath);
935
- const chunk = existsChunk ? JSON.parse(import_runtime4.runtime.fs.readFile(chunkPath)) : {};
936
- const localeValue = chunk[id] ?? cache[id];
937
- if (!localeValue) {
938
- untranslatedDictionary[id] = value;
939
- localeTranslatedMsgs++;
940
- } else {
941
- translatedDictionary[id] = localeValue;
942
- cache[id] = localeValue;
943
- localeCachedMsgs++;
944
- }
945
- }
946
- }
947
- if (localeTranslatedMsgs > 0) {
948
- const translation = await (0, import_translator.translate)({
949
- ...config,
950
- dictionary: untranslatedDictionary,
951
- locale
952
- });
953
- translatedDictionary = (0, import_utils3.merge)(translation, translatedDictionary);
954
- }
955
- cache = {
956
- ...cache,
957
- ...translatedDictionary
958
- };
959
- import_runtime4.runtime.fs.remove(localeDirPath);
960
- const dictionaries = (0, import_utils3.groupDictionaryByChunks)(
961
- translatedDictionary,
962
- buildManifest,
963
- locale
964
- );
965
- await generate({
966
- ...config,
967
- dictionaries,
968
- locale,
969
- cwd
970
- });
971
- import_runtime4.runtime.fs.write(localeCachePath, (0, import_utils3.stringify)(cache));
972
- totalTranslatedMsgs += localeTranslatedMsgs;
973
- totalCachedMsgs += localeCachedMsgs;
974
- logger.info(
975
- `Locale ${locale.toUpperCase()}:`,
976
- `${localeTranslatedMsgs} new messages translated, ${localeCachedMsgs} recovered from cache`
977
- );
978
- } catch (err) {
979
- if (err instanceof Error) {
980
- logger.error(
981
- `${locale} translation:`,
982
- `Error translating to ${locale}: ${err.message}
983
- `
984
- );
985
- }
986
- }
987
- })
988
- );
989
- if (!totalTranslatedMsgs) {
990
- return done("Everything up-to-date");
991
- }
992
- done(
993
- `Translated ${totalTranslatedMsgs} messages, ${totalCachedMsgs} read from cache`
994
- );
995
- }
996
- // Annotate the CommonJS export names for ESM import in node:
997
- 0 && (module.exports = {
998
- createExtractCommand,
999
- createInitCommand,
1000
- createTranslateCommand,
1001
- extractCmd,
1002
- initCmd,
1003
- translateCmd
17
+ Object.defineProperty(exports, "extractCmd", {
18
+ enumerable: true,
19
+ get: function () { return chunkKYDPPJQL_js.extractCmd; }
20
+ });
21
+ Object.defineProperty(exports, "createInitCommand", {
22
+ enumerable: true,
23
+ get: function () { return chunk73E3KEZD_js.createInitCommand; }
24
+ });
25
+ Object.defineProperty(exports, "initCmd", {
26
+ enumerable: true,
27
+ get: function () { return chunk73E3KEZD_js.initCmd; }
28
+ });
29
+ Object.defineProperty(exports, "createTranslateCommand", {
30
+ enumerable: true,
31
+ get: function () { return chunkSSJE2GTB_js.createTranslateCommand; }
32
+ });
33
+ Object.defineProperty(exports, "translateCmd", {
34
+ enumerable: true,
35
+ get: function () { return chunkSSJE2GTB_js.translateCmd; }
1004
36
  });
37
+ //# sourceMappingURL=index.js.map
1005
38
  //# sourceMappingURL=index.js.map