2026-03-14 12:55:25 -07:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
|
|
const {
|
2026-03-15 21:47:22 -07:00
|
|
|
createLegacyCompatInstallPlan,
|
2026-03-14 12:55:25 -07:00
|
|
|
createLegacyInstallPlan,
|
|
|
|
|
createManifestInstallPlan,
|
|
|
|
|
} = require('../install-executor');
|
2026-08-25 12:17:21 -04:00
|
|
|
const { resolveInvocationEnvironment } = require('../invocation-environment');
|
2026-08-07 15:18:14 -04:00
|
|
|
const { withHookConsent } = require('./hook-consent');
|
2026-03-14 12:55:25 -07:00
|
|
|
|
|
|
|
|
function createInstallPlanFromRequest(request, options = {}) {
|
|
|
|
|
if (!request || typeof request !== 'object') {
|
|
|
|
|
throw new Error('A normalized install request is required');
|
|
|
|
|
}
|
|
|
|
|
|
2026-08-07 15:18:14 -04:00
|
|
|
return withHookConsent(createRawInstallPlan(request, options), request.hookConsent || null);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function createRawInstallPlan(request, options = {}) {
|
2026-03-14 12:55:25 -07:00
|
|
|
if (request.mode === 'manifest') {
|
|
|
|
|
return createManifestInstallPlan({
|
|
|
|
|
target: request.target,
|
|
|
|
|
profileId: request.profileId,
|
|
|
|
|
moduleIds: request.moduleIds,
|
|
|
|
|
includeComponentIds: request.includeComponentIds,
|
|
|
|
|
excludeComponentIds: request.excludeComponentIds,
|
|
|
|
|
projectRoot: options.projectRoot,
|
|
|
|
|
homeDir: options.homeDir,
|
2026-08-25 12:17:21 -04:00
|
|
|
env: resolveInvocationEnvironment(options),
|
2026-03-14 12:55:25 -07:00
|
|
|
sourceRoot: options.sourceRoot,
|
2026-08-07 15:18:14 -04:00
|
|
|
exemptValidationCodes: options.exemptValidationCodes || [],
|
2026-03-14 12:55:25 -07:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-15 21:47:22 -07:00
|
|
|
if (request.mode === 'legacy-compat') {
|
|
|
|
|
return createLegacyCompatInstallPlan({
|
|
|
|
|
target: request.target,
|
|
|
|
|
legacyLanguages: request.legacyLanguages,
|
2026-05-17 20:46:04 -04:00
|
|
|
includeComponentIds: request.includeComponentIds,
|
|
|
|
|
excludeComponentIds: request.excludeComponentIds,
|
2026-03-15 21:47:22 -07:00
|
|
|
projectRoot: options.projectRoot,
|
|
|
|
|
homeDir: options.homeDir,
|
2026-08-25 12:17:21 -04:00
|
|
|
env: resolveInvocationEnvironment(options),
|
2026-03-15 21:47:22 -07:00
|
|
|
claudeRulesDir: options.claudeRulesDir,
|
|
|
|
|
sourceRoot: options.sourceRoot,
|
2026-08-07 15:18:14 -04:00
|
|
|
exemptValidationCodes: options.exemptValidationCodes || [],
|
2026-03-15 21:47:22 -07:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-14 12:55:25 -07:00
|
|
|
if (request.mode === 'legacy') {
|
|
|
|
|
return createLegacyInstallPlan({
|
|
|
|
|
target: request.target,
|
|
|
|
|
languages: request.languages,
|
|
|
|
|
projectRoot: options.projectRoot,
|
|
|
|
|
homeDir: options.homeDir,
|
|
|
|
|
claudeRulesDir: options.claudeRulesDir,
|
|
|
|
|
sourceRoot: options.sourceRoot,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
throw new Error(`Unsupported install request mode: ${request.mode}`);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
|
createInstallPlanFromRequest,
|
|
|
|
|
};
|