create-revojs 0.0.18
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/dist/index.js +117 -0
- package/package.json +26 -0
- package/templates/ts/index.html +12 -0
- package/templates/ts/main.tsx +8 -0
- package/templates/ts/package.json +17 -0
- package/templates/ts/tsconfig.json +3 -0
- package/templates/ts/vite.config.ts +6 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { defineCommand, runMain } from "citty";
|
|
2
|
+
import { cp } from "node:fs/promises";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
|
|
5
|
+
//#region ../../node_modules/pathe/dist/shared/pathe.M-eThtNZ.mjs
|
|
6
|
+
const _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
|
|
7
|
+
function normalizeWindowsPath(input = "") {
|
|
8
|
+
if (!input) return input;
|
|
9
|
+
return input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE, (r) => r.toUpperCase());
|
|
10
|
+
}
|
|
11
|
+
const _IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/;
|
|
12
|
+
function cwd() {
|
|
13
|
+
if (typeof process !== "undefined" && typeof process.cwd === "function") return process.cwd().replace(/\\/g, "/");
|
|
14
|
+
return "/";
|
|
15
|
+
}
|
|
16
|
+
const resolve = function(...arguments_) {
|
|
17
|
+
arguments_ = arguments_.map((argument) => normalizeWindowsPath(argument));
|
|
18
|
+
let resolvedPath = "";
|
|
19
|
+
let resolvedAbsolute = false;
|
|
20
|
+
for (let index = arguments_.length - 1; index >= -1 && !resolvedAbsolute; index--) {
|
|
21
|
+
const path = index >= 0 ? arguments_[index] : cwd();
|
|
22
|
+
if (!path || path.length === 0) continue;
|
|
23
|
+
resolvedPath = `${path}/${resolvedPath}`;
|
|
24
|
+
resolvedAbsolute = isAbsolute(path);
|
|
25
|
+
}
|
|
26
|
+
resolvedPath = normalizeString(resolvedPath, !resolvedAbsolute);
|
|
27
|
+
if (resolvedAbsolute && !isAbsolute(resolvedPath)) return `/${resolvedPath}`;
|
|
28
|
+
return resolvedPath.length > 0 ? resolvedPath : ".";
|
|
29
|
+
};
|
|
30
|
+
function normalizeString(path, allowAboveRoot) {
|
|
31
|
+
let res = "";
|
|
32
|
+
let lastSegmentLength = 0;
|
|
33
|
+
let lastSlash = -1;
|
|
34
|
+
let dots = 0;
|
|
35
|
+
let char = null;
|
|
36
|
+
for (let index = 0; index <= path.length; ++index) {
|
|
37
|
+
if (index < path.length) char = path[index];
|
|
38
|
+
else if (char === "/") break;
|
|
39
|
+
else char = "/";
|
|
40
|
+
if (char === "/") {
|
|
41
|
+
if (lastSlash === index - 1 || dots === 1);
|
|
42
|
+
else if (dots === 2) {
|
|
43
|
+
if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
|
|
44
|
+
if (res.length > 2) {
|
|
45
|
+
const lastSlashIndex = res.lastIndexOf("/");
|
|
46
|
+
if (lastSlashIndex === -1) {
|
|
47
|
+
res = "";
|
|
48
|
+
lastSegmentLength = 0;
|
|
49
|
+
} else {
|
|
50
|
+
res = res.slice(0, lastSlashIndex);
|
|
51
|
+
lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
|
|
52
|
+
}
|
|
53
|
+
lastSlash = index;
|
|
54
|
+
dots = 0;
|
|
55
|
+
continue;
|
|
56
|
+
} else if (res.length > 0) {
|
|
57
|
+
res = "";
|
|
58
|
+
lastSegmentLength = 0;
|
|
59
|
+
lastSlash = index;
|
|
60
|
+
dots = 0;
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
if (allowAboveRoot) {
|
|
65
|
+
res += res.length > 0 ? "/.." : "..";
|
|
66
|
+
lastSegmentLength = 2;
|
|
67
|
+
}
|
|
68
|
+
} else {
|
|
69
|
+
if (res.length > 0) res += `/${path.slice(lastSlash + 1, index)}`;
|
|
70
|
+
else res = path.slice(lastSlash + 1, index);
|
|
71
|
+
lastSegmentLength = index - lastSlash - 1;
|
|
72
|
+
}
|
|
73
|
+
lastSlash = index;
|
|
74
|
+
dots = 0;
|
|
75
|
+
} else if (char === "." && dots !== -1) ++dots;
|
|
76
|
+
else dots = -1;
|
|
77
|
+
}
|
|
78
|
+
return res;
|
|
79
|
+
}
|
|
80
|
+
const isAbsolute = function(p) {
|
|
81
|
+
return _IS_ABSOLUTE_RE.test(p);
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
//#endregion
|
|
85
|
+
//#region package.json
|
|
86
|
+
var name = "create-revojs";
|
|
87
|
+
var version = "0.0.18";
|
|
88
|
+
|
|
89
|
+
//#endregion
|
|
90
|
+
//#region src/index.ts
|
|
91
|
+
const create = defineCommand({
|
|
92
|
+
args: {
|
|
93
|
+
template: {
|
|
94
|
+
type: "string",
|
|
95
|
+
default: "ts"
|
|
96
|
+
},
|
|
97
|
+
name: {
|
|
98
|
+
type: "positional",
|
|
99
|
+
default: "revojs-app"
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
run: async ({ args }) => {
|
|
103
|
+
const source = resolve(fileURLToPath(import.meta.url).replace("index.js", ""), "..", "templates", args.template);
|
|
104
|
+
const destination = resolve(".", args.name);
|
|
105
|
+
await cp(source, destination, { recursive: true });
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
const main = defineCommand({
|
|
109
|
+
meta: {
|
|
110
|
+
name,
|
|
111
|
+
version
|
|
112
|
+
},
|
|
113
|
+
subCommands: { create }
|
|
114
|
+
});
|
|
115
|
+
runMain(main);
|
|
116
|
+
|
|
117
|
+
//#endregion
|
package/package.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "create-revojs",
|
|
3
|
+
"version": "0.0.18",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"repository": "coverbase/revojs",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"files": ["dist", "templates"],
|
|
8
|
+
"scripts": {
|
|
9
|
+
"build": "rolldown -c rolldown.config.ts && tsc",
|
|
10
|
+
"watch": "rolldown -w -c rolldown.config.ts && tsc --watch"
|
|
11
|
+
},
|
|
12
|
+
"bin": {
|
|
13
|
+
"create-revojs": "./dist/index.js"
|
|
14
|
+
},
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"citty": "^0.1.6",
|
|
17
|
+
"pathe": "^2.0.0"
|
|
18
|
+
},
|
|
19
|
+
"optionalDependencies": {
|
|
20
|
+
"@rolldown/binding-linux-x64-gnu": "*"
|
|
21
|
+
},
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"@revojs/tsconfig": "*",
|
|
24
|
+
"rolldown": "^1.0.0-beta.1"
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
|
+
<title> Revojs </title>
|
|
7
|
+
</head>
|
|
8
|
+
<body>
|
|
9
|
+
<x-main></x-main>
|
|
10
|
+
<script type="module" src="/main.tsx"></script>
|
|
11
|
+
</body>
|
|
12
|
+
</html>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "revojs-ts",
|
|
3
|
+
"private": true,
|
|
4
|
+
"type": "module",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"dev": "vite",
|
|
7
|
+
"build": "vite build --app"
|
|
8
|
+
},
|
|
9
|
+
"dependencies": {
|
|
10
|
+
"revojs": "^0.0.18"
|
|
11
|
+
},
|
|
12
|
+
"devDependencies": {
|
|
13
|
+
"@revojs/tsconfig": "^0.0.18",
|
|
14
|
+
"@revojs/vite": "^0.0.18",
|
|
15
|
+
"vite": "^6.0.1"
|
|
16
|
+
}
|
|
17
|
+
}
|