@@ -44,12 +44,12 @@ const templates = [
44
44
async function init ( projectName : string , cwd : string , template : string ) {
45
45
const projectPath = path . join ( cwd , projectName ) ;
46
46
const clientPath = path . join ( projectPath , "client" ) ;
47
- const dojoStarterPath = path . join ( projectPath , "dojo-starter " ) ;
47
+ const contractPath = path . join ( projectPath , "contract " ) ;
48
48
49
49
// Create project directories
50
50
await fs . mkdir ( projectPath , { recursive : true } ) ;
51
51
await fs . mkdir ( clientPath , { recursive : true } ) ;
52
- await fs . mkdir ( dojoStarterPath , { recursive : true } ) ;
52
+ await fs . mkdir ( contractPath , { recursive : true } ) ;
53
53
54
54
// Clone template into client directory
55
55
console . log ( `Downloading ${ template } into client directory...` ) ;
@@ -66,26 +66,21 @@ async function init(projectName: string, cwd: string, template: string) {
66
66
// Rewrite package.json in client directory
67
67
await rewritePackageJson ( projectName , clientPath ) ;
68
68
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 ) ;
83
71
84
72
// Clone dojo-starter
85
73
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
+ }
89
84
90
85
console . log ( `Project initialized at ${ projectPath } ` ) ;
91
86
console . log ( "Congrats! Your new project has been set up successfully.\n" ) ;
@@ -116,6 +111,24 @@ async function rewritePackageJson(projectName: string, clientPath: string) {
116
111
await fs . writeFile ( packageJsonPath , JSON . stringify ( packageJson , null , 2 ) ) ;
117
112
}
118
113
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
+ / f r o m [ ' " ] \. { 0 , 2 } \/ .* m a n i f e s t (?: _ d e v ) ? \. j s o n [ ' " ] / 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
+
119
132
async function getLatestVersion ( ) : Promise < string > {
120
133
return new Promise ( ( resolve , reject ) => {
121
134
https
0 commit comments