@justinli/create-vite-template 0.1.1 → 0.1.2

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.
package/README.md CHANGED
@@ -1,14 +1,15 @@
1
- # Create Vite Template
2
-
3
- This template provides a minimal setup for a static site using:
4
- - React
5
- - TypeScript
6
- - Vite
7
- - Oxlint
8
- - Oxfmt
9
-
10
- ## Usage
11
-
12
- ```
13
- pnpm create @justinli/vite-template my-app
14
- ```
1
+ # Create Vite Template
2
+
3
+ This template provides a minimal setup for a static site using:
4
+
5
+ - React
6
+ - TypeScript
7
+ - Vite
8
+ - Oxlint
9
+ - Oxfmt
10
+
11
+ ## Usage
12
+
13
+ ```
14
+ pnpm create @justinli/vite-template my-app
15
+ ```
package/index.js CHANGED
@@ -1,16 +1,27 @@
1
- #!/usr/bin/env node
2
- import { cpSync, existsSync } from "node:fs";
3
- import { resolve } from "node:path";
4
- import { fileURLToPath } from "node:url";
5
-
1
+ #!/usr/bin/env node
2
+ import { cp, readFile, writeFile, rename, access } from "node:fs/promises";
3
+ import { resolve } from "node:path";
4
+ import { fileURLToPath } from "node:url";
5
+
6
6
  const target = process.argv[2] ?? "my-app";
7
7
  const from = fileURLToPath(new URL("./template", import.meta.url));
8
8
  const to = resolve(process.cwd(), target);
9
-
10
- if (existsSync(to)) {
11
- console.error(`Target already exists: ${to}`);
12
- process.exit(1);
13
- }
14
-
15
- cpSync(from, to, { recursive: true });
16
- console.log(`Created ${target}`);
9
+
10
+ try {
11
+ await access(to);
12
+ console.error(`Target already exists: ${to}`);
13
+ process.exit(1);
14
+ } catch (e) {
15
+ if (e.code !== "ENOENT") throw e;
16
+ }
17
+
18
+ await cp(from, to, { recursive: true });
19
+
20
+ const pkgPath = resolve(to, "package.json");
21
+ const pkg = await readFile(pkgPath, "utf8");
22
+ await writeFile(pkgPath, pkg.replace(/vite-template/, target));
23
+
24
+ const gitignore = resolve(to, "_gitignore");
25
+ await rename(gitignore, resolve(to, ".gitignore"));
26
+
27
+ console.log(`Created ${target}`);
package/package.json CHANGED
@@ -1,16 +1,21 @@
1
- {
2
- "name": "@justinli/create-vite-template",
3
- "version": "0.1.1",
4
- "private": false,
5
- "type": "module",
6
- "bin": {
7
- "create-vite-template": "index.js"
8
- },
9
- "files": ["index.js", "template"],
10
- "publishConfig": { "access": "public" },
11
- "license": "MIT",
12
- "repository": {
13
- "type": "git",
14
- "url": "git+https://github.com/justinli34/create-vite-template.git"
15
- }
16
- }
1
+ {
2
+ "name": "@justinli/create-vite-template",
3
+ "version": "0.1.2",
4
+ "private": false,
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/justinli34/create-vite-template.git"
9
+ },
10
+ "bin": {
11
+ "create-vite-template": "index.js"
12
+ },
13
+ "files": [
14
+ "index.js",
15
+ "template"
16
+ ],
17
+ "type": "module",
18
+ "publishConfig": {
19
+ "access": "public"
20
+ }
21
+ }
@@ -0,0 +1,3 @@
1
+ node_modules/
2
+ dist/
3
+ .env