@slats/claude-assets-sync 0.0.6 → 0.1.1
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/dist/commands/add.cjs +24 -0
- package/dist/commands/add.d.ts +2 -6
- package/dist/commands/add.mjs +24 -0
- package/dist/commands/index.d.ts +1 -2
- package/dist/commands/list.cjs +12 -1
- package/dist/commands/list.d.ts +10 -1
- package/dist/commands/list.mjs +12 -2
- package/dist/commands/remove.cjs +49 -31
- package/dist/commands/remove.mjs +49 -30
- package/dist/commands/types.d.ts +9 -0
- package/dist/commands/update.cjs +34 -3
- package/dist/commands/update.d.ts +16 -0
- package/dist/commands/update.mjs +34 -4
- package/dist/components/add/BulkAddView.cjs +169 -0
- package/dist/components/add/BulkAddView.d.ts +11 -0
- package/dist/components/add/BulkAddView.mjs +167 -0
- package/dist/components/list/ListCommand.cjs +585 -392
- package/dist/components/list/ListCommand.d.ts +0 -3
- package/dist/components/list/ListCommand.mjs +590 -377
- package/dist/components/list/index.d.ts +1 -0
- package/dist/components/list/types.d.ts +14 -0
- package/dist/components/remove/RemoveConfirm.cjs +18 -0
- package/dist/components/remove/RemoveConfirm.d.ts +11 -0
- package/dist/components/remove/RemoveConfirm.mjs +16 -0
- package/dist/components/shared/Confirm.cjs +30 -0
- package/dist/components/shared/Confirm.d.ts +8 -0
- package/dist/components/shared/Confirm.mjs +28 -0
- package/dist/components/shared/MenuItem.cjs +18 -0
- package/dist/components/shared/MenuItem.d.ts +7 -0
- package/dist/components/shared/MenuItem.mjs +16 -0
- package/dist/components/shared/ProgressBar.d.ts +7 -0
- package/dist/components/shared/StepRunner.cjs +58 -0
- package/dist/components/shared/StepRunner.d.ts +15 -0
- package/dist/components/shared/StepRunner.mjs +56 -0
- package/dist/components/shared/Table.cjs +19 -0
- package/dist/components/shared/Table.d.ts +8 -0
- package/dist/components/shared/Table.mjs +17 -0
- package/dist/components/shared/index.d.ts +6 -0
- package/dist/core/cli.cjs +4 -8
- package/dist/core/cli.mjs +5 -9
- package/dist/core/constants.cjs +2 -0
- package/dist/core/constants.d.ts +5 -1
- package/dist/core/constants.mjs +2 -1
- package/dist/core/io.mjs +1 -1
- package/dist/core/listOperations.cjs +228 -0
- package/dist/core/listOperations.d.ts +43 -0
- package/dist/core/listOperations.mjs +205 -0
- package/dist/core/localSource.cjs +8 -2
- package/dist/core/localSource.mjs +8 -2
- package/dist/core/packageScanner.cjs +10 -10
- package/dist/core/packageScanner.mjs +10 -10
- package/dist/core/sync.cjs +10 -16
- package/dist/core/sync.mjs +11 -17
- package/dist/core/syncMeta.cjs +7 -2
- package/dist/core/syncMeta.d.ts +1 -1
- package/dist/core/syncMeta.mjs +7 -2
- package/dist/utils/asyncPool.cjs +26 -0
- package/dist/utils/asyncPool.d.ts +5 -0
- package/dist/utils/asyncPool.mjs +24 -0
- package/dist/utils/dependencies.cjs +57 -0
- package/dist/utils/dependencies.d.ts +10 -0
- package/dist/utils/dependencies.mjs +34 -0
- package/dist/utils/package.cjs +5 -0
- package/dist/utils/package.d.ts +6 -1
- package/dist/utils/package.mjs +6 -2
- package/dist/version.cjs +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.mjs +1 -1
- package/package.json +3 -2
package/dist/core/sync.cjs
CHANGED
|
@@ -5,11 +5,11 @@ var nameTransform = require('../utils/nameTransform.cjs');
|
|
|
5
5
|
var _package = require('../utils/package.cjs');
|
|
6
6
|
var packageName = require('../utils/packageName.cjs');
|
|
7
7
|
var paths = require('../utils/paths.cjs');
|
|
8
|
+
var constants = require('./constants.cjs');
|
|
8
9
|
var filesystem = require('./filesystem.cjs');
|
|
9
10
|
var github = require('./github.cjs');
|
|
10
11
|
var localSource = require('./localSource.cjs');
|
|
11
12
|
var syncMeta = require('./syncMeta.cjs');
|
|
12
|
-
var constants = require('./constants.cjs');
|
|
13
13
|
var assetStructure = require('./assetStructure.cjs');
|
|
14
14
|
|
|
15
15
|
function groupEntriesIntoSkillUnits(entries, prefix) {
|
|
@@ -60,13 +60,7 @@ const syncPackage = async (packageName$1, options, cwd = process.cwd(), exclusio
|
|
|
60
60
|
reason: `Package not found in ${location}`,
|
|
61
61
|
};
|
|
62
62
|
}
|
|
63
|
-
|
|
64
|
-
return {
|
|
65
|
-
packageName: packageName$1,
|
|
66
|
-
success: false,
|
|
67
|
-
skipped: true,
|
|
68
|
-
reason: 'Package does not have claude.assetPath in package.json',
|
|
69
|
-
};
|
|
63
|
+
const claudeConfig = _package.resolveClaudeConfig(packageInfo.claude);
|
|
70
64
|
const repoInfo = _package.parseGitHubRepo(packageInfo.repository);
|
|
71
65
|
const useFlat = options.flat !== false;
|
|
72
66
|
if (useFlat) {
|
|
@@ -81,11 +75,11 @@ const syncPackage = async (packageName$1, options, cwd = process.cwd(), exclusio
|
|
|
81
75
|
reason: `Already synced at version ${packageInfo.version}`,
|
|
82
76
|
};
|
|
83
77
|
}
|
|
84
|
-
const assetPath = _package.buildAssetPath(
|
|
78
|
+
const assetPath = _package.buildAssetPath(claudeConfig.assetPath);
|
|
85
79
|
const useLocalSource = options.ref
|
|
86
80
|
? { available: false }
|
|
87
81
|
: localSource.canUseLocalSource(packageName$1, packageInfo.version, assetPath, cwd);
|
|
88
|
-
const assetTypes = _package.getAssetTypes(
|
|
82
|
+
const assetTypes = _package.getAssetTypes(claudeConfig);
|
|
89
83
|
let assetFiles;
|
|
90
84
|
let isLocalSource;
|
|
91
85
|
if (useLocalSource.available && useLocalSource.docsPath) {
|
|
@@ -135,7 +129,7 @@ const syncPackage = async (packageName$1, options, cwd = process.cwd(), exclusio
|
|
|
135
129
|
});
|
|
136
130
|
if (filteredEntries.length === 0)
|
|
137
131
|
continue;
|
|
138
|
-
const structure = assetStructure.getAssetStructure(assetType,
|
|
132
|
+
const structure = assetStructure.getAssetStructure(assetType, claudeConfig);
|
|
139
133
|
if (structure === 'nested') {
|
|
140
134
|
fileMappings[assetType] = filteredEntries.map((e) => ({
|
|
141
135
|
name: e.name,
|
|
@@ -151,7 +145,7 @@ const syncPackage = async (packageName$1, options, cwd = process.cwd(), exclusio
|
|
|
151
145
|
const units = fileMappings[assetType];
|
|
152
146
|
if (!units || units.length === 0)
|
|
153
147
|
continue;
|
|
154
|
-
const structure = assetStructure.getAssetStructure(assetType,
|
|
148
|
+
const structure = assetStructure.getAssetStructure(assetType, claudeConfig);
|
|
155
149
|
if (structure === 'nested') {
|
|
156
150
|
logger.logger.step(`Would sync ${assetType} to`, paths.getDestinationDir(destDir, packageName$1, assetType));
|
|
157
151
|
units.forEach((unit) => {
|
|
@@ -181,7 +175,7 @@ const syncPackage = async (packageName$1, options, cwd = process.cwd(), exclusio
|
|
|
181
175
|
};
|
|
182
176
|
}
|
|
183
177
|
for (const assetType of assetTypes) {
|
|
184
|
-
const structure = assetStructure.getAssetStructure(assetType,
|
|
178
|
+
const structure = assetStructure.getAssetStructure(assetType, claudeConfig);
|
|
185
179
|
if (structure === 'nested') {
|
|
186
180
|
filesystem.cleanAssetDir(destDir, packageName$1, assetType);
|
|
187
181
|
}
|
|
@@ -201,7 +195,7 @@ const syncPackage = async (packageName$1, options, cwd = process.cwd(), exclusio
|
|
|
201
195
|
});
|
|
202
196
|
if (filteredEntries.length === 0)
|
|
203
197
|
continue;
|
|
204
|
-
const structure = assetStructure.getAssetStructure(assetType,
|
|
198
|
+
const structure = assetStructure.getAssetStructure(assetType, claudeConfig);
|
|
205
199
|
logger.logger.step('Downloading', assetType);
|
|
206
200
|
let downloadedFiles;
|
|
207
201
|
if (isLocalSource && useLocalSource.docsPath) {
|
|
@@ -252,11 +246,11 @@ const syncPackage = async (packageName$1, options, cwd = process.cwd(), exclusio
|
|
|
252
246
|
};
|
|
253
247
|
}
|
|
254
248
|
else {
|
|
255
|
-
const assetPath = _package.buildAssetPath(
|
|
249
|
+
const assetPath = _package.buildAssetPath(claudeConfig.assetPath);
|
|
256
250
|
const useLocalSource = options.ref
|
|
257
251
|
? { available: false }
|
|
258
252
|
: localSource.canUseLocalSource(packageName$1, packageInfo.version, assetPath, cwd);
|
|
259
|
-
const assetTypes = _package.getAssetTypes(
|
|
253
|
+
const assetTypes = _package.getAssetTypes(claudeConfig);
|
|
260
254
|
let assetFiles;
|
|
261
255
|
let isLocalSource;
|
|
262
256
|
if (useLocalSource.available && useLocalSource.docsPath) {
|
package/dist/core/sync.mjs
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { logger } from '../utils/logger.mjs';
|
|
2
2
|
import { toFlatFileName } from '../utils/nameTransform.mjs';
|
|
3
|
-
import { findGitRoot, readLocalPackageJson, readPackageJson, parseGitHubRepo, buildAssetPath, getAssetTypes, buildVersionTag } from '../utils/package.mjs';
|
|
3
|
+
import { findGitRoot, readLocalPackageJson, readPackageJson, resolveClaudeConfig, parseGitHubRepo, buildAssetPath, getAssetTypes, buildVersionTag } from '../utils/package.mjs';
|
|
4
4
|
import { packageNameToPrefix } from '../utils/packageName.mjs';
|
|
5
5
|
import { getDestinationDir, getFlatDestinationDir } from '../utils/paths.mjs';
|
|
6
|
+
import { SCHEMA_VERSIONS } from './constants.mjs';
|
|
6
7
|
import { cleanAssetDir, cleanFlatAssetFiles, writeAssetFile, writeFlatAssetFile, needsSync, writeSyncMeta, createSyncMeta } from './filesystem.mjs';
|
|
7
8
|
import { fetchAssetFiles, downloadAssetFiles, RateLimitError } from './github.mjs';
|
|
8
9
|
import { canUseLocalSource, fetchLocalAssetFiles, downloadLocalAssetFiles } from './localSource.mjs';
|
|
9
10
|
import { readUnifiedSyncMeta, createEmptyUnifiedMeta, needsSyncUnified, updatePackageInMeta, writeUnifiedSyncMeta } from './syncMeta.mjs';
|
|
10
|
-
import { SCHEMA_VERSIONS } from './constants.mjs';
|
|
11
11
|
import { getAssetStructure } from './assetStructure.mjs';
|
|
12
12
|
|
|
13
13
|
function groupEntriesIntoSkillUnits(entries, prefix) {
|
|
@@ -58,13 +58,7 @@ const syncPackage = async (packageName, options, cwd = process.cwd(), exclusions
|
|
|
58
58
|
reason: `Package not found in ${location}`,
|
|
59
59
|
};
|
|
60
60
|
}
|
|
61
|
-
|
|
62
|
-
return {
|
|
63
|
-
packageName,
|
|
64
|
-
success: false,
|
|
65
|
-
skipped: true,
|
|
66
|
-
reason: 'Package does not have claude.assetPath in package.json',
|
|
67
|
-
};
|
|
61
|
+
const claudeConfig = resolveClaudeConfig(packageInfo.claude);
|
|
68
62
|
const repoInfo = parseGitHubRepo(packageInfo.repository);
|
|
69
63
|
const useFlat = options.flat !== false;
|
|
70
64
|
if (useFlat) {
|
|
@@ -79,11 +73,11 @@ const syncPackage = async (packageName, options, cwd = process.cwd(), exclusions
|
|
|
79
73
|
reason: `Already synced at version ${packageInfo.version}`,
|
|
80
74
|
};
|
|
81
75
|
}
|
|
82
|
-
const assetPath = buildAssetPath(
|
|
76
|
+
const assetPath = buildAssetPath(claudeConfig.assetPath);
|
|
83
77
|
const useLocalSource = options.ref
|
|
84
78
|
? { available: false }
|
|
85
79
|
: canUseLocalSource(packageName, packageInfo.version, assetPath, cwd);
|
|
86
|
-
const assetTypes = getAssetTypes(
|
|
80
|
+
const assetTypes = getAssetTypes(claudeConfig);
|
|
87
81
|
let assetFiles;
|
|
88
82
|
let isLocalSource;
|
|
89
83
|
if (useLocalSource.available && useLocalSource.docsPath) {
|
|
@@ -133,7 +127,7 @@ const syncPackage = async (packageName, options, cwd = process.cwd(), exclusions
|
|
|
133
127
|
});
|
|
134
128
|
if (filteredEntries.length === 0)
|
|
135
129
|
continue;
|
|
136
|
-
const structure = getAssetStructure(assetType,
|
|
130
|
+
const structure = getAssetStructure(assetType, claudeConfig);
|
|
137
131
|
if (structure === 'nested') {
|
|
138
132
|
fileMappings[assetType] = filteredEntries.map((e) => ({
|
|
139
133
|
name: e.name,
|
|
@@ -149,7 +143,7 @@ const syncPackage = async (packageName, options, cwd = process.cwd(), exclusions
|
|
|
149
143
|
const units = fileMappings[assetType];
|
|
150
144
|
if (!units || units.length === 0)
|
|
151
145
|
continue;
|
|
152
|
-
const structure = getAssetStructure(assetType,
|
|
146
|
+
const structure = getAssetStructure(assetType, claudeConfig);
|
|
153
147
|
if (structure === 'nested') {
|
|
154
148
|
logger.step(`Would sync ${assetType} to`, getDestinationDir(destDir, packageName, assetType));
|
|
155
149
|
units.forEach((unit) => {
|
|
@@ -179,7 +173,7 @@ const syncPackage = async (packageName, options, cwd = process.cwd(), exclusions
|
|
|
179
173
|
};
|
|
180
174
|
}
|
|
181
175
|
for (const assetType of assetTypes) {
|
|
182
|
-
const structure = getAssetStructure(assetType,
|
|
176
|
+
const structure = getAssetStructure(assetType, claudeConfig);
|
|
183
177
|
if (structure === 'nested') {
|
|
184
178
|
cleanAssetDir(destDir, packageName, assetType);
|
|
185
179
|
}
|
|
@@ -199,7 +193,7 @@ const syncPackage = async (packageName, options, cwd = process.cwd(), exclusions
|
|
|
199
193
|
});
|
|
200
194
|
if (filteredEntries.length === 0)
|
|
201
195
|
continue;
|
|
202
|
-
const structure = getAssetStructure(assetType,
|
|
196
|
+
const structure = getAssetStructure(assetType, claudeConfig);
|
|
203
197
|
logger.step('Downloading', assetType);
|
|
204
198
|
let downloadedFiles;
|
|
205
199
|
if (isLocalSource && useLocalSource.docsPath) {
|
|
@@ -250,11 +244,11 @@ const syncPackage = async (packageName, options, cwd = process.cwd(), exclusions
|
|
|
250
244
|
};
|
|
251
245
|
}
|
|
252
246
|
else {
|
|
253
|
-
const assetPath = buildAssetPath(
|
|
247
|
+
const assetPath = buildAssetPath(claudeConfig.assetPath);
|
|
254
248
|
const useLocalSource = options.ref
|
|
255
249
|
? { available: false }
|
|
256
250
|
: canUseLocalSource(packageName, packageInfo.version, assetPath, cwd);
|
|
257
|
-
const assetTypes = getAssetTypes(
|
|
251
|
+
const assetTypes = getAssetTypes(claudeConfig);
|
|
258
252
|
let assetFiles;
|
|
259
253
|
let isLocalSource;
|
|
260
254
|
if (useLocalSource.available && useLocalSource.docsPath) {
|
package/dist/core/syncMeta.cjs
CHANGED
|
@@ -143,7 +143,9 @@ function needsSkillUnitMigration(meta) {
|
|
|
143
143
|
!('isDirectory' in first)) {
|
|
144
144
|
return true;
|
|
145
145
|
}
|
|
146
|
-
if (typeof first === 'object' &&
|
|
146
|
+
if (typeof first === 'object' &&
|
|
147
|
+
first !== null &&
|
|
148
|
+
'isDirectory' in first) {
|
|
147
149
|
return false;
|
|
148
150
|
}
|
|
149
151
|
}
|
|
@@ -191,7 +193,10 @@ function migrateToSkillUnitSchema(meta) {
|
|
|
191
193
|
? mapping.transformed.substring(0, transformedSlashIndex)
|
|
192
194
|
: mapping.transformed;
|
|
193
195
|
if (!groupedByDir.has(dirName)) {
|
|
194
|
-
groupedByDir.set(dirName, {
|
|
196
|
+
groupedByDir.set(dirName, {
|
|
197
|
+
transformed: transformedDir,
|
|
198
|
+
internalFiles: [],
|
|
199
|
+
});
|
|
195
200
|
}
|
|
196
201
|
groupedByDir.get(dirName).internalFiles.push(internalFile);
|
|
197
202
|
}
|
package/dist/core/syncMeta.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type { PackageSyncInfo, SkillUnit, UnifiedSyncMeta } from '../utils/types
|
|
|
2
2
|
/**
|
|
3
3
|
* Schema version for the unified metadata format
|
|
4
4
|
*/
|
|
5
|
-
export declare const SCHEMA_VERSION: "0.0
|
|
5
|
+
export declare const SCHEMA_VERSION: "0.1.0";
|
|
6
6
|
/**
|
|
7
7
|
* Read unified sync metadata from .claude/.sync-meta.json
|
|
8
8
|
*
|
package/dist/core/syncMeta.mjs
CHANGED
|
@@ -141,7 +141,9 @@ function needsSkillUnitMigration(meta) {
|
|
|
141
141
|
!('isDirectory' in first)) {
|
|
142
142
|
return true;
|
|
143
143
|
}
|
|
144
|
-
if (typeof first === 'object' &&
|
|
144
|
+
if (typeof first === 'object' &&
|
|
145
|
+
first !== null &&
|
|
146
|
+
'isDirectory' in first) {
|
|
145
147
|
return false;
|
|
146
148
|
}
|
|
147
149
|
}
|
|
@@ -189,7 +191,10 @@ function migrateToSkillUnitSchema(meta) {
|
|
|
189
191
|
? mapping.transformed.substring(0, transformedSlashIndex)
|
|
190
192
|
: mapping.transformed;
|
|
191
193
|
if (!groupedByDir.has(dirName)) {
|
|
192
|
-
groupedByDir.set(dirName, {
|
|
194
|
+
groupedByDir.set(dirName, {
|
|
195
|
+
transformed: transformedDir,
|
|
196
|
+
internalFiles: [],
|
|
197
|
+
});
|
|
193
198
|
}
|
|
194
199
|
groupedByDir.get(dirName).internalFiles.push(internalFile);
|
|
195
200
|
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
async function asyncPool(limit, items, fn) {
|
|
4
|
+
const results = [];
|
|
5
|
+
const executing = new Set();
|
|
6
|
+
for (const [index, item] of items.entries()) {
|
|
7
|
+
const p = (async () => {
|
|
8
|
+
try {
|
|
9
|
+
const value = await fn(item);
|
|
10
|
+
results[index] = { status: 'fulfilled', value };
|
|
11
|
+
}
|
|
12
|
+
catch (reason) {
|
|
13
|
+
results[index] = { status: 'rejected', reason };
|
|
14
|
+
}
|
|
15
|
+
})();
|
|
16
|
+
executing.add(p);
|
|
17
|
+
p.then(() => executing.delete(p));
|
|
18
|
+
if (executing.size >= limit) {
|
|
19
|
+
await Promise.race(executing);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
await Promise.all(executing);
|
|
23
|
+
return results;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
exports.asyncPool = asyncPool;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
async function asyncPool(limit, items, fn) {
|
|
2
|
+
const results = [];
|
|
3
|
+
const executing = new Set();
|
|
4
|
+
for (const [index, item] of items.entries()) {
|
|
5
|
+
const p = (async () => {
|
|
6
|
+
try {
|
|
7
|
+
const value = await fn(item);
|
|
8
|
+
results[index] = { status: 'fulfilled', value };
|
|
9
|
+
}
|
|
10
|
+
catch (reason) {
|
|
11
|
+
results[index] = { status: 'rejected', reason };
|
|
12
|
+
}
|
|
13
|
+
})();
|
|
14
|
+
executing.add(p);
|
|
15
|
+
p.then(() => executing.delete(p));
|
|
16
|
+
if (executing.size >= limit) {
|
|
17
|
+
await Promise.race(executing);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
await Promise.all(executing);
|
|
21
|
+
return results;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export { asyncPool };
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var fs = require('node:fs');
|
|
4
|
+
var path = require('node:path');
|
|
5
|
+
|
|
6
|
+
function _interopNamespaceDefault(e) {
|
|
7
|
+
var n = Object.create(null);
|
|
8
|
+
if (e) {
|
|
9
|
+
Object.keys(e).forEach(function (k) {
|
|
10
|
+
if (k !== 'default') {
|
|
11
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
12
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () { return e[k]; }
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
n.default = e;
|
|
20
|
+
return Object.freeze(n);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
var fs__namespace = /*#__PURE__*/_interopNamespaceDefault(fs);
|
|
24
|
+
var path__namespace = /*#__PURE__*/_interopNamespaceDefault(path);
|
|
25
|
+
|
|
26
|
+
function readProjectDependencies(cwd) {
|
|
27
|
+
const pkgPath = path__namespace.join(cwd, 'package.json');
|
|
28
|
+
if (!fs__namespace.existsSync(pkgPath)) {
|
|
29
|
+
throw new Error(`package.json not found at: ${pkgPath}`);
|
|
30
|
+
}
|
|
31
|
+
let pkg;
|
|
32
|
+
try {
|
|
33
|
+
pkg = JSON.parse(fs__namespace.readFileSync(pkgPath, 'utf-8'));
|
|
34
|
+
}
|
|
35
|
+
catch (error) {
|
|
36
|
+
throw new Error(`Failed to parse package.json at ${pkgPath}: ${error instanceof Error ? error.message : String(error)}`);
|
|
37
|
+
}
|
|
38
|
+
return {
|
|
39
|
+
...pkg.dependencies,
|
|
40
|
+
...pkg.devDependencies,
|
|
41
|
+
...pkg.peerDependencies,
|
|
42
|
+
...pkg.optionalDependencies,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
function filterByPattern(deps, pattern) {
|
|
46
|
+
let regex;
|
|
47
|
+
try {
|
|
48
|
+
regex = new RegExp(pattern);
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
throw new Error(`Invalid regex pattern "${pattern}": ${error instanceof Error ? error.message : String(error)}`);
|
|
52
|
+
}
|
|
53
|
+
return Object.keys(deps).filter(name => regex.test(name));
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
exports.filterByPattern = filterByPattern;
|
|
57
|
+
exports.readProjectDependencies = readProjectDependencies;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reads all dependencies from the project's package.json
|
|
3
|
+
* (dependencies, devDependencies, peerDependencies, optionalDependencies)
|
|
4
|
+
*/
|
|
5
|
+
export declare function readProjectDependencies(cwd: string): Record<string, string>;
|
|
6
|
+
/**
|
|
7
|
+
* Filters dependency names by regex pattern.
|
|
8
|
+
* Wraps RegExp construction in try/catch for invalid patterns.
|
|
9
|
+
*/
|
|
10
|
+
export declare function filterByPattern(deps: Record<string, string>, pattern: string): string[];
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import * as fs from 'node:fs';
|
|
2
|
+
import * as path from 'node:path';
|
|
3
|
+
|
|
4
|
+
function readProjectDependencies(cwd) {
|
|
5
|
+
const pkgPath = path.join(cwd, 'package.json');
|
|
6
|
+
if (!fs.existsSync(pkgPath)) {
|
|
7
|
+
throw new Error(`package.json not found at: ${pkgPath}`);
|
|
8
|
+
}
|
|
9
|
+
let pkg;
|
|
10
|
+
try {
|
|
11
|
+
pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf-8'));
|
|
12
|
+
}
|
|
13
|
+
catch (error) {
|
|
14
|
+
throw new Error(`Failed to parse package.json at ${pkgPath}: ${error instanceof Error ? error.message : String(error)}`);
|
|
15
|
+
}
|
|
16
|
+
return {
|
|
17
|
+
...pkg.dependencies,
|
|
18
|
+
...pkg.devDependencies,
|
|
19
|
+
...pkg.peerDependencies,
|
|
20
|
+
...pkg.optionalDependencies,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
function filterByPattern(deps, pattern) {
|
|
24
|
+
let regex;
|
|
25
|
+
try {
|
|
26
|
+
regex = new RegExp(pattern);
|
|
27
|
+
}
|
|
28
|
+
catch (error) {
|
|
29
|
+
throw new Error(`Invalid regex pattern "${pattern}": ${error instanceof Error ? error.message : String(error)}`);
|
|
30
|
+
}
|
|
31
|
+
return Object.keys(deps).filter(name => regex.test(name));
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export { filterByPattern, readProjectDependencies };
|
package/dist/utils/package.cjs
CHANGED
|
@@ -135,6 +135,10 @@ function getAssetTypes(config) {
|
|
|
135
135
|
}
|
|
136
136
|
return Object.keys(config.assets);
|
|
137
137
|
}
|
|
138
|
+
const resolveClaudeConfig = (claude) => ({
|
|
139
|
+
assetPath: claude?.assetPath ?? constants.DEFAULT_ASSET_PATH,
|
|
140
|
+
...(claude?.assets ? { assets: claude.assets } : {}),
|
|
141
|
+
});
|
|
138
142
|
|
|
139
143
|
exports.buildAssetPath = buildAssetPath;
|
|
140
144
|
exports.buildVersionTag = buildVersionTag;
|
|
@@ -146,3 +150,4 @@ exports.getWorkspaceList = getWorkspaceList;
|
|
|
146
150
|
exports.parseGitHubRepo = parseGitHubRepo;
|
|
147
151
|
exports.readLocalPackageJson = readLocalPackageJson;
|
|
148
152
|
exports.readPackageJson = readPackageJson;
|
|
153
|
+
exports.resolveClaudeConfig = resolveClaudeConfig;
|
package/dist/utils/package.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { GitHubRepoInfo, PackageInfo, WorkspaceInfo } from './types';
|
|
1
|
+
import type { ClaudeConfig, GitHubRepoInfo, PackageInfo, WorkspaceInfo } from './types';
|
|
2
2
|
export { getAssetStructure } from '../core/assetStructure';
|
|
3
3
|
/**
|
|
4
4
|
* Read package.json from node_modules
|
|
@@ -89,3 +89,8 @@ export declare function getAssetTypes(config: {
|
|
|
89
89
|
structure: 'nested' | 'flat';
|
|
90
90
|
}>;
|
|
91
91
|
}): string[];
|
|
92
|
+
/**
|
|
93
|
+
* Resolve claude config with default assetPath fallback.
|
|
94
|
+
* If claude config is missing or assetPath is not set, defaults to DEFAULT_ASSET_PATH.
|
|
95
|
+
*/
|
|
96
|
+
export declare const resolveClaudeConfig: (claude?: ClaudeConfig) => ClaudeConfig;
|
package/dist/utils/package.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { execSync } from 'node:child_process';
|
|
2
2
|
import { readFileSync, existsSync } from 'node:fs';
|
|
3
3
|
import { join, dirname } from 'node:path';
|
|
4
|
-
import { FS_PATTERNS, DEFAULT_ASSET_TYPES } from '../core/constants.mjs';
|
|
4
|
+
import { DEFAULT_ASSET_PATH, FS_PATTERNS, DEFAULT_ASSET_TYPES } from '../core/constants.mjs';
|
|
5
5
|
|
|
6
6
|
const readPackageJson = (packageName, cwd = process.cwd()) => {
|
|
7
7
|
try {
|
|
@@ -133,5 +133,9 @@ function getAssetTypes(config) {
|
|
|
133
133
|
}
|
|
134
134
|
return Object.keys(config.assets);
|
|
135
135
|
}
|
|
136
|
+
const resolveClaudeConfig = (claude) => ({
|
|
137
|
+
assetPath: claude?.assetPath ?? DEFAULT_ASSET_PATH,
|
|
138
|
+
...(claude?.assets ? { assets: claude.assets } : {}),
|
|
139
|
+
});
|
|
136
140
|
|
|
137
|
-
export { buildAssetPath, buildVersionTag, findGitRoot, findWorkspaceLocation, findWorkspaceRoot, getAssetTypes, getWorkspaceList, parseGitHubRepo, readLocalPackageJson, readPackageJson };
|
|
141
|
+
export { buildAssetPath, buildVersionTag, findGitRoot, findWorkspaceLocation, findWorkspaceRoot, getAssetTypes, getWorkspaceList, parseGitHubRepo, readLocalPackageJson, readPackageJson, resolveClaudeConfig };
|
package/dist/version.cjs
CHANGED
package/dist/version.d.ts
CHANGED
package/dist/version.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@slats/claude-assets-sync",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "CLI tool to sync Claude commands and skills from npm packages to your project's .claude directory",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"claude",
|
|
@@ -53,9 +53,10 @@
|
|
|
53
53
|
"version:patch": "yarn version patch"
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
56
|
-
"@winglet/react-utils": "^0.
|
|
56
|
+
"@winglet/react-utils": "^0.11.0",
|
|
57
57
|
"commander": "^12.1.0",
|
|
58
58
|
"ink": "^6.6.0",
|
|
59
|
+
"ink-select-input": "^6.2.0",
|
|
59
60
|
"ink-spinner": "^5.0.0",
|
|
60
61
|
"picocolors": "^1.1.1",
|
|
61
62
|
"react": "^19.1.1",
|