@insforge/cli 0.1.30 → 0.1.31
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 +32 -30
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -106,6 +106,10 @@ var ProjectNotLinkedError = class extends CLIError {
|
|
|
106
106
|
super("No project linked. Run `insforge link` first.", 3, "PROJECT_NOT_LINKED");
|
|
107
107
|
}
|
|
108
108
|
};
|
|
109
|
+
function getDeploymentError(metadata) {
|
|
110
|
+
if (!metadata || typeof metadata.error !== "object" || !metadata.error) return null;
|
|
111
|
+
return metadata.error.errorMessage ?? null;
|
|
112
|
+
}
|
|
109
113
|
function handleError(err, json) {
|
|
110
114
|
if (err instanceof CLIError) {
|
|
111
115
|
if (json) {
|
|
@@ -708,21 +712,6 @@ ${missing.join("\n")}
|
|
|
708
712
|
`;
|
|
709
713
|
appendFileSync(gitignorePath, block);
|
|
710
714
|
}
|
|
711
|
-
async function installCliGlobally(json) {
|
|
712
|
-
try {
|
|
713
|
-
const { stdout } = await execAsync("npm ls -g @insforge/cli --json", { timeout: 1e4 });
|
|
714
|
-
const parsed = JSON.parse(stdout);
|
|
715
|
-
if (parsed?.dependencies?.["@insforge/cli"]) return;
|
|
716
|
-
} catch {
|
|
717
|
-
}
|
|
718
|
-
try {
|
|
719
|
-
if (!json) clack5.log.info("Installing InsForge CLI globally...");
|
|
720
|
-
await execAsync("npm install -g @insforge/cli", { timeout: 6e4 });
|
|
721
|
-
if (!json) clack5.log.success("InsForge CLI installed. You can now run `insforge` directly.");
|
|
722
|
-
} catch {
|
|
723
|
-
if (!json) clack5.log.warn("Failed to install CLI globally. You can run manually: npm install -g @insforge/cli");
|
|
724
|
-
}
|
|
725
|
-
}
|
|
726
715
|
async function installSkills(json) {
|
|
727
716
|
try {
|
|
728
717
|
if (!json) clack5.log.info("Installing InsForge agent skills...");
|
|
@@ -822,7 +811,6 @@ function registerProjectLinkCommand(program2) {
|
|
|
822
811
|
} else {
|
|
823
812
|
outputSuccess(`Linked to direct project at ${projectConfig2.oss_host}`);
|
|
824
813
|
}
|
|
825
|
-
await installCliGlobally(json);
|
|
826
814
|
await installSkills(json);
|
|
827
815
|
await reportCliUsage("cli.link_direct", true, 6);
|
|
828
816
|
return;
|
|
@@ -831,7 +819,7 @@ function registerProjectLinkCommand(program2) {
|
|
|
831
819
|
handleError(err, json);
|
|
832
820
|
}
|
|
833
821
|
}
|
|
834
|
-
await requireAuth(apiUrl, false);
|
|
822
|
+
const creds = await requireAuth(apiUrl, false);
|
|
835
823
|
let orgId = opts.orgId;
|
|
836
824
|
let projectId = opts.projectId;
|
|
837
825
|
if (!orgId && !projectId) {
|
|
@@ -873,10 +861,24 @@ function registerProjectLinkCommand(program2) {
|
|
|
873
861
|
if (clack6.isCancel(selected)) process.exit(0);
|
|
874
862
|
projectId = selected;
|
|
875
863
|
}
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
864
|
+
let project;
|
|
865
|
+
let apiKey;
|
|
866
|
+
try {
|
|
867
|
+
[project, apiKey] = await Promise.all([
|
|
868
|
+
getProject(projectId, apiUrl),
|
|
869
|
+
getProjectApiKey(projectId, apiUrl)
|
|
870
|
+
]);
|
|
871
|
+
} catch (err) {
|
|
872
|
+
if (err instanceof CLIError && (err.exitCode === 5 || err.exitCode === 4 || err.message.includes("not found"))) {
|
|
873
|
+
const identity = creds.user?.email ?? creds.user?.name ?? "unknown user";
|
|
874
|
+
throw new CLIError(
|
|
875
|
+
`You're logged in as ${identity}, and you don't have access to project ${projectId}. Check that the project ID is correct and belongs to one of your organizations.`,
|
|
876
|
+
5,
|
|
877
|
+
"PERMISSION_DENIED"
|
|
878
|
+
);
|
|
879
|
+
}
|
|
880
|
+
throw err;
|
|
881
|
+
}
|
|
880
882
|
const projectConfig = {
|
|
881
883
|
project_id: project.id,
|
|
882
884
|
project_name: project.name,
|
|
@@ -892,7 +894,6 @@ function registerProjectLinkCommand(program2) {
|
|
|
892
894
|
} else {
|
|
893
895
|
outputSuccess(`Linked to project "${project.name}" (${project.appkey}.${project.region})`);
|
|
894
896
|
}
|
|
895
|
-
await installCliGlobally(json);
|
|
896
897
|
await installSkills(json);
|
|
897
898
|
await reportCliUsage("cli.link", true, 6);
|
|
898
899
|
} catch (err) {
|
|
@@ -1942,12 +1943,13 @@ async function deployProject(opts) {
|
|
|
1942
1943
|
try {
|
|
1943
1944
|
const statusRes = await ossFetch(`/api/deployments/${deploymentId}`);
|
|
1944
1945
|
deployment = await statusRes.json();
|
|
1945
|
-
|
|
1946
|
+
const status = deployment.status.toUpperCase();
|
|
1947
|
+
if (status === "READY") {
|
|
1946
1948
|
break;
|
|
1947
1949
|
}
|
|
1948
|
-
if (
|
|
1950
|
+
if (status === "ERROR" || status === "CANCELED") {
|
|
1949
1951
|
s?.stop("Deployment failed");
|
|
1950
|
-
throw new CLIError(deployment.
|
|
1952
|
+
throw new CLIError(getDeploymentError(deployment.metadata) ?? `Deployment failed with status: ${deployment.status}`);
|
|
1951
1953
|
}
|
|
1952
1954
|
const elapsed = Math.round((Date.now() - startTime) / 1e3);
|
|
1953
1955
|
s?.message(`Building and deploying... (${elapsed}s, status: ${deployment.status})`);
|
|
@@ -1955,8 +1957,8 @@ async function deployProject(opts) {
|
|
|
1955
1957
|
if (err instanceof CLIError) throw err;
|
|
1956
1958
|
}
|
|
1957
1959
|
}
|
|
1958
|
-
const isReady = deployment?.status === "
|
|
1959
|
-
const liveUrl = isReady ? deployment?.
|
|
1960
|
+
const isReady = deployment?.status.toUpperCase() === "READY";
|
|
1961
|
+
const liveUrl = isReady ? deployment?.url ?? null : null;
|
|
1960
1962
|
return { deploymentId, deployment, isReady, liveUrl };
|
|
1961
1963
|
}
|
|
1962
1964
|
function registerDeploymentsDeployCommand(deploymentsCmd2) {
|
|
@@ -2136,7 +2138,6 @@ function registerCreateCommand(program2) {
|
|
|
2136
2138
|
} else if (hasTemplate) {
|
|
2137
2139
|
await downloadTemplate(template, projectConfig, projectName, json, apiUrl);
|
|
2138
2140
|
}
|
|
2139
|
-
await installCliGlobally(json);
|
|
2140
2141
|
await installSkills(json);
|
|
2141
2142
|
await reportCliUsage("cli.create", true, 6);
|
|
2142
2143
|
if (hasTemplate) {
|
|
@@ -2469,6 +2470,7 @@ function registerDeploymentsStatusCommand(deploymentsCmd2) {
|
|
|
2469
2470
|
if (json) {
|
|
2470
2471
|
outputJson(d);
|
|
2471
2472
|
} else {
|
|
2473
|
+
const errorMessage = getDeploymentError(d.metadata);
|
|
2472
2474
|
outputTable(
|
|
2473
2475
|
["Field", "Value"],
|
|
2474
2476
|
[
|
|
@@ -2476,10 +2478,10 @@ function registerDeploymentsStatusCommand(deploymentsCmd2) {
|
|
|
2476
2478
|
["Status", d.status],
|
|
2477
2479
|
["Provider", d.provider ?? "-"],
|
|
2478
2480
|
["Provider ID", d.providerDeploymentId ?? "-"],
|
|
2479
|
-
["URL", d.
|
|
2481
|
+
["URL", d.url ?? "-"],
|
|
2480
2482
|
["Created", new Date(d.createdAt).toLocaleString()],
|
|
2481
2483
|
["Updated", new Date(d.updatedAt).toLocaleString()],
|
|
2482
|
-
...
|
|
2484
|
+
...errorMessage ? [["Error", errorMessage]] : []
|
|
2483
2485
|
]
|
|
2484
2486
|
);
|
|
2485
2487
|
}
|