@slats/claude-assets-sync 0.1.0 → 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 +27 -0
- package/dist/commands/update.d.ts +16 -0
- package/dist/commands/update.mjs +27 -1
- 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 +4 -0
- 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/packageScanner.cjs +8 -6
- package/dist/core/packageScanner.mjs +9 -7
- package/dist/core/sync.cjs +9 -15
- package/dist/core/sync.mjs +10 -16
- 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/package.json +2 -1
package/dist/core/sync.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
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
6
|
import { SCHEMA_VERSIONS } from './constants.mjs';
|
|
@@ -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) {
|
|
@@ -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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@slats/claude-assets-sync",
|
|
3
|
-
"version": "0.1.
|
|
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",
|
|
@@ -56,6 +56,7 @@
|
|
|
56
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",
|