Skip to content

Commit ff054d9

Browse files
committed
don't hardcode path for engine deps.
1 parent 2687e3f commit ff054d9

3 files changed

Lines changed: 38 additions & 9 deletions

File tree

scripts/_utils/generate-project.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,15 @@ export const projectTemplate = () => ({
2525
},
2626
});
2727

28-
export const denoJson = (root: string | URL) => ({
28+
export const denoJson = (root: string = "./.dreamlab-engine") => ({
2929
imports: {
30-
"@dreamlab/engine": path.join(root, "engine/mod.ts"),
31-
"@dreamlab/engine/internal": path.join(root, "engine/internal.ts"),
32-
"@dreamlab/vendor/": path.join(root, "engine/_deps/"),
33-
"@dreamlab/ui": path.join(root, "ui/mod.ts"),
34-
"@dreamlab/ui/jsx-runtime": path.join(root, "ui/jsx.ts"),
35-
"@dreamlab/util/": path.join(root, "util/"),
30+
// deno demands leading ./ or it errors
31+
"@dreamlab/engine": "./" + path.join(root, "engine/mod.ts"),
32+
"@dreamlab/engine/internal": "./" + path.join(root, "engine/internal.ts"),
33+
"@dreamlab/vendor/": "./" + path.join(root, "engine/_deps/"),
34+
"@dreamlab/ui": "./" + path.join(root, "ui/mod.ts"),
35+
"@dreamlab/ui/jsx-runtime": "./" + path.join(root, "ui/jsx.ts"),
36+
"@dreamlab/util/": "./" + path.join(root, "util/"),
3637
},
3738
compilerOptions: {
3839
lib: ["deno.window", "dom"],

scripts/setup.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ if (import.meta.main) {
147147
);
148148
await Deno.writeTextFile(
149149
path.join(fullPath, "deno.json"),
150-
JSON.stringify(denoJson(DREAMLAB_ROOT), null, 2) + "\n",
150+
JSON.stringify(denoJson(), null, 2) + "\n",
151151
);
152152

153153
await fs.ensureDir(path.join(fullPath, "src"));
@@ -174,9 +174,18 @@ if (import.meta.main) {
174174
// write correct deno.json
175175
await Deno.writeTextFile(
176176
path.join(fullPath, "deno.json"),
177-
JSON.stringify(denoJson(DREAMLAB_ROOT), null, 2) + "\n",
177+
JSON.stringify(denoJson(), null, 2) + "\n",
178178
);
179179

180+
// add the folder .dreamlab-engine to .gitignore (append to end)
181+
const gitignorePath = path.join(fullPath, ".gitignore");
182+
const gitignore = (await fs.exists(gitignorePath))
183+
? await Deno.readTextFile(gitignorePath)
184+
: "";
185+
if (!gitignore.includes(".dreamlab-engine")) {
186+
await Deno.writeTextFile(gitignorePath, gitignore + "\n.dreamlab-engine\n");
187+
}
188+
180189
return `Cloned Template: "${template.label}"`;
181190
});
182191

scripts/wql.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,25 @@ const cli = new Command()
2424
Deno.exit(1);
2525
}
2626

27+
// Create symlink to .worldql-dreamlab-engine if it doesn't exist
28+
const homeDir = Deno.env.get("HOME");
29+
if (homeDir) {
30+
const sourcePath = path.join(homeDir, ".worldql-dreamlab-engine");
31+
const targetPath = path.join(dir, ".dreamlab-engine");
32+
33+
const symlinkExists = await fs.exists(targetPath);
34+
if (!symlinkExists) {
35+
try {
36+
await Deno.symlink(sourcePath, targetPath);
37+
log.success(
38+
"Created symlink for engine dependencies. IntelliSense will now function properly. You may need to reload your code editor.",
39+
);
40+
} catch (error) {
41+
log.warning(`Failed to create symlink: ${error}`);
42+
}
43+
}
44+
}
45+
2746
const serverCmd = new Deno.Command(Deno.execPath(), {
2847
cwd: DREAMLAB_ROOT,
2948
args: ["task", "run-server", dir],

0 commit comments

Comments
 (0)