@ecomcx/create-nexus 1.24.0 → 1.24.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/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @ecomcx/create-nexus
2
2
 
3
- CLI for Ecomcx Nexus CMS themes and plugins: create, validate, pack, test and deploy.
3
+ CLI for ECX Nexus CMS themes and plugins: create, validate, pack, test and deploy.
4
4
 
5
5
  ```bash
6
6
  npm create @ecomcx/nexus theme "My theme" # new theme (code; --blocks for a block theme)
package/bin/cms.mjs CHANGED
@@ -1,13 +1,13 @@
1
1
  #!/usr/bin/env node
2
- // create-cms — tạo, kiểm tra, đóng gói và triển khai theme/plugin cho CMS.
3
- // create-cms theme "Tên" [--parent default] [--blocks] [--dir x]
4
- // create-cms plugin "Tên" [--admin] [--frontend] [--project] [--no-backend] [--tests] [--dir x]
5
- // create-cms validate [thư-mục]
6
- // create-cms upgrade [thư-mục]
7
- // create-cms pack [thư-mục] [--out dist]
8
- // create-cms deploy [thư-mục] [--url …] [--user …] [--password …] [--activate]
9
- // create-cms dev [thư-mục] [--url …] [--user …] [--password …] (tự đóng gói + cài lại khi sửa file)
10
- // create-cms env up | status | down [--purge]
2
+ // create-nexus — tạo, kiểm tra, đóng gói và triển khai theme/plugin cho ECX Nexus.
3
+ // create-nexus theme "Tên" [--parent default] [--blocks] [--dir x]
4
+ // create-nexus plugin "Tên" [--admin] [--frontend] [--project] [--no-backend] [--tests] [--dir x]
5
+ // create-nexus validate [thư-mục]
6
+ // create-nexus upgrade [thư-mục]
7
+ // create-nexus pack [thư-mục] [--out dist]
8
+ // create-nexus deploy [thư-mục] [--url …] [--user …] [--password …] [--activate]
9
+ // create-nexus dev [thư-mục] [--url …] [--user …] [--password …] (tự đóng gói + cài lại khi sửa file)
10
+ // create-nexus env up | status | down [--purge]
11
11
  import { CLI } from "../lib/npm.mjs";
12
12
  import fs from "node:fs";
13
13
  import path from "node:path";
@@ -19,7 +19,7 @@ import { pack } from "../lib/pack.mjs";
19
19
  import { check, deploy } from "../lib/deploy.mjs";
20
20
  import { env, findEnv } from "../lib/env.mjs";
21
21
 
22
- const HELP = `${c.bold("create-cms")} — công cụ viết theme/plugin cho CMS
22
+ const HELP = `${c.bold("create-nexus")} — công cụ viết theme/plugin cho ECX Nexus
23
23
 
24
24
  ${c.cyan('theme "Tên"')} [--parent default] tạo theme (child theme với --parent; --blocks: dựng bằng khối, sửa trong Trình dựng)
25
25
  ${c.cyan('plugin "Tên"')} [--admin] [--frontend] [--tests] tạo plugin: plugin.json + một file C# (CMS tự biên dịch)
@@ -97,7 +97,7 @@ try {
97
97
  case "theme":
98
98
  case "plugin": {
99
99
  const name = rest[0];
100
- if (!name) throw new Error(`Thiếu tên: create-cms ${cmd} "Tên ${cmd}"`);
100
+ if (!name) throw new Error(`Thiếu tên: create-nexus ${cmd} "Tên ${cmd}"`);
101
101
  const { root } = cmd === "theme"
102
102
  ? scaffoldTheme(name, { parent: args.parent, dir: args.dir, blocks: !!args.blocks })
103
103
  : scaffoldPlugin(name, { backend: args["no-backend"] ? false : args.project ? "project" : "source", admin: !!args.admin, frontend: !!args.frontend, tests: !!args.tests, dir: args.dir });
@@ -123,7 +123,7 @@ try {
123
123
  // Đóng gói → chạy dotnet test cho tests/*.csproj (Cms.Plugin.Testing cài gói lên CMS thử một lần rồi chạy test)
124
124
  const testsDir = path.join(dir, "tests");
125
125
  if (!fs.existsSync(testsDir) || !fs.readdirSync(testsDir).some((f) => f.endsWith(".csproj")))
126
- throw new Error("Không thấy tests/*.csproj — tạo bằng: create-cms plugin \"Tên\" --tests (hoặc xem tài liệu Cms.Plugin.Testing)");
126
+ throw new Error("Không thấy tests/*.csproj — tạo bằng: create-nexus plugin \"Tên\" --tests (hoặc xem tài liệu Cms.Plugin.Testing)");
127
127
  const pkg = await packAndReport(dir);
128
128
  const conn = connection();
129
129
  const env = { ...process.env, CMS_TEST_PACKAGE: path.resolve(pkg.zipPath), CMS_TEST_SLUG: pkg.manifest.slug,
package/lib/deploy.mjs CHANGED
@@ -75,7 +75,7 @@ export async function check({ zipPath, kind }, { url, user, password }) {
75
75
  const base = (url ?? process.env.CMS_URL ?? "http://localhost:5100").replace(/\/$/, "");
76
76
  user ??= process.env.CMS_USER ?? "admin";
77
77
  password ??= process.env.CMS_PASSWORD;
78
- if (!password) throw new Error("Thiếu mật khẩu: dùng --password, CMS_PASSWORD hoặc `create-cms env up`");
78
+ if (!password) throw new Error("Thiếu mật khẩu: dùng --password, CMS_PASSWORD hoặc `create-nexus env up`");
79
79
  const login = await fetch(`${base}/api/auth/login`, { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ login: user, password }) });
80
80
  if (!login.ok) throw new Error(`Đăng nhập thất bại (${login.status})`);
81
81
  const { accessToken } = await login.json();
package/lib/env.mjs CHANGED
@@ -1,11 +1,11 @@
1
1
  // Môi trường CMS chạy bằng Docker cho người làm theme/plugin — không cần mã nguồn CMS.
2
- // create-cms env up dựng CMS (Postgres, Redis, API, website, Caddy) + cài đặt sẵn, in tài khoản quản trị
3
- // create-cms env status trạng thái, địa chỉ, tài khoản
4
- // create-cms env down dừng (giữ dữ liệu) · --purge: xoá luôn dữ liệu
5
- // create-cms env logs [api|builder|…] [-f] xem log
2
+ // create-nexus env up dựng CMS (Postgres, Redis, API, website, Caddy) + cài đặt sẵn, in tài khoản quản trị
3
+ // create-nexus env status trạng thái, địa chỉ, tài khoản
4
+ // create-nexus env down dừng (giữ dữ liệu) · --purge: xoá luôn dữ liệu
5
+ // create-nexus env logs [api|builder|…] [-f] xem log
6
6
  // --dev website chạy `next dev`; theme/plugin trong thư mục hiện tại (và thư mục con) được gắn thẳng vào → sửa là thấy
7
7
  // --build DIR build image từ mã nguồn CMS ở DIR (khi chưa kéo được image dựng sẵn)
8
- // Tài khoản được lưu ở .cms-env/credentials.json → `create-cms deploy/dev` tự dùng, không cần --password.
8
+ // Tài khoản được lưu ở .cms-env/credentials.json → `create-nexus deploy/dev` tự dùng, không cần --password.
9
9
  import { CLI } from "./npm.mjs";
10
10
  import crypto from "node:crypto";
11
11
  import fs from "node:fs";
@@ -16,7 +16,7 @@ import { c, readJson, run, write } from "./util.mjs";
16
16
 
17
17
  const cliDir = path.dirname(fileURLToPath(import.meta.url));
18
18
  /** Image dựng sẵn của CMS (đổi bằng --api-image/--builder-image hoặc biến CMS_API_IMAGE/CMS_BUILDER_IMAGE). */
19
- const DEFAULT_IMAGES = { api: "ghcr.io/ecomcx-jsc/ecomcx-nexus-api:latest", builder: "ghcr.io/ecomcx-jsc/ecomcx-nexus-builder:latest" };
19
+ const DEFAULT_IMAGES = { api: "ghcr.io/ecomcx-jsc/ecx-nexus-api:latest", builder: "ghcr.io/ecomcx-jsc/ecx-nexus-builder:latest" };
20
20
 
21
21
  /** Theme/plugin đang viết ở thư mục hiện tại và thư mục con (+ --mount) → gắn vào Builder khi chạy --dev. */
22
22
  export function devMounts(args) {
@@ -35,7 +35,7 @@ export function devMounts(args) {
35
35
  /** File cấu hình đi kèm gói (lib/env/) hoặc lấy từ thư mục deploy/ khi chạy trong repo CMS. */
36
36
  function asset(name) {
37
37
  for (const p of [path.join(cliDir, "env", name), path.resolve(cliDir, "../../../deploy", name)]) if (fs.existsSync(p)) return fs.readFileSync(p, "utf8");
38
- throw new Error(`Thiếu file ${name} của create-cms`);
38
+ throw new Error(`Thiếu file ${name} của create-nexus`);
39
39
  }
40
40
 
41
41
  /** Tìm .cms-env gần nhất (thư mục hiện tại hoặc thư mục cha) — dùng cho deploy/dev. */
@@ -48,7 +48,7 @@ export function findEnv(start = process.cwd()) {
48
48
  }
49
49
 
50
50
  const compose = (o) => `
51
- # Sinh bởi create-cms env — môi trường thử cho theme/plugin. Không dùng cho website thật.
51
+ # Sinh bởi create-nexus env — môi trường thử cho theme/plugin. Không dùng cho website thật.
52
52
  name: ${o.project}
53
53
  services:
54
54
  init:
@@ -133,7 +133,7 @@ export async function env(action, args) {
133
133
  const buildDir = args.build ? path.resolve(args.build) : saved?.buildDir;
134
134
  const mounts = dev ? devMounts(args) : [];
135
135
  // Môi trường đang chạy dùng lại cổng của nó; môi trường mới thì cổng phải trống
136
- if (!saved && !(await portFree(port))) throw new Error(`Cổng ${port} đang được dùng — chọn cổng khác: create-cms env up --port ${port + 1}`);
136
+ if (!saved && !(await portFree(port))) throw new Error(`Cổng ${port} đang được dùng — chọn cổng khác: create-nexus env up --port ${port + 1}`);
137
137
  write(path.join(dir, "docker-compose.yml"), compose({ project, port, url, apiImage, builderImage, dev, buildDir, mounts }));
138
138
  write(path.join(dir, "Caddyfile"), asset("Caddyfile"));
139
139
  write(path.join(dir, "init-secrets.sh"), asset("init-secrets.sh"));
@@ -153,7 +153,7 @@ export async function env(action, args) {
153
153
  try { if (missing.length) await dc("pull", ...missing); }
154
154
  catch (e) {
155
155
  throw new Error(`Không kéo được image CMS (${apiImage}). Image có thể chưa được phát hành công khai.\n`
156
- + ` Có mã nguồn CMS: create-cms env up --build <thư-mục-mã-nguồn>\n Hoặc chỉ định image khác: --api-image … --builder-image …\n Chi tiết: ${e.message.split("\n").slice(-2).join(" ")}`);
156
+ + ` Có mã nguồn CMS: create-nexus env up --build <thư-mục-mã-nguồn>\n Hoặc chỉ định image khác: --api-image … --builder-image …\n Chi tiết: ${e.message.split("\n").slice(-2).join(" ")}`);
157
157
  }
158
158
  }
159
159
  try { await dc("up", "-d"); }
@@ -225,11 +225,11 @@ export async function env(action, args) {
225
225
  if (saved.password) printInfo(saved, dir); else console.log(` Website ${saved.url} (chưa cài đặt hoặc tự cài bằng màn hình cài đặt)`);
226
226
  return;
227
227
  }
228
- throw new Error("Dùng: create-cms env up [--dev] [--build DIR] | status | logs [dịch vụ] [-f] | down [--purge]");
228
+ throw new Error("Dùng: create-nexus env up [--dev] [--build DIR] | status | logs [dịch vụ] [-f] | down [--purge]");
229
229
  }
230
230
 
231
231
  function printInfo(cred, dir) {
232
232
  console.log(` Website ${cred.url}`);
233
233
  console.log(` Quản trị ${cred.url}/admin (${cred.user} / ${cred.password})`);
234
- console.log(c.dim(` Tài khoản lưu ở ${path.relative(process.cwd(), path.join(dir, "credentials.json"))} — \`create-cms dev\` tự dùng.`));
234
+ console.log(c.dim(` Tài khoản lưu ở ${path.relative(process.cwd(), path.join(dir, "credentials.json"))} — \`create-nexus dev\` tự dùng.`));
235
235
  }
package/lib/scaffold.mjs CHANGED
@@ -31,7 +31,7 @@ export function scaffoldTheme(name, { parent, dir, blocks = false } = {}) {
31
31
  for (const [code, dict] of Object.entries(labels)) write(path.join(root, "locales", `${code}.json`), JSON.stringify(dict, null, 2) + "\n");
32
32
 
33
33
  write(path.join(root, "package.json"), JSON.stringify({
34
- name: `cms-theme-${slug}`, private: true, version: "1.0.0",
34
+ name: `nexus-theme-${slug}`, private: true, version: "1.0.0",
35
35
  description: "Thêm dependencies npm mà theme cần vào đây — Builder sẽ tự cài khi build.",
36
36
  dependencies: {},
37
37
  devDependencies: {
@@ -164,7 +164,7 @@ export default definePlugin({
164
164
  },
165
165
  });
166
166
  `);
167
- write(path.join(root, "README.md"), `# ${name}\n\nTheme cho CMS.\n\n- \`npx ${CLI} validate\` — kiểm tra theme\n- \`npx ${CLI} pack\` — đóng gói thành zip để upload trong Giao diện › Thêm mới\n- \`npx ${CLI} dev --password ...\` — tự đóng gói và cài lên CMS local mỗi khi sửa file\n`);
167
+ write(path.join(root, "README.md"), `# ${name}\n\nTheme cho ECX Nexus.\n\n- \`npx ${CLI} validate\` — kiểm tra theme\n- \`npx ${CLI} pack\` — đóng gói thành zip để upload trong Giao diện › Thêm mới\n- \`npx ${CLI} dev --password ...\` — tự đóng gói và cài lên ECX Nexus trên máy mỗi khi sửa file\n`);
168
168
  return { root, slug };
169
169
  }
170
170
 
@@ -258,7 +258,7 @@ export function scaffoldSimplePlugin(name, { dir, tests = false } = {}) {
258
258
  return scaffoldPlugin(name, { dir, tests });
259
259
  }
260
260
 
261
- /** Dự án test xUnit dùng Cms.Plugin.Testing — chạy bằng `create-cms test` (cần .NET SDK). */
261
+ /** Dự án test xUnit dùng EcxNexus.Plugin.Testing (namespace Cms.Plugin.Testing) — chạy bằng `create-nexus test` (cần .NET SDK). */
262
262
  function scaffoldTests(root, cls, slug) {
263
263
  write(path.join(root, "tests", `${cls}.Tests.csproj`), `<Project Sdk="Microsoft.NET.Sdk">
264
264
  <PropertyGroup>
@@ -268,7 +268,7 @@ function scaffoldTests(root, cls, slug) {
268
268
  <IsPackable>false</IsPackable>
269
269
  </PropertyGroup>
270
270
  <ItemGroup>
271
- <PackageReference Include="Cms.Plugin.Testing" Version="1.8.0" />
271
+ <PackageReference Include="EcxNexus.Plugin.Testing" Version="1.12.0" />
272
272
  <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.1" />
273
273
  <PackageReference Include="xunit" Version="2.9.3" />
274
274
  <PackageReference Include="xunit.runner.visualstudio" Version="3.1.4" />
@@ -280,7 +280,7 @@ using System.Net.Http.Json;
280
280
  using Cms.Plugin.Testing;
281
281
  using Xunit;
282
282
 
283
- /// Chạy: create-cms env up (một lần) rồi create-cms test — gói plugin được cài + bật trên CMS thử.
283
+ /// Chạy: create-nexus env up (một lần) rồi create-nexus test — gói plugin được cài + bật trên CMS thử.
284
284
  public class ${cls}Tests : PluginTest
285
285
  {
286
286
  [Fact]
@@ -350,7 +350,7 @@ export function scaffoldPlugin(name, { backend = "source", admin = false, fronte
350
350
 
351
351
  if (backend === "project") {
352
352
  const repo = findCmsRepo(root);
353
- // Nguồn Cms.Plugin.Sdk: nuget.org; thêm feed local khi ở trong repo CMS hoặc khi đặt CMS_NUGET_FEED (thư mục chứa .nupkg)
353
+ // Nguồn EcxNexus.Plugin.Sdk: nuget.org; thêm feed local khi ở trong repo CMS hoặc khi đặt CMS_NUGET_FEED (thư mục chứa .nupkg)
354
354
  const feed = process.env.CMS_NUGET_FEED ? path.resolve(process.env.CMS_NUGET_FEED) : repo ? path.join(repo, "sdk", "nuget") : null;
355
355
  write(path.join(root, "backend", `${cls}.csproj`), `
356
356
  <Project Sdk="Microsoft.NET.Sdk">
@@ -365,7 +365,7 @@ export function scaffoldPlugin(name, { backend = "source", admin = false, fronte
365
365
  </PropertyGroup>
366
366
  <ItemGroup>
367
367
  <FrameworkReference Include="Microsoft.AspNetCore.App" />
368
- <PackageReference Include="Cms.Plugin.Sdk" Version="1.8.0">
368
+ <PackageReference Include="EcxNexus.Plugin.Sdk" Version="1.12.0">
369
369
  <Private>false</Private>
370
370
  <ExcludeAssets>runtime</ExcludeAssets>
371
371
  </PackageReference>
@@ -469,7 +469,7 @@ export default definePlugin({
469
469
  if (admin) devDeps[ADMIN_SDK] = `^${VERSION}`;
470
470
  if (frontend) devDeps[THEME_SDK] = `^${VERSION}`;
471
471
  write(path.join(root, "package.json"), JSON.stringify({
472
- name: `cms-plugin-${slug}`, private: true, version: "1.0.0",
472
+ name: `nexus-plugin-${slug}`, private: true, version: "1.0.0",
473
473
  description: `Dependencies cho giao diện admin/frontend của plugin ${name}`,
474
474
  dependencies: {},
475
475
  devDependencies: devDeps,
package/package.json CHANGED
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "name": "@ecomcx/create-nexus",
3
- "version": "1.24.0",
4
- "description": "CLI tạo, kiểm tra, đóng gói và triển khai theme/plugin cho CMS",
3
+ "version": "1.24.2",
4
+ "description": "CLI tạo, kiểm tra, đóng gói và triển khai theme/plugin cho ECX Nexus",
5
5
  "type": "module",
6
6
  "bin": {
7
7
  "create-nexus": "bin/cms.mjs",
8
+ "nexus": "bin/cms.mjs",
8
9
  "create-cms": "bin/cms.mjs",
9
10
  "cms": "bin/cms.mjs"
10
11
  },
@@ -14,7 +15,7 @@
14
15
  "README.md"
15
16
  ],
16
17
  "dependencies": {
17
- "@ecomcx/nexus-admin-sdk": "1.24.0",
18
+ "@ecomcx/nexus-admin-sdk": "1.24.2",
18
19
  "@ecomcx/nexus-content": "^1.13.0",
19
20
  "adm-zip": "0.5.18",
20
21
  "esbuild": "0.25.12",
@@ -25,10 +26,10 @@
25
26
  },
26
27
  "repository": {
27
28
  "type": "git",
28
- "url": "git+https://github.com/Ecomcx-Jsc/ecomcx-sdk.git",
29
+ "url": "git+https://github.com/Ecomcx-Jsc/ecx-nexus-sdk.git",
29
30
  "directory": "packages/create-cms"
30
31
  },
31
- "homepage": "https://github.com/Ecomcx-Jsc/ecomcx-sdk#readme",
32
+ "homepage": "https://github.com/Ecomcx-Jsc/ecx-nexus-sdk#readme",
32
33
  "license": "MIT",
33
34
  "publishConfig": {
34
35
  "access": "public",