@insforge/cli 0.1.66 → 0.1.67

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 CHANGED
@@ -1835,6 +1835,15 @@ async function getJwtSecret() {
1835
1835
  return null;
1836
1836
  }
1837
1837
  }
1838
+ async function getDatabaseConnectionString() {
1839
+ try {
1840
+ const res = await ossFetch("/api/metadata/database-connection-string");
1841
+ const data = await res.json();
1842
+ return typeof data.connectionURL === "string" && data.connectionURL.length > 0 ? data.connectionURL : null;
1843
+ } catch {
1844
+ return null;
1845
+ }
1846
+ }
1838
1847
  async function ossFetch(path6, options = {}) {
1839
1848
  const config = requireProjectConfig();
1840
1849
  const headers = {
@@ -2032,8 +2041,11 @@ async function applyAuthProvider(provider, cwd, projectConfig, json) {
2032
2041
  const envLocalExists = await pathExists(envLocalPath);
2033
2042
  const existingLocal = envLocalExists ? await fs.readFile(envLocalPath, "utf-8") : "";
2034
2043
  const existingLocalKeys = envLocalExists ? extractEnvKeys(existingLocal) : /* @__PURE__ */ new Set();
2035
- const anonKey = await getAnonKey();
2036
- const jwtSecret = await getJwtSecret();
2044
+ const [anonKey, jwtSecret, databaseUrl] = await Promise.all([
2045
+ getAnonKey(),
2046
+ getJwtSecret(),
2047
+ getDatabaseConnectionString()
2048
+ ]);
2037
2049
  const filled = manifest.envExampleAppend.replace(
2038
2050
  /^([A-Z][A-Z0-9_]*=)(.*)$/gm,
2039
2051
  (_, prefix, value) => {
@@ -2043,6 +2055,7 @@ async function applyAuthProvider(provider, cwd, projectConfig, json) {
2043
2055
  if (key === "NEXT_PUBLIC_APP_URL") return `${prefix}https://${projectConfig.appkey}.insforge.site`;
2044
2056
  if (/JWT_SECRET$/.test(key)) return `${prefix}${jwtSecret ?? value}`;
2045
2057
  if (key === "BETTER_AUTH_SECRET") return `${prefix}${randomBytes2(32).toString("hex")}`;
2058
+ if (key === "DATABASE_URL") return `${prefix}${databaseUrl ?? value}`;
2046
2059
  return `${prefix}${value}`;
2047
2060
  }
2048
2061
  );
@@ -6776,7 +6789,7 @@ function registerDiagnoseCommands(diagnoseCmd2) {
6776
6789
  const s = !json ? clack14.spinner() : null;
6777
6790
  s?.start("Collecting diagnostic data...");
6778
6791
  const data2 = await collectDiagnosticData(projectId, ossMode, apiUrl);
6779
- const cliVersion = "0.1.66";
6792
+ const cliVersion = "0.1.67";
6780
6793
  s?.stop("Data collected");
6781
6794
  if (!json) {
6782
6795
  console.log(`