@vivliostyle/cli 10.3.0 → 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/README.md +7 -4
- package/dist/{chunk-RBKPG6VU.js → chunk-4DTPH2XX.js} +2 -2
- package/dist/{chunk-QLK3XMQI.js → chunk-DEJL63H2.js} +195 -130
- package/dist/chunk-DEJL63H2.js.map +1 -0
- package/dist/{chunk-ZEBXHUJX.js → chunk-DK3HFVHX.js} +27 -51
- package/dist/chunk-DK3HFVHX.js.map +1 -0
- package/dist/{chunk-3QOSSWIX.js → chunk-J2YGULSR.js} +58 -10
- package/dist/chunk-J2YGULSR.js.map +1 -0
- package/dist/{chunk-ALY3QX7K.js → chunk-L4PJ2SP3.js} +22 -25
- package/dist/chunk-L4PJ2SP3.js.map +1 -0
- package/dist/{chunk-WIGLU3EK.js → chunk-LE3QOQ5F.js} +11 -9
- package/dist/{chunk-WIGLU3EK.js.map → chunk-LE3QOQ5F.js.map} +1 -1
- package/dist/{chunk-YNX6D2I6.js → chunk-P33ELNYE.js} +342 -383
- 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-NVNEYZ3J.js → chunk-RLV2H3QB.js} +11 -11
- package/dist/chunk-RLV2H3QB.js.map +1 -0
- package/dist/{chunk-RILZCPJE.js → chunk-VAPIKX4A.js} +308 -503
- 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 +17 -10
- package/dist/commands/build.js.map +1 -1
- package/dist/commands/create.js +14 -7
- 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 +16 -9
- package/dist/commands/preview.js.map +1 -1
- package/dist/config/schema.d.ts +13293 -1796
- 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 +16 -12
- package/dist/chunk-3QOSSWIX.js.map +0 -1
- package/dist/chunk-ALY3QX7K.js.map +0 -1
- package/dist/chunk-NVNEYZ3J.js.map +0 -1
- package/dist/chunk-QLK3XMQI.js.map +0 -1
- package/dist/chunk-RILZCPJE.js.map +0 -1
- package/dist/chunk-YNX6D2I6.js.map +0 -1
- package/dist/chunk-ZEBXHUJX.js.map +0 -1
- /package/dist/{chunk-RBKPG6VU.js.map → chunk-4DTPH2XX.js.map} +0 -0
package/README.md
CHANGED
|
@@ -59,7 +59,10 @@ Options:
|
|
|
59
59
|
-l, --language <language> language
|
|
60
60
|
-s, --size <size> paper size
|
|
61
61
|
-T, --theme <theme> theme
|
|
62
|
+
--no-theme Do not include a theme.
|
|
62
63
|
--template <template> Template source in the format of `[provider]:repo[/subpath][#ref]` or as a local directory to copy from.
|
|
64
|
+
--install-dependencies Install dependencies after creating a project.
|
|
65
|
+
--no-install-dependencies Do not install dependencies after creating a project.
|
|
63
66
|
--create-config-file-only Create a Vivliostyle config file without generating project template files.
|
|
64
67
|
--proxy-server <proxyServer> HTTP/SOCK proxy server url
|
|
65
68
|
--proxy-bypass <proxyBypass> optional comma-separated domains to bypass proxy
|
|
@@ -123,8 +126,8 @@ Options:
|
|
|
123
126
|
--bleed <bleed> extent of the bleed area for printing with crop marks [3mm]
|
|
124
127
|
--crop-offset <offset> distance between the edge of the trim size and the edge of the media size. [auto (13mm + bleed)]
|
|
125
128
|
--css <CSS> custom style CSS code. (ex: ":root {--my-color: lime;}")
|
|
126
|
-
--style <stylesheet>
|
|
127
|
-
--user-style <user_stylesheet> user stylesheet
|
|
129
|
+
--style <stylesheet> Additional stylesheet for Vivliostyle viewer.
|
|
130
|
+
--user-style <user_stylesheet> Additional user stylesheet for Vivliostyle viewer.
|
|
128
131
|
-d, --single-doc single HTML document input
|
|
129
132
|
-p, --press-ready make generated PDF compatible with press ready PDF/X-1a [false]
|
|
130
133
|
This option is equivalent with "--preflight press-ready"
|
|
@@ -184,8 +187,8 @@ Options:
|
|
|
184
187
|
--bleed <bleed> extent of the bleed area for printing with crop marks [3mm]
|
|
185
188
|
--crop-offset <offset> distance between the edge of the trim size and the edge of the media size. [auto (13mm + bleed)]
|
|
186
189
|
--css <CSS> custom style CSS code. (ex: ":root {--my-color: lime;}")
|
|
187
|
-
--style <stylesheet>
|
|
188
|
-
--user-style <user_stylesheet> user stylesheet
|
|
190
|
+
--style <stylesheet> Additional stylesheet for Vivliostyle viewer.
|
|
191
|
+
--user-style <user_stylesheet> Additional user stylesheet for Vivliostyle viewer.
|
|
189
192
|
-d, --single-doc single HTML document input
|
|
190
193
|
-q, --quick quick loading with rough page count
|
|
191
194
|
--title <title> title
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Logger,
|
|
3
3
|
useTmpDirectory
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-VAPIKX4A.js";
|
|
5
5
|
|
|
6
6
|
// src/config/vite.ts
|
|
7
7
|
import upath from "upath";
|
|
@@ -75,4 +75,4 @@ async function resolveViteConfig({
|
|
|
75
75
|
export {
|
|
76
76
|
resolveViteConfig
|
|
77
77
|
};
|
|
78
|
-
//# sourceMappingURL=chunk-
|
|
78
|
+
//# sourceMappingURL=chunk-4DTPH2XX.js.map
|
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
import {
|
|
2
2
|
GlobMatcher,
|
|
3
|
+
locateVivliostyleConfig
|
|
4
|
+
} from "./chunk-Q4EIXB5V.js";
|
|
5
|
+
import {
|
|
6
|
+
ValidString,
|
|
7
|
+
VivliostyleInlineConfigWithoutChecks,
|
|
8
|
+
VivliostylePackageMetadata
|
|
9
|
+
} from "./chunk-J2YGULSR.js";
|
|
10
|
+
import {
|
|
3
11
|
Logger,
|
|
12
|
+
cliVersion,
|
|
13
|
+
coreVersion,
|
|
4
14
|
cwd,
|
|
5
15
|
getDefaultBrowserTag,
|
|
6
16
|
getOsLocale,
|
|
@@ -8,22 +18,16 @@ import {
|
|
|
8
18
|
registerExitHandler,
|
|
9
19
|
toTitleCase,
|
|
10
20
|
whichPm
|
|
11
|
-
} from "./chunk-
|
|
12
|
-
import {
|
|
13
|
-
ValidString,
|
|
14
|
-
VivliostyleInlineConfigWithoutChecks,
|
|
15
|
-
VivliostylePackageMetadata
|
|
16
|
-
} from "./chunk-3QOSSWIX.js";
|
|
21
|
+
} from "./chunk-VAPIKX4A.js";
|
|
17
22
|
import {
|
|
18
23
|
DEFAULT_CONFIG_FILENAME,
|
|
19
24
|
DEFAULT_PROJECT_AUTHOR,
|
|
20
25
|
DEFAULT_PROJECT_TITLE,
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
} from "./chunk-ZEBXHUJX.js";
|
|
26
|
+
LANGUAGES,
|
|
27
|
+
TEMPLATE_DEFAULT_PACKAGE_JSON,
|
|
28
|
+
TEMPLATE_DEFAULT_VIVLIOSTYLE_CONFIG_JS,
|
|
29
|
+
TEMPLATE_SETTINGS
|
|
30
|
+
} from "./chunk-DK3HFVHX.js";
|
|
27
31
|
import {
|
|
28
32
|
__callDispose,
|
|
29
33
|
__using
|
|
@@ -113,6 +117,7 @@ import {
|
|
|
113
117
|
} from "yoctocolors";
|
|
114
118
|
async function askQuestion({
|
|
115
119
|
question: questions,
|
|
120
|
+
interactiveLogger,
|
|
116
121
|
schema,
|
|
117
122
|
validateProgressMessage
|
|
118
123
|
}) {
|
|
@@ -166,10 +171,15 @@ async function askQuestion({
|
|
|
166
171
|
process.exit(0);
|
|
167
172
|
}
|
|
168
173
|
response[name] = result2;
|
|
174
|
+
interactiveLogger.messageHistory.push({
|
|
175
|
+
type: "question",
|
|
176
|
+
message: question.message,
|
|
177
|
+
answer: result2
|
|
178
|
+
});
|
|
169
179
|
}
|
|
170
180
|
let result;
|
|
171
181
|
if (schema && schema.async) {
|
|
172
|
-
result = await
|
|
182
|
+
result = await interactiveLogger?.logLoading(
|
|
173
183
|
validateProgressMessage ?? "",
|
|
174
184
|
() => v.safeParseAsync(schema, response)
|
|
175
185
|
);
|
|
@@ -182,7 +192,7 @@ async function askQuestion({
|
|
|
182
192
|
if (success) {
|
|
183
193
|
return output;
|
|
184
194
|
}
|
|
185
|
-
|
|
195
|
+
interactiveLogger.logWarn(issues[0].message);
|
|
186
196
|
}
|
|
187
197
|
}
|
|
188
198
|
var promptStateSymbol = {
|
|
@@ -377,93 +387,102 @@ ${userInputText}`;
|
|
|
377
387
|
function autocompleteMultiSelectPrompt(opts) {
|
|
378
388
|
return autocompletePrompt(opts, true);
|
|
379
389
|
}
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
const
|
|
388
|
-
output
|
|
389
|
-
|
|
390
|
-
const
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
390
|
+
var InteractiveLogger = class {
|
|
391
|
+
messageHistory = [];
|
|
392
|
+
async logLoading(message, fn, deferredTimeMs = 300) {
|
|
393
|
+
this.messageHistory.push({ type: "loading", message });
|
|
394
|
+
if (!Logger.isInteractive || import.meta.env?.VITEST) {
|
|
395
|
+
return await fn();
|
|
396
|
+
}
|
|
397
|
+
const output = Logger.stdout;
|
|
398
|
+
const columns = getColumns(output);
|
|
399
|
+
const showMessage = (msg) => {
|
|
400
|
+
const wrapped = wrapAnsi(msg, columns, { hard: true, trim: false });
|
|
401
|
+
output.write(wrapped);
|
|
402
|
+
return () => {
|
|
403
|
+
const prevLines = wrapped.split("\n");
|
|
404
|
+
if (prevLines.length > 1) {
|
|
405
|
+
output.write(cursor.up(prevLines.length - 1));
|
|
406
|
+
}
|
|
407
|
+
output.write(cursor.to(0));
|
|
408
|
+
output.write(erase.down());
|
|
409
|
+
};
|
|
396
410
|
};
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
output.write(`${blueBright("\u2551")}
|
|
411
|
+
let timer;
|
|
412
|
+
let clearMessage;
|
|
413
|
+
const promise = new Promise((resolve) => {
|
|
414
|
+
timer = setTimeout(() => {
|
|
415
|
+
output.write(`${blueBright("\u2551")}
|
|
403
416
|
`);
|
|
404
|
-
|
|
405
|
-
|
|
417
|
+
clearMessage = showMessage(
|
|
418
|
+
`${blueBright(`${promptStateSymbol.active}\u2500`)} ${dim(message)}
|
|
406
419
|
`
|
|
420
|
+
);
|
|
421
|
+
resolve();
|
|
422
|
+
}, deferredTimeMs);
|
|
423
|
+
});
|
|
424
|
+
const result = await fn().then((r) => {
|
|
425
|
+
if (!clearMessage) {
|
|
426
|
+
return r;
|
|
427
|
+
}
|
|
428
|
+
return new Promise(
|
|
429
|
+
(resolve) => setTimeout(() => resolve(r), deferredTimeMs)
|
|
407
430
|
);
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
return r;
|
|
414
|
-
}
|
|
415
|
-
return new Promise(
|
|
416
|
-
(resolve) => setTimeout(() => resolve(r), deferredTimeMs)
|
|
417
|
-
);
|
|
418
|
-
}).catch(async (e) => {
|
|
419
|
-
await promise;
|
|
420
|
-
clearMessage?.();
|
|
421
|
-
showMessage(
|
|
422
|
-
`${redBright(`${promptStateSymbol.error}\u2500`)} ${dim(message)}
|
|
431
|
+
}).catch(async (e) => {
|
|
432
|
+
await promise;
|
|
433
|
+
clearMessage?.();
|
|
434
|
+
showMessage(
|
|
435
|
+
`${redBright(`${promptStateSymbol.error}\u2500`)} ${dim(message)}
|
|
423
436
|
|
|
424
437
|
`
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
438
|
+
);
|
|
439
|
+
throw e;
|
|
440
|
+
});
|
|
441
|
+
clearTimeout(timer);
|
|
442
|
+
if (clearMessage) {
|
|
443
|
+
clearMessage();
|
|
444
|
+
showMessage(
|
|
445
|
+
`${blueBright(`${promptStateSymbol.submit}\u2500`)} ${dim(message)}
|
|
433
446
|
`
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
}
|
|
438
|
-
function interactiveLogInfo(message) {
|
|
439
|
-
if (import.meta.env?.VITEST) {
|
|
440
|
-
return;
|
|
447
|
+
);
|
|
448
|
+
}
|
|
449
|
+
return result;
|
|
441
450
|
}
|
|
442
|
-
|
|
443
|
-
|
|
451
|
+
logInfo(message) {
|
|
452
|
+
this.messageHistory.push({ type: "info", message });
|
|
453
|
+
if (import.meta.env?.VITEST) {
|
|
454
|
+
return;
|
|
455
|
+
}
|
|
456
|
+
Logger.stdout.write(
|
|
457
|
+
`${blueBright(`${promptStateSymbol.submit}\u2500`)} ${message.split("\n").join(`
|
|
444
458
|
${blueBright("\u2551")} `)}
|
|
445
459
|
`
|
|
446
|
-
|
|
447
|
-
}
|
|
448
|
-
function interactiveLogWarn(message) {
|
|
449
|
-
if (import.meta.env?.VITEST) {
|
|
450
|
-
return;
|
|
460
|
+
);
|
|
451
461
|
}
|
|
452
|
-
|
|
453
|
-
|
|
462
|
+
logWarn(message) {
|
|
463
|
+
this.messageHistory.push({ type: "warn", message });
|
|
464
|
+
if (import.meta.env?.VITEST) {
|
|
465
|
+
return;
|
|
466
|
+
}
|
|
467
|
+
Logger.stdout.write(
|
|
468
|
+
`${yellowBright(`${promptStateSymbol.error}\u2500`)} ${yellowBright(message.split("\n").join(`
|
|
454
469
|
${yellowBright("\u2551")} `))}
|
|
455
470
|
`
|
|
456
|
-
|
|
457
|
-
}
|
|
458
|
-
function interactiveLogOutro(message) {
|
|
459
|
-
if (import.meta.env?.VITEST) {
|
|
460
|
-
return;
|
|
471
|
+
);
|
|
461
472
|
}
|
|
462
|
-
|
|
473
|
+
logOutro(message) {
|
|
474
|
+
this.messageHistory.push({ type: "outro", message });
|
|
475
|
+
if (import.meta.env?.VITEST) {
|
|
476
|
+
return;
|
|
477
|
+
}
|
|
478
|
+
Logger.stdout.write(
|
|
479
|
+
`${blueBright("\u2551")}
|
|
463
480
|
${blueBright("\u2559\u2500")} ${message}
|
|
464
481
|
|
|
465
|
-
`
|
|
466
|
-
|
|
482
|
+
`
|
|
483
|
+
);
|
|
484
|
+
}
|
|
485
|
+
};
|
|
467
486
|
|
|
468
487
|
// src/npm.ts
|
|
469
488
|
import { fetch as _fetch } from "node-fetch-native";
|
|
@@ -517,6 +536,7 @@ async function create(inlineConfig) {
|
|
|
517
536
|
Logger.setLogOptions(inlineConfig);
|
|
518
537
|
Logger.debug("create > inlineConfig %O", inlineConfig);
|
|
519
538
|
const fetch = createFetch(inlineConfig);
|
|
539
|
+
const interactiveLogger = new InteractiveLogger();
|
|
520
540
|
let {
|
|
521
541
|
projectPath,
|
|
522
542
|
cwd: cwd2 = cwd,
|
|
@@ -525,29 +545,34 @@ async function create(inlineConfig) {
|
|
|
525
545
|
language,
|
|
526
546
|
theme,
|
|
527
547
|
template,
|
|
548
|
+
installDependencies,
|
|
528
549
|
createConfigFileOnly = false
|
|
529
550
|
} = inlineConfig;
|
|
530
551
|
let extraTemplateVariables = {};
|
|
531
552
|
let themePackage;
|
|
532
|
-
let installDependencies;
|
|
533
553
|
let useLocalTemplate = false;
|
|
534
554
|
if (template && !/^([\w-.]+):/.test(template)) {
|
|
535
555
|
const absTemplatePath = upath.resolve(cwd2, template);
|
|
536
556
|
useLocalTemplate = fs.existsSync(upath.resolve(cwd2, template)) && fs.statSync(upath.resolve(cwd2, template)).isDirectory();
|
|
557
|
+
const usingPresetTemplate = TEMPLATE_SETTINGS.find(
|
|
558
|
+
(t) => t.value === template
|
|
559
|
+
);
|
|
537
560
|
if (useLocalTemplate) {
|
|
538
561
|
template = absTemplatePath;
|
|
539
|
-
|
|
562
|
+
interactiveLogger.logInfo(
|
|
540
563
|
`Using the specified local template directory
|
|
541
564
|
${dim2(upath.relative(cwd2, absTemplatePath) || ".")}`
|
|
542
565
|
);
|
|
566
|
+
} else if (usingPresetTemplate) {
|
|
567
|
+
template = usingPresetTemplate.template;
|
|
543
568
|
} else {
|
|
544
|
-
|
|
569
|
+
interactiveLogger.logWarn(
|
|
545
570
|
`The specified theme ${green2(template)} was not found as a local directory. Proceeding to fetch it from GitHub repository.`
|
|
546
571
|
);
|
|
547
572
|
}
|
|
548
573
|
}
|
|
549
574
|
if (!projectPath) {
|
|
550
|
-
({ projectPath } = await askProjectPath());
|
|
575
|
+
({ projectPath } = await askProjectPath({ interactiveLogger }));
|
|
551
576
|
}
|
|
552
577
|
const dist = upath.join(cwd2, projectPath);
|
|
553
578
|
if (createConfigFileOnly) {
|
|
@@ -558,35 +583,41 @@ ${dim2(upath.relative(cwd2, absTemplatePath) || ".")}`
|
|
|
558
583
|
throw new Error(`Destination ${dist} is not empty.`);
|
|
559
584
|
}
|
|
560
585
|
if (!title) {
|
|
561
|
-
({ title } = createConfigFileOnly ? { title: DEFAULT_PROJECT_TITLE } : await askTitle({ projectPath }));
|
|
586
|
+
({ title } = createConfigFileOnly ? { title: DEFAULT_PROJECT_TITLE } : await askTitle({ projectPath, interactiveLogger }));
|
|
562
587
|
}
|
|
563
588
|
if (!author) {
|
|
564
|
-
({ author } = createConfigFileOnly ? { author: DEFAULT_PROJECT_AUTHOR } : await askAuthor());
|
|
589
|
+
({ author } = createConfigFileOnly ? { author: DEFAULT_PROJECT_AUTHOR } : await askAuthor({ interactiveLogger }));
|
|
565
590
|
}
|
|
566
591
|
if (!language) {
|
|
567
|
-
({ language } = createConfigFileOnly ? { language: await getOsLocale() } : await askLanguage());
|
|
592
|
+
({ language } = createConfigFileOnly ? { language: await getOsLocale() } : await askLanguage({ interactiveLogger }));
|
|
568
593
|
}
|
|
569
594
|
if (!createConfigFileOnly) {
|
|
570
595
|
let presetTemplate;
|
|
571
596
|
if (!template) {
|
|
572
|
-
({ presetTemplate } = await askPresetTemplate());
|
|
597
|
+
({ presetTemplate } = await askPresetTemplate({ interactiveLogger }));
|
|
573
598
|
if (presetTemplate) {
|
|
574
599
|
template = presetTemplate.template;
|
|
575
600
|
}
|
|
576
601
|
}
|
|
577
|
-
if (!theme) {
|
|
602
|
+
if (!theme && theme !== false) {
|
|
578
603
|
({ theme, themePackage } = await askTheme({
|
|
579
604
|
presetTemplate,
|
|
580
605
|
template,
|
|
581
|
-
fetch
|
|
606
|
+
fetch,
|
|
607
|
+
interactiveLogger
|
|
582
608
|
}));
|
|
583
609
|
}
|
|
584
610
|
if (!template) {
|
|
585
|
-
({ template, extraTemplateVariables } = await askThemeTemplate(
|
|
586
|
-
themePackage?.vivliostyle
|
|
587
|
-
|
|
611
|
+
({ template, extraTemplateVariables } = await askThemeTemplate({
|
|
612
|
+
themeMetadata: themePackage?.vivliostyle,
|
|
613
|
+
interactiveLogger
|
|
614
|
+
}));
|
|
615
|
+
}
|
|
616
|
+
if (typeof installDependencies !== "boolean") {
|
|
617
|
+
({ installDependencies } = await askInstallDependencies({
|
|
618
|
+
interactiveLogger
|
|
619
|
+
}));
|
|
588
620
|
}
|
|
589
|
-
({ installDependencies } = await askInstallDependencies());
|
|
590
621
|
}
|
|
591
622
|
const browserType = "chrome";
|
|
592
623
|
const browserTag = getDefaultBrowserTag(browserType);
|
|
@@ -625,7 +656,11 @@ ${dim2(upath.relative(cwd2, absTemplatePath) || ".")}`
|
|
|
625
656
|
} else {
|
|
626
657
|
var _stack2 = [];
|
|
627
658
|
try {
|
|
628
|
-
|
|
659
|
+
if (interactiveLogger.messageHistory.length > 0) {
|
|
660
|
+
interactiveLogger.logOutro(
|
|
661
|
+
"All configurations are set! Creating your project..."
|
|
662
|
+
);
|
|
663
|
+
}
|
|
629
664
|
const _3 = __using(_stack2, Logger.startLogging(
|
|
630
665
|
useLocalTemplate ? "Copying a local template" : "Downloading a template"
|
|
631
666
|
));
|
|
@@ -675,7 +710,9 @@ ${dim2(upath.relative(cwd2, absTemplatePath) || ".")}`
|
|
|
675
710
|
});
|
|
676
711
|
}
|
|
677
712
|
}
|
|
678
|
-
async function askProjectPath(
|
|
713
|
+
async function askProjectPath({
|
|
714
|
+
interactiveLogger
|
|
715
|
+
}) {
|
|
679
716
|
return await askQuestion({
|
|
680
717
|
question: {
|
|
681
718
|
projectPath: {
|
|
@@ -687,10 +724,14 @@ async function askProjectPath() {
|
|
|
687
724
|
},
|
|
688
725
|
schema: v2.required(
|
|
689
726
|
v2.pick(VivliostyleInlineConfigWithoutChecks, ["projectPath"])
|
|
690
|
-
)
|
|
727
|
+
),
|
|
728
|
+
interactiveLogger
|
|
691
729
|
});
|
|
692
730
|
}
|
|
693
|
-
async function askTitle({
|
|
731
|
+
async function askTitle({
|
|
732
|
+
projectPath,
|
|
733
|
+
interactiveLogger
|
|
734
|
+
}) {
|
|
694
735
|
return await askQuestion({
|
|
695
736
|
question: {
|
|
696
737
|
title: {
|
|
@@ -700,10 +741,13 @@ async function askTitle({ projectPath }) {
|
|
|
700
741
|
placeholder: toTitleCase(projectPath) || DEFAULT_PROJECT_TITLE
|
|
701
742
|
}
|
|
702
743
|
},
|
|
703
|
-
schema: v2.required(v2.pick(VivliostyleInlineConfigWithoutChecks, ["title"]))
|
|
744
|
+
schema: v2.required(v2.pick(VivliostyleInlineConfigWithoutChecks, ["title"])),
|
|
745
|
+
interactiveLogger
|
|
704
746
|
});
|
|
705
747
|
}
|
|
706
|
-
async function askAuthor(
|
|
748
|
+
async function askAuthor({
|
|
749
|
+
interactiveLogger
|
|
750
|
+
}) {
|
|
707
751
|
return await askQuestion({
|
|
708
752
|
question: {
|
|
709
753
|
author: {
|
|
@@ -715,17 +759,20 @@ async function askAuthor() {
|
|
|
715
759
|
},
|
|
716
760
|
schema: v2.required(
|
|
717
761
|
v2.pick(VivliostyleInlineConfigWithoutChecks, ["author"])
|
|
718
|
-
)
|
|
762
|
+
),
|
|
763
|
+
interactiveLogger
|
|
719
764
|
});
|
|
720
765
|
}
|
|
721
|
-
async function askLanguage(
|
|
766
|
+
async function askLanguage({
|
|
767
|
+
interactiveLogger
|
|
768
|
+
}) {
|
|
722
769
|
const initialValue = await getOsLocale();
|
|
723
770
|
return await askQuestion({
|
|
724
771
|
question: {
|
|
725
772
|
language: {
|
|
726
773
|
type: "autocomplete",
|
|
727
774
|
message: "What's the language?",
|
|
728
|
-
options: Object.entries(
|
|
775
|
+
options: Object.entries(LANGUAGES).map(([value, displayName]) => ({
|
|
729
776
|
value,
|
|
730
777
|
label: displayName,
|
|
731
778
|
hint: value
|
|
@@ -735,11 +782,14 @@ async function askLanguage() {
|
|
|
735
782
|
},
|
|
736
783
|
schema: v2.required(
|
|
737
784
|
v2.pick(VivliostyleInlineConfigWithoutChecks, ["language"])
|
|
738
|
-
)
|
|
785
|
+
),
|
|
786
|
+
interactiveLogger
|
|
739
787
|
});
|
|
740
788
|
}
|
|
741
789
|
var PRESET_TEMPLATE_NOT_USE = "Use templates from the community theme";
|
|
742
|
-
async function askPresetTemplate(
|
|
790
|
+
async function askPresetTemplate({
|
|
791
|
+
interactiveLogger
|
|
792
|
+
}) {
|
|
743
793
|
const { presetTemplate } = await askQuestion({
|
|
744
794
|
question: {
|
|
745
795
|
presetTemplate: {
|
|
@@ -762,7 +812,8 @@ async function askPresetTemplate() {
|
|
|
762
812
|
(value) => value === PRESET_TEMPLATE_NOT_USE ? void 0 : TEMPLATE_SETTINGS.find((t) => t.value === value)
|
|
763
813
|
)
|
|
764
814
|
)
|
|
765
|
-
})
|
|
815
|
+
}),
|
|
816
|
+
interactiveLogger
|
|
766
817
|
});
|
|
767
818
|
return { presetTemplate };
|
|
768
819
|
}
|
|
@@ -776,10 +827,11 @@ var THEME_ANSWER_MANUAL = "Install other themes from npm";
|
|
|
776
827
|
async function askTheme({
|
|
777
828
|
template,
|
|
778
829
|
presetTemplate,
|
|
779
|
-
fetch
|
|
830
|
+
fetch,
|
|
831
|
+
interactiveLogger
|
|
780
832
|
}) {
|
|
781
833
|
const useCommunityThemes = !presetTemplate && !template;
|
|
782
|
-
const themePackages = await
|
|
834
|
+
const themePackages = await interactiveLogger.logLoading(
|
|
783
835
|
"Fetching a list of Vivliostyle themes...",
|
|
784
836
|
async () => {
|
|
785
837
|
let themes = (await listVivliostyleThemes({ fetch })).objects;
|
|
@@ -842,7 +894,8 @@ async function askTheme({
|
|
|
842
894
|
}
|
|
843
895
|
},
|
|
844
896
|
schema: v2.objectAsync({ theme: validateThemeMetadataSchema }),
|
|
845
|
-
validateProgressMessage: "Fetching package metadata..."
|
|
897
|
+
validateProgressMessage: "Fetching package metadata...",
|
|
898
|
+
interactiveLogger
|
|
846
899
|
});
|
|
847
900
|
if (theme === THEME_ANSWER_NOT_USE) {
|
|
848
901
|
return { theme: void 0, themePackage: void 0 };
|
|
@@ -877,7 +930,8 @@ async function askTheme({
|
|
|
877
930
|
validateThemeMetadataSchema
|
|
878
931
|
)
|
|
879
932
|
}),
|
|
880
|
-
validateProgressMessage: "Fetching package metadata..."
|
|
933
|
+
validateProgressMessage: "Fetching package metadata...",
|
|
934
|
+
interactiveLogger
|
|
881
935
|
}).then((ret) => ret.themeManualInput);
|
|
882
936
|
}
|
|
883
937
|
return {
|
|
@@ -887,7 +941,10 @@ async function askTheme({
|
|
|
887
941
|
themePackage
|
|
888
942
|
};
|
|
889
943
|
}
|
|
890
|
-
async function askThemeTemplate(
|
|
944
|
+
async function askThemeTemplate({
|
|
945
|
+
interactiveLogger,
|
|
946
|
+
themeMetadata
|
|
947
|
+
}) {
|
|
891
948
|
const themeTemplate = themeMetadata?.template;
|
|
892
949
|
const options = Object.entries(themeTemplate || {}).map(([value, tmpl]) => ({
|
|
893
950
|
label: tmpl.name || value,
|
|
@@ -895,7 +952,7 @@ async function askThemeTemplate(themeMetadata) {
|
|
|
895
952
|
hint: truncateString(tmpl.description || "")
|
|
896
953
|
}));
|
|
897
954
|
if (!themeTemplate || options.length === 0) {
|
|
898
|
-
|
|
955
|
+
interactiveLogger.logWarn(
|
|
899
956
|
"The chosen theme does not set template settings. Applying the minimal template."
|
|
900
957
|
);
|
|
901
958
|
return {
|
|
@@ -916,19 +973,23 @@ async function askThemeTemplate(themeMetadata) {
|
|
|
916
973
|
v2.string(),
|
|
917
974
|
v2.transform((input) => themeTemplate[input])
|
|
918
975
|
)
|
|
919
|
-
})
|
|
976
|
+
}),
|
|
977
|
+
interactiveLogger
|
|
920
978
|
});
|
|
921
979
|
let extraTemplateVariables = {};
|
|
922
980
|
if (usingTemplate.prompt?.length) {
|
|
923
981
|
extraTemplateVariables = await askQuestion({
|
|
924
982
|
question: Object.fromEntries(
|
|
925
983
|
usingTemplate.prompt.map((q) => [q.name, q])
|
|
926
|
-
)
|
|
984
|
+
),
|
|
985
|
+
interactiveLogger
|
|
927
986
|
});
|
|
928
987
|
}
|
|
929
988
|
return { template: usingTemplate.source, extraTemplateVariables };
|
|
930
989
|
}
|
|
931
|
-
async function askInstallDependencies(
|
|
990
|
+
async function askInstallDependencies({
|
|
991
|
+
interactiveLogger
|
|
992
|
+
}) {
|
|
932
993
|
return await askQuestion({
|
|
933
994
|
question: {
|
|
934
995
|
installDependencies: {
|
|
@@ -942,7 +1003,8 @@ async function askInstallDependencies() {
|
|
|
942
1003
|
},
|
|
943
1004
|
schema: v2.object({
|
|
944
1005
|
installDependencies: v2.boolean()
|
|
945
|
-
})
|
|
1006
|
+
}),
|
|
1007
|
+
interactiveLogger
|
|
946
1008
|
});
|
|
947
1009
|
}
|
|
948
1010
|
async function setupTemplate({
|
|
@@ -990,13 +1052,16 @@ async function setupTemplate({
|
|
|
990
1052
|
}
|
|
991
1053
|
cleanupExitHandler()?.();
|
|
992
1054
|
}
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
fs.
|
|
999
|
-
|
|
1055
|
+
const packageJsonPath = upath.join(cwd2, projectPath, "package.json");
|
|
1056
|
+
if (!fs.existsSync(packageJsonPath)) {
|
|
1057
|
+
fs.writeFileSync(packageJsonPath, TEMPLATE_DEFAULT_PACKAGE_JSON, "utf8");
|
|
1058
|
+
}
|
|
1059
|
+
if (!locateVivliostyleConfig({ cwd: upath.join(cwd2, projectPath) })) {
|
|
1060
|
+
fs.writeFileSync(
|
|
1061
|
+
upath.join(cwd2, projectPath, DEFAULT_CONFIG_FILENAME),
|
|
1062
|
+
TEMPLATE_DEFAULT_VIVLIOSTYLE_CONFIG_JS,
|
|
1063
|
+
"utf8"
|
|
1064
|
+
);
|
|
1000
1065
|
}
|
|
1001
1066
|
const replaceTemplateVariable = (dir) => {
|
|
1002
1067
|
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
|
|
@@ -1024,7 +1089,7 @@ function setupConfigFile({
|
|
|
1024
1089
|
templateVariables
|
|
1025
1090
|
}) {
|
|
1026
1091
|
const targetPath = upath.join(cwd2, projectPath, DEFAULT_CONFIG_FILENAME);
|
|
1027
|
-
const content =
|
|
1092
|
+
const content = TEMPLATE_DEFAULT_VIVLIOSTYLE_CONFIG_JS;
|
|
1028
1093
|
fs.mkdirSync(upath.dirname(targetPath), { recursive: true });
|
|
1029
1094
|
fs.writeFileSync(targetPath, format(content, templateVariables), "utf8");
|
|
1030
1095
|
}
|
|
@@ -1080,4 +1145,4 @@ For more information, visit ${terminalLink(yellow2("https://docs.vivliostyle.org
|
|
|
1080
1145
|
export {
|
|
1081
1146
|
create
|
|
1082
1147
|
};
|
|
1083
|
-
//# sourceMappingURL=chunk-
|
|
1148
|
+
//# sourceMappingURL=chunk-DEJL63H2.js.map
|