Skip to content

Commit

Permalink
Merge pull request #5 from neghi14/main
Browse files Browse the repository at this point in the history
Updated Rezact CLI app.
  • Loading branch information
zachlankton authored Oct 23, 2023
2 parents fbd26c3 + e1eb725 commit 56f47d7
Show file tree
Hide file tree
Showing 51 changed files with 11,822 additions and 96 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
### Usage

```bash
npm create @rezact/app@latest my-rezact-project
npm create @rezact/app@latest
cd my-rezact-project
npm install
npm run dev
Expand Down
Empty file removed helpers/copy.ts
Empty file.
102 changes: 79 additions & 23 deletions index.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,70 @@
#!/usr/bin/env node

import { green } from "picocolors";
import colors from "picocolors";
import packageJson from "./package.json";
import Commander from "commander";
import { Command } from "commander";
import path from "path";
import { fileURLToPath } from "url";
import { cwd, argv } from "process";
import fs from "fs";
import fse from "fs-extra";
import { checkDirEmpty, checkDirExits } from "./helpers/check-dir";
import { splitDir } from "./helpers/split-dir";
import fs from "fs-extra";
import { checkDirEmpty, checkDirExits } from "./helpers/check-dir.js";
import { splitDir } from "./helpers/split-dir.js";
import { select, input } from "@inquirer/prompts";

let projectPath: string = "";

const handleExit = () => process.exit(1);
// const program = new Command(packageJson.name)
// .version(packageJson.version)
// .usage(`${colors.green("<project-directory>")} [options]`)
// .description("Command line utility used for creating new Rezact project")
// .argument("<project-directory>")
// .option("-ts --typescript", "Use Typescript")
// .option("-tw --tailwind", "Use tailwind as default styling")
// .parse(argv);

process.on("SIGTERM", handleExit);
process.on("SIGINT", handleExit);
// const options = program.opts();
// //choose flavor
// console.log(options);
//choose if tailwind or not

const program = new Commander.Command(packageJson.name)
.version(packageJson.version)
.usage(`${green("<project-directory>")} [options]`)
.description("Command line utility used for creating new Rezact project")
.argument("<project-directory>")
.parse(argv);
console.log("Welcome, Quickly scaffold a rezact Project");
console.log();

const directory = await input({
message: "Project name?",
default: "my-app",
});

projectPath = path.resolve(cwd(), argv[2]);
const typescript = await select({
message: "Use Typescript?",
choices: [
{
name: "Yes",
value: true,
},
{
name: "No",
value: false,
},
],
});
const tailwind = await select({
message: "Use Tailwind CSS?",
choices: [
{
name: "Yes",
value: true,
},
{
name: "No",
value: false,
},
],
});
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);

projectPath = path.resolve(cwd(), directory);

// copy folder from template to new folder
console.log("Creating New Rezact Project...");
Expand Down Expand Up @@ -54,7 +94,14 @@ if (dirExist) {
}

const templateDir = path.join(__dirname, "templates");
fse.copySync(`${templateDir}/default`, projectPath);
fs.copySync(
`${templateDir}/${
typescript
? `${tailwind ? "tw-ts" : "default-ts"}`
: `${tailwind ? "tw" : "default"}`
}`,
projectPath
);

const projectName = splitDir(projectPath);

Expand All @@ -66,13 +113,24 @@ const JsonPackage = `{
"type": "module",
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"build": ${typescript ? `"tsc && vite build"` : `"vite build"`},
"preview": "vite preview"
},
"devDependencies": {
"typescript": "*",
${
tailwind
? `"devDependencies": {
${typescript ? `"typescript": "*",` : ""}
"autoprefixer": "^10.4.16",
"postcss": "^8.4.31",
"tailwindcss": "latest",
"vite": "latest"
},
},`
: `"devDependencies": {
${typescript ? ` "typescript": "*",` : ""}
"vite": "latest"
},`
}
"dependencies": {
"@rezact/rezact": "latest"
}
Expand All @@ -88,5 +146,3 @@ console.log();
console.log("npm install");
console.log();
console.log("npm run dev");

//process.exit(0);
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "@rezact/create-app",
"version": "1.0.9",
"version": "1.1.0",
"type": "module",
"description": "Quickly Scaffold a Rezact App",
"main": "index.js",
"scripts": {
Expand All @@ -18,6 +19,7 @@
"typescript": "^5.2.2"
},
"dependencies": {
"@inquirer/prompts": "^3.2.0",
"commander": "^11.0.0",
"fs-extra": "^11.1.1",
"picocolors": "^1.0.0"
Expand Down
Loading

0 comments on commit 56f47d7

Please sign in to comment.