shadcn-studio-extension-cli 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.
@@ -1,6 +1,6 @@
1
1
  # Third-Party Licenses
2
2
 
3
- ## shadcn-studio-extension-cli@0.1.1
3
+ ## shadcn-studio-extension-cli@0.1.2
4
4
  - License: AGPL-3.0-only
5
5
  - Repository: https://github.com/stagewise-io/stagewise
6
6
  - Publisher: stagewise GmbH
@@ -11089,7 +11089,7 @@
11089
11089
  "format": "esm"
11090
11090
  },
11091
11091
  "src/server/proxy.ts": {
11092
- "bytes": 1963,
11092
+ "bytes": 2335,
11093
11093
  "imports": [
11094
11094
  {
11095
11095
  "path": "../../node_modules/.pnpm/http-proxy-middleware@3.0.5/node_modules/http-proxy-middleware/dist/index.js",
@@ -11102,14 +11102,14 @@
11102
11102
  "original": "../config"
11103
11103
  },
11104
11104
  {
11105
- "path": "src/server/error-page.ts",
11105
+ "path": "src/utils/logger.ts",
11106
11106
  "kind": "import-statement",
11107
- "original": "./error-page"
11107
+ "original": "../utils/logger"
11108
11108
  },
11109
11109
  {
11110
- "path": "src/utils/logger.ts",
11110
+ "path": "src/server/error-page.ts",
11111
11111
  "kind": "import-statement",
11112
- "original": "../utils/logger"
11112
+ "original": "./error-page"
11113
11113
  },
11114
11114
  {
11115
11115
  "path": "src/server/proxy-utils/headers-rewrites.ts",
@@ -11247,8 +11247,24 @@
11247
11247
  ],
11248
11248
  "format": "esm"
11249
11249
  },
11250
+ "src/utils/check-port.ts": {
11251
+ "bytes": 809,
11252
+ "imports": [
11253
+ {
11254
+ "path": "node:net",
11255
+ "kind": "import-statement",
11256
+ "external": true
11257
+ },
11258
+ {
11259
+ "path": "<runtime>",
11260
+ "kind": "import-statement",
11261
+ "external": true
11262
+ }
11263
+ ],
11264
+ "format": "esm"
11265
+ },
11250
11266
  "src/index.ts": {
11251
- "bytes": 10221,
11267
+ "bytes": 10806,
11252
11268
  "imports": [
11253
11269
  {
11254
11270
  "path": "../../node_modules/.pnpm/open@10.1.2/node_modules/open/index.js",
@@ -11315,6 +11331,11 @@
11315
11331
  "kind": "import-statement",
11316
11332
  "original": "./utils/telemetry"
11317
11333
  },
11334
+ {
11335
+ "path": "src/utils/check-port.ts",
11336
+ "kind": "dynamic-import",
11337
+ "original": "./utils/check-port.js"
11338
+ },
11318
11339
  {
11319
11340
  "path": "<runtime>",
11320
11341
  "kind": "import-statement",
@@ -11329,7 +11350,7 @@
11329
11350
  "imports": [],
11330
11351
  "exports": [],
11331
11352
  "inputs": {},
11332
- "bytes": 6268144
11353
+ "bytes": 6270887
11333
11354
  },
11334
11355
  "dist/index.cjs": {
11335
11356
  "imports": [
@@ -12178,6 +12199,11 @@
12178
12199
  "kind": "require-call",
12179
12200
  "external": true
12180
12201
  },
12202
+ {
12203
+ "path": "node:net",
12204
+ "kind": "require-call",
12205
+ "external": true
12206
+ },
12181
12207
  {
12182
12208
  "path": "node:process",
12183
12209
  "kind": "require-call",
@@ -13719,6 +13745,9 @@
13719
13745
  "../../node_modules/.pnpm/http-proxy-middleware@3.0.5/node_modules/http-proxy-middleware/dist/index.js": {
13720
13746
  "bytesInOutput": 1233
13721
13747
  },
13748
+ "src/utils/check-port.ts": {
13749
+ "bytesInOutput": 745
13750
+ },
13722
13751
  "../../node_modules/.pnpm/open@10.1.2/node_modules/open/index.js": {
13723
13752
  "bytesInOutput": 9631
13724
13753
  },
@@ -14119,7 +14148,7 @@
14119
14148
  "bytesInOutput": 6791
14120
14149
  },
14121
14150
  "src/server/proxy.ts": {
14122
- "bytesInOutput": 1659
14151
+ "bytesInOutput": 1959
14123
14152
  },
14124
14153
  "src/server/error-page.ts": {
14125
14154
  "bytesInOutput": 1638
@@ -14134,10 +14163,10 @@
14134
14163
  "bytesInOutput": 3729
14135
14164
  },
14136
14165
  "src/index.ts": {
14137
- "bytesInOutput": 7220
14166
+ "bytesInOutput": 7811
14138
14167
  }
14139
14168
  },
14140
- "bytes": 3806761
14169
+ "bytes": 3808425
14141
14170
  }
14142
14171
  }
14143
14172
  }
package/dist/index.cjs CHANGED
@@ -57548,6 +57548,36 @@ var require_dist = __commonJS({
57548
57548
  }
57549
57549
  });
57550
57550
 
57551
+ // src/utils/check-port.ts
57552
+ var check_port_exports = {};
57553
+ __export(check_port_exports, {
57554
+ isPortListening: () => isPortListening
57555
+ });
57556
+ async function isPortListening(port2, host = "localhost", timeout = 1e3) {
57557
+ return new Promise((resolve3) => {
57558
+ const socket = (0, import_node_net.createConnection)({ port: port2, host }, () => {
57559
+ socket.end();
57560
+ resolve3(true);
57561
+ });
57562
+ socket.setTimeout(timeout);
57563
+ socket.on("error", () => {
57564
+ resolve3(false);
57565
+ });
57566
+ socket.on("timeout", () => {
57567
+ socket.destroy();
57568
+ resolve3(false);
57569
+ });
57570
+ });
57571
+ }
57572
+ var import_node_net;
57573
+ var init_check_port = __esm({
57574
+ "src/utils/check-port.ts"() {
57575
+ "use strict";
57576
+ import_node_net = require("node:net");
57577
+ __name(isPortListening, "isPortListening");
57578
+ }
57579
+ });
57580
+
57551
57581
  // ../../node_modules/.pnpm/open@10.1.2/node_modules/open/index.js
57552
57582
  var import_node_process5 = __toESM(require("node:process"), 1);
57553
57583
  var import_node_buffer = require("node:buffer");
@@ -96810,9 +96840,17 @@ var proxy = (0, import_http_proxy_middleware.createProxyMiddleware)({
96810
96840
  // @ts-expect-error
96811
96841
  error: /* @__PURE__ */ __name((err, _req, res) => {
96812
96842
  log.error(`Proxy error: ${err.message}`);
96813
- const config = configResolver.getConfig();
96814
- res.writeHead(503, { "Content-Type": "text/html" });
96815
- res.end(errorPage(config.appPort));
96843
+ if (res && typeof res.writeHead === "function" && !res.headersSent) {
96844
+ try {
96845
+ const config = configResolver.getConfig();
96846
+ res.writeHead(503, { "Content-Type": "text/html" });
96847
+ res.end(errorPage(config.appPort));
96848
+ } catch (writeError) {
96849
+ log.debug(
96850
+ `Failed to send error response: ${writeError instanceof Error ? writeError.message : "Unknown error"}`
96851
+ );
96852
+ }
96853
+ }
96816
96854
  }, "error"),
96817
96855
  proxyRes: /* @__PURE__ */ __name((proxyRes) => {
96818
96856
  applyHeaderRewrites(proxyRes);
@@ -97340,6 +97378,18 @@ async function main() {
97340
97378
  );
97341
97379
  }
97342
97380
  const { server } = await getServer();
97381
+ if (config.appPort) {
97382
+ const { isPortListening: isPortListening2 } = await Promise.resolve().then(() => (init_check_port(), check_port_exports));
97383
+ const isAppPortAvailable = await isPortListening2(config.appPort);
97384
+ if (!isAppPortAvailable) {
97385
+ log.warn(
97386
+ `\u26A0\uFE0F Warning: App port ${config.appPort} is not responding. Make sure your application is running on port ${config.appPort}.`
97387
+ );
97388
+ log.warn(
97389
+ ` The Shadcn IDE Extension will still start, but proxying will not work until your app is running.`
97390
+ );
97391
+ }
97392
+ }
97343
97393
  server.listen(config.port);
97344
97394
  server.on("listening", async () => {
97345
97395
  const address = server.address();