@@ -9,8 +9,6 @@ import { promisify } from "util";
99import { glob } from "glob" ;
1010import c from "picocolors" ;
1111
12- const rescriptVersion = "10.1" ;
13-
1412// Get __dirname in an ES6 module
1513const __filename = fileURLToPath ( import . meta. url ) ;
1614const __dirname = path . dirname ( __filename ) ;
@@ -31,7 +29,6 @@ const templates = [
3129 // value: "rescript-template-nextjs",
3230 // label: "Next.js",
3331 // hint: "Next.js, Tailwind CSS",
34- // incompatibleWithCore: true,
3532 // },
3633] ;
3734
@@ -71,30 +68,14 @@ async function updatePackageJson(projectName) {
7168 ) ;
7269}
7370
74- async function updateBsconfigJson ( projectName , withCore ) {
75- await updateFile ( "bsconfig .json" , contents => {
71+ async function updateRescriptJson ( projectName , withCore ) {
72+ await updateFile ( "rescript .json" , contents => {
7673 const config = JSON . parse ( contents ) ;
77-
7874 config [ "name" ] = projectName ;
79-
80- if ( withCore ) {
81- config [ "bs-dependencies" ] = [ ...( config [ "bs-dependencies" ] || [ ] ) , "@rescript/core" ] ;
82- config [ "bsc-flags" ] = [ ...( config [ "bsc-flags" ] || [ ] ) , "-open RescriptCore" ] ;
83- }
84-
8575 return JSON . stringify ( config , null , 2 ) ;
8676 } ) ;
8777}
8878
89- async function coreify ( ) {
90- const resFiles = await glob ( "src/**/*.res" ) ;
91- for ( const resFile of resFiles ) {
92- await updateFile ( resFile , contents =>
93- contents . replace ( "Js.log" , "Console.log" ) . replace ( "string_of_int" , "Int.toString" )
94- ) ;
95- }
96- }
97-
9879async function renameGitignore ( ) {
9980 await fs . promises . rename ( "_gitignore" , ".gitignore" ) ;
10081}
@@ -108,8 +89,10 @@ function getVersion() {
10889async function main ( ) {
10990 console . clear ( ) ;
11091
111- const versionString = `for ReScript ${ rescriptVersion } ${ c . dim ( "(" + getVersion ( ) + ")" ) } ` ;
112- p . intro ( `${ c . bgCyan ( c . black ( ` create-rescript-app ` ) ) } ${ versionString } ` ) ;
92+ p . intro ( `${ c . bgCyan ( c . black ( ` create-rescript-app ` ) ) } ${ c . dim ( "(" + getVersion ( ) + ")" ) } ` ) ;
93+ p . note (
94+ 'Create a new ReScript 11 project with modern defaults\n("Core" standard library, JSX 4 automatic mode)'
95+ ) ;
11396
11497 const projectName = await p . text ( {
11598 message : "What is the name of your new ReScript project?" ,
@@ -124,14 +107,17 @@ async function main() {
124107 } ) ;
125108 checkCancel ( templateName ) ;
126109
127- const incompatibleWithCore = templates . find ( t => t . value === templateName ) . incompatibleWithCore ;
110+ const rescriptVersion = await p . text ( {
111+ message : "ReScript version? (keep the default if unsure)" ,
112+ initialValue : "11.0.0-rc.7" ,
113+ } ) ;
114+ checkCancel ( rescriptVersion ) ;
128115
129- const withCore =
130- ! incompatibleWithCore &&
131- ( await p . confirm ( {
132- message : "Add the new @rescript/core standard library?" ,
133- } ) ) ;
134- checkCancel ( withCore ) ;
116+ const rescriptCoreVersion = await p . text ( {
117+ message : "ReScript Core version? (keep the default if unsure)" ,
118+ initialValue : "0.6.0" ,
119+ } ) ;
120+ checkCancel ( rescriptCoreVersion ) ;
135121
136122 const templatePath = path . join ( __dirname , "templates" , templateName ) ;
137123 const projectPath = path . join ( process . cwd ( ) , projectName ) ;
@@ -145,22 +131,23 @@ async function main() {
145131
146132 await renameGitignore ( ) ;
147133 await updatePackageJson ( projectName ) ;
148- await updateBsconfigJson ( projectName , withCore ) ;
149- await coreify ( ) ;
134+ await updateRescriptJson ( projectName ) ;
150135
151- const packages = [ `rescript@${ rescriptVersion } ` ] ;
152- if ( withCore ) {
153- packages . push ( "@rescript/core" ) ;
154- }
136+ const packages = [ `rescript@${ rescriptVersion } ` , `@rescript/core@${ rescriptCoreVersion } ` ] ;
155137
156138 await promisify ( exec ) ( "npm add " + packages . join ( " " ) ) ;
157139 await promisify ( exec ) ( "git init" ) ;
158140 s . stop ( "Project created." ) ;
159141
160- p . note ( `cd ${ projectName } \nnpm run res:dev` , "Next steps" ) ;
161- p . outro ( `Happy hacking! See ${ c . cyan ( "README.md" ) } for more information.` ) ;
142+ p . note (
143+ `Your project ${ c . cyan ( projectName ) } was created successfully.\nChange to the ${ c . cyan (
144+ projectName
145+ ) } folder and view ${ c . cyan ( "README.md" ) } for more information.`,
146+ "Next steps"
147+ ) ;
148+ p . outro ( `Happy hacking!` ) ;
162149 } catch ( error ) {
163- s . stop ( " Installation error." ) ;
150+ s . stop ( ` Installation error: ${ error } ` ) ;
164151
165152 p . outro ( `Project creation failed.` ) ;
166153
0 commit comments