Skip to content

Commit

Permalink
[fix]: Determine the correct package name for GitHub dependencies (#2801
Browse files Browse the repository at this point in the history
)

* prepare changelog for beta

* allow to install github urls too

* add to docs

* fix the validation log

* trim output from npm view

* fix linter

* listInstalledNodeModules now returns correct name also for GitHub dependencies
  • Loading branch information
foxriver76 authored Jun 12, 2024
1 parent 5e59f9f commit 05d1f58
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
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

0 comments on commit 05d1f58

Please sign in to comment.