@textadventures/squiffy-cli 6.0.1 → 7.0.0-beta.2
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/assets.d.ts +8 -0
- package/dist/assets.js +63 -0
- package/dist/assets.test.d.ts +1 -0
- package/dist/assets.test.js +73 -0
- package/dist/external-files.d.ts +1 -0
- package/dist/external-files.js +11 -1
- package/dist/file-packager.d.ts +3 -2
- package/dist/file-packager.js +39 -11
- package/dist/file-packager.test.js +25 -0
- package/dist/squiffy.js +25 -7
- package/package.json +9 -8
package/dist/assets.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { CompileSuccess } from "squiffy-compiler";
|
|
2
|
+
/**
|
|
3
|
+
* Finds the asset files referenced by a story: anything in the story text or scripts that looks like a
|
|
4
|
+
* relative path to an asset file (by extension), and exists in the story's folder (or below it).
|
|
5
|
+
* Returns a map of path (relative to the story folder, with "/" separators) to bytes.
|
|
6
|
+
*/
|
|
7
|
+
export declare const findAssets: (inputFilename: string, storyText: string) => Record<string, Uint8Array>;
|
|
8
|
+
export declare const getStoryText: (result: CompileSuccess) => string;
|
package/dist/assets.js
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import * as fs from "fs";
|
|
2
|
+
import * as path from "path";
|
|
3
|
+
// File types that we look for references to in a story. Anything else (.squiffy, .js, .css, .html etc.)
|
|
4
|
+
// is either part of the story source or something we'd be guessing about.
|
|
5
|
+
const assetExtensions = [
|
|
6
|
+
"apng", "avif", "bmp", "gif", "ico", "jpeg", "jpg", "png", "svg", "webp",
|
|
7
|
+
"aac", "flac", "m4a", "mp3", "oga", "ogg", "opus", "wav", "weba",
|
|
8
|
+
"m4v", "mp4", "ogv", "webm", "vtt",
|
|
9
|
+
"otf", "ttf", "woff", "woff2",
|
|
10
|
+
"pdf",
|
|
11
|
+
];
|
|
12
|
+
// Matches things that look like a relative path to an asset file, e.g. "cat.png", "images/cat.png",
|
|
13
|
+
// "./sounds/meow.mp3" or "my%20cat.png". Paths containing spaces aren't matched, so use %20 for those.
|
|
14
|
+
const assetPathPattern = new RegExp(String.raw `(?<![\w%./:\\-])((?:\.\/)?[\w%.-]+(?:\/[\w%.-]+)*\.(?:${assetExtensions.join("|")}))(?![\w%/-])`, "gi");
|
|
15
|
+
/**
|
|
16
|
+
* Finds the asset files referenced by a story: anything in the story text or scripts that looks like a
|
|
17
|
+
* relative path to an asset file (by extension), and exists in the story's folder (or below it).
|
|
18
|
+
* Returns a map of path (relative to the story folder, with "/" separators) to bytes.
|
|
19
|
+
*/
|
|
20
|
+
export const findAssets = (inputFilename, storyText) => {
|
|
21
|
+
const basePath = path.resolve(path.dirname(inputFilename));
|
|
22
|
+
const result = {};
|
|
23
|
+
for (const match of storyText.matchAll(assetPathPattern)) {
|
|
24
|
+
let reference = match[1].replace(/^(\.\/)+/, "");
|
|
25
|
+
try {
|
|
26
|
+
reference = decodeURI(reference);
|
|
27
|
+
}
|
|
28
|
+
catch {
|
|
29
|
+
// Not valid percent-encoding - use it as it is
|
|
30
|
+
}
|
|
31
|
+
if (reference in result)
|
|
32
|
+
continue;
|
|
33
|
+
const filename = path.resolve(basePath, reference);
|
|
34
|
+
const relative = path.relative(basePath, filename);
|
|
35
|
+
if (!relative || relative.startsWith("..") || path.isAbsolute(relative))
|
|
36
|
+
continue;
|
|
37
|
+
let stat;
|
|
38
|
+
try {
|
|
39
|
+
stat = fs.statSync(filename);
|
|
40
|
+
}
|
|
41
|
+
catch {
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
if (!stat.isFile())
|
|
45
|
+
continue;
|
|
46
|
+
result[relative.split(path.sep).join("/")] = fs.readFileSync(filename);
|
|
47
|
+
}
|
|
48
|
+
return result;
|
|
49
|
+
};
|
|
50
|
+
// All the text and script in a compiled story, which is where we look for asset references.
|
|
51
|
+
export const getStoryText = (result) => {
|
|
52
|
+
const texts = [];
|
|
53
|
+
for (const section of Object.values(result.output.story.sections)) {
|
|
54
|
+
texts.push(section.text ?? "");
|
|
55
|
+
for (const passage of Object.values(section.passages ?? {})) {
|
|
56
|
+
texts.push(passage.text ?? "");
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
for (const js of result.output.js) {
|
|
60
|
+
texts.push(...js);
|
|
61
|
+
}
|
|
62
|
+
return texts.join("\n");
|
|
63
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { describe, test, expect, beforeEach, afterEach, vi } from "vitest";
|
|
2
|
+
import { unzipSync } from "fflate";
|
|
3
|
+
import { findAssets } from "./assets.js";
|
|
4
|
+
import { createPackageFiles } from "./file-packager.js";
|
|
5
|
+
import fs from "fs/promises";
|
|
6
|
+
import path from "path";
|
|
7
|
+
import { fileURLToPath } from "url";
|
|
8
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
9
|
+
const TEST_DIR = path.join(__dirname, "..", "test-fixtures-assets");
|
|
10
|
+
const STORY_DIR = path.join(TEST_DIR, "story");
|
|
11
|
+
const storyFile = path.join(STORY_DIR, "story.squiffy");
|
|
12
|
+
const pngBytes = new Uint8Array([0x89, 0x50, 0x4e, 0x47]);
|
|
13
|
+
const writeFile = async (relativePath, content = pngBytes) => {
|
|
14
|
+
const filename = path.join(STORY_DIR, relativePath);
|
|
15
|
+
await fs.mkdir(path.dirname(filename), { recursive: true });
|
|
16
|
+
await fs.writeFile(filename, content);
|
|
17
|
+
};
|
|
18
|
+
beforeEach(async () => {
|
|
19
|
+
await fs.mkdir(STORY_DIR, { recursive: true });
|
|
20
|
+
vi.spyOn(console, "log").mockImplementation(() => { });
|
|
21
|
+
});
|
|
22
|
+
afterEach(async () => {
|
|
23
|
+
vi.restoreAllMocks();
|
|
24
|
+
await fs.rm(TEST_DIR, { recursive: true, force: true });
|
|
25
|
+
});
|
|
26
|
+
describe("findAssets", () => {
|
|
27
|
+
test("finds referenced asset files in the story folder", async () => {
|
|
28
|
+
await writeFile("cat.png");
|
|
29
|
+
await writeFile("images/dog.jpg");
|
|
30
|
+
await writeFile("sounds/meow.mp3");
|
|
31
|
+
await writeFile("my cat.png");
|
|
32
|
+
await writeFile("unused.png");
|
|
33
|
+
const assets = findAssets(storyFile, `
|
|
34
|
+
<img src="./images/dog.jpg">
|
|
35
|
+
squiffy.set("sound", "sounds/meow.mp3");
|
|
36
|
+
<img src="my%20cat.png">`);
|
|
37
|
+
expect(Object.keys(assets).sort()).toEqual(["cat.png", "images/dog.jpg", "my cat.png", "sounds/meow.mp3"]);
|
|
38
|
+
expect(new Uint8Array(assets["cat.png"])).toEqual(pngBytes);
|
|
39
|
+
});
|
|
40
|
+
test("ignores missing files, absolute URLs, non-asset files and files outside the story folder", async () => {
|
|
41
|
+
await writeFile("cat.png");
|
|
42
|
+
await writeFile("notes.txt", "notes");
|
|
43
|
+
await fs.writeFile(path.join(TEST_DIR, "outside.png"), pngBytes);
|
|
44
|
+
const assets = findAssets(storyFile, `missing.png
|
|
45
|
+
https://example.com/cat.png
|
|
46
|
+
//example.com/cat.png
|
|
47
|
+
notes.txt
|
|
48
|
+
../outside.png
|
|
49
|
+
story.squiffy`);
|
|
50
|
+
expect(assets).toEqual({});
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
describe("createPackageFiles with assets", () => {
|
|
54
|
+
const story = `@title Assets
|
|
55
|
+
|
|
56
|
+
`;
|
|
57
|
+
test("adds referenced assets to the zip", async () => {
|
|
58
|
+
await writeFile("story.squiffy", story);
|
|
59
|
+
await writeFile("cat.png");
|
|
60
|
+
await writeFile("unused.png");
|
|
61
|
+
expect(await createPackageFiles(storyFile, STORY_DIR, { createZip: true })).toBe(true);
|
|
62
|
+
const zip = unzipSync(new Uint8Array(await fs.readFile(path.join(STORY_DIR, "output.zip"))));
|
|
63
|
+
expect(Object.keys(zip).sort()).toEqual(["cat.png", "index.html", "squiffy.runtime.global.js", "story.js", "style.css"]);
|
|
64
|
+
expect(zip["cat.png"]).toEqual(pngBytes);
|
|
65
|
+
});
|
|
66
|
+
test("embeds referenced assets in inline HTML", async () => {
|
|
67
|
+
await writeFile("story.squiffy", story);
|
|
68
|
+
await writeFile("cat.png");
|
|
69
|
+
expect(await createPackageFiles(storyFile, STORY_DIR, { inlineHtml: true })).toBe(true);
|
|
70
|
+
const html = await fs.readFile(path.join(STORY_DIR, "index.html"), "utf8");
|
|
71
|
+
expect(html).toContain('"cat.png":"data:image/png;base64,iVBORw=="');
|
|
72
|
+
});
|
|
73
|
+
});
|
package/dist/external-files.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export declare const sortByRelativePath: (basePath: string, filenames: string[]) => string[];
|
|
1
2
|
export declare const externalFiles: (inputFilename: string) => {
|
|
2
3
|
getMatchingFilenames: (pattern: string) => Promise<string[]>;
|
|
3
4
|
getContent: (filename: string) => Promise<string>;
|
package/dist/external-files.js
CHANGED
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
import { glob } from "glob";
|
|
2
2
|
import path from "path";
|
|
3
3
|
import fs from "fs/promises";
|
|
4
|
+
// glob doesn't return matches in a guaranteed order, but the order decides which
|
|
5
|
+
// same-named section wins and how continue sections are numbered. So sort them,
|
|
6
|
+
// like the editor does, by their path relative to the story's folder.
|
|
7
|
+
export const sortByRelativePath = (basePath, filenames) => {
|
|
8
|
+
const relative = (filename) => path.relative(basePath, filename).split(path.sep).join("/");
|
|
9
|
+
return filenames
|
|
10
|
+
.map(filename => ({ filename, key: relative(filename) }))
|
|
11
|
+
.sort((a, b) => a.key < b.key ? -1 : a.key > b.key ? 1 : 0)
|
|
12
|
+
.map(f => f.filename);
|
|
13
|
+
};
|
|
4
14
|
export const externalFiles = (inputFilename) => {
|
|
5
15
|
const includedFiles = [path.resolve(inputFilename)];
|
|
6
16
|
const basePath = path.resolve(path.dirname(inputFilename));
|
|
@@ -8,7 +18,7 @@ export const externalFiles = (inputFilename) => {
|
|
|
8
18
|
getMatchingFilenames: async (pattern) => {
|
|
9
19
|
const filenames = path.join(basePath, pattern);
|
|
10
20
|
const result = await glob(filenames);
|
|
11
|
-
return result.filter((filename) => !includedFiles.includes(filename));
|
|
21
|
+
return sortByRelativePath(basePath, result.filter((filename) => !includedFiles.includes(filename)));
|
|
12
22
|
},
|
|
13
23
|
getContent: async (filename) => {
|
|
14
24
|
// Resolve relative paths against the base path
|
package/dist/file-packager.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { StoryOnDisk } from "squiffy-compiler/node";
|
|
1
2
|
import { PackageOptions } from "@textadventures/squiffy-packager";
|
|
2
|
-
export declare const writeScriptFile: (
|
|
3
|
-
export declare const createPackageFiles: (
|
|
3
|
+
export declare const writeScriptFile: (input: string | StoryOnDisk, outputPath: string, outputFilename: string) => Promise<false | undefined>;
|
|
4
|
+
export declare const createPackageFiles: (input: string | StoryOnDisk, outputPath: string, options?: PackageOptions) => Promise<boolean>;
|
package/dist/file-packager.js
CHANGED
|
@@ -1,25 +1,44 @@
|
|
|
1
1
|
import * as fs from "fs";
|
|
2
2
|
import * as path from "path";
|
|
3
|
-
import { compile, findV5Syntax } from "squiffy-compiler";
|
|
3
|
+
import { compile, findV5Syntax, formatDiagnostic } from "squiffy-compiler";
|
|
4
4
|
import { externalFiles } from "./external-files.js";
|
|
5
|
+
import { findAssets, getStoryText } from "./assets.js";
|
|
5
6
|
import { createPackage } from "@textadventures/squiffy-packager";
|
|
6
|
-
|
|
7
|
+
// A story given as a filename is just that file and its @imports, as with no squiffy.json
|
|
8
|
+
const toStory = (input) => typeof input == "string" ? { mainFile: input } : input;
|
|
9
|
+
async function getCompileResult(story) {
|
|
10
|
+
const inputFilename = story.mainFile;
|
|
7
11
|
const inputFile = fs.readFileSync(inputFilename);
|
|
8
12
|
const inputText = inputFile.toString();
|
|
9
13
|
if (findV5Syntax(inputText).length > 0) {
|
|
10
14
|
console.warn("This story looks like it uses Squiffy 5 text processor syntax. Run with --convert-v5 to convert it to Squiffy 6.");
|
|
11
15
|
}
|
|
12
|
-
|
|
16
|
+
const result = await compile({
|
|
13
17
|
scriptBaseFilename: path.basename(inputFilename),
|
|
14
18
|
script: inputText,
|
|
15
|
-
onWarning: console.warn,
|
|
16
19
|
externalFiles: externalFiles(inputFilename),
|
|
20
|
+
storyFiles: story.storyFiles,
|
|
17
21
|
globalJs: true,
|
|
18
22
|
});
|
|
23
|
+
for (const diagnostic of result.diagnostics) {
|
|
24
|
+
if (diagnostic.severity == "error") {
|
|
25
|
+
console.error(formatDiagnostic(diagnostic));
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
console.warn(formatDiagnostic(diagnostic));
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return result;
|
|
19
32
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
33
|
+
const logLoading = (story) => {
|
|
34
|
+
if (story.note)
|
|
35
|
+
console.log(story.note);
|
|
36
|
+
console.log("Loading " + (story.projectFile ?? story.mainFile));
|
|
37
|
+
};
|
|
38
|
+
export const writeScriptFile = async (input, outputPath, outputFilename) => {
|
|
39
|
+
const story = toStory(input);
|
|
40
|
+
logLoading(story);
|
|
41
|
+
const result = await getCompileResult(story);
|
|
23
42
|
if (!result.success) {
|
|
24
43
|
console.log("Failed.");
|
|
25
44
|
return false;
|
|
@@ -27,14 +46,23 @@ export const writeScriptFile = async (inputFilename, outputPath, outputFilename)
|
|
|
27
46
|
console.log(`Writing ${outputFilename}`);
|
|
28
47
|
fs.writeFileSync(path.join(outputPath, outputFilename), await result.getJs());
|
|
29
48
|
};
|
|
30
|
-
export const createPackageFiles = async (
|
|
31
|
-
|
|
32
|
-
const
|
|
49
|
+
export const createPackageFiles = async (input, outputPath, options = {}) => {
|
|
50
|
+
const story = toStory(input);
|
|
51
|
+
const inputFilename = story.mainFile;
|
|
52
|
+
logLoading(story);
|
|
53
|
+
const result = await getCompileResult(story);
|
|
33
54
|
if (!result.success) {
|
|
34
55
|
console.log("Failed.");
|
|
35
56
|
return false;
|
|
36
57
|
}
|
|
37
|
-
|
|
58
|
+
// Asset files (images etc.) referenced by the story. The other package files are written to the
|
|
59
|
+
// story's folder, alongside these, so they only need to be passed on for the zip or for inlining.
|
|
60
|
+
const assets = options.assets ?? findAssets(inputFilename, getStoryText(result));
|
|
61
|
+
const assetPaths = Object.keys(assets);
|
|
62
|
+
if (assetPaths.length > 0 && (options.createZip || options.inlineHtml)) {
|
|
63
|
+
console.log(`Including asset${assetPaths.length == 1 ? "" : "s"}: ${assetPaths.join(", ")}`);
|
|
64
|
+
}
|
|
65
|
+
const pkg = await createPackage(result, { ...options, assets });
|
|
38
66
|
const files = pkg.files;
|
|
39
67
|
for (const file of Object.keys(files)) {
|
|
40
68
|
console.log(`Writing ${file}`);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { describe, test, expect, beforeEach, afterEach } from "vitest";
|
|
2
2
|
import { writeScriptFile, createPackageFiles } from "./file-packager.js";
|
|
3
3
|
import { externalFiles } from "./external-files.js";
|
|
4
|
+
import { findStory } from "squiffy-compiler/node";
|
|
4
5
|
import fs from "fs/promises";
|
|
5
6
|
import path from "path";
|
|
6
7
|
import { fileURLToPath } from "url";
|
|
@@ -147,6 +148,17 @@ describe("external-files", () => {
|
|
|
147
148
|
expect(matches.some(f => f.includes("test2.txt"))).toBe(true);
|
|
148
149
|
expect(matches.some(f => f.includes("other.md"))).toBe(false);
|
|
149
150
|
});
|
|
151
|
+
test("getMatchingFilenames returns matches sorted by relative path", async () => {
|
|
152
|
+
await fs.mkdir(path.join(TEST_DIR, "b"), { recursive: true });
|
|
153
|
+
for (const name of ["c.txt", "a.txt", "B.txt", "b/a.txt", "a-b.txt"]) {
|
|
154
|
+
await fs.writeFile(path.join(TEST_DIR, name), name);
|
|
155
|
+
}
|
|
156
|
+
const ext = externalFiles(path.join(TEST_DIR, "main.squiffy"));
|
|
157
|
+
const matches = await ext.getMatchingFilenames("**/*.txt");
|
|
158
|
+
// The same plain string sort on "/"-separated relative paths as the editor
|
|
159
|
+
expect(matches.map(f => ext.getLocalFilename(f).split(path.sep).join("/")))
|
|
160
|
+
.toEqual(["B.txt", "a-b.txt", "a.txt", "b/a.txt", "c.txt"]);
|
|
161
|
+
});
|
|
150
162
|
test("getContent reads file content", async () => {
|
|
151
163
|
const contentFile = path.join(TEST_DIR, "content.txt");
|
|
152
164
|
await fs.writeFile(contentFile, "Hello from external file!");
|
|
@@ -176,4 +188,17 @@ describe("external-files", () => {
|
|
|
176
188
|
expect(matches.length).toBe(1);
|
|
177
189
|
expect(matches[0]).toContain("notincluded.txt");
|
|
178
190
|
});
|
|
191
|
+
test("a folder with a squiffy.json builds every .squiffy file in it", async () => {
|
|
192
|
+
await fs.writeFile(path.join(TEST_DIR, "squiffy.json"), "{ \"version\": 1, \"main\": \"story.squiffy\", \"exclude\": [\"drafts/**\"] }");
|
|
193
|
+
await fs.writeFile(path.join(TEST_DIR, "story.squiffy"), "@title Folder\n[[start]]:\nGo to [[chapter]].\n");
|
|
194
|
+
await fs.mkdir(path.join(TEST_DIR, "chapters"), { recursive: true });
|
|
195
|
+
await fs.writeFile(path.join(TEST_DIR, "chapters", "one.squiffy"), "[[chapter]]:\nFrom another file.\n");
|
|
196
|
+
await fs.mkdir(path.join(TEST_DIR, "drafts"), { recursive: true });
|
|
197
|
+
await fs.writeFile(path.join(TEST_DIR, "drafts", "draft.squiffy"), "[[draft]]:\nNot in the story.\n");
|
|
198
|
+
const story = await findStory(TEST_DIR);
|
|
199
|
+
expect(await writeScriptFile(story, OUTPUT_DIR, "story.js")).not.toBe(false);
|
|
200
|
+
const storyContent = await fs.readFile(path.join(OUTPUT_DIR, "story.js"), "utf8");
|
|
201
|
+
expect(storyContent).toContain("From another file.");
|
|
202
|
+
expect(storyContent).not.toContain("Not in the story.");
|
|
203
|
+
});
|
|
179
204
|
});
|
package/dist/squiffy.js
CHANGED
|
@@ -4,12 +4,13 @@ import { hideBin } from "yargs/helpers";
|
|
|
4
4
|
import { serve } from "./server.js";
|
|
5
5
|
import { createPackageFiles, writeScriptFile } from "./file-packager.js";
|
|
6
6
|
import { convertV5File } from "./convert-v5.js";
|
|
7
|
+
import { findStory, StoryNotFoundError } from "squiffy-compiler/node";
|
|
7
8
|
import pkg from "../package.json" with { type: "json" };
|
|
8
9
|
import path from "path";
|
|
9
10
|
const version = pkg.version;
|
|
10
11
|
const argv = yargs(hideBin(process.argv))
|
|
11
|
-
.usage("Usage: npx @textadventures/squiffy-cli filename.squiffy [options]"
|
|
12
|
-
|
|
12
|
+
.usage("Usage: npx @textadventures/squiffy-cli [filename.squiffy | folder] [options]\n\n" +
|
|
13
|
+
"With a folder (or nothing, for the current folder), builds the story in its squiffy.json.")
|
|
13
14
|
.alias("s", "serve")
|
|
14
15
|
.alias("p", "port")
|
|
15
16
|
.describe("s", "Start HTTP server after compiling")
|
|
@@ -28,19 +29,36 @@ const options = {
|
|
|
28
29
|
zip: argv.zip,
|
|
29
30
|
inline: argv.inline
|
|
30
31
|
};
|
|
31
|
-
const
|
|
32
|
-
const
|
|
32
|
+
const input = argv._[0] === undefined ? "." : String(argv._[0]);
|
|
33
|
+
const findStoryOrExit = async () => {
|
|
34
|
+
try {
|
|
35
|
+
return await findStory(input);
|
|
36
|
+
}
|
|
37
|
+
catch (e) {
|
|
38
|
+
if (!(e instanceof StoryNotFoundError))
|
|
39
|
+
throw e;
|
|
40
|
+
console.error(e.message);
|
|
41
|
+
process.exit(1);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
33
44
|
if (argv.convertV5) {
|
|
34
|
-
if (
|
|
45
|
+
if (argv._[0] === undefined) {
|
|
46
|
+
console.error("Give the .squiffy file to convert.");
|
|
47
|
+
process.exitCode = 1;
|
|
48
|
+
}
|
|
49
|
+
else if (!convertV5File(input)) {
|
|
35
50
|
process.exitCode = 1;
|
|
36
51
|
}
|
|
37
52
|
}
|
|
38
53
|
else if (options.scriptOnly) {
|
|
54
|
+
const story = await findStoryOrExit();
|
|
39
55
|
const outputFilename = typeof options.scriptOnly === "string" ? options.scriptOnly : "story.js";
|
|
40
|
-
await writeScriptFile(
|
|
56
|
+
await writeScriptFile(story, path.dirname(story.mainFile), outputFilename);
|
|
41
57
|
}
|
|
42
58
|
else {
|
|
43
|
-
const
|
|
59
|
+
const story = await findStoryOrExit();
|
|
60
|
+
const outputPath = path.dirname(story.mainFile);
|
|
61
|
+
const result = await createPackageFiles(story, outputPath, {
|
|
44
62
|
createZip: !!options.zip,
|
|
45
63
|
inlineHtml: !!options.inline
|
|
46
64
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@textadventures/squiffy-cli",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.0-beta.2",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/textadventures/squiffy.git",
|
|
@@ -35,26 +35,27 @@
|
|
|
35
35
|
"squiffy-packager": "dist/squiffy.js"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@textadventures/squiffy-packager": "^
|
|
38
|
+
"@textadventures/squiffy-packager": "^7.0.0-beta.2",
|
|
39
39
|
"finalhandler": "^2.1.0",
|
|
40
|
-
"glob": "^
|
|
40
|
+
"glob": "^14.0.2",
|
|
41
41
|
"serve-static": "^2.2.0",
|
|
42
|
-
"squiffy-compiler": "^
|
|
43
|
-
"squiffy-runtime": "^
|
|
42
|
+
"squiffy-compiler": "^7.0.0-beta.2",
|
|
43
|
+
"squiffy-runtime": "^7.0.0-beta.2",
|
|
44
44
|
"yargs": "^18.2.0"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@types/finalhandler": "^1.2.4",
|
|
48
|
-
"@types/node": "^26.6.
|
|
48
|
+
"@types/node": "^26.6.6",
|
|
49
49
|
"@types/serve-static": "^2.2.0",
|
|
50
50
|
"@types/yargs": "^17.0.33",
|
|
51
|
+
"fflate": "^0.8.3",
|
|
51
52
|
"tsx": "^4.23.15",
|
|
52
53
|
"typescript": "^6.0.3",
|
|
53
|
-
"vitest": "^5.0.
|
|
54
|
+
"vitest": "^5.0.5"
|
|
54
55
|
},
|
|
55
56
|
"files": [
|
|
56
57
|
"dist"
|
|
57
58
|
],
|
|
58
59
|
"type": "module",
|
|
59
|
-
"gitHead": "
|
|
60
|
+
"gitHead": "2913cee0b823e2fadceb48d89c7029f2365974d9"
|
|
60
61
|
}
|