@berlysia/vertical-writing-slide-system 0.0.13 → 0.0.15
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/cli.js +65 -4
- package/package.json +1 -1
- package/src/screen.css +2 -2
package/cli.js
CHANGED
|
@@ -2,16 +2,77 @@
|
|
|
2
2
|
// @ts-check
|
|
3
3
|
|
|
4
4
|
import { execSync } from "child_process";
|
|
5
|
-
import { mkdir, mkdtemp, cp, rm } from "node:fs/promises";
|
|
5
|
+
import { mkdir, mkdtemp, cp, rm, writeFile, access } from "node:fs/promises";
|
|
6
6
|
import { resolve } from "node:path";
|
|
7
7
|
import { parseArgs } from "node:util";
|
|
8
|
-
import { build } from "vite";
|
|
8
|
+
import { build, createServer } from "vite";
|
|
9
|
+
|
|
10
|
+
async function ensureIndexHtml() {
|
|
11
|
+
const indexHtmlPath = resolve(process.cwd(), "index.html");
|
|
12
|
+
try {
|
|
13
|
+
await access(indexHtmlPath);
|
|
14
|
+
// index.html already exists
|
|
15
|
+
return;
|
|
16
|
+
} catch {
|
|
17
|
+
// index.html doesn't exist, create it
|
|
18
|
+
// Use relative paths that Vite can resolve during development
|
|
19
|
+
const indexHtmlContent = `<!doctype html>
|
|
20
|
+
<html lang="ja">
|
|
21
|
+
<head>
|
|
22
|
+
<meta charset="UTF-8" />
|
|
23
|
+
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
|
24
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
25
|
+
<title>Vertical Writing Slides</title>
|
|
26
|
+
<link rel="preconnect" href="https://fonts.googleapis.com">
|
|
27
|
+
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
28
|
+
<link href="https://fonts.googleapis.com/css2?family=Noto+Sans+JP&family=Noto+Sans+Mono:wght@100..900&display=swap" rel="stylesheet">
|
|
29
|
+
<link rel="stylesheet" href="/src/index.css" />
|
|
30
|
+
<link rel="stylesheet" media="screen" href="/src/screen.css" />
|
|
31
|
+
<link rel="stylesheet" media="print" href="/src/print.css" />
|
|
32
|
+
</head>
|
|
33
|
+
<body>
|
|
34
|
+
<div id="root"></div>
|
|
35
|
+
<script type="module" src="/src/main.tsx"></script>
|
|
36
|
+
</body>
|
|
37
|
+
</html>`;
|
|
38
|
+
|
|
39
|
+
await writeFile(indexHtmlPath, indexHtmlContent);
|
|
40
|
+
console.log("Generated index.html for external project");
|
|
41
|
+
}
|
|
42
|
+
}
|
|
9
43
|
|
|
10
44
|
async function runDev() {
|
|
11
45
|
try {
|
|
12
|
-
|
|
46
|
+
const libPath = import.meta.dirname;
|
|
47
|
+
const projectPath = process.cwd();
|
|
48
|
+
|
|
49
|
+
const server = await createServer({
|
|
50
|
+
root: libPath, // Use library as root for assets
|
|
51
|
+
configFile: resolve(libPath, "vite.config.ts"),
|
|
52
|
+
server: {
|
|
53
|
+
fs: {
|
|
54
|
+
allow: [
|
|
55
|
+
// Allow serving files from the library directory
|
|
56
|
+
libPath,
|
|
57
|
+
// Allow serving files from the current working directory
|
|
58
|
+
projectPath,
|
|
59
|
+
],
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
await server.listen();
|
|
65
|
+
server.printUrls();
|
|
66
|
+
console.log("Development server started. Press Ctrl+C to stop.");
|
|
67
|
+
|
|
68
|
+
// Keep the process running
|
|
69
|
+
process.on("SIGINT", async () => {
|
|
70
|
+
console.log("\nShutting down development server...");
|
|
71
|
+
await server.close();
|
|
72
|
+
process.exit(0);
|
|
73
|
+
});
|
|
13
74
|
} catch (error) {
|
|
14
|
-
console.error("Error during
|
|
75
|
+
console.error("Error during development server startup:", error);
|
|
15
76
|
process.exit(1);
|
|
16
77
|
}
|
|
17
78
|
}
|
package/package.json
CHANGED