aicm 0.14.4 → 0.14.5
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/install.js +5 -5
- package/package.json +1 -1
- package/dist/api_v2.d.ts +0 -9
- package/dist/api_v2.js +0 -12
- package/dist/bin/aicm_v2.d.ts +0 -2
- package/dist/bin/aicm_v2.js +0 -8
- package/dist/cli_v2.d.ts +0 -2
- package/dist/cli_v2.js +0 -94
- package/dist/commands/install/install-package.d.ts +0 -53
- package/dist/commands/install/install-package.js +0 -122
- package/dist/commands/install/install-single-package.d.ts +0 -53
- package/dist/commands/install/install-single-package.js +0 -139
- package/dist/commands/install/install-workspaces.d.ts +0 -9
- package/dist/commands/install/install-workspaces.js +0 -172
- package/dist/commands/install_new.d.ts +0 -17
- package/dist/commands/install_new.js +0 -457
- package/dist/commands/install_v2.d.ts +0 -52
- package/dist/commands/install_v2.js +0 -505
- package/dist/commands/install_/327/2242.d.ts +0 -59
- package/dist/commands/install_/327/2242.js +0 -546
- package/dist/commands/workspaces/discovery.d.ts +0 -7
- package/dist/commands/workspaces/discovery.js +0 -50
- package/dist/commands/workspaces/workspaces-install.d.ts +0 -9
- package/dist/commands/workspaces/workspaces-install.js +0 -48
- package/dist/index.d.ts +0 -2
- package/dist/index.js +0 -76
- package/dist/types/index.d.ts +0 -64
- package/dist/types/index.js +0 -2
- package/dist/utils/config_new.d.ts +0 -64
- package/dist/utils/config_new.js +0 -228
- package/dist/utils/config_v2.d.ts +0 -64
- package/dist/utils/config_v2.js +0 -250
- package/dist/utils/glob-handler.d.ts +0 -35
- package/dist/utils/glob-handler.js +0 -125
- package/dist/utils/mcp-writer.d.ts +0 -14
- package/dist/utils/mcp-writer.js +0 -69
- package/dist/utils/mdc-parser.d.ts +0 -9
- package/dist/utils/mdc-parser.js +0 -59
- package/dist/utils/rule-collector.d.ts +0 -33
- package/dist/utils/rule-collector.js +0 -169
- package/dist/utils/rule-detector.d.ts +0 -4
- package/dist/utils/rule-detector.js +0 -31
- package/dist/utils/rule-status.d.ts +0 -8
- package/dist/utils/rule-status.js +0 -53
- package/dist/utils/rule-writer.d.ts +0 -6
- package/dist/utils/rule-writer.js +0 -118
package/dist/commands/install.js
CHANGED
|
@@ -451,7 +451,6 @@ async function installWorkspaces(cwd, installOnCI, verbose = false, dryRun = fal
|
|
|
451
451
|
packagesCount: result.packages.length,
|
|
452
452
|
};
|
|
453
453
|
}
|
|
454
|
-
console.log(`Successfully installed ${result.totalRuleCount} rules across ${result.packages.length} packages`);
|
|
455
454
|
return {
|
|
456
455
|
success: true,
|
|
457
456
|
installedRuleCount: result.totalRuleCount,
|
|
@@ -500,19 +499,20 @@ async function installCommand(installOnCI, verbose, dryRun) {
|
|
|
500
499
|
throw (_a = result.error) !== null && _a !== void 0 ? _a : new Error("Installation failed with unknown error");
|
|
501
500
|
}
|
|
502
501
|
else {
|
|
502
|
+
const rulesInstalledMessage = `${result.installedRuleCount} rule${result.installedRuleCount === 1 ? "" : "s"}`;
|
|
503
503
|
if (dryRun) {
|
|
504
504
|
if (result.packagesCount > 1) {
|
|
505
|
-
console.log(`Dry run: ${
|
|
505
|
+
console.log(`Dry run: validated ${rulesInstalledMessage} across ${result.packagesCount} packages`);
|
|
506
506
|
}
|
|
507
507
|
else {
|
|
508
|
-
console.log(
|
|
508
|
+
console.log(`Dry run: validated ${rulesInstalledMessage}`);
|
|
509
509
|
}
|
|
510
510
|
}
|
|
511
511
|
else if (result.packagesCount > 1) {
|
|
512
|
-
console.log(`Successfully installed ${
|
|
512
|
+
console.log(`Successfully installed ${rulesInstalledMessage} across ${result.packagesCount} packages`);
|
|
513
513
|
}
|
|
514
514
|
else {
|
|
515
|
-
console.log(
|
|
515
|
+
console.log(`Successfully installed ${rulesInstalledMessage}`);
|
|
516
516
|
}
|
|
517
517
|
}
|
|
518
518
|
}
|
package/package.json
CHANGED
package/dist/api_v2.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { InstallOptions, InstallResult } from "./commands/install";
|
|
2
|
-
/**
|
|
3
|
-
* Install AICM rules based on configuration (v2)
|
|
4
|
-
* @param options Installation options
|
|
5
|
-
* @returns Result of the install operation
|
|
6
|
-
*/
|
|
7
|
-
export declare function install(options?: InstallOptions): Promise<InstallResult>;
|
|
8
|
-
export type { InstallOptions, InstallResult } from "./commands/install";
|
|
9
|
-
export type { ResolvedConfig, Config, RuleFile, MCPServers, } from "./utils/config";
|
package/dist/api_v2.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.install = install;
|
|
4
|
-
const install_1 = require("./commands/install");
|
|
5
|
-
/**
|
|
6
|
-
* Install AICM rules based on configuration (v2)
|
|
7
|
-
* @param options Installation options
|
|
8
|
-
* @returns Result of the install operation
|
|
9
|
-
*/
|
|
10
|
-
async function install(options = {}) {
|
|
11
|
-
return (0, install_1.install)(options);
|
|
12
|
-
}
|
package/dist/bin/aicm_v2.d.ts
DELETED
package/dist/bin/aicm_v2.js
DELETED
package/dist/cli_v2.d.ts
DELETED
package/dist/cli_v2.js
DELETED
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
"use strict";
|
|
3
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
-
};
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.runCliV2 = runCliV2;
|
|
8
|
-
const arg_1 = __importDefault(require("arg"));
|
|
9
|
-
const chalk_1 = __importDefault(require("chalk"));
|
|
10
|
-
const init_1 = require("./commands/init");
|
|
11
|
-
const install_1 = require("./commands/install");
|
|
12
|
-
const list_1 = require("./commands/list");
|
|
13
|
-
// Define version from package.json
|
|
14
|
-
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
15
|
-
const pkg = require("../package.json");
|
|
16
|
-
async function runCliV2() {
|
|
17
|
-
const args = (0, arg_1.default)({
|
|
18
|
-
"--help": Boolean,
|
|
19
|
-
"--version": Boolean,
|
|
20
|
-
"--ci": Boolean,
|
|
21
|
-
"--verbose": Boolean,
|
|
22
|
-
"-h": "--help",
|
|
23
|
-
"-v": "--version",
|
|
24
|
-
}, {
|
|
25
|
-
permissive: true,
|
|
26
|
-
argv: process.argv.slice(2),
|
|
27
|
-
});
|
|
28
|
-
// Show version
|
|
29
|
-
if (args["--version"]) {
|
|
30
|
-
console.log(pkg.version);
|
|
31
|
-
process.exit(0);
|
|
32
|
-
}
|
|
33
|
-
// Show help
|
|
34
|
-
if (args["--help"]) {
|
|
35
|
-
showHelp();
|
|
36
|
-
process.exit(0);
|
|
37
|
-
}
|
|
38
|
-
const command = args._.length > 0 ? args._[0] : null;
|
|
39
|
-
try {
|
|
40
|
-
switch (command) {
|
|
41
|
-
case "init":
|
|
42
|
-
(0, init_1.initCommand)();
|
|
43
|
-
break;
|
|
44
|
-
case "install":
|
|
45
|
-
await (0, install_1.installCommand)(args["--ci"], args["--verbose"]);
|
|
46
|
-
break;
|
|
47
|
-
case "list":
|
|
48
|
-
await (0, list_1.listCommand)();
|
|
49
|
-
break;
|
|
50
|
-
default:
|
|
51
|
-
showHelp();
|
|
52
|
-
break;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
catch (error) {
|
|
56
|
-
logError(error, args["--verbose"]);
|
|
57
|
-
process.exit(1);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
function showHelp() {
|
|
61
|
-
console.log(`
|
|
62
|
-
${chalk_1.default.bold("aicm v2")} - A CLI tool for managing AI IDE configurations (v2)
|
|
63
|
-
|
|
64
|
-
${chalk_1.default.bold("USAGE")}
|
|
65
|
-
$ aicm-v2 [command] [options]
|
|
66
|
-
|
|
67
|
-
${chalk_1.default.bold("COMMANDS")}
|
|
68
|
-
init Initialize a new aicm configuration file
|
|
69
|
-
install Install rules from configured sources
|
|
70
|
-
list List all configured rules and their status
|
|
71
|
-
|
|
72
|
-
${chalk_1.default.bold("OPTIONS")}
|
|
73
|
-
-h, --help Show this help message
|
|
74
|
-
-v, --version Show version number
|
|
75
|
-
--ci Run in CI environments (default: \`false\`)
|
|
76
|
-
--verbose Show detailed output and stack traces for debugging
|
|
77
|
-
|
|
78
|
-
${chalk_1.default.bold("EXAMPLES")}
|
|
79
|
-
$ aicm-v2 init
|
|
80
|
-
$ aicm-v2 install
|
|
81
|
-
$ aicm-v2 list
|
|
82
|
-
`);
|
|
83
|
-
}
|
|
84
|
-
function logError(error, verbose) {
|
|
85
|
-
if (error instanceof Error) {
|
|
86
|
-
console.error(chalk_1.default.red(`Error: ${error.message}`));
|
|
87
|
-
if (verbose && error.stack) {
|
|
88
|
-
console.error(chalk_1.default.gray(error.stack));
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
else {
|
|
92
|
-
console.error(chalk_1.default.red(`Error: ${String(error)}`));
|
|
93
|
-
}
|
|
94
|
-
}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { NormalizedConfig } from "../../types";
|
|
2
|
-
/**
|
|
3
|
-
* Options for the install functions
|
|
4
|
-
*/
|
|
5
|
-
export interface InstallOptions {
|
|
6
|
-
/**
|
|
7
|
-
* Base directory to use instead of process.cwd()
|
|
8
|
-
*/
|
|
9
|
-
cwd?: string;
|
|
10
|
-
/**
|
|
11
|
-
* Custom config object to use instead of loading from file
|
|
12
|
-
*/
|
|
13
|
-
config?: NormalizedConfig;
|
|
14
|
-
/**
|
|
15
|
-
* allow installation on CI environments
|
|
16
|
-
*/
|
|
17
|
-
installOnCI?: boolean;
|
|
18
|
-
/**
|
|
19
|
-
* Show verbose output during installation
|
|
20
|
-
*/
|
|
21
|
-
verbose?: boolean;
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Result of the install operation
|
|
25
|
-
*/
|
|
26
|
-
export interface InstallResult {
|
|
27
|
-
/**
|
|
28
|
-
* Whether the operation was successful
|
|
29
|
-
*/
|
|
30
|
-
success: boolean;
|
|
31
|
-
/**
|
|
32
|
-
* Error message if the operation failed
|
|
33
|
-
*/
|
|
34
|
-
error?: string;
|
|
35
|
-
/**
|
|
36
|
-
* Error stack trace for debugging (when available)
|
|
37
|
-
*/
|
|
38
|
-
errorStack?: string;
|
|
39
|
-
/**
|
|
40
|
-
* Number of rules installed
|
|
41
|
-
*/
|
|
42
|
-
installedRuleCount: number;
|
|
43
|
-
/**
|
|
44
|
-
* Number of packages installed
|
|
45
|
-
*/
|
|
46
|
-
packagesCount: number;
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Install rules for a single package (used within workspaces and standalone installs)
|
|
50
|
-
* @param options Install options
|
|
51
|
-
* @returns Result of the install operation
|
|
52
|
-
*/
|
|
53
|
-
export declare function installPackage(options?: InstallOptions): Promise<InstallResult>;
|
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.installPackage = installPackage;
|
|
7
|
-
const chalk_1 = __importDefault(require("chalk"));
|
|
8
|
-
const config_1 = require("../../utils/config");
|
|
9
|
-
const rule_detector_1 = require("../../utils/rule-detector");
|
|
10
|
-
const working_directory_1 = require("../../utils/working-directory");
|
|
11
|
-
const rule_collector_1 = require("../../utils/rule-collector");
|
|
12
|
-
const rule_writer_1 = require("../../utils/rule-writer");
|
|
13
|
-
const mcp_writer_1 = require("../../utils/mcp-writer");
|
|
14
|
-
const glob_handler_1 = require("../../utils/glob-handler");
|
|
15
|
-
/**
|
|
16
|
-
* Install rules for a single package (used within workspaces and standalone installs)
|
|
17
|
-
* @param options Install options
|
|
18
|
-
* @returns Result of the install operation
|
|
19
|
-
*/
|
|
20
|
-
async function installPackage(options = {}) {
|
|
21
|
-
const cwd = options.cwd || process.cwd();
|
|
22
|
-
return (0, working_directory_1.withWorkingDirectory)(cwd, async () => {
|
|
23
|
-
const config = options.config || (await (0, config_1.getConfig)());
|
|
24
|
-
const ruleCollection = (0, rule_collector_1.initRuleCollection)();
|
|
25
|
-
if (!config) {
|
|
26
|
-
return {
|
|
27
|
-
success: false,
|
|
28
|
-
error: "Configuration file not found",
|
|
29
|
-
installedRuleCount: 0,
|
|
30
|
-
packagesCount: 0,
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
// Check if rules are defined (either directly or through presets)
|
|
34
|
-
if (!config.rules || Object.keys(config.rules).length === 0) {
|
|
35
|
-
// If there are no presets defined either, show a message
|
|
36
|
-
if (!config.presets || config.presets.length === 0) {
|
|
37
|
-
return {
|
|
38
|
-
success: false,
|
|
39
|
-
error: "No rules defined in configuration",
|
|
40
|
-
installedRuleCount: 0,
|
|
41
|
-
packagesCount: 0,
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
let expandedRules;
|
|
46
|
-
try {
|
|
47
|
-
const expansion = await (0, glob_handler_1.expandRulesGlobPatterns)(config.rules, cwd);
|
|
48
|
-
expandedRules = expansion.expandedRules;
|
|
49
|
-
if (options.verbose) {
|
|
50
|
-
for (const [expandedKey, originalPattern] of Object.entries(expansion.globSources)) {
|
|
51
|
-
console.log(chalk_1.default.gray(` Pattern "${originalPattern}" → ${expandedKey}`));
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
catch (error) {
|
|
56
|
-
const errorMessage = `Error expanding glob patterns: ${error instanceof Error ? error.message : String(error)}`;
|
|
57
|
-
return {
|
|
58
|
-
success: false,
|
|
59
|
-
error: errorMessage,
|
|
60
|
-
errorStack: error instanceof Error ? error.stack : undefined,
|
|
61
|
-
installedRuleCount: 0,
|
|
62
|
-
packagesCount: 0,
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
let hasErrors = false;
|
|
66
|
-
const errorMessages = [];
|
|
67
|
-
let firstErrorStack;
|
|
68
|
-
let installedRuleCount = 0;
|
|
69
|
-
for (const [name, source] of Object.entries(expandedRules)) {
|
|
70
|
-
const ruleType = (0, rule_detector_1.detectRuleType)(source);
|
|
71
|
-
const ruleBasePath = (0, config_1.getRuleSource)(config, name);
|
|
72
|
-
const originalPresetPath = (0, config_1.getOriginalPresetPath)(config, name);
|
|
73
|
-
try {
|
|
74
|
-
let ruleContent;
|
|
75
|
-
switch (ruleType) {
|
|
76
|
-
case "npm":
|
|
77
|
-
ruleContent = (0, rule_collector_1.collectNpmRule)(name, source);
|
|
78
|
-
break;
|
|
79
|
-
case "local":
|
|
80
|
-
ruleContent = (0, rule_collector_1.collectLocalRule)(name, source, ruleBasePath);
|
|
81
|
-
break;
|
|
82
|
-
default:
|
|
83
|
-
errorMessages.push(`Unknown rule type: ${ruleType}`);
|
|
84
|
-
continue;
|
|
85
|
-
}
|
|
86
|
-
if (originalPresetPath) {
|
|
87
|
-
ruleContent.presetPath = originalPresetPath;
|
|
88
|
-
}
|
|
89
|
-
(0, rule_collector_1.addRuleToCollection)(ruleCollection, ruleContent, config.ides);
|
|
90
|
-
installedRuleCount++;
|
|
91
|
-
}
|
|
92
|
-
catch (e) {
|
|
93
|
-
hasErrors = true;
|
|
94
|
-
const errorMessage = `Error processing rule ${name}: ${e instanceof Error ? e.message : String(e)}`;
|
|
95
|
-
errorMessages.push(errorMessage);
|
|
96
|
-
// Keep the first error stack trace
|
|
97
|
-
if (!firstErrorStack && e instanceof Error && e.stack) {
|
|
98
|
-
firstErrorStack = e.stack;
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
if (hasErrors) {
|
|
103
|
-
return {
|
|
104
|
-
success: false,
|
|
105
|
-
error: errorMessages.join("; "),
|
|
106
|
-
errorStack: firstErrorStack,
|
|
107
|
-
installedRuleCount,
|
|
108
|
-
packagesCount: 0,
|
|
109
|
-
};
|
|
110
|
-
}
|
|
111
|
-
(0, rule_writer_1.writeRulesToTargets)(ruleCollection);
|
|
112
|
-
if (config.mcpServers) {
|
|
113
|
-
const filteredMcpServers = Object.fromEntries(Object.entries(config.mcpServers).filter(([, v]) => v !== false));
|
|
114
|
-
(0, mcp_writer_1.writeMcpServersToTargets)(filteredMcpServers, config.ides, cwd);
|
|
115
|
-
}
|
|
116
|
-
return {
|
|
117
|
-
success: true,
|
|
118
|
-
installedRuleCount,
|
|
119
|
-
packagesCount: 1,
|
|
120
|
-
};
|
|
121
|
-
});
|
|
122
|
-
}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { NormalizedConfig } from "../../types";
|
|
2
|
-
/**
|
|
3
|
-
* Options for the install functions
|
|
4
|
-
*/
|
|
5
|
-
export interface InstallOptions {
|
|
6
|
-
/**
|
|
7
|
-
* Base directory to use instead of process.cwd()
|
|
8
|
-
*/
|
|
9
|
-
cwd?: string;
|
|
10
|
-
/**
|
|
11
|
-
* Custom config object to use instead of loading from file
|
|
12
|
-
*/
|
|
13
|
-
config?: NormalizedConfig;
|
|
14
|
-
/**
|
|
15
|
-
* allow installation on CI environments
|
|
16
|
-
*/
|
|
17
|
-
installOnCI?: boolean;
|
|
18
|
-
/**
|
|
19
|
-
* Show verbose output during installation
|
|
20
|
-
*/
|
|
21
|
-
verbose?: boolean;
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Result of the install operation
|
|
25
|
-
*/
|
|
26
|
-
export interface InstallResult {
|
|
27
|
-
/**
|
|
28
|
-
* Whether the operation was successful
|
|
29
|
-
*/
|
|
30
|
-
success: boolean;
|
|
31
|
-
/**
|
|
32
|
-
* Error message if the operation failed
|
|
33
|
-
*/
|
|
34
|
-
error?: string;
|
|
35
|
-
/**
|
|
36
|
-
* Error stack trace for debugging (when available)
|
|
37
|
-
*/
|
|
38
|
-
errorStack?: string;
|
|
39
|
-
/**
|
|
40
|
-
* Number of rules installed
|
|
41
|
-
*/
|
|
42
|
-
installedRuleCount: number;
|
|
43
|
-
/**
|
|
44
|
-
* Number of packages installed
|
|
45
|
-
*/
|
|
46
|
-
packagesCount: number;
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Core single package installation logic
|
|
50
|
-
* @param options Install options
|
|
51
|
-
* @returns Result of the install operation
|
|
52
|
-
*/
|
|
53
|
-
export declare function installSinglePackage(options?: InstallOptions): Promise<InstallResult>;
|
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.installSinglePackage = installSinglePackage;
|
|
7
|
-
const chalk_1 = __importDefault(require("chalk"));
|
|
8
|
-
const config_1 = require("../../utils/config");
|
|
9
|
-
const rule_detector_1 = require("../../utils/rule-detector");
|
|
10
|
-
const rule_collector_1 = require("../../utils/rule-collector");
|
|
11
|
-
const rule_writer_1 = require("../../utils/rule-writer");
|
|
12
|
-
const mcp_writer_1 = require("../../utils/mcp-writer");
|
|
13
|
-
const glob_handler_1 = require("../../utils/glob-handler");
|
|
14
|
-
/**
|
|
15
|
-
* Helper function to execute a function within a specific working directory
|
|
16
|
-
* and ensure the original directory is always restored
|
|
17
|
-
*/
|
|
18
|
-
async function withWorkingDirectory(targetDir, fn) {
|
|
19
|
-
const originalCwd = process.cwd();
|
|
20
|
-
if (targetDir !== originalCwd) {
|
|
21
|
-
process.chdir(targetDir);
|
|
22
|
-
}
|
|
23
|
-
try {
|
|
24
|
-
return await fn();
|
|
25
|
-
}
|
|
26
|
-
finally {
|
|
27
|
-
if (targetDir !== originalCwd) {
|
|
28
|
-
process.chdir(originalCwd);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Core single package installation logic
|
|
34
|
-
* @param options Install options
|
|
35
|
-
* @returns Result of the install operation
|
|
36
|
-
*/
|
|
37
|
-
async function installSinglePackage(options = {}) {
|
|
38
|
-
const cwd = options.cwd || process.cwd();
|
|
39
|
-
return withWorkingDirectory(cwd, async () => {
|
|
40
|
-
const config = options.config || (0, config_1.getConfig)();
|
|
41
|
-
const ruleCollection = (0, rule_collector_1.initRuleCollection)();
|
|
42
|
-
if (!config) {
|
|
43
|
-
return {
|
|
44
|
-
success: false,
|
|
45
|
-
error: "Configuration file not found",
|
|
46
|
-
installedRuleCount: 0,
|
|
47
|
-
packagesCount: 0,
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
// Check if rules are defined (either directly or through presets)
|
|
51
|
-
if (!config.rules || Object.keys(config.rules).length === 0) {
|
|
52
|
-
// If there are no presets defined either, show a message
|
|
53
|
-
if (!config.presets || config.presets.length === 0) {
|
|
54
|
-
return {
|
|
55
|
-
success: false,
|
|
56
|
-
error: "No rules defined in configuration",
|
|
57
|
-
installedRuleCount: 0,
|
|
58
|
-
packagesCount: 0,
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
let expandedRules;
|
|
63
|
-
try {
|
|
64
|
-
const expansion = await (0, glob_handler_1.expandRulesGlobPatterns)(config.rules, cwd);
|
|
65
|
-
expandedRules = expansion.expandedRules;
|
|
66
|
-
if (options.verbose) {
|
|
67
|
-
for (const [expandedKey, originalPattern] of Object.entries(expansion.globSources)) {
|
|
68
|
-
console.log(chalk_1.default.gray(` Pattern "${originalPattern}" → ${expandedKey}`));
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
catch (error) {
|
|
73
|
-
const errorMessage = `Error expanding glob patterns: ${error instanceof Error ? error.message : String(error)}`;
|
|
74
|
-
return {
|
|
75
|
-
success: false,
|
|
76
|
-
error: errorMessage,
|
|
77
|
-
errorStack: error instanceof Error ? error.stack : undefined,
|
|
78
|
-
installedRuleCount: 0,
|
|
79
|
-
packagesCount: 0,
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
let hasErrors = false;
|
|
83
|
-
const errorMessages = [];
|
|
84
|
-
let firstErrorStack;
|
|
85
|
-
let installedRuleCount = 0;
|
|
86
|
-
for (const [name, source] of Object.entries(expandedRules)) {
|
|
87
|
-
const ruleType = (0, rule_detector_1.detectRuleType)(source);
|
|
88
|
-
const ruleBasePath = (0, config_1.getRuleSource)(config, name);
|
|
89
|
-
const originalPresetPath = (0, config_1.getOriginalPresetPath)(config, name);
|
|
90
|
-
try {
|
|
91
|
-
let ruleContent;
|
|
92
|
-
switch (ruleType) {
|
|
93
|
-
case "npm":
|
|
94
|
-
ruleContent = (0, rule_collector_1.collectNpmRule)(name, source);
|
|
95
|
-
break;
|
|
96
|
-
case "local":
|
|
97
|
-
ruleContent = (0, rule_collector_1.collectLocalRule)(name, source, ruleBasePath);
|
|
98
|
-
break;
|
|
99
|
-
default:
|
|
100
|
-
errorMessages.push(`Unknown rule type: ${ruleType}`);
|
|
101
|
-
continue;
|
|
102
|
-
}
|
|
103
|
-
if (originalPresetPath) {
|
|
104
|
-
ruleContent.presetPath = originalPresetPath;
|
|
105
|
-
}
|
|
106
|
-
(0, rule_collector_1.addRuleToCollection)(ruleCollection, ruleContent, config.ides);
|
|
107
|
-
installedRuleCount++;
|
|
108
|
-
}
|
|
109
|
-
catch (e) {
|
|
110
|
-
hasErrors = true;
|
|
111
|
-
const errorMessage = `Error processing rule ${name}: ${e instanceof Error ? e.message : String(e)}`;
|
|
112
|
-
errorMessages.push(errorMessage);
|
|
113
|
-
// Keep the first error stack trace
|
|
114
|
-
if (!firstErrorStack && e instanceof Error && e.stack) {
|
|
115
|
-
firstErrorStack = e.stack;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
if (hasErrors) {
|
|
120
|
-
return {
|
|
121
|
-
success: false,
|
|
122
|
-
error: errorMessages.join("; "),
|
|
123
|
-
errorStack: firstErrorStack,
|
|
124
|
-
installedRuleCount,
|
|
125
|
-
packagesCount: 0,
|
|
126
|
-
};
|
|
127
|
-
}
|
|
128
|
-
(0, rule_writer_1.writeRulesToTargets)(ruleCollection);
|
|
129
|
-
if (config.mcpServers) {
|
|
130
|
-
const filteredMcpServers = Object.fromEntries(Object.entries(config.mcpServers).filter(([, v]) => v !== false));
|
|
131
|
-
(0, mcp_writer_1.writeMcpServersToTargets)(filteredMcpServers, config.ides, cwd);
|
|
132
|
-
}
|
|
133
|
-
return {
|
|
134
|
-
success: true,
|
|
135
|
-
installedRuleCount,
|
|
136
|
-
packagesCount: 1,
|
|
137
|
-
};
|
|
138
|
-
});
|
|
139
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { InstallResult } from "./install-package";
|
|
2
|
-
/**
|
|
3
|
-
* Install rules across multiple packages in a workspace
|
|
4
|
-
* @param cwd The current working directory
|
|
5
|
-
* @param installOnCI Whether to install on CI environments
|
|
6
|
-
* @param verbose Whether to show verbose output
|
|
7
|
-
* @returns Result of the install operation
|
|
8
|
-
*/
|
|
9
|
-
export declare function installWorkspaces(cwd: string, installOnCI: boolean, verbose?: boolean): Promise<InstallResult>;
|