Skip to content

Commit ca7ed9c

Browse files
committed
fix: create-dojo + update manifest path
1 parent b47c945 commit ca7ed9c

File tree

3 files changed

+34
-21
lines changed

3 files changed

+34
-21
lines changed

examples/example-vite-kitchen-sink/dojoConfig.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { createDojoConfig } from "@dojoengine/core";
22

3-
import manifest from "../../worlds/dojo-starter/manifest_dev.json";
3+
import manifest from "../../worlds/onchain-dash/manifests/release/deployment/manifest.json";
44

55
export const dojoConfig = createDojoConfig({
66
manifest,

examples/example-vite-kitchen-sink/src/main.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import "./app/globals.css";
99
import { init } from "@dojoengine/sdk";
1010
import { OnchainDashSchemaType, schema } from "@/dojo/models";
1111
import { env, getRpcUrl } from "@/env";
12-
import { dojoConfig } from "@/dojo.config";
12+
import { dojoConfig } from "../dojoConfig";
1313
import { DojoContext } from "@/dojo/provider";
1414

1515
async function main() {

packages/create-dojo/src/commands/start.ts

+32-19
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,12 @@ const templates = [
4444
async function init(projectName: string, cwd: string, template: string) {
4545
const projectPath = path.join(cwd, projectName);
4646
const clientPath = path.join(projectPath, "client");
47-
const dojoStarterPath = path.join(projectPath, "dojo-starter");
47+
const contractPath = path.join(projectPath, "contract");
4848

4949
// Create project directories
5050
await fs.mkdir(projectPath, { recursive: true });
5151
await fs.mkdir(clientPath, { recursive: true });
52-
await fs.mkdir(dojoStarterPath, { recursive: true });
52+
await fs.mkdir(contractPath, { recursive: true });
5353

5454
// Clone template into client directory
5555
console.log(`Downloading ${template} into client directory...`);
@@ -66,26 +66,21 @@ async function init(projectName: string, cwd: string, template: string) {
6666
// Rewrite package.json in client directory
6767
await rewritePackageJson(projectName, clientPath);
6868

69-
console.log(`Cloning dojo-starter repository...`);
70-
const gitCloneResult = spawn.sync(
71-
"git",
72-
[
73-
"clone",
74-
"https://github.com/dojoengine/dojo-starter.git",
75-
dojoStarterPath,
76-
],
77-
{ stdio: "inherit" }
78-
);
79-
80-
if (gitCloneResult.status !== 0) {
81-
throw new Error(`Failed to clone dojo-starter repository.`);
82-
}
69+
// Update dojoConfig.ts imports
70+
await rewriteDojoConfigFile(clientPath);
8371

8472
// Clone dojo-starter
8573
console.log(`Downloading dojo-starter...`);
86-
spawn.sync("npx", ["degit", `dojoengine/dojo-starter`, dojoStarterPath], {
87-
stdio: "inherit",
88-
});
74+
const contractRes = spawn.sync(
75+
"npx",
76+
["degit", `dojoengine/dojo-starter`, contractPath],
77+
{
78+
stdio: "inherit",
79+
}
80+
);
81+
if (contractRes.status !== 0) {
82+
throw new Error(`Failed to clone template: ${template}`);
83+
}
8984

9085
console.log(`Project initialized at ${projectPath}`);
9186
console.log("Congrats! Your new project has been set up successfully.\n");
@@ -116,6 +111,24 @@ async function rewritePackageJson(projectName: string, clientPath: string) {
116111
await fs.writeFile(packageJsonPath, JSON.stringify(packageJson, null, 2));
117112
}
118113

114+
async function rewriteDojoConfigFile(clientPath: string) {
115+
const dojoConfigPath = path.join(clientPath, "dojoConfig.ts");
116+
117+
try {
118+
let content = await fs.readFile(dojoConfigPath, "utf-8");
119+
120+
// Update relative imports to account for new directory structure
121+
content = content.replace(
122+
/from ['"]\.{0,2}\/.*manifest(?:_dev)?\.json['"]/g,
123+
'from "../contract/target/dev/manifest.json"'
124+
);
125+
126+
await fs.writeFile(dojoConfigPath, content, "utf-8");
127+
} catch (error) {
128+
console.warn(`Warning: Could not update dojoConfig.ts: ${error}`);
129+
}
130+
}
131+
119132
async function getLatestVersion(): Promise<string> {
120133
return new Promise((resolve, reject) => {
121134
https

0 commit comments

Comments
 (0)