Skip to content

Commit

Permalink
other: 🔹 setup playground
Browse files Browse the repository at this point in the history
  • Loading branch information
Ubugeeei committed Aug 12, 2023
1 parent 0709740 commit 1fd63dc
Show file tree
Hide file tree
Showing 13 changed files with 508 additions and 0 deletions.
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"deduped",
"deindent",
"estree",
"nocheck",
"RAWTEXT",
"RCDATA",
"unref",
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"scripts": {
"setup": "pnpm i && ts-node --esm tools/create-chibivue/main.ts",
"dev": "cd example/playground && pnpm i && pnpm run dev",
"dev:setup": "ts-node --esm tools/chibivue-playground/main.ts",
"dev:app": "cd example/app && pnpm i && pnpm run dev",
"test": "vitest",
"prepare": "husky install",
Expand Down
40 changes: 40 additions & 0 deletions tools/chibivue-playground/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import fs from "fs";
import fse from "fs-extra";

const red = (s: string) => `\x1b[31m${s}\x1b[0m`;
const green = (s: string) => `\x1b[32m${s}\x1b[0m`;
const blue = (s: string) => `\x1b[34m${s}\x1b[0m`;

const targetDirPath = 'example/playground'

// check if target path is empty
if (!targetDirPath) {
console.log("Please specify the target path!");
process.exit(1);
}

// check if target path exists. auto create if not
if (fs.existsSync(targetDirPath)) {
const files = fs.readdirSync(targetDirPath);
if (files.length) {
console.log("");
console.log(`${red("Oops!")} Target directory is not empty!`);
console.log("");
process.exit(1);
}
} else {
fs.mkdirSync(targetDirPath, { recursive: true });
}

// copy template files
const templateDirPath = `tools/chibivue-playground/template`;
fse.copySync(templateDirPath, targetDirPath);

// message
console.log("");
console.log("----------------------------------------------------------");
console.log(
`${green("chibivue project created!")} ${blue(">>>")} ${targetDirPath}`
);
console.log(`Enjoy your learning! 😎`);
console.log("----------------------------------------------------------");
12 changes: 12 additions & 0 deletions tools/chibivue-playground/template/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
</head>

<body>
<div id="app"></div>
<script type="module" src="src/main.ts"></script>
</body>
</html>
15 changes: 15 additions & 0 deletions tools/chibivue-playground/template/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "chibi-vue",
"version": "1.0.0",
"type": "module",
"scripts": {
"dev": "vite"
},
"author": "Ubugeeei <[email protected]>",
"devDependencies": {
"vite": "^3.0.9"
},
"volta": {
"node": "18.14.0"
}
}
Loading

0 comments on commit 1fd63dc

Please sign in to comment.