@file-viewer/cli 3.0.0

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/LICENSE ADDED
@@ -0,0 +1,160 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction, and
10
+ distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by the copyright
13
+ owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all other entities
16
+ that control, are controlled by, or are under common control with that entity.
17
+ For the purposes of this definition, "control" means (i) the power, direct or
18
+ indirect, to cause the direction or management of such entity, whether by
19
+ contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the
20
+ outstanding shares, or (iii) beneficial ownership of such entity.
21
+
22
+ "You" (or "Your") shall mean an individual or Legal Entity exercising
23
+ permissions granted by this License.
24
+
25
+ "Source" form shall mean the preferred form for making modifications, including
26
+ but not limited to software source code, documentation source, and configuration
27
+ files.
28
+
29
+ "Object" form shall mean any form resulting from mechanical transformation or
30
+ translation of a Source form, including but not limited to compiled object code,
31
+ generated documentation, and conversions to other media types.
32
+
33
+ "Work" shall mean the work of authorship, whether in Source or Object form,
34
+ made available under the License, as indicated by a copyright notice that is
35
+ included in or attached to the work.
36
+
37
+ "Derivative Works" shall mean any work, whether in Source or Object form, that
38
+ is based on (or derived from) the Work and for which the editorial revisions,
39
+ annotations, elaborations, or other modifications represent, as a whole, an
40
+ original work of authorship. For the purposes of this License, Derivative Works
41
+ shall not include works that remain separable from, or merely link (or bind by
42
+ name) to the interfaces of, the Work and Derivative Works thereof.
43
+
44
+ "Contribution" shall mean any work of authorship, including the original version
45
+ of the Work and any modifications or additions to that Work or Derivative Works
46
+ thereof, that is intentionally submitted to Licensor for inclusion in the Work by
47
+ the copyright owner or by an individual or Legal Entity authorized to submit on
48
+ behalf of the copyright owner. For the purposes of this definition, "submitted"
49
+ means any form of electronic, verbal, or written communication sent to the
50
+ Licensor or its representatives, including but not limited to communication on
51
+ electronic mailing lists, source code control systems, and issue tracking systems
52
+ that are managed by, or on behalf of, the Licensor for the purpose of discussing
53
+ and improving the Work, but excluding communication that is conspicuously marked
54
+ or otherwise designated in writing by the copyright owner as "Not a
55
+ Contribution."
56
+
57
+ "Contributor" shall mean Licensor and any individual or Legal Entity on behalf
58
+ of whom a Contribution has been received by Licensor and subsequently
59
+ incorporated within the Work.
60
+
61
+ 2. Grant of Copyright License. Subject to the terms and conditions of this
62
+ License, each Contributor hereby grants to You a perpetual, worldwide,
63
+ non-exclusive, no-charge, royalty-free, irrevocable copyright license to
64
+ reproduce, prepare Derivative Works of, publicly display, publicly perform,
65
+ sublicense, and distribute the Work and such Derivative Works in Source or
66
+ Object form.
67
+
68
+ 3. Grant of Patent License. Subject to the terms and conditions of this License,
69
+ each Contributor hereby grants to You a perpetual, worldwide, non-exclusive,
70
+ no-charge, royalty-free, irrevocable (except as stated in this section) patent
71
+ license to make, have made, use, offer to sell, sell, import, and otherwise
72
+ transfer the Work, where such license applies only to those patent claims
73
+ licensable by such Contributor that are necessarily infringed by their
74
+ Contribution(s) alone or by combination of their Contribution(s) with the Work to
75
+ which such Contribution(s) was submitted. If You institute patent litigation
76
+ against any entity (including a cross-claim or counterclaim in a lawsuit)
77
+ alleging that the Work or a Contribution incorporated within the Work
78
+ constitutes direct or contributory patent infringement, then any patent licenses
79
+ granted to You under this License for that Work shall terminate as of the date
80
+ such litigation is filed.
81
+
82
+ 4. Redistribution. You may reproduce and distribute copies of the Work or
83
+ Derivative Works thereof in any medium, with or without modifications, and in
84
+ Source or Object form, provided that You meet the following conditions:
85
+
86
+ (a) You must give any other recipients of the Work or Derivative Works a copy of
87
+ this License; and
88
+
89
+ (b) You must cause any modified files to carry prominent notices stating that
90
+ You changed the files; and
91
+
92
+ (c) You must retain, in the Source form of any Derivative Works that You
93
+ distribute, all copyright, patent, trademark, and attribution notices from the
94
+ Source form of the Work, excluding those notices that do not pertain to any part
95
+ of the Derivative Works; and
96
+
97
+ (d) If the Work includes a "NOTICE" text file as part of its distribution, then
98
+ any Derivative Works that You distribute must include a readable copy of the
99
+ attribution notices contained within such NOTICE file, excluding those notices
100
+ that do not pertain to any part of the Derivative Works, in at least one of the
101
+ following places: within a NOTICE text file distributed as part of the Derivative
102
+ Works; within the Source form or documentation, if provided along with the
103
+ Derivative Works; or, within a display generated by the Derivative Works, if and
104
+ wherever such third-party notices normally appear. The contents of the NOTICE
105
+ file are for informational purposes only and do not modify the License. You may
106
+ add Your own attribution notices within Derivative Works that You distribute,
107
+ alongside or as an addendum to the NOTICE text from the Work, provided that such
108
+ additional attribution notices cannot be construed as modifying the License.
109
+
110
+ You may add Your own copyright statement to Your modifications and may provide
111
+ additional or different license terms and conditions for use, reproduction, or
112
+ distribution of Your modifications, or for any such Derivative Works as a whole,
113
+ provided Your use, reproduction, and distribution of the Work otherwise complies
114
+ with the conditions stated in this License.
115
+
116
+ 5. Submission of Contributions. Unless You explicitly state otherwise, any
117
+ Contribution intentionally submitted for inclusion in the Work by You to the
118
+ Licensor shall be under the terms and conditions of this License, without any
119
+ additional terms or conditions. Notwithstanding the above, nothing herein shall
120
+ supersede or modify the terms of any separate license agreement you may have
121
+ executed with Licensor regarding such Contributions.
122
+
123
+ 6. Trademarks. This License does not grant permission to use the trade names,
124
+ trademarks, service marks, or product names of the Licensor, except as required
125
+ for reasonable and customary use in describing the origin of the Work and
126
+ reproducing the content of the NOTICE file.
127
+
128
+ 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in
129
+ writing, Licensor provides the Work (and each Contributor provides its
130
+ Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
131
+ KIND, either express or implied, including, without limitation, any warranties or
132
+ conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
133
+ PARTICULAR PURPOSE. You are solely responsible for determining the
134
+ appropriateness of using or redistributing the Work and assume any risks
135
+ associated with Your exercise of permissions under this License.
136
+
137
+ 8. Limitation of Liability. In no event and under no legal theory, whether in
138
+ tort (including negligence), contract, or otherwise, unless required by
139
+ applicable law (such as deliberate and grossly negligent acts) or agreed to in
140
+ writing, shall any Contributor be liable to You for damages, including any
141
+ direct, indirect, special, incidental, or consequential damages of any character
142
+ arising as a result of this License or out of the use or inability to use the
143
+ Work (including but not limited to damages for loss of goodwill, work stoppage,
144
+ computer failure or malfunction, or any and all other commercial damages or
145
+ losses), even if such Contributor has been advised of the possibility of such
146
+ damages.
147
+
148
+ 9. Accepting Warranty or Additional Liability. While redistributing the Work or
149
+ Derivative Works thereof, You may choose to offer, and charge a fee for,
150
+ acceptance of support, warranty, indemnity, or other liability obligations and/or
151
+ rights consistent with this License. However, in accepting such obligations, You
152
+ may act only on Your own behalf and on Your sole responsibility, not on behalf of
153
+ any other Contributor, and only if You agree to indemnify, defend, and hold each
154
+ Contributor harmless for any liability incurred by, or claims asserted against,
155
+ such Contributor by reason of your accepting any such warranty or additional
156
+ liability.
157
+
158
+ END OF TERMS AND CONDITIONS
159
+
160
+ Copyright 2026 Flyfish Viewer
package/README.en.md ADDED
@@ -0,0 +1,109 @@
1
+ # @file-viewer/cli
2
+
3
+ Create projects, integrate existing applications, select exact capabilities, and prepare offline File Viewer delivery. The CLI carries only a frozen capability catalog; it does not duplicate renderers, Workers, WASM, fonts, or static assets.
4
+
5
+ - [CLI home](https://file-viewer.app/en/cli/)
6
+ - [Complete guide](https://doc.file-viewer.app/guide/cli)
7
+ - [简体中文](./README.md)
8
+
9
+ ## Quick start
10
+
11
+ Create a runnable project:
12
+
13
+ ```bash
14
+ npm create file-viewer@latest my-viewer
15
+ ```
16
+
17
+ Integrate the project containing the current `package.json`:
18
+
19
+ ```bash
20
+ npx file-viewer-cli@latest add .
21
+ ```
22
+
23
+ `file-viewer-cli` is the single-bin `npx` carrier and pins this scoped package at the same version. If `@file-viewer/cli` is already installed locally, run `file-viewer add .` instead.
24
+
25
+ The wizard selects a framework and validated version, File Viewer release, profile, formats, package manager, and asset directory. It supports Vanilla/Web Component, Vue 3, Vue 2.7, Vue 2.6, React, React Legacy, Svelte, and jQuery.
26
+
27
+ ```bash
28
+ npx file-viewer-cli create my-viewer \
29
+ --framework vue3 \
30
+ --profile standard \
31
+ --formats pdf,docx,xlsx,pptx \
32
+ --package-manager pnpm \
33
+ --non-interactive \
34
+ --yes
35
+ ```
36
+
37
+ `add` detects the `packageManager` field, lockfiles, framework and version, installed preset/Full packages, Vite, Vue CLI, Webpack, Next.js, Nuxt 2/3, statically provable public directories, and application entries. Multiple candidates or an unsafe static-directory inference produce `manualSteps` and fail closed before installation or file writes; pass a contained `--asset-target` after confirming the real build target.
38
+
39
+ ## Standard and Full
40
+
41
+ `standard` is the recommended common-format baseline for new projects. The eight existing `@file-viewer/*-full` packages keep their published `preset-all`, API, asset, and format behavior; they are not silently changed to `standard`.
42
+
43
+ Installing a Full package directly does not automatically add future specialist capabilities. Explicit CLI `--profile full` keeps the matching Full package and adds later opt-ins in the catalog. The current extra opt-ins are DICOM and digital-signature/evidence containers, so the CLI shows their weight and licenses before confirmation. DICOM covers one local DICOM Part 10 file, including multi-frame navigation. It does not provide series assembly, PACS/DICOMweb, MPR, segmentation, diagnosis, or an embedded OHIF application. The signature renderer reports bounded container inspection and cryptographic verification separately from certificate trust, policy, and legal-validity decisions.
44
+
45
+ ## Configuration, assets, and legacy compatibility
46
+
47
+ ```bash
48
+ npx file-viewer-cli list
49
+ npx file-viewer-cli config add dicom --write
50
+ npx file-viewer-cli config add p7m --write
51
+ npx file-viewer-cli plan --framework vue3 --profile full
52
+ npx file-viewer-cli install --yes
53
+ npx file-viewer-cli assets --write
54
+ npx file-viewer-cli doctor --json
55
+ npx file-viewer-cli verify --json
56
+ ```
57
+
58
+ The original package and command remain available:
59
+
60
+ ```bash
61
+ npx --no-install file-viewer-copy-assets ./public/file-viewer \
62
+ --renderers pdf,office-word-openxml
63
+
64
+ # Unified entry to the same compatibility implementation
65
+ npx file-viewer-cli copy-assets ./public/file-viewer \
66
+ --renderers pdf,office-word-openxml
67
+ ```
68
+
69
+ Without a project config, `file-viewer assets` preserves the arguments, environment variables, merge default, receipts, and safety checks of `file-viewer-copy-assets`. Merge mode preserves unrelated files by default; cleanup replaces only a dedicated, boundary-checked `file-viewer` target and requires both `--clean --confirm`. A complete deployment of `@file-viewer/web-full/dist/` needs no separate copy step.
70
+
71
+ ## Private registries and offline tgz files
72
+
73
+ ```bash
74
+ npx file-viewer-cli prepare \
75
+ --framework vue3 \
76
+ --profile standard \
77
+ --registry https://registry.example.com/ \
78
+ --offline-dir .file-viewer/offline \
79
+ --concurrency 4 \
80
+ --yes
81
+
82
+ npx file-viewer-cli add . \
83
+ --profile standard \
84
+ --offline-dir .file-viewer/offline \
85
+ --cache-dir .file-viewer/package-cache \
86
+ --non-interactive \
87
+ --yes
88
+ ```
89
+
90
+ The offline directory includes the exact CLI, has an integrity manifest, and is reused only for exact versions. Tarballs are checked against their package identity; integrity is not registry provenance. Remote registries must use HTTPS (HTTP is loopback-only). `prepare` concurrency is `1-8`; install concurrency is `1-32`. Keep credentials in package-manager or CI configuration—the CLI rejects credentials embedded in URLs and does not write secrets into project config.
91
+
92
+ ## Recovery and dependency ownership
93
+
94
+ Before a confirmed install, the CLI moves an existing project-local `node_modules` and Yarn unplugged directory into a same-filesystem backup, and snapshots the manifest, lockfiles, Yarn PnP/install-state files, generated integration, and managed asset target. A handled package-manager or asset failure restores those bytes. If safe atomic staging cannot be established, installation stops before invoking the package manager.
95
+
96
+ An abrupt process or host termination can leave an adjacent `.<project>.file-viewer-install-*` backup. Inspect and restore that directory before rerunning; do not delete it blindly. Package-manager caches, including a project-local Yarn cache, are outside this transaction. Obsolete heavy dependencies are removed only when the project config records them in `managedPackages` as CLI-owned; packages that were not installed and tracked by the CLI remain untouched.
97
+
98
+ ## Help and language
99
+
100
+ Interactive text and help support English, Simplified Chinese, Japanese, and German. `--json` always uses stable English keys.
101
+
102
+ ```bash
103
+ file-viewer --help --lang en
104
+ file-viewer create --help --lang zh-CN
105
+ file-viewer add --help --lang ja-JP
106
+ file-viewer prepare --help --lang de-DE
107
+ ```
108
+
109
+ See the [complete CLI guide](https://doc.file-viewer.app/guide/cli) for every command, config field, CI pattern, offline boundary, and troubleshooting step.
package/README.md ADDED
@@ -0,0 +1,109 @@
1
+ # @file-viewer/cli
2
+
3
+ File Viewer 的项目创建、已有项目接入、能力选择和离线交付 CLI。它只携带冻结的能力目录,不重复打包 renderer、Worker、WASM、字体或其他静态资源。
4
+
5
+ - [CLI 使用主页](https://file-viewer.app/cli/)
6
+ - [完整中文指南](https://doc.file-viewer.app/zh/guide/cli)
7
+ - [English README](./README.en.md)
8
+
9
+ ## 快速开始
10
+
11
+ 创建一个可运行项目:
12
+
13
+ ```bash
14
+ npm create file-viewer@latest my-viewer
15
+ ```
16
+
17
+ 接入当前 `package.json` 项目:
18
+
19
+ ```bash
20
+ npx file-viewer-cli@latest add .
21
+ ```
22
+
23
+ `file-viewer-cli` 是便于 `npx` 自动选择命令的单 bin 入口,并严格依赖同版本的本 scoped 包。项目已经安装 `@file-viewer/cli` 时,直接运行 `file-viewer add .`。
24
+
25
+ 向导可选择框架及其已校验版本、File Viewer 版本、profile、格式、包管理器和资源目录。支持 Vanilla/Web Component、Vue 3、Vue 2.7、Vue 2.6、React、React Legacy、Svelte 和 jQuery。
26
+
27
+ ```bash
28
+ npx file-viewer-cli create my-viewer \
29
+ --framework vue3 \
30
+ --profile standard \
31
+ --formats pdf,docx,xlsx,pptx \
32
+ --package-manager pnpm \
33
+ --non-interactive \
34
+ --yes
35
+ ```
36
+
37
+ `add` 会检测 `packageManager`、lockfile、框架及版本、既有 preset/Full 包、Vite、Vue CLI、Webpack、Next.js、Nuxt 2/3、可静态证明的公开目录和应用入口。存在多个候选或无法安全推导静态目录时会生成 `manualSteps`,并在安装或写文件前失败关闭;确认实际构建目标后可显式传入 `--asset-target`。
38
+
39
+ ## Standard 与 Full
40
+
41
+ `standard` 是新项目推荐的常用格式基线。现有八个 `@file-viewer/*-full` 包继续保持已发布的 `preset-all`、API、资产和格式行为,不会被静默改成 `standard`。
42
+
43
+ 直接安装 Full 包不会自动带入以后新增的专业能力;通过 CLI 明确选择 `--profile full` 时,CLI 会保留对应 Full 包并加入目录中的后续可选能力。当前额外能力是 DICOM 和数字签名/证据容器,因此确认前会显示体积和许可证信息。DICOM 仅预览本地单个 DICOM Part 10 文件及其多帧,不包含 series、PACS/DICOMweb、MPR、分割、诊断或内嵌 OHIF。签名 renderer 仅声明有界容器检查和密码学验证结果,不代替证书信任、政策或法律效力判定。
44
+
45
+ ## 配置、资产与旧命令兼容
46
+
47
+ ```bash
48
+ npx file-viewer-cli list
49
+ npx file-viewer-cli config add dicom --write
50
+ npx file-viewer-cli config add p7m --write
51
+ npx file-viewer-cli plan --framework vue3 --profile full
52
+ npx file-viewer-cli install --yes
53
+ npx file-viewer-cli assets --write
54
+ npx file-viewer-cli doctor --json
55
+ npx file-viewer-cli verify --json
56
+ ```
57
+
58
+ 原有命令和包继续可用:
59
+
60
+ ```bash
61
+ npx --no-install file-viewer-copy-assets ./public/file-viewer \
62
+ --renderers pdf,office-word-openxml
63
+
64
+ # 同一兼容实现的统一入口
65
+ npx file-viewer-cli copy-assets ./public/file-viewer \
66
+ --renderers pdf,office-word-openxml
67
+ ```
68
+
69
+ 未提供项目配置时,`file-viewer assets` 的参数、环境变量、合并模式、回执及安全校验与 `file-viewer-copy-assets` 保持一致。默认合并并保留无关文件;只有同时传入 `--clean --confirm` 才会清理并替换专用且通过安全边界校验的 `file-viewer` 目标目录。完整部署 `@file-viewer/web-full/dist/` 时无需再复制资产。
70
+
71
+ ## 私有源和离线 tgz
72
+
73
+ ```bash
74
+ npx file-viewer-cli prepare \
75
+ --framework vue3 \
76
+ --profile standard \
77
+ --registry https://registry.example.com/ \
78
+ --offline-dir .file-viewer/offline \
79
+ --concurrency 4 \
80
+ --yes
81
+
82
+ npx file-viewer-cli add . \
83
+ --profile standard \
84
+ --offline-dir .file-viewer/offline \
85
+ --cache-dir .file-viewer/package-cache \
86
+ --non-interactive \
87
+ --yes
88
+ ```
89
+
90
+ 离线目录包含精确 CLI,带完整性清单并按精确版本复用;tarball 还会核对包身份,但完整性不等于 registry 来源可信。远程源必须使用 HTTPS(HTTP 只允许回环地址)。`prepare` 并发为 `1-8`,安装并发为 `1-32`。Registry 凭据应配置在包管理器或 CI 中;CLI 拒绝 URL 内嵌账号密码,也不会把凭据写入项目配置。
91
+
92
+ ## 失败恢复与依赖所有权
93
+
94
+ 确认安装后,CLI 会先把已有的项目内 `node_modules` 及 Yarn unplugged 目录原子移动到同文件系统备份区,同时保存 manifest、lockfile、Yarn PnP/install-state、生成模块和受管资产目录。包管理器或资产步骤正常抛错时会恢复这些字节;无法建立安全原子备份时,会在调用包管理器前停止。
95
+
96
+ 进程或主机被强制中断时,项目同级可能留下 `.<项目名>.file-viewer-install-*` 备份。再次执行前应先检查并恢复,不能直接删除。包管理器 cache(包括项目内 Yarn cache)不在该事务范围内。只有在配置的 `managedPackages` 中明确记录为 CLI 所有的过期重型依赖才会被移除;CLI 未安装、未跟踪的用户依赖保持不动。
97
+
98
+ ## 帮助与语言
99
+
100
+ CLI 的交互和帮助支持英文、简体中文、日文和德文;`--json` 始终使用稳定英文键。
101
+
102
+ ```bash
103
+ file-viewer --help --lang zh-CN
104
+ file-viewer create --help --lang en
105
+ file-viewer add --help --lang ja-JP
106
+ file-viewer prepare --help --lang de-DE
107
+ ```
108
+
109
+ 完整命令、配置字段、CI 模式、离线限制和故障排查请查看[完整 CLI 指南](https://doc.file-viewer.app/zh/guide/cli)。