Skip to content

Commit

Permalink
fix: issue with godot-ts build (#10)
Browse files Browse the repository at this point in the history
* fix: issue with dependency for package.json

* fix: additional issues with build
  • Loading branch information
nmerget authored Sep 27, 2024
1 parent d3ea50c commit 5c74dda
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 28 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ Tool for using [GodotJS](https://github.com/godotjs/javascript) with TypeScript.
4. Test if you can use Godot via CLI and run `godot --version`
5. Run `npx -y @godot-js/godot-ts init` - new project will be crated at your current terminal path
6. Follow the prompts
7. After Godot editor opens click on `Project/Reload current project` to see all generated files

## API

Expand Down
5 changes: 1 addition & 4 deletions src/commands/init/copy/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@
"experimentalDecorators": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"resolveJsonModule": true,
"paths": {
"decorators": ["./src/decorators.bundle"]
}
"resolveJsonModule": true
}
}
4 changes: 2 additions & 2 deletions src/commands/init/create/package.json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ export const getPackageJson = (
build: "godot-ts build",
dev: "npm-run-all build -p watch open-editor",
"open-editor": "godot -e --path .",
start: "godot",
start: "npm run build && godot",
watch: "godot-ts watch",
},
devDependencies: {
"@godot-js/ts": `^${version}`,
"@godot-js/godot-ts": `^${version}`,
"npm-run-all": `${npmRunAll}`,
typescript: `${typescript}`,
},
Expand Down
4 changes: 4 additions & 0 deletions src/utils/path.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,9 @@ export const stripRelativePath = (path?: string): string => {
return path.slice(1, path.length);
}

if (!path.startsWith("/")) {
return `/${path}`;
}

return path;
};
30 changes: 20 additions & 10 deletions test/esbuild/build.test.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,29 @@
import { describe, expect, test } from "vitest";
import { buildAction } from "../../src/commands/build";
import { readdirSync } from "node:fs";
import { rimrafSync } from "rimraf";

const src = "./test/esbuild/src";
const out = "./test/esbuild/scripts";
const allSrc = ["./test/esbuild/src", "test/esbuild/src"];

const allOut = [
"./test/esbuild/scripts",
"test/esbuild/scripts",
];

describe("build", () => {
test("simple test", async () => {
await buildAction({
src,
out,
allSrc.forEach((src) => {
allOut.forEach((out) => {
rimrafSync(out);
test(`simple test ${src} ${out}`, async () => {
await buildAction({
src,
out,
});
const files: string[] = readdirSync(out);
expect(files).toHaveLength(2);
expect(files[0]).toEqual("decorators.bundle.js");
expect(files[1]).toEqual("my-class.mjs");
});
});
const files: string[] = readdirSync(out);
expect(files).toHaveLength(2);
expect(files[0]).toEqual("decorators.bundle.js");
expect(files[1]).toEqual("my-class.mjs");
});
});
25 changes: 14 additions & 11 deletions test/init/init.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ import { describe, expect, test } from "vitest";
import { readdirSync } from "node:fs";
import { initAction } from "../../src/commands/init";

const out = "./test/init";
const gameName = "game";

const allOut = ["./test/init", "test/init"];

const expectedFiles = [
"node_modules",
"src",
Expand All @@ -16,16 +17,18 @@ const expectedFiles = [
];

describe("init", () => {
test("test", async () => {
await initAction({
name: gameName,
out,
forceDelete: true,
});
const files: string[] = readdirSync(`${out}/${gameName}`);
expect(files).toHaveLength(7);
expectedFiles.forEach((file) => {
expect(files).toContain(file);
allOut.forEach((out) => {
test(`test ${out}`, async () => {
await initAction({
name: gameName,
out,
forceDelete: true,
});
const files: string[] = readdirSync(`${out}/${gameName}`);
expect(files).toHaveLength(7);
expectedFiles.forEach((file) => {
expect(files).toContain(file);
});
});
});
});

0 comments on commit 5c74dda

Please sign in to comment.