Skip to content

Commit 9c84789

Browse files
authored
Cleanup; fix long form of command line option not working (#8)
* Add prettier * Cleanup .gitignore * Cleanup * Fix long form of command line option not working
1 parent 8ee257b commit 9c84789

File tree

5 files changed

+64
-31
lines changed

5 files changed

+64
-31
lines changed

.gitignore

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1 @@
1-
.cache
2-
3-
dist
4-
5-
build
6-
7-
node_modules
1+
node_modules/

.prettierrc.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"arrowParens": "avoid"
3+
}

index.js

Lines changed: 31 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
11
#!/usr/bin/env node
2-
const path = require("path"),
3-
fs = require("fs"),
4-
{ execSync } = require("child_process"),
5-
colors = require("colors");
2+
const path = require("path");
3+
const fs = require("fs");
4+
const { execSync } = require("child_process");
65

7-
let projectName = process.argv[2],
8-
projectType = process.argv[3];
6+
require("colors");
7+
8+
const projectName = process.argv[2];
9+
const projectType = process.argv[3];
910

1011
const currentPath = process.cwd(),
1112
projectPath = path.join(currentPath, projectName);
1213

1314
const basicRepo =
14-
"https://github.com/rescript-lang/rescript-project-template.git",
15-
defaultRepo = "https://github.com/mahezsh/rescript-template-default.git",
16-
nextJsRepo = "https://github.com/ryyppy/rescript-nextjs-template.git",
17-
graphqlRepo = "https://github.com/mahezsh/rescript-template-graphql.git",
18-
sbRepo = "https://github.com/mahezsh/rescript-template-storybook.git";
15+
"https://github.com/rescript-lang/rescript-project-template.git";
16+
const defaultRepo = "https://github.com/mahezsh/rescript-template-default.git";
17+
const nextJsRepo = "https://github.com/ryyppy/rescript-nextjs-template.git";
18+
const graphqlRepo = "https://github.com/mahezsh/rescript-template-graphql.git";
19+
const sbRepo = "https://github.com/mahezsh/rescript-template-storybook.git";
1920

2021
try {
2122
fs.mkdirSync(projectPath);
@@ -32,33 +33,40 @@ try {
3233
process.exit(1);
3334
}
3435

35-
async function main() {
36+
function main() {
3637
try {
37-
let repoUrl = defaultRepo,
38-
templateName = "default";
38+
let repoUrl;
39+
let templateName;
3940

4041
switch (projectType) {
41-
case "-b" || "--basic":
42+
case "-b":
43+
case "--basic":
4244
repoUrl = basicRepo;
4345
templateName = "basic";
4446
break;
45-
case "-d" || "--default" || undefined:
46-
repoUrl = defaultRepo;
47-
templateName = "default";
48-
break;
49-
case "-nx" || "--nextjs":
47+
case "-nx":
48+
case "--nextjs":
5049
repoUrl = nextJsRepo;
5150
templateName = "nextJS";
5251
break;
53-
case "-gql" || "--graphql":
52+
case "-gql":
53+
case "--graphql":
5454
repoUrl = graphqlRepo;
5555
templateName = "graphQL";
5656
break;
57-
case "-sb" || "--storybook":
57+
case "-sb":
58+
case "--storybook":
5859
repoUrl = sbRepo;
5960
templateName = "storybook";
6061
break;
62+
case "-d":
63+
case "--default":
64+
default:
65+
repoUrl = defaultRepo;
66+
templateName = "default";
67+
break;
6168
}
69+
6270
console.log(
6371
`\nCreating a new Rescript app in`,
6472
`${projectPath}`.green,
@@ -78,7 +86,7 @@ async function main() {
7886
}
7987
}
8088

81-
async function houseKeeping() {
89+
function houseKeeping() {
8290
console.log("\nInstalling packages. This might take a couple of seconds.");
8391

8492
execSync("npm install");

package-lock.json

Lines changed: 24 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
"description": "Create ReScript apps with no build configuration.",
55
"main": "index.js",
66
"scripts": {
7-
"start": "node index.js"
7+
"start": "node index.js",
8+
"format": "prettier --write ."
89
},
910
"author": "",
1011
"license": "ISC",
@@ -27,5 +28,8 @@
2728
],
2829
"bin": {
2930
"create-rescript-app": "index.js"
31+
},
32+
"devDependencies": {
33+
"prettier": "^2.7.1"
3034
}
3135
}

0 commit comments

Comments
 (0)