create-cabloy 5.0.0 → 5.0.7
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/LICENSE +21 -0
- package/dist/chunks/package.mjs +1 -1
- package/dist/index.mjs +33 -34
- package/package.json +8 -8
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2016-present Cabloy/Vona/Zova
|
|
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/dist/chunks/package.mjs
CHANGED
package/dist/index.mjs
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import * as p from '@clack/prompts';
|
|
3
|
+
import mri from 'mri';
|
|
2
4
|
import { createWriteStream, existsSync } from 'node:fs';
|
|
3
5
|
import { unlink, mkdir } from 'node:fs/promises';
|
|
4
|
-
import { join, dirname, resolve
|
|
5
|
-
import mri from 'mri';
|
|
6
|
-
import * as p from '@clack/prompts';
|
|
6
|
+
import { join, dirname, resolve } from 'node:path';
|
|
7
7
|
import pc from 'picocolors';
|
|
8
|
-
import { pipeline } from 'node:stream/promises';
|
|
9
|
-
import { tmpdir } from 'node:os';
|
|
10
8
|
import spawn from 'cross-spawn';
|
|
9
|
+
import { tmpdir } from 'node:os';
|
|
10
|
+
import { pipeline } from 'node:stream/promises';
|
|
11
11
|
|
|
12
12
|
const NPM_REGISTRY = "https://registry.npmjs.org";
|
|
13
13
|
const PACKAGE_NAME = "cabloy";
|
|
@@ -44,7 +44,13 @@ async function downloadTarball(tarballUrl) {
|
|
|
44
44
|
}
|
|
45
45
|
async function extractTarball(tarballPath, targetDir) {
|
|
46
46
|
await mkdir(targetDir, { recursive: true });
|
|
47
|
-
const exitCode = await spawnAsync("tar", [
|
|
47
|
+
const exitCode = await spawnAsync("tar", [
|
|
48
|
+
"--strip-components=1",
|
|
49
|
+
"-xzf",
|
|
50
|
+
tarballPath,
|
|
51
|
+
"-C",
|
|
52
|
+
targetDir
|
|
53
|
+
]);
|
|
48
54
|
if (exitCode !== 0) {
|
|
49
55
|
throw new Error("Failed to extract tarball");
|
|
50
56
|
}
|
|
@@ -73,15 +79,18 @@ function spawnAsync(command, args, options) {
|
|
|
73
79
|
|
|
74
80
|
async function runPrompts(options) {
|
|
75
81
|
p.intro(pc.bgCyan(pc.black(" Create Cabloy ")));
|
|
76
|
-
let projectName
|
|
82
|
+
let projectName;
|
|
77
83
|
if (options.projectName) {
|
|
78
84
|
projectName = isValidPackageName(options.projectName) ? options.projectName : toValidPackageName(options.projectName);
|
|
79
85
|
} else {
|
|
80
86
|
const name = await p.text({
|
|
81
|
-
message: "Project name
|
|
87
|
+
message: "Project name",
|
|
82
88
|
placeholder: "cabloy-app",
|
|
83
89
|
validate: (v) => {
|
|
84
|
-
if (v.trim()
|
|
90
|
+
if (!v.trim()) {
|
|
91
|
+
return "Project name is required";
|
|
92
|
+
}
|
|
93
|
+
if (!isValidPackageName(v) && !isValidPackageName(toValidPackageName(v))) {
|
|
85
94
|
return "Invalid package name";
|
|
86
95
|
}
|
|
87
96
|
return void 0;
|
|
@@ -91,11 +100,7 @@ async function runPrompts(options) {
|
|
|
91
100
|
p.cancel("Operation cancelled");
|
|
92
101
|
return null;
|
|
93
102
|
}
|
|
94
|
-
|
|
95
|
-
projectName = isValidPackageName(name) ? name : toValidPackageName(name);
|
|
96
|
-
} else {
|
|
97
|
-
projectName = null;
|
|
98
|
-
}
|
|
103
|
+
projectName = isValidPackageName(name) ? name : toValidPackageName(name);
|
|
99
104
|
}
|
|
100
105
|
return {
|
|
101
106
|
projectName,
|
|
@@ -104,13 +109,13 @@ async function runPrompts(options) {
|
|
|
104
109
|
}
|
|
105
110
|
|
|
106
111
|
function printHelp() {
|
|
107
|
-
|
|
112
|
+
p.log.info(`
|
|
108
113
|
${pc.bold("create-cabloy")} - Create a new Cabloy project
|
|
109
114
|
|
|
110
115
|
${pc.bold("Usage:")}
|
|
111
|
-
${pc.cyan("npm create cabloy")} ${pc.dim("
|
|
112
|
-
${pc.cyan("pnpm create cabloy")} ${pc.dim("
|
|
113
|
-
${pc.cyan("yarn create cabloy")} ${pc.dim("
|
|
116
|
+
${pc.cyan("npm create cabloy")} ${pc.dim("<project-name>")}
|
|
117
|
+
${pc.cyan("pnpm create cabloy")} ${pc.dim("<project-name>")}
|
|
118
|
+
${pc.cyan("yarn create cabloy")} ${pc.dim("<project-name>")}
|
|
114
119
|
|
|
115
120
|
${pc.bold("Options:")}
|
|
116
121
|
--force Overwrite existing directory
|
|
@@ -130,7 +135,7 @@ async function main() {
|
|
|
130
135
|
}
|
|
131
136
|
if (args.version) {
|
|
132
137
|
const { default: pkg } = await import('./chunks/package.mjs');
|
|
133
|
-
|
|
138
|
+
p.log.info(pkg.version);
|
|
134
139
|
process.exit(0);
|
|
135
140
|
}
|
|
136
141
|
const result = await runPrompts({
|
|
@@ -140,26 +145,19 @@ async function main() {
|
|
|
140
145
|
if (!result) {
|
|
141
146
|
process.exit(0);
|
|
142
147
|
}
|
|
143
|
-
|
|
144
|
-
if (
|
|
145
|
-
targetDir = resolve(process.cwd(), result.projectName);
|
|
146
|
-
result.projectName;
|
|
147
|
-
} else {
|
|
148
|
-
targetDir = process.cwd();
|
|
149
|
-
basename(targetDir);
|
|
150
|
-
}
|
|
151
|
-
if (existsSync(targetDir) && result.projectName) {
|
|
148
|
+
const targetDir = resolve(process.cwd(), result.projectName);
|
|
149
|
+
if (existsSync(targetDir)) {
|
|
152
150
|
const files = await import('node:fs/promises').then((fs) => fs.readdir(targetDir));
|
|
153
151
|
if (files.length > 0 && !result.force) {
|
|
154
152
|
p.log.error(
|
|
155
|
-
pc.red(
|
|
153
|
+
pc.red(
|
|
154
|
+
`Directory "${result.projectName}" already exists and is not empty. Use --force to overwrite.`
|
|
155
|
+
)
|
|
156
156
|
);
|
|
157
157
|
process.exit(1);
|
|
158
158
|
}
|
|
159
159
|
}
|
|
160
|
-
|
|
161
|
-
await mkdir(targetDir, { recursive: true });
|
|
162
|
-
}
|
|
160
|
+
await mkdir(targetDir, { recursive: true });
|
|
163
161
|
const s = p.spinner();
|
|
164
162
|
s.start("Downloading cabloy from npm registry...");
|
|
165
163
|
try {
|
|
@@ -182,8 +180,9 @@ async function main() {
|
|
|
182
180
|
s2.stop("Project initialized successfully!");
|
|
183
181
|
}
|
|
184
182
|
p.outro(
|
|
185
|
-
pc.green(" Done! ")
|
|
186
|
-
|
|
183
|
+
`${pc.green(" Done! ")}Next steps:
|
|
184
|
+
${pc.dim(` cd ${result.projectName}
|
|
185
|
+
`)}${pc.dim(" npm run dev\n")}`
|
|
187
186
|
);
|
|
188
187
|
}
|
|
189
188
|
main().catch((err) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-cabloy",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.7",
|
|
4
|
+
"gitHead": "e6a1371c4db1c9c17fb4825aeabe82ad7519c5da",
|
|
4
5
|
"description": "Create a new Cabloy project - npm create cabloy",
|
|
5
6
|
"keywords": [
|
|
6
7
|
"cabloy",
|
|
@@ -21,6 +22,11 @@
|
|
|
21
22
|
"dist"
|
|
22
23
|
],
|
|
23
24
|
"type": "module",
|
|
25
|
+
"scripts": {
|
|
26
|
+
"dev": "unbuild --stub",
|
|
27
|
+
"build": "unbuild",
|
|
28
|
+
"prepublishOnly": "npm run build"
|
|
29
|
+
},
|
|
24
30
|
"dependencies": {
|
|
25
31
|
"@clack/prompts": "^0.9.1",
|
|
26
32
|
"cross-spawn": "^7.0.6",
|
|
@@ -35,11 +41,5 @@
|
|
|
35
41
|
},
|
|
36
42
|
"engines": {
|
|
37
43
|
"node": ">=20.19.0"
|
|
38
|
-
},
|
|
39
|
-
"scripts": {
|
|
40
|
-
"dev": "unbuild --stub",
|
|
41
|
-
"build": "unbuild",
|
|
42
|
-
"release-patch": "npm version patch && npm publish && git push --follow-tags",
|
|
43
|
-
"release-minor": "npm version minor && npm publish && git push --follow-tags"
|
|
44
44
|
}
|
|
45
|
-
}
|
|
45
|
+
}
|