@gd-kirie/build 0.2.1 → 0.2.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/index.d.ts +3 -10
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -26
- package/dist/index.js.map +1 -1
- package/package.json +2 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,31 +1,24 @@
|
|
|
1
|
-
import { Options } from "execa";
|
|
2
1
|
import { InlineConfig, UserConfig } from "vite";
|
|
3
2
|
|
|
4
3
|
//#region src/dotnet.d.ts
|
|
5
4
|
interface BuildDotnetOptions {
|
|
6
5
|
projectDir: string;
|
|
7
6
|
skipMissingProject?: boolean;
|
|
8
|
-
stdio?: Options["stdio"];
|
|
9
7
|
}
|
|
10
8
|
declare function buildDotnet(options: BuildDotnetOptions): Promise<void>;
|
|
11
9
|
//#endregion
|
|
12
10
|
//#region src/godot.d.ts
|
|
13
11
|
type ExportMode = "debug" | "release";
|
|
14
|
-
interface
|
|
12
|
+
interface ExportGodotPresetOptions {
|
|
15
13
|
godotArgs?: string[];
|
|
16
14
|
godotCommand: string;
|
|
17
|
-
projectDir: string;
|
|
18
|
-
stdio?: Options["stdio"];
|
|
19
|
-
}
|
|
20
|
-
interface PrepareGodotProjectOptions extends GodotCommandOptions {}
|
|
21
|
-
interface ExportGodotPresetOptions extends GodotCommandOptions {
|
|
22
15
|
installAndroidBuildTemplate?: boolean;
|
|
23
16
|
mode: ExportMode;
|
|
24
17
|
outputPath: string;
|
|
25
18
|
preset: string;
|
|
19
|
+
projectDir: string;
|
|
26
20
|
userArgs?: string[];
|
|
27
21
|
}
|
|
28
|
-
declare function prepareGodotProject(options: PrepareGodotProjectOptions): Promise<void>;
|
|
29
22
|
declare function exportGodotPreset(options: ExportGodotPresetOptions): Promise<void>;
|
|
30
23
|
//#endregion
|
|
31
24
|
//#region src/presets.d.ts
|
|
@@ -45,5 +38,5 @@ interface BuildViteWebOptions {
|
|
|
45
38
|
declare function buildViteWeb(options: BuildViteWebOptions): Promise<void>;
|
|
46
39
|
declare function createViteBuildConfig(options: BuildViteWebOptions): InlineConfig;
|
|
47
40
|
//#endregion
|
|
48
|
-
export { type BuildDotnetOptions, type BuildViteWebOptions, type ExportGodotPresetOptions, type ExportMode, type
|
|
41
|
+
export { type BuildDotnetOptions, type BuildViteWebOptions, type ExportGodotPresetOptions, type ExportMode, type ReadExportPresetValueOptions, buildDotnet, buildViteWeb, createViteBuildConfig, exportGodotPreset, readExportPresetValue };
|
|
49
42
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/dotnet.ts","../src/godot.ts","../src/presets.ts","../src/vite.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/dotnet.ts","../src/godot.ts","../src/presets.ts","../src/vite.ts"],"mappings":";;;UAIiB,kBAAA;EACf,UAAA;EACA,kBAAA;AAAA;AAAA,iBAGoB,WAAA,CAAY,OAAA,EAAS,kBAAA,GAAqB,OAAA;;;KCLpD,UAAA;AAAA,UAEK,wBAAA;EACf,SAAA;EACA,YAAA;EACA,2BAAA;EACA,IAAA,EAAM,UAAA;EACN,UAAA;EACA,MAAA;EACA,UAAA;EACA,QAAA;AAAA;AAAA,iBAGoB,iBAAA,CAAkB,OAAA,EAAS,wBAAA,GAA2B,OAAA;;;UCT3D,4BAAA;EACf,UAAA;EACA,UAAA;EACA,UAAA;AAAA;AAAA,iBAGc,qBAAA,CAAsB,OAAS,EAAA,4BAAA;;;UCN9B,mBAAA;EACf,IAAA;EACA,UAAA,GAAa,UAAA;EACb,OAAA;AAAA;AAAA,iBAGoB,YAAA,CAAa,OAAA,EAAS,mBAAA,GAAsB,OAAA;AAAA,iBASlD,qBAAA,CAAsB,OAAA,EAAS,mBAAA,GAAsB,YAAA"}
|
package/dist/index.js
CHANGED
|
@@ -9,35 +9,22 @@ async function buildDotnet(options) {
|
|
|
9
9
|
const result = await execa("dotnet", ["build"], {
|
|
10
10
|
all: true,
|
|
11
11
|
cwd: options.projectDir,
|
|
12
|
-
reject: false
|
|
13
|
-
stdio: options.stdio
|
|
12
|
+
reject: false
|
|
14
13
|
});
|
|
15
|
-
const output =
|
|
14
|
+
const output = result.all ?? "";
|
|
16
15
|
if (result.exitCode === 0) {
|
|
17
|
-
|
|
16
|
+
process.stdout.write(output);
|
|
18
17
|
return;
|
|
19
18
|
}
|
|
20
19
|
if (options.skipMissingProject && output.includes(DOTNET_NO_PROJECT_ERROR)) {
|
|
21
20
|
console.log("No .NET project found; skipping dotnet build.");
|
|
22
21
|
return;
|
|
23
22
|
}
|
|
24
|
-
|
|
23
|
+
process.stdout.write(output);
|
|
25
24
|
throw new Error("dotnet build failed.");
|
|
26
25
|
}
|
|
27
26
|
//#endregion
|
|
28
27
|
//#region src/godot.ts
|
|
29
|
-
async function prepareGodotProject(options) {
|
|
30
|
-
await execa(options.godotCommand, [
|
|
31
|
-
...options.godotArgs ?? [],
|
|
32
|
-
"--headless",
|
|
33
|
-
"--path",
|
|
34
|
-
options.projectDir,
|
|
35
|
-
"--import"
|
|
36
|
-
], {
|
|
37
|
-
cwd: options.projectDir,
|
|
38
|
-
stdio: options.stdio ?? "inherit"
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
28
|
async function exportGodotPreset(options) {
|
|
42
29
|
fs.mkdirSync(path.dirname(options.outputPath), { recursive: true });
|
|
43
30
|
const args = [
|
|
@@ -48,10 +35,10 @@ async function exportGodotPreset(options) {
|
|
|
48
35
|
];
|
|
49
36
|
if (options.installAndroidBuildTemplate) args.push("--install-android-build-template");
|
|
50
37
|
args.push(options.mode === "debug" ? "--export-debug" : "--export-release", options.preset, options.outputPath);
|
|
51
|
-
if (options.userArgs
|
|
38
|
+
if (options.userArgs?.length) args.push("--", ...options.userArgs);
|
|
52
39
|
await execa(options.godotCommand, args, {
|
|
53
40
|
cwd: options.projectDir,
|
|
54
|
-
stdio:
|
|
41
|
+
stdio: "inherit"
|
|
55
42
|
});
|
|
56
43
|
}
|
|
57
44
|
//#endregion
|
|
@@ -78,7 +65,8 @@ const KIRIE_OWNED_VITE_SERVER_OPTIONS = [
|
|
|
78
65
|
];
|
|
79
66
|
const KIRIE_OWNED_VITE_BUILD_OPTIONS = ["outDir"];
|
|
80
67
|
async function buildViteWeb(options) {
|
|
81
|
-
|
|
68
|
+
const indexPath = path.join(options.webRoot, "index.html");
|
|
69
|
+
if (!fs.existsSync(indexPath)) throw new Error(`Kirie build web requires ${indexPath}.`);
|
|
82
70
|
await build(createViteBuildConfig(options));
|
|
83
71
|
}
|
|
84
72
|
function createViteBuildConfig(options) {
|
|
@@ -91,11 +79,6 @@ function createViteBuildConfig(options) {
|
|
|
91
79
|
root: options.webRoot
|
|
92
80
|
});
|
|
93
81
|
}
|
|
94
|
-
function assertWebEntryExists(webRoot, commandName) {
|
|
95
|
-
const indexPath = path.join(webRoot, "index.html");
|
|
96
|
-
if (fs.existsSync(indexPath)) return;
|
|
97
|
-
throw new Error(`${commandName} requires ${indexPath}.`);
|
|
98
|
-
}
|
|
99
82
|
function assertNoKirieOwnedViteOptions(viteConfig) {
|
|
100
83
|
assertNoOwnedOptions(viteConfig, "web.vite", KIRIE_OWNED_VITE_OPTIONS);
|
|
101
84
|
const server = viteConfig.server;
|
|
@@ -107,6 +90,6 @@ function assertNoOwnedOptions(config, pathPrefix, options) {
|
|
|
107
90
|
for (const option of options) if (option in config) throw new Error(`${pathPrefix}.${option} is owned by Kirie and cannot be set in kirie.config.ts.`);
|
|
108
91
|
}
|
|
109
92
|
//#endregion
|
|
110
|
-
export { buildDotnet, buildViteWeb, createViteBuildConfig, exportGodotPreset,
|
|
93
|
+
export { buildDotnet, buildViteWeb, createViteBuildConfig, exportGodotPreset, readExportPresetValue };
|
|
111
94
|
|
|
112
95
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["parseIni"],"sources":["../src/dotnet.ts","../src/godot.ts","../src/presets.ts","../src/vite.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"index.js","names":["parseIni"],"sources":["../src/dotnet.ts","../src/godot.ts","../src/presets.ts","../src/vite.ts"],"sourcesContent":["import { execa } from \"execa\";\n\nconst DOTNET_NO_PROJECT_ERROR = \"MSB1003\";\n\nexport interface BuildDotnetOptions {\n projectDir: string;\n skipMissingProject?: boolean;\n}\n\nexport async function buildDotnet(options: BuildDotnetOptions): Promise<void> {\n const result = await execa(\"dotnet\", [\"build\"], {\n all: true,\n cwd: options.projectDir,\n reject: false,\n });\n const output = result.all ?? \"\";\n\n if (result.exitCode === 0) {\n process.stdout.write(output);\n return;\n }\n\n if (options.skipMissingProject && output.includes(DOTNET_NO_PROJECT_ERROR)) {\n console.log(\"No .NET project found; skipping dotnet build.\");\n return;\n }\n\n process.stdout.write(output);\n throw new Error(\"dotnet build failed.\");\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport { execa } from \"execa\";\n\nexport type ExportMode = \"debug\" | \"release\";\n\nexport interface ExportGodotPresetOptions {\n godotArgs?: string[];\n godotCommand: string;\n installAndroidBuildTemplate?: boolean;\n mode: ExportMode;\n outputPath: string;\n preset: string;\n projectDir: string;\n userArgs?: string[];\n}\n\nexport async function exportGodotPreset(options: ExportGodotPresetOptions): Promise<void> {\n fs.mkdirSync(path.dirname(options.outputPath), { recursive: true });\n\n const args = [...(options.godotArgs ?? []), \"--headless\", \"--path\", options.projectDir];\n\n if (options.installAndroidBuildTemplate) {\n args.push(\"--install-android-build-template\");\n }\n\n args.push(\n options.mode === \"debug\" ? \"--export-debug\" : \"--export-release\",\n options.preset,\n options.outputPath,\n );\n\n if (options.userArgs?.length) {\n args.push(\"--\", ...options.userArgs);\n }\n\n await execa(options.godotCommand, args, {\n cwd: options.projectDir,\n stdio: \"inherit\",\n });\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport { parse as parseIni } from \"ini\";\n\ninterface ParsedExportPresets {\n preset?: Record<string, { name?: string; options?: Record<string, unknown> }>;\n}\n\nexport interface ReadExportPresetValueOptions {\n optionName: string;\n presetName: string;\n projectDir: string;\n}\n\nexport function readExportPresetValue(options: ReadExportPresetValueOptions): unknown {\n const exportPresetsPath = path.join(options.projectDir, \"export_presets.cfg\");\n const config = parseIni(fs.readFileSync(exportPresetsPath, \"utf8\")) as ParsedExportPresets;\n\n for (const preset of Object.values(config.preset ?? {})) {\n if (preset.name !== options.presetName) {\n continue;\n }\n\n const value = preset.options?.[options.optionName];\n if (value === undefined) {\n throw new Error(\n `Export preset option not found: ${options.optionName} in ${exportPresetsPath}`,\n );\n }\n\n return value;\n }\n\n throw new Error(`Export preset not found: ${options.presetName} in ${exportPresetsPath}`);\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport { build, type InlineConfig, mergeConfig, type UserConfig } from \"vite\";\n\nconst KIRIE_OWNED_VITE_OPTIONS = [\"root\", \"base\"] as const;\nconst KIRIE_OWNED_VITE_SERVER_OPTIONS = [\"host\", \"port\", \"strictPort\", \"open\"] as const;\nconst KIRIE_OWNED_VITE_BUILD_OPTIONS = [\"outDir\"] as const;\n\nexport interface BuildViteWebOptions {\n mode?: string;\n viteConfig?: UserConfig;\n webRoot: string;\n}\n\nexport async function buildViteWeb(options: BuildViteWebOptions): Promise<void> {\n const indexPath = path.join(options.webRoot, \"index.html\");\n if (!fs.existsSync(indexPath)) {\n throw new Error(`Kirie build web requires ${indexPath}.`);\n }\n\n await build(createViteBuildConfig(options));\n}\n\nexport function createViteBuildConfig(options: BuildViteWebOptions): InlineConfig {\n assertNoKirieOwnedViteOptions((options.viteConfig ?? {}) as Record<string, unknown>);\n\n return mergeConfig(options.viteConfig ?? {}, {\n base: \"./\",\n build: {\n outDir: \"dist\",\n },\n configFile: false,\n mode: options.mode,\n root: options.webRoot,\n }) as InlineConfig;\n}\n\nfunction assertNoKirieOwnedViteOptions(viteConfig: Record<string, unknown>): void {\n assertNoOwnedOptions(viteConfig, \"web.vite\", KIRIE_OWNED_VITE_OPTIONS);\n\n const server = viteConfig.server;\n if (server && typeof server === \"object\") {\n assertNoOwnedOptions(\n server as Record<string, unknown>,\n \"web.vite.server\",\n KIRIE_OWNED_VITE_SERVER_OPTIONS,\n );\n }\n\n const buildOptions = viteConfig.build;\n if (buildOptions && typeof buildOptions === \"object\") {\n assertNoOwnedOptions(\n buildOptions as Record<string, unknown>,\n \"web.vite.build\",\n KIRIE_OWNED_VITE_BUILD_OPTIONS,\n );\n }\n}\n\nfunction assertNoOwnedOptions(\n config: Record<string, unknown>,\n pathPrefix: string,\n options: readonly string[],\n): void {\n for (const option of options) {\n if (option in config) {\n throw new Error(\n `${pathPrefix}.${option} is owned by Kirie and cannot be set in kirie.config.ts.`,\n );\n }\n }\n}\n"],"mappings":";;;;;;AAEA,MAAM,0BAA0B;AAOhC,eAAsB,YAAY,SAA4C;CAC5E,MAAM,SAAS,MAAM,MAAM,UAAU,CAAC,OAAO,GAAG;EAC9C,KAAK;EACL,KAAK,QAAQ;EACb,QAAQ;CACV,CAAC;CACD,MAAM,SAAS,OAAO,OAAO;CAE7B,IAAI,OAAO,aAAa,GAAG;EACzB,QAAQ,OAAO,MAAM,MAAM;EAC3B;CACF;CAEA,IAAI,QAAQ,sBAAsB,OAAO,SAAS,uBAAuB,GAAG;EAC1E,QAAQ,IAAI,+CAA+C;EAC3D;CACF;CAEA,QAAQ,OAAO,MAAM,MAAM;CAC3B,MAAM,IAAI,MAAM,sBAAsB;AACxC;;;ACZA,eAAsB,kBAAkB,SAAkD;CACxF,GAAG,UAAU,KAAK,QAAQ,QAAQ,UAAU,GAAG,EAAE,WAAW,KAAK,CAAC;CAElE,MAAM,OAAO;EAAC,GAAI,QAAQ,aAAa,CAAC;EAAI;EAAc;EAAU,QAAQ;CAAU;CAEtF,IAAI,QAAQ,6BACV,KAAK,KAAK,kCAAkC;CAG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AAC;AACH;AAEA,SAAS,8BAA8B,YAA2C;CAChF,qBAAqB,YAAY,YAAY,wBAAwB;CAErE,MAAM,SAAS,WAAW;CAC1B,IAAI,UAAU,OAAO,WAAW,UAC9B,qBACE,QACA,mBACA,+BACF;CAGF,MAAM,eAAe,WAAW;CAChC,IAAI,gBAAgB,OAAO,iBAAiB,UAC1C,qBACE,cACA,kBACA,8BACF;AAEJ;AAEA,SAAS,qBACP,QACA,YACA,SACM;CACN,KAAK,MAAM,UAAU,SACnB,IAAI,UAAU,QACZ,MAAM,IAAI,MACR,GAAG,WAAW,GAAG,OAAO,yDAC1B;AAGN"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gd-kirie/build",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -27,8 +27,7 @@
|
|
|
27
27
|
"@types/ini": "^4.1.1",
|
|
28
28
|
"@types/node": "^25.6.0",
|
|
29
29
|
"tsdown": "^0.22.2",
|
|
30
|
-
"typescript": "^6.0.3"
|
|
31
|
-
"vitest": "^4.0.15"
|
|
30
|
+
"typescript": "^6.0.3"
|
|
32
31
|
},
|
|
33
32
|
"publishConfig": {
|
|
34
33
|
"access": "public",
|