miaoda-game-devkit 0.2.12 → 0.2.13

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.
@@ -1,32 +0,0 @@
1
- // src/lint/phaser-text-assertions.test.ts
2
- import { describe, expect, it } from "vitest";
3
-
4
- // src/phaser-text-assertions.ts
5
- import * as Phaser from "phaser";
6
- function collectMissingBitmapGlyphs(text, chars) {
7
- const missing = [];
8
- const seen = /* @__PURE__ */ new Set();
9
- for (let index = 0; index < text.length; index += 1) {
10
- const character = text[index];
11
- if (/\s/u.test(character)) continue;
12
- const code = text.charCodeAt(index);
13
- if (seen.has(code) || chars[code] !== void 0) continue;
14
- seen.add(code);
15
- missing.push(
16
- `${JSON.stringify(character)} (U+${code.toString(16).toUpperCase().padStart(4, "0")})`
17
- );
18
- }
19
- return missing;
20
- }
21
-
22
- // src/lint/phaser-text-assertions.test.ts
23
- describe("Phaser text health rules", () => {
24
- it("ignores whitespace-only BitmapText content", () => {
25
- expect(collectMissingBitmapGlyphs(" \n ", {})).toEqual([]);
26
- });
27
- it("accepts covered Unicode code units and reports missing ones once", () => {
28
- expect(collectMissingBitmapGlyphs("\u4E2D\u6587\u4E2D", { ["\u4E2D".charCodeAt(0)]: {} })).toEqual([
29
- '"\u6587" (U+6587)'
30
- ]);
31
- });
32
- });
@@ -1,97 +0,0 @@
1
- // src/lint/resource-import-plugin.test.ts
2
- import { createRequire } from "module";
3
- import { execFileSync } from "child_process";
4
- import {
5
- mkdtempSync,
6
- mkdirSync,
7
- readFileSync,
8
- rmSync,
9
- writeFileSync
10
- } from "fs";
11
- import { tmpdir } from "os";
12
- import { dirname, join, resolve } from "path";
13
- import { describe, expect, it } from "vitest";
14
- var packageRoot = resolve(import.meta.dirname, "../..");
15
- var packageRequire = createRequire(join(packageRoot, "package.json"));
16
- function resolveBinary(packageName, binName) {
17
- const manifestPath = packageRequire.resolve(`${packageName}/package.json`);
18
- const manifest = JSON.parse(readFileSync(manifestPath, "utf8"));
19
- const relativeBin = typeof manifest.bin === "string" ? manifest.bin : manifest.bin?.[binName];
20
- if (!relativeBin) throw new Error(`${packageName} does not expose ${binName}`);
21
- return resolve(dirname(manifestPath), relativeBin);
22
- }
23
- function createFixture(source, resources) {
24
- const root = mkdtempSync(join(tmpdir(), "miaoda-game-plugin-test-"));
25
- mkdirSync(join(root, "src", "assets"), { recursive: true });
26
- writeFileSync(join(root, "package.json"), JSON.stringify({ type: "module" }));
27
- writeFileSync(join(root, "tsconfig.json"), JSON.stringify({
28
- compilerOptions: { baseUrl: ".", paths: { "@/*": ["src/*"] } }
29
- }));
30
- writeFileSync(join(root, "src", "entry.ts"), source);
31
- for (const resource of resources) {
32
- const path = join(root, "src", "assets", resource);
33
- mkdirSync(dirname(path), { recursive: true });
34
- writeFileSync(path, "fixture");
35
- }
36
- return root;
37
- }
38
- function runOxlint(root) {
39
- const configPath = join(root, "oxlint.json");
40
- writeFileSync(configPath, JSON.stringify({
41
- jsPlugins: [
42
- resolve(import.meta.dirname, "../rules/check-image-import-plugin.js"),
43
- resolve(import.meta.dirname, "../rules/check-style-import-plugin.js")
44
- ],
45
- rules: {
46
- "check-image-exists/no-missing-image": "error",
47
- "check-style-exists/no-missing-style": "error"
48
- }
49
- }));
50
- const result = (() => {
51
- try {
52
- execFileSync(process.execPath, [resolveBinary("oxlint", "oxlint"), "-c", configPath, "src"], {
53
- cwd: root,
54
- encoding: "utf8",
55
- stdio: ["ignore", "pipe", "pipe"]
56
- });
57
- return { status: 0, output: "" };
58
- } catch (error) {
59
- const failure = error;
60
- return {
61
- status: failure.status ?? null,
62
- output: `${failure.stdout ?? ""}
63
- ${failure.stderr ?? ""}`
64
- };
65
- }
66
- })();
67
- return result;
68
- }
69
- describe("Oxlint resource import plugins", () => {
70
- it("accept existing relative and tsconfig-alias image/style imports", () => {
71
- const root = createFixture(
72
- [
73
- 'import "./assets/icon.png"; import "@/assets/theme.css";'
74
- ].join("\n"),
75
- ["icon.png", "theme.css"]
76
- );
77
- try {
78
- expect(runOxlint(root)).toMatchObject({ status: 0 });
79
- } finally {
80
- rmSync(root, { recursive: true, force: true });
81
- }
82
- });
83
- it("reports missing image and style imports through the real Oxlint CLI", () => {
84
- const root = createFixture(
85
- 'import "./assets/missing.png"; import "@/assets/missing.css";\n',
86
- []
87
- );
88
- try {
89
- const result = runOxlint(root);
90
- expect(result.status).toBe(1);
91
- expect(result.output).toContain("missing.png");
92
- expect(result.output).toContain("missing.css");
93
- } finally {
94
- rmSync(root, { recursive: true, force: true });
95
- }
96
- });
97
- });