@insforge/cli 0.1.55 → 0.1.57
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 +85 -12
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1123,7 +1123,7 @@ async function reportCliUsage(toolName, success, maxRetries = 1, explicitConfig)
|
|
|
1123
1123
|
|
|
1124
1124
|
// src/lib/analytics.ts
|
|
1125
1125
|
import { PostHog } from "posthog-node";
|
|
1126
|
-
var POSTHOG_API_KEY = "";
|
|
1126
|
+
var POSTHOG_API_KEY = "phc_ueV1ii62wdBTkH7E70ugyeqHIHu8dFDdjs0qq3TZhJz";
|
|
1127
1127
|
var POSTHOG_HOST = process.env.POSTHOG_HOST || "https://us.i.posthog.com";
|
|
1128
1128
|
var client = null;
|
|
1129
1129
|
function getClient() {
|
|
@@ -2131,7 +2131,11 @@ function buildOssHost2(appkey, region) {
|
|
|
2131
2131
|
function registerProjectLinkCommand(program2) {
|
|
2132
2132
|
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("--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) => {
|
|
2133
2133
|
const { json, apiUrl } = getRootOpts(cmd);
|
|
2134
|
+
const validTemplates = ["react", "nextjs", "chatbot", "crm", "e-commerce", "todo"];
|
|
2134
2135
|
try {
|
|
2136
|
+
if (opts.template && !validTemplates.includes(opts.template)) {
|
|
2137
|
+
throw new CLIError(`Invalid template "${opts.template}". Valid options: ${validTemplates.join(", ")}`);
|
|
2138
|
+
}
|
|
2135
2139
|
if (opts.apiBaseUrl || opts.apiKey) {
|
|
2136
2140
|
try {
|
|
2137
2141
|
if (!opts.apiBaseUrl || !opts.apiKey) {
|
|
@@ -2152,6 +2156,84 @@ function registerProjectLinkCommand(program2) {
|
|
|
2152
2156
|
oss_host: opts.apiBaseUrl.replace(/\/$/, "")
|
|
2153
2157
|
// remove trailing slash if any
|
|
2154
2158
|
};
|
|
2159
|
+
const template2 = opts.template;
|
|
2160
|
+
if (template2) {
|
|
2161
|
+
const defaultDir = `insforge-${template2}`;
|
|
2162
|
+
let dirName = defaultDir;
|
|
2163
|
+
if (!json) {
|
|
2164
|
+
const inputDir = await text2({
|
|
2165
|
+
message: "Directory name:",
|
|
2166
|
+
initialValue: defaultDir,
|
|
2167
|
+
validate: (v) => {
|
|
2168
|
+
if (v.length < 1) return "Directory name is required";
|
|
2169
|
+
const normalized = path4.basename(v).replace(/[^a-zA-Z0-9._-]/g, "-");
|
|
2170
|
+
if (!normalized || normalized === "." || normalized === "..") return "Invalid directory name";
|
|
2171
|
+
return void 0;
|
|
2172
|
+
}
|
|
2173
|
+
});
|
|
2174
|
+
if (isCancel2(inputDir)) process.exit(0);
|
|
2175
|
+
dirName = path4.basename(inputDir).replace(/[^a-zA-Z0-9._-]/g, "-");
|
|
2176
|
+
}
|
|
2177
|
+
if (!dirName || dirName === "." || dirName === "..") {
|
|
2178
|
+
throw new CLIError("Invalid directory name.");
|
|
2179
|
+
}
|
|
2180
|
+
const templateDir = path4.resolve(process.cwd(), dirName);
|
|
2181
|
+
const dirExists = await fs4.stat(templateDir).catch(() => null);
|
|
2182
|
+
if (dirExists) {
|
|
2183
|
+
throw new CLIError(`Directory "${dirName}" already exists.`);
|
|
2184
|
+
}
|
|
2185
|
+
await fs4.mkdir(templateDir);
|
|
2186
|
+
process.chdir(templateDir);
|
|
2187
|
+
saveProjectConfig(projectConfig2);
|
|
2188
|
+
if (json) {
|
|
2189
|
+
outputJson({
|
|
2190
|
+
success: true,
|
|
2191
|
+
project: { id: projectConfig2.project_id, name: projectConfig2.project_name, region: projectConfig2.region },
|
|
2192
|
+
directory: dirName,
|
|
2193
|
+
template: template2
|
|
2194
|
+
});
|
|
2195
|
+
} else {
|
|
2196
|
+
outputSuccess(`Linked to direct project at ${projectConfig2.oss_host}`);
|
|
2197
|
+
}
|
|
2198
|
+
captureEvent(FAKE_ORG_ID, "template_selected", { template: template2, source: "link_direct" });
|
|
2199
|
+
await downloadGitHubTemplate(template2, projectConfig2, json);
|
|
2200
|
+
const templateDownloaded = await fs4.stat(path4.join(process.cwd(), "package.json")).catch(() => null);
|
|
2201
|
+
if (templateDownloaded && !json) {
|
|
2202
|
+
const installSpinner = clack8.spinner();
|
|
2203
|
+
installSpinner.start("Installing dependencies...");
|
|
2204
|
+
try {
|
|
2205
|
+
await execAsync3("npm install", { cwd: process.cwd(), maxBuffer: 10 * 1024 * 1024 });
|
|
2206
|
+
installSpinner.stop("Dependencies installed");
|
|
2207
|
+
} catch (err) {
|
|
2208
|
+
installSpinner.stop("Failed to install dependencies");
|
|
2209
|
+
clack8.log.warn(`npm install failed: ${err.message}`);
|
|
2210
|
+
clack8.log.info("Run `npm install` manually to install dependencies.");
|
|
2211
|
+
}
|
|
2212
|
+
}
|
|
2213
|
+
await installSkills(json);
|
|
2214
|
+
trackCommand("link", "oss-org", { direct: true, template: template2 });
|
|
2215
|
+
await reportCliUsage("cli.link_direct", true, 6, projectConfig2);
|
|
2216
|
+
try {
|
|
2217
|
+
const urlMatch = opts.apiBaseUrl.match(/^https?:\/\/([^.]+)\.[^.]+\.insforge\.app/);
|
|
2218
|
+
if (urlMatch) {
|
|
2219
|
+
await reportAgentConnected({ app_key: urlMatch[1] }, apiUrl);
|
|
2220
|
+
}
|
|
2221
|
+
} catch {
|
|
2222
|
+
}
|
|
2223
|
+
if (!json) {
|
|
2224
|
+
if (templateDownloaded) {
|
|
2225
|
+
const runCommand = `${pc2.cyan("cd")} ${pc2.green(dirName)} ${pc2.dim("&&")} ${pc2.cyan("npm run dev")}`;
|
|
2226
|
+
const steps = [
|
|
2227
|
+
`${pc2.bold("1.")} ${runCommand}`,
|
|
2228
|
+
`${pc2.bold("2.")} Open ${pc2.cyan("Claude Code")} or ${pc2.cyan("Cursor")} and prompt your agent to add more features`
|
|
2229
|
+
];
|
|
2230
|
+
clack8.note(steps.join("\n"), "What's next");
|
|
2231
|
+
} else {
|
|
2232
|
+
clack8.log.warn("Template download failed. You can retry or set up manually.");
|
|
2233
|
+
}
|
|
2234
|
+
}
|
|
2235
|
+
return;
|
|
2236
|
+
}
|
|
2155
2237
|
saveProjectConfig(projectConfig2);
|
|
2156
2238
|
if (json) {
|
|
2157
2239
|
outputJson({ success: true, project: { id: projectConfig2.project_id, name: projectConfig2.project_name, region: projectConfig2.region } });
|
|
@@ -2264,10 +2346,6 @@ function registerProjectLinkCommand(program2) {
|
|
|
2264
2346
|
}
|
|
2265
2347
|
const template = opts.template;
|
|
2266
2348
|
if (template) {
|
|
2267
|
-
const validTemplates = ["react", "nextjs", "chatbot", "crm", "e-commerce", "todo"];
|
|
2268
|
-
if (!validTemplates.includes(template)) {
|
|
2269
|
-
throw new CLIError(`Invalid template "${template}". Valid options: ${validTemplates.join(", ")}`);
|
|
2270
|
-
}
|
|
2271
2349
|
let dirName = project.name;
|
|
2272
2350
|
if (!json) {
|
|
2273
2351
|
const inputDir = await text2({
|
|
@@ -2295,12 +2373,7 @@ function registerProjectLinkCommand(program2) {
|
|
|
2295
2373
|
process.chdir(templateDir);
|
|
2296
2374
|
saveProjectConfig(projectConfig);
|
|
2297
2375
|
captureEvent(orgId ?? project.organization_id, "template_selected", { template, source: "link" });
|
|
2298
|
-
|
|
2299
|
-
if (githubTemplates.includes(template)) {
|
|
2300
|
-
await downloadGitHubTemplate(template, projectConfig, json);
|
|
2301
|
-
} else {
|
|
2302
|
-
await downloadTemplate(template, projectConfig, project.name, json, apiUrl);
|
|
2303
|
-
}
|
|
2376
|
+
await downloadGitHubTemplate(template, projectConfig, json);
|
|
2304
2377
|
const templateDownloaded = await fs4.stat(path4.join(process.cwd(), "package.json")).catch(() => null);
|
|
2305
2378
|
if (templateDownloaded && !json) {
|
|
2306
2379
|
const installSpinner = clack8.spinner();
|
|
@@ -5529,7 +5602,7 @@ function registerDiagnoseCommands(diagnoseCmd2) {
|
|
|
5529
5602
|
const s = !json ? clack10.spinner() : null;
|
|
5530
5603
|
s?.start("Collecting diagnostic data...");
|
|
5531
5604
|
const data2 = await collectDiagnosticData(projectId, ossMode, apiUrl);
|
|
5532
|
-
const cliVersion = "0.1.
|
|
5605
|
+
const cliVersion = "0.1.57";
|
|
5533
5606
|
s?.stop("Data collected");
|
|
5534
5607
|
if (!json) {
|
|
5535
5608
|
console.log(`
|