layero 0.1.2 → 0.1.4
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/bin/layero.js +6 -1
- package/dist/commands/deploy.js +14 -4
- package/package.json +1 -1
package/dist/bin/layero.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import { readFileSync } from "node:fs";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
import path from "node:path";
|
|
2
5
|
import { Command } from "commander";
|
|
3
6
|
import chalk from "chalk";
|
|
4
7
|
import { whoamiCmd } from "../commands/whoami.js";
|
|
@@ -8,7 +11,9 @@ import { linkCmd } from "../commands/link.js";
|
|
|
8
11
|
import { tokenSetCmd } from "../commands/token.js";
|
|
9
12
|
import { deployCmd } from "../commands/deploy.js";
|
|
10
13
|
import { loginCmd } from "../commands/login.js";
|
|
11
|
-
|
|
14
|
+
// Read version from the shipped package.json (two levels up from dist/bin/).
|
|
15
|
+
const pkgPath = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..", "..", "package.json");
|
|
16
|
+
const VERSION = JSON.parse(readFileSync(pkgPath, "utf-8")).version;
|
|
12
17
|
async function main() {
|
|
13
18
|
const program = new Command();
|
|
14
19
|
program
|
package/dist/commands/deploy.js
CHANGED
|
@@ -2,9 +2,9 @@ import { promises as fs } from "node:fs";
|
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import readline from "node:readline/promises";
|
|
4
4
|
import chalk from "chalk";
|
|
5
|
-
import { ApiClient, uploadArchive } from "../api.js";
|
|
5
|
+
import { ApiClient, ApiError, uploadArchive } from "../api.js";
|
|
6
6
|
import { loadConfig } from "../config.js";
|
|
7
|
-
import { loadProjectConfig, saveProjectConfig, } from "../project-config.js";
|
|
7
|
+
import { loadProjectConfig, projectConfigPath, saveProjectConfig, } from "../project-config.js";
|
|
8
8
|
import { packCwd } from "../pack.js";
|
|
9
9
|
import { streamDeployLogs } from "../logs.js";
|
|
10
10
|
const VALID_TYPES = new Set([
|
|
@@ -60,8 +60,18 @@ async function resolveProject(api, cwd, opts) {
|
|
|
60
60
|
}
|
|
61
61
|
const existing = await loadProjectConfig(cwd);
|
|
62
62
|
if (existing) {
|
|
63
|
-
|
|
64
|
-
|
|
63
|
+
try {
|
|
64
|
+
const project = await api.getProject(existing.project_id);
|
|
65
|
+
return { project, createdNow: false };
|
|
66
|
+
}
|
|
67
|
+
catch (err) {
|
|
68
|
+
if (err instanceof ApiError && err.status === 404) {
|
|
69
|
+
throw new Error(`linked project ${existing.project_id} no longer exists or isn't on your account.\n` +
|
|
70
|
+
` fix: delete ${projectConfigPath(cwd)} and re-run \`layero deploy\` (creates a new project),\n` +
|
|
71
|
+
` or run \`layero link <id_or_slug>\` to point at an existing one.`);
|
|
72
|
+
}
|
|
73
|
+
throw err;
|
|
74
|
+
}
|
|
65
75
|
}
|
|
66
76
|
// No project_id locally — create one.
|
|
67
77
|
const me = await api.me();
|