create-rescript-app
Advanced tools
Comparing version 1.0.1 to 1.1.0
66
index.js
@@ -8,6 +8,12 @@ #!/usr/bin/env node | ||
let projectName = process.argv[2]; | ||
let projectType = process.argv[3]; | ||
const currentPath = process.cwd(); | ||
const projectPath = path.join(currentPath, projectName); | ||
const git_repo = | ||
const basicRepo = | ||
"https://github.com/rescript-lang/rescript-project-template.git"; | ||
const defaultRepo = "https://github.com/mahezsh/rescript-template-default.git"; | ||
const nextJsRepo = "https://github.com/ryyppy/rescript-nextjs-template.git"; | ||
const graphqlRepo = "https://github.com/mahezsh/rescript-template-graphql.git"; | ||
const sbRepo = "https://github.com/mahezsh/rescript-template-storybook.git"; | ||
@@ -31,15 +37,37 @@ try { | ||
try { | ||
console.log(`Creating a new Rescript app in`, `${projectPath}\n`.green); | ||
execSync(`git clone --depth 1 ${git_repo} ${projectPath}`); | ||
process.chdir(projectPath); | ||
console.log("\nInstalling packages. This might take a couple of seconds."); | ||
execSync("npm install"); | ||
execSync(`find . | grep "\.git/" | xargs rm -rf`); | ||
execSync("git init"); | ||
console.log(`\nInitialized a git repository.`); | ||
let repoUrl = basicRepo; | ||
let templateName = "default"; | ||
switch (projectType) { | ||
case "-b" || "--basic": | ||
repoUrl = basicRepo; | ||
templateName = "basic"; | ||
break; | ||
case "-d" || "--default" || undefined: | ||
repoUrl = defaultRepo; | ||
templateName = "default"; | ||
break; | ||
case "-nx" || "--nextjs": | ||
repoUrl = nextJsRepo; | ||
templateName = "nextJS"; | ||
break; | ||
case "-gql" || "--graphql": | ||
repoUrl = graphqlRepo; | ||
templateName = "graphQL"; | ||
break; | ||
case "-sb" || "--storybook": | ||
repoUrl = sbRepo; | ||
templateName = "storybook"; | ||
break; | ||
} | ||
console.log( | ||
`\nSuccess!`.green, | ||
`Created ${projectName} at `, | ||
`${projectPath}`.green | ||
`\nCreating a new Rescript app in`, | ||
`${projectPath}`.green, | ||
`from`, | ||
`${templateName}`.blue, | ||
`template\n` | ||
); | ||
execSync(`git clone --depth 1 ${basicRepo} ${projectPath}`); | ||
process.chdir(projectPath); | ||
houseKeeping(); | ||
console.log(`\nHappy hacking!\n`); | ||
@@ -50,2 +78,16 @@ } catch (error) { | ||
} | ||
async function houseKeeping() { | ||
console.log("\nInstalling packages. This might take a couple of seconds."); | ||
execSync("npm install"); | ||
execSync(`find . | grep "\.git/" | xargs rm -rf`); | ||
execSync("git init"); | ||
console.log(`\nInitialized a git repository.`); | ||
console.log( | ||
`\nSuccess!`.green, | ||
`Created ${projectName} at`, | ||
`${projectPath}`.green | ||
); | ||
} | ||
main(); |
{ | ||
"name": "create-rescript-app", | ||
"version": "1.0.1", | ||
"version": "1.1.0", | ||
"description": "Create ReScript apps with no build configuration.", | ||
@@ -28,2 +28,8 @@ "main": "index.js", | ||
"homepage": "https://github.com/mahezsh/create-rescript-app#readme", | ||
"keywords": [ | ||
"rescript", | ||
"bootstrap rescript", | ||
"rescript app", | ||
"rescript start" | ||
], | ||
"bin": { | ||
@@ -30,0 +36,0 @@ "create-rescript-app": "index.js" |
@@ -5,1 +5,36 @@ # create-rescript-app | ||
## Quick Start | ||
```sh | ||
npx create-rescript-app my-app | ||
cd my-app | ||
npm start | ||
``` | ||
## Install options | ||
| Template | short cmd | long cmd | | ||
| :------------------------------- | :-------: | ----------: | | ||
| Basic | -b | --basic | | ||
| Default / CRA equivalent (React) | -d | --default | | ||
| NextJS | -nx | --nextjs | | ||
| GraphQL | -gql | --graphql | | ||
| Storybook | -sb | --storybook | | ||
### Bootstrap a ReScript app with Graphql | ||
```sh | ||
npx create-rescript-app my-app -gql | ||
``` | ||
### Bootstrap a ReScript app with Storybook | ||
```sh | ||
npx create-rescript-app my-app -sb | ||
``` | ||
### Bootstrap a NextJS app with ReScript | ||
```sh | ||
npx create-rescript-app my-app -nx | ||
``` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4331
83
40