From 3ba33e2840506d60665f4809785232ffc43479e3 Mon Sep 17 00:00:00 2001 From: Martin Hochel Date: Tue, 7 May 2024 19:41:18 +0200 Subject: [PATCH] chore: wc-3 changes necessary in order to bring it back to master (#31296) --- .../azure-static-web-apps-deploy.yml | 2 +- .github/workflows/check-packages.yml | 3 +- apps/vr-tests-web-components/package.json | 2 +- azure-pipelines-pr.yml | 1 - azure-pipelines.bundlesize.yml | 2 - azure-pipelines.release.web-components.yml | 6 +- azure-pipelines.vrt-pr.yml | 1 - ...-db28c4c9-e1dd-4dd0-a4fe-c7fed393995e.json | 7 + package.json | 8 +- packages/web-components/package.json | 4 +- scripts/beachball/check-wc-3-changefiles.js | 74 ----------- .../beachball/check-wc-3-changefiles.spec.ts | 122 ------------------ .../release-web-components.config.js | 4 +- scripts/beachball/utils.ts | 17 ++- 14 files changed, 26 insertions(+), 227 deletions(-) create mode 100644 change/@fluentui-web-components-db28c4c9-e1dd-4dd0-a4fe-c7fed393995e.json delete mode 100644 scripts/beachball/check-wc-3-changefiles.js delete mode 100644 scripts/beachball/check-wc-3-changefiles.spec.ts diff --git a/.github/workflows/azure-static-web-apps-deploy.yml b/.github/workflows/azure-static-web-apps-deploy.yml index 0fa6027290917..1e049feb7b0b2 100644 --- a/.github/workflows/azure-static-web-apps-deploy.yml +++ b/.github/workflows/azure-static-web-apps-deploy.yml @@ -3,7 +3,7 @@ name: Azure Static Web Apps web components on: push: branches: - - web-components-v3 + - master paths: - packages/web-components/** workflow_dispatch: diff --git a/.github/workflows/check-packages.yml b/.github/workflows/check-packages.yml index 5d1f822240a0c..cbfb7971cd1da 100644 --- a/.github/workflows/check-packages.yml +++ b/.github/workflows/check-packages.yml @@ -85,5 +85,4 @@ jobs: core.exportVariable('BEACHBALL_VERSION', beachballVersion); - run: | - npx beachball@$BEACHBALL_VERSION check -b web-components-v3 - node ./scripts/beachball/check-wc-3-changefiles + npx beachball@$BEACHBALL_VERSION check diff --git a/apps/vr-tests-web-components/package.json b/apps/vr-tests-web-components/package.json index b18ba04c801ad..e07a49c9df426 100644 --- a/apps/vr-tests-web-components/package.json +++ b/apps/vr-tests-web-components/package.json @@ -23,7 +23,7 @@ "dependencies": { "@fluentui/react-button": "*", "@fluentui/react-storybook-addon": "*", - "@fluentui/web-components": "3.0.0-beta.15", + "@fluentui/web-components": ">=3.0.0-alpha", "tslib": "^2.1.0" } } diff --git a/azure-pipelines-pr.yml b/azure-pipelines-pr.yml index fb1674dcb0345..50459ff3ee73f 100644 --- a/azure-pipelines-pr.yml +++ b/azure-pipelines-pr.yml @@ -1,6 +1,5 @@ pr: - master - - web-components-v3 # Remove before merging to master # There's a separate pipeline for CI which also uses this file, but with a trigger override in the UI # https://dev.azure.com/uifabric/fabricpublic/_apps/hub/ms.vss-ciworkflow.build-ci-hub?_a=edit-build-definition&id=164&view=Tab_Triggers diff --git a/azure-pipelines.bundlesize.yml b/azure-pipelines.bundlesize.yml index fc845113a2abd..dda75d1e32a2b 100644 --- a/azure-pipelines.bundlesize.yml +++ b/azure-pipelines.bundlesize.yml @@ -1,10 +1,8 @@ pr: - master - - web-components-v3 # Remove before merging to master trigger: - master - - web-components-v3 # Remove before merging to master variables: - ${{ if not(startsWith(variables['Build.SourceBranch'], 'refs/heads/')) }}: diff --git a/azure-pipelines.release.web-components.yml b/azure-pipelines.release.web-components.yml index c3ec1a5becc80..7a41f66b0b2d3 100644 --- a/azure-pipelines.release.web-components.yml +++ b/azure-pipelines.release.web-components.yml @@ -30,7 +30,7 @@ schedules: displayName: 'Daily release (M-F at 5am UTC+1)' branches: include: - - web-components-v3 + - master extends: template: v1/1ES.Official.PipelineTemplate.yml@1esPipelines @@ -75,8 +75,8 @@ extends: displayName: Build, [test], Lint - script: | - yarn beachball publish -b origin/web-components-v3 --access public -y -n $(npmToken) --config scripts/beachball/release-web-components.config.js - git reset --hard origin/web-components-v3 + yarn publish:beachball -n $(npmToken) --config scripts/beachball/release-web-components.config.js + git reset --hard origin/master env: GITHUB_PAT: $(githubPAT) displayName: Publish changes and bump versions diff --git a/azure-pipelines.vrt-pr.yml b/azure-pipelines.vrt-pr.yml index 2aa00ee15dc04..d542831ed1551 100644 --- a/azure-pipelines.vrt-pr.yml +++ b/azure-pipelines.vrt-pr.yml @@ -1,6 +1,5 @@ pr: - master - - web-components-v3 # There's a separate pipeline for CI which also uses this file, but with a trigger override in the UI. # https://dev.azure.com/uifabric/fabricpublic/_apps/hub/ms.vss-ciworkflow.build-ci-hub?_a=edit-build-definition&id=164&view=Tab_Triggers diff --git a/change/@fluentui-web-components-db28c4c9-e1dd-4dd0-a4fe-c7fed393995e.json b/change/@fluentui-web-components-db28c4c9-e1dd-4dd0-a4fe-c7fed393995e.json new file mode 100644 index 0000000000000..c0bb1939edff0 --- /dev/null +++ b/change/@fluentui-web-components-db28c4c9-e1dd-4dd0-a4fe-c7fed393995e.json @@ -0,0 +1,7 @@ +{ + "type": "none", + "comment": "chore: merge wc-3 to master - avoiding any library bumps", + "packageName": "@fluentui/web-components", + "email": "martinhochel@microsoft.com", + "dependentChangeType": "none" +} diff --git a/package.json b/package.json index d9c7d006eb350..5a196b3712e73 100644 --- a/package.json +++ b/package.json @@ -18,8 +18,8 @@ "builddemo": "yarn build --to public-docsite-resources", "buildto": "lage build --verbose --to", "bundle": "lage bundle --verbose", - "change": "beachball change --no-commit -b web-components-v3", - "check:change": "beachball check -b web-components-v3", + "change": "beachball change --no-commit", + "check:change": "beachball check", "check:modified-files": "node -r ./scripts/ts-node/register ./scripts/executors/check-for-modified-files", "check:affected": "node ./scripts/executors/checkIfPackagesAffected.js", "check:installed-dependencies-versions": "satisfied --no-peers --skip-invalid", @@ -369,9 +369,7 @@ "typings" ], "nohoist": [ - "@fluentui/web-components/@storybook/html", - "@fluentui/web-components/@microsoft/api-extractor", - "@fluentui/web-components/@microsoft/api-extractor/**" + "@fluentui/web-components/@storybook/html" ] }, "resolutions": { diff --git a/packages/web-components/package.json b/packages/web-components/package.json index 4dd01bb6c3b80..f296234ce5726 100644 --- a/packages/web-components/package.json +++ b/packages/web-components/package.json @@ -198,11 +198,9 @@ }, "devDependencies": { "@types/web": "^0.0.142", - "@microsoft/api-extractor": "7.31.2", "@storybook/html": "6.5.15", "@tensile-perf/web-components": "~0.1.13", - "rimraf": "^3.0.2", - "typescript": "4.7.4" + "rimraf": "^3.0.2" }, "dependencies": { "@microsoft/fast-element": "2.0.0-beta.26", diff --git a/scripts/beachball/check-wc-3-changefiles.js b/scripts/beachball/check-wc-3-changefiles.js deleted file mode 100644 index 8e1c2c5e75703..0000000000000 --- a/scripts/beachball/check-wc-3-changefiles.js +++ /dev/null @@ -1,74 +0,0 @@ -const fs = require('fs'); -const path = require('path'); - -/** - * @typedef {{ - type: 'none' | 'prerelease' | 'patch' | 'minor' | 'major'; - comment: string; - packageName: string; - email: string; - dependentChangeType: 'none' | 'patch'; -}} ChangeFile - */ - -const isExecutedFromCli = require.main === module; - -if (isExecutedFromCli) { - const changefilesRootPath = path.resolve(__dirname, '../../change'); - main(changefilesRootPath); -} - -/** - * Utility for web-components-v3 development branch to double check we dont accidentally introduce chain of changes, - * which could result in releasing/bumping monorepo packages beside `@fluentui/web-components` ! - * - * ⚠️ TODO: - * - This functionality NEEDS to be REMOVED prior merging to master - * - Usage needs to be removed from .github/workflows/check-packages.yml - */ -function main(/** @type {string} */ root) { - if (!fs.existsSync(root)) { - console.log('✅ Changes folder does not exist, skipping check.'); - return; - } - - const changeFiles = fs.readdirSync(root, 'utf8'); - - const invalidChangeFiles = /** @type string [] */ ( - changeFiles - .map(changeFilePath => { - const filePath = path.join(root, changeFilePath); - /** @type {ChangeFile} */ - const content = JSON.parse(fs.readFileSync(filePath, 'utf-8')); - - if (content.packageName === '@fluentui/web-components') { - return; - } - - if (content.type !== 'none' || content.dependentChangeType !== 'none') { - return changeFilePath; - } - - return; - }) - .filter(Boolean) - ); - - if (invalidChangeFiles.length > 0) { - console.error('================'); - console.error(`You commited changefiles with not allowed type/dependentChangeType!`); - console.error( - `Changefiles that are not for @fluentui/web-components need to have type and dependentChangeType set to "none"`, - ); - console.error(); - console.error('Invalid change files:'); - console.error(invalidChangeFiles.join('\n')); - console.error('================'); - - process.exit(1); - } - - console.log('✅ All changefiles are valid.'); -} - -exports.main = main; diff --git a/scripts/beachball/check-wc-3-changefiles.spec.ts b/scripts/beachball/check-wc-3-changefiles.spec.ts deleted file mode 100644 index cf12108df4f6e..0000000000000 --- a/scripts/beachball/check-wc-3-changefiles.spec.ts +++ /dev/null @@ -1,122 +0,0 @@ -import * as fs from 'fs'; -import * as path from 'path'; - -import tmp from 'tmp'; - -import type { ChangeFile } from './check-wc-3-changefiles'; -import { main } from './check-wc-3-changefiles'; - -tmp.setGracefulCleanup(); - -function setup(changefiles: Array) { - const root = tmp.dirSync({ prefix: 'changefiles', unsafeCleanup: true }).name; - const changesRoot = path.join(root, 'change'); - - fs.mkdirSync(changesRoot); - changefiles.forEach((change, idx) => { - const changeFilePath = path.join(changesRoot, `${change.packageName.replace('/', '-')}-${idx}-abc.json`); - // console.log(`creating: ${changeFilePath}`); - - fs.writeFileSync(changeFilePath, JSON.stringify(change, null, 2), 'utf-8'); - }); - - const consoleErrorSpy = jest.spyOn(console, 'error').mockImplementation(); - const processExitSpy = jest.spyOn(process, 'exit').mockImplementation(); - - return { root: changesRoot, consoleErrorSpy, processExitSpy }; -} - -describe(`Name of the group`, () => { - it(`should pass if only valid changefiles exist`, () => { - const changeFiles: Array = [ - { - type: 'none', - comment: 'change one', - email: 'foo@bar.com', - dependentChangeType: 'none', - packageName: '@fluentui/react-text', - }, - { - type: 'prerelease', - comment: 'change one', - email: 'foo@bar.com', - dependentChangeType: 'patch', - packageName: '@fluentui/web-components', - }, - ]; - const { root, consoleErrorSpy, processExitSpy } = setup(changeFiles); - main(root); - - expect(processExitSpy).not.toHaveBeenCalled(); - expect(consoleErrorSpy).not.toHaveBeenCalled(); - }); - - it(`should pass if changes folder does not exist`, () => { - const { root, consoleErrorSpy, processExitSpy } = setup([]); - main(path.join(root, 'invalid')); - - expect(processExitSpy).not.toHaveBeenCalled(); - expect(consoleErrorSpy).not.toHaveBeenCalled(); - }); - - it(`should pass if changes folder is empty`, () => { - const { root, consoleErrorSpy, processExitSpy } = setup([]); - main(root); - - expect(processExitSpy).not.toHaveBeenCalled(); - expect(consoleErrorSpy).not.toHaveBeenCalled(); - }); - - it(`should fail if there is invalid changefile`, () => { - const changeFiles: Array = [ - { - type: 'patch', - comment: 'change one', - email: 'foo@bar.com', - dependentChangeType: 'patch', - packageName: '@fluentui/react-card', - }, - { - type: 'none', - comment: 'change one', - email: 'foo@bar.com', - dependentChangeType: 'patch', - packageName: '@fluentui/react-image', - }, - { - type: 'patch', - comment: 'change one', - email: 'foo@bar.com', - dependentChangeType: 'none', - packageName: '@fluentui/react-text', - }, - { - type: 'prerelease', - comment: 'change one', - email: 'foo@bar.com', - dependentChangeType: 'patch', - packageName: '@fluentui/web-components', - }, - ]; - const { root, consoleErrorSpy, processExitSpy } = setup(changeFiles); - main(root); - - expect(processExitSpy).toHaveBeenCalledWith(1); - - expect(consoleErrorSpy).toHaveBeenCalled(); - const logs = consoleErrorSpy.mock.calls.flat(); - - expect(logs).toMatchInlineSnapshot(` - Array [ - "================", - "You commited changefiles with not allowed type/dependentChangeType!", - "Changefiles that are not for @fluentui/web-components need to have type and dependentChangeType set to \\"none\\"", - "Invalid change files:", - "@fluentui-react-card-0-abc.json - @fluentui-react-image-1-abc.json - @fluentui-react-text-2-abc.json", - "================", - ] - `); - }); -}); diff --git a/scripts/beachball/release-web-components.config.js b/scripts/beachball/release-web-components.config.js index 201ecbb169e4d..5ecb33e99213b 100644 --- a/scripts/beachball/release-web-components.config.js +++ b/scripts/beachball/release-web-components.config.js @@ -1,6 +1,4 @@ -if (process.env.NODE_ENV !== 'test') { - require('../ts-node-register'); -} +require('./register').register(); const { config: sharedConfig } = require('./shared.config'); const { getConfig } = require('./utils'); diff --git a/scripts/beachball/utils.ts b/scripts/beachball/utils.ts index 1392d616cb76a..3f93e389a7ff6 100644 --- a/scripts/beachball/utils.ts +++ b/scripts/beachball/utils.ts @@ -20,13 +20,6 @@ export function getConfig({ version }: { version: 'vNext' }): { export function getConfig({ version }: { version: 'v8' | 'vNext' | 'web-components' }) { const vNextPackagePaths = getVNextPackagePaths(); - if (version === 'web-components') { - const ignoreVNextScope = vNextPackagePaths.map(path => `!${path}`); - return { - scope: ['packages/web-components', '!apps/*', ...ignoreVNextScope], - }; - } - if (version === 'vNext') { return { scope: [...vNextPackagePaths], @@ -38,9 +31,15 @@ export function getConfig({ version }: { version: 'v8' | 'vNext' | 'web-componen }; } - if (version === 'v8') { - const ignoreVNextScope = vNextPackagePaths.map(pkgPath => `!${pkgPath}`); + const ignoreVNextScope = vNextPackagePaths.map(path => `!${path}`); + if (version === 'web-components') { + return { + scope: ['packages/web-components', '!apps/*', ...ignoreVNextScope], + }; + } + + if (version === 'v8') { return { scope: [...ignoreVNextScope] }; }