@stackable-labs/cli-app-extension 1.10.2 → 1.10.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.
Files changed (2) hide show
  1. package/dist/index.js +26 -80
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1074,7 +1074,6 @@ var readDevContext = async (projectRoot) => {
1074
1074
  appId: stackableEnv.APP_ID || null,
1075
1075
  extensionId: stackableEnv.EXTENSION_ID || null,
1076
1076
  appName: stackableEnv.APP_NAME || null,
1077
- originalBundleUrl: stackableEnv.ORIGINAL_BUNDLE_URL || null,
1078
1077
  extensionPort,
1079
1078
  previewPort
1080
1079
  };
@@ -1103,9 +1102,6 @@ var writeDevContext = async (projectRoot, ctx) => {
1103
1102
  if (ctx.extensionName && ctx.extensionName !== "Unknown Extension") {
1104
1103
  env.EXTENSION_NAME = ctx.extensionName;
1105
1104
  }
1106
- if (ctx.originalBundleUrl) {
1107
- env.ORIGINAL_BUNDLE_URL = ctx.originalBundleUrl;
1108
- }
1109
1105
  await writeEnvFile(join(projectRoot, ".env.stackable"), env);
1110
1106
  };
1111
1107
 
@@ -1929,7 +1925,6 @@ var DevDashboard = ({
1929
1925
  previewTunnelUrl,
1930
1926
  previewPort,
1931
1927
  extensionPort,
1932
- bundleUrlUpdated,
1933
1928
  onQuit
1934
1929
  }) => {
1935
1930
  useEffect5(() => {
@@ -1952,13 +1947,10 @@ var DevDashboard = ({
1952
1947
  StepShell,
1953
1948
  {
1954
1949
  title: "dev",
1955
- hint: "Live development with Tunnel",
1956
- footer: /* @__PURE__ */ jsxs15(Box15, { flexDirection: "column", gap: 1, children: [
1957
- bundleUrlUpdated && /* @__PURE__ */ jsx15(Text15, { color: "green", children: "bundleUrl updated \u2713" }),
1958
- /* @__PURE__ */ jsx15(Text15, { dimColor: true, children: "Press q or Ctrl-C to quit" })
1959
- ] }),
1950
+ hint: `Live development ${tunnelUrl ? "with" : "w/o"} Tunnel`,
1951
+ footer: /* @__PURE__ */ jsx15(Box15, { flexDirection: "column", gap: 1, children: /* @__PURE__ */ jsx15(Text15, { dimColor: true, children: "Press q or Ctrl-C to quit" }) }),
1960
1952
  children: [
1961
- /* @__PURE__ */ jsxs15(Box15, { flexDirection: "column", gap: 1, children: [
1953
+ /* @__PURE__ */ jsxs15(Box15, { flexDirection: "column", children: [
1962
1954
  /* @__PURE__ */ jsxs15(Box15, { gap: 2, children: [
1963
1955
  /* @__PURE__ */ jsx15(Text15, { dimColor: true, children: "Extension:" }),
1964
1956
  /* @__PURE__ */ jsxs15(Text15, { children: [
@@ -1971,9 +1963,13 @@ var DevDashboard = ({
1971
1963
  /* @__PURE__ */ jsxs15(Box15, { gap: 2, children: [
1972
1964
  /* @__PURE__ */ jsx15(Text15, { dimColor: true, children: "App:" }),
1973
1965
  /* @__PURE__ */ jsx15(Text15, { children: `${appName ? `${appName} ` : ""}(${appId})` })
1966
+ ] }),
1967
+ /* @__PURE__ */ jsxs15(Box15, { gap: 2, children: [
1968
+ /* @__PURE__ */ jsx15(Text15, { dimColor: true, children: "Bundle URL:" }),
1969
+ /* @__PURE__ */ jsx15(Text15, { children: tunnelUrl || `http://localhost:${extensionPort}` })
1974
1970
  ] })
1975
1971
  ] }),
1976
- /* @__PURE__ */ jsxs15(Box15, { flexDirection: "column", gap: 1, children: [
1972
+ /* @__PURE__ */ jsxs15(Box15, { flexDirection: "column", children: [
1977
1973
  previewTunnelUrl && /* @__PURE__ */ jsxs15(Box15, { gap: 2, children: [
1978
1974
  /* @__PURE__ */ jsx15(Text15, { dimColor: true, children: "Tunnel Dev - Preview:" }),
1979
1975
  /* @__PURE__ */ jsx15(Text15, { children: previewTunnelUrl })
@@ -1984,7 +1980,9 @@ var DevDashboard = ({
1984
1980
  "http://localhost:",
1985
1981
  previewPort
1986
1982
  ] })
1987
- ] }),
1983
+ ] })
1984
+ ] }),
1985
+ /* @__PURE__ */ jsxs15(Box15, { flexDirection: "column", children: [
1988
1986
  tunnelUrl && /* @__PURE__ */ jsxs15(Box15, { gap: 2, children: [
1989
1987
  /* @__PURE__ */ jsx15(Text15, { dimColor: true, children: "Tunnel Dev - Extension:" }),
1990
1988
  /* @__PURE__ */ jsx15(Text15, { children: tunnelUrl })
@@ -1995,15 +1993,15 @@ var DevDashboard = ({
1995
1993
  "http://localhost:",
1996
1994
  extensionPort
1997
1995
  ] })
1998
- ] }),
1999
- /* @__PURE__ */ jsxs15(Box15, { gap: 2, children: [
2000
- /* @__PURE__ */ jsx15(Text15, { dimColor: true, children: "Bundle URL:" }),
2001
- /* @__PURE__ */ jsxs15(Text15, { children: [
2002
- tunnelUrl || `http://localhost:${extensionPort}`,
2003
- bundleUrlUpdated ? " (updated \u2713)" : ""
2004
- ] })
2005
1996
  ] })
2006
- ] })
1997
+ ] }),
1998
+ /* @__PURE__ */ jsx15(Box15, { flexDirection: "column", children: tunnelUrl && /* @__PURE__ */ jsxs15(Box15, { gap: 2, children: [
1999
+ /* @__PURE__ */ jsx15(Text15, { dimColor: true, children: "Host Dev - Query Param:" }),
2000
+ /* @__PURE__ */ jsxs15(Text15, { children: [
2001
+ "?_stackable_dev=",
2002
+ encodeURIComponent(`${extensionId}:${tunnelUrl}`)
2003
+ ] })
2004
+ ] }) })
2007
2005
  ]
2008
2006
  }
2009
2007
  )
@@ -2012,28 +2010,17 @@ var DevDashboard = ({
2012
2010
 
2013
2011
  // src/components/DevApp.tsx
2014
2012
  import { jsx as jsx16 } from "react/jsx-runtime";
2015
- var isEphemeralUrl = (url) => {
2016
- try {
2017
- const { hostname } = new URL(url);
2018
- return hostname.endsWith(".ngrok.io") || hostname.endsWith(".ngrok-free.app") || hostname.endsWith(".trycloudflare.com");
2019
- } catch {
2020
- return true;
2021
- }
2022
- };
2023
2013
  var DevApp = ({ options = {} }) => {
2024
2014
  const [state, setState] = useState10("setup");
2025
2015
  const [devContext, setDevContext] = useState10(null);
2026
2016
  const [resolvedContext, setResolvedContext] = useState10(null);
2027
2017
  const [tunnelUrl, setTunnelUrl] = useState10(null);
2028
2018
  const [previewTunnelUrl, setPreviewTunnelUrl] = useState10(null);
2029
- const [bundleUrlUpdated, setBundleUrlUpdated] = useState10(false);
2030
2019
  const [tunnelHandle, setTunnelHandle] = useState10(null);
2031
2020
  const [previewTunnelHandle, setPreviewTunnelHandle] = useState10(null);
2032
2021
  const [devServerHandle, setDevServerHandle] = useState10(null);
2033
2022
  const shuttingDown = useRef(false);
2034
2023
  const useTunnel = options.tunnel !== false;
2035
- const useUpdate = options.update !== false;
2036
- const useRestore = options.restore !== false;
2037
2024
  useEffect6(() => {
2038
2025
  const projectRoot = options.dir || process.cwd();
2039
2026
  console.log(`[dev] Reading context from ${projectRoot}`);
@@ -2055,32 +2042,6 @@ var DevApp = ({ options = {} }) => {
2055
2042
  const extensionPort = options.extensionPort ? parseInt(options.extensionPort, 10) : devContext.extensionPort;
2056
2043
  const previewPort = options.previewPort ? parseInt(options.previewPort, 10) : devContext.previewPort;
2057
2044
  await patchViteAllowedHosts(devContext.projectRoot);
2058
- let cachedOriginalUrl = devContext.originalBundleUrl;
2059
- if (useUpdate) {
2060
- try {
2061
- console.log("[dev] Fetching current bundleUrl from API...");
2062
- const extensions = await fetchExtensions(resolved.appId);
2063
- const currentExtension = extensions[resolved.extensionId];
2064
- if (currentExtension?.bundleUrl) {
2065
- console.log(`[dev] Current bundleUrl: ${currentExtension.bundleUrl}`);
2066
- if (!isEphemeralUrl(currentExtension.bundleUrl)) {
2067
- console.log("[dev] Caching stable bundleUrl to .env.stackable");
2068
- cachedOriginalUrl = currentExtension.bundleUrl;
2069
- await writeDevContext(devContext.projectRoot, {
2070
- ...devContext,
2071
- appId: resolved.appId,
2072
- extensionId: resolved.extensionId,
2073
- appName: resolved.appName || null,
2074
- originalBundleUrl: cachedOriginalUrl
2075
- });
2076
- } else {
2077
- console.log("[dev] Current bundleUrl is ephemeral, keeping previous cached value");
2078
- }
2079
- }
2080
- } catch (err) {
2081
- console.warn("[dev] Failed to fetch current bundleUrl:", err);
2082
- }
2083
- }
2084
2045
  if (useTunnel) {
2085
2046
  try {
2086
2047
  console.log(`[dev] Starting extension tunnel on port ${extensionPort}...`);
@@ -2095,14 +2056,6 @@ var DevApp = ({ options = {} }) => {
2095
2056
  setPreviewTunnelUrl(previewTunnelResult.url);
2096
2057
  console.log(`[dev] Writing VITE_EXTENSION_BUNDLE_URL=${tunnelResult.url} to .env`);
2097
2058
  await patchProjectEnv(devContext.projectRoot, "VITE_EXTENSION_BUNDLE_URL", tunnelResult.url);
2098
- if (useUpdate) {
2099
- console.log(`[dev] Updating bundleUrl to ${tunnelResult.url}`);
2100
- await updateExtension(resolved.appId, resolved.extensionId, {
2101
- bundleUrl: tunnelResult.url
2102
- });
2103
- console.log("[dev] bundleUrl updated successfully");
2104
- setBundleUrlUpdated(true);
2105
- }
2106
2059
  } catch (err) {
2107
2060
  console.error("[dev] Failed to start tunnel:", err);
2108
2061
  }
@@ -2114,7 +2067,7 @@ var DevApp = ({ options = {} }) => {
2114
2067
  setDevServerHandle(serverHandle);
2115
2068
  console.log("[dev] Ready");
2116
2069
  setState("running");
2117
- }, [devContext, options.extensionPort, options.previewPort, useTunnel, useUpdate]);
2070
+ }, [devContext, options.extensionPort, options.previewPort, useTunnel]);
2118
2071
  useEffect6(() => {
2119
2072
  if (state === "setup" && devContext && devContext.appId && devContext.extensionId) {
2120
2073
  handleSetupReady({
@@ -2130,15 +2083,6 @@ var DevApp = ({ options = {} }) => {
2130
2083
  setState("stopping");
2131
2084
  console.log("[dev] Shutting down...");
2132
2085
  try {
2133
- if (useRestore && devContext.originalBundleUrl) {
2134
- console.log(`[dev] Restoring bundleUrl to ${devContext.originalBundleUrl}`);
2135
- await updateExtension(resolvedContext.appId, resolvedContext.extensionId, {
2136
- bundleUrl: devContext.originalBundleUrl
2137
- });
2138
- console.log("[dev] bundleUrl restored");
2139
- } else if (useRestore && !devContext.originalBundleUrl) {
2140
- console.warn("[dev] No cached original bundleUrl to restore");
2141
- }
2142
2086
  console.log("[dev] Removing VITE_EXTENSION_BUNDLE_URL from .env");
2143
2087
  await removeProjectEnvKey(devContext.projectRoot, "VITE_EXTENSION_BUNDLE_URL");
2144
2088
  if (tunnelHandle) {
@@ -2183,7 +2127,6 @@ var DevApp = ({ options = {} }) => {
2183
2127
  previewPort: options.previewPort ? parseInt(options.previewPort, 10) : devContext.previewPort,
2184
2128
  tunnelUrl,
2185
2129
  previewTunnelUrl,
2186
- bundleUrlUpdated,
2187
2130
  onQuit: handleQuit
2188
2131
  }
2189
2132
  );
@@ -2218,8 +2161,11 @@ var checkForUpdate = (currentVersion) => {
2218
2161
  res.on("end", () => {
2219
2162
  try {
2220
2163
  const { version: latest } = JSON.parse(data);
2221
- if (latest && latest !== currentVersion && isNewer(latest, currentVersion)) {
2222
- const warning = "\n\x1B[33m\u26A0 Update available: " + currentVersion + " \u2192 " + latest + "\x1B[0m\n Run \x1B[36mnpx @stackable-labs/cli-app-extension@latest\x1B[0m to update\n";
2164
+ if (latest && latest !== currentVersion && currentVersion !== "0.0.0" && isNewer(latest, currentVersion)) {
2165
+ const warning = `
2166
+ \x1B[33m\u26A0 Update available: ${currentVersion} \u2192 ${latest}\x1B[0m
2167
+ Run \x1B[36mnpx @stackable-labs/cli-app-extension@latest\x1B[0m to update
2168
+ `;
2223
2169
  console.error(warning);
2224
2170
  }
2225
2171
  } catch {
@@ -2253,7 +2199,7 @@ program.command("scaffold" /* SCAFFOLD */).description("Scaffold a local project
2253
2199
  program.command("update" /* UPDATE */).description("Update an existing Extension").argument("[extensionId]", "Extension ID to update").option("--app-id <id>", "Skip App selection").option("--name <name>", "New Extension name").option("--targets <targets>", "Comma-separated target slots (validated against app)").option("--bundle-url <url>", "New bundle URL").option("--enabled <bool>", "Enable/disable Extension").option("--set-version <version>", "Explicit version (skips auto-compute)").action((extensionId, options) => {
2254
2200
  render(/* @__PURE__ */ jsx17(App, { command: "update" /* UPDATE */, initialExtensionId: extensionId, options }));
2255
2201
  });
2256
- program.command("dev" /* DEV */).description("Start dev servers with a public tunnel").option("--dir <path>", "Project root (default: cwd)").option("--extension-port <port>", "Override Extension port").option("--preview-port <port>", "Override Preview port").option("--no-tunnel", "Skip tunnel, just run vite dev").option("--no-update", "Skip bundleUrl update on server").option("--no-restore", "On exit, keep tunnel URL as bundleUrl").action((options) => {
2202
+ program.command("dev" /* DEV */).description("Start dev servers with a public tunnel").option("--dir <path>", "Project root (default: cwd)").option("--extension-port <port>", "Override Extension port").option("--preview-port <port>", "Override Preview port").option("--no-tunnel", "Skip tunnel, just run vite dev").action((options) => {
2257
2203
  render(/* @__PURE__ */ jsx17(DevApp, { options }), { exitOnCtrlC: false });
2258
2204
  });
2259
2205
  program.parse(process.argv.filter((arg) => arg !== "--"));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stackable-labs/cli-app-extension",
3
- "version": "1.10.2",
3
+ "version": "1.10.3",
4
4
  "type": "module",
5
5
  "private": false,
6
6
  "bin": {