dsh-config-manager 0.4.1 → 0.4.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.
Files changed (122) hide show
  1. package/lib/cli/actions.js +2 -3
  2. package/lib/cli/import-source.js +2 -6
  3. package/lib/cli/index.js +2 -3
  4. package/lib/client.d.ts +0 -5
  5. package/lib/client.js +26116 -25801
  6. package/lib/core/exporter.js +2 -4
  7. package/lib/core/host-schedulers/cache-cleanup.d.ts +41 -0
  8. package/lib/core/host-schedulers/cache-cleanup.js +45 -0
  9. package/lib/core/host-schedulers/lifecycle-hooks.d.ts +51 -0
  10. package/lib/core/host-schedulers/lifecycle-hooks.js +78 -0
  11. package/lib/core/host-schedulers/market-cache.d.ts +40 -0
  12. package/lib/core/host-schedulers/market-cache.js +92 -0
  13. package/lib/core/model-tools.js +2 -6
  14. package/lib/core/restore.d.ts +0 -2
  15. package/lib/core/restore.js +16 -18
  16. package/lib/core/verify-recovery.js +4 -7
  17. package/lib/index.d.ts +3 -22
  18. package/lib/index.js +69 -325
  19. package/lib/profiles/dsh-profile-manager.d.ts +23 -1
  20. package/lib/profiles/dsh-profile-manager.js +70 -2
  21. package/lib/routes/kit.d.ts +21 -0
  22. package/lib/routes/kit.js +29 -0
  23. package/lib/routes/prefs.js +6 -6
  24. package/lib/routes/recovery.js +25 -41
  25. package/lib/routes/route-support.d.ts +23 -1
  26. package/lib/routes/route-support.js +185 -0
  27. package/lib/routes/snapshots.js +4 -11
  28. package/lib/routes/sync.js +5 -7
  29. package/lib/security/redaction.d.ts +5 -1
  30. package/lib/security/redaction.js +26 -23
  31. package/lib/sync/backup-scheduler.js +2 -6
  32. package/lib/ui/backup-inspect.d.ts +1 -1
  33. package/lib/ui/dsh-profiles-view.d.ts +0 -10
  34. package/lib/ui/dsh-profiles-view.js +3 -7
  35. package/lib/ui/snapshots-view.d.ts +0 -14
  36. package/lib/ui/snapshots-view.js +16 -2
  37. package/lib/utils/paths.d.ts +20 -4
  38. package/lib/utils/paths.js +22 -6
  39. package/lib/utils/time.d.ts +31 -0
  40. package/lib/utils/time.js +54 -0
  41. package/package.json +1 -1
  42. package/src/cli/actions.ts +2 -3
  43. package/src/cli/import-source.ts +2 -7
  44. package/src/cli/index.ts +2 -3
  45. package/src/client/about/AboutPanel.tsx +1 -1
  46. package/src/client/about/ReleaseBody.tsx +22 -52
  47. package/src/client/about/ReleaseNotesDialog.tsx +15 -69
  48. package/src/client/about/release-notes-view.ts +4 -11
  49. package/src/client/common/info-hint-guard.test.ts +11 -5
  50. package/src/client/common/ui.tsx +23 -0
  51. package/src/client/config-manager.module.css +201 -32
  52. package/src/client/css-token-guard.test.ts +135 -1
  53. package/src/client/import/ConflictList.tsx +3 -3
  54. package/src/client/import/ImportWizardView.tsx +1 -1
  55. package/src/client/library/ArtifactRow.tsx +2 -2
  56. package/src/client/library/RestorePlanView.tsx +21 -9
  57. package/src/client/library/report-dismiss.test.ts +5 -3
  58. package/src/client/locales/about.ts +97 -0
  59. package/src/client/locales/backup.ts +141 -0
  60. package/src/client/locales/common.ts +113 -0
  61. package/src/client/locales/export.ts +184 -0
  62. package/src/client/locales/foreign.ts +184 -0
  63. package/src/client/locales/import-compat.ts +32 -0
  64. package/src/client/locales/import.ts +192 -0
  65. package/src/client/locales/next-steps.ts +25 -0
  66. package/src/client/locales/overview-control.ts +32 -0
  67. package/src/client/locales/overview.ts +145 -0
  68. package/src/client/locales/profiles.ts +263 -0
  69. package/src/client/locales/report.ts +17 -0
  70. package/src/client/locales/restore.ts +132 -0
  71. package/src/client/locales/sessions.ts +257 -0
  72. package/src/client/locales/shell.ts +149 -0
  73. package/src/client/locales.ts +49 -1783
  74. package/src/client/market/MarketImportReview.tsx +2 -2
  75. package/src/client/market/MarketPanel.tsx +1 -1
  76. package/src/client/market/market-view.ts +3 -5
  77. package/src/client/recovery/RecoveryPanel.tsx +62 -1054
  78. package/src/client/recovery/SessionHealthCard.tsx +134 -0
  79. package/src/client/recovery/SessionHealthDialog.tsx +665 -0
  80. package/src/client/recovery/SessionLayoutSection.tsx +284 -0
  81. package/src/client/recovery/recovery-api.ts +10 -1
  82. package/src/client/recovery/recovery-panel-layout.test.ts +20 -5
  83. package/src/client/recovery/session-dialog-mount.test.ts +16 -9
  84. package/src/client/recovery/use-recovery-write.test.ts +90 -0
  85. package/src/client/recovery/use-recovery-write.ts +53 -0
  86. package/src/client/run-store.ts +57 -2
  87. package/src/client/sync/PushPreviewCard.tsx +2 -2
  88. package/src/client/sync/SyncConfirmView.tsx +5 -5
  89. package/src/client/sync/SyncLogList.tsx +2 -2
  90. package/src/client/sync/history-model.ts +4 -5
  91. package/src/client/sync/sync-view.ts +3 -4
  92. package/src/core/exporter.ts +2 -4
  93. package/src/core/host-schedulers/cache-cleanup.test.ts +84 -0
  94. package/src/core/host-schedulers/cache-cleanup.ts +74 -0
  95. package/src/core/host-schedulers/lifecycle-hooks.test.ts +111 -0
  96. package/src/core/host-schedulers/lifecycle-hooks.ts +118 -0
  97. package/src/core/host-schedulers/market-cache.test.ts +93 -0
  98. package/src/core/host-schedulers/market-cache.ts +116 -0
  99. package/src/core/model-tools.ts +2 -7
  100. package/src/core/restore-failure-state.test.ts +210 -0
  101. package/src/core/restore.ts +16 -18
  102. package/src/core/verify-recovery.ts +4 -7
  103. package/src/index.ts +76 -330
  104. package/src/profiles/dsh-profile-copy-rollback.test.ts +156 -0
  105. package/src/profiles/dsh-profile-manager.ts +71 -3
  106. package/src/routes/kit.ts +37 -0
  107. package/src/routes/prefs.ts +6 -6
  108. package/src/routes/recovery.ts +25 -42
  109. package/src/routes/route-support.ts +208 -1
  110. package/src/routes/snapshots.ts +4 -9
  111. package/src/routes/sync.ts +4 -7
  112. package/src/security/redaction.ts +29 -23
  113. package/src/sync/backup-scheduler.ts +3 -6
  114. package/src/sync/sync-config.test.ts +24 -13
  115. package/src/ui/backup-inspect.ts +1 -1
  116. package/src/ui/dsh-profiles-view.ts +3 -5
  117. package/src/ui/i18n.test.ts +8 -3
  118. package/src/ui/snapshots-view.ts +2 -2
  119. package/src/utils/paths.test.ts +36 -1
  120. package/src/utils/paths.ts +30 -6
  121. package/src/utils/time.test.ts +46 -0
  122. package/src/utils/time.ts +55 -0
@@ -28,6 +28,7 @@ import { readTextSafe } from '../profiles/dsh-profile-io.js';
28
28
  import { AUTO_BACKUP_PREFIX, DEFAULT_BACKUP_RETENTION, listBackupFiles, } from '../sync/backup-files.js';
29
29
  import { EnvironmentLockManager, OWNERSHIP_FILE } from '../utils/env-lock.js';
30
30
  import { scanSessionHealth } from '../utils/session-health-scan.js';
31
+ import { formatDateStamp } from '../utils/time.js';
31
32
  /* ------------------------------------------------------------ 进程/实例事实 */
32
33
  /** 进程是否存活(不发送信号,只探测)。EPERM = 存在但无权限发信号 → 仍算存活。 */
33
34
  export function isProcessAlive(pid) {
@@ -970,9 +971,7 @@ export async function exportOfflineBackup(paths, sections) {
970
971
  if (collection.entries.length === 0) {
971
972
  return { ok: false, code: 'nothing-to-export', message: '没有可打包的内容(该 home 下未找到可离线收集的分区)。' };
972
973
  }
973
- const now = new Date();
974
- const stamp = String(now.getFullYear()) + String(now.getMonth() + 1).padStart(2, '0') + String(now.getDate()).padStart(2, '0')
975
- + '-' + String(now.getHours()).padStart(2, '0') + String(now.getMinutes()).padStart(2, '0') + String(now.getSeconds()).padStart(2, '0');
974
+ const stamp = formatDateStamp();
976
975
  const { randomBytes } = await import('node:crypto');
977
976
  const desired = 'dsh-config-cli-' + stamp + '-' + randomBytes(4).toString('hex') + '.zip';
978
977
  await fsp.mkdir(paths.exportsDir, { recursive: true });
@@ -21,6 +21,7 @@ import { verifyBackupZip } from '../core/backup-verify.js';
21
21
  import { writeForeignBundle } from '../foreign/bundle.js';
22
22
  import { FOREIGN_CONFLICT_POLICY, ForeignSourceError, createBuiltinForeignSourceRegistry, } from '../foreign/registry.js';
23
23
  import { foreignSourceContext } from '../routes/foreign-context.js';
24
+ import { formatDateStamp } from '../utils/time.js';
24
25
  /** 分区摘要的一行:文件类给文件数,JSON 类给该分区的计数键(全部是机器可读的条目数) */
25
26
  function sectionLine(section, result) {
26
27
  if (section.files !== undefined)
@@ -67,7 +68,7 @@ function printImportSummary(sourceId, detection, result, io) {
67
68
  async function resolveOutPath(options, sourceId) {
68
69
  const desired = options.out !== undefined && options.out !== ''
69
70
  ? path.resolve(options.out)
70
- : path.join(options.exportsDir, 'foreign-' + sourceId + '-' + stamp() + '-' + randomHex4() + '.zip');
71
+ : path.join(options.exportsDir, 'foreign-' + sourceId + '-' + formatDateStamp() + '-' + randomHex4() + '.zip');
71
72
  if (!(await pathExists(desired)))
72
73
  return desired;
73
74
  const base = desired.endsWith('.zip') ? desired.slice(0, -4) : desired;
@@ -77,11 +78,6 @@ async function resolveOutPath(options, sourceId) {
77
78
  return candidate;
78
79
  }
79
80
  }
80
- function stamp() {
81
- const now = new Date();
82
- return `${now.getFullYear()}${String(now.getMonth() + 1).padStart(2, '0')}${String(now.getDate()).padStart(2, '0')}`
83
- + `-${String(now.getHours()).padStart(2, '0')}${String(now.getMinutes()).padStart(2, '0')}${String(now.getSeconds()).padStart(2, '0')}`;
84
- }
85
81
  function randomHex4() {
86
82
  // 用全局 crypto(Node ≥ 19);零额外依赖
87
83
  const bytes = new Uint8Array(4);
package/lib/cli/index.js CHANGED
@@ -39,6 +39,7 @@ import { buildChecksums } from '../utils/hashing.js';
39
39
  import { stringifyJsonSafe } from '../utils/json.js';
40
40
  import { buildManifest, CHECKSUMS_FILE, MANIFEST_FILE } from '../schema/manifest.js';
41
41
  import { writeZip } from '../utils/zip.js';
42
+ import { formatDateStamp } from '../utils/time.js';
42
43
  const VALUE_FLAGS = new Map([
43
44
  ['--data-dir', 'dataDir'],
44
45
  ['--data-root', 'dataRoot'],
@@ -1191,9 +1192,7 @@ async function runBackup(options, io, env) {
1191
1192
  }
1192
1193
  else {
1193
1194
  // 注意:此处刻意不 mkdir —— dry-run 必须零写入,目录在真正落盘前才创建
1194
- const now = new Date();
1195
- const stamp = `${now.getFullYear()}${String(now.getMonth() + 1).padStart(2, '0')}${String(now.getDate()).padStart(2, '0')}`
1196
- + `-${String(now.getHours()).padStart(2, '0')}${String(now.getMinutes()).padStart(2, '0')}${String(now.getSeconds()).padStart(2, '0')}`;
1195
+ const stamp = formatDateStamp();
1197
1196
  try {
1198
1197
  const rand = await randomHex4();
1199
1198
  outPath = await resolveNonCollidingName(exportsDir, `dsh-config-cli-${stamp}-${rand}.zip`);
package/lib/client.d.ts CHANGED
@@ -5014,11 +5014,6 @@ interface ConfigManagerSectionInjected {
5014
5014
  */
5015
5015
  uiT: UiT;
5016
5016
  }
5017
- /**
5018
- * Config Manager 表面文案:zh 为源语言,en 镜像每个键。
5019
- * 字典 namespace 由 client/index.ts 注册(declare module 合并进 LocaleNamespaceMap)。
5020
- * 键集合通过 `ConfigManagerKey` 类型在注册处做编译期校验(缺键/多键即编译错误)。
5021
- */
5022
5017
  declare const zh$4: {
5023
5018
  readonly 'section.label': '备份与迁移';
5024
5019
  readonly 'section.description': '导出 / 导入 / 迁移 DSH 配置(备份不含密钥,加密备份可选)';