layero 0.1.1 → 0.1.3
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 +23 -2
- 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
|
@@ -19,6 +19,22 @@ const VALID_TYPES = new Set([
|
|
|
19
19
|
"gatsby",
|
|
20
20
|
"static",
|
|
21
21
|
]);
|
|
22
|
+
function dashboardUrl(apiUrl, projectId) {
|
|
23
|
+
// api.layero.ru → app.layero.ru. Falls back to app.layero.ru for any
|
|
24
|
+
// unrecognized api base (incl. localhost) — the user can override via
|
|
25
|
+
// LAYERO_DASHBOARD_URL if they're pointed at a non-standard env.
|
|
26
|
+
const override = process.env.LAYERO_DASHBOARD_URL;
|
|
27
|
+
if (override)
|
|
28
|
+
return `${override.replace(/\/+$/, "")}/projects/${projectId}`;
|
|
29
|
+
try {
|
|
30
|
+
const u = new URL(apiUrl);
|
|
31
|
+
u.hostname = u.hostname.replace(/^api\./, "app.");
|
|
32
|
+
return `${u.origin}/projects/${projectId}`;
|
|
33
|
+
}
|
|
34
|
+
catch {
|
|
35
|
+
return `https://app.layero.ru/projects/${projectId}`;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
22
38
|
async function prompt(question, fallback) {
|
|
23
39
|
const rl = readline.createInterface({
|
|
24
40
|
input: process.stdin,
|
|
@@ -83,8 +99,12 @@ export async function deployCmd(opts) {
|
|
|
83
99
|
throw new Error(`project "${project.slug}" is a GitHub-source project; ` +
|
|
84
100
|
"use the dashboard's Deploy button or push to the linked repo.");
|
|
85
101
|
}
|
|
102
|
+
// Project page on the dashboard. CDN propagation lags by ~30-60s after a
|
|
103
|
+
// fresh deploy, so a link to the project page is more useful as the
|
|
104
|
+
// immediate "where to look next" target than the live site URL.
|
|
105
|
+
const projectUrl = dashboardUrl(cfg.apiUrl, project.id);
|
|
86
106
|
if (createdNow) {
|
|
87
|
-
console.log(chalk.green(`created project ${project.slug} →
|
|
107
|
+
console.log(chalk.green(`created project ${project.slug} → ${projectUrl}`));
|
|
88
108
|
}
|
|
89
109
|
console.log(chalk.cyan("packing source..."));
|
|
90
110
|
const pack = await packCwd(cwd, project.slug);
|
|
@@ -108,7 +128,8 @@ export async function deployCmd(opts) {
|
|
|
108
128
|
process.exitCode = 1;
|
|
109
129
|
return;
|
|
110
130
|
}
|
|
111
|
-
console.log(chalk.green(`deploy ready →
|
|
131
|
+
console.log(chalk.green(`deploy ready → ${projectUrl}`));
|
|
132
|
+
console.log(chalk.dim(` site: https://${project.apex_hostname} (CDN may take ~30-60s to propagate)`));
|
|
112
133
|
}
|
|
113
134
|
finally {
|
|
114
135
|
// Always clean up the local archive.
|