@@ -2,7 +2,7 @@ open Node
2
2
3
3
module P = ClackPrompts
4
4
5
- let packageNameRegExp = % re ( " /^[a-z0-9-]+$/" )
5
+ let packageNameRegExp = /^ [a - z0 - 9 - ]+ $/
6
6
7
7
let validateProjectName = projectName =>
8
8
if projectName -> String .trim -> String .length === 0 {
@@ -19,20 +19,20 @@ let updatePackageJson = async (~projectName, ~versions) =>
19
19
await JsonUtils .updateJsonFile ("package.json" , json =>
20
20
switch json {
21
21
| 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
+ }
34
35
}
35
- }
36
36
| _ => ()
37
37
}
38
38
)
@@ -55,6 +55,11 @@ let updateRescriptJson = async (~projectName, ~versions) =>
55
55
if Option .isNone (versions .rescriptCoreVersion ) {
56
56
RescriptJsonUtils .removeRescriptCore (config )
57
57
}
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
+ }
58
63
| _ => ()
59
64
}
60
65
)
@@ -119,8 +124,10 @@ let createNewProject = async () => {
119
124
validate : validateProjectName ,
120
125
})-> P .resultOrRaise
121
126
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
124
131
125
132
let versions = await RescriptVersions .promptVersions ()
126
133
0 commit comments