-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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(js): .swcrc path option should follow existing conventions #10127
Merged
Merged
Changes from 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
9037648
fix(js): make swrc option follow existing conventions
djgrant 7f8563d
docs(js): update parameter name for swcrc option
djgrant 23f6dc0
fix(js): resolve swcrc path predictably
djgrant f51b0d9
docs(js): hardcode swcrc option default in desc
djgrant 058dfa2
fix(js): migrate swcrcPath to swcrc
djgrant 0594e2f
fix(js): release migration to latest version
djgrant 9c20834
chore(repo): kick off circle
AgentEnder File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
33 changes: 33 additions & 0 deletions
33
packages/js/src/migrations/update-14.1.1-beta.0/update-swcrc-path.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,33 @@ | ||
import { | ||
addProjectConfiguration, | ||
readProjectConfiguration, | ||
} from '@nrwl/devkit'; | ||
import { createTreeWithEmptyWorkspace } from '@nrwl/devkit/testing'; | ||
import updateSwcrcPath from './update-swcrc-path'; | ||
|
||
describe('update-swcrc-path migration', () => { | ||
it('should replace relative `swcrcPath` option with absolute `swcrc`', async () => { | ||
const tree = createTreeWithEmptyWorkspace(2); | ||
addProjectConfiguration(tree, 'test-package', { | ||
root: 'packages/test-package', | ||
targets: { | ||
build: { | ||
executor: '@nrwl/js:swc', | ||
options: { | ||
swcrcPath: 'config/swcrc.json', | ||
somethingThatShouldNotBeRemoved: true, | ||
}, | ||
}, | ||
}, | ||
}); | ||
|
||
await updateSwcrcPath(tree); | ||
|
||
const { targets } = readProjectConfiguration(tree, 'test-package'); | ||
expect(targets.build.options.somethingThatShouldNotBeRemoved).toBeDefined(); | ||
expect(targets.build.options.swcrcPath).toBeUndefined(); | ||
expect(targets.build.options.swcrc).toBe( | ||
'packages/test-package/config/swcrc.json' | ||
); | ||
}); | ||
}); |
37 changes: 37 additions & 0 deletions
37
packages/js/src/migrations/update-14.1.1-beta.0/update-swcrc-path.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,37 @@ | ||
import { | ||
joinPathFragments, | ||
readProjectConfiguration, | ||
Tree, | ||
updateProjectConfiguration, | ||
} from '@nrwl/devkit'; | ||
import { forEachExecutorOptions } from '@nrwl/workspace/src/utilities/executor-options-utils'; | ||
import { SwcExecutorOptions } from '../../utils/schema'; | ||
|
||
type OldSwcExecutorOptions = SwcExecutorOptions & { swcrcPath?: string }; | ||
|
||
export function updateSwcrcPath(tree: Tree) { | ||
forEachExecutorOptions( | ||
tree, | ||
'@nrwl/js:swc', | ||
(_, projectName, targetName, configurationName) => { | ||
const projectConfig = readProjectConfiguration(tree, projectName); | ||
const executorOptions: OldSwcExecutorOptions = configurationName | ||
? projectConfig.targets[targetName].configurations[configurationName] | ||
: projectConfig.targets[targetName].options; | ||
|
||
if (!executorOptions.swcrcPath) return; | ||
|
||
const newSwcrcPath = joinPathFragments( | ||
projectConfig.root, | ||
executorOptions.swcrcPath | ||
); | ||
|
||
delete executorOptions.swcrcPath; | ||
executorOptions.swcrc = newSwcrcPath; | ||
|
||
updateProjectConfiguration(tree, projectName, projectConfig); | ||
} | ||
); | ||
} | ||
|
||
export default updateSwcrcPath; |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
14.1.1 has been released already, can you bump this to 14.1.5-beta.0?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done 👍