create-clis 0.1.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 +21 -0
- package/README.md +113 -0
- package/README.zh-CN.md +113 -0
- package/assets/manifest.json +99 -0
- package/assets/template/.editorconfig +12 -0
- package/assets/template/.gitattributes +18 -0
- package/assets/template/.github/ISSUE_TEMPLATE/bug_report.yml +86 -0
- package/assets/template/.github/ISSUE_TEMPLATE/feature_request.yml +45 -0
- package/assets/template/.github/PULL_REQUEST_TEMPLATE.md +26 -0
- package/assets/template/.github/workflows/ci.yml +42 -0
- package/assets/template/.github/workflows/release.yml +65 -0
- package/assets/template/.gitignorerc.json +21 -0
- package/assets/template/.nvmrc +1 -0
- package/assets/template/.oxlintrc.json +52 -0
- package/assets/template/.prettierignore +11 -0
- package/assets/template/.prettierrc +11 -0
- package/assets/template/.releaserc.json +17 -0
- package/assets/template/.vscode/extensions.json +8 -0
- package/assets/template/.vscode/launch.json +13 -0
- package/assets/template/.vscode/settings.json +14 -0
- package/assets/template/AGENTS.md +25 -0
- package/assets/template/CODE_OF_CONDUCT.md +91 -0
- package/assets/template/CONTRIBUTING.md +85 -0
- package/assets/template/CONTRIBUTING.zh-CN.md +85 -0
- package/assets/template/LICENSE +21 -0
- package/assets/template/README.md +22 -0
- package/assets/template/README.zh-CN.md +22 -0
- package/assets/template/SECURITY.md +21 -0
- package/assets/template/_gitignore +409 -0
- package/assets/template/_npmrc +6 -0
- package/assets/template/bunfig.toml +16 -0
- package/assets/template/docs/README.md +30 -0
- package/assets/template/docs/adrs/README.md +7 -0
- package/assets/template/docs/designs/README.md +11 -0
- package/assets/template/docs/designs/tech-debt.md +22 -0
- package/assets/template/docs/development.md +59 -0
- package/assets/template/lefthook.yml +55 -0
- package/assets/template/package.json +38 -0
- package/assets/template/packages/{{NAME}}/CHANGELOG.md +3 -0
- package/assets/template/packages/{{NAME}}/LICENSE +21 -0
- package/assets/template/packages/{{NAME}}/README.md +33 -0
- package/assets/template/packages/{{NAME}}/README.zh-CN.md +33 -0
- package/assets/template/packages/{{NAME}}/docs/README.md +21 -0
- package/assets/template/packages/{{NAME}}/package.json +40 -0
- package/assets/template/packages/{{NAME}}/scripts/build.ts +82 -0
- package/assets/template/packages/{{NAME}}/scripts/verify-release.test.ts +214 -0
- package/assets/template/packages/{{NAME}}/scripts/verify-release.ts +152 -0
- package/assets/template/packages/{{NAME}}/src/index.ts +15 -0
- package/assets/template/packages/{{NAME}}/tsconfig.build.json +12 -0
- package/assets/template/packages/{{NAME}}/tsconfig.json +5 -0
- package/assets/template/packages/{{NAME}}-cli/CHANGELOG.md +3 -0
- package/assets/template/packages/{{NAME}}-cli/LICENSE +21 -0
- package/assets/template/packages/{{NAME}}-cli/README.md +35 -0
- package/assets/template/packages/{{NAME}}-cli/README.zh-CN.md +35 -0
- package/assets/template/packages/{{NAME}}-cli/bin/{{BIN_NAME}} +30 -0
- package/assets/template/packages/{{NAME}}-cli/bin/{{BIN_NAME}}.cmd +30 -0
- package/assets/template/packages/{{NAME}}-cli/bin/{{BIN_NAME}}.d.mts +23 -0
- package/assets/template/packages/{{NAME}}-cli/bin/{{BIN_NAME}}.mjs +212 -0
- package/assets/template/packages/{{NAME}}-cli/docs/README.md +21 -0
- package/assets/template/packages/{{NAME}}-cli/package.json +48 -0
- package/assets/template/packages/{{NAME}}-cli/scripts/release-artifact.ts +141 -0
- package/assets/template/packages/{{NAME}}-cli/scripts/release.fixtures.ts +70 -0
- package/assets/template/packages/{{NAME}}-cli/scripts/verify-release.test.ts +444 -0
- package/assets/template/packages/{{NAME}}-cli/scripts/verify-release.ts +72 -0
- package/assets/template/packages/{{NAME}}-cli/scripts/write-dist-manifest.test.ts +126 -0
- package/assets/template/packages/{{NAME}}-cli/scripts/write-dist-manifest.ts +81 -0
- package/assets/template/packages/{{NAME}}-cli/src/cli.ts +36 -0
- package/assets/template/packages/{{NAME}}-cli/tsconfig.json +4 -0
- package/assets/template/scripts/ci.ts +163 -0
- package/assets/template/scripts/install-git-hooks.mjs +122 -0
- package/assets/template/scripts/install-git-hooks.test.ts +418 -0
- package/assets/template/scripts/lib/git-env.ts +21 -0
- package/assets/template/scripts/lib/release-verify.ts +431 -0
- package/assets/template/scripts/lib/tmp-root.ts +17 -0
- package/assets/template/scripts/lib/workspace.test.ts +92 -0
- package/assets/template/scripts/lib/workspace.ts +100 -0
- package/assets/template/scripts/lint-doc-examples.test.ts +129 -0
- package/assets/template/scripts/lint-doc-examples.ts +249 -0
- package/assets/template/scripts/lint-doc-references.test.ts +158 -0
- package/assets/template/scripts/lint-doc-references.ts +308 -0
- package/assets/template/scripts/lint-doc-shared.ts +59 -0
- package/assets/template/scripts/lint-stray-backups.test.ts +53 -0
- package/assets/template/scripts/lint-stray-backups.ts +39 -0
- package/assets/template/scripts/npm-trust-guard.test.ts +253 -0
- package/assets/template/scripts/npm-trust-guard.ts +533 -0
- package/assets/template/scripts/safe-install.ts +39 -0
- package/assets/template/scripts/transcription/api-harness.ts +219 -0
- package/assets/template/scripts/transcription/compare.ts +421 -0
- package/assets/template/scripts/transcription/corpus.ts +208 -0
- package/assets/template/scripts/transcription/fixture.ts +290 -0
- package/assets/template/scripts/transcription/make-mutants.ts +425 -0
- package/assets/template/scripts/transcription/report.ts +86 -0
- package/assets/template/scripts/transcription/run-conformance.ts +344 -0
- package/assets/template/scripts/transcription/validate-coverage.test.ts +119 -0
- package/assets/template/scripts/transcription/validate-coverage.ts +144 -0
- package/assets/template/scripts/transcription/validate.ts +366 -0
- package/assets/template/tsconfig.json +46 -0
- package/assets/template/turbo.jsonc +60 -0
- package/bin/create-clis +35 -0
- package/bin/create-clis.cmd +32 -0
- package/bin/create-clis.mjs +219 -0
- package/dist/create-clis.js +87682 -0
- package/dist/manifest.json +7 -0
- package/package.json +57 -0
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# {{SCOPE}}/{{NAME}}-cli
|
|
2
|
+
|
|
3
|
+
<!-- 模板骨架: 示例命令是 {{BIN_NAME}} --name <名字>; 换成自己的命令后, 同步本节与包内文档。 -->
|
|
4
|
+
|
|
5
|
+
本集合仓的命令行工具: API 包 ([{{SCOPE}}/{{NAME}}](../{{NAME}}/README.zh-CN.md)) 的薄壳, 领域逻辑在 API 包里。
|
|
6
|
+
|
|
7
|
+
## 安装
|
|
8
|
+
|
|
9
|
+
```shell
|
|
10
|
+
npm install -g {{SCOPE}}/{{NAME}}-cli
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## 用法
|
|
14
|
+
|
|
15
|
+
```shell
|
|
16
|
+
# 打印一句问候 (示例)
|
|
17
|
+
{{BIN_NAME}} --name world
|
|
18
|
+
|
|
19
|
+
# 查看命令帮助
|
|
20
|
+
{{BIN_NAME}} --help
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## 开发
|
|
24
|
+
|
|
25
|
+
```shell
|
|
26
|
+
# 类型检查与测试 (在包目录内)
|
|
27
|
+
bun run typecheck && bun run test
|
|
28
|
+
|
|
29
|
+
# 打包发布产物 (dist/) 并跑发布自证闸门 (自证要求干净工作树)
|
|
30
|
+
bun run build && bun run verify:release
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## 文档
|
|
34
|
+
|
|
35
|
+
- [包级文档入口](docs/README.md): 包内设计与包级 ADR 的登记入口。
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
# {{BIN_NAME}} 启动器: 挑选运行时 (Bun 优先, 其次 Node) 后 exec 真实入口。
|
|
3
|
+
# 经 ~/.local/bin/{{BIN_NAME}} 软链调用; readlink 解出仓库内路径 (BSD / GNU 皆可)。
|
|
4
|
+
#
|
|
5
|
+
# 运行时解析防劫持 (安全审计项 runtime-resolution:bare-name-cwd-precedence-windows):
|
|
6
|
+
# 本入口的 command -v 与 exec 都按 shell 的 PATH 查找; shell 层无法过滤 PATH 中的空 / 相对
|
|
7
|
+
# 条目 (两者在 POSIX 下均意为当前目录), 该边界属已知前提: npm 分发入口 (bin/{{BIN_NAME}}.mjs)
|
|
8
|
+
# 已按 PATH 解析绝对路径并跳过这两类条目, 防御落在那一侧。对照实测与本条的证据面见
|
|
9
|
+
# src/launcher.runtime-resolution.test.ts; win32 侧的对应处理见 bin/{{BIN_NAME}}.cmd 与
|
|
10
|
+
# bin/{{BIN_NAME}}.mjs 的文件头。
|
|
11
|
+
|
|
12
|
+
# readlink 为空 = 未经软链直跑, 此时 $0 即自身路径
|
|
13
|
+
target=$(readlink "$0" 2>/dev/null)
|
|
14
|
+
case "$target" in
|
|
15
|
+
"") target=$0 ;;
|
|
16
|
+
/*) ;;
|
|
17
|
+
*) target="$(dirname "$0")/$target" ;;
|
|
18
|
+
esac
|
|
19
|
+
root=$(cd "$(dirname "$target")/.." && pwd)
|
|
20
|
+
|
|
21
|
+
if command -v bun >/dev/null 2>&1; then
|
|
22
|
+
exec bun "$root/src/cli.ts" "$@"
|
|
23
|
+
fi
|
|
24
|
+
|
|
25
|
+
if command -v node >/dev/null 2>&1; then
|
|
26
|
+
exec node "$root/src/cli.ts" "$@"
|
|
27
|
+
fi
|
|
28
|
+
|
|
29
|
+
echo "{{BIN_NAME}}: 未找到 bun 或 node, 请至少安装其一" >&2
|
|
30
|
+
exit 1
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
@echo off
|
|
2
|
+
rem {{BIN_NAME}} 启动器 (Windows): 挑选运行时 (Bun 优先, 其次 Node) 后启动真实入口。
|
|
3
|
+
rem 与 sh 启动器 (bin/{{BIN_NAME}}) 同逻辑; 未经 Windows 真机验证 (证据缺口)。
|
|
4
|
+
rem 分支结构全程只用单行 if 判定 (不用标签与括号块), 与 sh 启动器一一对应。
|
|
5
|
+
rem
|
|
6
|
+
rem 运行时解析防劫持 (安全审计项 runtime-resolution:bare-name-cwd-precedence-windows):
|
|
7
|
+
rem 裸名执行与 where 的默认搜索都含当前目录 (官方文档: by default, where searches the current
|
|
8
|
+
rem directory and the paths that are specified in the PATH environment variable; path 命令页:
|
|
9
|
+
rem the current directory is always searched before the directories specified in the command path),
|
|
10
|
+
rem 而本工具又在被扫目录里执行 —— 目录内放一个同名 bun.exe / bun.cmd 即可顶替真实运行时。
|
|
11
|
+
rem 故改用 for 的 PATH 展开修饰符 (官方 for 文档: Searches the directories listed in the PATH
|
|
12
|
+
rem environment variable and expands 变量 to the fully qualified name of the first directory
|
|
13
|
+
rem found): 只搜 PATH, 不搜当前目录, 也不派生任何子进程; 解析出的绝对路径交给末行执行, 带路径
|
|
14
|
+
rem 的命令不再触发搜索序。候选扩展名取 .com / .exe: 扩展名相对序 (.com 先于 .exe) 与 libuv 一致;
|
|
15
|
+
rem 搜索粒度则不同 —— 本实现扩展名优先 (.com 扫完全部 PATH 目录再试 .exe), npm 启动器
|
|
16
|
+
rem (bin/{{BIN_NAME}}.mjs, 走 Node 的 libuv 搜索) 目录优先 (逐目录内先 .com 再 .exe); 仅当多个 PATH 目录
|
|
17
|
+
rem 分别存在不同扩展名的 bun / node 时, 三入口可能选中不同二进制 (登记见 packages/{{NAME}}/docs/adrs/0007-platform-portability.md)。
|
|
18
|
+
setlocal
|
|
19
|
+
set "ROOT=%~dp0.."
|
|
20
|
+
set "ENTRY=%ROOT%\src\cli.ts"
|
|
21
|
+
set "RUNNER="
|
|
22
|
+
|
|
23
|
+
for %%I in (bun.com bun.exe) do if not defined RUNNER set "RUNNER=%%~$PATH:I"
|
|
24
|
+
if not defined RUNNER for %%I in (node.com node.exe) do if not defined RUNNER set "RUNNER=%%~$PATH:I"
|
|
25
|
+
|
|
26
|
+
if not defined RUNNER echo {{BIN_NAME}}: 未找到 bun 或 node, 请至少安装其一 1>&2
|
|
27
|
+
if not defined RUNNER exit /b 1
|
|
28
|
+
|
|
29
|
+
"%RUNNER%" "%ENTRY%" %*
|
|
30
|
+
exit /b %errorlevel%
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* bin/{{BIN_NAME}}.mjs 的类型投影: 分发入口是纯 JS (node 直跑, 不进 tsc 编译面), 此声明只为让
|
|
3
|
+
* src/launcher.runtime-resolution.test.ts 能带类型地 import 其中的三个导出。
|
|
4
|
+
* 签名与实现须同步; 实现本体与语义说明见 bin/{{BIN_NAME}}.mjs。
|
|
5
|
+
*/
|
|
6
|
+
export declare const resolveWin32Executable: (
|
|
7
|
+
name: string,
|
|
8
|
+
pathEnv: string,
|
|
9
|
+
fileProbe: (candidate: string) => boolean,
|
|
10
|
+
) => string | null;
|
|
11
|
+
|
|
12
|
+
export declare const resolvePosixExecutables: (
|
|
13
|
+
name: string,
|
|
14
|
+
pathEnv: string,
|
|
15
|
+
fileProbe: (candidate: string) => boolean,
|
|
16
|
+
) => string[];
|
|
17
|
+
|
|
18
|
+
export declare const pickRuntime: (options?: {
|
|
19
|
+
platform?: NodeJS.Platform;
|
|
20
|
+
pathEnv?: string;
|
|
21
|
+
fileProbe?: (candidate: string) => boolean;
|
|
22
|
+
probe?: (command: string) => boolean;
|
|
23
|
+
}) => string | null;
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* npm 安装场景的启动器: 挑选运行时 (Bun 优先, 其次 Node) 后启动真实入口。
|
|
4
|
+
* 与 bin/{{BIN_NAME}} (sh) / bin/{{BIN_NAME}}.cmd (cmd) 职责同逻辑 (挑选运行时: Bun 优先, Node 回退),
|
|
5
|
+
* 差异在宿主与本文件多加的入口选择 (优先跑编译产物 dist/cli.js, 无产物则回退源码 src/cli.ts;
|
|
6
|
+
* 包内只有产物, 开发态通常无产物):
|
|
7
|
+
* 本文件同时承担 Unix 与 Windows 的 npm shim 目标 (shebang 必须是 node, 否则
|
|
8
|
+
* npm 的 cmd-shim 会按 shebang 解释器生成 Windows 上不存在的调用)。
|
|
9
|
+
*
|
|
10
|
+
* 运行时解析防劫持 (安全审计项 runtime-resolution:bare-name-cwd-precedence-windows):
|
|
11
|
+
* Windows 上裸名执行会先搜当前工作目录 (CreateProcessW 的搜索序里「parent 的当前目录」居第 2 位;
|
|
12
|
+
* 本文件走的 Node spawn 亦然 —— libuv 的 search_path 以 NeedCurrentDirectoryForExePathW 门控
|
|
13
|
+
* 先试 cwd 再扫 PATH), 而本工具的调用现场恰是「在被扫目录里执行」, 目录内放一个同名
|
|
14
|
+
* bun.exe / bun.com 即可顶替真实运行时进入执行链。故 win32 下先按 PATH 解析出绝对路径
|
|
15
|
+
* (空条目与相对条目都会把解析引回当前目录, 一并跳过) 再探测与执行, 解析面与执行面都不再
|
|
16
|
+
* 触发任何搜索序; POSIX 侧同法收紧 (空与相对条目在 POSIX 下同样意为当前目录), 并保持
|
|
17
|
+
* execvp「首候选不可执行时继续搜索」的语义 (逐候选探测)。
|
|
18
|
+
*
|
|
19
|
+
* 产物自证 (审计项「发行面 dist/cli.js 与源码和提交无身份绑定」的运行时防线): 决定跑
|
|
20
|
+
* dist/cli.js 之前必须与随附的 dist/manifest.json 对账 (形状版本受支持, 且清单记的 cliSha256
|
|
21
|
+
* 必须等于实测摘要), 清单缺失 / 损坏 / 版本不支持 / 摘要不符一律拒收产物并给出指引, 不静默回退
|
|
22
|
+
* 源码 (静默回退会把产物漂移藏起来, 包内也没有源码可回退); 拒收指引按宿主分流 (仓库检出态给
|
|
23
|
+
* 源码入口与重构建, 包态给重装本包)。工作树脏净不进本判定 (开发态常脏), 那是发布闸门
|
|
24
|
+
* scripts/verify-release.ts 的职责; 清单字段契约见 scripts/release-artifact.ts (包内无法
|
|
25
|
+
* 跨语言复用该模块, 两边口径由 src/npm-launcher.smoke.test.ts 的集成用例钉住)。
|
|
26
|
+
*
|
|
27
|
+
* 退出码原样透传; 两个运行时都缺席时给出可操作提示并非零退出。
|
|
28
|
+
*/
|
|
29
|
+
import { spawnSync } from 'node:child_process';
|
|
30
|
+
import { createHash } from 'node:crypto';
|
|
31
|
+
import { existsSync, readFileSync, realpathSync, statSync } from 'node:fs';
|
|
32
|
+
import { dirname, join, posix, win32 } from 'node:path';
|
|
33
|
+
import { fileURLToPath } from 'node:url';
|
|
34
|
+
|
|
35
|
+
/** 产物与清单的文件名 (与 scripts/release-artifact.ts 的 CLI_FILE / MANIFEST_FILE 同值) */
|
|
36
|
+
const CLI_FILE = 'cli.js';
|
|
37
|
+
const MANIFEST_FILE = 'manifest.json';
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* win32 的候选可执行扩展名, 顺序与 Node 实际走的 libuv 搜索一致 (.com 先于 .exe)。
|
|
41
|
+
* 不展开 PATHEXT: .bat / .cmd 无法被 Node 无 shell 直接执行, 展开只会把不可执行的命中当成功;
|
|
42
|
+
* 保持该面与 libuv 等价也意味着本次收紧不改动 win32 上「哪些安装形态能命中」的既有行为。
|
|
43
|
+
*/
|
|
44
|
+
const WIN32_EXEC_EXTS = ['.com', '.exe'];
|
|
45
|
+
|
|
46
|
+
/** 探测命令是否可执行 (以 --version 的实际退出码为准, 不依赖 shell 内建) */
|
|
47
|
+
const available = (command) =>
|
|
48
|
+
spawnSync(command, ['--version'], { stdio: 'ignore' }).status === 0;
|
|
49
|
+
|
|
50
|
+
/** 路径处是否为普通文件 (探针读不到即 false, 不抛; 目录名撞上候选名时不得当选) */
|
|
51
|
+
const isFileAt = (path) => {
|
|
52
|
+
try {
|
|
53
|
+
return statSync(path).isFile();
|
|
54
|
+
} catch {
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* 在 PATH 中解析命令的绝对路径 (win32 语义), 找不到返回 null。
|
|
61
|
+
* 只供 win32 分支调用: CreateProcessW 与 libuv 的裸名搜索序都会先搜当前目录, 本函数把
|
|
62
|
+
* 「当前目录」从解析面整个摘掉 —— 空条目 (Windows 上表示当前目录) 与相对条目 (同样按当前
|
|
63
|
+
* 目录解析) 一律跳过, 只认绝对目录; 条目两侧的引号按 libuv 同款剥掉 (Windows PATH 允许
|
|
64
|
+
* 引号包裹含空格的目录)。注入 pathEnv / fileProbe 供测试在非 win32 宿主上覆盖本函数。
|
|
65
|
+
*/
|
|
66
|
+
export const resolveWin32Executable = (name, pathEnv, fileProbe) => {
|
|
67
|
+
for (const raw of pathEnv.split(';')) {
|
|
68
|
+
const dir =
|
|
69
|
+
raw.length > 1 && raw.startsWith('"') && raw.endsWith('"')
|
|
70
|
+
? raw.slice(1, -1)
|
|
71
|
+
: raw;
|
|
72
|
+
if (dir === '' || !win32.isAbsolute(dir)) continue;
|
|
73
|
+
for (const ext of WIN32_EXEC_EXTS) {
|
|
74
|
+
const candidate = win32.join(dir, name + ext);
|
|
75
|
+
if (fileProbe(candidate)) return candidate;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return null;
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* 在 PATH 中解析命令的全部候选绝对路径 (POSIX 语义, 保持 PATH 顺序), 跳过空条目与相对
|
|
83
|
+
* 条目 (两者在 POSIX 下都按当前目录解析, 属本工具要摘掉的解析面; 与 win32 分支同一理由,
|
|
84
|
+
* 见文件头「运行时解析防劫持」)。返回数组而非首命中: 同名文件可能不可执行, execvp 在
|
|
85
|
+
* 该情形会继续搜索, 候选交由调用方逐个探测以保持同一语义。注入 pathEnv / fileProbe 供
|
|
86
|
+
* 测试在任意宿主上覆盖本函数。
|
|
87
|
+
*/
|
|
88
|
+
export const resolvePosixExecutables = (name, pathEnv, fileProbe) => {
|
|
89
|
+
const found = [];
|
|
90
|
+
for (const dir of pathEnv.split(':')) {
|
|
91
|
+
if (dir === '' || !dir.startsWith('/')) continue;
|
|
92
|
+
const candidate = posix.join(dir, name);
|
|
93
|
+
if (fileProbe(candidate)) found.push(candidate);
|
|
94
|
+
}
|
|
95
|
+
return found;
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* 挑选运行时: Bun 优先, 其次 Node; 皆无则 null (由调用处报错退出)。
|
|
100
|
+
* 两个平台都先按 PATH 解析绝对路径再探测 (理由见文件头「运行时解析防劫持」): win32 取
|
|
101
|
+
* 首个解析命中, POSIX 按 PATH 顺序逐个候选探测 (保持 execvp 的继续搜索语义); 各参数
|
|
102
|
+
* 显式传入供测试注入, 生产调用不传。
|
|
103
|
+
*/
|
|
104
|
+
export const pickRuntime = ({
|
|
105
|
+
platform = process.platform,
|
|
106
|
+
pathEnv = process.env.PATH ?? '',
|
|
107
|
+
fileProbe = isFileAt,
|
|
108
|
+
probe = available,
|
|
109
|
+
} = {}) => {
|
|
110
|
+
for (const name of ['bun', 'node']) {
|
|
111
|
+
if (platform === 'win32') {
|
|
112
|
+
const resolved = resolveWin32Executable(name, pathEnv, fileProbe);
|
|
113
|
+
if (resolved !== null && probe(resolved)) return resolved;
|
|
114
|
+
continue;
|
|
115
|
+
}
|
|
116
|
+
for (const candidate of resolvePosixExecutables(name, pathEnv, fileProbe)) {
|
|
117
|
+
if (probe(candidate)) return candidate;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return null;
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* 产物自证: 核对 dist/cli.js 与 dist/manifest.json 的摘要是否同源。
|
|
125
|
+
* 通过返回 null, 否则返回人话原因; 原因串全是本文件固定措辞, 不回显清单内容 (清单是外部
|
|
126
|
+
* 文件, 其文本不受控, 不落进输出面)。
|
|
127
|
+
*/
|
|
128
|
+
const artifactProblem = (distDir) => {
|
|
129
|
+
const manifestPath = join(distDir, MANIFEST_FILE);
|
|
130
|
+
if (!existsSync(manifestPath)) return `缺少产物清单 (dist/${MANIFEST_FILE})`;
|
|
131
|
+
let manifest;
|
|
132
|
+
try {
|
|
133
|
+
manifest = JSON.parse(readFileSync(manifestPath, 'utf8'));
|
|
134
|
+
} catch {
|
|
135
|
+
return `产物清单 (dist/${MANIFEST_FILE}) 损坏, 不是合法 JSON`;
|
|
136
|
+
}
|
|
137
|
+
// 形状版本先对: 异版本的字段语义无保证, 宁可拒收 (字面量 1 与 scripts/release-artifact.ts 的
|
|
138
|
+
// MANIFEST_SCHEMA_VERSION 同值, 改动须两处同步; 启动器随包分发, 包内无法 import 该模块)
|
|
139
|
+
if (manifest?.schemaVersion !== 1) {
|
|
140
|
+
return `产物清单 (dist/${MANIFEST_FILE}) 的 schemaVersion 不是受支持的版本 (期望 1)`;
|
|
141
|
+
}
|
|
142
|
+
const recorded = manifest?.cliSha256;
|
|
143
|
+
if (typeof recorded !== 'string') {
|
|
144
|
+
return `产物清单 (dist/${MANIFEST_FILE}) 缺少 cliSha256 字段`;
|
|
145
|
+
}
|
|
146
|
+
let actual;
|
|
147
|
+
try {
|
|
148
|
+
actual = createHash('sha256')
|
|
149
|
+
.update(readFileSync(join(distDir, CLI_FILE)))
|
|
150
|
+
.digest('hex');
|
|
151
|
+
} catch {
|
|
152
|
+
return `产物 (dist/${CLI_FILE}) 读不出来, 摘要算不出`;
|
|
153
|
+
}
|
|
154
|
+
if (recorded !== actual)
|
|
155
|
+
return `产物 (dist/${CLI_FILE}) 的摘要与清单记录不符`;
|
|
156
|
+
return null;
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* 本文件是否作为入口被直接执行。
|
|
161
|
+
* 经 realpath 比对而非字面路径: npm 在 Unix 上以符号链接 (或经 shim) 落 bin, 此时 argv[1] 是
|
|
162
|
+
* 链接路径而 import.meta.url 是解析后的真实路径。main 守卫只为让测试 import 本模块取函数时
|
|
163
|
+
* 不触发主流程, 判定失配的后果是入口静默不跑, 故除字面相等外只在 realpath 成功时采信。
|
|
164
|
+
*/
|
|
165
|
+
const isEntry = () => {
|
|
166
|
+
const entry = process.argv[1];
|
|
167
|
+
if (typeof entry !== 'string' || entry === '') return false;
|
|
168
|
+
const self = fileURLToPath(import.meta.url);
|
|
169
|
+
if (entry === self) return true;
|
|
170
|
+
try {
|
|
171
|
+
return realpathSync(entry) === self;
|
|
172
|
+
} catch {
|
|
173
|
+
return false;
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
const main = () => {
|
|
178
|
+
const root = dirname(dirname(fileURLToPath(import.meta.url)));
|
|
179
|
+
const distDir = join(root, 'dist');
|
|
180
|
+
const built = join(distDir, CLI_FILE);
|
|
181
|
+
const hasBuilt = existsSync(built);
|
|
182
|
+
// 有产物就得先自证 (与随附清单对账); 不通过即拒收, 退出码与「无运行时」同一档: 1
|
|
183
|
+
const problem = hasBuilt ? artifactProblem(distDir) : null;
|
|
184
|
+
if (problem !== null) {
|
|
185
|
+
// 处置指引按宿主分流: 仓库检出态 (有源码) 可走源码入口或重构建; 包态 (无源码) 只能重装本包
|
|
186
|
+
const advice = existsSync(join(root, 'src', 'cli.ts'))
|
|
187
|
+
? '用源码入口跑 (bun src/cli.ts 或 node src/cli.ts), 或重新构建 (bun run build)'
|
|
188
|
+
: '重装本包换一份完好分发 (npm install -g {{SCOPE}}/{{NAME}}-cli); 重装无效则说明该版本包有缺陷, 需发布者重新构建后再发';
|
|
189
|
+
process.stderr.write(
|
|
190
|
+
`{{BIN_NAME}}: ${problem}, 已拒绝执行该产物 (无法证明它与构建清单同源)。\n` +
|
|
191
|
+
` 处置: ${advice}。\n`,
|
|
192
|
+
);
|
|
193
|
+
process.exit(1);
|
|
194
|
+
}
|
|
195
|
+
// npm 包内是编译产物 (node 拒绝对 node_modules 内的 TS 做类型剥离, 见 package.json 的 build 脚本);
|
|
196
|
+
// 仓库开发态无 dist, 回退直跑源码 (bun / node 皆可)
|
|
197
|
+
const entry = hasBuilt ? built : join(root, 'src', 'cli.ts');
|
|
198
|
+
const runtime = pickRuntime();
|
|
199
|
+
|
|
200
|
+
if (runtime === null) {
|
|
201
|
+
process.stderr.write('{{BIN_NAME}}: 未找到 bun 或 node, 请至少安装其一\n');
|
|
202
|
+
process.exit(1);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
const { status } = spawnSync(runtime, [entry, ...process.argv.slice(2)], {
|
|
206
|
+
stdio: 'inherit',
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
process.exit(status ?? 1);
|
|
210
|
+
};
|
|
211
|
+
|
|
212
|
+
if (isEntry()) main();
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# {{SCOPE}}/{{NAME}}-cli (CLI 包) 文档
|
|
2
|
+
|
|
3
|
+
> 文档类型: 包级文档入口
|
|
4
|
+
|
|
5
|
+
`{{SCOPE}}/{{NAME}}-cli` 是示例工具的命令行薄壳: 换成自己的命令后, 在此登记包内文档与包级 ADR。使用面见[包 README](../README.md)。
|
|
6
|
+
|
|
7
|
+
## 包内文档
|
|
8
|
+
|
|
9
|
+
| 文档 | 一句话 |
|
|
10
|
+
| -------- | ------------------------------------ |
|
|
11
|
+
| (待登记) | 新项目在这里登记包级设计文档的第一篇 |
|
|
12
|
+
|
|
13
|
+
## 包级 ADR
|
|
14
|
+
|
|
15
|
+
| 编号 | 标题 |
|
|
16
|
+
| -------- | ----------------------------- |
|
|
17
|
+
| (待登记) | 包级 ADR 与仓库级共用一套编号 |
|
|
18
|
+
|
|
19
|
+
## 仓库级关联
|
|
20
|
+
|
|
21
|
+
- [仓库文档索引](../../../docs/README.md) / [设计文档索引](../../../docs/designs/README.md)。
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "{{SCOPE}}/{{NAME}}-cli",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"description": "The command-line tool of this collection: a thin shell over the API package, where the domain logic lives. 本集合仓的命令行示例包。",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"cli",
|
|
7
|
+
"cli-tool",
|
|
8
|
+
"tool",
|
|
9
|
+
"typescript",
|
|
10
|
+
"bun",
|
|
11
|
+
"node"
|
|
12
|
+
],
|
|
13
|
+
"author": "{{OWNER}} (https://github.com/{{OWNER}})",
|
|
14
|
+
"license": "MIT",
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "git+{{REPO_URL}}.git"
|
|
18
|
+
},
|
|
19
|
+
"homepage": "{{REPO_URL}}#readme",
|
|
20
|
+
"bugs": {
|
|
21
|
+
"url": "{{REPO_URL}}/issues"
|
|
22
|
+
},
|
|
23
|
+
"type": "module",
|
|
24
|
+
"bin": {
|
|
25
|
+
"{{BIN_NAME}}": "bin/{{BIN_NAME}}.mjs"
|
|
26
|
+
},
|
|
27
|
+
"files": [
|
|
28
|
+
"bin/{{BIN_NAME}}.mjs",
|
|
29
|
+
"dist"
|
|
30
|
+
],
|
|
31
|
+
"engines": {
|
|
32
|
+
"node": ">=22.18.0"
|
|
33
|
+
},
|
|
34
|
+
"publishConfig": {
|
|
35
|
+
"access": "public",
|
|
36
|
+
"registry": "https://registry.npmjs.org/"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"{{SCOPE}}/{{NAME}}": "0.0.0"
|
|
40
|
+
},
|
|
41
|
+
"scripts": {
|
|
42
|
+
"build": "bun build src/cli.ts --target=node --outfile=dist/cli.js && bun scripts/write-dist-manifest.ts",
|
|
43
|
+
"prepublishOnly": "npm run build && npm run verify:release",
|
|
44
|
+
"verify:release": "bun scripts/verify-release.ts",
|
|
45
|
+
"typecheck": "tsc --noEmit",
|
|
46
|
+
"test": "bun test"
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 发布自证闸门 (CLI 包) 的适配层: 判定本体与事实读取在共享库 (scripts/lib/release-verify.ts,
|
|
3
|
+
* 与 API 包同源, 结构对称), 本文件只表达 CLI 侧的坐标与口径差异 (产物文件名 / 清单摘要字段名 /
|
|
4
|
+
* 面包白名单 / manifest 契约), 并向包内消费方 (verify-release / write-dist-manifest / 测试)
|
|
5
|
+
* 保持稳定的导出面。
|
|
6
|
+
*
|
|
7
|
+
* 判定序 (共享库统一, 顺序即口径): 检出可信 (git 可读 / 有提交 / 工作树干净) → 产物就位
|
|
8
|
+
* (存在 / 非空 / 可读) → 清单与提交、产物对账 → 面包白名单。
|
|
9
|
+
*/
|
|
10
|
+
import { resolve } from 'node:path';
|
|
11
|
+
|
|
12
|
+
import {
|
|
13
|
+
type DistState,
|
|
14
|
+
type ReleaseFacts,
|
|
15
|
+
type ReleaseVerdict,
|
|
16
|
+
type VerifyProfile,
|
|
17
|
+
judgePackFiles as judgePackFilesCommon,
|
|
18
|
+
judgeRelease as judgeReleaseCommon,
|
|
19
|
+
normalizeCommit,
|
|
20
|
+
readDistState as readDistStateCommon,
|
|
21
|
+
readGitText,
|
|
22
|
+
} from '../../../scripts/lib/release-verify.ts';
|
|
23
|
+
|
|
24
|
+
export const PACKAGE_ROOT = resolve(import.meta.dir, '..');
|
|
25
|
+
|
|
26
|
+
/** CLI 产物主文件 (dist/ 下) */
|
|
27
|
+
export const CLI_FILE = 'cli.js';
|
|
28
|
+
|
|
29
|
+
/** 产物清单文件名 (dist/ 下) */
|
|
30
|
+
export const MANIFEST_FILE = 'manifest.json';
|
|
31
|
+
|
|
32
|
+
/** 清单形状版本 */
|
|
33
|
+
export const MANIFEST_SCHEMA_VERSION = 1;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* 发行面包的期望文件集: files 白名单 (dist) 的物化 + npm 强制包含项 (README / LICENSE /
|
|
37
|
+
* package.json 等文件由 npm 无条件收进包, 且官方没有任何「排除」通道 (npm docs configuring-npm/
|
|
38
|
+
* package-json「files」节的排除语义 + 本机 npm-packlist 的 strict 规则, 见 ADR 0009 补记),
|
|
39
|
+
* 仓库根多一份 README 备份就会被静默收进发行包。本常量把「包内应有什么」显式声明成契约,
|
|
40
|
+
* 发布前逐项对账。
|
|
41
|
+
*
|
|
42
|
+
* 改动义务: package.json 的 files / bin 变更, 或仓库根增删总是收录类文件时, 必须同步本清单,
|
|
43
|
+
* 否则闸门会拒绝发布 (这正是它存在的目的: 发行面变化必须是一次显式决定, 不能靠静默)。
|
|
44
|
+
*/
|
|
45
|
+
export const PACK_FILES_EXPECTED: readonly string[] = [
|
|
46
|
+
'LICENSE',
|
|
47
|
+
'README.md',
|
|
48
|
+
'README.zh-CN.md',
|
|
49
|
+
'bin/{{BIN_NAME}}.mjs',
|
|
50
|
+
'dist/cli.js',
|
|
51
|
+
'dist/manifest.json',
|
|
52
|
+
'package.json',
|
|
53
|
+
];
|
|
54
|
+
|
|
55
|
+
/** CLI 侧闸门坐标 (差异面收口) */
|
|
56
|
+
const PROFILE: VerifyProfile = {
|
|
57
|
+
entryFile: CLI_FILE,
|
|
58
|
+
manifestFile: MANIFEST_FILE,
|
|
59
|
+
shaField: 'cliSha256',
|
|
60
|
+
schemaVersion: MANIFEST_SCHEMA_VERSION,
|
|
61
|
+
packExpected: PACK_FILES_EXPECTED,
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
/** dist/manifest.json 的字段契约 (构建写入、闸门与启动器读, 两侧同源) */
|
|
65
|
+
export interface DistManifest {
|
|
66
|
+
/** 形状版本, 恒为 MANIFEST_SCHEMA_VERSION */
|
|
67
|
+
schemaVersion: number;
|
|
68
|
+
/** 构建时 HEAD 的完整哈希; 非 git 检出为 null */
|
|
69
|
+
commit: string | null;
|
|
70
|
+
/** 构建时工作树是否不干净; 读不到为 null */
|
|
71
|
+
dirty: boolean | null;
|
|
72
|
+
/** 产物 (dist/cli.js) 的 sha256 十六进制 */
|
|
73
|
+
cliSha256: string;
|
|
74
|
+
/** 构建时刻 (ISO 8601), 仅供人读诊断; 时间不是判据, 判定只看提交与摘要 */
|
|
75
|
+
builtAt: string;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** 构建侧 git 事实 (collectGitFacts 的产物, 写清单用) */
|
|
79
|
+
export interface GitFacts {
|
|
80
|
+
/** HEAD 提交的完整哈希 */
|
|
81
|
+
commit: string | null;
|
|
82
|
+
/** 工作树是否有未提交改动 (含未跟踪文件) */
|
|
83
|
+
dirty: boolean | null;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// ---- 共享库直通导出 (包内消费方经本文件取用, 路径与命名保持稳定) ----
|
|
87
|
+
|
|
88
|
+
export {
|
|
89
|
+
countDirtyEntries,
|
|
90
|
+
normalizeCommit,
|
|
91
|
+
parsePackFiles,
|
|
92
|
+
previewDirtyEntries,
|
|
93
|
+
readGitText,
|
|
94
|
+
readPackFiles,
|
|
95
|
+
sha256File,
|
|
96
|
+
shortHash,
|
|
97
|
+
} from '../../../scripts/lib/release-verify.ts';
|
|
98
|
+
export type {
|
|
99
|
+
DistState,
|
|
100
|
+
PackFacts,
|
|
101
|
+
ReleaseFacts,
|
|
102
|
+
ReleaseVerdict,
|
|
103
|
+
} from '../../../scripts/lib/release-verify.ts';
|
|
104
|
+
|
|
105
|
+
/** 读产物目录现状 (CLI 口径) */
|
|
106
|
+
export const readDistState = (distDir: string): DistState =>
|
|
107
|
+
readDistStateCommon(distDir, PROFILE);
|
|
108
|
+
|
|
109
|
+
/** 发行面包白名单判定 (CLI 口径) */
|
|
110
|
+
export const judgePackFiles = (
|
|
111
|
+
files: string[],
|
|
112
|
+
): { ok: true } | { ok: false; reason: string } =>
|
|
113
|
+
judgePackFilesCommon(files, PACK_FILES_EXPECTED);
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* 发布闸门判定 (纯函数, 不碰文件系统): 委托共享库按统一判定序执行 (CLI 无专属判定项)。
|
|
117
|
+
*/
|
|
118
|
+
export const judgeRelease = (facts: ReleaseFacts): ReleaseVerdict =>
|
|
119
|
+
judgeReleaseCommon(facts, PROFILE);
|
|
120
|
+
|
|
121
|
+
/** 采 git 事实 (构建侧写清单用): 在 root 内跑两条只读命令, 任一步读不到即落 null */
|
|
122
|
+
export const collectGitFacts = (root: string): GitFacts => {
|
|
123
|
+
const status = readGitText(root, ['status', '--porcelain']);
|
|
124
|
+
return {
|
|
125
|
+
commit: normalizeCommit(readGitText(root, ['rev-parse', 'HEAD'])),
|
|
126
|
+
dirty: status === null ? null : status.trim() !== '',
|
|
127
|
+
};
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
/** 组装清单 (构建侧写入的正是这份数据; 字段形状即契约) */
|
|
131
|
+
export const buildManifest = (fields: {
|
|
132
|
+
cliSha256: string;
|
|
133
|
+
git: GitFacts;
|
|
134
|
+
builtAt: string;
|
|
135
|
+
}): DistManifest => ({
|
|
136
|
+
schemaVersion: MANIFEST_SCHEMA_VERSION,
|
|
137
|
+
commit: fields.git.commit,
|
|
138
|
+
dirty: fields.git.dirty,
|
|
139
|
+
cliSha256: fields.cliSha256,
|
|
140
|
+
builtAt: fields.builtAt,
|
|
141
|
+
});
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 发行面闸门测试的共享夹具: 临时目录与临时 git 检出 (一次初始提交 + 忽略 dist/ 的 .gitignore)。
|
|
3
|
+
* 为什么用真 git 而不是打桩: 闸门的事实输入就是 git 命令的输出, 打桩只能证明判定函数自洽,
|
|
4
|
+
* 证明不了「porcelain 空输出等于工作树干净」这条口径; 临时仓库建一次几十毫秒, 换的是真口径。
|
|
5
|
+
* 建仓是夹具内部步骤, 与产品代码的只读 git 探测 (release-artifact.ts) 无关。
|
|
6
|
+
*/
|
|
7
|
+
import { spawnSync } from 'node:child_process';
|
|
8
|
+
import { mkdtemp, realpath, rm, writeFile } from 'node:fs/promises';
|
|
9
|
+
import { tmpdir } from 'node:os';
|
|
10
|
+
import { join } from 'node:path';
|
|
11
|
+
|
|
12
|
+
import { cleanGitEnv } from '../../../scripts/lib/git-env.ts';
|
|
13
|
+
|
|
14
|
+
export interface TempDir {
|
|
15
|
+
root: string;
|
|
16
|
+
cleanup: () => Promise<void>;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/** 临时目录 (realpath 归一: macOS 上 /var 与 /private/var 是同一处的两种拼写) */
|
|
20
|
+
export const makeTempDir = async (prefix: string): Promise<TempDir> => {
|
|
21
|
+
const root = await realpath(await mkdtemp(join(tmpdir(), prefix)));
|
|
22
|
+
return {
|
|
23
|
+
root,
|
|
24
|
+
cleanup: async () => {
|
|
25
|
+
await rm(root, { recursive: true, force: true });
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* 同步跑一条 git 命令 (夹具自用; 失败即抛: 建仓出错不该被当成用例结论继续跑)。
|
|
32
|
+
* env 经 cleanGitEnv: 宿主的 GIT_* 坐标不得把临时仓库的 init / add / commit 改道到宿主仓库。
|
|
33
|
+
*/
|
|
34
|
+
export const runGit = (cwd: string, args: string[]): string => {
|
|
35
|
+
const result = spawnSync('git', args, {
|
|
36
|
+
cwd,
|
|
37
|
+
encoding: 'utf8',
|
|
38
|
+
env: cleanGitEnv(),
|
|
39
|
+
});
|
|
40
|
+
if (result.status !== 0) {
|
|
41
|
+
throw new Error(`git ${args.join(' ')} 失败: ${result.stderr.trim()}`);
|
|
42
|
+
}
|
|
43
|
+
return result.stdout;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* 临时 git 检出: 一次初始提交, 工作树干净; .gitignore 忽略 dist/ (与真实仓库同款,
|
|
48
|
+
* 使「造产物」这一步不会反过来把工作树弄脏)。
|
|
49
|
+
* 提交带上 --no-verify 与 commit.gpgsign=false: 夹具不该被宿主的钩子 / 签名配置干扰。
|
|
50
|
+
*/
|
|
51
|
+
export const makeTempRepo = async (prefix: string): Promise<TempDir> => {
|
|
52
|
+
const temp = await makeTempDir(prefix);
|
|
53
|
+
await writeFile(join(temp.root, '.gitignore'), 'dist/\n');
|
|
54
|
+
await writeFile(join(temp.root, 'workspace.txt'), '基线\n');
|
|
55
|
+
runGit(temp.root, ['init']);
|
|
56
|
+
runGit(temp.root, ['add', '-A']);
|
|
57
|
+
runGit(temp.root, [
|
|
58
|
+
'-c',
|
|
59
|
+
'commit.gpgsign=false',
|
|
60
|
+
'-c',
|
|
61
|
+
'user.name=sweep-lab',
|
|
62
|
+
'-c',
|
|
63
|
+
'user.email=sweep-lab@example.com',
|
|
64
|
+
'commit',
|
|
65
|
+
'--no-verify',
|
|
66
|
+
'-m',
|
|
67
|
+
'基线',
|
|
68
|
+
]);
|
|
69
|
+
return temp;
|
|
70
|
+
};
|