rulesync 0.3.0 → 0.4.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/dist/index.js +39 -2
- package/dist/index.mjs +40 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -254,6 +254,15 @@ async function fileExists(filepath) {
|
|
|
254
254
|
return false;
|
|
255
255
|
}
|
|
256
256
|
}
|
|
257
|
+
async function removeDirectory(dirPath) {
|
|
258
|
+
try {
|
|
259
|
+
if (await fileExists(dirPath)) {
|
|
260
|
+
await (0, import_promises.rm)(dirPath, { recursive: true, force: true });
|
|
261
|
+
}
|
|
262
|
+
} catch (error) {
|
|
263
|
+
console.warn(`Failed to remove directory ${dirPath}:`, error);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
257
266
|
|
|
258
267
|
// src/core/generator.ts
|
|
259
268
|
async function generateConfigurations(rules, config, targetTools) {
|
|
@@ -423,6 +432,33 @@ async function generateCommand(options = {}) {
|
|
|
423
432
|
if (options.verbose) {
|
|
424
433
|
console.log(`Found ${rules.length} rule(s)`);
|
|
425
434
|
}
|
|
435
|
+
if (options.delete) {
|
|
436
|
+
if (options.verbose) {
|
|
437
|
+
console.log("Deleting existing output directories...");
|
|
438
|
+
}
|
|
439
|
+
const targetTools = options.tools || config.defaultTargets;
|
|
440
|
+
const deleteTasks = [];
|
|
441
|
+
for (const tool of targetTools) {
|
|
442
|
+
switch (tool) {
|
|
443
|
+
case "copilot":
|
|
444
|
+
deleteTasks.push(removeDirectory(config.outputPaths.copilot));
|
|
445
|
+
break;
|
|
446
|
+
case "cursor":
|
|
447
|
+
deleteTasks.push(removeDirectory(config.outputPaths.cursor));
|
|
448
|
+
break;
|
|
449
|
+
case "cline":
|
|
450
|
+
deleteTasks.push(removeDirectory(config.outputPaths.cline));
|
|
451
|
+
break;
|
|
452
|
+
case "claude":
|
|
453
|
+
deleteTasks.push(removeDirectory(config.outputPaths.claude));
|
|
454
|
+
break;
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
await Promise.all(deleteTasks);
|
|
458
|
+
if (options.verbose) {
|
|
459
|
+
console.log("Deleted existing output directories");
|
|
460
|
+
}
|
|
461
|
+
}
|
|
426
462
|
const outputs = await generateConfigurations(rules, config, options.tools);
|
|
427
463
|
if (outputs.length === 0) {
|
|
428
464
|
console.warn("\u26A0\uFE0F No configurations generated");
|
|
@@ -715,14 +751,15 @@ var program = new import_commander.Command();
|
|
|
715
751
|
program.name("rulesync").description("Unified AI rules management CLI tool").version("0.1.0");
|
|
716
752
|
program.command("init").description("Initialize rulesync in current directory").action(initCommand);
|
|
717
753
|
program.command("gitignore").description("Add generated files to .gitignore").action(gitignoreCommand);
|
|
718
|
-
program.command("generate").description("Generate configuration files for AI tools").option("--copilot", "Generate only for GitHub Copilot").option("--cursor", "Generate only for Cursor").option("--cline", "Generate only for Cline").option("--claude", "Generate only for Claude Code").option("-v, --verbose", "Verbose output").action(async (options) => {
|
|
754
|
+
program.command("generate").description("Generate configuration files for AI tools").option("--copilot", "Generate only for GitHub Copilot").option("--cursor", "Generate only for Cursor").option("--cline", "Generate only for Cline").option("--claude", "Generate only for Claude Code").option("--delete", "Delete all existing files in output directories before generating").option("-v, --verbose", "Verbose output").action(async (options) => {
|
|
719
755
|
const tools = [];
|
|
720
756
|
if (options.copilot) tools.push("copilot");
|
|
721
757
|
if (options.cursor) tools.push("cursor");
|
|
722
758
|
if (options.cline) tools.push("cline");
|
|
723
759
|
if (options.claude) tools.push("claude");
|
|
724
760
|
const generateOptions = {
|
|
725
|
-
verbose: options.verbose
|
|
761
|
+
verbose: options.verbose,
|
|
762
|
+
delete: options.delete
|
|
726
763
|
};
|
|
727
764
|
if (tools.length > 0) {
|
|
728
765
|
generateOptions.tools = tools;
|
package/dist/index.mjs
CHANGED
|
@@ -199,7 +199,7 @@ function resolveTargets(targets, config) {
|
|
|
199
199
|
}
|
|
200
200
|
|
|
201
201
|
// src/utils/file.ts
|
|
202
|
-
import { mkdir, readdir, readFile, stat, writeFile } from "fs/promises";
|
|
202
|
+
import { mkdir, readdir, readFile, rm, stat, writeFile } from "fs/promises";
|
|
203
203
|
import { dirname, join as join5 } from "path";
|
|
204
204
|
async function ensureDir(dirPath) {
|
|
205
205
|
try {
|
|
@@ -231,6 +231,15 @@ async function fileExists(filepath) {
|
|
|
231
231
|
return false;
|
|
232
232
|
}
|
|
233
233
|
}
|
|
234
|
+
async function removeDirectory(dirPath) {
|
|
235
|
+
try {
|
|
236
|
+
if (await fileExists(dirPath)) {
|
|
237
|
+
await rm(dirPath, { recursive: true, force: true });
|
|
238
|
+
}
|
|
239
|
+
} catch (error) {
|
|
240
|
+
console.warn(`Failed to remove directory ${dirPath}:`, error);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
234
243
|
|
|
235
244
|
// src/core/generator.ts
|
|
236
245
|
async function generateConfigurations(rules, config, targetTools) {
|
|
@@ -400,6 +409,33 @@ async function generateCommand(options = {}) {
|
|
|
400
409
|
if (options.verbose) {
|
|
401
410
|
console.log(`Found ${rules.length} rule(s)`);
|
|
402
411
|
}
|
|
412
|
+
if (options.delete) {
|
|
413
|
+
if (options.verbose) {
|
|
414
|
+
console.log("Deleting existing output directories...");
|
|
415
|
+
}
|
|
416
|
+
const targetTools = options.tools || config.defaultTargets;
|
|
417
|
+
const deleteTasks = [];
|
|
418
|
+
for (const tool of targetTools) {
|
|
419
|
+
switch (tool) {
|
|
420
|
+
case "copilot":
|
|
421
|
+
deleteTasks.push(removeDirectory(config.outputPaths.copilot));
|
|
422
|
+
break;
|
|
423
|
+
case "cursor":
|
|
424
|
+
deleteTasks.push(removeDirectory(config.outputPaths.cursor));
|
|
425
|
+
break;
|
|
426
|
+
case "cline":
|
|
427
|
+
deleteTasks.push(removeDirectory(config.outputPaths.cline));
|
|
428
|
+
break;
|
|
429
|
+
case "claude":
|
|
430
|
+
deleteTasks.push(removeDirectory(config.outputPaths.claude));
|
|
431
|
+
break;
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
await Promise.all(deleteTasks);
|
|
435
|
+
if (options.verbose) {
|
|
436
|
+
console.log("Deleted existing output directories");
|
|
437
|
+
}
|
|
438
|
+
}
|
|
403
439
|
const outputs = await generateConfigurations(rules, config, options.tools);
|
|
404
440
|
if (outputs.length === 0) {
|
|
405
441
|
console.warn("\u26A0\uFE0F No configurations generated");
|
|
@@ -692,14 +728,15 @@ var program = new Command();
|
|
|
692
728
|
program.name("rulesync").description("Unified AI rules management CLI tool").version("0.1.0");
|
|
693
729
|
program.command("init").description("Initialize rulesync in current directory").action(initCommand);
|
|
694
730
|
program.command("gitignore").description("Add generated files to .gitignore").action(gitignoreCommand);
|
|
695
|
-
program.command("generate").description("Generate configuration files for AI tools").option("--copilot", "Generate only for GitHub Copilot").option("--cursor", "Generate only for Cursor").option("--cline", "Generate only for Cline").option("--claude", "Generate only for Claude Code").option("-v, --verbose", "Verbose output").action(async (options) => {
|
|
731
|
+
program.command("generate").description("Generate configuration files for AI tools").option("--copilot", "Generate only for GitHub Copilot").option("--cursor", "Generate only for Cursor").option("--cline", "Generate only for Cline").option("--claude", "Generate only for Claude Code").option("--delete", "Delete all existing files in output directories before generating").option("-v, --verbose", "Verbose output").action(async (options) => {
|
|
696
732
|
const tools = [];
|
|
697
733
|
if (options.copilot) tools.push("copilot");
|
|
698
734
|
if (options.cursor) tools.push("cursor");
|
|
699
735
|
if (options.cline) tools.push("cline");
|
|
700
736
|
if (options.claude) tools.push("claude");
|
|
701
737
|
const generateOptions = {
|
|
702
|
-
verbose: options.verbose
|
|
738
|
+
verbose: options.verbose,
|
|
739
|
+
delete: options.delete
|
|
703
740
|
};
|
|
704
741
|
if (tools.length > 0) {
|
|
705
742
|
generateOptions.tools = tools;
|
package/package.json
CHANGED