create-velto 1.0.0
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/README.md +2 -0
- package/dist/index.mjs +83 -0
- package/package.json +33 -0
- package/templates/velto/assets/logo.jpg +0 -0
- package/templates/velto/index.html +13 -0
- package/templates/velto/package.json +22 -0
- package/templates/velto/pnpm-lock.yaml +1135 -0
- package/templates/velto/src/App.jsx +12 -0
- package/templates/velto/src/components/HelloWorld/index.jsx +22 -0
- package/templates/velto/src/components/HelloWorld/styles.module.scss +5 -0
- package/templates/velto/src/index.js +4 -0
- package/templates/velto/src/styles.module.scss +8 -0
- package/templates/velto/vite.config.js +37 -0
- package/templates/velto-ts/assets/logo.jpg +0 -0
- package/templates/velto-ts/index.html +13 -0
- package/templates/velto-ts/package.json +25 -0
- package/templates/velto-ts/pnpm-lock.yaml +1300 -0
- package/templates/velto-ts/src/App.tsx +12 -0
- package/templates/velto-ts/src/components/HelloWorld/index.tsx +22 -0
- package/templates/velto-ts/src/components/HelloWorld/styles.module.scss +5 -0
- package/templates/velto-ts/src/index.ts +4 -0
- package/templates/velto-ts/src/styles.module.scss +8 -0
- package/templates/velto-ts/src/types/global.d.ts +1 -0
- package/templates/velto-ts/tsconfig.json +109 -0
- package/templates/velto-ts/vite.config.ts +37 -0
package/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2025 veltojs
|
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/README.md
ADDED
package/dist/index.mjs
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
#!/usr/bin/env node
|
2
|
+
|
3
|
+
// bin/index.ts
|
4
|
+
import { program } from "commander";
|
5
|
+
import inquirer from "inquirer";
|
6
|
+
import chalk from "chalk";
|
7
|
+
import fs from "fs-extra";
|
8
|
+
import path from "path";
|
9
|
+
import { fileURLToPath } from "node:url";
|
10
|
+
var pwd = process.cwd();
|
11
|
+
var VERSION = "1.0.0";
|
12
|
+
var templateList = ["velto", "velto-ts"];
|
13
|
+
function pkgFromUserAgent(userAgent) {
|
14
|
+
if (!userAgent) return void 0;
|
15
|
+
const pkgSpec = userAgent.split(" ")[0];
|
16
|
+
const pkgSpecArr = pkgSpec.split("/");
|
17
|
+
return {
|
18
|
+
name: pkgSpecArr[0],
|
19
|
+
version: pkgSpecArr[1]
|
20
|
+
};
|
21
|
+
}
|
22
|
+
var command = async (projectName, options) => {
|
23
|
+
const pkgInfo = pkgFromUserAgent(process.env.npm_config_user_agent);
|
24
|
+
const pkgManagerName = pkgInfo?.name ?? "npm";
|
25
|
+
try {
|
26
|
+
if (!projectName) {
|
27
|
+
const { name } = await inquirer.prompt({
|
28
|
+
type: "input",
|
29
|
+
name: "name",
|
30
|
+
message: "Project name: ",
|
31
|
+
validate: (input) => !!input.trim() || "Project name is required"
|
32
|
+
});
|
33
|
+
projectName = name;
|
34
|
+
}
|
35
|
+
const targetDir = path.resolve(projectName);
|
36
|
+
if (fs.existsSync(targetDir)) {
|
37
|
+
const { overwrite } = await inquirer.prompt({
|
38
|
+
type: "confirm",
|
39
|
+
name: "overwrite",
|
40
|
+
message: "The directory already exists, is it overwritten?",
|
41
|
+
default: false
|
42
|
+
});
|
43
|
+
if (!overwrite) process.exit(1);
|
44
|
+
await fs.remove(targetDir);
|
45
|
+
}
|
46
|
+
let template = options.template;
|
47
|
+
if (!options.template || !templateList.includes(template)) {
|
48
|
+
const { selectedTemplate } = await inquirer.prompt({
|
49
|
+
type: "list",
|
50
|
+
name: "selectedTemplate",
|
51
|
+
message: options.template ? `"${template}" isn't a valid template. Please choose from below: ` : "Select a template: ",
|
52
|
+
choices: templateList
|
53
|
+
});
|
54
|
+
template = selectedTemplate;
|
55
|
+
}
|
56
|
+
const templatePath = path.resolve(
|
57
|
+
fileURLToPath(import.meta.url),
|
58
|
+
`../../templates/${template}`
|
59
|
+
);
|
60
|
+
await fs.copy(templatePath, targetDir);
|
61
|
+
const packagePath = path.join(targetDir, "package.json");
|
62
|
+
if (fs.existsSync(packagePath)) {
|
63
|
+
const pkg = JSON.parse(fs.readFileSync(packagePath, "utf8"));
|
64
|
+
pkg.name = projectName;
|
65
|
+
fs.writeFileSync(packagePath, JSON.stringify(pkg, null, 2));
|
66
|
+
}
|
67
|
+
console.log("Done. Now run: ");
|
68
|
+
console.log(
|
69
|
+
chalk.yellow(`
|
70
|
+
cd ${projectName}`),
|
71
|
+
chalk.yellow(`
|
72
|
+
${pkgManagerName} install`),
|
73
|
+
chalk.yellow(`
|
74
|
+
${pkgManagerName} run dev`),
|
75
|
+
"\n"
|
76
|
+
);
|
77
|
+
} catch (error) {
|
78
|
+
console.error(chalk.red("\u274C Error: "), error);
|
79
|
+
process.exit(1);
|
80
|
+
}
|
81
|
+
};
|
82
|
+
program.version(VERSION).argument("[project-name]", "Project name").option("-t, --template <template>", "template").action(command);
|
83
|
+
program.parse(process.argv);
|
package/package.json
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
{
|
2
|
+
"name": "create-velto",
|
3
|
+
"version": "1.0.0",
|
4
|
+
"type": "module",
|
5
|
+
"license": "MIT",
|
6
|
+
"author": "Zebing Fu",
|
7
|
+
"bin": {
|
8
|
+
"create-velto": "dist/index.mjs"
|
9
|
+
},
|
10
|
+
"files": [
|
11
|
+
"dist",
|
12
|
+
"templates",
|
13
|
+
"LICENSE"
|
14
|
+
],
|
15
|
+
"dependencies": {
|
16
|
+
"chalk": "^5.4.1",
|
17
|
+
"commander": "^13.1.0",
|
18
|
+
"degit": "^2.8.4",
|
19
|
+
"fs-extra": "^11.3.0",
|
20
|
+
"inquirer": "^12.5.2"
|
21
|
+
},
|
22
|
+
"devDependencies": {
|
23
|
+
"@types/degit": "^2.8.6",
|
24
|
+
"@types/fs-extra": "^11.0.4",
|
25
|
+
"@types/node": "^22.14.1",
|
26
|
+
"tsup": "^8.4.0",
|
27
|
+
"typescript": "^5.8.3"
|
28
|
+
},
|
29
|
+
"scripts": {
|
30
|
+
"dev": "tsup --watch",
|
31
|
+
"build": "tsup"
|
32
|
+
}
|
33
|
+
}
|
Binary file
|
@@ -0,0 +1,13 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html lang="en">
|
3
|
+
<head>
|
4
|
+
<meta charset="UTF-8" />
|
5
|
+
<link rel="icon" href="/favicon.ico" />
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
7
|
+
<title>Velto App</title>
|
8
|
+
<script type="module" src="/src/index.js"></script>
|
9
|
+
</head>
|
10
|
+
<body>
|
11
|
+
<div id="app"></div>
|
12
|
+
</body>
|
13
|
+
</html>
|
@@ -0,0 +1,22 @@
|
|
1
|
+
{
|
2
|
+
"name": "velto",
|
3
|
+
"version": "1.0.0",
|
4
|
+
"description": "",
|
5
|
+
"main": "index.js",
|
6
|
+
"scripts": {
|
7
|
+
"dev": "vite",
|
8
|
+
"build": "vite build",
|
9
|
+
"preview": "vite preview"
|
10
|
+
},
|
11
|
+
"keywords": [],
|
12
|
+
"author": "",
|
13
|
+
"license": "ISC",
|
14
|
+
"dependencies": {
|
15
|
+
"@velto/runtime": "1.0.0-beta.0"
|
16
|
+
},
|
17
|
+
"devDependencies": {
|
18
|
+
"@velto/babel-plugin-velto": "1.0.0-beta.0",
|
19
|
+
"sass": "^1.86.3",
|
20
|
+
"vite": "^6.2.6"
|
21
|
+
}
|
22
|
+
}
|