Skip to content

Commit 0d26dd8

Browse files
committed
init
0 parents  commit 0d26dd8

File tree

5 files changed

+88
-0
lines changed

5 files changed

+88
-0
lines changed

.gitignore

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

Readme.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# create-rescript-app
2+
3+
Create ReScript apps with no build configuration.
4+

index.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<html>
2+
<body>
3+
<div>create-rescript-app</div>
4+
<script src="index.js"></script>
5+
</body>
6+
</html>

index.js

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/usr/bin/env node
2+
const path = require("path");
3+
let fs = require("fs");
4+
const { execSync } = require("child_process");
5+
let colors = require("colors");
6+
7+
let projectName = process.argv[2];
8+
const currentPath = process.cwd();
9+
const projectPath = path.join(currentPath, projectName);
10+
const git_repo =
11+
"https://github.com/rescript-lang/rescript-project-template.git";
12+
13+
try {
14+
fs.mkdirSync(projectPath);
15+
} catch (err) {
16+
if (err.code === "EEXIST") {
17+
console.log(
18+
`The folder`,
19+
`${projectName}`.red,
20+
`already exist in the current directory, please give it another name.`
21+
);
22+
} else {
23+
console.log(error);
24+
}
25+
process.exit(1);
26+
}
27+
28+
async function main() {
29+
try {
30+
console.log(`Creating a new Rescript app in`, `${projectPath}\n`.green);
31+
execSync(`git clone --depth 1 ${git_repo} ${projectPath}`);
32+
process.chdir(projectPath);
33+
console.log("\nInstalling packages. This might take a couple of seconds.");
34+
execSync("npm install");
35+
execSync(`find . | grep "\.git/" | xargs rm -rf`);
36+
execSync("git init");
37+
console.log(`\nInitialized a git repository.`);
38+
console.log(
39+
`\nSuccess!`.green,
40+
`Created ${projectName} at `,
41+
`${projectPath}`.green
42+
);
43+
console.log(`\nHappy hacking!\n`);
44+
} catch (error) {
45+
console.log(error);
46+
}
47+
}
48+
main();

package.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"name": "create-rescript-app",
3+
"version": "1.0.0",
4+
"description": "Create ReScript apps with no build configuration.",
5+
"main": "index.js",
6+
"scripts": {
7+
"start": "parcel index.html",
8+
"build": "parcel build index.js",
9+
"test": "echo \"Error: no test specified\" && exit 1"
10+
},
11+
"author": "",
12+
"license": "ISC",
13+
"dependencies": {
14+
"colors": "^1.4.0",
15+
"shelljs": "^0.8.4"
16+
},
17+
"devDependencies": {
18+
"parcel-bundler": "^1.12.5"
19+
},
20+
"bin": {
21+
"create-rescript-app": "index.js"
22+
}
23+
}

0 commit comments

Comments
 (0)