layero 0.1.0 → 0.1.2
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/commands/deploy.js +23 -2
- package/dist/commands/login.js +4 -1
- package/package.json +1 -1
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.
|
package/dist/commands/login.js
CHANGED
|
@@ -22,6 +22,7 @@ export async function loginCmd(opts) {
|
|
|
22
22
|
const provider = opts.provider ?? "github";
|
|
23
23
|
const desiredPort = opts.port ?? Number(process.env.LAYERO_LOGIN_PORT ?? 0);
|
|
24
24
|
const tokenPromise = new Promise((resolve, reject) => {
|
|
25
|
+
let timeoutHandle;
|
|
25
26
|
const server = http.createServer(async (req, res) => {
|
|
26
27
|
const url = new URL(req.url ?? "/", "http://127.0.0.1");
|
|
27
28
|
if (url.pathname !== "/callback") {
|
|
@@ -58,6 +59,8 @@ export async function loginCmd(opts) {
|
|
|
58
59
|
"Access-Control-Allow-Origin": "*",
|
|
59
60
|
})
|
|
60
61
|
.end("ok — you can close this tab");
|
|
62
|
+
if (timeoutHandle)
|
|
63
|
+
clearTimeout(timeoutHandle);
|
|
61
64
|
server.close();
|
|
62
65
|
resolve(token);
|
|
63
66
|
});
|
|
@@ -75,7 +78,7 @@ export async function loginCmd(opts) {
|
|
|
75
78
|
// open failure is non-fatal — user can paste the URL manually.
|
|
76
79
|
});
|
|
77
80
|
});
|
|
78
|
-
setTimeout(() => {
|
|
81
|
+
timeoutHandle = setTimeout(() => {
|
|
79
82
|
server.close();
|
|
80
83
|
reject(new Error(`login timed out after ${LOGIN_TIMEOUT_MS / 1000}s`));
|
|
81
84
|
}, LOGIN_TIMEOUT_MS);
|