@insforge/cli 0.1.60 → 0.1.61
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 +71 -13
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
// src/index.ts
|
|
4
4
|
import { readFileSync as readFileSync7 } from "fs";
|
|
5
|
-
import { join as
|
|
5
|
+
import { join as join13, dirname } from "path";
|
|
6
6
|
import { fileURLToPath } from "url";
|
|
7
7
|
import { Command } from "commander";
|
|
8
8
|
import * as clack11 from "@clack/prompts";
|
|
@@ -4844,11 +4844,13 @@ function registerComputeLogsCommand(computeCmd2) {
|
|
|
4844
4844
|
}
|
|
4845
4845
|
|
|
4846
4846
|
// src/commands/compute/deploy.ts
|
|
4847
|
-
import { existsSync as
|
|
4848
|
-
import { join as
|
|
4847
|
+
import { existsSync as existsSync8 } from "fs";
|
|
4848
|
+
import { join as join12, resolve as resolve4 } from "path";
|
|
4849
4849
|
|
|
4850
4850
|
// src/lib/flyctl.ts
|
|
4851
4851
|
import { spawn, spawnSync } from "child_process";
|
|
4852
|
+
import { existsSync as existsSync7, writeFileSync as writeFileSync5, unlinkSync as unlinkSync2 } from "fs";
|
|
4853
|
+
import { join as join11 } from "path";
|
|
4852
4854
|
function ensureFlyctlAvailable() {
|
|
4853
4855
|
const r = spawnSync("flyctl", ["version"], {
|
|
4854
4856
|
encoding: "utf8",
|
|
@@ -4860,8 +4862,41 @@ function ensureFlyctlAvailable() {
|
|
|
4860
4862
|
);
|
|
4861
4863
|
}
|
|
4862
4864
|
}
|
|
4865
|
+
function ensureFlyTomlStub(opts) {
|
|
4866
|
+
const path5 = join11(opts.dir, "fly.toml");
|
|
4867
|
+
if (existsSync7(path5)) {
|
|
4868
|
+
return () => {
|
|
4869
|
+
};
|
|
4870
|
+
}
|
|
4871
|
+
const stub = `# Auto-generated by @insforge/cli for compute deploy. Safe to delete.
|
|
4872
|
+
app = "${opts.appId}"
|
|
4873
|
+
primary_region = "${opts.region}"
|
|
4874
|
+
|
|
4875
|
+
[build]
|
|
4876
|
+
|
|
4877
|
+
[http_service]
|
|
4878
|
+
internal_port = ${opts.port}
|
|
4879
|
+
force_https = true
|
|
4880
|
+
auto_stop_machines = false
|
|
4881
|
+
auto_start_machines = true
|
|
4882
|
+
min_machines_running = 0
|
|
4883
|
+
`;
|
|
4884
|
+
writeFileSync5(path5, stub, "utf8");
|
|
4885
|
+
return () => {
|
|
4886
|
+
try {
|
|
4887
|
+
unlinkSync2(path5);
|
|
4888
|
+
} catch {
|
|
4889
|
+
}
|
|
4890
|
+
};
|
|
4891
|
+
}
|
|
4863
4892
|
function flyctlBuildAndPush(opts) {
|
|
4864
4893
|
return new Promise((resolve5, reject) => {
|
|
4894
|
+
const cleanupStub = ensureFlyTomlStub({
|
|
4895
|
+
dir: opts.dir,
|
|
4896
|
+
appId: opts.appId,
|
|
4897
|
+
region: opts.region,
|
|
4898
|
+
port: opts.port
|
|
4899
|
+
});
|
|
4865
4900
|
const child = spawn(
|
|
4866
4901
|
"flyctl",
|
|
4867
4902
|
[
|
|
@@ -4893,9 +4928,11 @@ function flyctlBuildAndPush(opts) {
|
|
|
4893
4928
|
process.stderr.write(s);
|
|
4894
4929
|
});
|
|
4895
4930
|
child.on("error", (err) => {
|
|
4931
|
+
cleanupStub();
|
|
4896
4932
|
reject(new CLIError(`flyctl deploy could not start: ${err.message}`));
|
|
4897
4933
|
});
|
|
4898
4934
|
child.on("exit", (code) => {
|
|
4935
|
+
cleanupStub();
|
|
4899
4936
|
if (code !== 0) {
|
|
4900
4937
|
return reject(
|
|
4901
4938
|
new CLIError(`flyctl deploy --build-only failed (exit ${code}). See output above.`)
|
|
@@ -5003,8 +5040,8 @@ function registerComputeDeployCommand(computeCmd2) {
|
|
|
5003
5040
|
return;
|
|
5004
5041
|
}
|
|
5005
5042
|
const absDir = resolve4(dir);
|
|
5006
|
-
const dockerfilePath =
|
|
5007
|
-
if (!
|
|
5043
|
+
const dockerfilePath = join12(absDir, "Dockerfile");
|
|
5044
|
+
if (!existsSync8(dockerfilePath)) {
|
|
5008
5045
|
throw new CLIError(
|
|
5009
5046
|
`No Dockerfile at ${dockerfilePath}.
|
|
5010
5047
|
Either:
|
|
@@ -5046,12 +5083,33 @@ function registerComputeDeployCommand(computeCmd2) {
|
|
|
5046
5083
|
const tokenJson = await tokenRes.json();
|
|
5047
5084
|
const imageLabel = `cli-${Date.now()}`;
|
|
5048
5085
|
if (!json) outputInfo(`Building & pushing on Fly remote builder...`);
|
|
5049
|
-
|
|
5050
|
-
|
|
5051
|
-
|
|
5052
|
-
|
|
5053
|
-
|
|
5054
|
-
|
|
5086
|
+
let imageRef;
|
|
5087
|
+
try {
|
|
5088
|
+
({ imageRef } = await flyctlBuildAndPush({
|
|
5089
|
+
dir: absDir,
|
|
5090
|
+
appId: flyAppId,
|
|
5091
|
+
imageLabel,
|
|
5092
|
+
token: tokenJson.token,
|
|
5093
|
+
region: opts.region,
|
|
5094
|
+
port
|
|
5095
|
+
}));
|
|
5096
|
+
} catch (buildErr) {
|
|
5097
|
+
if (!existing) {
|
|
5098
|
+
try {
|
|
5099
|
+
await ossFetch(`/api/compute/services/${encodeURIComponent(serviceId)}`, {
|
|
5100
|
+
method: "DELETE"
|
|
5101
|
+
});
|
|
5102
|
+
if (!json) outputInfo(`Rolled back service "${opts.name}" after build failure.`);
|
|
5103
|
+
} catch {
|
|
5104
|
+
if (!json) {
|
|
5105
|
+
outputInfo(
|
|
5106
|
+
`Build failed and rollback also failed. Run: npx @insforge/cli compute delete ${serviceId}`
|
|
5107
|
+
);
|
|
5108
|
+
}
|
|
5109
|
+
}
|
|
5110
|
+
}
|
|
5111
|
+
throw buildErr;
|
|
5112
|
+
}
|
|
5055
5113
|
if (!json) outputInfo("Launching machine...");
|
|
5056
5114
|
const updateBody = {
|
|
5057
5115
|
imageUrl: imageRef,
|
|
@@ -5761,7 +5819,7 @@ function registerDiagnoseCommands(diagnoseCmd2) {
|
|
|
5761
5819
|
const s = !json ? clack10.spinner() : null;
|
|
5762
5820
|
s?.start("Collecting diagnostic data...");
|
|
5763
5821
|
const data2 = await collectDiagnosticData(projectId, ossMode, apiUrl);
|
|
5764
|
-
const cliVersion = "0.1.
|
|
5822
|
+
const cliVersion = "0.1.61";
|
|
5765
5823
|
s?.stop("Data collected");
|
|
5766
5824
|
if (!json) {
|
|
5767
5825
|
console.log(`
|
|
@@ -5990,7 +6048,7 @@ function formatBytesCompact(bytes) {
|
|
|
5990
6048
|
|
|
5991
6049
|
// src/index.ts
|
|
5992
6050
|
var __dirname = dirname(fileURLToPath(import.meta.url));
|
|
5993
|
-
var pkg = JSON.parse(readFileSync7(
|
|
6051
|
+
var pkg = JSON.parse(readFileSync7(join13(__dirname, "../package.json"), "utf-8"));
|
|
5994
6052
|
var INSFORGE_LOGO = `
|
|
5995
6053
|
\u2588\u2588\u2557\u2588\u2588\u2588\u2557 \u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557
|
|
5996
6054
|
\u2588\u2588\u2551\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D\u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D\u2588\u2588\u2554\u2550\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D \u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D
|