@justinli/create-vite-template 0.1.1 → 0.1.3
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 +42 -14
- package/index.js +35 -13
- package/package.json +21 -16
- package/template/_gitignore +3 -0
- package/template/index.html +1 -1
- package/template/package.json +2 -1
- package/template/src/App.tsx +1 -1
- package/template/pnpm-lock.yaml +0 -1380
package/README.md
CHANGED
|
@@ -1,14 +1,42 @@
|
|
|
1
|
-
# Create Vite Template
|
|
2
|
-
|
|
3
|
-
This template provides a minimal setup for a static site using:
|
|
4
|
-
|
|
5
|
-
-
|
|
6
|
-
-
|
|
7
|
-
-
|
|
8
|
-
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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
|
+
## Prerequisites
|
|
12
|
+
- Node.js
|
|
13
|
+
- pnpm
|
|
14
|
+
|
|
15
|
+
## Usage
|
|
16
|
+
|
|
17
|
+
Create a project in a new directory:
|
|
18
|
+
```
|
|
19
|
+
pnpm create @justinli/vite-template my-app
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Create a project in the current (empty) directory:
|
|
23
|
+
```
|
|
24
|
+
pnpm create @justinli/vite-template .
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
cd into the project directory, install dependencies, and start the development server:
|
|
28
|
+
```
|
|
29
|
+
cd my-app
|
|
30
|
+
pnpm install
|
|
31
|
+
pnpm dev
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Scripts
|
|
35
|
+
- `pnpm dev`: Start the development server
|
|
36
|
+
- `pnpm build`: Build for production
|
|
37
|
+
- `pnpm preview`: Preview the production build locally
|
|
38
|
+
- `pnpm lint`: Run Oxlint to check for linting errors
|
|
39
|
+
- `pnpm lint:fix`: Run Oxlint to fix linting errors
|
|
40
|
+
- `pnpm fmt`: Run Oxfmt to format code
|
|
41
|
+
- `pnpm fmt:check`: Run Oxfmt to check if code is formatted
|
|
42
|
+
- `pnpm check`: Run TypeScript, Oxlint, and Oxfmt checks
|
package/index.js
CHANGED
|
@@ -1,16 +1,38 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
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, readdir } from "node:fs/promises";
|
|
3
|
+
import { resolve, basename } from "node:path";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
|
|
6
6
|
const target = process.argv[2] ?? "my-app";
|
|
7
|
+
const targetName = target === "." ? basename(process.cwd()) : target;
|
|
7
8
|
const from = fileURLToPath(new URL("./template", import.meta.url));
|
|
8
9
|
const to = resolve(process.cwd(), target);
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
10
|
+
|
|
11
|
+
try {
|
|
12
|
+
await access(to);
|
|
13
|
+
const entries = await readdir(to);
|
|
14
|
+
if (entries.length > 0) {
|
|
15
|
+
console.error(`Failed to create. Target directory is not empty: ${to}`);
|
|
16
|
+
process.exit(1);
|
|
17
|
+
}
|
|
18
|
+
} catch (e) {
|
|
19
|
+
if (e.code !== "ENOENT") throw e;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
await cp(from, to, { recursive: true });
|
|
23
|
+
|
|
24
|
+
const files = [
|
|
25
|
+
resolve(to, "package.json"),
|
|
26
|
+
resolve(to, "index.html"),
|
|
27
|
+
resolve(to, "src/App.tsx"),
|
|
28
|
+
]
|
|
29
|
+
|
|
30
|
+
for (const file of files) {
|
|
31
|
+
const content = await readFile(file, "utf8");
|
|
32
|
+
await writeFile(file, content.replace(/vite-template/g, targetName));
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const gitignore = resolve(to, "_gitignore");
|
|
36
|
+
await rename(gitignore, resolve(to, ".gitignore"));
|
|
37
|
+
|
|
38
|
+
console.log(`Created ${targetName}`);
|
package/package.json
CHANGED
|
@@ -1,16 +1,21 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@justinli/create-vite-template",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"private": false,
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
"
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
"
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "@justinli/create-vite-template",
|
|
3
|
+
"version": "0.1.3",
|
|
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
|
+
}
|
package/template/index.html
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
<meta charset="UTF-8" />
|
|
5
5
|
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
|
6
6
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
|
-
<title>
|
|
7
|
+
<title>vite-template</title>
|
|
8
8
|
</head>
|
|
9
9
|
<body>
|
|
10
10
|
<div id="root"></div>
|
package/template/package.json
CHANGED