dynamic-doctor
Advanced tools
Comparing version 0.1.0-beta.2 to 0.1.0-beta.3
@@ -701,2 +701,7 @@ #! /usr/bin/env node | ||
Object.entries(deps).forEach(([moduleName, version]) => { | ||
// Handle npm aliases | ||
const aliasMatch = version.match(/^npm:(.*)@(.*)/); | ||
if (aliasMatch) { | ||
version = aliasMatch[2]; | ||
} | ||
if (!moduleTree.resolved[moduleName]) { | ||
@@ -831,2 +836,11 @@ const resolvedRef = resolveModule(rootModuleTree, moduleTree.ref, moduleName); | ||
}; | ||
// Handle npm aliases | ||
const getNameOrAlias = (name, lineage) => { | ||
const lineageName = lineage.at(-1); | ||
// Handle aliases | ||
if (lineageName && lineageName !== name) { | ||
return lineageName; | ||
} | ||
return name; | ||
}; | ||
const buildModuleTreeRecursive = (basePath, rootBasePath, currentModuleBranch = moduleTreeStore, isDynamicFlag = false) => { | ||
@@ -839,10 +853,12 @@ const packageJsonPath = path.join(basePath, 'package.json'); | ||
const packageJson = readJsonFile(packageJsonPath); | ||
const ref = resolveLineage(modulePath).join(REF_SEPARATOR); | ||
const moduleLineage = resolveLineage(modulePath); | ||
const ref = moduleLineage.join(REF_SEPARATOR); | ||
isDynamicFlag = isDynamicFlag || isDynamicPackage(ref); | ||
const packageName = getNameOrAlias(packageJson.name, moduleLineage); | ||
// If we are a nested module, set the moduleTree branch to the current module. | ||
currentModuleBranch = isRootPkg | ||
? currentModuleBranch | ||
: (currentModuleBranch['modules'][packageJson.name] = initialBranch()); | ||
: (currentModuleBranch['modules'][packageName] = initialBranch()); | ||
Object.assign(currentModuleBranch, { | ||
name: packageJson.name, | ||
name: packageName, | ||
version: packageJson.version, | ||
@@ -854,3 +870,3 @@ isDynamic: isDynamicFlag, | ||
ref, | ||
moduleLineage: resolveLineage(modulePath), | ||
moduleLineage, | ||
modules: {}, | ||
@@ -874,72 +890,2 @@ modulePath, | ||
// const isOk = () => { | ||
// return ( | ||
// !result.invalidDepVersion.length && | ||
// !result.invalidPeerVersion.length && | ||
// !result.missingDep.length && | ||
// !result.missingPeer.length | ||
// ); | ||
// }; | ||
// export const reporter = () => { | ||
// // Emoki check | ||
// const status = chalk.bold( | ||
// isOk() ? chalk.green('✅ OK') : chalk.red('❌ FAIL'), | ||
// ); | ||
// console.log( | ||
// `Sanity Checking ${chalk.bold('Dynamic SDK')} Dependencies... ${status}`, | ||
// ); | ||
// if (isOk()) { | ||
// return; | ||
// } | ||
// report('dependencies', false, result.invalidDepVersion); | ||
// report('peer dependencies', false, result.invalidPeerVersion); | ||
// report('dependencies', true, result.missingDep); | ||
// report('peer dependencies', true, result.missingPeer); | ||
// console.log( | ||
// chalk.magentaBright( | ||
// '🛠 Ensure all dependencies are installed and meet version requirements.', | ||
// ), | ||
// ); | ||
// DoctorLogger.newLine(); | ||
// }; | ||
// const report = ( | ||
// depType: 'peer dependencies' | 'dependencies', | ||
// missing: boolean, | ||
// resultObj: | ||
// | Result['invalidPeerVersion'] | ||
// | Result['invalidDepVersion'] | ||
// | Result['missingDep'] | ||
// | Result['missingPeer'], | ||
// ) => { | ||
// if (!resultObj.length) { | ||
// return; | ||
// } | ||
// DoctorLogger.dashedLine(); | ||
// console.log(chalk.bold(`${missing ? 'Missing' : 'Incorrect'} ${depType}:`)); | ||
// resultObj.forEach(({ name, lineage, ...rest }) => { | ||
// const { requiredVersion, version } = rest as | ||
// | Result['invalidDepVersion'][number] | ||
// | Result['invalidPeerVersion'][number]; | ||
// lineage.push(name); | ||
// const hierarchy: Data = lineage.reduceRight((acc, curr) => { | ||
// if (isEmpty(acc)) { | ||
// const label = `${curr}${version ? `@${version}` : ''}`; | ||
// acc['label'] = chalk.yellow( | ||
// `${label} ${ | ||
// requiredVersion | ||
// ? chalk.red(`Incorrect version Required: ${requiredVersion}`) | ||
// : '' | ||
// }`, | ||
// ); | ||
// return acc; | ||
// } | ||
// return { | ||
// label: curr, | ||
// nodes: [acc], | ||
// }; | ||
// }, {} as Data); | ||
// console.log(archy(hierarchy)); | ||
// }); | ||
// process.exitCode = 1; | ||
// }; | ||
const isDataObj = (obj) => { | ||
@@ -946,0 +892,0 @@ if (typeof obj === 'string' || !obj) { |
@@ -12,3 +12,3 @@ { | ||
}, | ||
"version": "0.1.0-beta.2", | ||
"version": "0.1.0-beta.3", | ||
"license": "MIT", | ||
@@ -15,0 +15,0 @@ "bin": { |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1752466
45133