@coraltravelcenter/b2c-landing-builder 2.3.0 → 2.4.1

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/README.md CHANGED
@@ -33,6 +33,9 @@ b2c-landing-vite update
33
33
  - `block:rename` атомарно переименовывает все файлы блока и обновляет порядок.
34
34
  - `update` проверяет npm registry и показывает команду ручного обновления.
35
35
 
36
+ После успешного выполнения рабочих команд builder коротко проверяет npm
37
+ registry. Если доступна новая стабильная версия, терминал показывает текущую и
38
+ новую версии и команду ручного обновления. Ошибки сети не влияют на работу CLI.
36
39
  Builder никогда не обновляется автоматически:
37
40
 
38
41
  ```bash
@@ -93,8 +96,8 @@ Monkey URL, контейнер и CDN prefix не задаются вручну
93
96
  - контейнер: `#monkey-app`;
94
97
  - CDN prefix: `landing-pages/<project.name>`.
95
98
 
96
- Production CDN Sunmar пока не настроен. `dev` и `check` доступны, но `build`
97
- завершается понятной ошибкой до добавления CDN в preset.
99
+ Для Coral и Sunmar настроены отдельные production CDN. Команда `build`
100
+ автоматически выбирает CDN по `site.preset`.
98
101
 
99
102
  ## Структура проекта
100
103
 
@@ -2,7 +2,15 @@
2
2
 
3
3
  import {runCli} from "../src/cli/index.mjs";
4
4
 
5
- runCli(process.argv.slice(2)).catch((error) => {
5
+ const args = process.argv.slice(2);
6
+
7
+ runCli(args).then(async () => {
8
+ const command = args[0];
9
+ if (!command || ["help", "--help", "-h", "update"].includes(command)) return;
10
+
11
+ const {printUpdateNotice} = await import("../src/update/check-update.mjs");
12
+ await printUpdateNotice();
13
+ }).catch((error) => {
6
14
  console.error(`[b2c-landing-vite] ${error.message}`);
7
15
  process.exitCode = 1;
8
16
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coraltravelcenter/b2c-landing-builder",
3
- "version": "2.3.0",
3
+ "version": "2.4.1",
4
4
  "description": "CLI and build toolkit for B2C landing projects",
5
5
  "type": "module",
6
6
  "bin": {
@@ -23,7 +23,7 @@
23
23
  "dev": "node scripts/run-fixture.mjs dev",
24
24
  "check": "node scripts/run-fixture.mjs check",
25
25
  "build": "node scripts/run-fixture.mjs build",
26
- "test": "node --test test/*.test.mjs",
26
+ "test": "node scripts/run-tests.mjs",
27
27
  "test:dev": "node scripts/smoke-dev.mjs",
28
28
  "pack:check": "npm pack --dry-run"
29
29
  },
@@ -64,3 +64,16 @@ export async function printUpdateStatus(options) {
64
64
  return null;
65
65
  }
66
66
  }
67
+
68
+ export async function printUpdateNotice({log = console.warn, timeoutMs = 1000, ...options} = {}) {
69
+ try {
70
+ const status = await checkForUpdate({...options, timeoutMs});
71
+ if (!status.updateAvailable) return status;
72
+
73
+ log(`New ${PACKAGE_NAME} version available: ${status.currentVersion} → ${status.latestVersion}`);
74
+ log(`Update manually: npm install --global ${PACKAGE_NAME}@latest`);
75
+ return status;
76
+ } catch {
77
+ return null;
78
+ }
79
+ }
@@ -1,5 +1,4 @@
1
1
  import {fileURLToPath} from "node:url";
2
- import path from "node:path";
3
2
 
4
3
  import {createServer} from "vite";
5
4
 
@@ -11,7 +10,11 @@ import {resolveScriptStack} from "../config/script-stack.mjs";
11
10
 
12
11
  const clientEntry = fileURLToPath(new URL("./client.js", import.meta.url));
13
12
  const builderRoot = fileURLToPath(new URL("../../", import.meta.url));
14
- const clientEntryUrl = `/@fs${clientEntry.replaceAll("\\", "/")}`;
13
+ export function toViteFsUrl(filePath) {
14
+ return `/@fs/${filePath.replaceAll("\\", "/").replace(/^\/+/, "")}`;
15
+ }
16
+
17
+ const clientEntryUrl = toViteFsUrl(clientEntry);
15
18
  let monkeyPlugin;
16
19
 
17
20
  async function loadMonkeyPlugin() {
@@ -51,7 +54,7 @@ export async function createViteConfig(root = process.cwd()) {
51
54
  vue && vue(),
52
55
  landingBlocksPlugin({root, stack: config.stack}),
53
56
  monkey({
54
- entry: path.normalize(clientEntryUrl),
57
+ entry: clientEntryUrl,
55
58
  server: {open: shouldOpen, prefix: false},
56
59
  userscript: {
57
60
  name: config.project.name,