Skip to content

[fix]: Determine the correct package name for GitHub dependencies #2801

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Jun 12, 2024
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
## __WORK IN PROGRESS__
-->

## 6.0.2 (2024-06-11) - Kiera
## __WORK IN PROGRESS__ - Kiera

**Breaking changes**
* Support for Node.js 16 is dropped!
Expand Down
13 changes: 9 additions & 4 deletions packages/adapter/src/lib/adapter/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ import {
import { SUPPORTED_FEATURES, type SupportedFeature } from '@/lib/adapter/constants.js';
import path from 'node:path';
import fs from 'fs-extra';
import { createRequire } from 'node:module';

// eslint-disable-next-line unicorn/prefer-module
const require = createRequire(import.meta.url || 'file://' + __filename);

interface EncryptArrayOptions {
/** The objects whose values should be en/decrypted */
Expand Down Expand Up @@ -114,14 +118,15 @@ export async function listInstalledNodeModules(namespace: string): Promise<strin
};
const dependencies: string[] = [];

for (const [dependency, versionInfo] of Object.entries(packJson.dependencies)) {
for (const dependency of Object.keys(packJson.dependencies)) {
if (!dependency.startsWith(`@${appNameLowerCase}-${namespace}/`)) {
continue;
}

// remove npm: and version after last @
const realDependencyName = versionInfo.substring(4, versionInfo.lastIndexOf('@'));
dependencies.push(realDependencyName);
const packPath = require.resolve(`${dependency}/package.json`);
const packJson = await fs.readJson(packPath);

dependencies.push(packJson.name);
}

return dependencies;
Expand Down
Loading