linkany 0.0.2 → 0.0.3

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
@@ -146,6 +146,7 @@
146
146
  - 默认写入:`${manifestPath}.log.jsonl`
147
147
  - 每行是一条 JSON(完整 `Result`),包含:执行步骤、错误、耗时、变更摘要。
148
148
  - 可通过 `opts.auditLogPath` 指定自定义路径。
149
+ - 如需完全关闭审计(由上层自行处理),传 `opts.audit=false`;CLI 对应 `--no-audit`。
149
150
 
150
151
  ## Options(opts)
151
152
 
package/dist/cli.js CHANGED
@@ -41,7 +41,8 @@ function parseCommonOptions(args) {
41
41
  const dryRun = hasFlag(args, ['--dry-run']);
42
42
  const includePlanText = hasFlag(args, ['--plan']);
43
43
  const auditLogPath = popFlagValue(args, ['--audit-log']);
44
- return { dryRun, includePlanText, auditLogPath };
44
+ const audit = hasFlag(args, ['--no-audit']) ? false : undefined;
45
+ return { dryRun, includePlanText, auditLogPath, audit };
45
46
  }
46
47
  async function resolveManifestPath(args) {
47
48
  const m = popFlagValue(args, ['-m', '--manifest']);
@@ -61,10 +62,10 @@ Usage:
61
62
  linkany manifest show
62
63
  linkany manifest clear
63
64
 
64
- linkany add --source <path> --target <path> [--kind file|dir] [--atomic|--no-atomic] [-m <manifest>] [--dry-run] [--plan]
65
- linkany remove <key> [--keep-link] [-m <manifest>] [--dry-run] [--plan]
66
- linkany install [-m <manifest>] [--dry-run] [--plan]
67
- linkany uninstall [-m <manifest>] [--dry-run] [--plan]
65
+ linkany add --source <path> --target <path> [--kind file|dir] [--atomic|--no-atomic] [-m <manifest>] [--dry-run] [--plan] [--no-audit]
66
+ linkany remove <key> [--keep-link] [-m <manifest>] [--dry-run] [--plan] [--no-audit]
67
+ linkany install [-m <manifest>] [--dry-run] [--plan] [--no-audit]
68
+ linkany uninstall [-m <manifest>] [--dry-run] [--plan] [--no-audit]
68
69
  `;
69
70
  process.stdout.write(msg.trimStart());
70
71
  process.stdout.write('\n');
@@ -9,6 +9,8 @@ export async function appendAudit(logPath, result) {
9
9
  await fs.appendFile(logPath, line, 'utf8');
10
10
  }
11
11
  export async function tryAppendAuditStep(result, manifestPath, opts) {
12
+ if (opts?.audit === false)
13
+ return result;
12
14
  const logPath = opts?.auditLogPath ?? (manifestPath ? `${path.resolve(manifestPath)}.log.jsonl` : undefined);
13
15
  if (!logPath)
14
16
  return result;
@@ -24,7 +24,9 @@ export async function runOperation(input) {
24
24
  if (input.finalize) {
25
25
  res = await input.finalize(res);
26
26
  }
27
- res = await tryAppendAuditStep(res, input.manifestPath, input.opts);
27
+ if (input.opts?.audit !== false) {
28
+ res = await tryAppendAuditStep(res, input.manifestPath, input.opts);
29
+ }
28
30
  logger?.info?.(`[linkany] ${input.operation} ${res.ok ? 'ok' : 'fail'} (${res.durationMs}ms)`);
29
31
  return res;
30
32
  }
package/dist/types.d.ts CHANGED
@@ -55,6 +55,13 @@ export interface Logger {
55
55
  error(msg: string): void;
56
56
  }
57
57
  export interface CommonOptions {
58
+ /**
59
+ * Whether to append an audit log entry for this operation.
60
+ * Default: true.
61
+ *
62
+ * Set to false if the caller wants to fully disable audit logging and handle it themselves.
63
+ */
64
+ audit?: boolean;
58
65
  /**
59
66
  * If provided, we append one JSON line per operation (Result summary).
60
67
  * Default strategy (V1): `${manifestPath}.log.jsonl` when manifestPath is known.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "linkany",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",