Skip to content

Commit

Permalink
fix(core): add missing bun PM support (#26084)
Browse files Browse the repository at this point in the history
This fix add support for bun PM in daemon and affected changes.

Helps towards #26053 fix

(cherry picked from commit 4cbb0f0)
  • Loading branch information
Jordan-Hall authored and FrozenPandaz committed May 27, 2024
1 parent f086869 commit 20f5a8a
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 31 deletions.
14 changes: 14 additions & 0 deletions docs/shared/getting-started/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ npx create-nx-workspace --pm yarn
npx create-nx-workspace --pm pnpm
```

{% /tab %}
{% tab label="Bun" %}

```shell
bunx create-nx-workspace --pm bun
```

{% /tab %}
{% /tabs %}

Expand Down Expand Up @@ -85,6 +92,13 @@ yarn global add nx@latest
pnpm add --global nx@latest
```

{% /tab %}
{% tab label="Bun" %}

```shell
bun install --global nx@latest
```

{% /tab %}
{% /tabs %}

Expand Down
1 change: 1 addition & 0 deletions packages/devkit/src/utils/replace-package.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ function replaceMentions(
'yarn.lock',
'package-lock.json',
'pnpm-lock.yaml',
'bun.lockb',
'CHANGELOG.md',
];
if (ignoredFiles.includes(basename(path))) {
Expand Down
1 change: 1 addition & 0 deletions packages/nx/src/daemon/server/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ function lockFileHashChanged(): boolean {
join(workspaceRoot, 'package-lock.json'),
join(workspaceRoot, 'yarn.lock'),
join(workspaceRoot, 'pnpm-lock.yaml'),
join(workspaceRoot, 'bun.lockb'),
]
.filter((file) => existsSync(file))
.map((file) => hashFile(file));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,37 +36,41 @@ describe('getTouchedProjectsFromLockFile', () => {
allNodes = Object.keys(graph.nodes);
});

['package-lock.json', 'yarn.lock', 'pnpm-lock.yaml', 'pnpm-lock.yml'].forEach(
(lockFile) => {
describe(`"${lockFile}"`, () => {
it(`should not return changes when "${lockFile}" is not touched`, () => {
const result = getTouchedProjectsFromLockFile(
[
{
file: 'source.ts',
hash: 'some-hash',
getChanges: () => [new WholeFileChange()],
},
],
graph.nodes
);
expect(result).toEqual([]);
});
[
'package-lock.json',
'yarn.lock',
'pnpm-lock.yaml',
'pnpm-lock.yml',
'bun.lockb',
].forEach((lockFile) => {
describe(`"${lockFile}"`, () => {
it(`should not return changes when "${lockFile}" is not touched`, () => {
const result = getTouchedProjectsFromLockFile(
[
{
file: 'source.ts',
hash: 'some-hash',
getChanges: () => [new WholeFileChange()],
},
],
graph.nodes
);
expect(result).toEqual([]);
});

it(`should return all nodes when "${lockFile}" is touched`, () => {
const result = getTouchedProjectsFromLockFile(
[
{
file: lockFile,
hash: 'some-hash',
getChanges: () => [new WholeFileChange()],
},
],
graph.nodes
);
expect(result).toEqual(allNodes);
});
it(`should return all nodes when "${lockFile}" is touched`, () => {
const result = getTouchedProjectsFromLockFile(
[
{
file: lockFile,
hash: 'some-hash',
getChanges: () => [new WholeFileChange()],
},
],
graph.nodes
);
expect(result).toEqual(allNodes);
});
}
);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export const getTouchedProjectsFromLockFile: TouchedProjectLocator<
'yarn.lock',
'pnpm-lock.yaml',
'pnpm-lock.yml',
'bun.lockb',
];

if (fileChanges.some((f) => lockFiles.includes(f.file))) {
Expand Down

0 comments on commit 20f5a8a

Please sign in to comment.