@slats/claude-assets-sync 0.1.4 โ 0.2.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/README.md +111 -587
- package/bin/claude-sync.mjs +24 -0
- package/dist/claude-hashes.json +20 -0
- package/dist/commands/index.d.ts +1 -112
- package/dist/commands/runCli/index.d.ts +2 -0
- package/dist/commands/runCli/runCli.cjs +31 -0
- package/dist/commands/runCli/runCli.d.ts +10 -0
- package/dist/commands/runCli/runCli.mjs +29 -0
- package/dist/commands/runCli/type.d.ts +28 -0
- package/dist/commands/runCli/utils/injectOne.cjs +48 -0
- package/dist/commands/runCli/utils/injectOne.d.ts +3 -0
- package/dist/commands/runCli/utils/injectOne.mjs +46 -0
- package/dist/commands/runCli/utils/resolveScopeFlag.cjs +28 -0
- package/dist/commands/runCli/utils/resolveScopeFlag.d.ts +2 -0
- package/dist/commands/runCli/utils/resolveScopeFlag.mjs +26 -0
- package/dist/commands/runCli/utils/runInject.cjs +36 -0
- package/dist/commands/runCli/utils/runInject.d.ts +2 -0
- package/dist/commands/runCli/utils/runInject.mjs +34 -0
- package/dist/core/buildPlan/buildPlan.cjs +42 -0
- package/dist/core/buildPlan/buildPlan.d.ts +2 -0
- package/dist/core/buildPlan/buildPlan.mjs +40 -0
- package/dist/core/buildPlan/index.d.ts +2 -0
- package/dist/core/buildPlan/type.d.ts +32 -0
- package/dist/core/buildPlan/utils/toPosix.cjs +9 -0
- package/dist/core/buildPlan/utils/toPosix.d.ts +1 -0
- package/dist/core/buildPlan/utils/toPosix.mjs +7 -0
- package/dist/core/buildPlan/utils/walkFiles.cjs +25 -0
- package/dist/core/buildPlan/utils/walkFiles.d.ts +1 -0
- package/dist/core/buildPlan/utils/walkFiles.mjs +23 -0
- package/dist/core/hash/hash.cjs +30 -0
- package/dist/core/hash/hash.d.ts +4 -0
- package/dist/core/hash/hash.mjs +26 -0
- package/dist/core/hash/index.d.ts +1 -0
- package/dist/core/hashManifest/hashManifest.cjs +27 -0
- package/dist/core/hashManifest/hashManifest.d.ts +17 -0
- package/dist/core/hashManifest/hashManifest.mjs +23 -0
- package/dist/core/hashManifest/index.d.ts +1 -0
- package/dist/core/index.d.ts +5 -0
- package/dist/core/injectDocs/index.d.ts +2 -0
- package/dist/core/injectDocs/injectDocs.cjs +43 -0
- package/dist/core/injectDocs/injectDocs.d.ts +2 -0
- package/dist/core/injectDocs/injectDocs.mjs +41 -0
- package/dist/core/injectDocs/type.d.ts +30 -0
- package/dist/core/injectDocs/utils/applyAction.cjs +21 -0
- package/dist/core/injectDocs/utils/applyAction.d.ts +2 -0
- package/dist/core/injectDocs/utils/applyAction.mjs +19 -0
- package/dist/core/injectDocs/utils/emitCiForceList.cjs +10 -0
- package/dist/core/injectDocs/utils/emitCiForceList.d.ts +2 -0
- package/dist/core/injectDocs/utils/emitCiForceList.mjs +8 -0
- package/dist/core/injectDocs/utils/printPlan.cjs +20 -0
- package/dist/core/injectDocs/utils/printPlan.d.ts +2 -0
- package/dist/core/injectDocs/utils/printPlan.mjs +18 -0
- package/dist/core/injectDocs/utils/summarize.cjs +27 -0
- package/dist/core/injectDocs/utils/summarize.d.ts +3 -0
- package/dist/core/injectDocs/utils/summarize.mjs +25 -0
- package/dist/core/scope/index.d.ts +1 -0
- package/dist/core/scope/scope.cjs +46 -0
- package/dist/core/scope/scope.d.ts +16 -0
- package/dist/core/scope/scope.mjs +41 -0
- package/dist/core/scope/utils/isDirectory.cjs +14 -0
- package/dist/core/scope/utils/isDirectory.d.ts +1 -0
- package/dist/core/scope/utils/isDirectory.mjs +12 -0
- package/dist/index.cjs +15 -9
- package/dist/index.d.ts +3 -5
- package/dist/index.mjs +7 -3
- package/dist/prompts/confirmForce.cjs +27 -0
- package/dist/prompts/confirmForce.d.ts +1 -0
- package/dist/prompts/confirmForce.mjs +25 -0
- package/dist/prompts/index.d.ts +2 -0
- package/dist/prompts/selectScope.cjs +30 -0
- package/dist/prompts/selectScope.d.ts +2 -0
- package/dist/prompts/selectScope.mjs +28 -0
- package/dist/utils/heartbeat.cjs +25 -0
- package/dist/utils/heartbeat.d.ts +16 -0
- package/dist/utils/heartbeat.mjs +23 -0
- package/dist/utils/logger.cjs +7 -0
- package/dist/utils/logger.d.ts +8 -0
- package/dist/utils/logger.mjs +7 -0
- package/dist/utils/types.d.ts +1 -252
- package/dist/utils/version.cjs +2 -14
- package/dist/utils/version.d.ts +3 -53
- package/dist/utils/version.mjs +2 -13
- package/docs/bundle-size-decision.md +36 -0
- package/docs/claude/skills/claude-sync-applier/SKILL.md +195 -0
- package/docs/claude/skills/claude-sync-applier/knowledge/claude-md-template.md +77 -0
- package/docs/claude/skills/claude-sync-applier/knowledge/dependency-cruiser.md +126 -0
- package/docs/claude/skills/claude-sync-applier/knowledge/gotchas.md +139 -0
- package/docs/claude/skills/claude-sync-applier/knowledge/package-json-patches.md +130 -0
- package/docs/claude/skills/claude-sync-applier/knowledge/reference-files.md +120 -0
- package/docs/claude/skills/claude-sync-applier/knowledge/smoke-tests.md +102 -0
- package/docs/consumer-integration.md +153 -0
- package/package.json +24 -16
- package/scripts/build-hashes.mjs +30 -0
- package/scripts/buildHashes.d.mts +15 -0
- package/scripts/buildHashes.mjs +82 -0
- package/scripts/claude-build-hashes.mjs +42 -0
- package/scripts/inject-version.js +112 -0
- package/dist/cli.cjs +0 -8
- package/dist/cli.d.ts +0 -1
- package/dist/cli.mjs +0 -7
- package/dist/commands/add.cjs +0 -80
- package/dist/commands/add.d.ts +0 -8
- package/dist/commands/add.mjs +0 -78
- package/dist/commands/list.cjs +0 -94
- package/dist/commands/list.d.ts +0 -15
- package/dist/commands/list.mjs +0 -91
- package/dist/commands/migrate.cjs +0 -9
- package/dist/commands/migrate.d.ts +0 -6
- package/dist/commands/migrate.mjs +0 -7
- package/dist/commands/remove.cjs +0 -127
- package/dist/commands/remove.d.ts +0 -6
- package/dist/commands/remove.mjs +0 -105
- package/dist/commands/status.cjs +0 -193
- package/dist/commands/status.d.ts +0 -6
- package/dist/commands/status.mjs +0 -171
- package/dist/commands/sync.cjs +0 -28
- package/dist/commands/sync.d.ts +0 -6
- package/dist/commands/sync.mjs +0 -26
- package/dist/commands/types.d.ts +0 -89
- package/dist/commands/update.cjs +0 -209
- package/dist/commands/update.d.ts +0 -29
- package/dist/commands/update.mjs +0 -206
- package/dist/components/add/AddCommand.cjs +0 -103
- package/dist/components/add/AddCommand.d.ts +0 -14
- package/dist/components/add/AddCommand.mjs +0 -101
- package/dist/components/add/BulkAddView.cjs +0 -165
- package/dist/components/add/BulkAddView.d.ts +0 -11
- package/dist/components/add/BulkAddView.mjs +0 -163
- package/dist/components/add/index.d.ts +0 -2
- package/dist/components/index.d.ts +0 -2
- package/dist/components/list/EditableTreeItem.d.ts +0 -13
- package/dist/components/list/ListCommand.cjs +0 -651
- package/dist/components/list/ListCommand.d.ts +0 -5
- package/dist/components/list/ListCommand.mjs +0 -649
- package/dist/components/list/SyncedPackageTree.d.ts +0 -14
- package/dist/components/list/index.d.ts +0 -10
- package/dist/components/list/types.d.ts +0 -14
- package/dist/components/primitives/Box.d.ts +0 -4
- package/dist/components/primitives/Spinner.d.ts +0 -6
- package/dist/components/primitives/Text.d.ts +0 -4
- package/dist/components/primitives/index.d.ts +0 -3
- package/dist/components/remove/RemoveConfirm.cjs +0 -18
- package/dist/components/remove/RemoveConfirm.d.ts +0 -11
- package/dist/components/remove/RemoveConfirm.mjs +0 -16
- package/dist/components/shared/Confirm.cjs +0 -30
- package/dist/components/shared/Confirm.d.ts +0 -8
- package/dist/components/shared/Confirm.mjs +0 -28
- package/dist/components/shared/MenuItem.cjs +0 -18
- package/dist/components/shared/MenuItem.d.ts +0 -7
- package/dist/components/shared/MenuItem.mjs +0 -16
- package/dist/components/shared/ProgressBar.d.ts +0 -7
- package/dist/components/shared/StepRunner.cjs +0 -58
- package/dist/components/shared/StepRunner.d.ts +0 -15
- package/dist/components/shared/StepRunner.mjs +0 -56
- package/dist/components/shared/Table.cjs +0 -19
- package/dist/components/shared/Table.d.ts +0 -8
- package/dist/components/shared/Table.mjs +0 -17
- package/dist/components/shared/index.d.ts +0 -6
- package/dist/components/status/PackageStatusCard.d.ts +0 -10
- package/dist/components/status/StatusDisplay.cjs +0 -26
- package/dist/components/status/StatusDisplay.d.ts +0 -23
- package/dist/components/status/StatusDisplay.mjs +0 -24
- package/dist/components/status/StatusTreeNode.cjs +0 -40
- package/dist/components/status/StatusTreeNode.d.ts +0 -15
- package/dist/components/status/StatusTreeNode.mjs +0 -38
- package/dist/components/status/index.d.ts +0 -6
- package/dist/components/tree/AssetTreeNode.cjs +0 -54
- package/dist/components/tree/AssetTreeNode.d.ts +0 -12
- package/dist/components/tree/AssetTreeNode.mjs +0 -52
- package/dist/components/tree/TreeSelect.cjs +0 -129
- package/dist/components/tree/TreeSelect.d.ts +0 -12
- package/dist/components/tree/TreeSelect.mjs +0 -127
- package/dist/components/tree/index.d.ts +0 -4
- package/dist/core/assetStructure.cjs +0 -30
- package/dist/core/assetStructure.d.ts +0 -36
- package/dist/core/assetStructure.mjs +0 -27
- package/dist/core/cli.cjs +0 -106
- package/dist/core/cli.d.ts +0 -9
- package/dist/core/cli.mjs +0 -103
- package/dist/core/constants.cjs +0 -28
- package/dist/core/constants.d.ts +0 -94
- package/dist/core/constants.mjs +0 -21
- package/dist/core/filesystem.cjs +0 -98
- package/dist/core/filesystem.d.ts +0 -94
- package/dist/core/filesystem.mjs +0 -88
- package/dist/core/github.cjs +0 -115
- package/dist/core/github.d.ts +0 -61
- package/dist/core/github.mjs +0 -107
- package/dist/core/io.cjs +0 -46
- package/dist/core/io.d.ts +0 -40
- package/dist/core/io.mjs +0 -39
- package/dist/core/listOperations.cjs +0 -228
- package/dist/core/listOperations.d.ts +0 -43
- package/dist/core/listOperations.mjs +0 -205
- package/dist/core/localSource.cjs +0 -126
- package/dist/core/localSource.d.ts +0 -33
- package/dist/core/localSource.mjs +0 -120
- package/dist/core/migration.cjs +0 -201
- package/dist/core/migration.d.ts +0 -57
- package/dist/core/migration.mjs +0 -198
- package/dist/core/packageScanner.cjs +0 -360
- package/dist/core/packageScanner.d.ts +0 -22
- package/dist/core/packageScanner.mjs +0 -356
- package/dist/core/sync.cjs +0 -400
- package/dist/core/sync.d.ts +0 -21
- package/dist/core/sync.mjs +0 -397
- package/dist/core/syncMeta.cjs +0 -242
- package/dist/core/syncMeta.d.ts +0 -75
- package/dist/core/syncMeta.mjs +0 -229
- package/dist/utils/dependencies.cjs +0 -57
- package/dist/utils/dependencies.d.ts +0 -10
- package/dist/utils/dependencies.mjs +0 -34
- package/dist/utils/nameTransform.cjs +0 -13
- package/dist/utils/nameTransform.d.ts +0 -65
- package/dist/utils/nameTransform.mjs +0 -11
- package/dist/utils/package.cjs +0 -170
- package/dist/utils/package.d.ts +0 -105
- package/dist/utils/package.mjs +0 -157
- package/dist/utils/packageName.cjs +0 -24
- package/dist/utils/packageName.d.ts +0 -32
- package/dist/utils/packageName.mjs +0 -21
- package/dist/utils/paths.cjs +0 -18
- package/dist/utils/paths.d.ts +0 -55
- package/dist/utils/paths.mjs +0 -15
- package/dist/version.cjs +0 -5
- package/dist/version.d.ts +0 -5
- package/dist/version.mjs +0 -3
|
@@ -1,205 +0,0 @@
|
|
|
1
|
-
import * as fs from 'node:fs';
|
|
2
|
-
import * as path from 'node:path';
|
|
3
|
-
import { syncPackage } from './sync.mjs';
|
|
4
|
-
import { removeSkillUnitFromPackage, removePackageFromMeta, writeUnifiedSyncMeta } from './syncMeta.mjs';
|
|
5
|
-
|
|
6
|
-
function computeFileOperations(meta, packageFiles, selectedTrees, cwd) {
|
|
7
|
-
const newPackageFiles = { ...packageFiles };
|
|
8
|
-
for (const packageTree of selectedTrees) {
|
|
9
|
-
const prefix = packageTree.id;
|
|
10
|
-
if (!newPackageFiles[prefix])
|
|
11
|
-
continue;
|
|
12
|
-
const selectedPaths = new Set();
|
|
13
|
-
if (packageTree.children) {
|
|
14
|
-
for (const assetTypeNode of packageTree.children) {
|
|
15
|
-
if (assetTypeNode.children) {
|
|
16
|
-
for (const fileNode of assetTypeNode.children) {
|
|
17
|
-
if (fileNode.disabled)
|
|
18
|
-
continue;
|
|
19
|
-
if (fileNode.selected) {
|
|
20
|
-
selectedPaths.add(fileNode.path);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
newPackageFiles[prefix] = {
|
|
27
|
-
...newPackageFiles[prefix],
|
|
28
|
-
selected: selectedPaths,
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
const fileOperations = [];
|
|
32
|
-
const filesToDelete = [];
|
|
33
|
-
const packagesToSync = [];
|
|
34
|
-
for (const [prefix] of Object.entries(meta.packages)) {
|
|
35
|
-
const packageTree = selectedTrees.find((t) => t.id === prefix);
|
|
36
|
-
const packageInfo = meta.packages[prefix];
|
|
37
|
-
const packageData = newPackageFiles[prefix];
|
|
38
|
-
if (!packageTree || !packageTree.selected || !packageData) {
|
|
39
|
-
for (const [assetType, files] of Object.entries(packageInfo.files)) {
|
|
40
|
-
if (!Array.isArray(files))
|
|
41
|
-
continue;
|
|
42
|
-
const units = files;
|
|
43
|
-
for (const unit of units) {
|
|
44
|
-
fileOperations.push({
|
|
45
|
-
type: 'remove',
|
|
46
|
-
prefix,
|
|
47
|
-
assetType,
|
|
48
|
-
skillName: unit.name,
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
const firstUnit = units[0];
|
|
52
|
-
if (firstUnit?.transformed) {
|
|
53
|
-
for (const unit of units) {
|
|
54
|
-
const targetPath = path.join(cwd, '.claude', assetType, unit.transformed);
|
|
55
|
-
filesToDelete.push(targetPath);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
else {
|
|
59
|
-
const dirPath = path.join(cwd, '.claude', assetType, packageInfo.originalName);
|
|
60
|
-
filesToDelete.push(dirPath);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
continue;
|
|
64
|
-
}
|
|
65
|
-
let hasChanges = false;
|
|
66
|
-
const selectedByAssetType = {};
|
|
67
|
-
for (const filePath of packageData.selected) {
|
|
68
|
-
const [assetType, fileName] = filePath.split('/');
|
|
69
|
-
if (!selectedByAssetType[assetType]) {
|
|
70
|
-
selectedByAssetType[assetType] = new Set();
|
|
71
|
-
}
|
|
72
|
-
selectedByAssetType[assetType].add(fileName);
|
|
73
|
-
}
|
|
74
|
-
for (const [assetType, originalFiles] of Object.entries(packageInfo.files)) {
|
|
75
|
-
const selectedFiles = selectedByAssetType[assetType];
|
|
76
|
-
const units = Array.isArray(originalFiles)
|
|
77
|
-
? originalFiles
|
|
78
|
-
: [];
|
|
79
|
-
const firstUnit = units[0];
|
|
80
|
-
const isFlat = !!firstUnit?.transformed;
|
|
81
|
-
if (!selectedFiles || selectedFiles.size === 0) {
|
|
82
|
-
hasChanges = true;
|
|
83
|
-
for (const unit of units) {
|
|
84
|
-
fileOperations.push({
|
|
85
|
-
type: 'remove',
|
|
86
|
-
prefix,
|
|
87
|
-
assetType,
|
|
88
|
-
skillName: unit.name,
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
if (isFlat) {
|
|
92
|
-
for (const unit of units) {
|
|
93
|
-
const targetPath = path.join(cwd, '.claude', assetType, unit.transformed);
|
|
94
|
-
filesToDelete.push(targetPath);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
else {
|
|
98
|
-
const dirPath = path.join(cwd, '.claude', assetType, packageInfo.originalName);
|
|
99
|
-
filesToDelete.push(dirPath);
|
|
100
|
-
}
|
|
101
|
-
continue;
|
|
102
|
-
}
|
|
103
|
-
const originalNames = new Set(units.map((u) => u.name));
|
|
104
|
-
for (const unit of units) {
|
|
105
|
-
if (!selectedFiles.has(unit.name)) {
|
|
106
|
-
hasChanges = true;
|
|
107
|
-
fileOperations.push({
|
|
108
|
-
type: 'remove',
|
|
109
|
-
prefix,
|
|
110
|
-
assetType,
|
|
111
|
-
skillName: unit.name,
|
|
112
|
-
});
|
|
113
|
-
if (unit.transformed) {
|
|
114
|
-
const targetPath = path.join(cwd, '.claude', assetType, unit.transformed);
|
|
115
|
-
filesToDelete.push(targetPath);
|
|
116
|
-
}
|
|
117
|
-
else {
|
|
118
|
-
const filePath = path.join(cwd, '.claude', assetType, packageInfo.originalName, unit.name);
|
|
119
|
-
filesToDelete.push(filePath);
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
for (const skillName of selectedFiles) {
|
|
124
|
-
if (!originalNames.has(skillName)) {
|
|
125
|
-
hasChanges = true;
|
|
126
|
-
fileOperations.push({
|
|
127
|
-
type: 'add',
|
|
128
|
-
prefix,
|
|
129
|
-
assetType,
|
|
130
|
-
skillName,
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
if (hasChanges) {
|
|
136
|
-
packagesToSync.push({
|
|
137
|
-
prefix,
|
|
138
|
-
name: packageInfo.originalName,
|
|
139
|
-
local: packageInfo.local,
|
|
140
|
-
});
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
return { filesToDelete, fileOperations, packagesToSync };
|
|
144
|
-
}
|
|
145
|
-
async function applyChangesAndSync(changesSummary, meta, cwd, callbacks) {
|
|
146
|
-
const syncErrors = [];
|
|
147
|
-
for (const filePath of changesSummary.filesToDelete) {
|
|
148
|
-
try {
|
|
149
|
-
const stat = fs.statSync(filePath);
|
|
150
|
-
if (stat.isDirectory()) {
|
|
151
|
-
fs.rmSync(filePath, { recursive: true, force: true });
|
|
152
|
-
}
|
|
153
|
-
else {
|
|
154
|
-
fs.unlinkSync(filePath);
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
catch (error) {
|
|
158
|
-
if (error.code !== 'ENOENT') {
|
|
159
|
-
console.error(`Failed to remove ${filePath}: ${error}`);
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
let updatedMeta = { ...meta };
|
|
164
|
-
const hasAddOperations = changesSummary.fileOperations.some((op) => op.type === 'add');
|
|
165
|
-
for (const op of changesSummary.fileOperations) {
|
|
166
|
-
if (op.type === 'remove') {
|
|
167
|
-
updatedMeta = removeSkillUnitFromPackage(updatedMeta, op.prefix, op.assetType, op.skillName);
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
for (const prefix of Object.keys(updatedMeta.packages)) {
|
|
171
|
-
const pkg = updatedMeta.packages[prefix];
|
|
172
|
-
if (!pkg.files || Object.keys(pkg.files).length === 0) {
|
|
173
|
-
updatedMeta = removePackageFromMeta(updatedMeta, prefix);
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
writeUnifiedSyncMeta(cwd, updatedMeta);
|
|
177
|
-
if (hasAddOperations && changesSummary.packagesToSync.length > 0) {
|
|
178
|
-
callbacks?.onSyncStart?.();
|
|
179
|
-
for (const { prefix, name, local } of changesSummary.packagesToSync) {
|
|
180
|
-
try {
|
|
181
|
-
const removedFiles = changesSummary.fileOperations
|
|
182
|
-
.filter((op) => op.type === 'remove' && op.prefix === prefix)
|
|
183
|
-
.map((op) => `${op.assetType}/${op.skillName}`);
|
|
184
|
-
const exclusions = removedFiles.length > 0
|
|
185
|
-
? { directories: [], files: removedFiles }
|
|
186
|
-
: undefined;
|
|
187
|
-
await syncPackage(name, {
|
|
188
|
-
force: true,
|
|
189
|
-
dryRun: false,
|
|
190
|
-
local: local ?? false,
|
|
191
|
-
ref: undefined,
|
|
192
|
-
flat: undefined,
|
|
193
|
-
}, cwd, exclusions);
|
|
194
|
-
}
|
|
195
|
-
catch (error) {
|
|
196
|
-
const msg = `Failed to sync ${name}: ${error}`;
|
|
197
|
-
console.error(msg);
|
|
198
|
-
syncErrors.push(msg);
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
return { updatedMeta, syncErrors };
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
export { applyChangesAndSync, computeFileOperations };
|
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var fs = require('node:fs');
|
|
4
|
-
var path = require('node:path');
|
|
5
|
-
var _package = require('../utils/package.cjs');
|
|
6
|
-
|
|
7
|
-
const canUseLocalSource = (packageName, requestedVersion, assetPath, cwd) => {
|
|
8
|
-
const packagePath = _package.resolvePackagePath(packageName, cwd);
|
|
9
|
-
if (!packagePath) {
|
|
10
|
-
return {
|
|
11
|
-
available: false,
|
|
12
|
-
reason: `Package ${packageName} not found in node_modules`,
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
const docsPath = path.join(packagePath, assetPath);
|
|
16
|
-
if (!fs.existsSync(docsPath)) {
|
|
17
|
-
return {
|
|
18
|
-
available: false,
|
|
19
|
-
reason: `Local docs path not found: ${docsPath}`,
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
try {
|
|
23
|
-
const pkgJsonPath = path.join(packagePath, 'package.json');
|
|
24
|
-
const pkgJson = JSON.parse(fs.readFileSync(pkgJsonPath, 'utf-8'));
|
|
25
|
-
if (pkgJson.version !== requestedVersion) {
|
|
26
|
-
return {
|
|
27
|
-
available: false,
|
|
28
|
-
reason: `Version mismatch: installed=${pkgJson.version}, requested=${requestedVersion}`,
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
catch {
|
|
33
|
-
return {
|
|
34
|
-
available: false,
|
|
35
|
-
reason: 'Failed to read package.json from node_modules',
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
return { available: true, docsPath };
|
|
39
|
-
};
|
|
40
|
-
const fetchLocalDirectoryContents = (dirPath) => {
|
|
41
|
-
if (!fs.existsSync(dirPath))
|
|
42
|
-
return null;
|
|
43
|
-
try {
|
|
44
|
-
const entries = fs.readdirSync(dirPath);
|
|
45
|
-
const result = [];
|
|
46
|
-
for (const name of entries) {
|
|
47
|
-
const fullPath = path.join(dirPath, name);
|
|
48
|
-
const stat = fs.statSync(fullPath);
|
|
49
|
-
if (stat.isDirectory()) {
|
|
50
|
-
result.push({
|
|
51
|
-
name,
|
|
52
|
-
path: fullPath,
|
|
53
|
-
type: 'dir',
|
|
54
|
-
download_url: null,
|
|
55
|
-
sha: '',
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
else if (stat.isFile() && name.endsWith('.md')) {
|
|
59
|
-
result.push({
|
|
60
|
-
name,
|
|
61
|
-
path: fullPath,
|
|
62
|
-
type: 'file',
|
|
63
|
-
download_url: null,
|
|
64
|
-
sha: '',
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
return result;
|
|
69
|
-
}
|
|
70
|
-
catch {
|
|
71
|
-
return null;
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
const expandLocalDirectoryEntries = (dirPath, entries, prefix = '') => {
|
|
75
|
-
const result = [];
|
|
76
|
-
for (const entry of entries) {
|
|
77
|
-
const entryPrefix = prefix ? `${prefix}/${entry.name}` : entry.name;
|
|
78
|
-
if (entry.type === 'file') {
|
|
79
|
-
result.push({
|
|
80
|
-
...entry,
|
|
81
|
-
name: prefix ? entryPrefix : entry.name,
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
else if (entry.type === 'dir') {
|
|
85
|
-
const subDirPath = path.join(dirPath, entry.name);
|
|
86
|
-
const subEntries = fetchLocalDirectoryContents(subDirPath);
|
|
87
|
-
if (subEntries) {
|
|
88
|
-
const expanded = expandLocalDirectoryEntries(subDirPath, subEntries, entryPrefix);
|
|
89
|
-
result.push(...expanded);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
return result;
|
|
94
|
-
};
|
|
95
|
-
const fetchLocalAssetFiles = async (docsBasePath, assetTypes) => {
|
|
96
|
-
const assetFiles = {};
|
|
97
|
-
for (const assetType of assetTypes) {
|
|
98
|
-
const assetDirPath = path.join(docsBasePath, assetType);
|
|
99
|
-
const entries = fetchLocalDirectoryContents(assetDirPath);
|
|
100
|
-
if (!entries) {
|
|
101
|
-
assetFiles[assetType] = [];
|
|
102
|
-
continue;
|
|
103
|
-
}
|
|
104
|
-
assetFiles[assetType] = expandLocalDirectoryEntries(assetDirPath, entries);
|
|
105
|
-
}
|
|
106
|
-
return assetFiles;
|
|
107
|
-
};
|
|
108
|
-
const downloadLocalAssetFiles = async (docsBasePath, assetType, entries) => {
|
|
109
|
-
const results = new Map();
|
|
110
|
-
for (const entry of entries) {
|
|
111
|
-
const filePath = path.join(docsBasePath, assetType, entry.name);
|
|
112
|
-
try {
|
|
113
|
-
const content = fs.readFileSync(filePath, 'utf-8');
|
|
114
|
-
results.set(entry.name, content);
|
|
115
|
-
}
|
|
116
|
-
catch {
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
return results;
|
|
120
|
-
};
|
|
121
|
-
|
|
122
|
-
exports.canUseLocalSource = canUseLocalSource;
|
|
123
|
-
exports.downloadLocalAssetFiles = downloadLocalAssetFiles;
|
|
124
|
-
exports.expandLocalDirectoryEntries = expandLocalDirectoryEntries;
|
|
125
|
-
exports.fetchLocalAssetFiles = fetchLocalAssetFiles;
|
|
126
|
-
exports.fetchLocalDirectoryContents = fetchLocalDirectoryContents;
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import type { AssetType, GitHubEntry } from '../utils/types.js';
|
|
2
|
-
export interface LocalSourceResult {
|
|
3
|
-
available: boolean;
|
|
4
|
-
docsPath?: string;
|
|
5
|
-
reason?: string;
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
* Check if local docs source is available in node_modules.
|
|
9
|
-
* Returns available=true if:
|
|
10
|
-
* 1. node_modules/<packageName>/<assetPath> directory exists
|
|
11
|
-
* 2. Installed version matches requestedVersion
|
|
12
|
-
*/
|
|
13
|
-
export declare const canUseLocalSource: (packageName: string, requestedVersion: string, assetPath: string, cwd: string) => LocalSourceResult;
|
|
14
|
-
/**
|
|
15
|
-
* Read directory contents and return .md files and subdirs in GitHubEntry format.
|
|
16
|
-
* Returns null if the directory doesn't exist.
|
|
17
|
-
*/
|
|
18
|
-
export declare const fetchLocalDirectoryContents: (dirPath: string) => GitHubEntry[] | null;
|
|
19
|
-
/**
|
|
20
|
-
* Recursively expand directory entries into flat file entries with path prefixes.
|
|
21
|
-
* Mirrors github.ts expandDirectoryEntries behaviour but reads from local filesystem.
|
|
22
|
-
*/
|
|
23
|
-
export declare const expandLocalDirectoryEntries: (dirPath: string, entries: GitHubEntry[], prefix?: string) => GitHubEntry[];
|
|
24
|
-
/**
|
|
25
|
-
* Fetch asset files from local filesystem.
|
|
26
|
-
* Mirrors github.ts fetchAssetFiles but reads from node_modules instead of GitHub API.
|
|
27
|
-
*/
|
|
28
|
-
export declare const fetchLocalAssetFiles: (docsBasePath: string, assetTypes: string[]) => Promise<Record<string, GitHubEntry[]>>;
|
|
29
|
-
/**
|
|
30
|
-
* Read file contents from local filesystem for the given entries.
|
|
31
|
-
* Mirrors github.ts downloadAssetFiles but reads local files instead of HTTP requests.
|
|
32
|
-
*/
|
|
33
|
-
export declare const downloadLocalAssetFiles: (docsBasePath: string, assetType: AssetType, entries: GitHubEntry[]) => Promise<Map<string, string>>;
|
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
import { existsSync, readFileSync, readdirSync, statSync } from 'node:fs';
|
|
2
|
-
import { join } from 'node:path';
|
|
3
|
-
import { resolvePackagePath } from '../utils/package.mjs';
|
|
4
|
-
|
|
5
|
-
const canUseLocalSource = (packageName, requestedVersion, assetPath, cwd) => {
|
|
6
|
-
const packagePath = resolvePackagePath(packageName, cwd);
|
|
7
|
-
if (!packagePath) {
|
|
8
|
-
return {
|
|
9
|
-
available: false,
|
|
10
|
-
reason: `Package ${packageName} not found in node_modules`,
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
const docsPath = join(packagePath, assetPath);
|
|
14
|
-
if (!existsSync(docsPath)) {
|
|
15
|
-
return {
|
|
16
|
-
available: false,
|
|
17
|
-
reason: `Local docs path not found: ${docsPath}`,
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
try {
|
|
21
|
-
const pkgJsonPath = join(packagePath, 'package.json');
|
|
22
|
-
const pkgJson = JSON.parse(readFileSync(pkgJsonPath, 'utf-8'));
|
|
23
|
-
if (pkgJson.version !== requestedVersion) {
|
|
24
|
-
return {
|
|
25
|
-
available: false,
|
|
26
|
-
reason: `Version mismatch: installed=${pkgJson.version}, requested=${requestedVersion}`,
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
catch {
|
|
31
|
-
return {
|
|
32
|
-
available: false,
|
|
33
|
-
reason: 'Failed to read package.json from node_modules',
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
return { available: true, docsPath };
|
|
37
|
-
};
|
|
38
|
-
const fetchLocalDirectoryContents = (dirPath) => {
|
|
39
|
-
if (!existsSync(dirPath))
|
|
40
|
-
return null;
|
|
41
|
-
try {
|
|
42
|
-
const entries = readdirSync(dirPath);
|
|
43
|
-
const result = [];
|
|
44
|
-
for (const name of entries) {
|
|
45
|
-
const fullPath = join(dirPath, name);
|
|
46
|
-
const stat = statSync(fullPath);
|
|
47
|
-
if (stat.isDirectory()) {
|
|
48
|
-
result.push({
|
|
49
|
-
name,
|
|
50
|
-
path: fullPath,
|
|
51
|
-
type: 'dir',
|
|
52
|
-
download_url: null,
|
|
53
|
-
sha: '',
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
else if (stat.isFile() && name.endsWith('.md')) {
|
|
57
|
-
result.push({
|
|
58
|
-
name,
|
|
59
|
-
path: fullPath,
|
|
60
|
-
type: 'file',
|
|
61
|
-
download_url: null,
|
|
62
|
-
sha: '',
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
return result;
|
|
67
|
-
}
|
|
68
|
-
catch {
|
|
69
|
-
return null;
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
const expandLocalDirectoryEntries = (dirPath, entries, prefix = '') => {
|
|
73
|
-
const result = [];
|
|
74
|
-
for (const entry of entries) {
|
|
75
|
-
const entryPrefix = prefix ? `${prefix}/${entry.name}` : entry.name;
|
|
76
|
-
if (entry.type === 'file') {
|
|
77
|
-
result.push({
|
|
78
|
-
...entry,
|
|
79
|
-
name: prefix ? entryPrefix : entry.name,
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
else if (entry.type === 'dir') {
|
|
83
|
-
const subDirPath = join(dirPath, entry.name);
|
|
84
|
-
const subEntries = fetchLocalDirectoryContents(subDirPath);
|
|
85
|
-
if (subEntries) {
|
|
86
|
-
const expanded = expandLocalDirectoryEntries(subDirPath, subEntries, entryPrefix);
|
|
87
|
-
result.push(...expanded);
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
return result;
|
|
92
|
-
};
|
|
93
|
-
const fetchLocalAssetFiles = async (docsBasePath, assetTypes) => {
|
|
94
|
-
const assetFiles = {};
|
|
95
|
-
for (const assetType of assetTypes) {
|
|
96
|
-
const assetDirPath = join(docsBasePath, assetType);
|
|
97
|
-
const entries = fetchLocalDirectoryContents(assetDirPath);
|
|
98
|
-
if (!entries) {
|
|
99
|
-
assetFiles[assetType] = [];
|
|
100
|
-
continue;
|
|
101
|
-
}
|
|
102
|
-
assetFiles[assetType] = expandLocalDirectoryEntries(assetDirPath, entries);
|
|
103
|
-
}
|
|
104
|
-
return assetFiles;
|
|
105
|
-
};
|
|
106
|
-
const downloadLocalAssetFiles = async (docsBasePath, assetType, entries) => {
|
|
107
|
-
const results = new Map();
|
|
108
|
-
for (const entry of entries) {
|
|
109
|
-
const filePath = join(docsBasePath, assetType, entry.name);
|
|
110
|
-
try {
|
|
111
|
-
const content = readFileSync(filePath, 'utf-8');
|
|
112
|
-
results.set(entry.name, content);
|
|
113
|
-
}
|
|
114
|
-
catch {
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
return results;
|
|
118
|
-
};
|
|
119
|
-
|
|
120
|
-
export { canUseLocalSource, downloadLocalAssetFiles, expandLocalDirectoryEntries, fetchLocalAssetFiles, fetchLocalDirectoryContents };
|
package/dist/core/migration.cjs
DELETED
|
@@ -1,201 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var fs = require('node:fs');
|
|
4
|
-
var path = require('node:path');
|
|
5
|
-
var nameTransform = require('../utils/nameTransform.cjs');
|
|
6
|
-
var packageName = require('../utils/packageName.cjs');
|
|
7
|
-
var filesystem = require('./filesystem.cjs');
|
|
8
|
-
var syncMeta = require('./syncMeta.cjs');
|
|
9
|
-
|
|
10
|
-
function needsMigration(cwd) {
|
|
11
|
-
const assetTypes = ['commands', 'skills'];
|
|
12
|
-
for (const assetType of assetTypes) {
|
|
13
|
-
const assetDir = path.join(cwd, '.claude', assetType);
|
|
14
|
-
if (!fs.existsSync(assetDir)) {
|
|
15
|
-
continue;
|
|
16
|
-
}
|
|
17
|
-
try {
|
|
18
|
-
const entries = fs.readdirSync(assetDir);
|
|
19
|
-
for (const entry of entries) {
|
|
20
|
-
if (entry.startsWith('@')) {
|
|
21
|
-
const scopeDir = path.join(assetDir, entry);
|
|
22
|
-
if (fs.statSync(scopeDir).isDirectory()) {
|
|
23
|
-
return true;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
catch (error) {
|
|
29
|
-
console.error(`Error scanning ${assetDir}:`, error);
|
|
30
|
-
continue;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
return false;
|
|
34
|
-
}
|
|
35
|
-
async function migrateToFlat(cwd, options = {}) {
|
|
36
|
-
const { dryRun = false } = options;
|
|
37
|
-
const migratedPackages = [];
|
|
38
|
-
const errors = [];
|
|
39
|
-
console.log(`\n๐ Starting migration to flat structure${dryRun ? ' (DRY RUN)' : ''}...`);
|
|
40
|
-
let unifiedMeta = syncMeta.readUnifiedSyncMeta(cwd);
|
|
41
|
-
if (!unifiedMeta) {
|
|
42
|
-
console.log('๐ Creating new unified sync metadata');
|
|
43
|
-
unifiedMeta = syncMeta.createEmptyUnifiedMeta();
|
|
44
|
-
}
|
|
45
|
-
const assetTypes = ['commands', 'skills'];
|
|
46
|
-
const legacyDirs = [];
|
|
47
|
-
for (const assetType of assetTypes) {
|
|
48
|
-
const assetDir = path.join(cwd, '.claude', assetType);
|
|
49
|
-
if (!fs.existsSync(assetDir)) {
|
|
50
|
-
continue;
|
|
51
|
-
}
|
|
52
|
-
console.log(`\n๐ Scanning ${assetType}...`);
|
|
53
|
-
try {
|
|
54
|
-
const scopeDirs = fs.readdirSync(assetDir).filter((entry) => {
|
|
55
|
-
const fullPath = path.join(assetDir, entry);
|
|
56
|
-
return entry.startsWith('@') && fs.statSync(fullPath).isDirectory();
|
|
57
|
-
});
|
|
58
|
-
for (const scopeDir of scopeDirs) {
|
|
59
|
-
const scopePath = path.join(assetDir, scopeDir);
|
|
60
|
-
const packageDirs = fs.readdirSync(scopePath).filter((entry) => {
|
|
61
|
-
const fullPath = path.join(scopePath, entry);
|
|
62
|
-
return fs.statSync(fullPath).isDirectory();
|
|
63
|
-
});
|
|
64
|
-
for (const packageDir of packageDirs) {
|
|
65
|
-
const packagePath = path.join(scopePath, packageDir);
|
|
66
|
-
const packageName$1 = `${scopeDir}/${packageDir}`;
|
|
67
|
-
console.log(` ๐ฆ Processing ${packageName$1}...`);
|
|
68
|
-
try {
|
|
69
|
-
const metaPath = path.join(packagePath, '.sync-meta.json');
|
|
70
|
-
let legacyMeta = null;
|
|
71
|
-
if (fs.existsSync(metaPath)) {
|
|
72
|
-
const metaContent = fs.readFileSync(metaPath, 'utf-8');
|
|
73
|
-
legacyMeta = JSON.parse(metaContent);
|
|
74
|
-
}
|
|
75
|
-
if (!legacyMeta) {
|
|
76
|
-
console.log(` โ ๏ธ No .sync-meta.json found, skipping`);
|
|
77
|
-
continue;
|
|
78
|
-
}
|
|
79
|
-
const prefix = packageName.packageNameToPrefix(packageName$1);
|
|
80
|
-
const commandUnits = [];
|
|
81
|
-
const skillUnits = [];
|
|
82
|
-
for (const fileName of legacyMeta.files) {
|
|
83
|
-
const sourcePath = path.join(packagePath, fileName);
|
|
84
|
-
if (!fs.existsSync(sourcePath)) {
|
|
85
|
-
console.log(` โ ๏ธ File not found: ${fileName}`);
|
|
86
|
-
continue;
|
|
87
|
-
}
|
|
88
|
-
if (assetType === 'commands') {
|
|
89
|
-
if (!dryRun) {
|
|
90
|
-
const content = fs.readFileSync(sourcePath, 'utf-8');
|
|
91
|
-
filesystem.writeFlatAssetFile(cwd, assetType, fileName, content);
|
|
92
|
-
console.log(` โ
Migrated: ${fileName}`);
|
|
93
|
-
}
|
|
94
|
-
else {
|
|
95
|
-
console.log(` ๐ Would migrate: ${fileName}`);
|
|
96
|
-
}
|
|
97
|
-
commandUnits.push({ name: fileName, isDirectory: false });
|
|
98
|
-
}
|
|
99
|
-
else {
|
|
100
|
-
const flatFileName = nameTransform.toFlatFileName(prefix, fileName);
|
|
101
|
-
if (!dryRun) {
|
|
102
|
-
const content = fs.readFileSync(sourcePath, 'utf-8');
|
|
103
|
-
filesystem.writeFlatAssetFile(cwd, assetType, flatFileName, content);
|
|
104
|
-
console.log(` โ
Migrated: ${fileName} โ ${flatFileName}`);
|
|
105
|
-
}
|
|
106
|
-
else {
|
|
107
|
-
console.log(` ๐ Would migrate: ${fileName} โ ${flatFileName}`);
|
|
108
|
-
}
|
|
109
|
-
skillUnits.push({
|
|
110
|
-
name: fileName,
|
|
111
|
-
isDirectory: false,
|
|
112
|
-
transformed: flatFileName,
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
const packageInfo = {
|
|
117
|
-
originalName: packageName$1,
|
|
118
|
-
version: legacyMeta.version,
|
|
119
|
-
files: {
|
|
120
|
-
commands: assetType === 'commands' ? commandUnits : [],
|
|
121
|
-
skills: assetType === 'skills' ? skillUnits : [],
|
|
122
|
-
agents: [],
|
|
123
|
-
},
|
|
124
|
-
};
|
|
125
|
-
if (unifiedMeta.packages[prefix]) {
|
|
126
|
-
const existing = unifiedMeta.packages[prefix];
|
|
127
|
-
if (assetType === 'commands') {
|
|
128
|
-
packageInfo.files.skills = existing.files.skills;
|
|
129
|
-
packageInfo.files.agents = existing.files.agents;
|
|
130
|
-
}
|
|
131
|
-
else if (assetType === 'skills') {
|
|
132
|
-
packageInfo.files.commands = existing.files.commands;
|
|
133
|
-
packageInfo.files.agents = existing.files.agents;
|
|
134
|
-
}
|
|
135
|
-
else {
|
|
136
|
-
packageInfo.files.commands = existing.files.commands;
|
|
137
|
-
packageInfo.files.skills = existing.files.skills;
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
unifiedMeta = syncMeta.updatePackageInMeta(unifiedMeta, prefix, packageInfo);
|
|
141
|
-
migratedPackages.push(packageName$1);
|
|
142
|
-
legacyDirs.push(packagePath);
|
|
143
|
-
}
|
|
144
|
-
catch (error) {
|
|
145
|
-
const errorMsg = `Failed to migrate ${packageName$1}: ${error}`;
|
|
146
|
-
console.error(` โ ${errorMsg}`);
|
|
147
|
-
errors.push(errorMsg);
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
legacyDirs.push(scopePath);
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
catch (error) {
|
|
154
|
-
const errorMsg = `Error scanning ${assetType}: ${error}`;
|
|
155
|
-
console.error(`โ ${errorMsg}`);
|
|
156
|
-
errors.push(errorMsg);
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
if (!dryRun && migratedPackages.length > 0) {
|
|
160
|
-
syncMeta.writeUnifiedSyncMeta(cwd, unifiedMeta);
|
|
161
|
-
console.log(`\n๐พ Updated unified sync metadata`);
|
|
162
|
-
}
|
|
163
|
-
if (!dryRun && legacyDirs.length > 0) {
|
|
164
|
-
console.log(`\n๐งน Cleaning up legacy directories...`);
|
|
165
|
-
for (const legacyDir of legacyDirs) {
|
|
166
|
-
try {
|
|
167
|
-
if (fs.existsSync(legacyDir)) {
|
|
168
|
-
const entries = fs.readdirSync(legacyDir);
|
|
169
|
-
const hasOnlyMeta = entries.length === 1 && entries[0] === '.sync-meta.json';
|
|
170
|
-
const isEmpty = entries.length === 0;
|
|
171
|
-
if (isEmpty || hasOnlyMeta) {
|
|
172
|
-
fs.rmSync(legacyDir, { recursive: true, force: true });
|
|
173
|
-
console.log(` โ
Removed: ${legacyDir}`);
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
catch (error) {
|
|
178
|
-
console.error(` โ ๏ธ Failed to remove ${legacyDir}:`, error);
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
console.log(`\n๐ Migration Summary:`);
|
|
183
|
-
console.log(` โ
Migrated packages: ${migratedPackages.length}`);
|
|
184
|
-
if (errors.length > 0) {
|
|
185
|
-
console.log(` โ Errors: ${errors.length}`);
|
|
186
|
-
}
|
|
187
|
-
if (dryRun) {
|
|
188
|
-
console.log(`\n๐ DRY RUN: No changes were made. Run without --dry-run to apply migration.`);
|
|
189
|
-
}
|
|
190
|
-
else if (migratedPackages.length > 0) {
|
|
191
|
-
console.log(`\nโจ Migration completed successfully!`);
|
|
192
|
-
}
|
|
193
|
-
return {
|
|
194
|
-
success: errors.length === 0,
|
|
195
|
-
migratedPackages,
|
|
196
|
-
errors: errors.length > 0 ? errors : undefined,
|
|
197
|
-
};
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
exports.migrateToFlat = migrateToFlat;
|
|
201
|
-
exports.needsMigration = needsMigration;
|