create-revojs 0.0.88 → 0.2.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/dist/index.js CHANGED
@@ -1,118 +1,36 @@
1
1
  #!/usr/bin/env node
2
- import { cp } from "node:fs/promises";
2
+ import { spawnSync } from "node:child_process";
3
+ import { cpSync, existsSync, mkdirSync, readFileSync, readdirSync, writeFileSync } from "node:fs";
4
+ import { basename, join, relative, resolve } from "node:path";
3
5
  import { fileURLToPath } from "node:url";
4
- import { defineCommand, runMain } from "citty";
5
-
6
- //#region ../../node_modules/pathe/dist/shared/pathe.M-eThtNZ.mjs
7
- const _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
8
- function normalizeWindowsPath(input = "") {
9
- if (!input) return input;
10
- return input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE, (r) => r.toUpperCase());
6
+ const root = fileURLToPath(new URL("../", import.meta.url));
7
+ const directory = resolve(process.argv[2] ?? "revojs-app");
8
+ const name = basename(directory).toLowerCase();
9
+ if (process.argv.length > 3 || !/^[a-z0-9][a-z0-9._-]*$/.test(name)) {
10
+ console.error("Usage: npm create revojs@latest [project-directory]");
11
+ process.exitCode = 1;
11
12
  }
12
- const _IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/;
13
- function cwd() {
14
- if (typeof process !== "undefined" && typeof process.cwd === "function") return process.cwd().replace(/\\/g, "/");
15
- return "/";
13
+ else if (existsSync(directory) && readdirSync(directory).length > 0) {
14
+ console.error(`The destination is not empty: ${directory}`);
15
+ process.exitCode = 1;
16
16
  }
17
- const resolve = function(...arguments_) {
18
- arguments_ = arguments_.map((argument) => normalizeWindowsPath(argument));
19
- let resolvedPath = "";
20
- let resolvedAbsolute = false;
21
- for (let index = arguments_.length - 1; index >= -1 && !resolvedAbsolute; index--) {
22
- const path = index >= 0 ? arguments_[index] : cwd();
23
- if (!path || path.length === 0) continue;
24
- resolvedPath = `${path}/${resolvedPath}`;
25
- resolvedAbsolute = isAbsolute(path);
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;
17
+ else {
18
+ mkdirSync(directory, { recursive: true });
19
+ cpSync(join(root, "template"), directory, { recursive: true });
20
+ const manifest = JSON.parse(readFileSync(join(directory, "package.json"), "utf8"));
21
+ manifest.name = name;
22
+ writeFileSync(join(directory, "package.json"), `${JSON.stringify(manifest, null, 4)}\n`);
23
+ console.log(`Created ${name} with revojs.`);
24
+ console.log("Installing the revojs skill...");
25
+ const command = "npx skills add tellua/revojs --skill revojs";
26
+ const result = spawnSync(command, {
27
+ cwd: directory,
28
+ stdio: "inherit",
29
+ shell: true,
30
+ });
31
+ if (result.error || result.status !== 0) {
32
+ console.error(`Skill installation failed. Run \`${command}\` in the project.`);
33
+ process.exitCode = 1;
34
+ }
35
+ console.log(`\n cd ${relative(process.cwd(), directory) || "."}\n npm install\n npm run dev`);
80
36
  }
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.88";
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.0.88",
4
- "type": "module",
5
- "repository": "coverbase/revojs",
3
+ "version": "0.2.0",
6
4
  "license": "MIT",
7
- "files": [
8
- "dist",
9
- "templates"
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
- "dependencies": {
19
- "citty": "^0.1.6",
20
- "pathe": "^2.0.3"
21
- },
22
- "optionalDependencies": {
23
- "@rolldown/binding-linux-x64-gnu": "*"
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
- "@revojs/tsconfig": "*",
27
- "rolldown": "^1.0.0-beta.19"
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
  }
@@ -0,0 +1,11 @@
1
+ # revojs app
2
+
3
+ This project is a revojs app. When asked to create an app or add a feature, build it here with revojs. Keep the existing `revojs` dependency and `vite.config.ts`; do not replace this starter with another framework.
4
+
5
+ Before coding, load the `revojs` skill and read the references for the modules the task needs. If the skill is missing, install it with `npx skills add tellua/revojs --skill revojs` and then load it.
6
+
7
+ Use npm packages, not framework source code: run `npm install` for this starter, check that each needed `@revojs/*` package is available with `npm view @revojs/<module> version`, and install it with `npm install @revojs/<module>`. Import only public package exports such as `@revojs/vue/module`, then register the module in `revojs({ modules: [...] })` in `vite.config.ts`. Install only modules the app needs; use revojs routing, server, storage, auth, and other infrastructure where provided.
8
+
9
+ Do not add Git submodules, `vendor/`, copied revojs source, Git dependencies, or local package links to obtain framework modules. If a required package is unavailable on npm, report the exact package and registry error and stop that integration; do not silently substitute another implementation.
10
+
11
+ Run `npm run build` and `npm run typecheck` after changes.
@@ -1,12 +1,13 @@
1
- <!DOCTYPE html>
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>Revojs</title>
6
+ <title>revojs app</title>
7
7
  </head>
8
8
  <body>
9
- <x-main></x-main>
10
- <script type="module" src="/main.tsx"></script>
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.2.0"
12
+ },
13
+ "devDependencies": {
14
+ "typescript": "^7.0.2",
15
+ "vite": "^8.3.0"
16
+ }
17
+ }
@@ -0,0 +1,12 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ESNext",
4
+ "module": "ESNext",
5
+ "moduleResolution": "Bundler",
6
+ "strict": true,
7
+ "noEmit": true,
8
+ "skipLibCheck": true,
9
+ "types": ["vite/client"]
10
+ },
11
+ "include": ["vite.config.ts", ".revojs"]
12
+ }
@@ -1,4 +1,4 @@
1
- import { revojs } from "@revojs/vite";
1
+ import { revojs } from "revojs/module";
2
2
  import { defineConfig } from "vite";
3
3
 
4
4
  export default defineConfig({
@@ -1,8 +0,0 @@
1
- import { defineComponent } from "revojs";
2
-
3
- const Main = defineComponent({
4
- name: "x-main",
5
- setup: () => {
6
- return <div> Hello World </div>;
7
- },
8
- });
@@ -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
- }
@@ -1,3 +0,0 @@
1
- {
2
- "extends": "@revojs/tsconfig"
3
- }