@insforge/cli 0.1.71 → 0.1.73
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 +54 -11
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1865,11 +1865,22 @@ async function getJwtSecret() {
|
|
|
1865
1865
|
return null;
|
|
1866
1866
|
}
|
|
1867
1867
|
}
|
|
1868
|
+
function spliceDatabasePassword(maskedUrl, password3) {
|
|
1869
|
+
return maskedUrl.replace(/^(postgresql:\/\/[^:]+:)[^@]+(@)/, `$1${password3}$2`);
|
|
1870
|
+
}
|
|
1868
1871
|
async function getDatabaseConnectionString() {
|
|
1869
1872
|
try {
|
|
1870
|
-
const
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
+
const [urlRes, pwRes] = await Promise.all([
|
|
1874
|
+
ossFetch("/api/metadata/database-connection-string"),
|
|
1875
|
+
ossFetch("/api/metadata/database-password")
|
|
1876
|
+
]);
|
|
1877
|
+
const urlBody = await urlRes.json();
|
|
1878
|
+
const pwBody = await pwRes.json();
|
|
1879
|
+
const masked = urlBody.connectionURL;
|
|
1880
|
+
const password3 = pwBody.databasePassword;
|
|
1881
|
+
if (typeof masked !== "string" || !masked) return null;
|
|
1882
|
+
if (typeof password3 !== "string" || !password3) return null;
|
|
1883
|
+
return spliceDatabasePassword(masked, password3);
|
|
1873
1884
|
} catch {
|
|
1874
1885
|
return null;
|
|
1875
1886
|
}
|
|
@@ -1941,6 +1952,7 @@ function extractEnvPairs(content) {
|
|
|
1941
1952
|
}
|
|
1942
1953
|
return out;
|
|
1943
1954
|
}
|
|
1955
|
+
var MASKED_PASSWORD_PATTERN = /:\*+@/;
|
|
1944
1956
|
function refreshStaleEnvDefaults(existing, manifestDefaults, platformValues) {
|
|
1945
1957
|
const refreshed = [];
|
|
1946
1958
|
const lines = existing.split("\n").map((line) => {
|
|
@@ -1950,7 +1962,10 @@ function refreshStaleEnvDefaults(existing, manifestDefaults, platformValues) {
|
|
|
1950
1962
|
const userValue = m[2];
|
|
1951
1963
|
const def = manifestDefaults.get(key);
|
|
1952
1964
|
const real = platformValues.get(key);
|
|
1953
|
-
if (def
|
|
1965
|
+
if (def === void 0 || real === void 0 || real === def) return line;
|
|
1966
|
+
const matchesDefault = userValue === def;
|
|
1967
|
+
const isMaskedPassword = MASKED_PASSWORD_PATTERN.test(userValue);
|
|
1968
|
+
if (matchesDefault || isMaskedPassword) {
|
|
1954
1969
|
refreshed.push(key);
|
|
1955
1970
|
return `${key}=${real}`;
|
|
1956
1971
|
}
|
|
@@ -3111,6 +3126,26 @@ async function runNpmInstall(startMessage = "Installing dependencies...") {
|
|
|
3111
3126
|
clack13.log.info("Run `npm install` manually to install dependencies.");
|
|
3112
3127
|
}
|
|
3113
3128
|
}
|
|
3129
|
+
async function runNpmSetupIfPresent() {
|
|
3130
|
+
const pkgPath = path5.join(process.cwd(), "package.json");
|
|
3131
|
+
let hasSetup = false;
|
|
3132
|
+
try {
|
|
3133
|
+
const pkg2 = JSON.parse(await fs5.readFile(pkgPath, "utf-8"));
|
|
3134
|
+
hasSetup = typeof pkg2.scripts?.setup === "string";
|
|
3135
|
+
} catch {
|
|
3136
|
+
}
|
|
3137
|
+
if (!hasSetup) return;
|
|
3138
|
+
const spinner10 = clack13.spinner();
|
|
3139
|
+
spinner10.start("Running setup (schema + migrations)...");
|
|
3140
|
+
try {
|
|
3141
|
+
await execAsync3("npm run setup", { cwd: process.cwd(), maxBuffer: 20 * 1024 * 1024 });
|
|
3142
|
+
spinner10.stop("Setup complete");
|
|
3143
|
+
} catch (err) {
|
|
3144
|
+
spinner10.stop("Setup failed");
|
|
3145
|
+
clack13.log.warn(`npm run setup failed: ${err.message.split("\n")[0]}`);
|
|
3146
|
+
clack13.log.info("Inspect the error, fix DATABASE_URL or network access, then run `npm run setup` manually.");
|
|
3147
|
+
}
|
|
3148
|
+
}
|
|
3114
3149
|
function registerProjectLinkCommand(program2) {
|
|
3115
3150
|
program2.command("link").description("Link current directory to an InsForge project").option("--project-id <id>", "Project ID to link").option("--org-id <id>", "Organization ID").option("--template <template>", "Download a template after linking: react, nextjs, chatbot, crm, e-commerce, todo").option("--auth <provider>", "Wire a third-party auth provider into the chosen template (currently: better-auth)").option("--api-base-url <url>", "API Base URL for direct linking (OSS/Self-hosted)").option("--api-key <key>", "API Key for direct linking (OSS/Self-hosted)").action(async (opts, cmd) => {
|
|
3116
3151
|
const { json, apiUrl } = getRootOpts(cmd);
|
|
@@ -3196,6 +3231,9 @@ function registerProjectLinkCommand(program2) {
|
|
|
3196
3231
|
}
|
|
3197
3232
|
if (templateDownloaded && !json) {
|
|
3198
3233
|
await runNpmInstall();
|
|
3234
|
+
if (opts.auth) {
|
|
3235
|
+
await runNpmSetupIfPresent();
|
|
3236
|
+
}
|
|
3199
3237
|
}
|
|
3200
3238
|
await installSkills(json);
|
|
3201
3239
|
trackCommand("link", "oss-org", { direct: true, template: template2 });
|
|
@@ -3235,8 +3273,8 @@ function registerProjectLinkCommand(program2) {
|
|
|
3235
3273
|
}
|
|
3236
3274
|
if (result.packageJsonPatched && !json) {
|
|
3237
3275
|
await runNpmInstall("Installing new dependencies...");
|
|
3276
|
+
await runNpmSetupIfPresent();
|
|
3238
3277
|
}
|
|
3239
|
-
if (!json) clack13.note(result.nextSteps, "What's next");
|
|
3240
3278
|
} catch (err) {
|
|
3241
3279
|
const msg = `Failed to apply --auth ${opts.auth}: ${err.message}`;
|
|
3242
3280
|
if (json) console.error(JSON.stringify({ warning: msg }));
|
|
@@ -3390,6 +3428,9 @@ function registerProjectLinkCommand(program2) {
|
|
|
3390
3428
|
}
|
|
3391
3429
|
if (templateDownloaded && !json) {
|
|
3392
3430
|
await runNpmInstall();
|
|
3431
|
+
if (opts.auth) {
|
|
3432
|
+
await runNpmSetupIfPresent();
|
|
3433
|
+
}
|
|
3393
3434
|
}
|
|
3394
3435
|
await installSkills(json);
|
|
3395
3436
|
await reportCliUsage("cli.link", true, 6, projectConfig);
|
|
@@ -3416,8 +3457,8 @@ function registerProjectLinkCommand(program2) {
|
|
|
3416
3457
|
}
|
|
3417
3458
|
if (result.packageJsonPatched && !json) {
|
|
3418
3459
|
await runNpmInstall("Installing new dependencies...");
|
|
3460
|
+
await runNpmSetupIfPresent();
|
|
3419
3461
|
}
|
|
3420
|
-
if (!json) clack13.note(result.nextSteps, "What's next");
|
|
3421
3462
|
} catch (err) {
|
|
3422
3463
|
const msg = `Failed to apply --auth ${opts.auth}: ${err.message}`;
|
|
3423
3464
|
if (json) console.error(JSON.stringify({ warning: msg }));
|
|
@@ -4236,12 +4277,14 @@ function registerDbConnectionStringCommand(dbCmd2) {
|
|
|
4236
4277
|
const { json } = getRootOpts(cmd);
|
|
4237
4278
|
try {
|
|
4238
4279
|
await requireAuth();
|
|
4239
|
-
const
|
|
4240
|
-
|
|
4280
|
+
const url = await getDatabaseConnectionString();
|
|
4281
|
+
if (!url) {
|
|
4282
|
+
throw new CLIError("Could not fetch the database connection string. This command requires a cloud project (self-hosted instances expose Postgres directly via your docker-compose).");
|
|
4283
|
+
}
|
|
4241
4284
|
if (json) {
|
|
4242
|
-
outputJson(
|
|
4285
|
+
outputJson({ connectionURL: url });
|
|
4243
4286
|
} else {
|
|
4244
|
-
console.log(
|
|
4287
|
+
console.log(url);
|
|
4245
4288
|
}
|
|
4246
4289
|
await reportCliUsage("cli.db.connection-string", true);
|
|
4247
4290
|
} catch (err) {
|
|
@@ -6853,7 +6896,7 @@ function registerDiagnoseCommands(diagnoseCmd2) {
|
|
|
6853
6896
|
const s = !json ? clack15.spinner() : null;
|
|
6854
6897
|
s?.start("Collecting diagnostic data...");
|
|
6855
6898
|
const data2 = await collectDiagnosticData(projectId, ossMode, apiUrl);
|
|
6856
|
-
const cliVersion = "0.1.
|
|
6899
|
+
const cliVersion = "0.1.73";
|
|
6857
6900
|
s?.stop("Data collected");
|
|
6858
6901
|
if (!json) {
|
|
6859
6902
|
console.log(`
|