@m4vi/create-vrt-tmp 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.js +52 -1
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -1 +1,52 @@
1
- import fs from"fs";import path from"path";import{fileURLToPath}from"url";import{execSync}from"child_process";const __filename=fileURLToPath(import.meta.url),__dirname=path.dirname(__filename),projectName=process.argv[2]||"vrt-app",targetDir=path.join(process.cwd(),projectName);if(fs.existsSync(targetDir)){console.error(`Directory ${projectName} already exists`);process.exit(1)}const templateDir=path.join(__dirname,"template");fs.mkdirSync(targetDir,{recursive:!0});function copyDir(src,dest){fs.mkdirSync(dest,{recursive:!0});const files=fs.readdirSync(src);files.forEach((file)=>{const srcPath=path.join(src,file),destPath=path.join(dest,file);fs.statSync(srcPath).isDirectory()?copyDir(srcPath,destPath):fs.copyFileSync(srcPath,destPath)})}copyDir(templateDir,targetDir);process.chdir(targetDir);console.log(`\nCreating project in ${targetDir}\n`);try{console.log("Installing dependencies...\n");execSync("npm install",{stdio:"inherit"});console.log(`\nProject created successfully!\n`);console.log(`To start developing:\n`);console.log(` cd ${projectName}`);console.log(` npm run dev\n`)}catch(error){console.error("Failed to install dependencies",error);process.exit(1)}
1
+ #!/usr/bin/env node
2
+
3
+ import fs from "fs";
4
+ import path from "path";
5
+ import { fileURLToPath } from "url";
6
+ import { execSync } from "child_process";
7
+
8
+ const __filename = fileURLToPath(import.meta.url);
9
+ const __dirname = path.dirname(__filename);
10
+
11
+ const projectName = process.argv[2] || "vrt-app";
12
+ const targetDir = path.join(process.cwd(), projectName);
13
+
14
+ if (fs.existsSync(targetDir)) {
15
+ console.error(`Directory ${projectName} already exists`);
16
+ process.exit(1);
17
+ }
18
+
19
+ const templateDir = path.join(__dirname, "template");
20
+
21
+ fs.mkdirSync(targetDir, { recursive: true });
22
+
23
+ function copyDir(src, dest) {
24
+ fs.mkdirSync(dest, { recursive: true });
25
+ const files = fs.readdirSync(src);
26
+ files.forEach((file) => {
27
+ const srcPath = path.join(src, file);
28
+ const destPath = path.join(dest, file);
29
+ if (fs.statSync(srcPath).isDirectory()) {
30
+ copyDir(srcPath, destPath);
31
+ } else {
32
+ fs.copyFileSync(srcPath, destPath);
33
+ }
34
+ });
35
+ }
36
+
37
+ copyDir(templateDir, targetDir);
38
+ process.chdir(targetDir);
39
+
40
+ console.log(`\nCreating project in ${targetDir}\n`);
41
+
42
+ try {
43
+ console.log("Installing dependencies...\n");
44
+ execSync("npm install", { stdio: "inherit" });
45
+ console.log(`\nProject created successfully!\n`);
46
+ console.log(`To start developing:\n`);
47
+ console.log(` cd ${projectName}`);
48
+ console.log(` npm run dev\n`);
49
+ } catch (error) {
50
+ console.error("Failed to install dependencies", error);
51
+ process.exit(1);
52
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@m4vi/create-vrt-tmp",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Vite, React, and Tailwind CSS --template",
5
5
  "type": "module",
6
6
  "license": "MIT",