Skip to content
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

fix(core): add missing bun PM support #26084

Merged
merged 1 commit into from
May 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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