layero 0.1.3 → 0.1.5

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.
@@ -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
- const project = await api.getProject(existing.project_id);
64
- return { project, createdNow: false };
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();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "layero",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "description": "Layero CLI — publish a local site with one command.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -12,12 +12,14 @@
12
12
  },
13
13
  "files": [
14
14
  "dist",
15
+ "scripts/postinstall.cjs",
15
16
  "README.md"
16
17
  ],
17
18
  "scripts": {
18
19
  "build": "tsc -p tsconfig.json",
19
20
  "prepublishOnly": "npm run build",
20
- "dev": "tsc -p tsconfig.json --watch"
21
+ "dev": "tsc -p tsconfig.json --watch",
22
+ "postinstall": "node scripts/postinstall.cjs || true"
21
23
  },
22
24
  "dependencies": {
23
25
  "chalk": "^5.3.0",
@@ -0,0 +1,38 @@
1
+ #!/usr/bin/env node
2
+ // Print a quick-start banner after `npm install -g layero`.
3
+ // Stays silent in CI, in non-TTY (piped/automated installs), and when
4
+ // installed as a transitive dependency.
5
+
6
+ if (process.env.CI) return;
7
+ if (process.env.LAYERO_SKIP_POSTINSTALL) return;
8
+ if (!process.stdout.isTTY) return;
9
+
10
+ // Only print when the user installed `layero` directly (not as a sub-dep).
11
+ // npm sets npm_config_global=true for `npm install -g`; for local installs
12
+ // we check that this package is the install target via npm_package_name.
13
+ const isGlobal = process.env.npm_config_global === "true";
14
+ const isDirect = process.env.npm_package_name === "layero";
15
+ if (!isGlobal && !isDirect) return;
16
+
17
+ const c = process.stdout.hasColors && process.stdout.hasColors()
18
+ ? {
19
+ reset: "\x1b[0m",
20
+ bold: "\x1b[1m",
21
+ dim: "\x1b[2m",
22
+ cyan: "\x1b[36m",
23
+ green: "\x1b[32m",
24
+ }
25
+ : { reset: "", bold: "", dim: "", cyan: "", green: "" };
26
+
27
+ const lines = [
28
+ "",
29
+ `${c.green}${c.bold}✨ Layero CLI installed${c.reset}`,
30
+ "",
31
+ ` ${c.cyan}layero login${c.reset} ${c.dim}authenticate via browser${c.reset}`,
32
+ ` ${c.cyan}cd your-site && layero deploy${c.reset} ${c.dim}publish current dir${c.reset}`,
33
+ ` ${c.cyan}layero --help${c.reset} ${c.dim}all commands${c.reset}`,
34
+ "",
35
+ ` ${c.dim}Docs: https://layero.ru${c.reset}`,
36
+ "",
37
+ ];
38
+ process.stdout.write(lines.join("\n"));