codarch 0.1.2 → 0.1.3
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 +1 -0
- package/index.js +22 -10
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -47,6 +47,7 @@ configuración.
|
|
|
47
47
|
```bash
|
|
48
48
|
codarch serve . # analiza, sirve la web y reanaliza al cambiar ficheros
|
|
49
49
|
codarch serve . --no-watch # solo análisis inicial; sin SSE
|
|
50
|
+
codarch serve . --no-web # modo API para Vite u otro frontend
|
|
50
51
|
codarch serve . --port 8080
|
|
51
52
|
```
|
|
52
53
|
|
package/index.js
CHANGED
|
@@ -4770,8 +4770,8 @@ var IGNORED_BROWSE = /* @__PURE__ */ new Set([
|
|
|
4770
4770
|
]);
|
|
4771
4771
|
function runServe(options) {
|
|
4772
4772
|
const root = path8.resolve(options.root ?? ".");
|
|
4773
|
-
const webRoot = findWebRoot();
|
|
4774
|
-
if (!webRoot) {
|
|
4773
|
+
const webRoot = options.web === false ? null : findWebRoot();
|
|
4774
|
+
if (options.web !== false && !webRoot) {
|
|
4775
4775
|
console.error(
|
|
4776
4776
|
"no se encontr\xF3 el build web. Ejecuta `npm run web:build` o usa el paquete publicado."
|
|
4777
4777
|
);
|
|
@@ -4973,6 +4973,10 @@ data: ${JSON.stringify({
|
|
|
4973
4973
|
request.on("close", () => clients.delete(response));
|
|
4974
4974
|
return;
|
|
4975
4975
|
}
|
|
4976
|
+
if (!webRoot) {
|
|
4977
|
+
sendError(response, 404, "servidor en modo API: la web la sirve otro proceso");
|
|
4978
|
+
return;
|
|
4979
|
+
}
|
|
4976
4980
|
serveStatic(webRoot, pathname, request.method === "HEAD", response);
|
|
4977
4981
|
} catch (error) {
|
|
4978
4982
|
if (!response.headersSent) {
|
|
@@ -5000,7 +5004,7 @@ data: ${JSON.stringify({
|
|
|
5000
5004
|
" CodArch \xB7 serve",
|
|
5001
5005
|
"",
|
|
5002
5006
|
` ra\xEDz ${state.root}`,
|
|
5003
|
-
` web ${webRoot}`,
|
|
5007
|
+
` web ${webRoot ?? "modo API (la sirve Vite)"}`,
|
|
5004
5008
|
` URL ${url}`,
|
|
5005
5009
|
` snapshot ${state.files} ficheros \xB7 checksum ${state.checksum.slice(0, 8)}`,
|
|
5006
5010
|
` modo ${state.watch ? "watch activo (SSE)" : "solo an\xE1lisis inicial"}`,
|
|
@@ -5060,12 +5064,16 @@ async function readBody(request) {
|
|
|
5060
5064
|
function originAllowed(request, options) {
|
|
5061
5065
|
const origin = request.headers.origin;
|
|
5062
5066
|
if (!origin) return true;
|
|
5063
|
-
|
|
5064
|
-
|
|
5065
|
-
|
|
5066
|
-
|
|
5067
|
-
|
|
5068
|
-
|
|
5067
|
+
try {
|
|
5068
|
+
const parsed = new URL(origin);
|
|
5069
|
+
if (parsed.protocol !== "http:") return false;
|
|
5070
|
+
if (parsed.hostname === "localhost" || parsed.hostname === "127.0.0.1") {
|
|
5071
|
+
return true;
|
|
5072
|
+
}
|
|
5073
|
+
return origin === `http://${options.host}:${options.port}`;
|
|
5074
|
+
} catch {
|
|
5075
|
+
return false;
|
|
5076
|
+
}
|
|
5069
5077
|
}
|
|
5070
5078
|
function findWebRoot() {
|
|
5071
5079
|
const candidates = [
|
|
@@ -5165,7 +5173,7 @@ data: ${JSON.stringify(data)}
|
|
|
5165
5173
|
}
|
|
5166
5174
|
|
|
5167
5175
|
// apps/cli/src/index.ts
|
|
5168
|
-
var VERSION = true ? "0.1.
|
|
5176
|
+
var VERSION = true ? "0.1.3" : "0.0.0";
|
|
5169
5177
|
var USAGE = `
|
|
5170
5178
|
CodArch \xB7 mapa vivo de la arquitectura de tu software
|
|
5171
5179
|
|
|
@@ -5213,6 +5221,7 @@ Opciones de serve:
|
|
|
5213
5221
|
--host <host> interfaz (por defecto 127.0.0.1)
|
|
5214
5222
|
--watch reanaliza al cambiar ficheros y refresca por SSE (por defecto)
|
|
5215
5223
|
--no-watch solo analiza al arrancar
|
|
5224
|
+
--no-web modo API sin servir la app (para Vite u otro frontend)
|
|
5216
5225
|
-h, --help esta ayuda
|
|
5217
5226
|
|
|
5218
5227
|
Ejemplos:
|
|
@@ -5492,6 +5501,7 @@ function parseServe(args) {
|
|
|
5492
5501
|
port: 4173,
|
|
5493
5502
|
host: "127.0.0.1",
|
|
5494
5503
|
watch: true,
|
|
5504
|
+
web: true,
|
|
5495
5505
|
help: false
|
|
5496
5506
|
};
|
|
5497
5507
|
const positional = [];
|
|
@@ -5525,6 +5535,8 @@ function parseServe(args) {
|
|
|
5525
5535
|
options.watch = true;
|
|
5526
5536
|
} else if (arg === "--no-watch") {
|
|
5527
5537
|
options.watch = false;
|
|
5538
|
+
} else if (arg === "--no-web") {
|
|
5539
|
+
options.web = false;
|
|
5528
5540
|
} else if (arg === "--help" || arg === "-h") {
|
|
5529
5541
|
options.help = true;
|
|
5530
5542
|
} else if (arg.startsWith("-")) {
|