@@ -2,7 +2,7 @@ open Node
22
33module P = ClackPrompts
44
5- let packageNameRegExp = % re ( " /^[a-z0-9-]+$/" )
5+ let packageNameRegExp = /^ [a - z0 - 9 - ]+ $/
66
77let validateProjectName = projectName =>
88 if projectName -> String .trim -> String .length === 0 {
@@ -19,20 +19,20 @@ let updatePackageJson = async (~projectName, ~versions) =>
1919 await JsonUtils .updateJsonFile ("package.json" , json =>
2020 switch json {
2121 | Object (config ) => {
22- config -> Dict .set ("name" , String (projectName ))
23-
24- let scripts = switch config -> Dict .get ("scripts" ) {
25- | Some (Object (scripts )) => scripts
26- | _ =>
27- let scripts = Dict .make ()
28- config -> Dict .set ("scripts" , Object (scripts ))
29- scripts
30- }
31-
32- if RescriptVersions .usesRewatch (versions ) {
33- scripts -> Dict .set ("res:dev" , String ("rescript watch" ))
22+ config -> Dict .set ("name" , String (projectName ))
23+
24+ let scripts = switch config -> Dict .get ("scripts" ) {
25+ | Some (Object (scripts )) => scripts
26+ | _ =>
27+ let scripts = Dict .make ()
28+ config -> Dict .set ("scripts" , Object (scripts ))
29+ scripts
30+ }
31+
32+ if RescriptVersions .usesRewatch (versions ) {
33+ scripts -> Dict .set ("res:dev" , String ("rescript watch" ))
34+ }
3435 }
35- }
3636 | _ => ()
3737 }
3838 )
@@ -55,6 +55,11 @@ let updateRescriptJson = async (~projectName, ~versions) =>
5555 if Option .isNone (versions .rescriptCoreVersion ) {
5656 RescriptJsonUtils .removeRescriptCore (config )
5757 }
58+
59+ // https://github.com/rescript-lang/rescript/blob/master/CHANGELOG.md#1200-beta3
60+ if CompareVersions .satisfies (versions .rescriptVersion , ">=12.0.0-beta.3" ) {
61+ RescriptJsonUtils .modernizeConfigurationFields (config )
62+ }
5863 | _ => ()
5964 }
6065 )
@@ -119,8 +124,10 @@ let createNewProject = async () => {
119124 validate : validateProjectName ,
120125 })-> P .resultOrRaise
121126
122- let templateName =
123- await P .select ({message : "Select a template" , options : getTemplateOptions ()})-> P .resultOrRaise
127+ let templateName = await P .select ({
128+ message : "Select a template" ,
129+ options : getTemplateOptions (),
130+ })-> P .resultOrRaise
124131
125132 let versions = await RescriptVersions .promptVersions ()
126133
0 commit comments