-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(nextjs): remove the "root" option from Next.js build executor si…
…nce it can be inferred
- Loading branch information
Showing
10 changed files
with
123 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
packages/next/src/migrations/update-16-3-0/remove-root-build-option.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import update from './remove-root-build-option'; | ||
import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing-pre16'; | ||
import { | ||
addProjectConfiguration, | ||
readProjectConfiguration, | ||
Tree, | ||
} from '@nx/devkit'; | ||
|
||
describe('remove-root-build-option', () => { | ||
let tree: Tree; | ||
|
||
beforeEach(() => { | ||
tree = createTreeWithEmptyWorkspace(); | ||
}); | ||
|
||
it('should remove the root option from the build target for @nx/next:build executor', async () => { | ||
addProjectConfiguration(tree, 'my-app', { | ||
root: 'my-app', | ||
targets: { | ||
build: { | ||
executor: '@nx/next:build', | ||
options: { | ||
root: 'my-app', | ||
}, | ||
}, | ||
}, | ||
}); | ||
|
||
await update(tree); | ||
|
||
const updatedConfig = readProjectConfiguration(tree, 'my-app'); | ||
expect(updatedConfig.targets.build.options.root).toBeUndefined(); | ||
}); | ||
|
||
it('should remove the root option from the build target for @nrwl/next:build executor', async () => { | ||
addProjectConfiguration(tree, 'my-app', { | ||
root: 'my-app', | ||
targets: { | ||
build: { | ||
executor: '@nrwl/next:build', | ||
options: { | ||
root: 'my-app', | ||
}, | ||
}, | ||
}, | ||
}); | ||
|
||
await update(tree); | ||
|
||
const updatedConfig = readProjectConfiguration(tree, 'my-app'); | ||
expect(updatedConfig.targets.build.options.root).toBeUndefined(); | ||
}); | ||
|
||
it('should leave other executors alone', async () => { | ||
addProjectConfiguration(tree, 'my-app', { | ||
root: 'my-app', | ||
targets: { | ||
build: { | ||
executor: '@acme/foo:bar', | ||
options: { | ||
root: 'my-app', | ||
}, | ||
}, | ||
}, | ||
}); | ||
|
||
await update(tree); | ||
|
||
const updatedConfig = readProjectConfiguration(tree, 'my-app'); | ||
expect(updatedConfig.targets.build.options.root).toEqual('my-app'); | ||
}); | ||
}); |
27 changes: 27 additions & 0 deletions
27
packages/next/src/migrations/update-16-3-0/remove-root-build-option.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { | ||
readProjectConfiguration, | ||
Tree, | ||
updateProjectConfiguration, | ||
} from '@nx/devkit'; | ||
import { forEachExecutorOptions } from '@nx/devkit/src/generators/executor-options-utils'; | ||
|
||
export default async function update(tree: Tree) { | ||
forEachExecutorOptions( | ||
tree, | ||
'@nx/next:build', | ||
(options, projectName, targetName) => { | ||
const projectConfig = readProjectConfiguration(tree, projectName); | ||
delete projectConfig.targets[targetName].options.root; | ||
updateProjectConfiguration(tree, projectName, projectConfig); | ||
} | ||
); | ||
forEachExecutorOptions( | ||
tree, | ||
'@nx/nrwl:build', | ||
(options, projectName, targetName) => { | ||
const projectConfig = readProjectConfiguration(tree, projectName); | ||
delete projectConfig.targets[targetName].options.root; | ||
updateProjectConfiguration(tree, projectName, projectConfig); | ||
} | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters