aicm 0.14.4 → 0.15.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 +18 -1
- package/dist/commands/install.js +61 -93
- package/dist/utils/config.d.ts +3 -1
- package/dist/utils/config.js +2 -0
- package/dist/utils/rules-file-writer.d.ts +5 -0
- package/dist/utils/rules-file-writer.js +46 -1
- 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
|
@@ -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>;
|
|
@@ -1,172 +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.installWorkspaces = installWorkspaces;
|
|
7
|
-
const node_path_1 = __importDefault(require("node:path"));
|
|
8
|
-
const node_child_process_1 = require("node:child_process");
|
|
9
|
-
const chalk_1 = __importDefault(require("chalk"));
|
|
10
|
-
const config_1 = require("../../utils/config");
|
|
11
|
-
const working_directory_1 = require("../../utils/working-directory");
|
|
12
|
-
const install_package_1 = require("./install-package");
|
|
13
|
-
/**
|
|
14
|
-
* Discover aicm.json files using git ls-files
|
|
15
|
-
* @param rootDir The root directory to search from
|
|
16
|
-
* @returns Array of aicm.json file paths
|
|
17
|
-
*/
|
|
18
|
-
function findAicmFiles(rootDir) {
|
|
19
|
-
const output = (0, node_child_process_1.execSync)("git ls-files --cached --others --exclude-standard aicm.json **/aicm.json", {
|
|
20
|
-
cwd: rootDir,
|
|
21
|
-
encoding: "utf8",
|
|
22
|
-
});
|
|
23
|
-
return output
|
|
24
|
-
.trim()
|
|
25
|
-
.split("\n")
|
|
26
|
-
.filter(Boolean)
|
|
27
|
-
.map((file) => node_path_1.default.resolve(rootDir, file));
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Discover all packages with aicm configurations
|
|
31
|
-
* @param rootDir The root directory to search from
|
|
32
|
-
* @returns Array of discovered packages
|
|
33
|
-
*/
|
|
34
|
-
async function discoverPackagesWithAicm(rootDir) {
|
|
35
|
-
const aicmFiles = findAicmFiles(rootDir);
|
|
36
|
-
const packages = [];
|
|
37
|
-
for (const aicmFile of aicmFiles) {
|
|
38
|
-
const packageDir = node_path_1.default.dirname(aicmFile);
|
|
39
|
-
const relativePath = node_path_1.default.relative(rootDir, packageDir);
|
|
40
|
-
// Normalize to forward slashes for cross-platform compatibility
|
|
41
|
-
const normalizedRelativePath = relativePath.replace(/\\/g, "/");
|
|
42
|
-
const config = await (0, config_1.getConfig)(packageDir);
|
|
43
|
-
if (config) {
|
|
44
|
-
packages.push({
|
|
45
|
-
relativePath: normalizedRelativePath || ".",
|
|
46
|
-
absolutePath: packageDir,
|
|
47
|
-
config,
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
// Sort packages by relativePath for deterministic order
|
|
52
|
-
return packages.sort((a, b) => a.relativePath.localeCompare(b.relativePath));
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Install aicm configurations for all packages in a workspace
|
|
56
|
-
* @param packages The packages to install configurations for
|
|
57
|
-
* @param options Install options
|
|
58
|
-
* @returns Result of the workspace installation
|
|
59
|
-
*/
|
|
60
|
-
async function installWorkspacesPackages(packages, options = {}) {
|
|
61
|
-
const results = [];
|
|
62
|
-
let totalRuleCount = 0;
|
|
63
|
-
// Install packages sequentially for now (can be parallelized later)
|
|
64
|
-
for (const pkg of packages) {
|
|
65
|
-
const packagePath = pkg.absolutePath;
|
|
66
|
-
try {
|
|
67
|
-
const result = await (0, install_package_1.installPackage)({
|
|
68
|
-
...options,
|
|
69
|
-
cwd: packagePath,
|
|
70
|
-
});
|
|
71
|
-
totalRuleCount += result.installedRuleCount;
|
|
72
|
-
results.push({
|
|
73
|
-
path: pkg.relativePath,
|
|
74
|
-
success: result.success,
|
|
75
|
-
error: result.error,
|
|
76
|
-
errorStack: result.errorStack,
|
|
77
|
-
installedRuleCount: result.installedRuleCount,
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
catch (error) {
|
|
81
|
-
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
82
|
-
results.push({
|
|
83
|
-
path: pkg.relativePath,
|
|
84
|
-
success: false,
|
|
85
|
-
error: errorMessage,
|
|
86
|
-
errorStack: error instanceof Error ? error.stack : undefined,
|
|
87
|
-
installedRuleCount: 0,
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
const failedPackages = results.filter((r) => !r.success);
|
|
92
|
-
return {
|
|
93
|
-
success: failedPackages.length === 0,
|
|
94
|
-
packages: results,
|
|
95
|
-
totalRuleCount,
|
|
96
|
-
};
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* Install rules across multiple packages in a workspace
|
|
100
|
-
* @param cwd The current working directory
|
|
101
|
-
* @param installOnCI Whether to install on CI environments
|
|
102
|
-
* @param verbose Whether to show verbose output
|
|
103
|
-
* @returns Result of the install operation
|
|
104
|
-
*/
|
|
105
|
-
async function installWorkspaces(cwd, installOnCI, verbose = false) {
|
|
106
|
-
return (0, working_directory_1.withWorkingDirectory)(cwd, async () => {
|
|
107
|
-
if (verbose) {
|
|
108
|
-
console.log(chalk_1.default.blue("🔍 Discovering packages..."));
|
|
109
|
-
}
|
|
110
|
-
const allPackages = await discoverPackagesWithAicm(cwd);
|
|
111
|
-
const packages = allPackages.filter((pkg) => {
|
|
112
|
-
const isRoot = pkg.relativePath === ".";
|
|
113
|
-
if (!isRoot)
|
|
114
|
-
return true;
|
|
115
|
-
// For root directories, only keep if it has rules or presets
|
|
116
|
-
const hasRules = pkg.config.rules && Object.keys(pkg.config.rules).length > 0;
|
|
117
|
-
const hasPresets = pkg.config.presets && pkg.config.presets.length > 0;
|
|
118
|
-
return hasRules || hasPresets;
|
|
119
|
-
});
|
|
120
|
-
if (packages.length === 0) {
|
|
121
|
-
return {
|
|
122
|
-
success: false,
|
|
123
|
-
error: "No packages with aicm configurations found",
|
|
124
|
-
installedRuleCount: 0,
|
|
125
|
-
packagesCount: 0,
|
|
126
|
-
};
|
|
127
|
-
}
|
|
128
|
-
if (verbose) {
|
|
129
|
-
console.log(chalk_1.default.blue(`Found ${packages.length} packages with aicm configurations:`));
|
|
130
|
-
packages.forEach((pkg) => {
|
|
131
|
-
console.log(chalk_1.default.gray(` - ${pkg.relativePath}`));
|
|
132
|
-
});
|
|
133
|
-
console.log(chalk_1.default.blue(`📦 Installing configurations...`));
|
|
134
|
-
}
|
|
135
|
-
const result = await installWorkspacesPackages(packages, {
|
|
136
|
-
installOnCI,
|
|
137
|
-
});
|
|
138
|
-
if (verbose) {
|
|
139
|
-
result.packages.forEach((pkg) => {
|
|
140
|
-
if (pkg.success) {
|
|
141
|
-
console.log(chalk_1.default.green(`✅ ${pkg.path} (${pkg.installedRuleCount} rules)`));
|
|
142
|
-
}
|
|
143
|
-
else {
|
|
144
|
-
console.log(chalk_1.default.red(`❌ ${pkg.path}: ${pkg.error}`));
|
|
145
|
-
}
|
|
146
|
-
});
|
|
147
|
-
}
|
|
148
|
-
const failedPackages = result.packages.filter((r) => !r.success);
|
|
149
|
-
if (failedPackages.length > 0) {
|
|
150
|
-
console.log(chalk_1.default.yellow(`Installation completed with errors`));
|
|
151
|
-
if (verbose) {
|
|
152
|
-
console.log(chalk_1.default.green(`Successfully installed: ${result.packages.length - failedPackages.length}/${result.packages.length} packages (${result.totalRuleCount} rules total)`));
|
|
153
|
-
console.log(chalk_1.default.red(`Failed packages: ${failedPackages.map((p) => p.path).join(", ")}`));
|
|
154
|
-
}
|
|
155
|
-
const errorDetails = failedPackages
|
|
156
|
-
.map((p) => `${p.path}: ${p.error}`)
|
|
157
|
-
.join("; ");
|
|
158
|
-
return {
|
|
159
|
-
success: false,
|
|
160
|
-
error: `Package installation failed for ${failedPackages.length} package(s): ${errorDetails}`,
|
|
161
|
-
installedRuleCount: result.totalRuleCount,
|
|
162
|
-
packagesCount: result.packages.length,
|
|
163
|
-
};
|
|
164
|
-
}
|
|
165
|
-
console.log(`Successfully installed ${result.totalRuleCount} rules across ${result.packages.length} packages`);
|
|
166
|
-
return {
|
|
167
|
-
success: true,
|
|
168
|
-
installedRuleCount: result.totalRuleCount,
|
|
169
|
-
packagesCount: result.packages.length,
|
|
170
|
-
};
|
|
171
|
-
});
|
|
172
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { ResolvedConfig } from "../utils/config_v2";
|
|
2
|
-
export interface InstallOptions {
|
|
3
|
-
cwd?: string;
|
|
4
|
-
config?: ResolvedConfig;
|
|
5
|
-
installOnCI?: boolean;
|
|
6
|
-
verbose?: boolean;
|
|
7
|
-
}
|
|
8
|
-
export interface InstallResult {
|
|
9
|
-
success: boolean;
|
|
10
|
-
error?: string;
|
|
11
|
-
errorStack?: string;
|
|
12
|
-
installedRuleCount: number;
|
|
13
|
-
packagesCount: number;
|
|
14
|
-
}
|
|
15
|
-
export declare function installPackage(options?: InstallOptions): Promise<InstallResult>;
|
|
16
|
-
export declare function install(options?: InstallOptions): Promise<InstallResult>;
|
|
17
|
-
export declare function installCommand(installOnCI?: boolean, verbose?: boolean): Promise<void>;
|