@zuplo/cli 1.81.0 → 1.83.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.
@@ -1,10 +1,14 @@
1
1
 
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="a91948d7-c2a9-5d47-a291-0780bc4b373e")}catch(e){}}();
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="9e645dee-f3c2-5cd2-9f0d-99bc6c6e20dd")}catch(e){}}();
3
3
  import { logger } from "../common/logger.js";
4
4
  import { ApiServer } from "./server/server.js";
5
5
  export async function editor(argv) {
6
- const workingDir = argv.dir || null;
7
- const server = new ApiServer(workingDir);
6
+ const workingDir = argv.dir || process.cwd();
7
+ const server = new ApiServer({
8
+ workingDir,
9
+ port: argv.port,
10
+ isStandalone: true,
11
+ });
8
12
  server.start().catch(logger.error);
9
13
  return new Promise((resolve) => {
10
14
  process.on("SIGTERM", async () => {
@@ -18,4 +22,4 @@ export async function editor(argv) {
18
22
  });
19
23
  }
20
24
  //# sourceMappingURL=handler.js.map
21
- //# debugId=a91948d7-c2a9-5d47-a291-0780bc4b373e
25
+ //# debugId=9e645dee-f3c2-5cd2-9f0d-99bc6c6e20dd
@@ -1,18 +1,22 @@
1
- <!doctype html>
1
+ <!DOCTYPE html>
2
2
  <html lang="en">
3
3
  <head>
4
4
  <meta charset="UTF-8" />
5
5
  <link rel="icon" href="/favicon.ico" />
6
6
  <style>
7
- @import url('https://fonts.googleapis.com/css2?family=Exo:wght@500&display=swap');
7
+ @import url("https://fonts.googleapis.com/css2?family=Exo:wght@500&display=swap");
8
8
  </style>
9
9
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
10
10
  <title>Zuplo Local Designer</title>
11
11
  <script type="module" crossorigin src="/assets/index-03352ce7.js"></script>
12
- <link rel="stylesheet" href="/assets/index-416489b7.css">
12
+ <link rel="stylesheet" href="/assets/index-416489b7.css" />
13
13
  </head>
14
14
  <body>
15
15
  <div id="root"></div>
16
-
16
+
17
+ <script>
18
+ // Set the global window variable
19
+ window.SERVER_DATA = __SERVER_DATA__;
20
+ </script>
17
21
  </body>
18
22
  </html>
@@ -1,10 +1,10 @@
1
1
 
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="70ff8667-6414-5c3f-83ad-33606a7805f6")}catch(e){}}();
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="5ab9ac05-f559-54b5-b7df-cad35032f993")}catch(e){}}();
3
3
  import fastifyStatic from "@fastify/static";
4
4
  import chokidar from "chokidar";
5
5
  import Fastify from "fastify";
6
6
  import { FastifySSEPlugin } from "fastify-sse-v2";
7
- import fs, { readdir } from "node:fs/promises";
7
+ import fs, { readFile, readdir } from "node:fs/promises";
8
8
  import path from "node:path";
9
9
  import { fileURLToPath } from "node:url";
10
10
  import { logger } from "../../common/logger.js";
@@ -16,13 +16,19 @@ const CONFIG_DIR = "config";
16
16
  export class ApiServer {
17
17
  fastify;
18
18
  listenerPort;
19
+ isStandalone;
19
20
  listenerHost;
20
21
  workingDir;
21
22
  watcher;
22
23
  sseContext;
23
- constructor(workingDir) {
24
- this.workingDir = workingDir ?? ".";
25
- this.listenerPort = 5500;
24
+ constructor(options = {
25
+ workingDir: ".",
26
+ port: 9100,
27
+ isStandalone: true,
28
+ }) {
29
+ this.workingDir = options.workingDir;
30
+ this.listenerPort = options.port;
31
+ this.isStandalone = options.isStandalone;
26
32
  this.listenerHost = "localhost";
27
33
  this.watcher = chokidar.watch(path.join(this.workingDir, CONFIG_DIR));
28
34
  this.fastify = Fastify({
@@ -40,8 +46,13 @@ export class ApiServer {
40
46
  });
41
47
  this.fastify.register((instance, _options, done) => {
42
48
  instance.get("/", {
43
- handler: (_request, reply) => {
44
- reply.sendFile("index.html");
49
+ handler: async (_request, reply) => {
50
+ let html = await readFile(path.join(editorRootPath, "index.html"), "utf-8");
51
+ html = html.replace("__SERVER_DATA__", JSON.stringify({
52
+ server_address: this.listenerHost,
53
+ server_port: this.listenerPort,
54
+ }));
55
+ reply.type("text/html").send(html);
45
56
  },
46
57
  });
47
58
  instance.get("/open-api-content", {
@@ -178,12 +189,14 @@ export class ApiServer {
178
189
  reject(err);
179
190
  }
180
191
  this.fastify.log.level = "info";
181
- printDiagnosticsToConsole("Started route designer");
182
- printDiagnosticsToConsole("Ctrl+C to exit");
183
- printDiagnosticsToConsole("");
184
- printDiagnosticsToConsole(`📘 Route Designer: http://${this.listenerHost}:${this.listenerPort}`);
185
- printDiagnosticsToConsole("");
186
- printDiagnosticsToConsole("");
192
+ if (this.isStandalone) {
193
+ printDiagnosticsToConsole("Started route designer");
194
+ printDiagnosticsToConsole("Ctrl+C to exit");
195
+ printDiagnosticsToConsole("");
196
+ printDiagnosticsToConsole(`📘 Route Designer: http://${this.listenerHost}:${this.listenerPort}`);
197
+ printDiagnosticsToConsole("");
198
+ printDiagnosticsToConsole("");
199
+ }
187
200
  resolve();
188
201
  });
189
202
  });
@@ -194,7 +207,9 @@ export class ApiServer {
194
207
  return this.fastify.ready();
195
208
  };
196
209
  close = async () => {
197
- printDiagnosticsToConsole("Closing route designer");
210
+ if (this.isStandalone) {
211
+ printDiagnosticsToConsole("Closing route designer");
212
+ }
198
213
  try {
199
214
  if (this.sseContext) {
200
215
  this.sseContext.source.end();
@@ -211,4 +226,4 @@ export class ApiServer {
211
226
  };
212
227
  }
213
228
  //# sourceMappingURL=server.js.map
214
- //# debugId=70ff8667-6414-5c3f-83ad-33606a7805f6
229
+ //# debugId=5ab9ac05-f559-54b5-b7df-cad35032f993
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zuplo/cli",
3
- "version": "1.81.0",
3
+ "version": "1.83.0",
4
4
  "type": "module",
5
5
  "repository": "https://github.com/zuplo/cli",
6
6
  "description": "The command-line interface for Zuplo",
@@ -58,9 +58,9 @@
58
58
  "@inquirer/prompts": "^3.0.4",
59
59
  "@sentry/node": "7.69.0",
60
60
  "@swc/core": "1.3.78",
61
- "@zuplo/core": "5.1324.0",
61
+ "@zuplo/core": "5.1333.0",
62
62
  "@zuplo/pino-pretty-configurations": "^1.5.0",
63
- "@zuplo/runtime": "5.1324.0",
63
+ "@zuplo/runtime": "5.1333.0",
64
64
  "chalk": "^5.1.2",
65
65
  "chokidar": "^3.5.3",
66
66
  "deno-bin": "1.31.1",