@stackable-labs/cli-app-extension 1.6.2 → 1.7.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.
- package/dist/index.js +31 -14
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1247,7 +1247,7 @@ const extensions: ExtensionRegistryEntry[] = [
|
|
|
1247
1247
|
{
|
|
1248
1248
|
id: manifest.name.toLowerCase().replace(/\\s+/g, '-'),
|
|
1249
1249
|
manifest,
|
|
1250
|
-
bundleUrl: \`http://localhost:\${import.meta.env.VITE_EXTENSION_PORT || '5173'}\`,
|
|
1250
|
+
bundleUrl: import.meta.env.VITE_EXTENSION_BUNDLE_URL || \`http://localhost:\${import.meta.env.VITE_EXTENSION_PORT || '5173'}\`,
|
|
1251
1251
|
enabled: true,
|
|
1252
1252
|
},
|
|
1253
1253
|
]
|
|
@@ -1297,7 +1297,7 @@ var patchViteAllowedHosts = async (rootDir) => {
|
|
|
1297
1297
|
if (content.includes("allowedHosts")) continue;
|
|
1298
1298
|
const patched = content.replace(
|
|
1299
1299
|
/server:\s*\{/,
|
|
1300
|
-
"server: {\n allowedHosts:
|
|
1300
|
+
"server: {\n allowedHosts: true,"
|
|
1301
1301
|
);
|
|
1302
1302
|
if (patched !== content) {
|
|
1303
1303
|
await writeFile(configPath, patched);
|
|
@@ -1309,7 +1309,7 @@ var rewriteTurboJson = async (rootDir) => {
|
|
|
1309
1309
|
const raw = await readFile(turboPath, "utf8");
|
|
1310
1310
|
const turbo = JSON.parse(raw);
|
|
1311
1311
|
delete turbo["extends"];
|
|
1312
|
-
turbo["globalEnv"] = ["VITE_EXTENSION_PORT", "VITE_PREVIEW_PORT"];
|
|
1312
|
+
turbo["globalEnv"] = ["VITE_EXTENSION_PORT", "VITE_PREVIEW_PORT", "VITE_EXTENSION_BUNDLE_URL"];
|
|
1313
1313
|
await writeFile(turboPath, `${JSON.stringify(turbo, null, 2)}
|
|
1314
1314
|
`);
|
|
1315
1315
|
};
|
|
@@ -1799,6 +1799,18 @@ var readDevContext = async (projectRoot) => {
|
|
|
1799
1799
|
previewPort
|
|
1800
1800
|
};
|
|
1801
1801
|
};
|
|
1802
|
+
var patchProjectEnv = async (projectRoot, key, value) => {
|
|
1803
|
+
const envPath = join3(projectRoot, ".env");
|
|
1804
|
+
const existing = await readEnvFile(envPath);
|
|
1805
|
+
existing[key] = value;
|
|
1806
|
+
await writeEnvFile2(envPath, existing);
|
|
1807
|
+
};
|
|
1808
|
+
var removeProjectEnvKey = async (projectRoot, key) => {
|
|
1809
|
+
const envPath = join3(projectRoot, ".env");
|
|
1810
|
+
const existing = await readEnvFile(envPath);
|
|
1811
|
+
delete existing[key];
|
|
1812
|
+
await writeEnvFile2(envPath, existing);
|
|
1813
|
+
};
|
|
1802
1814
|
var writeDevContext = async (projectRoot, ctx) => {
|
|
1803
1815
|
const env = {
|
|
1804
1816
|
APP_ID: ctx.appId || "",
|
|
@@ -1818,7 +1830,6 @@ var startTunnel = (port) => new Promise((resolve, reject) => {
|
|
|
1818
1830
|
reject(new Error("Tunnel connection timed out after 30s"));
|
|
1819
1831
|
}, 3e4);
|
|
1820
1832
|
tunnel.once("url", (url) => {
|
|
1821
|
-
console.log(">>> > startTunnel > url:", { url });
|
|
1822
1833
|
clearTimeout(timeout);
|
|
1823
1834
|
resolve({ url, stop: () => tunnel.stop() });
|
|
1824
1835
|
});
|
|
@@ -1891,9 +1902,9 @@ var DevDashboard = ({
|
|
|
1891
1902
|
extensionId,
|
|
1892
1903
|
appId,
|
|
1893
1904
|
appName,
|
|
1894
|
-
extensionPort,
|
|
1895
|
-
previewPort,
|
|
1896
1905
|
tunnelUrl,
|
|
1906
|
+
previewPort,
|
|
1907
|
+
extensionPort,
|
|
1897
1908
|
bundleUrlUpdated,
|
|
1898
1909
|
onQuit
|
|
1899
1910
|
}) => {
|
|
@@ -1911,7 +1922,6 @@ var DevDashboard = ({
|
|
|
1911
1922
|
onQuit();
|
|
1912
1923
|
}
|
|
1913
1924
|
});
|
|
1914
|
-
const previewUrl = tunnelUrl ? `${tunnelUrl.replace(/\/$/, "")}/preview` : `http://localhost:${previewPort}`;
|
|
1915
1925
|
return /* @__PURE__ */ jsxs15(Box15, { flexDirection: "column", children: [
|
|
1916
1926
|
/* @__PURE__ */ jsx15(Banner, {}),
|
|
1917
1927
|
/* @__PURE__ */ jsxs15(
|
|
@@ -1941,18 +1951,21 @@ var DevDashboard = ({
|
|
|
1941
1951
|
] }),
|
|
1942
1952
|
/* @__PURE__ */ jsxs15(Box15, { flexDirection: "column", gap: 1, children: [
|
|
1943
1953
|
/* @__PURE__ */ jsxs15(Box15, { gap: 2, children: [
|
|
1944
|
-
/* @__PURE__ */ jsx15(Text15, { dimColor: true, children: "
|
|
1945
|
-
/* @__PURE__ */
|
|
1954
|
+
/* @__PURE__ */ jsx15(Text15, { dimColor: true, children: "Preview:" }),
|
|
1955
|
+
/* @__PURE__ */ jsxs15(Text15, { children: [
|
|
1956
|
+
"http://localhost:",
|
|
1957
|
+
previewPort
|
|
1958
|
+
] })
|
|
1946
1959
|
] }),
|
|
1947
1960
|
/* @__PURE__ */ jsxs15(Box15, { gap: 2, children: [
|
|
1948
|
-
/* @__PURE__ */ jsx15(Text15, { dimColor: true, children: "Local
|
|
1961
|
+
/* @__PURE__ */ jsx15(Text15, { dimColor: true, children: "Local:" }),
|
|
1949
1962
|
/* @__PURE__ */ jsxs15(Text15, { children: [
|
|
1950
1963
|
"http://localhost:",
|
|
1951
1964
|
extensionPort
|
|
1952
1965
|
] })
|
|
1953
1966
|
] }),
|
|
1954
1967
|
/* @__PURE__ */ jsxs15(Box15, { gap: 2, children: [
|
|
1955
|
-
/* @__PURE__ */ jsx15(Text15, { dimColor: true, children: "Tunnel
|
|
1968
|
+
/* @__PURE__ */ jsx15(Text15, { dimColor: true, children: "Tunnel:" }),
|
|
1956
1969
|
/* @__PURE__ */ jsx15(Text15, { children: tunnelUrl || "Connecting\u2026" })
|
|
1957
1970
|
] })
|
|
1958
1971
|
] })
|
|
@@ -1995,9 +2008,6 @@ var DevApp = ({ options = {} }) => {
|
|
|
1995
2008
|
});
|
|
1996
2009
|
const extensionPort = options.extensionPort ? parseInt(options.extensionPort, 10) : devContext.extensionPort;
|
|
1997
2010
|
await patchViteAllowedHosts(devContext.projectRoot);
|
|
1998
|
-
console.log(`[dev] Starting dev server in ${devContext.projectRoot}`);
|
|
1999
|
-
const serverHandle = startDevServer(devContext.projectRoot);
|
|
2000
|
-
setDevServerHandle(serverHandle);
|
|
2001
2011
|
if (useTunnel) {
|
|
2002
2012
|
try {
|
|
2003
2013
|
console.log(`[dev] Starting tunnel on port ${extensionPort}...`);
|
|
@@ -2005,6 +2015,8 @@ var DevApp = ({ options = {} }) => {
|
|
|
2005
2015
|
console.log(`[dev] Tunnel ready: ${tunnelResult.url}`);
|
|
2006
2016
|
setTunnelHandle(tunnelResult);
|
|
2007
2017
|
setTunnelUrl(tunnelResult.url);
|
|
2018
|
+
console.log(`[dev] Writing VITE_EXTENSION_BUNDLE_URL=${tunnelResult.url} to .env`);
|
|
2019
|
+
await patchProjectEnv(devContext.projectRoot, "VITE_EXTENSION_BUNDLE_URL", tunnelResult.url);
|
|
2008
2020
|
if (useUpdate) {
|
|
2009
2021
|
const originalUrl = `http://localhost:${extensionPort}`;
|
|
2010
2022
|
setOriginalBundleUrl(originalUrl);
|
|
@@ -2021,6 +2033,9 @@ var DevApp = ({ options = {} }) => {
|
|
|
2021
2033
|
} else {
|
|
2022
2034
|
console.log("[dev] Tunnel disabled (--no-tunnel)");
|
|
2023
2035
|
}
|
|
2036
|
+
console.log(`[dev] Starting dev server in ${devContext.projectRoot}`);
|
|
2037
|
+
const serverHandle = startDevServer(devContext.projectRoot);
|
|
2038
|
+
setDevServerHandle(serverHandle);
|
|
2024
2039
|
console.log("[dev] Ready");
|
|
2025
2040
|
setState("running");
|
|
2026
2041
|
}, [devContext, options.extensionPort, useTunnel, useUpdate]);
|
|
@@ -2044,6 +2059,8 @@ var DevApp = ({ options = {} }) => {
|
|
|
2044
2059
|
});
|
|
2045
2060
|
console.log("[dev] bundleUrl restored");
|
|
2046
2061
|
}
|
|
2062
|
+
console.log("[dev] Removing VITE_EXTENSION_BUNDLE_URL from .env");
|
|
2063
|
+
await removeProjectEnvKey(devContext.projectRoot, "VITE_EXTENSION_BUNDLE_URL");
|
|
2047
2064
|
if (tunnelHandle) {
|
|
2048
2065
|
console.log("[dev] Stopping tunnel");
|
|
2049
2066
|
tunnelHandle.stop();
|