@stackable-labs/cli-app-extension 1.5.0 → 1.6.1

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 +85 -48
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1787,12 +1787,23 @@ var writeDevContext = async (projectRoot, ctx) => {
1787
1787
  };
1788
1788
 
1789
1789
  // src/lib/tunnel.ts
1790
- import { tunnel } from "cloudflared";
1791
- var startTunnel = async (port) => {
1792
- const { url, stop } = tunnel({ "--url": `http://localhost:${port}` });
1793
- const resolvedUrl = await url;
1794
- return { url: resolvedUrl, stop };
1795
- };
1790
+ import { Tunnel } from "cloudflared";
1791
+ var startTunnel = (port) => new Promise((resolve, reject) => {
1792
+ const tunnel = Tunnel.quick(`http://localhost:${port}`);
1793
+ const timeout = setTimeout(() => {
1794
+ tunnel.stop();
1795
+ reject(new Error("Tunnel connection timed out after 30s"));
1796
+ }, 3e4);
1797
+ tunnel.once("url", (url) => {
1798
+ console.log(">>> > startTunnel > url:", { url });
1799
+ clearTimeout(timeout);
1800
+ resolve({ url, stop: () => tunnel.stop() });
1801
+ });
1802
+ tunnel.once("error", (err) => {
1803
+ clearTimeout(timeout);
1804
+ reject(err);
1805
+ });
1806
+ });
1796
1807
 
1797
1808
  // src/lib/devServer.ts
1798
1809
  import { spawn } from "child_process";
@@ -1877,45 +1888,54 @@ var DevDashboard = ({
1877
1888
  onQuit();
1878
1889
  }
1879
1890
  });
1880
- return /* @__PURE__ */ jsxs15(Box15, { flexDirection: "column", padding: 1, children: [
1881
- /* @__PURE__ */ jsx15(Box15, { marginBottom: 1, children: /* @__PURE__ */ jsx15(Text15, { bold: true, color: "blue", children: "\u2500\u2500 stackable dev \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500" }) }),
1882
- /* @__PURE__ */ jsxs15(Box15, { flexDirection: "column", gap: 1, marginBottom: 1, children: [
1883
- /* @__PURE__ */ jsxs15(Box15, { gap: 2, children: [
1884
- /* @__PURE__ */ jsx15(Text15, { dimColor: true, children: "Extension:" }),
1885
- /* @__PURE__ */ jsxs15(Text15, { children: [
1886
- extensionName,
1887
- " (",
1888
- extensionId,
1889
- ")"
1890
- ] })
1891
- ] }),
1892
- /* @__PURE__ */ jsxs15(Box15, { gap: 2, children: [
1893
- /* @__PURE__ */ jsx15(Text15, { dimColor: true, children: "App:" }),
1894
- /* @__PURE__ */ jsx15(Text15, { children: appName || appId })
1895
- ] })
1896
- ] }),
1897
- /* @__PURE__ */ jsxs15(Box15, { flexDirection: "column", gap: 1, marginBottom: 1, children: [
1898
- /* @__PURE__ */ jsxs15(Box15, { gap: 2, children: [
1899
- /* @__PURE__ */ jsx15(Text15, { dimColor: true, children: "Local:" }),
1900
- /* @__PURE__ */ jsxs15(Text15, { children: [
1901
- "http://localhost:",
1902
- extensionPort
1903
- ] })
1904
- ] }),
1905
- /* @__PURE__ */ jsxs15(Box15, { gap: 2, children: [
1906
- /* @__PURE__ */ jsx15(Text15, { dimColor: true, children: "Tunnel:" }),
1907
- /* @__PURE__ */ jsx15(Text15, { children: tunnelUrl || "Connecting\u2026" })
1908
- ] }),
1909
- /* @__PURE__ */ jsxs15(Box15, { gap: 2, children: [
1910
- /* @__PURE__ */ jsx15(Text15, { dimColor: true, children: "Preview:" }),
1911
- /* @__PURE__ */ jsxs15(Text15, { children: [
1912
- "http://localhost:",
1913
- previewPort
1914
- ] })
1915
- ] })
1916
- ] }),
1917
- bundleUrlUpdated && /* @__PURE__ */ jsx15(Box15, { marginBottom: 1, children: /* @__PURE__ */ jsx15(Text15, { color: "green", children: "bundleUrl updated \u2713" }) }),
1918
- /* @__PURE__ */ jsx15(Box15, { children: /* @__PURE__ */ jsx15(Text15, { dimColor: true, children: "Press Ctrl-C to quit" }) })
1891
+ const previewUrl = tunnelUrl ? `${tunnelUrl.replace(/\/$/, "")}/preview` : `http://localhost:${previewPort}`;
1892
+ return /* @__PURE__ */ jsxs15(Box15, { flexDirection: "column", children: [
1893
+ /* @__PURE__ */ jsx15(Banner, {}),
1894
+ /* @__PURE__ */ jsxs15(
1895
+ StepShell,
1896
+ {
1897
+ title: "dev",
1898
+ hint: "Live development with tunnel",
1899
+ footer: /* @__PURE__ */ jsxs15(Box15, { flexDirection: "column", gap: 1, children: [
1900
+ bundleUrlUpdated && /* @__PURE__ */ jsx15(Text15, { color: "green", children: "bundleUrl updated \u2713" }),
1901
+ /* @__PURE__ */ jsx15(Text15, { dimColor: true, children: "Press q or Ctrl-C to quit" })
1902
+ ] }),
1903
+ children: [
1904
+ /* @__PURE__ */ jsxs15(Box15, { flexDirection: "column", gap: 1, children: [
1905
+ /* @__PURE__ */ jsxs15(Box15, { gap: 2, children: [
1906
+ /* @__PURE__ */ jsx15(Text15, { dimColor: true, children: "Extension:" }),
1907
+ /* @__PURE__ */ jsxs15(Text15, { children: [
1908
+ extensionName,
1909
+ " (",
1910
+ extensionId,
1911
+ ")"
1912
+ ] })
1913
+ ] }),
1914
+ /* @__PURE__ */ jsxs15(Box15, { gap: 2, children: [
1915
+ /* @__PURE__ */ jsx15(Text15, { dimColor: true, children: "App:" }),
1916
+ /* @__PURE__ */ jsx15(Text15, { children: `${appName ? `${appName} ` : ""}(${appId})` })
1917
+ ] })
1918
+ ] }),
1919
+ /* @__PURE__ */ jsxs15(Box15, { flexDirection: "column", gap: 1, children: [
1920
+ /* @__PURE__ */ jsxs15(Box15, { gap: 2, children: [
1921
+ /* @__PURE__ */ jsx15(Text15, { dimColor: true, children: "Local Dev - Preview:" }),
1922
+ /* @__PURE__ */ jsx15(Text15, { children: previewUrl })
1923
+ ] }),
1924
+ /* @__PURE__ */ jsxs15(Box15, { gap: 2, children: [
1925
+ /* @__PURE__ */ jsx15(Text15, { dimColor: true, children: "Local Dev - Extension:" }),
1926
+ /* @__PURE__ */ jsxs15(Text15, { children: [
1927
+ "http://localhost:",
1928
+ extensionPort
1929
+ ] })
1930
+ ] }),
1931
+ /* @__PURE__ */ jsxs15(Box15, { gap: 2, children: [
1932
+ /* @__PURE__ */ jsx15(Text15, { dimColor: true, children: "Tunnel Dev - Extension:" }),
1933
+ /* @__PURE__ */ jsx15(Text15, { children: tunnelUrl || "Connecting\u2026" })
1934
+ ] })
1935
+ ] })
1936
+ ]
1937
+ }
1938
+ )
1919
1939
  ] });
1920
1940
  };
1921
1941
 
@@ -1935,38 +1955,49 @@ var DevApp = ({ options = {} }) => {
1935
1955
  const useRestore = options.restore !== false;
1936
1956
  useEffect6(() => {
1937
1957
  const projectRoot = options.dir || process.cwd();
1958
+ console.log(`[dev] Reading context from ${projectRoot}`);
1938
1959
  readDevContext(projectRoot).then((ctx) => {
1960
+ console.log(`[dev] Context loaded: extension="${ctx.extensionName}" appId=${ctx.appId ?? "(missing)"} extensionId=${ctx.extensionId ?? "(missing)"}`);
1939
1961
  setDevContext(ctx);
1940
1962
  });
1941
1963
  }, [options.dir]);
1942
1964
  const handleSetupReady = useCallback2(async (resolved) => {
1943
1965
  if (!devContext) return;
1944
1966
  setResolvedContext(resolved);
1967
+ console.log(`[dev] Saving context: appId=${resolved.appId} extensionId=${resolved.extensionId}`);
1945
1968
  await writeDevContext(devContext.projectRoot, {
1946
1969
  ...devContext,
1947
1970
  appId: resolved.appId,
1948
1971
  extensionId: resolved.extensionId
1949
1972
  });
1950
1973
  const extensionPort = options.extensionPort ? parseInt(options.extensionPort, 10) : devContext.extensionPort;
1974
+ console.log(`[dev] Starting dev server in ${devContext.projectRoot}`);
1951
1975
  const serverHandle = startDevServer(devContext.projectRoot);
1952
1976
  setDevServerHandle(serverHandle);
1953
1977
  if (useTunnel) {
1954
1978
  try {
1979
+ console.log(`[dev] Starting tunnel on port ${extensionPort}...`);
1955
1980
  const tunnelResult = await startTunnel(extensionPort);
1981
+ console.log(`[dev] Tunnel ready: ${tunnelResult.url}`);
1956
1982
  setTunnelHandle(tunnelResult);
1957
1983
  setTunnelUrl(tunnelResult.url);
1958
1984
  if (useUpdate) {
1959
1985
  const originalUrl = `http://localhost:${extensionPort}`;
1960
1986
  setOriginalBundleUrl(originalUrl);
1987
+ console.log(`[dev] Updating bundleUrl to ${tunnelResult.url}`);
1961
1988
  await updateExtension(resolved.appId, resolved.extensionId, {
1962
1989
  bundleUrl: tunnelResult.url
1963
1990
  });
1991
+ console.log("[dev] bundleUrl updated successfully");
1964
1992
  setBundleUrlUpdated(true);
1965
1993
  }
1966
1994
  } catch (err) {
1967
- console.error("Failed to start tunnel:", err);
1995
+ console.error("[dev] Failed to start tunnel:", err);
1968
1996
  }
1997
+ } else {
1998
+ console.log("[dev] Tunnel disabled (--no-tunnel)");
1969
1999
  }
2000
+ console.log("[dev] Ready");
1970
2001
  setState("running");
1971
2002
  }, [devContext, options.extensionPort, useTunnel, useUpdate]);
1972
2003
  useEffect6(() => {
@@ -1980,21 +2011,27 @@ var DevApp = ({ options = {} }) => {
1980
2011
  const handleQuit = async () => {
1981
2012
  if (!devContext || !resolvedContext) return;
1982
2013
  setState("stopping");
2014
+ console.log("[dev] Shutting down...");
1983
2015
  try {
1984
2016
  if (useRestore && originalBundleUrl) {
2017
+ console.log(`[dev] Restoring bundleUrl to ${originalBundleUrl}`);
1985
2018
  await updateExtension(resolvedContext.appId, resolvedContext.extensionId, {
1986
2019
  bundleUrl: originalBundleUrl
1987
2020
  });
2021
+ console.log("[dev] bundleUrl restored");
1988
2022
  }
1989
2023
  if (tunnelHandle) {
2024
+ console.log("[dev] Stopping tunnel");
1990
2025
  tunnelHandle.stop();
1991
2026
  }
1992
2027
  if (devServerHandle) {
2028
+ console.log("[dev] Stopping dev server");
1993
2029
  devServerHandle.stop();
1994
2030
  }
1995
2031
  } catch (err) {
1996
- console.error("Error during cleanup:", err);
2032
+ console.error("[dev] Error during cleanup:", err);
1997
2033
  }
2034
+ console.log("[dev] Done");
1998
2035
  process.exit(0);
1999
2036
  };
2000
2037
  if (state === "setup" && devContext) {
@@ -2032,7 +2069,7 @@ var DevApp = ({ options = {} }) => {
2032
2069
  import { jsx as jsx17 } from "react/jsx-runtime";
2033
2070
  var require2 = createRequire(import.meta.url);
2034
2071
  var { version } = require2("../package.json");
2035
- program.name("stackable-app-extension").description("Stackable app extension developer CLI").version(version);
2072
+ program.name("stackable-app-extension").description("Stackable app Extension developer CLI").version(version);
2036
2073
  program.command("create" /* CREATE */).description("Create a new Extension project").argument("[name]", "Extension project name").option("--extension-port <port>", "Extension dev server port (default: 5173)").option("--preview-port <port>", "Preview host dev server port").option("--skip-install", "Skip package manager install").option("--skip-git", "Skip git initialization").action((name, options) => {
2037
2074
  render(/* @__PURE__ */ jsx17(App, { command: "create" /* CREATE */, initialName: name, options }));
2038
2075
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stackable-labs/cli-app-extension",
3
- "version": "1.5.0",
3
+ "version": "1.6.1",
4
4
  "type": "module",
5
5
  "private": false,
6
6
  "bin": {