@synopackageland/cli 0.54.7 → 0.54.8

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/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.54.8 (2026-11-18)
4
+
5
+ - Use SDK 0.53.50 by default.
6
+ - A short path keeps its address: `https://<nas>:5001/m` stays `/m` in the address bar instead of becoming `/webman/3rdparty/<package>/app/<build>/m/index.html`. The redirect now puts `spl-short=<path>` first in the query; the build puts a small script first in the `<head>` of each `.html` stable page a short path opens (before the UI digest), which adds `<base href>` with the page's real URL and replaces the address with the short path, keeping the rest of the query and the fragment. A short path to `app` is handled by the SDK's entry boot. Reload, bookmarks and Add to Home Screen open the short path, and therefore the current build; the stable page and build URLs keep working and keep their own address. A short path to `app` needs the App's frontend `@synopackageland/sdk` 0.53.50 or later; an older one keeps the marker in the query.
7
+
3
8
  ## 0.54.7 (2026-11-17)
4
9
 
5
10
  - App metadata accepts `screenshots_mobile`, a list of phone screenshots under the same rules as `screenshots` (at most 5 `https://` PNG or JPG URLs). `screenshots` stays the desktop list. The App page on synopkgland.com shows phone screenshots under a Mobile tab; DSM Package Center shows only `screenshots`.
package/README.md CHANGED
@@ -487,6 +487,26 @@ App's short path returns DSM's 404, and an upgrade replaces the file. With
487
487
  `portal`, short paths still stay on DSM's server only: their target,
488
488
  `/webman/3rdparty/`, is not served on 80/443.
489
489
 
490
+ The address bar keeps the short path. The redirect puts `spl-short=<path>`
491
+ first in the query (`/connect` → `…/m/index.html?spl-short=connect&<query>`).
492
+ For a stable page whose target is an `.html` file, the build puts a small
493
+ script first in the target's `<head>` (after the page's own `<base>`, if it
494
+ has one), before the UI digest. On a page with the marker of one of its
495
+ declared paths, the script adds `<base href>` with the page's real URL, so
496
+ relative scripts, styles, images, `fetch` and Expo/Vite chunk URLs keep
497
+ resolving in the build folder, then `history.replaceState` shows
498
+ `/connect?<query>#<fragment>`. A reload, a bookmark or iOS Add to Home Screen
499
+ therefore opens the short path again and lands on the current build. A short
500
+ path to `app` does the same in the SDK's entry boot, which also keeps it
501
+ across a DSM sign-in in the same tab. A page opened without the marker (the
502
+ stable page or build URL itself, an Application Portal domain or port) keeps
503
+ its URL, and the long URLs keep working. Code that reads `location.pathname`
504
+ sees the short path: derive package URLs from `document.baseURI` or a
505
+ relative URL instead. With the `<base>`, a link that is only a fragment
506
+ (`href="#top"`) resolves to the page's real URL and reloads it there. A Web
507
+ App Manifest's `start_url` stays the App's own; Android Chrome's install uses
508
+ it, not the address bar.
509
+
490
510
  `check` refuses the root, DSM and SDK names (the reserved list of custom ingress,
491
511
  including `/mobile`, `/webman`, `/webapi`, `/sharing` and `/synopkgland`), a
492
512
  path that overlaps the package's own ingress, an undeclared page
package/dist/bin.js CHANGED
File without changes
@@ -1 +1 @@
1
- {"module":"github.com/synopackageland/syno-pkg-land-sdk","version":"0.53.26","local":false}
1
+ {"module":"github.com/synopackageland/syno-pkg-land-sdk","version":"0.53.50","local":false}
@@ -1,7 +1,7 @@
1
1
  export { goPrivateCovers } from './go-env.js';
2
2
  import { type ExecutorManifest } from './sdk-executor-manifest.js';
3
3
  /** Pinned SDK for CLI-owned controllers and Compose planning; App pins take precedence. */
4
- export declare const DEFAULT_SDK_VERSION = "0.53.26";
4
+ export declare const DEFAULT_SDK_VERSION = "0.53.50";
5
5
  export declare const SDK_PACKAGE = "@synopackageland/sdk";
6
6
  export declare const SDK_MODULE = "github.com/synopackageland/syno-pkg-land-sdk";
7
7
  export declare const EXECUTOR_MODULE = "github.com/synopackageland/syno-pkg-land-sdk/executor";
@@ -5,7 +5,7 @@ import { tmpdir } from 'node:os';
5
5
  import { join } from 'node:path';
6
6
  import { readExecutorManifest, predatesExecutorManifest } from './sdk-executor-manifest.js';
7
7
  /** Pinned SDK for CLI-owned controllers and Compose planning; App pins take precedence. */
8
- export const DEFAULT_SDK_VERSION = '0.53.26';
8
+ export const DEFAULT_SDK_VERSION = '0.53.50';
9
9
  export const SDK_PACKAGE = '@synopackageland/sdk';
10
10
  export const SDK_MODULE = 'github.com/synopackageland/syno-pkg-land-sdk';
11
11
  export const EXECUTOR_MODULE = `${SDK_MODULE}/executor`;
@@ -9,10 +9,20 @@ import { type StablePages } from "./stable-pages.js";
9
9
  * relative Location: no proxy, no upstream, no cookie and no package code runs,
10
10
  * so they widen no access. The browser keeps the query (passed on) and the
11
11
  * fragment (never sent to the server, kept across the redirect).
12
+ *
13
+ * The redirect puts `spl-short=<path>` first in the query. The page it opens
14
+ * then shows the short path in the address bar again (history.replaceState),
15
+ * with a `<base>` that keeps its relative URLs on the page's own folder: a
16
+ * stable page's target through the landing script below, the entry page
17
+ * through the SDK's entry boot. Only a page reached through the short path
18
+ * has the marker, so a page opened on another origin (an Application Portal
19
+ * domain or port, where the short path does not exist) keeps its own URL.
12
20
  */
13
21
  export type ShortPaths = Record<string, string>;
14
22
  export declare const SHORT_PATHS_CONFIG = "etc/short-paths-nginx.conf";
15
23
  export declare const SHORT_PATH_LIMIT = 4;
24
+ /** The query parameter the redirect puts first; its value is the path without the leading /. */
25
+ export declare const SHORT_PATH_MARKER = "spl-short";
16
26
  /** Undefined when valid; otherwise why. `stablePages` are the package's declared pages. */
17
27
  export declare function shortPathsProblem(value: unknown, stablePages: StablePages | undefined): string | undefined;
18
28
  /** DSM before 7.2 rejects an unsigned web-config, the worker that adds the locations. */
@@ -28,6 +38,18 @@ export declare function shortPathTarget(pkg: string, page: string): string;
28
38
  * 302 is never cached permanently, so a removed package leaves no stale redirect.
29
39
  */
30
40
  export declare function renderShortPathsConfig(pkg: string, paths: ShortPaths): string;
41
+ /**
42
+ * The script a stable page's target gets first in its head when a short path
43
+ * opens the page. It runs before the page's own scripts: with the marker of a
44
+ * declared path first in the query, it adds `<base href>` with the page's own
45
+ * URL (unless the page has one) and replaces the address with the short path,
46
+ * the rest of the query and the fragment. Anything else leaves the page alone.
47
+ */
48
+ export declare function shortPathLanding(paths: string[]): string;
49
+ /** The page with the landing after its <base> (resolved against the page's own URL), else first in <head>, else after the doctype, else first. */
50
+ export declare function withShortPathLanding(html: string, paths: string[]): string;
51
+ /** Each stable page target a short path opens, with those paths; only HTML pages get the landing. */
52
+ export declare function shortPathLandings(paths: ShortPaths, stablePages: StablePages | undefined): Map<string, string[]>;
31
53
  export declare function shortPathsResourceEntry(): {
32
54
  type: string;
33
55
  relpath: string;
@@ -4,6 +4,8 @@ import { STABLE_PAGE_FILE } from "./stable-pages.js";
4
4
  import { ENTRY_SHORT_PATH_TARGET, entryPagePath } from "./entry-page.js";
5
5
  export const SHORT_PATHS_CONFIG = "etc/short-paths-nginx.conf";
6
6
  export const SHORT_PATH_LIMIT = 4;
7
+ /** The query parameter the redirect puts first; its value is the path without the leading /. */
8
+ export const SHORT_PATH_MARKER = "spl-short";
7
9
  const PATH = /^\/[a-z0-9]+(?:-[a-z0-9]+)*$/;
8
10
  const PACKAGE = /^[A-Za-z][A-Za-z0-9]{1,63}$/;
9
11
  /** The lifecycle hooks that check the paths before DSM activates the resource, as for custom ingress. */
@@ -57,7 +59,49 @@ export function shortPathTarget(pkg, page) {
57
59
  * 302 is never cached permanently, so a removed package leaves no stale redirect.
58
60
  */
59
61
  export function renderShortPathsConfig(pkg, paths) {
60
- return checked(pkg, paths).map(([path, page]) => [path, `${path}/`].map(from => `location = ${from} {\n absolute_redirect off;\n return 302 ${shortPathTarget(pkg, page)}$is_args$args;\n}\n`).join("")).join("");
62
+ return checked(pkg, paths).map(([path, page]) => [path, `${path}/`].map(from => `location = ${from} {\n absolute_redirect off;\n return 302 ${shortPathTarget(pkg, page)}?${SHORT_PATH_MARKER}=${path.slice(1)}&$args;\n}\n`).join("")).join("");
63
+ }
64
+ /**
65
+ * The script a stable page's target gets first in its head when a short path
66
+ * opens the page. It runs before the page's own scripts: with the marker of a
67
+ * declared path first in the query, it adds `<base href>` with the page's own
68
+ * URL (unless the page has one) and replaces the address with the short path,
69
+ * the rest of the query and the fragment. Anything else leaves the page alone.
70
+ */
71
+ export function shortPathLanding(paths) {
72
+ if (!paths.length || paths.some(path => path.length > 65 || !PATH.test(path)))
73
+ throw new Error("Invalid ui.short_paths declaration");
74
+ return `<script>(function () {
75
+ try {
76
+ var m = /^\\?${SHORT_PATH_MARKER}=([a-z0-9]+(?:-[a-z0-9]+)*)(?:&|$)/.exec(location.search);
77
+ if (!m || ${JSON.stringify([...paths].sort())}.indexOf("/" + m[1]) < 0) return;
78
+ if (!document.querySelector("base[href]")) {
79
+ var base = document.createElement("base"), head = document.head || document.documentElement;
80
+ base.href = location.origin + location.pathname;
81
+ head.insertBefore(base, head.firstChild);
82
+ }
83
+ var rest = location.search.slice(m[0].length);
84
+ history.replaceState(history.state, "", "/" + m[1] + (rest ? "?" + rest : "") + location.hash);
85
+ } catch (e) {}
86
+ })();</script>`;
87
+ }
88
+ /** The page with the landing after its <base> (resolved against the page's own URL), else first in <head>, else after the doctype, else first. */
89
+ export function withShortPathLanding(html, paths) {
90
+ const tag = shortPathLanding(paths);
91
+ const at = /<base\b[^>]*>/i.exec(html) ?? /<head\b[^>]*>/i.exec(html) ?? /^\s*<!doctype\b[^>]*>/i.exec(html);
92
+ const end = at ? at.index + at[0].length : 0;
93
+ return html.slice(0, end) + tag + html.slice(end);
94
+ }
95
+ /** Each stable page target a short path opens, with those paths; only HTML pages get the landing. */
96
+ export function shortPathLandings(paths, stablePages) {
97
+ const out = new Map();
98
+ for (const [path, page] of Object.entries(paths)) {
99
+ const target = page === ENTRY_SHORT_PATH_TARGET ? undefined : stablePages?.[page];
100
+ if (!target || !/\.html?$/i.test(target))
101
+ continue;
102
+ out.set(target, [...(out.get(target) ?? []), path].sort());
103
+ }
104
+ return out;
61
105
  }
62
106
  export function shortPathsResourceEntry() {
63
107
  return { type: "dsm", relpath: SHORT_PATHS_CONFIG };
@@ -30,7 +30,7 @@ import { renderStandaloneScript } from "./lifecycle.js";
30
30
  import { APP_SCRIPTS_DIR, APP_SCRIPTS_SPK_DIR } from "./app-scripts.js";
31
31
  import { MODULE_UI_ENTRY, precompressUiTree, uiTreeDigest } from "./ui-assets.js";
32
32
  import { writeStablePages } from "./stable-pages.js";
33
- import { SHORT_PATHS_CONFIG, renderShortPathsConfig } from "./short-paths.js";
33
+ import { SHORT_PATHS_CONFIG, renderShortPathsConfig, shortPathLandings, withShortPathLanding } from "./short-paths.js";
34
34
  import { enforcePublicUi, isUiBundle, logicalUiFile, minifyUi, minifyUiTree, storedUiSecretIgnores, uiFiles } from "./public-ui.js";
35
35
  import { codedMessage } from "../errors.js";
36
36
  import { CHECKSUM_PLACEHOLDER, DIGEST_PLACEHOLDER, largestInstalledInfo, projectInstalledInfoIssue, stagedInstalledInfoIssue } from "../spk/installed-info.js";
@@ -106,6 +106,12 @@ export async function assembleStandaloneSpk(options) {
106
106
  copyUiTree(manifest.ui.dir, appDir, manifest.root);
107
107
  else
108
108
  mkdirSync(appDir, { recursive: true });
109
+ // Before the digest: a page a short path opens shows that path again.
110
+ for (const [target, paths] of shortPathLandings(manifest.ui?.shortPaths ?? {}, manifest.ui?.stablePages)) {
111
+ const file = join(appDir, target);
112
+ if (existsSync(file) && lstatSync(file).isFile())
113
+ writeFileSync(file, withShortPathLanding(readFileSync(file, "utf8"), paths));
114
+ }
109
115
  minifyUiTree(appDir);
110
116
  precompressUiTree(appDir);
111
117
  const moduleUi = hasSdkWindow(manifest) && existsSync(join(appDir, MODULE_UI_ENTRY));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@synopackageland/cli",
3
- "version": "0.54.7",
3
+ "version": "0.54.8",
4
4
  "description": "Syno Package Land Developer Kit CLI",
5
5
  "type": "module",
6
6
  "bin": {
@@ -26,20 +26,6 @@
26
26
  "docs/install-memory.md",
27
27
  "docs/catalog-text.md"
28
28
  ],
29
- "scripts": {
30
- "check:docs": "node --test scripts/check-doc-versions.test.mjs && node scripts/check-doc-versions.mjs",
31
- "build": "rm -rf dist && node scripts/prepare-native-http.mjs && tsc",
32
- "test": "pnpm run build && node --import tsx --import ./test/helpers/strict-dsm-setup.ts --test --test-concurrency=${SYNOPKGLAND_GATE_JOBS:-3} test/*.test.ts test/ctl/*.test.ts",
33
- "test:glossary": "node --test scripts/test/glossary-drift.test.mjs",
34
- "test:scripts": "node --test scripts/test/gate.test.mjs scripts/test/release.test.mjs scripts/test/pack-docker.test.mjs scripts/test/npm-pack.test.mjs scripts/test/executor-bump.test.mjs scripts/test/smoke-exports.test.mjs scripts/test/parallel.test.mjs scripts/test/scaffold-matrix.test.mjs scripts/test/frontend-deps.test.mjs scripts/test/docker-gate.test.mjs scripts/test/gate-plan.test.mjs scripts/test/gates.test.mjs && python3 scripts/test/npm-publish.py",
35
- "gates": "bash scripts/ci/gates.sh",
36
- "gates:fast": "bash scripts/ci/gates.sh",
37
- "prepublishOnly": "pnpm run build && node --input-type=module -e 'import {enforceRepositorySecrets} from \"./dist/secret-files.js\"; enforceRepositorySecrets(process.cwd())'",
38
- "gates:full": "bash scripts/ci/gates.sh --full",
39
- "test:basic": "node --import tsx --test test/schema.test.ts test/standalone-manifest.test.ts test/native-arch.test.ts test/archive-inventory.test.ts test/secret-files.test.ts",
40
- "check:dsm-contract": "node scripts/check-dsm-api-contract.mjs",
41
- "check:dsm-hub": "node scripts/check-dsm-api-hub.mjs"
42
- },
43
29
  "dependencies": {
44
30
  "@napi-rs/keyring": "^2.1.1",
45
31
  "@synopackageland/templates": "~0.44.1",
@@ -102,5 +88,17 @@
102
88
  "./native-layout": "./dist/standalone/native-layout.js",
103
89
  "./e2e": "./dist/e2e/dsm.js"
104
90
  },
105
- "packageManager": "pnpm@12.18.0"
91
+ "scripts": {
92
+ "check:docs": "node --test scripts/check-doc-versions.test.mjs && node scripts/check-doc-versions.mjs",
93
+ "build": "rm -rf dist && node scripts/prepare-native-http.mjs && tsc",
94
+ "test": "pnpm run build && node --import tsx --import ./test/helpers/strict-dsm-setup.ts --test --test-concurrency=${SYNOPKGLAND_GATE_JOBS:-3} test/*.test.ts test/ctl/*.test.ts",
95
+ "test:glossary": "node --test scripts/test/glossary-drift.test.mjs",
96
+ "test:scripts": "node --test scripts/test/gate.test.mjs scripts/test/release.test.mjs scripts/test/pack-docker.test.mjs scripts/test/npm-pack.test.mjs scripts/test/executor-bump.test.mjs scripts/test/smoke-exports.test.mjs scripts/test/parallel.test.mjs scripts/test/scaffold-matrix.test.mjs scripts/test/frontend-deps.test.mjs scripts/test/docker-gate.test.mjs scripts/test/gate-plan.test.mjs scripts/test/gates.test.mjs && python3 scripts/test/npm-publish.py",
97
+ "gates": "bash scripts/ci/gates.sh",
98
+ "gates:fast": "bash scripts/ci/gates.sh",
99
+ "gates:full": "bash scripts/ci/gates.sh --full",
100
+ "test:basic": "node --import tsx --test test/schema.test.ts test/standalone-manifest.test.ts test/native-arch.test.ts test/archive-inventory.test.ts test/secret-files.test.ts",
101
+ "check:dsm-contract": "node scripts/check-dsm-api-contract.mjs",
102
+ "check:dsm-hub": "node scripts/check-dsm-api-hub.mjs"
103
+ }
106
104
  }
@@ -288,6 +288,11 @@ ui:
288
288
  - build 寫入 `etc/short-paths-nginx.conf`:`location = /connect` 與 `location = /connect/`,回 302、相對 `Location`
289
289
  (`absolute_redirect off`,經反向代理或 tunnel 進來也不會被帶到 :5001),query 照傳,fragment 由瀏覽器保留。
290
290
  不 proxy、不碰 cookie、不跑套件程式。
291
+ - 網址列維持短網址:302 在 query 最前面加 `spl-short=<path>`;`.html` 目標頁由 build 在 `<head>` 最前面(頁面已有 `<base>` 就放在它後面)
292
+ 插一段小 script,加上指向實際頁面的 `<base href>` 後用 `history.replaceState` 換回 `/connect?<query>#<fragment>`;短網址到 `app` 由 SDK entry boot
293
+ 處理(同分頁 DSM 登入後也維持)。重新整理、書籤、iOS 加到主畫面都回到短網址並載入目前 build;沒有標記(直接開 stable page/長網址、
294
+ Application Portal 網域)就不改網址,長網址照常可用。頁面程式讀 `location.pathname` 會得到短網址,套件內網址請用 `document.baseURI`
295
+ 或相對網址;只有 fragment 的連結(`href="#top"`)會解析到實際頁面並重新載入。
291
296
  - DSM `web-config` worker 在套件啟動時加入 DSM server(5000/5001 與 DSM 自訂網域),停止時移除;停止或解除安裝後回 404。
292
297
  有 `portal` 也只註冊在 DSM server:80/443 不提供 `/webman/3rdparty/`。
293
298
  - 規則:單一小寫片段(字母、數字、中間的 `-`,最多 64 字元,不可結尾 `/`),最多 4 個;不可用 `/`、DSM/SDK 名稱