Spaces:
Running
Running
Rename generate_html.js to generate_html.cjs
Browse files- generate_html.cjs +24 -0
- generate_html.js +0 -27
generate_html.cjs
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// generate_html.cjs
|
| 2 |
+
const packager = require("@turbowarp/packager");
|
| 3 |
+
const fs = require("fs");
|
| 4 |
+
|
| 5 |
+
const projectId = process.argv[2];
|
| 6 |
+
const optionsFile = process.argv[3];
|
| 7 |
+
|
| 8 |
+
if (!projectId) {
|
| 9 |
+
console.error("Project ID is required.");
|
| 10 |
+
process.exit(1);
|
| 11 |
+
}
|
| 12 |
+
|
| 13 |
+
// JSONオプションを読み込み
|
| 14 |
+
const options = optionsFile ? JSON.parse(fs.readFileSync(optionsFile, "utf8")) : {};
|
| 15 |
+
|
| 16 |
+
// packProject は default プロパティに格納されている
|
| 17 |
+
const packProject = packager.default;
|
| 18 |
+
|
| 19 |
+
packProject(projectId, options)
|
| 20 |
+
.then(html => console.log(html))
|
| 21 |
+
.catch(err => {
|
| 22 |
+
console.error(err);
|
| 23 |
+
process.exit(1);
|
| 24 |
+
});
|
generate_html.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
| 1 |
-
// generate_html.js
|
| 2 |
-
import pkg from "@turbowarp/packager";
|
| 3 |
-
const { packProject } = pkg; // CommonJSのnamed exportを取得
|
| 4 |
-
|
| 5 |
-
import fs from "fs";
|
| 6 |
-
|
| 7 |
-
const projectId = process.argv[2];
|
| 8 |
-
const optionsFile = process.argv[3];
|
| 9 |
-
|
| 10 |
-
async function main() {
|
| 11 |
-
if (!projectId) {
|
| 12 |
-
console.error("Project ID is required.");
|
| 13 |
-
process.exit(1);
|
| 14 |
-
}
|
| 15 |
-
|
| 16 |
-
const options = optionsFile ? JSON.parse(fs.readFileSync(optionsFile, "utf8")) : {};
|
| 17 |
-
|
| 18 |
-
try {
|
| 19 |
-
const html = await packProject(projectId, options);
|
| 20 |
-
console.log(html);
|
| 21 |
-
} catch (err) {
|
| 22 |
-
console.error(err);
|
| 23 |
-
process.exit(1);
|
| 24 |
-
}
|
| 25 |
-
}
|
| 26 |
-
|
| 27 |
-
main();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|