Skip to content

Commit

Permalink
fix(workspace-plugin): update import within bundle-size fixtures with…
Browse files Browse the repository at this point in the history
…in prepare-intial-release generator (#31325)
  • Loading branch information
Hotell committed May 15, 2024
1 parent 3855dcb commit 01a93ee
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
readJson,
updateJson,
installPackagesTask,
visitNotIgnoredFiles,
} from '@nrwl/devkit';
import childProcess from 'child_process';

Expand Down Expand Up @@ -251,6 +252,18 @@ describe('prepare-initial-release generator', () => {
export {Two} from './two';
export type {TwoType} from './two';
`,
},
{
filePath: 'packages/react-one-preview/bundle-size/index.fixture.js',
content: stripIndents`
import {One} from '@proj/react-one-preview';
console.log(One);
export default {
name: '@proj/react-one-preview - package',
}
`,
},
{
Expand Down Expand Up @@ -328,6 +341,17 @@ describe('prepare-initial-release generator', () => {
}),
);
expect(utils.project.jest()).toEqual(expect.stringContaining(`displayName: 'react-one'`));
expect(utils.project.bundleSize()).toMatchInlineSnapshot(`
Object {
"packages/react-one/bundle-size/index.fixture.js": "import { One } from '@proj/react-one';
console.log(One);
export default {
name: '@proj/react-one - package',
};",
}
`);
expect(utils.project.md.readme()).toMatchInlineSnapshot(`
"# @proj/react-one
Expand Down Expand Up @@ -606,6 +630,16 @@ These are not production-ready components and **should never be used in product*
readme: () => tree.read(joinPathFragments(newRoot, 'README.md'), 'utf-8'),
api: () => tree.read(joinPathFragments(newRoot, `etc/${projectName.replace('-preview', '')}.api.md`), 'utf-8'),
},
bundleSize: () => {
const root = joinPathFragments(newRoot, 'bundle-size');
const contents: Record<string, string> = {};

visitNotIgnoredFiles(tree, root, file => {
contents[file] = stripIndents`${tree.read(file, 'utf-8')}` ?? '';
});

return contents;
},
global: {
tsBase: () => readJson<TsConfig>(tree, tsConfigBasePath),
tsBaseAll: () => readJson<TsConfig>(tree, tsConfigBaseAllPath),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,16 @@ async function stableRelease(tree: Tree, options: NormalizedSchema) {

updateFileContent(tree, { filePath: options.paths.jestConfig, updater: contentNameUpdater });

const bundleSizeFixturesRoot = joinPathFragments(options.projectConfig.root, 'bundle-size');
if (tree.exists(bundleSizeFixturesRoot)) {
visitNotIgnoredFiles(tree, bundleSizeFixturesRoot, filePath => {
updateFileContent(tree, {
filePath,
updater: contentNameUpdater,
});
});
}

const mdFilePath = {
readme: joinPathFragments(options.projectConfig.root, 'README.md'),
api: joinPathFragments(options.projectConfig.root, 'etc', options.normalizedPkgName + '.api.md'),
Expand Down

0 comments on commit 01a93ee

Please sign in to comment.