-
Notifications
You must be signed in to change notification settings - Fork 2.9k
feat(scripts-task): implement initial verify-packaging task #29595
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
Merged
Hotell
merged 7 commits into
microsoft:master
from
Hotell:hotell/build/verify-packaging
Oct 25, 2023
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
293bb33
feat(scripts-task): implement initial verify-packaging task
Hotell bd7cccd
ci: add verify-package to lage task dependency graph
Hotell fc28675
chore(react-text): add verify-packaging task
Hotell 4513cca
chore(utilities): add verify-packaging task
Hotell 7f786ee
generate changefiles
Hotell 84fea08
ci: run verify-packaging task on ci
Hotell b355d28
fixup! feat(scripts-task): implement initial verify-packaging task
Hotell File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
change/@fluentui-react-text-701383d5-631a-46fc-a991-276a590f6132.json
This file contains hidden or 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,7 @@ | ||
| { | ||
| "type": "none", | ||
| "comment": "chore: add verify-packaging task", | ||
| "packageName": "@fluentui/react-text", | ||
| "email": "[email protected]", | ||
| "dependentChangeType": "none" | ||
| } |
7 changes: 7 additions & 0 deletions
7
change/@fluentui-utilities-78031fb1-2f31-4c82-a6e6-921baf28c8f6.json
This file contains hidden or 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,7 @@ | ||
| { | ||
| "type": "none", | ||
| "comment": "chore: add verify-packaging task", | ||
| "packageName": "@fluentui/utilities", | ||
| "email": "[email protected]", | ||
| "dependentChangeType": "none" | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,58 @@ | ||
| import assert from 'node:assert/strict'; | ||
| import { spawnSync } from 'node:child_process'; | ||
| import { readFileSync } from 'node:fs'; | ||
| import path from 'node:path'; | ||
|
|
||
| export function verifyPackaging() { | ||
| const cwd = process.cwd(); | ||
| const projectJSON: import('@nx/devkit').ProjectConfiguration = JSON.parse( | ||
| readFileSync(path.join(cwd, 'project.json'), 'utf-8'), | ||
| ); | ||
| const tags = projectJSON.tags ?? []; | ||
|
|
||
| const result = spawnSync('npm', ['pack', '--dry-run']); | ||
|
|
||
| const processedResult = result.output | ||
| .toString() | ||
| .replace(/\bnpm notice\b\s+[\d.]+[kB]+\s+/gi, '') | ||
| .replace(/[ ]+/g, ''); | ||
|
|
||
| const isV8package = tags.indexOf('v8') !== -1; | ||
| const isV9package = tags.indexOf('vNext') !== -1; | ||
|
|
||
| if (isV9package) { | ||
| assert.doesNotMatch(processedResult, /src\/[.a-z0-9/-_]+/i, `wont ship source code from "/src"`); | ||
| assert.doesNotMatch(processedResult, /config\/[.a-z0-9/-_]+/i, `wont ship config folder`); | ||
| assert.doesNotMatch(processedResult, /etc\/[.a-z0-9/-_]+/i, `wont ship etc folder`); | ||
| assert.doesNotMatch(processedResult, /just\.config\.[jt]s/i, `wont ship configuration files`); | ||
| } | ||
|
|
||
| if (isV8package) { | ||
| assert.match(processedResult, /lib\/[.a-z0-9/-_]+(.d.ts)/i, 'ships dts'); | ||
| } | ||
|
|
||
| assert.match(processedResult, /package\.json/, 'ships package.json'); | ||
| assert.match(processedResult, /README\.md/, 'ships README.md'); | ||
| assert.match(processedResult, /CHANGELOG\.md/, 'ships CHANGELOG.md'); | ||
| assert.match(processedResult, /dist\/[a-z-]+\.d\.ts/, 'ships rolluped dts'); | ||
| assert.match(processedResult, /lib-commonjs\/[.a-z0-9/-_]+(.js|.map)/i, 'ships cjs'); | ||
| assert.match(processedResult, /lib\/[.a-z0-9/-_]+(.js|.map)/i, 'ships esm'); | ||
|
|
||
| assert.doesNotMatch(processedResult, /docs\/[.a-z0-9/-_]+/i, `wont ship docs folder`); | ||
| assert.doesNotMatch(processedResult, /temp\/[.a-z0-9/-_]+/i, `wont ship temp folder`); | ||
| assert.doesNotMatch(processedResult, /bundle-size\/[.a-z0-9/-_]+/i, `wont ship bundle-size fixtures`); | ||
| assert.doesNotMatch(processedResult, /.storybook\/[.a-z0-9/-_]+/i, `wont ship .storybook config`); | ||
| assert.doesNotMatch(processedResult, /stories\/[.a-z0-9/-_]+/i, `wont ship stories`); | ||
| assert.doesNotMatch(processedResult, /jest\.config\.js/i, `wont ship configuration files`); | ||
| assert.doesNotMatch(processedResult, /tsconfig[.a-z]*\.json/i, `wont ship configuration files`); | ||
| assert.doesNotMatch(processedResult, /project\.json/i, `wont ship configuration files`); | ||
| assert.doesNotMatch(processedResult, /\.eslintrc\.(json|js)/i, `wont ship configuration files`); | ||
| assert.doesNotMatch(processedResult, /\.babelrc\.json/i, `wont ship configuration files`); | ||
| assert.doesNotMatch(processedResult, /\.swcrc/i, `wont ship configuration files`); | ||
|
|
||
| // @FIXME `amd` is created only on release pipeline where `--production` flag is used on build commands which triggers it | ||
| // we should enable this also on PR pipelines - need to verify time execution impact | ||
| // if (isV8package || tags.indexOf('ships-amd') !== -1) { | ||
| // assert.match(processedResult, /lib-amd\/[.a-z0-9/-_]+(.js|.map)/i, 'ships amd'); | ||
| // } | ||
| } | ||
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.
Uh oh!
There was an error while loading. Please reload this page.