create-minista 4.0.3 → 4.0.5
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 +4 -4
- package/package.json +3 -3
- package/src/index.js +47 -10
- package/templates/minimal-js/_gitignore +6 -0
- package/templates/minimal-js/package.json +16 -0
- package/templates/minimal-js/src/pages/index.jsx +7 -0
- package/templates/minimal-js/vite.config.js +5 -0
- package/templates/minimal-ts/_gitignore +6 -0
- package/templates/minimal-ts/package.json +20 -0
- package/templates/minimal-ts/src/pages/index.tsx +7 -0
- package/templates/minimal-ts/tsconfig.json +14 -0
- package/templates/minimal-ts/vite.config.ts +5 -0
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
## About
|
|
4
4
|
|
|
5
|
-
簡単なコマンド入力で
|
|
5
|
+
簡単なコマンド入力で[minista](https://minista.qranoko.jp/)のプロジェクトを開始できます。
|
|
6
6
|
|
|
7
7
|
## How To Use
|
|
8
8
|
|
|
@@ -14,10 +14,10 @@ $ npm create minista@latest
|
|
|
14
14
|
$ npm create minista@latest my-minista-project -- --template minimal-ts
|
|
15
15
|
```
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
|テンプレート|内容 |
|
|
18
18
|
| ------------ | ------------------------------- |
|
|
19
|
-
| `minimal-js` | JavaScript
|
|
20
|
-
| `minimal-ts` | TypeScript
|
|
19
|
+
| `minimal-js` | JavaScriptを使った最低限の構成|
|
|
20
|
+
| `minimal-ts` | TypeScriptを使った最低限の構成|
|
|
21
21
|
|
|
22
22
|
## License
|
|
23
23
|
|
package/package.json
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-minista",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.5",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"bin": {
|
|
6
6
|
"create-minista": "./bin/create-minista.js"
|
|
7
7
|
},
|
|
8
8
|
"files": [
|
|
9
9
|
"bin",
|
|
10
|
-
"src"
|
|
10
|
+
"src",
|
|
11
|
+
"templates"
|
|
11
12
|
],
|
|
12
13
|
"license": "MIT",
|
|
13
14
|
"homepage": "https://minista.qranoko.jp",
|
|
@@ -31,7 +32,6 @@
|
|
|
31
32
|
},
|
|
32
33
|
"dependencies": {
|
|
33
34
|
"cac": "^7.0.0",
|
|
34
|
-
"degit": "^2.8.4",
|
|
35
35
|
"picocolors": "^1.1.1",
|
|
36
36
|
"prompts": "^2.4.2"
|
|
37
37
|
}
|
package/src/index.js
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* @typedef {Object} CliOptions
|
|
4
4
|
* @property {string} [template]
|
|
5
|
-
* @property {string} [tag]
|
|
6
5
|
*/
|
|
7
6
|
|
|
8
7
|
import fs from "node:fs"
|
|
@@ -10,7 +9,6 @@ import path from "node:path"
|
|
|
10
9
|
import pc from "picocolors"
|
|
11
10
|
import { cac } from "cac"
|
|
12
11
|
import prompts from "prompts"
|
|
13
|
-
import degit from "degit"
|
|
14
12
|
|
|
15
13
|
/** @type {{ title: string, value: string }[]} */
|
|
16
14
|
const TEMPLATES = [
|
|
@@ -34,11 +32,39 @@ function mkdirp(dir) {
|
|
|
34
32
|
try {
|
|
35
33
|
fs.mkdirSync(dir, { recursive: true })
|
|
36
34
|
} catch (e) {
|
|
37
|
-
if (e.code === "EEXIST") return
|
|
35
|
+
if (e instanceof Error && "code" in e && e.code === "EEXIST") return
|
|
38
36
|
throw e
|
|
39
37
|
}
|
|
40
38
|
}
|
|
41
39
|
|
|
40
|
+
/**
|
|
41
|
+
* @param {string} template
|
|
42
|
+
*/
|
|
43
|
+
function resolveTemplateDir(template) {
|
|
44
|
+
const templatesDir = new URL("../templates/", import.meta.url)
|
|
45
|
+
const templateDir = new URL(`${template}/`, templatesDir)
|
|
46
|
+
return templateDir
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* @param {string} template
|
|
51
|
+
* @returns {boolean}
|
|
52
|
+
*/
|
|
53
|
+
function hasTemplate(template) {
|
|
54
|
+
return TEMPLATES.some((item) => item.value === template)
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* @param {string} dir
|
|
59
|
+
*/
|
|
60
|
+
async function renameGitignore(dir) {
|
|
61
|
+
const from = path.resolve(dir, "_gitignore")
|
|
62
|
+
const to = path.resolve(dir, ".gitignore")
|
|
63
|
+
if (fs.existsSync(from)) {
|
|
64
|
+
await fs.promises.rename(from, to)
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
42
68
|
/**
|
|
43
69
|
* @param {string} root
|
|
44
70
|
* @param {CliOptions} options
|
|
@@ -48,9 +74,7 @@ async function main(root, options) {
|
|
|
48
74
|
|
|
49
75
|
const cwd = root || "."
|
|
50
76
|
const current = cwd === "."
|
|
51
|
-
const repo = "qrac/minista/packages/create-minista/templates"
|
|
52
77
|
const template = options.template || ""
|
|
53
|
-
const tag = options.tag ? "#" + options.tag : ""
|
|
54
78
|
|
|
55
79
|
/** @type {{ [key: string]: PromptObject }} */
|
|
56
80
|
const questions = {
|
|
@@ -82,14 +106,28 @@ async function main(root, options) {
|
|
|
82
106
|
? { template }
|
|
83
107
|
: /** @type {{ template: string }} */ (await prompts(questions.template))
|
|
84
108
|
|
|
85
|
-
|
|
86
|
-
|
|
109
|
+
if (!hasTemplate(configs.template)) {
|
|
110
|
+
console.error(pc.red(`Unknown template: ${configs.template}`))
|
|
111
|
+
console.error(
|
|
112
|
+
pc.gray(`Available templates: ${TEMPLATES.map((item) => item.value).join(", ")}`),
|
|
113
|
+
)
|
|
114
|
+
process.exit(1)
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
const templateDir = resolveTemplateDir(configs.template)
|
|
87
118
|
|
|
88
119
|
try {
|
|
89
120
|
console.log(`${pc.green(">")} ${pc.gray("Copying project files...")}`)
|
|
90
|
-
await
|
|
121
|
+
await fs.promises.cp(templateDir, cwd, {
|
|
122
|
+
recursive: true,
|
|
123
|
+
force: true,
|
|
124
|
+
errorOnExist: false,
|
|
125
|
+
})
|
|
126
|
+
await renameGitignore(cwd)
|
|
91
127
|
} catch (err) {
|
|
92
|
-
console.error(
|
|
128
|
+
console.error(
|
|
129
|
+
pc.red(err instanceof Error && err.message ? err.message : String(err)),
|
|
130
|
+
)
|
|
93
131
|
process.exit(1)
|
|
94
132
|
}
|
|
95
133
|
|
|
@@ -113,7 +151,6 @@ const cli = cac("create-minista")
|
|
|
113
151
|
cli
|
|
114
152
|
.command("[root]", "Scaffolding for minista projects")
|
|
115
153
|
.option("--template <template>", "[string] template directory")
|
|
116
|
-
.option("--tag <tag>", "[string] branch | tag | hash")
|
|
117
154
|
.action(async (root, options) => {
|
|
118
155
|
try {
|
|
119
156
|
await main(root, options)
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "minista-project",
|
|
3
|
+
"private": true,
|
|
4
|
+
"type": "module",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"dev": "minista",
|
|
7
|
+
"build": "minista build",
|
|
8
|
+
"preview": "minista preview"
|
|
9
|
+
},
|
|
10
|
+
"devDependencies": {
|
|
11
|
+
"minista": "^4.0.5",
|
|
12
|
+
"react": "^19.2.5",
|
|
13
|
+
"react-dom": "^19.2.5",
|
|
14
|
+
"vite": "^8.0.10"
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "minista-project",
|
|
3
|
+
"private": true,
|
|
4
|
+
"type": "module",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"dev": "minista",
|
|
7
|
+
"build": "minista build",
|
|
8
|
+
"preview": "minista preview"
|
|
9
|
+
},
|
|
10
|
+
"devDependencies": {
|
|
11
|
+
"@types/node": "^25.6.0",
|
|
12
|
+
"@types/react": "^19.2.14",
|
|
13
|
+
"@types/react-dom": "^19.2.3",
|
|
14
|
+
"minista": "^4.0.5",
|
|
15
|
+
"react": "^19.2.5",
|
|
16
|
+
"react-dom": "^19.2.5",
|
|
17
|
+
"typescript": "^6.0.3",
|
|
18
|
+
"vite": "^8.0.10"
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "esnext",
|
|
4
|
+
"module": "esnext",
|
|
5
|
+
"moduleResolution": "bundler",
|
|
6
|
+
"resolveJsonModule": true,
|
|
7
|
+
"allowSyntheticDefaultImports": true,
|
|
8
|
+
"skipLibCheck": true,
|
|
9
|
+
"noErrorTruncation": true,
|
|
10
|
+
"jsx": "react-jsx",
|
|
11
|
+
"types": ["minista/client"]
|
|
12
|
+
},
|
|
13
|
+
"exclude": ["node_modules", "dist"]
|
|
14
|
+
}
|