@matthesketh/utopia-cli 0.4.0 → 0.7.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/README.md +47 -0
- package/dist/index.js +16 -0
- package/package.json +5 -3
package/README.md
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# @matthesketh/utopia-cli
|
|
2
|
+
|
|
3
|
+
CLI for the UtopiaJS framework. Wraps Vite and auto-injects the UtopiaJS plugin when no `vite.config` exists.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm add -D @matthesketh/utopia-cli
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Or scaffold a new project (includes the CLI automatically):
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npx create-utopia my-app
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Commands
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
utopia dev # Start development server
|
|
21
|
+
utopia build # Build for production
|
|
22
|
+
utopia preview # Preview production build
|
|
23
|
+
utopia test # Run component tests (vitest + <test> block extraction)
|
|
24
|
+
utopia create # Prints instructions for npx create-utopia
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Options
|
|
28
|
+
|
|
29
|
+
| Flag | Description |
|
|
30
|
+
|------|-------------|
|
|
31
|
+
| `--port <port>` | Specify port (dev/preview) |
|
|
32
|
+
| `--host [host]` | Expose to network |
|
|
33
|
+
| `--open` | Open browser on startup |
|
|
34
|
+
| `--outDir <dir>` | Output directory (build) |
|
|
35
|
+
| `-c, --config <file>` | Use a specific Vite config file |
|
|
36
|
+
| `-h, --help` | Show help |
|
|
37
|
+
| `-v, --version` | Show version |
|
|
38
|
+
|
|
39
|
+
## How It Works
|
|
40
|
+
|
|
41
|
+
- If no `vite.config.{ts,js,mjs,mts}` exists, the CLI auto-injects `@matthesketh/utopia-vite-plugin`
|
|
42
|
+
- `utopia test` auto-injects the `utopiaTestPlugin` from `@matthesketh/utopia-test/plugin`, which extracts `<test>` blocks from `.utopia` files into vitest-discoverable companion files
|
|
43
|
+
- All commands pass through to Vite under the hood
|
|
44
|
+
|
|
45
|
+
## License
|
|
46
|
+
|
|
47
|
+
MIT
|
package/dist/index.js
CHANGED
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
preview as vitePreview
|
|
11
11
|
} from "vite";
|
|
12
12
|
import utopia from "@matthesketh/utopia-vite-plugin";
|
|
13
|
+
import { utopiaTestPlugin } from "@matthesketh/utopia-test/plugin";
|
|
13
14
|
function parseArgs(argv) {
|
|
14
15
|
const args = argv.slice(2);
|
|
15
16
|
const META_FLAGS = /* @__PURE__ */ new Set(["-v", "--version", "-h", "--help"]);
|
|
@@ -91,6 +92,17 @@ async function preview(args) {
|
|
|
91
92
|
const server = await vitePreview(config);
|
|
92
93
|
server.printUrls();
|
|
93
94
|
}
|
|
95
|
+
async function test(args) {
|
|
96
|
+
const { startVitest } = await import("vitest/node");
|
|
97
|
+
const config = buildInlineConfig(args, "test");
|
|
98
|
+
const plugins = config.plugins ?? [];
|
|
99
|
+
plugins.push(utopiaTestPlugin());
|
|
100
|
+
config.plugins = plugins;
|
|
101
|
+
const vitest = await startVitest("test", args.rest, {
|
|
102
|
+
...config
|
|
103
|
+
});
|
|
104
|
+
await vitest?.close();
|
|
105
|
+
}
|
|
94
106
|
function printVersion() {
|
|
95
107
|
const require2 = createRequire(import.meta.url);
|
|
96
108
|
const pkg = require2("../package.json");
|
|
@@ -107,6 +119,7 @@ function printHelp() {
|
|
|
107
119
|
dev Start development server
|
|
108
120
|
build Build for production
|
|
109
121
|
preview Preview production build
|
|
122
|
+
test Run component tests
|
|
110
123
|
create Create a new project
|
|
111
124
|
|
|
112
125
|
Options:
|
|
@@ -131,6 +144,9 @@ async function main() {
|
|
|
131
144
|
case "preview":
|
|
132
145
|
await preview(args);
|
|
133
146
|
break;
|
|
147
|
+
case "test":
|
|
148
|
+
await test(args);
|
|
149
|
+
break;
|
|
134
150
|
case "create":
|
|
135
151
|
console.log("To create a new UtopiaJS project, run:");
|
|
136
152
|
console.log(" npx create-utopia [project-name]");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@matthesketh/utopia-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "CLI for the UtopiaJS framework",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -31,10 +31,12 @@
|
|
|
31
31
|
"dist"
|
|
32
32
|
],
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@matthesketh/utopia-
|
|
34
|
+
"@matthesketh/utopia-test": "0.7.0",
|
|
35
|
+
"@matthesketh/utopia-vite-plugin": "0.7.0"
|
|
35
36
|
},
|
|
36
37
|
"peerDependencies": {
|
|
37
|
-
"vite": "^6.0.0 || ^7.0.0"
|
|
38
|
+
"vite": "^6.0.0 || ^7.0.0",
|
|
39
|
+
"vitest": "^3.0.0"
|
|
38
40
|
},
|
|
39
41
|
"devDependencies": {
|
|
40
42
|
"vite": "^7.3.1"
|