create-revojs 0.0.87 → 0.1.58
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 +21 -113
- package/package.json +19 -18
- package/{templates/ts → template}/index.html +5 -4
- package/template/package.json +17 -0
- package/template/tsconfig.json +12 -0
- package/{templates/ts → template}/vite.config.ts +1 -1
- package/templates/ts/main.tsx +0 -8
- package/templates/ts/package.json +0 -17
- package/templates/ts/tsconfig.json +0 -3
package/dist/index.js
CHANGED
|
@@ -1,118 +1,26 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
2
|
+
import { cpSync, existsSync, mkdirSync, readFileSync, readdirSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { basename, join, relative, resolve } from "node:path";
|
|
3
4
|
import { fileURLToPath } from "node:url";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
return input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE, (r) => r.toUpperCase());
|
|
5
|
+
const root = fileURLToPath(new URL("../", import.meta.url));
|
|
6
|
+
const directory = resolve(process.argv[2] ?? "revojs-app");
|
|
7
|
+
const name = basename(directory).toLowerCase();
|
|
8
|
+
if (process.argv.length > 3 || !/^[a-z0-9][a-z0-9._-]*$/.test(name)) {
|
|
9
|
+
console.error("Usage: npm create revojs@latest [project-directory]");
|
|
10
|
+
process.exitCode = 1;
|
|
11
11
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
return "/";
|
|
12
|
+
else if (existsSync(directory) && readdirSync(directory).length > 0) {
|
|
13
|
+
console.error(`The destination is not empty: ${directory}`);
|
|
14
|
+
process.exitCode = 1;
|
|
16
15
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
resolvedPath = normalizeString(resolvedPath, !resolvedAbsolute);
|
|
28
|
-
if (resolvedAbsolute && !isAbsolute(resolvedPath)) return `/${resolvedPath}`;
|
|
29
|
-
return resolvedPath.length > 0 ? resolvedPath : ".";
|
|
30
|
-
};
|
|
31
|
-
function normalizeString(path, allowAboveRoot) {
|
|
32
|
-
let res = "";
|
|
33
|
-
let lastSegmentLength = 0;
|
|
34
|
-
let lastSlash = -1;
|
|
35
|
-
let dots = 0;
|
|
36
|
-
let char = null;
|
|
37
|
-
for (let index = 0; index <= path.length; ++index) {
|
|
38
|
-
if (index < path.length) char = path[index];
|
|
39
|
-
else if (char === "/") break;
|
|
40
|
-
else char = "/";
|
|
41
|
-
if (char === "/") {
|
|
42
|
-
if (lastSlash === index - 1 || dots === 1);
|
|
43
|
-
else if (dots === 2) {
|
|
44
|
-
if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
|
|
45
|
-
if (res.length > 2) {
|
|
46
|
-
const lastSlashIndex = res.lastIndexOf("/");
|
|
47
|
-
if (lastSlashIndex === -1) {
|
|
48
|
-
res = "";
|
|
49
|
-
lastSegmentLength = 0;
|
|
50
|
-
} else {
|
|
51
|
-
res = res.slice(0, lastSlashIndex);
|
|
52
|
-
lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
|
|
53
|
-
}
|
|
54
|
-
lastSlash = index;
|
|
55
|
-
dots = 0;
|
|
56
|
-
continue;
|
|
57
|
-
} else if (res.length > 0) {
|
|
58
|
-
res = "";
|
|
59
|
-
lastSegmentLength = 0;
|
|
60
|
-
lastSlash = index;
|
|
61
|
-
dots = 0;
|
|
62
|
-
continue;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
if (allowAboveRoot) {
|
|
66
|
-
res += res.length > 0 ? "/.." : "..";
|
|
67
|
-
lastSegmentLength = 2;
|
|
68
|
-
}
|
|
69
|
-
} else {
|
|
70
|
-
if (res.length > 0) res += `/${path.slice(lastSlash + 1, index)}`;
|
|
71
|
-
else res = path.slice(lastSlash + 1, index);
|
|
72
|
-
lastSegmentLength = index - lastSlash - 1;
|
|
73
|
-
}
|
|
74
|
-
lastSlash = index;
|
|
75
|
-
dots = 0;
|
|
76
|
-
} else if (char === "." && dots !== -1) ++dots;
|
|
77
|
-
else dots = -1;
|
|
78
|
-
}
|
|
79
|
-
return res;
|
|
16
|
+
else {
|
|
17
|
+
mkdirSync(directory, { recursive: true });
|
|
18
|
+
cpSync(join(root, "template"), directory, { recursive: true });
|
|
19
|
+
const manifest = JSON.parse(readFileSync(join(directory, "package.json"), "utf8"));
|
|
20
|
+
const { version } = JSON.parse(readFileSync(join(root, "package.json"), "utf8"));
|
|
21
|
+
manifest.name = name;
|
|
22
|
+
manifest.dependencies.revojs = `^${version}`;
|
|
23
|
+
writeFileSync(join(directory, "package.json"), `${JSON.stringify(manifest, null, 4)}\n`);
|
|
24
|
+
console.log(`Created ${name} with revojs.`);
|
|
25
|
+
console.log(`\n cd ${relative(process.cwd(), directory) || "."}\n npm install\n npx skills add tellua/revojs --skill revojs\n npm run dev`);
|
|
80
26
|
}
|
|
81
|
-
const isAbsolute = function(p) {
|
|
82
|
-
return _IS_ABSOLUTE_RE.test(p);
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
//#endregion
|
|
86
|
-
//#region package.json
|
|
87
|
-
var name = "create-revojs";
|
|
88
|
-
var version = "0.0.87";
|
|
89
|
-
|
|
90
|
-
//#endregion
|
|
91
|
-
//#region src/index.ts
|
|
92
|
-
const create = defineCommand({
|
|
93
|
-
args: {
|
|
94
|
-
template: {
|
|
95
|
-
type: "string",
|
|
96
|
-
default: "ts"
|
|
97
|
-
},
|
|
98
|
-
name: {
|
|
99
|
-
type: "positional",
|
|
100
|
-
default: "revojs-app"
|
|
101
|
-
}
|
|
102
|
-
},
|
|
103
|
-
run: async ({ args }) => {
|
|
104
|
-
const source = resolve(fileURLToPath(import.meta.url).replace("index.js", ""), "..", "templates", args.template);
|
|
105
|
-
const destination = resolve(".", args.name);
|
|
106
|
-
await cp(source, destination, { recursive: true });
|
|
107
|
-
}
|
|
108
|
-
});
|
|
109
|
-
const main = defineCommand({
|
|
110
|
-
meta: {
|
|
111
|
-
name,
|
|
112
|
-
version
|
|
113
|
-
},
|
|
114
|
-
subCommands: { create }
|
|
115
|
-
});
|
|
116
|
-
runMain(main);
|
|
117
|
-
|
|
118
|
-
//#endregion
|
package/package.json
CHANGED
|
@@ -1,29 +1,30 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-revojs",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"type": "module",
|
|
5
|
-
"repository": "coverbase/revojs",
|
|
3
|
+
"version": "0.1.58",
|
|
6
4
|
"license": "MIT",
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
"
|
|
10
|
-
|
|
11
|
-
"scripts": {
|
|
12
|
-
"build": "rolldown -c rolldown.config.ts && tsc",
|
|
13
|
-
"watch": "rolldown -w -c rolldown.config.ts && tsc --watch"
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/tellua/revojs.git",
|
|
8
|
+
"directory": "packages/create-revojs"
|
|
14
9
|
},
|
|
15
10
|
"bin": {
|
|
16
11
|
"create-revojs": "./dist/index.js"
|
|
17
12
|
},
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
|
|
22
|
-
"
|
|
23
|
-
|
|
13
|
+
"files": [
|
|
14
|
+
"template",
|
|
15
|
+
"dist/index.js"
|
|
16
|
+
],
|
|
17
|
+
"type": "module",
|
|
18
|
+
"scripts": {
|
|
19
|
+
"build": "tsc -p tsconfig.json",
|
|
20
|
+
"typecheck": "tsc --noEmit -p tsconfig.json",
|
|
21
|
+
"prepack": "npm run build"
|
|
24
22
|
},
|
|
25
23
|
"devDependencies": {
|
|
26
|
-
"@
|
|
27
|
-
"
|
|
24
|
+
"@types/node": "^26.4.1",
|
|
25
|
+
"typescript": "^7.0.2"
|
|
26
|
+
},
|
|
27
|
+
"engines": {
|
|
28
|
+
"node": "^20.19.0 || >=22.12.0"
|
|
28
29
|
}
|
|
29
30
|
}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
<!
|
|
1
|
+
<!doctype html>
|
|
2
2
|
<html lang="en">
|
|
3
3
|
<head>
|
|
4
4
|
<meta charset="UTF-8" />
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
-
<title>
|
|
6
|
+
<title>revojs app</title>
|
|
7
7
|
</head>
|
|
8
8
|
<body>
|
|
9
|
-
<
|
|
10
|
-
|
|
9
|
+
<main>
|
|
10
|
+
<h1>Welcome to revojs</h1>
|
|
11
|
+
</main>
|
|
11
12
|
</body>
|
|
12
13
|
</html>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "revojs-app",
|
|
3
|
+
"private": true,
|
|
4
|
+
"type": "module",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"dev": "vite",
|
|
7
|
+
"build": "vite build",
|
|
8
|
+
"typecheck": "tsc --noEmit"
|
|
9
|
+
},
|
|
10
|
+
"dependencies": {
|
|
11
|
+
"revojs": "^0.1.58"
|
|
12
|
+
},
|
|
13
|
+
"devDependencies": {
|
|
14
|
+
"typescript": "^7.0.2",
|
|
15
|
+
"vite": "^8.3.0"
|
|
16
|
+
}
|
|
17
|
+
}
|
package/templates/ts/main.tsx
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
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.59"
|
|
11
|
-
},
|
|
12
|
-
"devDependencies": {
|
|
13
|
-
"@revojs/tsconfig": "^0.0.59",
|
|
14
|
-
"@revojs/vite": "^0.0.59",
|
|
15
|
-
"vite": "^7.0.0"
|
|
16
|
-
}
|
|
17
|
-
}
|