@vivliostyle/cli 10.3.1 → 10.4.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/dist/{chunk-MU7JCDMK.js → chunk-4DTPH2XX.js} +2 -2
- package/dist/{chunk-PYPAYBFL.js → chunk-DEJL63H2.js} +29 -22
- package/dist/chunk-DEJL63H2.js.map +1 -0
- package/dist/{chunk-OAFXM4ES.js → chunk-DK3HFVHX.js} +27 -51
- package/dist/chunk-DK3HFVHX.js.map +1 -0
- package/dist/{chunk-7GIJVX4M.js → chunk-J2YGULSR.js} +45 -7
- package/dist/chunk-J2YGULSR.js.map +1 -0
- package/dist/{chunk-ERDN47XG.js → chunk-L4PJ2SP3.js} +17 -13
- package/dist/chunk-L4PJ2SP3.js.map +1 -0
- package/dist/{chunk-LWMSAGHL.js → chunk-LE3QOQ5F.js} +11 -9
- package/dist/{chunk-LWMSAGHL.js.map → chunk-LE3QOQ5F.js.map} +1 -1
- package/dist/{chunk-C4HQHRXQ.js → chunk-P33ELNYE.js} +323 -379
- package/dist/chunk-P33ELNYE.js.map +1 -0
- package/dist/chunk-Q4EIXB5V.js +330 -0
- package/dist/chunk-Q4EIXB5V.js.map +1 -0
- package/dist/{chunk-LGOHUEEQ.js → chunk-RLV2H3QB.js} +11 -11
- package/dist/chunk-RLV2H3QB.js.map +1 -0
- package/dist/{chunk-DBK27BAR.js → chunk-VAPIKX4A.js} +300 -502
- package/dist/chunk-VAPIKX4A.js.map +1 -0
- package/dist/cli.js +2 -1
- package/dist/cli.js.map +1 -1
- package/dist/commands/build.js +10 -9
- package/dist/commands/build.js.map +1 -1
- package/dist/commands/create.js +7 -6
- package/dist/commands/create.js.map +1 -1
- package/dist/commands/init.js +7 -6
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/preview.js +9 -8
- package/dist/commands/preview.js.map +1 -1
- package/dist/config/schema.d.ts +13247 -1767
- package/dist/config/schema.js +7 -2
- package/dist/constants.d.ts +250 -0
- package/dist/constants.js +60 -0
- package/dist/constants.js.map +1 -0
- package/dist/index.js +13 -12
- package/dist/index.js.map +1 -1
- package/dist/vite-adapter.js +6 -5
- package/package.json +15 -11
- package/dist/chunk-7GIJVX4M.js.map +0 -1
- package/dist/chunk-C4HQHRXQ.js.map +0 -1
- package/dist/chunk-DBK27BAR.js.map +0 -1
- package/dist/chunk-ERDN47XG.js.map +0 -1
- package/dist/chunk-LGOHUEEQ.js.map +0 -1
- package/dist/chunk-OAFXM4ES.js.map +0 -1
- package/dist/chunk-PYPAYBFL.js.map +0 -1
- /package/dist/{chunk-MU7JCDMK.js.map → chunk-4DTPH2XX.js.map} +0 -0
|
@@ -1,317 +1,35 @@
|
|
|
1
|
-
import {
|
|
2
|
-
VivliostyleInlineConfig
|
|
3
|
-
} from "./chunk-7GIJVX4M.js";
|
|
4
1
|
import {
|
|
5
2
|
DEFAULT_BROWSER_VERSIONS,
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
} from "./chunk-OAFXM4ES.js";
|
|
3
|
+
LANGUAGES
|
|
4
|
+
} from "./chunk-DK3HFVHX.js";
|
|
9
5
|
|
|
10
|
-
// src/
|
|
11
|
-
import "
|
|
12
|
-
import
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
parseArgs
|
|
16
|
-
}) {
|
|
17
|
-
return (argv) => {
|
|
18
|
-
const program = setupProgram();
|
|
19
|
-
program.parse(argv);
|
|
20
|
-
let options = program.opts();
|
|
21
|
-
options = parseArgs?.(options, program.args ?? []) || options;
|
|
22
|
-
options = warnDeprecatedFlags(options);
|
|
23
|
-
return v.parse(VivliostyleInlineConfig, options);
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
function setupConfigFromFlags(flags) {
|
|
27
|
-
if (!flags.input) {
|
|
28
|
-
if (flags.enableViewerStartPage) {
|
|
29
|
-
return {
|
|
30
|
-
tasks: [{ entry: [] }],
|
|
31
|
-
inlineOptions: {
|
|
32
|
-
input: { format: "webbook", entry: EMPTY_DATA_URI }
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
} else {
|
|
36
|
-
throw new Error(
|
|
37
|
-
"No input is set. Please set an appropriate entry or a Vivliostyle config file."
|
|
38
|
-
);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
return {
|
|
42
|
-
tasks: [{ entry: [] }],
|
|
43
|
-
inlineOptions: { ...flags }
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
function warnDeprecatedFlags(options) {
|
|
47
|
-
const modifiedOptions = { ...options };
|
|
48
|
-
return modifiedOptions;
|
|
49
|
-
}
|
|
6
|
+
// src/logger.ts
|
|
7
|
+
import debug from "debug";
|
|
8
|
+
import { Console } from "node:console";
|
|
9
|
+
import yoctoSpinner from "yocto-spinner";
|
|
10
|
+
import { blueBright, greenBright, redBright as redBright2, yellowBright } from "yoctocolors";
|
|
50
11
|
|
|
51
12
|
// src/util.ts
|
|
52
13
|
import { codeFrameColumns } from "@babel/code-frame";
|
|
53
14
|
import {
|
|
54
15
|
evaluate,
|
|
55
|
-
parse
|
|
16
|
+
parse
|
|
56
17
|
} from "@humanwhocodes/momoa";
|
|
57
18
|
import { Ajv } from "ajv";
|
|
58
19
|
import formatsPlugin from "ajv-formats";
|
|
59
20
|
import { XMLParser } from "fast-xml-parser";
|
|
60
|
-
import lcid from "lcid";
|
|
61
21
|
import StreamZip from "node-stream-zip";
|
|
62
22
|
import childProcess from "node:child_process";
|
|
63
23
|
import fs from "node:fs";
|
|
64
24
|
import os from "node:os";
|
|
65
|
-
import
|
|
25
|
+
import { fileURLToPath } from "node:url";
|
|
66
26
|
import util from "node:util";
|
|
67
|
-
import
|
|
27
|
+
import osLocale from "os-locale";
|
|
28
|
+
import resolvePkg from "resolve-pkg";
|
|
68
29
|
import { titleCase } from "title-case";
|
|
69
30
|
import tmp from "tmp";
|
|
70
31
|
import upath from "upath";
|
|
71
|
-
import { gray, red, redBright
|
|
72
|
-
|
|
73
|
-
// src/logger.ts
|
|
74
|
-
import debug from "debug";
|
|
75
|
-
import { Console } from "node:console";
|
|
76
|
-
import yoctoSpinner from "yocto-spinner";
|
|
77
|
-
import { blueBright, greenBright, redBright, yellowBright } from "yoctocolors";
|
|
78
|
-
var isUnicodeSupported = process.platform !== "win32" || Boolean(process.env.WT_SESSION);
|
|
79
|
-
var randomBookSymbol = ["\u{1F4D5}", "\u{1F4D7}", "\u{1F4D8}", "\u{1F4D9}"][Math.floor(Math.random() * 4)];
|
|
80
|
-
var spinnerFrames = isUnicodeSupported ? ["\u2581\u2581\u2571 ", "\u2581\u2551\u2581 ", "\u2572\u2581\u2581 ", "\u2581\u2581\u2581 ", "\u2581\u2581\u2581 ", "\u2581\u2581\u2581 "] : ["- ", "\\ ", "| ", "/ "];
|
|
81
|
-
var spinnerInterval = 80;
|
|
82
|
-
var infoSymbol = blueBright("INFO");
|
|
83
|
-
var successSymbol = greenBright("SUCCESS");
|
|
84
|
-
var warnSymbol = yellowBright("WARN");
|
|
85
|
-
var errorSymbol = redBright("ERROR");
|
|
86
|
-
var Logger = class _Logger {
|
|
87
|
-
/**
|
|
88
|
-
* 0: silent 1: info 2: verbose 3: debug
|
|
89
|
-
*/
|
|
90
|
-
static #logLevel = 0;
|
|
91
|
-
static #loggerInstance;
|
|
92
|
-
static #nonBlockingLogPrinted = false;
|
|
93
|
-
static #customLogger;
|
|
94
|
-
static #logPrefix;
|
|
95
|
-
static #stdin = process.stdin;
|
|
96
|
-
static #stdout = process.stdout;
|
|
97
|
-
static #stderr = process.stderr;
|
|
98
|
-
static #signal;
|
|
99
|
-
static debug = debug("vs-cli");
|
|
100
|
-
static get #console() {
|
|
101
|
-
if (this.#customLogger) {
|
|
102
|
-
return {
|
|
103
|
-
...this.#customLogger,
|
|
104
|
-
log: () => {
|
|
105
|
-
}
|
|
106
|
-
};
|
|
107
|
-
}
|
|
108
|
-
return new Console({
|
|
109
|
-
stdout: this.#stdout,
|
|
110
|
-
stderr: this.#stderr
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
static get #spinner() {
|
|
114
|
-
return this.#loggerInstance && this.#loggerInstance.#_spinner;
|
|
115
|
-
}
|
|
116
|
-
static get stdin() {
|
|
117
|
-
return this.#stdin;
|
|
118
|
-
}
|
|
119
|
-
static get stdout() {
|
|
120
|
-
return this.#stdout;
|
|
121
|
-
}
|
|
122
|
-
static get stderr() {
|
|
123
|
-
return this.#stderr;
|
|
124
|
-
}
|
|
125
|
-
static get signal() {
|
|
126
|
-
return this.#signal;
|
|
127
|
-
}
|
|
128
|
-
static get isInteractive() {
|
|
129
|
-
return Boolean(
|
|
130
|
-
!this.#customLogger && this.#stderr.isTTY && process.env.TERM !== "dumb" && !("CI" in process.env) && !import.meta.env?.VITEST && !debug.enabled("vs-cli") && // Prevent stream output in docker container so that not to spawn process
|
|
131
|
-
!isInContainer()
|
|
132
|
-
);
|
|
133
|
-
}
|
|
134
|
-
static startLogging(text) {
|
|
135
|
-
if (this.#logLevel === 0) {
|
|
136
|
-
return;
|
|
137
|
-
}
|
|
138
|
-
if (!this.isInteractive) {
|
|
139
|
-
this.logInfo(text);
|
|
140
|
-
return;
|
|
141
|
-
}
|
|
142
|
-
if (this.#loggerInstance) {
|
|
143
|
-
this.#loggerInstance.#_spinner.text = text;
|
|
144
|
-
return this.#loggerInstance;
|
|
145
|
-
}
|
|
146
|
-
this.#loggerInstance = new _Logger(this.#stderr);
|
|
147
|
-
this.#loggerInstance.#start(text);
|
|
148
|
-
return this.#loggerInstance;
|
|
149
|
-
}
|
|
150
|
-
static suspendLogging(text) {
|
|
151
|
-
if (this.#logLevel === 0) {
|
|
152
|
-
return;
|
|
153
|
-
}
|
|
154
|
-
if (!this.#spinner || !this.isInteractive) {
|
|
155
|
-
this.logInfo(text);
|
|
156
|
-
return;
|
|
157
|
-
}
|
|
158
|
-
const currentMsg = this.#spinner?.text;
|
|
159
|
-
this.logUpdate(currentMsg);
|
|
160
|
-
this.#spinner.stop(`${infoSymbol} ${text}
|
|
161
|
-
`);
|
|
162
|
-
return {
|
|
163
|
-
[Symbol.dispose]() {
|
|
164
|
-
if (_Logger.isInteractive) {
|
|
165
|
-
_Logger.#console.log("");
|
|
166
|
-
_Logger.#spinner?.start(currentMsg);
|
|
167
|
-
_Logger.#nonBlockingLogPrinted = true;
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
};
|
|
171
|
-
}
|
|
172
|
-
static log(...messages) {
|
|
173
|
-
if (this.#logLevel < 1) {
|
|
174
|
-
return;
|
|
175
|
-
}
|
|
176
|
-
_Logger.#console.log(...messages);
|
|
177
|
-
}
|
|
178
|
-
static logUpdate(...messages) {
|
|
179
|
-
if (!this.#spinner || !this.isInteractive) {
|
|
180
|
-
this.logInfo(...messages);
|
|
181
|
-
return;
|
|
182
|
-
}
|
|
183
|
-
this.#spinner.stop(
|
|
184
|
-
this.#nonBlockingLogPrinted ? void 0 : `${infoSymbol} ${this.#spinner.text}`
|
|
185
|
-
);
|
|
186
|
-
this.#spinner.start(messages.join(" "));
|
|
187
|
-
this.#nonBlockingLogPrinted = false;
|
|
188
|
-
}
|
|
189
|
-
static getMessage(message, symbol) {
|
|
190
|
-
return !this.#customLogger && symbol ? `${symbol} ${message}` : message;
|
|
191
|
-
}
|
|
192
|
-
static #nonBlockingLog(logMethod, message) {
|
|
193
|
-
if (!this.#spinner || !this.isInteractive) {
|
|
194
|
-
if (this.#logPrefix) {
|
|
195
|
-
message = `${this.#logPrefix} ${message}`;
|
|
196
|
-
}
|
|
197
|
-
this.#logLevel >= 3 ? this.debug(message) : this.#console[logMethod](message);
|
|
198
|
-
return;
|
|
199
|
-
}
|
|
200
|
-
this.logUpdate(this.#spinner.text);
|
|
201
|
-
this.#nonBlockingLogPrinted = true;
|
|
202
|
-
this.#spinner.stop(message);
|
|
203
|
-
this.#spinner.start();
|
|
204
|
-
}
|
|
205
|
-
static logSuccess(...messages) {
|
|
206
|
-
if (this.#logLevel < 1) {
|
|
207
|
-
return;
|
|
208
|
-
}
|
|
209
|
-
this.#nonBlockingLog(
|
|
210
|
-
"info",
|
|
211
|
-
this.getMessage(messages.join(" "), successSymbol)
|
|
212
|
-
);
|
|
213
|
-
}
|
|
214
|
-
static logError(...messages) {
|
|
215
|
-
if (this.#logLevel < 1) {
|
|
216
|
-
return;
|
|
217
|
-
}
|
|
218
|
-
this.#nonBlockingLog(
|
|
219
|
-
"error",
|
|
220
|
-
this.getMessage(messages.join(" "), errorSymbol)
|
|
221
|
-
);
|
|
222
|
-
}
|
|
223
|
-
static logWarn(...messages) {
|
|
224
|
-
if (this.#logLevel < 1) {
|
|
225
|
-
return;
|
|
226
|
-
}
|
|
227
|
-
this.#nonBlockingLog(
|
|
228
|
-
"warn",
|
|
229
|
-
this.getMessage(messages.join(" "), warnSymbol)
|
|
230
|
-
);
|
|
231
|
-
}
|
|
232
|
-
static logInfo(...messages) {
|
|
233
|
-
if (this.#logLevel < 1) {
|
|
234
|
-
return;
|
|
235
|
-
}
|
|
236
|
-
this.#nonBlockingLog(
|
|
237
|
-
"info",
|
|
238
|
-
this.getMessage(messages.join(" "), infoSymbol)
|
|
239
|
-
);
|
|
240
|
-
}
|
|
241
|
-
static logVerbose(...messages) {
|
|
242
|
-
if (this.#logLevel < 2) {
|
|
243
|
-
return;
|
|
244
|
-
}
|
|
245
|
-
this.#nonBlockingLog("info", this.getMessage(messages.join(" ")));
|
|
246
|
-
}
|
|
247
|
-
static setLogOptions({
|
|
248
|
-
logLevel,
|
|
249
|
-
logger,
|
|
250
|
-
stdin,
|
|
251
|
-
stdout,
|
|
252
|
-
stderr,
|
|
253
|
-
signal
|
|
254
|
-
}) {
|
|
255
|
-
if (logLevel) {
|
|
256
|
-
this.#logLevel = {
|
|
257
|
-
silent: 0,
|
|
258
|
-
info: 1,
|
|
259
|
-
verbose: 2,
|
|
260
|
-
debug: 3
|
|
261
|
-
}[logLevel];
|
|
262
|
-
if (this.#logLevel >= 3) {
|
|
263
|
-
debug.enable("vs-cli");
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
if (logger) {
|
|
267
|
-
this.#customLogger = logger;
|
|
268
|
-
}
|
|
269
|
-
if (stdin) {
|
|
270
|
-
this.#stdin = stdin;
|
|
271
|
-
}
|
|
272
|
-
if (stdout) {
|
|
273
|
-
this.#stdout = stdout;
|
|
274
|
-
}
|
|
275
|
-
if (stderr) {
|
|
276
|
-
this.#stderr = stderr;
|
|
277
|
-
}
|
|
278
|
-
if (signal) {
|
|
279
|
-
this.#signal = signal;
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
static setLogPrefix(prefix) {
|
|
283
|
-
this.#logPrefix = prefix;
|
|
284
|
-
}
|
|
285
|
-
#_spinner;
|
|
286
|
-
#_disposeSpinnerExitHandler;
|
|
287
|
-
constructor(stream) {
|
|
288
|
-
this.#_spinner = yoctoSpinner({
|
|
289
|
-
spinner: {
|
|
290
|
-
frames: spinnerFrames,
|
|
291
|
-
interval: spinnerInterval
|
|
292
|
-
},
|
|
293
|
-
color: "gray",
|
|
294
|
-
stream
|
|
295
|
-
});
|
|
296
|
-
return this;
|
|
297
|
-
}
|
|
298
|
-
#start(text) {
|
|
299
|
-
this.#_spinner.start(text);
|
|
300
|
-
this.#_disposeSpinnerExitHandler = registerExitHandler(
|
|
301
|
-
"Stopping spinner",
|
|
302
|
-
() => {
|
|
303
|
-
this.#_spinner.stop();
|
|
304
|
-
}
|
|
305
|
-
);
|
|
306
|
-
}
|
|
307
|
-
[Symbol.dispose]() {
|
|
308
|
-
this.#_disposeSpinnerExitHandler?.();
|
|
309
|
-
this.#_spinner.stop(
|
|
310
|
-
_Logger.#nonBlockingLogPrinted ? void 0 : `${infoSymbol} ${this.#_spinner.text}`
|
|
311
|
-
);
|
|
312
|
-
_Logger.#loggerInstance = void 0;
|
|
313
|
-
}
|
|
314
|
-
};
|
|
32
|
+
import { gray, red, redBright } from "yoctocolors";
|
|
315
33
|
|
|
316
34
|
// schemas/pub-manifest/module/bcp.schema.json
|
|
317
35
|
var bcp_schema_default = {
|
|
@@ -908,35 +626,25 @@ async function runExitHandlers() {
|
|
|
908
626
|
}
|
|
909
627
|
}
|
|
910
628
|
}
|
|
911
|
-
var
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
629
|
+
var terminating = false;
|
|
630
|
+
async function terminate(exitCode) {
|
|
631
|
+
if (terminating) return;
|
|
632
|
+
terminating = true;
|
|
633
|
+
try {
|
|
634
|
+
if (exitCode === 130 || exitCode === 143) {
|
|
915
635
|
await runExitHandlers();
|
|
916
636
|
} else {
|
|
917
|
-
|
|
918
|
-
}
|
|
919
|
-
if (process.exitCode === void 0) {
|
|
920
|
-
process.exitCode = exitCode !== void 0 ? 128 + exitCode : Number(signal);
|
|
921
|
-
}
|
|
922
|
-
if (sig !== "exit") {
|
|
923
|
-
process.exit();
|
|
637
|
+
runExitHandlers();
|
|
924
638
|
}
|
|
925
|
-
}
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
const rl = readline.createInterface({
|
|
929
|
-
input: process.stdin,
|
|
930
|
-
output: process.stdout
|
|
931
|
-
});
|
|
932
|
-
rl.on("SIGINT", async () => {
|
|
933
|
-
await runExitHandlers();
|
|
934
|
-
process.exit(130);
|
|
935
|
-
});
|
|
936
|
-
registerExitHandler("Closing readline interface", () => {
|
|
937
|
-
rl.close();
|
|
938
|
-
});
|
|
639
|
+
} finally {
|
|
640
|
+
process.exit(exitCode);
|
|
641
|
+
}
|
|
939
642
|
}
|
|
643
|
+
process.once("SIGINT", () => void terminate(130));
|
|
644
|
+
process.once("SIGTERM", () => void terminate(143));
|
|
645
|
+
process.once("exit", (code) => {
|
|
646
|
+
void runExitHandlers();
|
|
647
|
+
});
|
|
940
648
|
var DetailError = class extends Error {
|
|
941
649
|
detail;
|
|
942
650
|
constructor(message, detail) {
|
|
@@ -949,7 +657,7 @@ function getFormattedError(err) {
|
|
|
949
657
|
${err.detail}` : err.stack || `${err.message}`;
|
|
950
658
|
}
|
|
951
659
|
function gracefulError(err) {
|
|
952
|
-
console.log(`${
|
|
660
|
+
console.log(`${redBright("ERROR")} ${getFormattedError(err)}
|
|
953
661
|
|
|
954
662
|
${gray("If you think this is a bug, please report at https://github.com/vivliostyle/vivliostyle-cli/issues")}`);
|
|
955
663
|
process.exit(1);
|
|
@@ -1103,7 +811,7 @@ var assertPubManifestSchema = getAjvValidatorFunction(
|
|
|
1103
811
|
publicationSchemas
|
|
1104
812
|
);
|
|
1105
813
|
function parseJsonc(rawJsonc) {
|
|
1106
|
-
const ast =
|
|
814
|
+
const ast = parse(rawJsonc, {
|
|
1107
815
|
mode: "jsonc",
|
|
1108
816
|
ranges: false,
|
|
1109
817
|
tokens: false
|
|
@@ -1111,7 +819,7 @@ function parseJsonc(rawJsonc) {
|
|
|
1111
819
|
return evaluate(ast);
|
|
1112
820
|
}
|
|
1113
821
|
function prettifySchemaError(rawJsonc, issues) {
|
|
1114
|
-
const parsed =
|
|
822
|
+
const parsed = parse(rawJsonc, {
|
|
1115
823
|
mode: "jsonc",
|
|
1116
824
|
ranges: false,
|
|
1117
825
|
tokens: false
|
|
@@ -1132,7 +840,7 @@ function prettifySchemaError(rawJsonc, issues) {
|
|
|
1132
840
|
const maxDepth = Math.max(...all.map(([, d]) => d));
|
|
1133
841
|
const issuesTraversed = all.find(([, d]) => d === maxDepth)[0];
|
|
1134
842
|
let jsonValue = parsed.body;
|
|
1135
|
-
for (const p of issuesTraversed.flatMap((
|
|
843
|
+
for (const p of issuesTraversed.flatMap((v) => v.path ?? [])) {
|
|
1136
844
|
let childValue;
|
|
1137
845
|
if (p.type === "object" && jsonValue.type === "Object") {
|
|
1138
846
|
childValue = jsonValue.members.find(
|
|
@@ -1166,36 +874,15 @@ function writeFileIfChanged(filePath, content) {
|
|
|
1166
874
|
var cachedLocale;
|
|
1167
875
|
async function getOsLocale() {
|
|
1168
876
|
if (import.meta.env?.VITEST) {
|
|
1169
|
-
return process.env.TEST_LOCALE || "en";
|
|
1170
|
-
}
|
|
1171
|
-
if (cachedLocale) {
|
|
1172
|
-
return cachedLocale;
|
|
1173
|
-
}
|
|
1174
|
-
let locale;
|
|
1175
|
-
if (process.platform === "win32") {
|
|
1176
|
-
const { stdout } = await exec("wmic", ["os", "get", "locale"]);
|
|
1177
|
-
const lcidCode = Number.parseInt(stdout.replace("Locale", ""), 16);
|
|
1178
|
-
locale = lcid.from(lcidCode);
|
|
1179
|
-
}
|
|
1180
|
-
if (process.platform === "darwin") {
|
|
1181
|
-
const results = await Promise.all([
|
|
1182
|
-
exec("defaults", ["read", "-globalDomain", "AppleLocale"]).then(
|
|
1183
|
-
({ stdout }) => stdout
|
|
1184
|
-
),
|
|
1185
|
-
exec("locale", ["-a"]).then(({ stdout }) => stdout)
|
|
1186
|
-
]);
|
|
1187
|
-
if (results[1].includes(results[0])) {
|
|
1188
|
-
locale = results[0];
|
|
1189
|
-
}
|
|
877
|
+
return process.env.TEST_LOCALE || "en";
|
|
1190
878
|
}
|
|
1191
|
-
if (
|
|
1192
|
-
|
|
1193
|
-
} else {
|
|
1194
|
-
locale = await osLocale();
|
|
879
|
+
if (cachedLocale) {
|
|
880
|
+
return cachedLocale;
|
|
1195
881
|
}
|
|
1196
|
-
const
|
|
1197
|
-
|
|
1198
|
-
|
|
882
|
+
const locale = osLocale();
|
|
883
|
+
const langs = Object.keys(LANGUAGES);
|
|
884
|
+
cachedLocale = langs.includes(locale) ? locale : langs.includes(locale.split("-")[0]) ? locale.split("-")[0] : "en";
|
|
885
|
+
return cachedLocale;
|
|
1199
886
|
}
|
|
1200
887
|
function toTitleCase(input) {
|
|
1201
888
|
if (typeof input !== "string") {
|
|
@@ -1288,161 +975,275 @@ function whichPm() {
|
|
|
1288
975
|
const name = pmSpec.substring(0, separatorPos);
|
|
1289
976
|
return name;
|
|
1290
977
|
}
|
|
978
|
+
var cliRoot = upath.join(fileURLToPath(import.meta.url), "../..");
|
|
979
|
+
var cliVersion = (() => {
|
|
980
|
+
if (import.meta.env?.VITEST) {
|
|
981
|
+
return "0.0.1";
|
|
982
|
+
}
|
|
983
|
+
const pkg = JSON.parse(
|
|
984
|
+
fs.readFileSync(upath.join(cliRoot, "package.json"), "utf8")
|
|
985
|
+
);
|
|
986
|
+
return pkg.version;
|
|
987
|
+
})();
|
|
988
|
+
var viewerRoot = resolvePkg("@vivliostyle/viewer", { cwd: cliRoot });
|
|
989
|
+
var coreVersion = (() => {
|
|
990
|
+
if (import.meta.env?.VITEST) {
|
|
991
|
+
return "0.0.1";
|
|
992
|
+
}
|
|
993
|
+
if (!viewerRoot) {
|
|
994
|
+
return "Unknown";
|
|
995
|
+
}
|
|
996
|
+
const pkg = JSON.parse(
|
|
997
|
+
fs.readFileSync(upath.join(viewerRoot, "package.json"), "utf8")
|
|
998
|
+
);
|
|
999
|
+
return pkg.version;
|
|
1000
|
+
})();
|
|
1001
|
+
var versionForDisplay = `cli: ${cliVersion}
|
|
1002
|
+
core: ${coreVersion}`;
|
|
1291
1003
|
|
|
1292
|
-
// src/
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
var
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1004
|
+
// src/logger.ts
|
|
1005
|
+
var isUnicodeSupported = process.platform !== "win32" || Boolean(process.env.WT_SESSION);
|
|
1006
|
+
var randomBookSymbol = ["\u{1F4D5}", "\u{1F4D7}", "\u{1F4D8}", "\u{1F4D9}"][Math.floor(Math.random() * 4)];
|
|
1007
|
+
var spinnerFrames = isUnicodeSupported ? ["\u2581\u2581\u2571 ", "\u2581\u2551\u2581 ", "\u2572\u2581\u2581 ", "\u2581\u2581\u2581 ", "\u2581\u2581\u2581 ", "\u2581\u2581\u2581 "] : ["- ", "\\ ", "| ", "/ "];
|
|
1008
|
+
var spinnerInterval = 80;
|
|
1009
|
+
var infoSymbol = blueBright("INFO");
|
|
1010
|
+
var successSymbol = greenBright("SUCCESS");
|
|
1011
|
+
var warnSymbol = yellowBright("WARN");
|
|
1012
|
+
var errorSymbol = redBright2("ERROR");
|
|
1013
|
+
var Logger = class _Logger {
|
|
1014
|
+
/**
|
|
1015
|
+
* 0: silent 1: info 2: verbose 3: debug
|
|
1016
|
+
*/
|
|
1017
|
+
static #logLevel = 0;
|
|
1018
|
+
static #loggerInstance;
|
|
1019
|
+
static #nonBlockingLogPrinted = false;
|
|
1020
|
+
static #customLogger;
|
|
1021
|
+
static #logPrefix;
|
|
1022
|
+
static #stdin = process.stdin;
|
|
1023
|
+
static #stdout = process.stdout;
|
|
1024
|
+
static #stderr = process.stderr;
|
|
1025
|
+
static #signal;
|
|
1026
|
+
static debug = debug("vs-cli");
|
|
1027
|
+
static get #console() {
|
|
1028
|
+
if (this.#customLogger) {
|
|
1029
|
+
return {
|
|
1030
|
+
...this.#customLogger,
|
|
1031
|
+
log: () => {
|
|
1032
|
+
}
|
|
1033
|
+
};
|
|
1034
|
+
}
|
|
1035
|
+
return new Console({
|
|
1036
|
+
stdout: this.#stdout,
|
|
1037
|
+
stderr: this.#stderr
|
|
1038
|
+
});
|
|
1039
|
+
}
|
|
1040
|
+
static get #spinner() {
|
|
1041
|
+
return this.#loggerInstance && this.#loggerInstance.#_spinner;
|
|
1042
|
+
}
|
|
1043
|
+
static get stdin() {
|
|
1044
|
+
return this.#stdin;
|
|
1045
|
+
}
|
|
1046
|
+
static get stdout() {
|
|
1047
|
+
return this.#stdout;
|
|
1048
|
+
}
|
|
1049
|
+
static get stderr() {
|
|
1050
|
+
return this.#stderr;
|
|
1051
|
+
}
|
|
1052
|
+
static get signal() {
|
|
1053
|
+
return this.#signal;
|
|
1054
|
+
}
|
|
1055
|
+
static get isInteractive() {
|
|
1056
|
+
return Boolean(
|
|
1057
|
+
!this.#customLogger && this.#stderr.isTTY && process.env.TERM !== "dumb" && !("CI" in process.env) && !import.meta.env?.VITEST && !debug.enabled("vs-cli") && // Prevent stream output in docker container so that not to spawn process
|
|
1058
|
+
!isInContainer()
|
|
1305
1059
|
);
|
|
1306
1060
|
}
|
|
1307
|
-
|
|
1308
|
-
|
|
1061
|
+
static startLogging(text) {
|
|
1062
|
+
if (this.#logLevel === 0) {
|
|
1063
|
+
return;
|
|
1064
|
+
}
|
|
1065
|
+
if (!this.isInteractive) {
|
|
1066
|
+
this.logInfo(text);
|
|
1067
|
+
return;
|
|
1068
|
+
}
|
|
1069
|
+
if (this.#loggerInstance) {
|
|
1070
|
+
this.#loggerInstance.#_spinner.text = text;
|
|
1071
|
+
return this.#loggerInstance;
|
|
1072
|
+
}
|
|
1073
|
+
this.#loggerInstance = new _Logger(this.#stderr);
|
|
1074
|
+
this.#loggerInstance.#start(text);
|
|
1075
|
+
return this.#loggerInstance;
|
|
1076
|
+
}
|
|
1077
|
+
static suspendLogging(text) {
|
|
1078
|
+
if (this.#logLevel === 0) {
|
|
1079
|
+
return;
|
|
1080
|
+
}
|
|
1081
|
+
if (!this.#spinner || !this.isInteractive) {
|
|
1082
|
+
this.logInfo(text);
|
|
1083
|
+
return;
|
|
1084
|
+
}
|
|
1085
|
+
const currentMsg = this.#spinner?.text;
|
|
1086
|
+
this.logUpdate(currentMsg);
|
|
1087
|
+
this.#spinner.stop(`${infoSymbol} ${text}
|
|
1088
|
+
`);
|
|
1089
|
+
return {
|
|
1090
|
+
[Symbol.dispose]() {
|
|
1091
|
+
if (_Logger.isInteractive) {
|
|
1092
|
+
_Logger.#console.log("");
|
|
1093
|
+
_Logger.#spinner?.start(currentMsg);
|
|
1094
|
+
_Logger.#nonBlockingLogPrinted = true;
|
|
1095
|
+
}
|
|
1096
|
+
}
|
|
1097
|
+
};
|
|
1098
|
+
}
|
|
1099
|
+
static log(...messages) {
|
|
1100
|
+
if (this.#logLevel < 1) {
|
|
1101
|
+
return;
|
|
1102
|
+
}
|
|
1103
|
+
_Logger.#console.log(...messages);
|
|
1309
1104
|
}
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1105
|
+
static logUpdate(...messages) {
|
|
1106
|
+
if (!this.#spinner || !this.isInteractive) {
|
|
1107
|
+
this.logInfo(...messages);
|
|
1108
|
+
return;
|
|
1109
|
+
}
|
|
1110
|
+
this.#spinner.stop(
|
|
1111
|
+
this.#nonBlockingLogPrinted ? void 0 : `${infoSymbol} ${this.#spinner.text}`
|
|
1317
1112
|
);
|
|
1113
|
+
this.#spinner.start(messages.join(" "));
|
|
1114
|
+
this.#nonBlockingLogPrinted = false;
|
|
1318
1115
|
}
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
function getIgnoreAssetPatterns({
|
|
1330
|
-
outputs,
|
|
1331
|
-
entries,
|
|
1332
|
-
cwd: cwd2
|
|
1333
|
-
}) {
|
|
1334
|
-
return [
|
|
1335
|
-
...outputs.flatMap(
|
|
1336
|
-
({ format, path: p }) => !pathContains(cwd2, p) ? [] : format === "webpub" ? upath2.join(upath2.relative(cwd2, p), "**") : upath2.relative(cwd2, p)
|
|
1337
|
-
),
|
|
1338
|
-
...entries.flatMap(({ template }) => {
|
|
1339
|
-
return template?.type === "file" && pathContains(cwd2, template.pathname) ? upath2.relative(cwd2, template.pathname) : [];
|
|
1340
|
-
})
|
|
1341
|
-
];
|
|
1342
|
-
}
|
|
1343
|
-
function getWebPubResourceMatcher({
|
|
1344
|
-
outputs,
|
|
1345
|
-
themesDir,
|
|
1346
|
-
entries,
|
|
1347
|
-
cwd: cwd2,
|
|
1348
|
-
manifestPath,
|
|
1349
|
-
copyAsset: { fileExtensions }
|
|
1350
|
-
}) {
|
|
1351
|
-
return new GlobMatcher([
|
|
1352
|
-
{
|
|
1353
|
-
patterns: [
|
|
1354
|
-
`**/${upath2.relative(cwd2, manifestPath)}`,
|
|
1355
|
-
"**/*.{html,htm,xhtml,xht}",
|
|
1356
|
-
`**/*.{${fileExtensions.join(",")}}`
|
|
1357
|
-
],
|
|
1358
|
-
ignore: [
|
|
1359
|
-
...getIgnoreAssetPatterns({
|
|
1360
|
-
cwd: cwd2,
|
|
1361
|
-
outputs,
|
|
1362
|
-
entries
|
|
1363
|
-
}),
|
|
1364
|
-
...getIgnoreThemeDirectoryPatterns({
|
|
1365
|
-
cwd: cwd2,
|
|
1366
|
-
themesDir
|
|
1367
|
-
}),
|
|
1368
|
-
// Ignore node_modules in the root directory
|
|
1369
|
-
"node_modules/**",
|
|
1370
|
-
// only include dotfiles starting with `.vs-`
|
|
1371
|
-
"**/.!(vs-*)/**"
|
|
1372
|
-
],
|
|
1373
|
-
dot: true,
|
|
1374
|
-
cwd: cwd2
|
|
1116
|
+
static getMessage(message, symbol) {
|
|
1117
|
+
return !this.#customLogger && symbol ? `${symbol} ${message}` : message;
|
|
1118
|
+
}
|
|
1119
|
+
static #nonBlockingLog(logMethod, message) {
|
|
1120
|
+
if (!this.#spinner || !this.isInteractive) {
|
|
1121
|
+
if (this.#logPrefix) {
|
|
1122
|
+
message = `${this.#logPrefix} ${message}`;
|
|
1123
|
+
}
|
|
1124
|
+
this.#logLevel >= 3 ? this.debug(message) : this.#console[logMethod](message);
|
|
1125
|
+
return;
|
|
1375
1126
|
}
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
ignore = []
|
|
1385
|
-
}) {
|
|
1386
|
-
const ignorePatterns = [
|
|
1387
|
-
...ignore,
|
|
1388
|
-
...excludes,
|
|
1389
|
-
...getIgnoreAssetPatterns({ outputs, entries, cwd: cwd2 })
|
|
1390
|
-
];
|
|
1391
|
-
return new GlobMatcher([
|
|
1392
|
-
// Step 1: Glob files with an extension in `fileExtension`
|
|
1393
|
-
// Ignore files in node_modules directory, theme example files and files matched `excludes`
|
|
1394
|
-
{
|
|
1395
|
-
patterns: fileExtensions.map((ext) => `**/*.${ext}`),
|
|
1396
|
-
ignore: [
|
|
1397
|
-
"**/node_modules/**",
|
|
1398
|
-
...ignorePatterns,
|
|
1399
|
-
...getIgnoreThemeDirectoryPatterns({ themesDir, cwd: cwd2 })
|
|
1400
|
-
],
|
|
1401
|
-
cwd: cwd2
|
|
1402
|
-
},
|
|
1403
|
-
// Step 2: Glob files matched with `includes`
|
|
1404
|
-
// Ignore only files matched `excludes`
|
|
1405
|
-
{
|
|
1406
|
-
patterns: includes,
|
|
1407
|
-
ignore: ignorePatterns,
|
|
1408
|
-
cwd: cwd2
|
|
1127
|
+
this.logUpdate(this.#spinner.text);
|
|
1128
|
+
this.#nonBlockingLogPrinted = true;
|
|
1129
|
+
this.#spinner.stop(message);
|
|
1130
|
+
this.#spinner.start();
|
|
1131
|
+
}
|
|
1132
|
+
static logSuccess(...messages) {
|
|
1133
|
+
if (this.#logLevel < 1) {
|
|
1134
|
+
return;
|
|
1409
1135
|
}
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
workspaceDir,
|
|
1415
|
-
copyAsset,
|
|
1416
|
-
outputs,
|
|
1417
|
-
themesDir,
|
|
1418
|
-
entries
|
|
1419
|
-
}) {
|
|
1420
|
-
if (pathEquals(entryContextDir, workspaceDir)) {
|
|
1421
|
-
return;
|
|
1136
|
+
this.#nonBlockingLog(
|
|
1137
|
+
"info",
|
|
1138
|
+
this.getMessage(messages.join(" "), successSymbol)
|
|
1139
|
+
);
|
|
1422
1140
|
}
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
// don't copy workspace itself
|
|
1432
|
-
...relWorkspaceDir ? [upath2.join(relWorkspaceDir, "**")] : []
|
|
1433
|
-
]
|
|
1434
|
-
}).glob({ followSymbolicLinks: true });
|
|
1435
|
-
Logger.debug("assets", assets);
|
|
1436
|
-
for (const asset of assets) {
|
|
1437
|
-
const target = upath2.join(workspaceDir, asset);
|
|
1438
|
-
fs2.mkdirSync(upath2.dirname(target), { recursive: true });
|
|
1439
|
-
await copy(upath2.resolve(entryContextDir, asset), target);
|
|
1141
|
+
static logError(...messages) {
|
|
1142
|
+
if (this.#logLevel < 1) {
|
|
1143
|
+
return;
|
|
1144
|
+
}
|
|
1145
|
+
this.#nonBlockingLog(
|
|
1146
|
+
"error",
|
|
1147
|
+
this.getMessage(messages.join(" "), errorSymbol)
|
|
1148
|
+
);
|
|
1440
1149
|
}
|
|
1441
|
-
|
|
1150
|
+
static logWarn(...messages) {
|
|
1151
|
+
if (this.#logLevel < 1) {
|
|
1152
|
+
return;
|
|
1153
|
+
}
|
|
1154
|
+
this.#nonBlockingLog(
|
|
1155
|
+
"warn",
|
|
1156
|
+
this.getMessage(messages.join(" "), warnSymbol)
|
|
1157
|
+
);
|
|
1158
|
+
}
|
|
1159
|
+
static logInfo(...messages) {
|
|
1160
|
+
if (this.#logLevel < 1) {
|
|
1161
|
+
return;
|
|
1162
|
+
}
|
|
1163
|
+
this.#nonBlockingLog(
|
|
1164
|
+
"info",
|
|
1165
|
+
this.getMessage(messages.join(" "), infoSymbol)
|
|
1166
|
+
);
|
|
1167
|
+
}
|
|
1168
|
+
static logVerbose(...messages) {
|
|
1169
|
+
if (this.#logLevel < 2) {
|
|
1170
|
+
return;
|
|
1171
|
+
}
|
|
1172
|
+
this.#nonBlockingLog("info", this.getMessage(messages.join(" ")));
|
|
1173
|
+
}
|
|
1174
|
+
static setLogOptions({
|
|
1175
|
+
logLevel,
|
|
1176
|
+
logger,
|
|
1177
|
+
stdin,
|
|
1178
|
+
stdout,
|
|
1179
|
+
stderr,
|
|
1180
|
+
signal
|
|
1181
|
+
}) {
|
|
1182
|
+
if (logLevel) {
|
|
1183
|
+
this.#logLevel = {
|
|
1184
|
+
silent: 0,
|
|
1185
|
+
info: 1,
|
|
1186
|
+
verbose: 2,
|
|
1187
|
+
debug: 3
|
|
1188
|
+
}[logLevel];
|
|
1189
|
+
if (this.#logLevel >= 3) {
|
|
1190
|
+
debug.enable("vs-cli");
|
|
1191
|
+
}
|
|
1192
|
+
}
|
|
1193
|
+
if (logger) {
|
|
1194
|
+
this.#customLogger = logger;
|
|
1195
|
+
}
|
|
1196
|
+
if (stdin) {
|
|
1197
|
+
this.#stdin = stdin;
|
|
1198
|
+
}
|
|
1199
|
+
if (stdout) {
|
|
1200
|
+
this.#stdout = stdout;
|
|
1201
|
+
}
|
|
1202
|
+
if (stderr) {
|
|
1203
|
+
this.#stderr = stderr;
|
|
1204
|
+
}
|
|
1205
|
+
if (signal) {
|
|
1206
|
+
this.#signal = signal;
|
|
1207
|
+
}
|
|
1208
|
+
}
|
|
1209
|
+
static setLogPrefix(prefix) {
|
|
1210
|
+
this.#logPrefix = prefix;
|
|
1211
|
+
}
|
|
1212
|
+
#_spinner;
|
|
1213
|
+
#_disposeSpinnerExitHandler;
|
|
1214
|
+
constructor(stream) {
|
|
1215
|
+
this.#_spinner = yoctoSpinner({
|
|
1216
|
+
spinner: {
|
|
1217
|
+
frames: spinnerFrames,
|
|
1218
|
+
interval: spinnerInterval
|
|
1219
|
+
},
|
|
1220
|
+
color: "gray",
|
|
1221
|
+
stream
|
|
1222
|
+
});
|
|
1223
|
+
return this;
|
|
1224
|
+
}
|
|
1225
|
+
#start(text) {
|
|
1226
|
+
this.#_spinner.start(text);
|
|
1227
|
+
this.#_disposeSpinnerExitHandler = registerExitHandler(
|
|
1228
|
+
"Stopping spinner",
|
|
1229
|
+
() => {
|
|
1230
|
+
this.#_spinner.stop();
|
|
1231
|
+
}
|
|
1232
|
+
);
|
|
1233
|
+
}
|
|
1234
|
+
[Symbol.dispose]() {
|
|
1235
|
+
this.#_disposeSpinnerExitHandler?.();
|
|
1236
|
+
this.#_spinner.stop(
|
|
1237
|
+
_Logger.#nonBlockingLogPrinted ? void 0 : `${infoSymbol} ${this.#_spinner.text}`
|
|
1238
|
+
);
|
|
1239
|
+
_Logger.#loggerInstance = void 0;
|
|
1240
|
+
}
|
|
1241
|
+
};
|
|
1442
1242
|
|
|
1443
1243
|
export {
|
|
1444
|
-
|
|
1445
|
-
|
|
1244
|
+
isUnicodeSupported,
|
|
1245
|
+
randomBookSymbol,
|
|
1246
|
+
Logger,
|
|
1446
1247
|
cwd,
|
|
1447
1248
|
exec,
|
|
1448
1249
|
registerExitHandler,
|
|
@@ -1473,12 +1274,9 @@ export {
|
|
|
1473
1274
|
detectBrowserPlatform,
|
|
1474
1275
|
getDefaultBrowserTag,
|
|
1475
1276
|
whichPm,
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
getWebPubResourceMatcher,
|
|
1481
|
-
getAssetMatcher,
|
|
1482
|
-
copyAssets
|
|
1277
|
+
cliVersion,
|
|
1278
|
+
viewerRoot,
|
|
1279
|
+
coreVersion,
|
|
1280
|
+
versionForDisplay
|
|
1483
1281
|
};
|
|
1484
|
-
//# sourceMappingURL=chunk-
|
|
1282
|
+
//# sourceMappingURL=chunk-VAPIKX4A.js.map
|