xcstrings-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.
- package/README.md +17 -14
- package/dist/index.js +351 -305
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -23,7 +23,6 @@ Check it out here: [xcstrings-cli Helper](https://chatgpt.com/g/g-69365945f8bc81
|
|
|
23
23
|
```
|
|
24
24
|
|
|
25
25
|
2. Initialize xcstrings-cli:
|
|
26
|
-
|
|
27
26
|
```bash
|
|
28
27
|
xcstrings init
|
|
29
28
|
```
|
|
@@ -53,6 +52,12 @@ EOF
|
|
|
53
52
|
xcstrings remove --key greeting
|
|
54
53
|
```
|
|
55
54
|
|
|
55
|
+
**Remove all strings of specific languages:**
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
xcstrings remove --languages ja zh-Hans
|
|
59
|
+
```
|
|
60
|
+
|
|
56
61
|
**List supported languages:**
|
|
57
62
|
|
|
58
63
|
This command lists all languages by checking xcstrings files and your Xcode project settings (`.pbxproj` specified in the config file as `xcodeprojPaths`).
|
|
@@ -67,30 +72,30 @@ You can use `xcstrings --help` or `xcstrings <sub-command> --help` to see the li
|
|
|
67
72
|
## Command options
|
|
68
73
|
|
|
69
74
|
* `--help, -h`: `boolean` (Optional)
|
|
70
|
-
|
|
71
75
|
* Show help.
|
|
72
76
|
* `--version, -v`: `boolean` (Optional)
|
|
73
|
-
|
|
74
77
|
* Show version.
|
|
75
78
|
* `--config`: `string` (Optional)
|
|
76
|
-
|
|
77
79
|
* The custom config file path. If not specified, xcstrings-cli will look for `xcstrings-cli.json` or `xcstrings-cli.json5` in the current folder or its parent folders until the root.
|
|
78
80
|
|
|
79
81
|
### `add` command options
|
|
80
82
|
|
|
81
83
|
* `--strings, -s`: `string | string[] | { [key: string]: string }` (Required)
|
|
82
|
-
|
|
83
84
|
* The strings to add or update.
|
|
84
85
|
* If only one string is provided, xcstrings-cli will use it as the default string.
|
|
85
86
|
* `--comment, -c`: `string` (Optional)
|
|
86
|
-
|
|
87
87
|
* The comment for the string to add, intended for translators.
|
|
88
88
|
* `--extractionState, -e`: `string` (Optional, default: `manual`)
|
|
89
|
-
|
|
90
89
|
* The extraction state of the string to add: `translated` or `manual`.
|
|
91
|
-
* `--help`: `boolean` (Optional)
|
|
92
90
|
|
|
93
|
-
|
|
91
|
+
### `remove` command options
|
|
92
|
+
|
|
93
|
+
* `--key, -k`: `string` (Optional if `languages` is specified)
|
|
94
|
+
* The key of the string to remove. If not specified, xcstrings-cli will remove all strings for the specified languages.
|
|
95
|
+
* `--languages, -l`: `string[]` (Optional if `key` is specified)
|
|
96
|
+
* The languages to remove. If not specified, xcstrings-cli will remove the string for all languages.
|
|
97
|
+
* `--dry-run`: `boolean` (Optional, default: `false`)
|
|
98
|
+
* If set to `true`, xcstrings-cli will only show what would be removed without actually removing anything.
|
|
94
99
|
|
|
95
100
|
## Config file
|
|
96
101
|
|
|
@@ -114,17 +119,15 @@ Put an `xcstrings-cli.json5` or `xcstrings-cli.json` file in the project root, a
|
|
|
114
119
|
These are the options for the config file:
|
|
115
120
|
|
|
116
121
|
* **xcstringsPaths**: `string[] | { alias: string, path: string }[]`
|
|
117
|
-
|
|
118
122
|
* If only one path is provided, xcstrings-cli will use it as the default xcstrings file.
|
|
119
123
|
* If multiple paths are provided, xcstrings-cli will ask you to select an xcstrings file.
|
|
120
124
|
* **xcodeprojPaths**: `string[]` (Optional)
|
|
121
|
-
|
|
122
125
|
* Paths to Xcode project files used to detect supported languages.
|
|
123
126
|
* If not specified, xcstrings-cli will not check the supported languages in your Xcode project.
|
|
124
|
-
* **missingLanguagePolicy**: `string` (Optional, default: `
|
|
127
|
+
* **missingLanguagePolicy**: `string` (Optional, default: `skip`)
|
|
125
128
|
* How to handle translations for languages that are not included in the `xcstrings languages` output when adding strings. Options are:
|
|
126
|
-
* `
|
|
127
|
-
* `
|
|
129
|
+
* `skip`: Only add translations for languages included in the `xcstrings languages` output.
|
|
130
|
+
* `include`: Add translations anyway.
|
|
128
131
|
|
|
129
132
|
## LICENSE
|
|
130
133
|
|
package/dist/index.js
CHANGED
|
@@ -3,207 +3,230 @@ import ve from "yargs";
|
|
|
3
3
|
import { hideBin as je } from "yargs/helpers";
|
|
4
4
|
import { readFile as Oe, writeFile as ae, readdir as ce } from "node:fs/promises";
|
|
5
5
|
import { cosmiconfig as xe } from "cosmiconfig";
|
|
6
|
-
import
|
|
6
|
+
import ze from "json5";
|
|
7
7
|
import { XcodeProject as ke } from "@bacons/xcode";
|
|
8
|
-
import { resolve as
|
|
9
|
-
import
|
|
10
|
-
import { checkbox as ne, confirm as
|
|
8
|
+
import { resolve as q, relative as D } from "node:path";
|
|
9
|
+
import u from "chalk";
|
|
10
|
+
import { checkbox as ne, confirm as Se, select as Ee } from "@inquirer/prompts";
|
|
11
11
|
async function U(t) {
|
|
12
|
-
const
|
|
13
|
-
return JSON.parse(
|
|
12
|
+
const o = await Oe(t, "utf-8");
|
|
13
|
+
return JSON.parse(o);
|
|
14
14
|
}
|
|
15
|
-
async function le(t,
|
|
16
|
-
const n = JSON.stringify(
|
|
17
|
-
await ae(t,
|
|
15
|
+
async function le(t, o) {
|
|
16
|
+
const n = JSON.stringify(o, null, 2), r = Le(n);
|
|
17
|
+
await ae(t, r + `
|
|
18
18
|
`, "utf-8");
|
|
19
19
|
}
|
|
20
|
-
function
|
|
21
|
-
let
|
|
22
|
-
for (let
|
|
23
|
-
const l = t[
|
|
24
|
-
if (n && l === "\\" && !
|
|
25
|
-
|
|
20
|
+
function Le(t) {
|
|
21
|
+
let o = "", n = !1, r = !1;
|
|
22
|
+
for (let a = 0; a < t.length; a++) {
|
|
23
|
+
const l = t[a];
|
|
24
|
+
if (n && l === "\\" && !r) {
|
|
25
|
+
r = !0, o += l;
|
|
26
26
|
continue;
|
|
27
27
|
}
|
|
28
|
-
if (
|
|
29
|
-
|
|
28
|
+
if (r) {
|
|
29
|
+
r = !1, o += l;
|
|
30
30
|
continue;
|
|
31
31
|
}
|
|
32
32
|
if (l === '"') {
|
|
33
|
-
n = !n,
|
|
33
|
+
n = !n, o += l;
|
|
34
34
|
continue;
|
|
35
35
|
}
|
|
36
36
|
if (!n && l === ":") {
|
|
37
|
-
|
|
37
|
+
o += " :";
|
|
38
38
|
continue;
|
|
39
39
|
}
|
|
40
|
-
|
|
40
|
+
o += l;
|
|
41
41
|
}
|
|
42
|
-
return
|
|
42
|
+
return o;
|
|
43
43
|
}
|
|
44
|
-
const
|
|
44
|
+
const W = "xcstrings-cli", oe = xe(W, {
|
|
45
45
|
searchPlaces: [
|
|
46
|
-
`${
|
|
47
|
-
`${
|
|
46
|
+
`${W}.json`,
|
|
47
|
+
`${W}.json5`
|
|
48
48
|
],
|
|
49
49
|
loaders: {
|
|
50
|
-
".json5": async (t,
|
|
50
|
+
".json5": async (t, o) => ze.parse(o)
|
|
51
51
|
},
|
|
52
52
|
cache: !1
|
|
53
53
|
});
|
|
54
54
|
async function H(t) {
|
|
55
55
|
if (t) {
|
|
56
|
-
const n = await
|
|
56
|
+
const n = await oe.load(t);
|
|
57
57
|
return n ? n.config : null;
|
|
58
58
|
}
|
|
59
|
-
const
|
|
60
|
-
return
|
|
59
|
+
const o = await oe.search();
|
|
60
|
+
return o ? o.config : null;
|
|
61
61
|
}
|
|
62
|
-
function
|
|
63
|
-
const
|
|
64
|
-
return ke.open(
|
|
62
|
+
function _e(t) {
|
|
63
|
+
const o = q(t, "project.pbxproj");
|
|
64
|
+
return ke.open(o).rootObject.props.knownRegions ?? [];
|
|
65
65
|
}
|
|
66
66
|
async function Pe(t) {
|
|
67
|
-
const
|
|
68
|
-
for (const
|
|
69
|
-
const
|
|
70
|
-
if (
|
|
71
|
-
for (const l of Object.keys(
|
|
67
|
+
const o = await U(t), n = /* @__PURE__ */ new Set();
|
|
68
|
+
for (const r of Object.keys(o.strings)) {
|
|
69
|
+
const a = o.strings[r];
|
|
70
|
+
if (a.localizations)
|
|
71
|
+
for (const l of Object.keys(a.localizations))
|
|
72
72
|
n.add(l);
|
|
73
73
|
}
|
|
74
74
|
return Array.from(n).sort();
|
|
75
75
|
}
|
|
76
|
-
async function fe(t,
|
|
77
|
-
const n = await H(
|
|
76
|
+
async function fe(t, o) {
|
|
77
|
+
const n = await H(o);
|
|
78
78
|
if (n?.xcodeprojPaths && n.xcodeprojPaths.length > 0) {
|
|
79
|
-
const
|
|
80
|
-
for (const
|
|
81
|
-
|
|
82
|
-
return Array.from(
|
|
79
|
+
const r = /* @__PURE__ */ new Set();
|
|
80
|
+
for (const a of n.xcodeprojPaths)
|
|
81
|
+
_e(a).forEach((b) => r.add(b));
|
|
82
|
+
return Array.from(r).sort();
|
|
83
83
|
}
|
|
84
84
|
return await Pe(t);
|
|
85
85
|
}
|
|
86
|
-
async function Fe(t,
|
|
86
|
+
async function Fe(t, o, n, r, a) {
|
|
87
87
|
const l = await U(t);
|
|
88
88
|
l.strings || (l.strings = {});
|
|
89
|
-
const
|
|
90
|
-
...l.strings[
|
|
89
|
+
const b = {
|
|
90
|
+
...l.strings[o],
|
|
91
91
|
extractionState: "manual"
|
|
92
92
|
};
|
|
93
|
-
if (n && (
|
|
94
|
-
const
|
|
95
|
-
for (const [
|
|
96
|
-
(
|
|
97
|
-
if (
|
|
98
|
-
|
|
99
|
-
for (const [
|
|
100
|
-
|
|
93
|
+
if (n && (b.comment = n), r) {
|
|
94
|
+
const z = (await H(a))?.missingLanguagePolicy || "skip", h = await fe(t, a), f = [];
|
|
95
|
+
for (const [y, w] of Object.entries(r))
|
|
96
|
+
(h.includes(y) || z === "include") && f.push([y, w]);
|
|
97
|
+
if (f.length > 0) {
|
|
98
|
+
b.localizations = b.localizations || {};
|
|
99
|
+
for (const [y, w] of f)
|
|
100
|
+
b.localizations[y] = {
|
|
101
101
|
stringUnit: {
|
|
102
102
|
state: "translated",
|
|
103
|
-
value:
|
|
103
|
+
value: w
|
|
104
104
|
}
|
|
105
105
|
};
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
|
-
l.strings[
|
|
108
|
+
l.strings[o] = b, await le(t, l);
|
|
109
|
+
}
|
|
110
|
+
function Ce(t, o, n, r, a) {
|
|
111
|
+
if (t.localizations) {
|
|
112
|
+
for (const l of o)
|
|
113
|
+
t.localizations[l] && (a[r] ??= [], a[r].push(l), n || delete t.localizations[l]);
|
|
114
|
+
!n && t.localizations && Object.keys(t.localizations).length === 0 && delete t.localizations;
|
|
115
|
+
}
|
|
109
116
|
}
|
|
110
|
-
async function
|
|
111
|
-
const
|
|
112
|
-
|
|
117
|
+
async function Te(t, o, n, r = !1) {
|
|
118
|
+
const a = await U(t), l = {}, b = a.strings || {};
|
|
119
|
+
a.strings = b;
|
|
120
|
+
const S = o ? [o] : Object.keys(b);
|
|
121
|
+
let z = !1;
|
|
122
|
+
for (const h of S) {
|
|
123
|
+
const f = b[h];
|
|
124
|
+
if (!f)
|
|
125
|
+
continue;
|
|
126
|
+
if (!n || n.length === 0) {
|
|
127
|
+
const p = Object.keys(f.localizations ?? {});
|
|
128
|
+
l[h] = p, r || delete b[h], z = !0;
|
|
129
|
+
continue;
|
|
130
|
+
}
|
|
131
|
+
Ce(f, n, r, h, l);
|
|
132
|
+
const y = l[h]?.length ?? 0;
|
|
133
|
+
!(f.localizations && Object.keys(f.localizations).length > 0) && y > 0 && (r || delete b[h]), y > 0 && (z = !0);
|
|
134
|
+
}
|
|
135
|
+
return !r && z && await le(t, a), l;
|
|
113
136
|
}
|
|
114
137
|
const B = "xcstrings-cli.json5";
|
|
115
|
-
async function
|
|
116
|
-
const
|
|
117
|
-
async function n(
|
|
138
|
+
async function $e(t) {
|
|
139
|
+
const o = [];
|
|
140
|
+
async function n(r) {
|
|
118
141
|
try {
|
|
119
|
-
const
|
|
120
|
-
for (const l of
|
|
121
|
-
const
|
|
122
|
-
l.isDirectory() ? !l.name.startsWith(".") && l.name !== "node_modules" && await n(
|
|
142
|
+
const a = await ce(r, { withFileTypes: !0 });
|
|
143
|
+
for (const l of a) {
|
|
144
|
+
const b = q(r, l.name);
|
|
145
|
+
l.isDirectory() ? !l.name.startsWith(".") && l.name !== "node_modules" && await n(b) : l.name.endsWith(".xcstrings") && o.push(b);
|
|
123
146
|
}
|
|
124
147
|
} catch {
|
|
125
148
|
}
|
|
126
149
|
}
|
|
127
|
-
return await n(t),
|
|
150
|
+
return await n(t), o;
|
|
128
151
|
}
|
|
129
|
-
async function
|
|
130
|
-
const
|
|
152
|
+
async function Ae(t) {
|
|
153
|
+
const o = [];
|
|
131
154
|
let n = t;
|
|
132
155
|
try {
|
|
133
|
-
const
|
|
134
|
-
for (const
|
|
135
|
-
|
|
156
|
+
const r = await ce(n, { withFileTypes: !0 });
|
|
157
|
+
for (const a of r)
|
|
158
|
+
a.isDirectory() && a.name.endsWith(".xcodeproj") && o.push(q(n, a.name));
|
|
136
159
|
} catch {
|
|
137
160
|
}
|
|
138
|
-
return
|
|
161
|
+
return o;
|
|
139
162
|
}
|
|
140
|
-
async function
|
|
163
|
+
async function Ne() {
|
|
141
164
|
const t = process.cwd();
|
|
142
|
-
console.log(), console.log(
|
|
143
|
-
const
|
|
144
|
-
console.log(
|
|
145
|
-
const n = await
|
|
165
|
+
console.log(), console.log(u.bold.cyan("🚀 xcstrings-cli Configuration Setup")), console.log(u.dim("─".repeat(40))), console.log(), console.log(u.yellow("🔍 Searching for .xcstrings files..."));
|
|
166
|
+
const o = await $e(t);
|
|
167
|
+
console.log(u.yellow("🔍 Searching for .xcodeproj directories..."));
|
|
168
|
+
const n = await Ae(t);
|
|
146
169
|
console.log();
|
|
147
|
-
let
|
|
148
|
-
if (
|
|
149
|
-
console.log(
|
|
150
|
-
const
|
|
151
|
-
name:
|
|
152
|
-
value:
|
|
170
|
+
let r = [];
|
|
171
|
+
if (o.length > 0) {
|
|
172
|
+
console.log(u.green(`✓ Found ${o.length} .xcstrings file(s)`));
|
|
173
|
+
const h = o.map((f) => ({
|
|
174
|
+
name: u.white(D(t, f)) + u.dim(` (${f})`),
|
|
175
|
+
value: D(t, f),
|
|
153
176
|
checked: !0
|
|
154
177
|
}));
|
|
155
|
-
|
|
156
|
-
message:
|
|
157
|
-
choices:
|
|
178
|
+
r = await ne({
|
|
179
|
+
message: u.bold("Select .xcstrings files to manage:"),
|
|
180
|
+
choices: h
|
|
158
181
|
});
|
|
159
182
|
} else
|
|
160
|
-
console.log(
|
|
183
|
+
console.log(u.dim(" No .xcstrings files found in current directory"));
|
|
161
184
|
console.log();
|
|
162
|
-
let
|
|
185
|
+
let a = [];
|
|
163
186
|
if (n.length > 0) {
|
|
164
|
-
console.log(
|
|
165
|
-
const
|
|
166
|
-
name:
|
|
167
|
-
value:
|
|
187
|
+
console.log(u.green(`✓ Found ${n.length} .xcodeproj director${n.length === 1 ? "y" : "ies"}`));
|
|
188
|
+
const h = n.map((f) => ({
|
|
189
|
+
name: u.white(D(t, f) || f) + u.dim(` (${f})`),
|
|
190
|
+
value: D(t, f) || f,
|
|
168
191
|
checked: !0
|
|
169
192
|
}));
|
|
170
|
-
|
|
171
|
-
message:
|
|
172
|
-
choices:
|
|
193
|
+
a = await ne({
|
|
194
|
+
message: u.bold("Select .xcodeproj directories for language detection:"),
|
|
195
|
+
choices: h
|
|
173
196
|
});
|
|
174
197
|
} else
|
|
175
|
-
console.log(
|
|
176
|
-
if (console.log(), console.log(
|
|
177
|
-
message:
|
|
198
|
+
console.log(u.dim(" No .xcodeproj directories found"));
|
|
199
|
+
if (console.log(), console.log(u.dim("─".repeat(40))), console.log(), console.log(u.bold("📋 Configuration Summary:")), console.log(), console.log(u.cyan(" xcstringsPaths:")), r.length > 0 ? r.forEach((h) => console.log(u.white(` • ${h}`))) : console.log(u.dim(" (none)")), console.log(), console.log(u.cyan(" xcodeprojPaths:")), a.length > 0 ? a.forEach((h) => console.log(u.white(` • ${h}`))) : console.log(u.dim(" (none)")), console.log(), !await Se({
|
|
200
|
+
message: u.bold(`Create ${u.yellow(B)}?`),
|
|
178
201
|
default: !0
|
|
179
202
|
})) {
|
|
180
|
-
console.log(
|
|
203
|
+
console.log(u.dim(" Configuration cancelled."));
|
|
181
204
|
return;
|
|
182
205
|
}
|
|
183
|
-
const
|
|
184
|
-
`),
|
|
185
|
-
`),
|
|
206
|
+
const b = r.map((h) => ` "${h}"`).join(`,
|
|
207
|
+
`), S = a.map((h) => ` "${h}"`).join(`,
|
|
208
|
+
`), z = `{
|
|
186
209
|
// Array of paths to .xcstrings files to manage. Specify relative or absolute paths.
|
|
187
210
|
xcstringsPaths: [
|
|
188
|
-
${
|
|
211
|
+
${b}
|
|
189
212
|
],
|
|
190
213
|
// Array of paths to .xcodeproj directories. Used for discovering supported languages.
|
|
191
214
|
xcodeprojPaths: [
|
|
192
|
-
${
|
|
215
|
+
${S}
|
|
193
216
|
],
|
|
194
217
|
// Behavior for handling missing languages when adding strings.
|
|
195
218
|
missingLanguagePolicy: "skip",
|
|
196
219
|
}
|
|
197
220
|
`;
|
|
198
|
-
await ae(B,
|
|
221
|
+
await ae(B, z, "utf-8"), console.log(), console.log(u.bold.green(`✓ Created ${B}`)), console.log(u.dim(` Run ${u.cyan("xcstrings --help")} to see available commands.`)), console.log();
|
|
199
222
|
}
|
|
200
|
-
function
|
|
223
|
+
function Ve(t) {
|
|
201
224
|
return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t;
|
|
202
225
|
}
|
|
203
|
-
var
|
|
204
|
-
function
|
|
205
|
-
if (
|
|
206
|
-
|
|
226
|
+
var T = { exports: {} }, I, re;
|
|
227
|
+
function Xe() {
|
|
228
|
+
if (re) return I;
|
|
229
|
+
re = 1;
|
|
207
230
|
function t(n) {
|
|
208
231
|
try {
|
|
209
232
|
return JSON.stringify(n);
|
|
@@ -211,91 +234,91 @@ function Re() {
|
|
|
211
234
|
return '"[Circular]"';
|
|
212
235
|
}
|
|
213
236
|
}
|
|
214
|
-
I =
|
|
215
|
-
function
|
|
216
|
-
var l =
|
|
237
|
+
I = o;
|
|
238
|
+
function o(n, r, a) {
|
|
239
|
+
var l = a && a.stringify || t, b = 1;
|
|
217
240
|
if (typeof n == "object" && n !== null) {
|
|
218
|
-
var
|
|
219
|
-
if (
|
|
220
|
-
var
|
|
221
|
-
|
|
222
|
-
for (var
|
|
223
|
-
|
|
224
|
-
return
|
|
241
|
+
var S = r.length + b;
|
|
242
|
+
if (S === 1) return n;
|
|
243
|
+
var z = new Array(S);
|
|
244
|
+
z[0] = l(n);
|
|
245
|
+
for (var h = 1; h < S; h++)
|
|
246
|
+
z[h] = l(r[h]);
|
|
247
|
+
return z.join(" ");
|
|
225
248
|
}
|
|
226
249
|
if (typeof n != "string")
|
|
227
250
|
return n;
|
|
228
|
-
var
|
|
229
|
-
if (
|
|
230
|
-
for (var
|
|
231
|
-
if (n.charCodeAt(
|
|
232
|
-
switch (
|
|
251
|
+
var f = r.length;
|
|
252
|
+
if (f === 0) return n;
|
|
253
|
+
for (var y = "", w = 1 - b, p = -1, E = n && n.length || 0, d = 0; d < E; ) {
|
|
254
|
+
if (n.charCodeAt(d) === 37 && d + 1 < E) {
|
|
255
|
+
switch (p = p > -1 ? p : 0, n.charCodeAt(d + 1)) {
|
|
233
256
|
case 100:
|
|
234
257
|
// 'd'
|
|
235
258
|
case 102:
|
|
236
|
-
if (
|
|
237
|
-
|
|
259
|
+
if (w >= f || r[w] == null) break;
|
|
260
|
+
p < d && (y += n.slice(p, d)), y += Number(r[w]), p = d + 2, d++;
|
|
238
261
|
break;
|
|
239
262
|
case 105:
|
|
240
|
-
if (
|
|
241
|
-
|
|
263
|
+
if (w >= f || r[w] == null) break;
|
|
264
|
+
p < d && (y += n.slice(p, d)), y += Math.floor(Number(r[w])), p = d + 2, d++;
|
|
242
265
|
break;
|
|
243
266
|
case 79:
|
|
244
267
|
// 'O'
|
|
245
268
|
case 111:
|
|
246
269
|
// 'o'
|
|
247
270
|
case 106:
|
|
248
|
-
if (
|
|
249
|
-
|
|
250
|
-
var
|
|
251
|
-
if (
|
|
252
|
-
|
|
271
|
+
if (w >= f || r[w] === void 0) break;
|
|
272
|
+
p < d && (y += n.slice(p, d));
|
|
273
|
+
var $ = typeof r[w];
|
|
274
|
+
if ($ === "string") {
|
|
275
|
+
y += "'" + r[w] + "'", p = d + 2, d++;
|
|
253
276
|
break;
|
|
254
277
|
}
|
|
255
|
-
if (
|
|
256
|
-
|
|
278
|
+
if ($ === "function") {
|
|
279
|
+
y += r[w].name || "<anonymous>", p = d + 2, d++;
|
|
257
280
|
break;
|
|
258
281
|
}
|
|
259
|
-
|
|
282
|
+
y += l(r[w]), p = d + 2, d++;
|
|
260
283
|
break;
|
|
261
284
|
case 115:
|
|
262
|
-
if (
|
|
285
|
+
if (w >= f)
|
|
263
286
|
break;
|
|
264
|
-
|
|
287
|
+
p < d && (y += n.slice(p, d)), y += String(r[w]), p = d + 2, d++;
|
|
265
288
|
break;
|
|
266
289
|
case 37:
|
|
267
|
-
|
|
290
|
+
p < d && (y += n.slice(p, d)), y += "%", p = d + 2, d++, w--;
|
|
268
291
|
break;
|
|
269
292
|
}
|
|
270
|
-
++
|
|
293
|
+
++w;
|
|
271
294
|
}
|
|
272
|
-
++
|
|
295
|
+
++d;
|
|
273
296
|
}
|
|
274
|
-
return
|
|
297
|
+
return p === -1 ? n : (p < E && (y += n.slice(p)), y);
|
|
275
298
|
}
|
|
276
299
|
return I;
|
|
277
300
|
}
|
|
278
|
-
var
|
|
279
|
-
function
|
|
280
|
-
if (
|
|
281
|
-
|
|
282
|
-
const t =
|
|
283
|
-
|
|
284
|
-
const
|
|
285
|
-
mapHttpRequest:
|
|
286
|
-
mapHttpResponse:
|
|
287
|
-
wrapRequestSerializer:
|
|
288
|
-
wrapResponseSerializer:
|
|
289
|
-
wrapErrorSerializer:
|
|
290
|
-
req:
|
|
291
|
-
res:
|
|
301
|
+
var se;
|
|
302
|
+
function De() {
|
|
303
|
+
if (se) return T.exports;
|
|
304
|
+
se = 1;
|
|
305
|
+
const t = Xe();
|
|
306
|
+
T.exports = f;
|
|
307
|
+
const o = be().console || {}, n = {
|
|
308
|
+
mapHttpRequest: N,
|
|
309
|
+
mapHttpResponse: N,
|
|
310
|
+
wrapRequestSerializer: M,
|
|
311
|
+
wrapResponseSerializer: M,
|
|
312
|
+
wrapErrorSerializer: M,
|
|
313
|
+
req: N,
|
|
314
|
+
res: N,
|
|
292
315
|
err: G,
|
|
293
316
|
errWithCause: G
|
|
294
317
|
};
|
|
295
|
-
function
|
|
318
|
+
function r(e, s) {
|
|
296
319
|
return e === "silent" ? 1 / 0 : s.levels.values[e];
|
|
297
320
|
}
|
|
298
|
-
const
|
|
321
|
+
const a = Symbol("pino.logFuncs"), l = Symbol("pino.hierarchy"), b = {
|
|
299
322
|
error: "log",
|
|
300
323
|
fatal: "error",
|
|
301
324
|
warn: "error",
|
|
@@ -303,101 +326,101 @@ function Ve() {
|
|
|
303
326
|
debug: "log",
|
|
304
327
|
trace: "log"
|
|
305
328
|
};
|
|
306
|
-
function
|
|
307
|
-
const
|
|
329
|
+
function S(e, s) {
|
|
330
|
+
const c = {
|
|
308
331
|
logger: s,
|
|
309
332
|
parent: e[l]
|
|
310
333
|
};
|
|
311
|
-
s[l] =
|
|
334
|
+
s[l] = c;
|
|
312
335
|
}
|
|
313
|
-
function
|
|
314
|
-
const
|
|
315
|
-
s.forEach((
|
|
316
|
-
|
|
317
|
-
}), e[
|
|
336
|
+
function z(e, s, c) {
|
|
337
|
+
const g = {};
|
|
338
|
+
s.forEach((m) => {
|
|
339
|
+
g[m] = c[m] ? c[m] : o[m] || o[b[m] || "log"] || C;
|
|
340
|
+
}), e[a] = g;
|
|
318
341
|
}
|
|
319
|
-
function
|
|
320
|
-
return Array.isArray(e) ? e.filter(function(
|
|
321
|
-
return
|
|
342
|
+
function h(e, s) {
|
|
343
|
+
return Array.isArray(e) ? e.filter(function(g) {
|
|
344
|
+
return g !== "!stdSerializers.err";
|
|
322
345
|
}) : e === !0 ? Object.keys(s) : !1;
|
|
323
346
|
}
|
|
324
|
-
function
|
|
347
|
+
function f(e) {
|
|
325
348
|
e = e || {}, e.browser = e.browser || {};
|
|
326
349
|
const s = e.browser.transmit;
|
|
327
350
|
if (s && typeof s.send != "function")
|
|
328
351
|
throw Error("pino: transmit option must have a send function");
|
|
329
|
-
const
|
|
352
|
+
const c = e.browser.write || o;
|
|
330
353
|
e.browser.write && (e.browser.asObject = !0);
|
|
331
|
-
const
|
|
354
|
+
const g = e.serializers || {}, m = h(e.browser.serialize, g);
|
|
332
355
|
let O = e.browser.serialize;
|
|
333
356
|
Array.isArray(e.browser.serialize) && e.browser.serialize.indexOf("!stdSerializers.err") > -1 && (O = !1);
|
|
334
|
-
const
|
|
335
|
-
typeof
|
|
336
|
-
|
|
357
|
+
const L = Object.keys(e.customLevels || {}), v = ["error", "fatal", "warn", "info", "debug", "trace"].concat(L);
|
|
358
|
+
typeof c == "function" && v.forEach(function(x) {
|
|
359
|
+
c[x] = c;
|
|
337
360
|
}), (e.enabled === !1 || e.browser.disabled) && (e.level = "silent");
|
|
338
|
-
const j = e.level || "info", i = Object.create(
|
|
339
|
-
i.log || (i.log =
|
|
340
|
-
get:
|
|
361
|
+
const j = e.level || "info", i = Object.create(c);
|
|
362
|
+
i.log || (i.log = C), z(i, v, c), S({}, i), Object.defineProperty(i, "levelVal", {
|
|
363
|
+
get: V
|
|
341
364
|
}), Object.defineProperty(i, "level", {
|
|
342
|
-
get:
|
|
365
|
+
get: _,
|
|
343
366
|
set: ye
|
|
344
367
|
});
|
|
345
|
-
const
|
|
368
|
+
const k = {
|
|
346
369
|
transmit: s,
|
|
347
|
-
serialize:
|
|
370
|
+
serialize: m,
|
|
348
371
|
asObject: e.browser.asObject,
|
|
349
372
|
formatters: e.browser.formatters,
|
|
350
|
-
levels:
|
|
373
|
+
levels: v,
|
|
351
374
|
timestamp: me(e)
|
|
352
375
|
};
|
|
353
|
-
i.levels =
|
|
354
|
-
function
|
|
355
|
-
return
|
|
376
|
+
i.levels = y(e), i.level = j, i.setMaxListeners = i.getMaxListeners = i.emit = i.addListener = i.on = i.prependListener = i.once = i.prependOnceListener = i.removeListener = i.removeAllListeners = i.listeners = i.listenerCount = i.eventNames = i.write = i.flush = C, i.serializers = g, i._serialize = m, i._stdErrSerialize = O, i.child = we, s && (i._logEvent = J());
|
|
377
|
+
function V() {
|
|
378
|
+
return r(this.level, this);
|
|
356
379
|
}
|
|
357
|
-
function
|
|
380
|
+
function _() {
|
|
358
381
|
return this._level;
|
|
359
382
|
}
|
|
360
383
|
function ye(x) {
|
|
361
384
|
if (x !== "silent" && !this.levels.values[x])
|
|
362
385
|
throw Error("unknown level " + x);
|
|
363
|
-
this._level = x,
|
|
364
|
-
|
|
386
|
+
this._level = x, E(this, k, i, "error"), E(this, k, i, "fatal"), E(this, k, i, "warn"), E(this, k, i, "info"), E(this, k, i, "debug"), E(this, k, i, "trace"), L.forEach((P) => {
|
|
387
|
+
E(this, k, i, P);
|
|
365
388
|
});
|
|
366
389
|
}
|
|
367
390
|
function we(x, P) {
|
|
368
391
|
if (!x)
|
|
369
392
|
throw new Error("missing bindings for child Pino");
|
|
370
|
-
P = P || {},
|
|
393
|
+
P = P || {}, m && x.serializers && (P.serializers = x.serializers);
|
|
371
394
|
const Y = P.serializers;
|
|
372
|
-
if (
|
|
373
|
-
var
|
|
374
|
-
delete x.serializers,
|
|
395
|
+
if (m && Y) {
|
|
396
|
+
var X = Object.assign({}, g, Y), Z = e.browser.serialize === !0 ? Object.keys(X) : m;
|
|
397
|
+
delete x.serializers, A([x], Z, X, this._stdErrSerialize);
|
|
375
398
|
}
|
|
376
399
|
function ee(te) {
|
|
377
|
-
this._childLevel = (te._childLevel | 0) + 1, this.bindings = x,
|
|
400
|
+
this._childLevel = (te._childLevel | 0) + 1, this.bindings = x, X && (this.serializers = X, this._serialize = Z), s && (this._logEvent = J(
|
|
378
401
|
[].concat(te._logEvent.bindings, x)
|
|
379
402
|
));
|
|
380
403
|
}
|
|
381
404
|
ee.prototype = this;
|
|
382
|
-
const
|
|
383
|
-
return
|
|
405
|
+
const R = new ee(this);
|
|
406
|
+
return S(this, R), R.level = this.level, R;
|
|
384
407
|
}
|
|
385
408
|
return i;
|
|
386
409
|
}
|
|
387
|
-
function
|
|
388
|
-
const s = e.customLevels || {},
|
|
410
|
+
function y(e) {
|
|
411
|
+
const s = e.customLevels || {}, c = Object.assign({}, f.levels.values, s), g = Object.assign({}, f.levels.labels, w(s));
|
|
389
412
|
return {
|
|
390
|
-
values:
|
|
391
|
-
labels:
|
|
413
|
+
values: c,
|
|
414
|
+
labels: g
|
|
392
415
|
};
|
|
393
416
|
}
|
|
394
|
-
function
|
|
417
|
+
function w(e) {
|
|
395
418
|
const s = {};
|
|
396
|
-
return Object.keys(e).forEach(function(
|
|
397
|
-
s[e[
|
|
419
|
+
return Object.keys(e).forEach(function(c) {
|
|
420
|
+
s[e[c]] = c;
|
|
398
421
|
}), s;
|
|
399
422
|
}
|
|
400
|
-
|
|
423
|
+
f.levels = {
|
|
401
424
|
values: {
|
|
402
425
|
fatal: 60,
|
|
403
426
|
error: 50,
|
|
@@ -414,90 +437,90 @@ function Ve() {
|
|
|
414
437
|
50: "error",
|
|
415
438
|
60: "fatal"
|
|
416
439
|
}
|
|
417
|
-
},
|
|
418
|
-
function
|
|
440
|
+
}, f.stdSerializers = n, f.stdTimeFunctions = Object.assign({}, { nullTime: K, epochTime: Q, unixTime: he, isoTime: pe });
|
|
441
|
+
function p(e) {
|
|
419
442
|
const s = [];
|
|
420
443
|
e.bindings && s.push(e.bindings);
|
|
421
|
-
let
|
|
422
|
-
for (;
|
|
423
|
-
|
|
444
|
+
let c = e[l];
|
|
445
|
+
for (; c.parent; )
|
|
446
|
+
c = c.parent, c.logger.bindings && s.push(c.logger.bindings);
|
|
424
447
|
return s.reverse();
|
|
425
448
|
}
|
|
426
|
-
function
|
|
427
|
-
if (Object.defineProperty(e,
|
|
428
|
-
value:
|
|
449
|
+
function E(e, s, c, g) {
|
|
450
|
+
if (Object.defineProperty(e, g, {
|
|
451
|
+
value: r(e.level, c) > r(g, c) ? C : c[a][g],
|
|
429
452
|
writable: !0,
|
|
430
453
|
enumerable: !0,
|
|
431
454
|
configurable: !0
|
|
432
|
-
}), !s.transmit && e[
|
|
455
|
+
}), !s.transmit && e[g] === C)
|
|
433
456
|
return;
|
|
434
|
-
e[
|
|
435
|
-
const
|
|
436
|
-
|
|
457
|
+
e[g] = $(e, s, c, g);
|
|
458
|
+
const m = p(e);
|
|
459
|
+
m.length !== 0 && (e[g] = d(m, e[g]));
|
|
437
460
|
}
|
|
438
|
-
function
|
|
461
|
+
function d(e, s) {
|
|
439
462
|
return function() {
|
|
440
463
|
return s.apply(this, [...e, ...arguments]);
|
|
441
464
|
};
|
|
442
465
|
}
|
|
443
|
-
function
|
|
444
|
-
return /* @__PURE__ */ (function(
|
|
466
|
+
function $(e, s, c, g) {
|
|
467
|
+
return /* @__PURE__ */ (function(m) {
|
|
445
468
|
return function() {
|
|
446
|
-
const
|
|
447
|
-
for (var i = 0; i <
|
|
448
|
-
if (s.serialize && !s.asObject &&
|
|
449
|
-
const
|
|
450
|
-
if (
|
|
469
|
+
const L = s.timestamp(), v = new Array(arguments.length), j = Object.getPrototypeOf && Object.getPrototypeOf(this) === o ? o : this;
|
|
470
|
+
for (var i = 0; i < v.length; i++) v[i] = arguments[i];
|
|
471
|
+
if (s.serialize && !s.asObject && A(v, this._serialize, this.serializers, this._stdErrSerialize), s.asObject || s.formatters ? m.call(j, de(this, g, v, L, s.formatters)) : m.apply(j, v), s.transmit) {
|
|
472
|
+
const k = s.transmit.level || e._level, V = c.levels.values[k], _ = c.levels.values[g];
|
|
473
|
+
if (_ < V) return;
|
|
451
474
|
ge(this, {
|
|
452
|
-
ts:
|
|
453
|
-
methodLevel:
|
|
454
|
-
methodValue:
|
|
455
|
-
transmitValue:
|
|
475
|
+
ts: L,
|
|
476
|
+
methodLevel: g,
|
|
477
|
+
methodValue: _,
|
|
478
|
+
transmitValue: c.levels.values[s.transmit.level || e._level],
|
|
456
479
|
send: s.transmit.send,
|
|
457
|
-
val:
|
|
458
|
-
},
|
|
480
|
+
val: r(e._level, c)
|
|
481
|
+
}, v);
|
|
459
482
|
}
|
|
460
483
|
};
|
|
461
|
-
})(e[
|
|
484
|
+
})(e[a][g]);
|
|
462
485
|
}
|
|
463
|
-
function de(e, s,
|
|
486
|
+
function de(e, s, c, g, m = {}) {
|
|
464
487
|
const {
|
|
465
488
|
level: O = () => e.levels.values[s],
|
|
466
|
-
log:
|
|
467
|
-
} =
|
|
468
|
-
e._serialize &&
|
|
469
|
-
const
|
|
470
|
-
let j =
|
|
489
|
+
log: L = (_) => _
|
|
490
|
+
} = m;
|
|
491
|
+
e._serialize && A(c, e._serialize, e.serializers, e._stdErrSerialize);
|
|
492
|
+
const v = c.slice();
|
|
493
|
+
let j = v[0];
|
|
471
494
|
const i = {};
|
|
472
|
-
|
|
473
|
-
let
|
|
474
|
-
if (
|
|
475
|
-
for (;
|
|
476
|
-
Object.assign(i,
|
|
477
|
-
j =
|
|
478
|
-
} else typeof j == "string" && (j = t(
|
|
479
|
-
return j !== void 0 && (i.msg = j),
|
|
480
|
-
}
|
|
481
|
-
function
|
|
482
|
-
for (const
|
|
483
|
-
if (
|
|
484
|
-
e[
|
|
485
|
-
else if (typeof e[
|
|
486
|
-
for (const O in e[
|
|
487
|
-
s && s.indexOf(O) > -1 && O in
|
|
488
|
-
}
|
|
489
|
-
function ge(e, s,
|
|
490
|
-
const
|
|
491
|
-
|
|
492
|
-
|
|
495
|
+
g && (i.time = g), i.level = O(s, e.levels.values[s]);
|
|
496
|
+
let k = (e._childLevel | 0) + 1;
|
|
497
|
+
if (k < 1 && (k = 1), j !== null && typeof j == "object") {
|
|
498
|
+
for (; k-- && typeof v[0] == "object"; )
|
|
499
|
+
Object.assign(i, v.shift());
|
|
500
|
+
j = v.length ? t(v.shift(), v) : void 0;
|
|
501
|
+
} else typeof j == "string" && (j = t(v.shift(), v));
|
|
502
|
+
return j !== void 0 && (i.msg = j), L(i);
|
|
503
|
+
}
|
|
504
|
+
function A(e, s, c, g) {
|
|
505
|
+
for (const m in e)
|
|
506
|
+
if (g && e[m] instanceof Error)
|
|
507
|
+
e[m] = f.stdSerializers.err(e[m]);
|
|
508
|
+
else if (typeof e[m] == "object" && !Array.isArray(e[m]))
|
|
509
|
+
for (const O in e[m])
|
|
510
|
+
s && s.indexOf(O) > -1 && O in c && (e[m][O] = c[O](e[m][O]));
|
|
511
|
+
}
|
|
512
|
+
function ge(e, s, c) {
|
|
513
|
+
const g = s.send, m = s.ts, O = s.methodLevel, L = s.methodValue, v = s.val, j = e._logEvent.bindings;
|
|
514
|
+
A(
|
|
515
|
+
c,
|
|
493
516
|
e._serialize || Object.keys(e.serializers),
|
|
494
517
|
e.serializers,
|
|
495
518
|
e._stdErrSerialize === void 0 ? !0 : e._stdErrSerialize
|
|
496
|
-
), e._logEvent.ts =
|
|
519
|
+
), e._logEvent.ts = m, e._logEvent.messages = c.filter(function(i) {
|
|
497
520
|
return j.indexOf(i) === -1;
|
|
498
|
-
}), e._logEvent.level.label = O, e._logEvent.level.value =
|
|
521
|
+
}), e._logEvent.level.label = O, e._logEvent.level.value = L, g(O, e._logEvent, v), e._logEvent = J(j);
|
|
499
522
|
}
|
|
500
|
-
function
|
|
523
|
+
function J(e) {
|
|
501
524
|
return {
|
|
502
525
|
ts: 0,
|
|
503
526
|
messages: [],
|
|
@@ -511,25 +534,25 @@ function Ve() {
|
|
|
511
534
|
msg: e.message,
|
|
512
535
|
stack: e.stack
|
|
513
536
|
};
|
|
514
|
-
for (const
|
|
515
|
-
s[
|
|
537
|
+
for (const c in e)
|
|
538
|
+
s[c] === void 0 && (s[c] = e[c]);
|
|
516
539
|
return s;
|
|
517
540
|
}
|
|
518
541
|
function me(e) {
|
|
519
|
-
return typeof e.timestamp == "function" ? e.timestamp : e.timestamp === !1 ?
|
|
542
|
+
return typeof e.timestamp == "function" ? e.timestamp : e.timestamp === !1 ? K : Q;
|
|
520
543
|
}
|
|
521
|
-
function
|
|
544
|
+
function N() {
|
|
522
545
|
return {};
|
|
523
546
|
}
|
|
524
|
-
function
|
|
547
|
+
function M(e) {
|
|
525
548
|
return e;
|
|
526
549
|
}
|
|
527
|
-
function
|
|
550
|
+
function C() {
|
|
528
551
|
}
|
|
529
|
-
function
|
|
552
|
+
function K() {
|
|
530
553
|
return !1;
|
|
531
554
|
}
|
|
532
|
-
function
|
|
555
|
+
function Q() {
|
|
533
556
|
return Date.now();
|
|
534
557
|
}
|
|
535
558
|
function he() {
|
|
@@ -553,54 +576,54 @@ function Ve() {
|
|
|
553
576
|
return e(self) || e(window) || e(this) || {};
|
|
554
577
|
}
|
|
555
578
|
}
|
|
556
|
-
return
|
|
579
|
+
return T.exports.default = f, T.exports.pino = f, T.exports;
|
|
557
580
|
}
|
|
558
|
-
var
|
|
559
|
-
const
|
|
581
|
+
var qe = De();
|
|
582
|
+
const Je = /* @__PURE__ */ Ve(qe), F = Je({
|
|
560
583
|
level: process.env.LOG_LEVEL || "info"
|
|
561
584
|
});
|
|
562
585
|
async function ue() {
|
|
563
586
|
return new Promise((t) => {
|
|
564
|
-
let
|
|
587
|
+
let o = "";
|
|
565
588
|
process.stdin.setEncoding("utf8"), process.stdin.on("data", (n) => {
|
|
566
|
-
|
|
589
|
+
o += n;
|
|
567
590
|
}), process.stdin.on("end", () => {
|
|
568
|
-
t(
|
|
591
|
+
t(o);
|
|
569
592
|
}), process.stdin.readableEnded && t("");
|
|
570
593
|
});
|
|
571
594
|
}
|
|
572
|
-
async function
|
|
595
|
+
async function Me(t, o = ue) {
|
|
573
596
|
if (t !== void 0) {
|
|
574
597
|
if (t === "") {
|
|
575
|
-
const n = await
|
|
598
|
+
const n = await o();
|
|
576
599
|
return n.trim() ? JSON.parse(n) : void 0;
|
|
577
600
|
}
|
|
578
601
|
if (typeof t == "string")
|
|
579
602
|
return JSON.parse(t);
|
|
580
603
|
if (Array.isArray(t)) {
|
|
581
604
|
const n = {};
|
|
582
|
-
for (const
|
|
583
|
-
typeof
|
|
605
|
+
for (const r of t)
|
|
606
|
+
typeof r == "string" && Object.assign(n, JSON.parse(r));
|
|
584
607
|
return n;
|
|
585
608
|
}
|
|
586
609
|
if (typeof t == "boolean" && t === !0) {
|
|
587
|
-
const n = await
|
|
610
|
+
const n = await o();
|
|
588
611
|
return n.trim() ? JSON.parse(n) : void 0;
|
|
589
612
|
}
|
|
590
613
|
}
|
|
591
614
|
}
|
|
592
|
-
async function
|
|
615
|
+
async function Re({
|
|
593
616
|
path: t,
|
|
594
|
-
key:
|
|
617
|
+
key: o,
|
|
595
618
|
comment: n,
|
|
596
|
-
stringsArg:
|
|
597
|
-
stdinReader:
|
|
619
|
+
stringsArg: r,
|
|
620
|
+
stdinReader: a = ue,
|
|
598
621
|
configPath: l
|
|
599
622
|
}) {
|
|
600
|
-
const
|
|
601
|
-
await Fe(t,
|
|
623
|
+
const b = await Me(r, a);
|
|
624
|
+
await Fe(t, o, n, b, l);
|
|
602
625
|
}
|
|
603
|
-
const ie =
|
|
626
|
+
const ie = q(process.cwd(), "Localizable.xcstrings");
|
|
604
627
|
ve(je(process.argv)).scriptName("xcstrings").usage("$0 <cmd> [args]").option("config", {
|
|
605
628
|
type: "string",
|
|
606
629
|
describe: "Path to config file"
|
|
@@ -611,17 +634,17 @@ ve(je(process.argv)).scriptName("xcstrings").usage("$0 <cmd> [args]").option("co
|
|
|
611
634
|
}).middleware(async (t) => {
|
|
612
635
|
if (t.path !== ie)
|
|
613
636
|
return;
|
|
614
|
-
const
|
|
615
|
-
if (!(!
|
|
616
|
-
if (
|
|
617
|
-
const n =
|
|
637
|
+
const o = await H(t.config);
|
|
638
|
+
if (!(!o || !o.xcstringsPaths || o.xcstringsPaths.length === 0))
|
|
639
|
+
if (o.xcstringsPaths.length === 1) {
|
|
640
|
+
const n = o.xcstringsPaths[0];
|
|
618
641
|
t.path = typeof n == "string" ? n : n.path;
|
|
619
642
|
} else {
|
|
620
|
-
const n =
|
|
643
|
+
const n = o.xcstringsPaths.map((a) => typeof a == "string" ? { name: a, value: a } : { name: `${a.alias} (${a.path})`, value: a.path }), r = await Ee({
|
|
621
644
|
message: "Select xcstrings file:",
|
|
622
645
|
choices: n
|
|
623
646
|
});
|
|
624
|
-
t.path =
|
|
647
|
+
t.path = r;
|
|
625
648
|
}
|
|
626
649
|
}).command(
|
|
627
650
|
"add",
|
|
@@ -638,43 +661,66 @@ ve(je(process.argv)).scriptName("xcstrings").usage("$0 <cmd> [args]").option("co
|
|
|
638
661
|
describe: "The strings JSON"
|
|
639
662
|
}),
|
|
640
663
|
async (t) => {
|
|
641
|
-
await
|
|
664
|
+
await Re({
|
|
642
665
|
path: t.path,
|
|
643
666
|
key: t.key,
|
|
644
667
|
comment: t.comment,
|
|
645
668
|
stringsArg: t.strings,
|
|
646
669
|
stdinReader: void 0,
|
|
647
670
|
configPath: t.config
|
|
648
|
-
}),
|
|
671
|
+
}), F.info(u.green(`✓ Added key "${t.key}"`));
|
|
649
672
|
}
|
|
650
673
|
).command(
|
|
651
674
|
"remove",
|
|
652
675
|
"Remove a string",
|
|
653
676
|
(t) => t.option("key", {
|
|
654
677
|
type: "string",
|
|
655
|
-
describe: "The key to remove"
|
|
656
|
-
|
|
678
|
+
describe: "The key to remove"
|
|
679
|
+
}).option("languages", {
|
|
680
|
+
type: "string",
|
|
681
|
+
array: !0,
|
|
682
|
+
describe: "Languages to remove"
|
|
683
|
+
}).option("dry-run", {
|
|
684
|
+
type: "boolean",
|
|
685
|
+
default: !1,
|
|
686
|
+
describe: "Show what would be removed without writing changes"
|
|
687
|
+
}).check((o) => {
|
|
688
|
+
if (o.key || o.languages && o.languages.length > 0)
|
|
689
|
+
return !0;
|
|
690
|
+
throw new Error("Either --key or --languages must be provided");
|
|
657
691
|
}),
|
|
658
692
|
async (t) => {
|
|
659
|
-
|
|
693
|
+
const o = await Te(
|
|
694
|
+
t.path,
|
|
695
|
+
t.key,
|
|
696
|
+
t.languages,
|
|
697
|
+
t.dryRun === !0
|
|
698
|
+
), n = Object.entries(o).map(([r, a]) => `- [${a.join(" ")}] ${r}`).join(`
|
|
699
|
+
`);
|
|
700
|
+
if (t.dryRun) {
|
|
701
|
+
n.length === 0 ? F.info(u.yellow("No matching strings found.")) : F.info(u.blue(`Would remove:
|
|
702
|
+
${n}`));
|
|
703
|
+
return;
|
|
704
|
+
}
|
|
705
|
+
n.length === 0 ? F.info(u.yellow("No matching strings found.")) : F.info(u.green(`✓ Removed
|
|
706
|
+
${n}`));
|
|
660
707
|
}
|
|
661
708
|
).command(
|
|
662
709
|
"init",
|
|
663
710
|
"Initialize configuration file",
|
|
664
711
|
(t) => t,
|
|
665
712
|
async () => {
|
|
666
|
-
await
|
|
713
|
+
await Ne();
|
|
667
714
|
}
|
|
668
715
|
).command(
|
|
669
716
|
"languages",
|
|
670
717
|
"List supported languages from xcodeproj or xcstrings",
|
|
671
718
|
(t) => t,
|
|
672
719
|
async (t) => {
|
|
673
|
-
const
|
|
674
|
-
|
|
720
|
+
const o = await fe(t.path, t.config);
|
|
721
|
+
F.info(o.join(" "));
|
|
675
722
|
}
|
|
676
|
-
).demandCommand(1, "").strictCommands().recommendCommands().showHelpOnFail(!0).fail((t,
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
t && (console.error(d.red(t)), console.log()), n.showHelp(), process.exit(1);
|
|
723
|
+
).demandCommand(1, "").strictCommands().recommendCommands().showHelpOnFail(!0).fail((t, o, n) => {
|
|
724
|
+
const r = t || o?.message;
|
|
725
|
+
r && (console.error(u.red(r)), console.log(), n.showHelp(), process.exit(1)), o && (console.error(o), process.exit(1)), n.showHelp(), process.exit(1);
|
|
680
726
|
}).help().argv;
|