create-minista 2.8.2 → 3.0.0-alpha.32
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 +6 -19
- package/bin/create-minista.js +4 -0
- package/dist/index.js +92 -105
- package/dist/types/index.d.ts +1 -2
- package/package.json +16 -23
- package/LICENSE +0 -21
- package/cli.mjs +0 -3
- package/dist/templates.js +0 -18
- package/dist/types/templates.d.ts +0 -4
package/README.md
CHANGED
|
@@ -20,29 +20,16 @@
|
|
|
20
20
|
|
|
21
21
|
```bash
|
|
22
22
|
# Interactive
|
|
23
|
-
$ npm
|
|
23
|
+
$ npm create minista@latest
|
|
24
24
|
|
|
25
25
|
# Shortcut
|
|
26
|
-
$ npm
|
|
26
|
+
$ npm create minista@latest my-minista-project -- --template minimal-ts
|
|
27
27
|
```
|
|
28
28
|
|
|
29
|
-
| テンプレート | 内容
|
|
30
|
-
| ------------ |
|
|
31
|
-
| `
|
|
32
|
-
| `
|
|
33
|
-
| `ts` | TypeScript を使った最低限の構成 |
|
|
34
|
-
| `js` | JavaScript を使った最低限の構成 |
|
|
35
|
-
|
|
36
|
-
```bash
|
|
37
|
-
# You can also use any GitHub repository
|
|
38
|
-
npm init minista my-minista-project -- --template qrac/minista-blog-with-rest-api
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
## Fork & Respect
|
|
42
|
-
|
|
43
|
-
- [astro/packages/create-astro at main · withastro/astro](https://github.com/withastro/astro/tree/main/packages/create-astro)
|
|
44
|
-
- [vite/packages/create-vite at main · vitejs/vite](https://github.com/vitejs/vite/tree/main/packages/create-vite)
|
|
45
|
-
- [vite/cli.ts at main · vitejs/vite](https://github.com/vitejs/vite/blob/main/packages/vite/src/node/cli.ts)
|
|
29
|
+
| テンプレート | 内容 |
|
|
30
|
+
| ------------ | ------------------------------- |
|
|
31
|
+
| `minimal-js` | JavaScript を使った最低限の構成 |
|
|
32
|
+
| `minimal-ts` | TypeScript を使った最低限の構成 |
|
|
46
33
|
|
|
47
34
|
## License
|
|
48
35
|
|
package/dist/index.js
CHANGED
|
@@ -1,112 +1,99 @@
|
|
|
1
|
-
import fs from "fs";
|
|
2
|
-
import path from "path";
|
|
3
|
-
import
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import pc from "picocolors";
|
|
4
|
+
import { cac } from "cac";
|
|
4
5
|
import prompts from "prompts";
|
|
5
6
|
import degit from "degit";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
return;
|
|
21
|
-
throw e;
|
|
22
|
-
}
|
|
7
|
+
const TEMPLATES = [
|
|
8
|
+
{
|
|
9
|
+
title: "Minimal (JavaScript)",
|
|
10
|
+
value: "minimal-js"
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
title: "Minimal (Typescript)",
|
|
14
|
+
value: "minimal-ts"
|
|
15
|
+
}
|
|
16
|
+
];
|
|
17
|
+
function pkgVersion() {
|
|
18
|
+
const pkgURL = new URL("../package.json", import.meta.url);
|
|
19
|
+
const pkg = JSON.parse(fs.readFileSync(pkgURL, "utf8"));
|
|
20
|
+
return pkg.version;
|
|
23
21
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
{
|
|
54
|
-
type: "select",
|
|
55
|
-
name: "template",
|
|
56
|
-
message: "Which template would you like to use?",
|
|
57
|
-
choices: TEMPLATES,
|
|
58
|
-
},
|
|
59
|
-
]);
|
|
60
|
-
if (!options.template) {
|
|
61
|
-
process.exit(1);
|
|
62
|
-
}
|
|
63
|
-
const projectName = options.projectName
|
|
64
|
-
? options.projectName
|
|
65
|
-
: defaultProjectName;
|
|
66
|
-
const hash = args.commit ? `#${args.commit}` : "";
|
|
67
|
-
const templateTarget = options.template.includes("/")
|
|
68
|
-
? options.template
|
|
69
|
-
: `${officialTemplatesPath}/${options.template}`;
|
|
70
|
-
const emitter = degit(`${templateTarget}${hash}`, {
|
|
71
|
-
cache: false,
|
|
72
|
-
force: true,
|
|
73
|
-
verbose: false,
|
|
74
|
-
});
|
|
75
|
-
try {
|
|
76
|
-
console.log(`${green(`>`)} ${gray(`Copying project files...`)}`);
|
|
77
|
-
await emitter.clone(cwd);
|
|
22
|
+
function mkdirp(dir) {
|
|
23
|
+
try {
|
|
24
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
25
|
+
} catch (e) {
|
|
26
|
+
if (e.code === "EEXIST")
|
|
27
|
+
return;
|
|
28
|
+
throw e;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
async function main(root, options) {
|
|
32
|
+
console.log(`
|
|
33
|
+
${pc.bold("create-minista")} ${pc.gray(`(v${pkgVersion()})`)}`);
|
|
34
|
+
const cwd = root || ".";
|
|
35
|
+
const current = cwd === ".";
|
|
36
|
+
const repo = "qrac/minista/packages/create-minista/templates";
|
|
37
|
+
const template = options.template || "";
|
|
38
|
+
const tag = options.tag ? "#" + options.tag : "";
|
|
39
|
+
const questions = {
|
|
40
|
+
overwrite: {
|
|
41
|
+
type: "confirm",
|
|
42
|
+
name: "overwrite",
|
|
43
|
+
message: "Directory not empty. Continue [force overwrite]?",
|
|
44
|
+
initial: false
|
|
45
|
+
},
|
|
46
|
+
template: {
|
|
47
|
+
type: "select",
|
|
48
|
+
name: "template",
|
|
49
|
+
message: "Which template would you like to use?",
|
|
50
|
+
choices: TEMPLATES
|
|
78
51
|
}
|
|
79
|
-
|
|
80
|
-
|
|
52
|
+
};
|
|
53
|
+
if (fs.existsSync(cwd)) {
|
|
54
|
+
if (fs.readdirSync(cwd).length > 0) {
|
|
55
|
+
const { overwrite } = await prompts(questions.overwrite);
|
|
56
|
+
if (!overwrite) {
|
|
81
57
|
process.exit(1);
|
|
58
|
+
}
|
|
59
|
+
!current && mkdirp(cwd);
|
|
82
60
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
console.log(` ${i++}: ${bold(cyan('git init && git add -A && git commit -m "Initial commit"'))} (optional step)`);
|
|
110
|
-
console.log(` ${i++}: ${bold(cyan("npm run dev"))} (or pnpm, yarn, etc)`);
|
|
111
|
-
console.log(`\nTo close the dev server, hit ${bold(cyan("Ctrl-C"))}`);
|
|
61
|
+
} else {
|
|
62
|
+
!current && mkdirp(cwd);
|
|
63
|
+
}
|
|
64
|
+
const configs = {
|
|
65
|
+
...template ? { template } : await prompts(questions.template)
|
|
66
|
+
};
|
|
67
|
+
const target = `${path.join(repo, configs.template)}${tag}`;
|
|
68
|
+
const emitter = degit(target, { cache: false, force: true, verbose: false });
|
|
69
|
+
try {
|
|
70
|
+
console.log(`${pc.green(`>`)} ${pc.gray(`Copying project files...`)}`);
|
|
71
|
+
await emitter.clone(cwd);
|
|
72
|
+
} catch (err) {
|
|
73
|
+
console.error(pc.red(err.message));
|
|
74
|
+
process.exit(1);
|
|
75
|
+
}
|
|
76
|
+
console.log(pc.bold(pc.green("\u2714") + " Done!"));
|
|
77
|
+
console.log("\nNext steps:");
|
|
78
|
+
let step = 1;
|
|
79
|
+
const relative = path.relative(process.cwd(), cwd);
|
|
80
|
+
if (relative !== "") {
|
|
81
|
+
console.log(` ${step++}: ${pc.bold(pc.cyan(`cd ${relative}`))}`);
|
|
82
|
+
}
|
|
83
|
+
console.log(` ${step++}: ${pc.bold(pc.cyan("npm install"))}`);
|
|
84
|
+
console.log(` ${step++}: ${pc.bold(pc.cyan("npm run dev"))}`);
|
|
85
|
+
console.log(`
|
|
86
|
+
To close the dev server, hit ${pc.bold(pc.cyan("Ctrl + C"))}`);
|
|
112
87
|
}
|
|
88
|
+
const cli = cac("create-minista");
|
|
89
|
+
cli.command("[root]", "Scaffolding for minista projects").option("--template <template>", "[string] template direcroty").option("--tag <tag>", "[string] branch | tag | hash").action(async (root, options) => {
|
|
90
|
+
try {
|
|
91
|
+
await main(root, options);
|
|
92
|
+
} catch (err) {
|
|
93
|
+
console.log(err);
|
|
94
|
+
process.exit(1);
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
cli.help();
|
|
98
|
+
cli.version(pkgVersion());
|
|
99
|
+
cli.parse();
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export
|
|
2
|
-
export declare function main(): Promise<void>;
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,23 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-minista",
|
|
3
3
|
"description": "Scaffolding for minista projects",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "3.0.0-alpha.32",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
7
|
-
"create-minista": "./
|
|
7
|
+
"create-minista": "./bin/create-minista.js"
|
|
8
8
|
},
|
|
9
9
|
"files": [
|
|
10
10
|
"dist",
|
|
11
11
|
"cli.js"
|
|
12
12
|
],
|
|
13
13
|
"license": "MIT",
|
|
14
|
-
"homepage": "https://
|
|
14
|
+
"homepage": "https://minista.qranoko.jp",
|
|
15
15
|
"repository": {
|
|
16
16
|
"type": "git",
|
|
17
|
-
"url": "https://github.com/qrac/
|
|
17
|
+
"url": "https://github.com/qrac/minista",
|
|
18
|
+
"directory": "packages/create-minista"
|
|
18
19
|
},
|
|
19
20
|
"bugs": {
|
|
20
|
-
"url": "https://github.com/qrac/
|
|
21
|
+
"url": "https://github.com/qrac/minista/issues"
|
|
21
22
|
},
|
|
22
23
|
"keywords": [
|
|
23
24
|
"static-site-generator",
|
|
@@ -27,7 +28,8 @@
|
|
|
27
28
|
"jsx",
|
|
28
29
|
"tsx",
|
|
29
30
|
"typescript",
|
|
30
|
-
"
|
|
31
|
+
"esbuild",
|
|
32
|
+
"vite",
|
|
31
33
|
"japanese",
|
|
32
34
|
"minista"
|
|
33
35
|
],
|
|
@@ -40,25 +42,16 @@
|
|
|
40
42
|
"url": "https://qranoko.jp"
|
|
41
43
|
},
|
|
42
44
|
"scripts": {
|
|
43
|
-
"build": "
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"clean": "
|
|
47
|
-
|
|
48
|
-
"prettier": {
|
|
49
|
-
"semi": false
|
|
45
|
+
"build": "npm run clean && npm run build:src && npm run build:type",
|
|
46
|
+
"build:src": "tsx ../../scripts/build-sources.ts",
|
|
47
|
+
"build:type": "tsc",
|
|
48
|
+
"clean": "rimraf ./dist",
|
|
49
|
+
"prepublishOnly": "npm run clean && npm run build"
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
|
+
"cac": "^6.7.14",
|
|
52
53
|
"degit": "^2.8.4",
|
|
53
|
-
"
|
|
54
|
-
"prompts": "^2.4.2"
|
|
55
|
-
"replace-in-file": "^6.3.2",
|
|
56
|
-
"yargs-parser": "^21.0.1"
|
|
57
|
-
},
|
|
58
|
-
"devDependencies": {
|
|
59
|
-
"@types/degit": "^2.8.3",
|
|
60
|
-
"@types/prompts": "^2.0.14",
|
|
61
|
-
"@types/yargs-parser": "^21.0.0",
|
|
62
|
-
"typescript": "^4.6.4"
|
|
54
|
+
"picocolors": "^1.0.0",
|
|
55
|
+
"prompts": "^2.4.2"
|
|
63
56
|
}
|
|
64
57
|
}
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2022 Qrac
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
package/cli.mjs
DELETED
package/dist/templates.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
export const TEMPLATES = [
|
|
2
|
-
{
|
|
3
|
-
title: "Basic Site (Typescript)",
|
|
4
|
-
value: "basic",
|
|
5
|
-
},
|
|
6
|
-
{
|
|
7
|
-
title: "SaaS Template (Typescript)",
|
|
8
|
-
value: "basic-saas",
|
|
9
|
-
},
|
|
10
|
-
{
|
|
11
|
-
title: "Minimal (Typescript)",
|
|
12
|
-
value: "ts",
|
|
13
|
-
},
|
|
14
|
-
{
|
|
15
|
-
title: "Minimal (JavaScript)",
|
|
16
|
-
value: "js",
|
|
17
|
-
},
|
|
18
|
-
];
|