@stacksjs/actions 0.70.103 → 0.70.105

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/dist/dev/api.js CHANGED
@@ -5,10 +5,11 @@ import { config, overridesReady } from "@stacksjs/config";
5
5
  import { path } from "@stacksjs/path";
6
6
  import { route } from "@stacksjs/router";
7
7
  import { generateAutoImportFiles, generateServerAutoImportTypes, injectGlobalAutoImports } from "@stacksjs/server";
8
+ import { resolveApiHost } from "../helpers/api-host";
8
9
  const _options = parseOptions();
9
10
  await generateServerAutoImportTypes();
10
11
  await overridesReady;
11
- const port = Number(process.env.PORT_API) || config.ports?.api || 3008, modelsIndex = path.storagePath("framework/auto-imports/models.ts");
12
+ const port = Number(process.env.PORT_API) || config.ports?.api || 3008, hostname = resolveApiHost(), modelsIndex = path.storagePath("framework/auto-imports/models.ts");
12
13
  if (!existsSync(modelsIndex))
13
14
  await generateAutoImportFiles();
14
15
  await injectGlobalAutoImports();
@@ -79,10 +80,10 @@ await route.importRoutes();
79
80
  try {
80
81
  await route.serve({
81
82
  port,
82
- hostname: "127.0.0.1"
83
+ hostname
83
84
  });
84
85
  console.log(`
85
- \u279C API server ready: http://localhost:${port}
86
+ \u279C API server ready: http://${hostname}:${port}
86
87
  `);
87
88
  } catch (err) {
88
89
  if ((err?.code || err?.errno) === "EADDRINUSE" || String(err?.message || "").includes("EADDRINUSE")) {
@@ -0,0 +1,2 @@
1
+ /** Resolve the interface used by API entrypoints in local and deployed runtimes. */
2
+ export declare function resolveApiHost(env?: Record<string, string | undefined>): string;
@@ -0,0 +1,7 @@
1
+ export function resolveApiHost(env = process.env) {
2
+ if (env.API_HOST)
3
+ return env.API_HOST;
4
+ if (env.HOST)
5
+ return env.HOST;
6
+ return env.NODE_ENV === "production" || env.APP_ENV === "production" ? "0.0.0.0" : "127.0.0.1";
7
+ }
package/dist/serve/api.js CHANGED
@@ -5,6 +5,7 @@ import { config } from "@stacksjs/config";
5
5
  import { log } from "@stacksjs/logging";
6
6
  import { frameworkPath } from "@stacksjs/path";
7
7
  import { route } from "@stacksjs/router";
8
+ import { resolveApiHost } from "../helpers/api-host";
8
9
  function resolveDefaultsFile(rel) {
9
10
  const vendored = frameworkPath(`defaults/${rel}`);
10
11
  if (existsSync(vendored))
@@ -16,7 +17,7 @@ function resolveDefaultsFile(rel) {
16
17
  return vendored;
17
18
  }
18
19
  }
19
- const isProduction = process.env.APP_ENV === "production" || process.env.NODE_ENV === "production", port = Number(process.env.PORT) || config.ports?.api || 3008, hostname = process.env.HOST || (isProduction ? "0.0.0.0" : "127.0.0.1");
20
+ const port = Number(process.env.PORT) || config.ports?.api || 3008, hostname = resolveApiHost();
20
21
  log.info("[Stacks API] Starting server...");
21
22
  log.info(`[Stacks API] Environment: ${process.env.APP_ENV || "development"}`);
22
23
  const corsMod = await import(resolveDefaultsFile("app/Middleware/Cors.ts")), corsMiddleware = corsMod.default;
@@ -83,6 +83,14 @@ export declare function resolveSuccessMessage(ctx: UpgradeContext, currentVersio
83
83
  * for `storage/framework/core/buddy/package.json` — the canonical marker.
84
84
  */
85
85
  export declare function detectLocalStacks(projectRoot: string): string | null;
86
+ /**
87
+ * Local checkout auto-detection is a development convenience for channel
88
+ * upgrades. A pinned version must resolve the published git tag instead: the
89
+ * local checkout may be ahead of that tag while still reporting the same
90
+ * package version, which would install unreleased code under a released label.
91
+ * An explicit --from remains authoritative because the caller selected it.
92
+ */
93
+ export declare function shouldAutoDetectLocalStacks(options: { from?: string, version?: string }): boolean;
86
94
  /**
87
95
  * Walk a directory recursively and return a Map of relative-path → entry,
88
96
  * with each entry's size + content hash captured at the time of the call.
@@ -129,6 +129,9 @@ export function detectLocalStacks(projectRoot) {
129
129
  }
130
130
  return null;
131
131
  }
132
+ export function shouldAutoDetectLocalStacks(options) {
133
+ return !options.from && !options.version;
134
+ }
132
135
  export async function snapshotTree(root, skip = []) {
133
136
  const out = new Map;
134
137
  if (!existsSync(root))
@@ -16,6 +16,7 @@ import {
16
16
  resolveSuccessMessage,
17
17
  resolveUpgradeContext,
18
18
  resolveUpgradeMessage,
19
+ shouldAutoDetectLocalStacks,
19
20
  shouldShortCircuit,
20
21
  snapshotTree,
21
22
  writeChannel,
@@ -33,7 +34,7 @@ if (!existsSync(p.projectPath("storage/framework/core"))) {
33
34
  noPostinstall: options.noPostinstall ?? options.postinstall === !1
34
35
  });
35
36
  }
36
- const channelFile = join(projectRoot, ".stacks-channel"), versionFile = join(projectRoot, ".stacks-version"), currentChannel = readChannel(channelFile), ctx = resolveUpgradeContext(options, currentChannel), corePkgPath = p.projectPath("storage/framework/core/buddy/package.json"), currentVersion = readVersion(corePkgPath), explicitLocal = options.from ? p.projectPath(options.from) : null, detectedLocal = explicitLocal ?? detectLocalStacks(projectRoot), usingLocal = !!detectedLocal;
37
+ const channelFile = join(projectRoot, ".stacks-channel"), versionFile = join(projectRoot, ".stacks-version"), currentChannel = readChannel(channelFile), ctx = resolveUpgradeContext(options, currentChannel), corePkgPath = p.projectPath("storage/framework/core/buddy/package.json"), currentVersion = readVersion(corePkgPath), explicitLocal = options.from ? p.projectPath(options.from) : null, detectedLocal = explicitLocal ?? (shouldAutoDetectLocalStacks(options) ? detectLocalStacks(projectRoot) : null), usingLocal = !!detectedLocal;
37
38
  console.log(resolveUpgradeMessage(ctx, currentChannel, !!options.stable));
38
39
  console.log(usingLocal ? ` source: local checkout at ${detectedLocal}` : ` source: github:stacksjs/stacks#${ctx.ref}`);
39
40
  if (!options.force) {
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@stacksjs/actions",
3
3
  "type": "module",
4
4
  "sideEffects": false,
5
- "version": "0.70.103",
5
+ "version": "0.70.105",
6
6
  "description": "The Stacks actions.",
7
7
  "author": "Chris Breuer",
8
8
  "contributors": [
@@ -69,23 +69,23 @@
69
69
  "@stacksjs/ts-md": "^0.1.1"
70
70
  },
71
71
  "devDependencies": {
72
- "@stacksjs/api": "0.70.103",
73
- "@stacksjs/cli": "0.70.103",
74
- "@stacksjs/config": "0.70.103",
75
- "@stacksjs/database": "0.70.103",
72
+ "@stacksjs/api": "0.70.105",
73
+ "@stacksjs/cli": "0.70.105",
74
+ "@stacksjs/config": "0.70.105",
75
+ "@stacksjs/database": "0.70.105",
76
76
  "@stacksjs/tlsx": "^0.13.2",
77
77
  "better-dx": "^0.2.16",
78
- "@stacksjs/dns": "0.70.103",
79
- "@stacksjs/enums": "0.70.103",
80
- "@stacksjs/env": "0.70.103",
81
- "@stacksjs/error-handling": "0.70.103",
82
- "@stacksjs/logging": "0.70.103",
83
- "@stacksjs/path": "0.70.103",
84
- "@stacksjs/security": "0.70.103",
85
- "@stacksjs/storage": "0.70.103",
86
- "@stacksjs/strings": "0.70.103",
87
- "@stacksjs/utils": "0.70.103",
88
- "@stacksjs/validation": "0.70.103"
78
+ "@stacksjs/dns": "0.70.105",
79
+ "@stacksjs/enums": "0.70.105",
80
+ "@stacksjs/env": "0.70.105",
81
+ "@stacksjs/error-handling": "0.70.105",
82
+ "@stacksjs/logging": "0.70.105",
83
+ "@stacksjs/path": "0.70.105",
84
+ "@stacksjs/security": "0.70.105",
85
+ "@stacksjs/storage": "0.70.105",
86
+ "@stacksjs/strings": "0.70.105",
87
+ "@stacksjs/utils": "0.70.105",
88
+ "@stacksjs/validation": "0.70.105"
89
89
  },
90
90
  "peerDependencies": {
91
91
  "pickier": "^0.1.28"