@nuvio/cli 0.5.4 → 0.5.5
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
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
# @nuvio/cli
|
|
2
2
|
|
|
3
|
-
One-command onboarding for
|
|
3
|
+
One-command onboarding for nuvio in Vite + React + Tailwind projects.
|
|
4
4
|
|
|
5
5
|
```bash
|
|
6
6
|
pnpm dlx @nuvio/cli init
|
|
7
7
|
pnpm dev
|
|
8
8
|
```
|
|
9
9
|
|
|
10
|
-
See [
|
|
10
|
+
See [nuvio docs](https://github.com/ehah/Nuvio/blob/main/docs/nuvioUser.md).
|
|
11
11
|
|
|
12
12
|
## Telemetry
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
nuvio collects anonymous usage metrics to improve onboarding and reliability. No source code, file contents, file paths, project names, emails, or personal data are sent.
|
|
15
15
|
|
|
16
16
|
Disable anytime with:
|
|
17
17
|
|
package/dist/cli-entry.js
CHANGED
|
@@ -13,15 +13,15 @@ import { join } from "path";
|
|
|
13
13
|
// src/messages.ts
|
|
14
14
|
var MSG = {
|
|
15
15
|
noPackageJson: "Run this from your app folder (the one with package.json).",
|
|
16
|
-
noVite: "
|
|
17
|
-
noReact: "
|
|
18
|
-
noViteDep: "
|
|
19
|
-
strictTailwind: "
|
|
20
|
-
monorepoRoot: "This looks like the
|
|
16
|
+
noVite: "nuvio works with React + Vite projects. I couldn't find a Vite config here.",
|
|
17
|
+
noReact: "nuvio needs React. Add react to this project first.",
|
|
18
|
+
noViteDep: "nuvio needs Vite. Add vite to this project first.",
|
|
19
|
+
strictTailwind: "nuvio expects Tailwind CSS for class edits. Install tailwindcss or pass --skip-tailwind-check.",
|
|
20
|
+
monorepoRoot: "This looks like the nuvio monorepo. Run init in your app folder, not the tooling repo.",
|
|
21
21
|
cliPackage: "Cannot init inside @nuvio/cli package.",
|
|
22
|
-
partialHelp: "
|
|
23
|
-
noHeading: '
|
|
24
|
-
telemetryNotice: `
|
|
22
|
+
partialHelp: "nuvio set up what it could safely. Finish the steps in nuvio/SETUP_TODO.md, then run your dev server.",
|
|
23
|
+
noHeading: 'nuvio is wired, but I could not find a heading to mark editable. Add data-nuvio-id="page.title" to one visible element (see nuvio/START_HERE.md).',
|
|
24
|
+
telemetryNotice: `nuvio collects anonymous usage metrics to improve onboarding and reliability.
|
|
25
25
|
No source code, file contents, file paths, project names, emails, or personal data are sent.
|
|
26
26
|
|
|
27
27
|
Disable anytime with:
|
|
@@ -722,8 +722,11 @@ var FORBIDDEN_PROP_KEYS = /* @__PURE__ */ new Set([
|
|
|
722
722
|
"message",
|
|
723
723
|
"stack"
|
|
724
724
|
]);
|
|
725
|
+
var SHUTDOWN_TIMEOUT_MS = 3e3;
|
|
725
726
|
var client = null;
|
|
726
727
|
var sessionAnonymousId = null;
|
|
728
|
+
var shutdownDone = false;
|
|
729
|
+
var signalHandlersRegistered = false;
|
|
727
730
|
function telemetryDebug(message, detail) {
|
|
728
731
|
if (process.env.NUVIO_TELEMETRY_DEBUG !== "1") return;
|
|
729
732
|
if (detail !== void 0) {
|
|
@@ -796,6 +799,23 @@ function sanitizeProps(props) {
|
|
|
796
799
|
}
|
|
797
800
|
return Object.keys(out).length > 0 ? out : void 0;
|
|
798
801
|
}
|
|
802
|
+
function resolveCliInvokedCommand(help, command) {
|
|
803
|
+
if (help) return "help";
|
|
804
|
+
if (!command) return "none";
|
|
805
|
+
if (command === "init") return "init";
|
|
806
|
+
return "unknown";
|
|
807
|
+
}
|
|
808
|
+
function buildCliInvokedProps(command, pmOverride) {
|
|
809
|
+
const props = {
|
|
810
|
+
nuvio_version: NUVIO_VERSION,
|
|
811
|
+
os: process.platform,
|
|
812
|
+
arch: os.arch(),
|
|
813
|
+
node: process.version,
|
|
814
|
+
command
|
|
815
|
+
};
|
|
816
|
+
if (pmOverride) props.package_manager = pmOverride;
|
|
817
|
+
return props;
|
|
818
|
+
}
|
|
799
819
|
function buildCliTelemetryProps(pm, project) {
|
|
800
820
|
const props = {
|
|
801
821
|
nuvio_version: NUVIO_VERSION,
|
|
@@ -821,6 +841,9 @@ function preflightErrorCode(message) {
|
|
|
821
841
|
}
|
|
822
842
|
return "preflight_unknown";
|
|
823
843
|
}
|
|
844
|
+
function captureCliInvoked(command, pmOverride) {
|
|
845
|
+
captureCliEvent("nuvio_cli_invoked", buildCliInvokedProps(command, pmOverride));
|
|
846
|
+
}
|
|
824
847
|
function captureCliEvent(event, props) {
|
|
825
848
|
try {
|
|
826
849
|
if (!isTelemetryEnabled()) {
|
|
@@ -843,18 +866,46 @@ function captureCliEvent(event, props) {
|
|
|
843
866
|
telemetryDebug(`capture failed for ${event}`, error);
|
|
844
867
|
}
|
|
845
868
|
}
|
|
869
|
+
async function flushAndShutdownClient() {
|
|
870
|
+
if (!client) return;
|
|
871
|
+
const active = client;
|
|
872
|
+
client = null;
|
|
873
|
+
await Promise.race([
|
|
874
|
+
(async () => {
|
|
875
|
+
await active.flush();
|
|
876
|
+
await active.shutdown();
|
|
877
|
+
})(),
|
|
878
|
+
new Promise((_, reject) => {
|
|
879
|
+
setTimeout(
|
|
880
|
+
() => reject(new Error("telemetry shutdown timed out")),
|
|
881
|
+
SHUTDOWN_TIMEOUT_MS
|
|
882
|
+
);
|
|
883
|
+
})
|
|
884
|
+
]);
|
|
885
|
+
}
|
|
846
886
|
async function shutdownTelemetry() {
|
|
887
|
+
if (shutdownDone) return;
|
|
888
|
+
shutdownDone = true;
|
|
847
889
|
try {
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
await client.shutdown();
|
|
851
|
-
client = null;
|
|
852
|
-
telemetryDebug("flush + shutdown complete");
|
|
853
|
-
}
|
|
890
|
+
await flushAndShutdownClient();
|
|
891
|
+
telemetryDebug("flush + shutdown complete");
|
|
854
892
|
} catch (error) {
|
|
855
893
|
telemetryDebug("shutdown failed", error);
|
|
856
894
|
}
|
|
857
895
|
}
|
|
896
|
+
function registerTelemetrySignalHandlers() {
|
|
897
|
+
if (signalHandlersRegistered) return;
|
|
898
|
+
signalHandlersRegistered = true;
|
|
899
|
+
const onSignal = (signal) => {
|
|
900
|
+
void (async () => {
|
|
901
|
+
await shutdownTelemetry();
|
|
902
|
+
const code2 = signal === "SIGINT" ? 130 : 143;
|
|
903
|
+
process.exit(code2);
|
|
904
|
+
})();
|
|
905
|
+
};
|
|
906
|
+
process.once("SIGINT", onSignal);
|
|
907
|
+
process.once("SIGTERM", onSignal);
|
|
908
|
+
}
|
|
858
909
|
|
|
859
910
|
// src/init.ts
|
|
860
911
|
function isAutoYes(opts) {
|
|
@@ -889,14 +940,14 @@ function computeTier(installOk, viteOk, appOk, starterOk) {
|
|
|
889
940
|
function printSuccess(plan, checks) {
|
|
890
941
|
if (checks.install) {
|
|
891
942
|
console.log(
|
|
892
|
-
`\u2705
|
|
943
|
+
`\u2705 nuvio packages targeted (@nuvio/vite-plugin@${NUVIO_VERSION}, @nuvio/overlay@${NUVIO_VERSION})`
|
|
893
944
|
);
|
|
894
945
|
}
|
|
895
946
|
if (checks.vite) console.log("\u2705 Vite plugin added");
|
|
896
947
|
else if (plan.failedSteps.some((s) => s.includes("vite"))) {
|
|
897
948
|
console.log("\u26A0 Vite plugin \u2014 see nuvio/SETUP_TODO.md");
|
|
898
949
|
}
|
|
899
|
-
if (checks.app) console.log("\u2705
|
|
950
|
+
if (checks.app) console.log("\u2705 nuvio editor mounted");
|
|
900
951
|
else console.log("\u26A0 App shell \u2014 see nuvio/SETUP_TODO.md");
|
|
901
952
|
if (checks.starter) {
|
|
902
953
|
console.log(
|
|
@@ -917,7 +968,7 @@ Next:
|
|
|
917
968
|
${MSG.partialHelp}`);
|
|
918
969
|
} else if (plan.tier === "partial") {
|
|
919
970
|
console.log(
|
|
920
|
-
"\
|
|
971
|
+
"\nnuvio helped you as far as it safely could. See warnings above."
|
|
921
972
|
);
|
|
922
973
|
}
|
|
923
974
|
console.log(`
|
|
@@ -1017,7 +1068,7 @@ async function runInit(opts) {
|
|
|
1017
1068
|
return 1;
|
|
1018
1069
|
}
|
|
1019
1070
|
} else {
|
|
1020
|
-
console.log("\u2705
|
|
1071
|
+
console.log("\u2705 nuvio packages already installed");
|
|
1021
1072
|
}
|
|
1022
1073
|
} else {
|
|
1023
1074
|
console.log("(skipped install \u2014 --no-install)");
|
|
@@ -1103,7 +1154,7 @@ async function runInit(opts) {
|
|
|
1103
1154
|
|
|
1104
1155
|
// src/cli.ts
|
|
1105
1156
|
function printHelp() {
|
|
1106
|
-
console.log(`nuvio \u2014
|
|
1157
|
+
console.log(`nuvio \u2014 CLI for React + Vite
|
|
1107
1158
|
|
|
1108
1159
|
Usage:
|
|
1109
1160
|
nuvio init [options]
|
|
@@ -1159,21 +1210,23 @@ function parseArgs(argv) {
|
|
|
1159
1210
|
return { command, opts, help };
|
|
1160
1211
|
}
|
|
1161
1212
|
async function runCli(argv) {
|
|
1213
|
+
registerTelemetrySignalHandlers();
|
|
1162
1214
|
const { command, opts, help } = parseArgs(argv);
|
|
1163
|
-
|
|
1164
|
-
printHelp();
|
|
1165
|
-
return 0;
|
|
1166
|
-
}
|
|
1167
|
-
if (!command) {
|
|
1168
|
-
printHelp();
|
|
1169
|
-
return 1;
|
|
1170
|
-
}
|
|
1171
|
-
if (command !== "init") {
|
|
1172
|
-
console.error(`Unknown command: ${command}`);
|
|
1173
|
-
printHelp();
|
|
1174
|
-
return 1;
|
|
1175
|
-
}
|
|
1215
|
+
captureCliInvoked(resolveCliInvokedCommand(help, command), opts.pm);
|
|
1176
1216
|
try {
|
|
1217
|
+
if (help) {
|
|
1218
|
+
printHelp();
|
|
1219
|
+
return 0;
|
|
1220
|
+
}
|
|
1221
|
+
if (!command) {
|
|
1222
|
+
printHelp();
|
|
1223
|
+
return 1;
|
|
1224
|
+
}
|
|
1225
|
+
if (command !== "init") {
|
|
1226
|
+
console.error(`Unknown command: ${command}`);
|
|
1227
|
+
printHelp();
|
|
1228
|
+
return 1;
|
|
1229
|
+
}
|
|
1177
1230
|
return await runInit(opts);
|
|
1178
1231
|
} catch (e) {
|
|
1179
1232
|
const pm = detectPackageManager(opts.cwd, opts.pm);
|
package/package.json
CHANGED
package/templates/AGENT.md.tpl
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
<!-- nuvio-cli-template: 1 -->
|
|
2
|
-
#
|
|
2
|
+
# nuvio agent instructions
|
|
3
3
|
|
|
4
|
-
This project uses [
|
|
4
|
+
This project uses [nuvio](https://www.npmjs.com/org/nuvio) (dev-only visual editor).
|
|
5
5
|
|
|
6
|
-
When the user asks to make UI editable or wire
|
|
6
|
+
When the user asks to make UI editable or wire nuvio:
|
|
7
7
|
|
|
8
8
|
1. Do **not** change unrelated files.
|
|
9
9
|
2. Add **string literal** `data-nuvio-id="region.name"` on JSX elements they should click in the browser.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<!-- nuvio-cli-template: 1 -->
|
|
2
|
-
# Start here —
|
|
2
|
+
# Start here — nuvio in this project
|
|
3
3
|
|
|
4
4
|
Installed with @nuvio/cli@{{NUVIO_VERSION}}.
|
|
5
5
|
|
|
@@ -7,7 +7,7 @@ Installed with @nuvio/cli@{{NUVIO_VERSION}}.
|
|
|
7
7
|
|
|
8
8
|
**Then:**
|
|
9
9
|
1. Open the localhost URL from the terminal
|
|
10
|
-
2. Turn **Edit** on (
|
|
10
|
+
2. Turn **Edit** on (nuvio chip)
|
|
11
11
|
3. Click the starter element (usually the page title — id `page.title`)
|
|
12
12
|
4. **Preview Changes** → **Apply to Code**
|
|
13
13
|
|