From d3312dba56373857ddd55ddffa245601f140bfa6 Mon Sep 17 00:00:00 2001 From: dougfabris Date: Fri, 15 Sep 2023 14:48:14 -0300 Subject: [PATCH 1/3] chore: change script --- .github/workflows/cd.yml | 10 +++-- package.json | 3 +- tools/scripts/src/resolve-workspace-deps.ts | 43 +++++++++++++-------- yarn.lock | 38 +++++++++--------- 4 files changed, 53 insertions(+), 41 deletions(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index b3b8b91f23..125cb33b0c 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -88,14 +88,18 @@ jobs: - run: yarn install if: steps.yarn-cache.outputs.cache-hit != 'true' - - uses: changesets/action@v1 - with: - publish: yarn release + - name: Create Release Pull Request or Publish to npm + id: changesets + uses: changesets/action@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} NPM_TOKEN: ${{ secrets.NPM_TOKEN }} NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + if: steps.changesets.outputs.hasChangesets == 'false' + run: yarn resolve-workspace-deps + - run: yarn publish + publish-to-gh-pages: name: Publish to GitHub Pages runs-on: ubuntu-latest diff --git a/package.json b/package.json index 6ab7080dad..4dfbc20123 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,6 @@ { - "name": "@rocket.chat/fuselage-root", + "name": "@rocket.chat/fuselage-monorepo", "private": true, - "version": "0.31.25", "workspaces": [ "packages/*", "tools/*" diff --git a/tools/scripts/src/resolve-workspace-deps.ts b/tools/scripts/src/resolve-workspace-deps.ts index 923b0e47fb..0d38201ca4 100644 --- a/tools/scripts/src/resolve-workspace-deps.ts +++ b/tools/scripts/src/resolve-workspace-deps.ts @@ -1,4 +1,3 @@ -// eslint-disable-next-line import/no-unresolved import { readFile, writeFile } from 'fs/promises'; import { join } from 'path'; @@ -11,6 +10,7 @@ type PackageList = { }; type PackageManifest = { + name: string; version?: string; dependencies?: PackageList; devDependencies?: PackageList; @@ -19,7 +19,7 @@ type PackageManifest = { const patchPackageList = ( packageList: PackageList | undefined, - version: string + packagesRefObj: Map ) => { if (!packageList) { return; @@ -30,22 +30,24 @@ const patchPackageList = ( continue; } - packageList[packageName] = `^${version}`; + packageList[packageName] = `^${packagesRefObj.get(packageName)}`; } }; +const getPackageManifest = async (packageManifestsPath: string) => + JSON.parse( + await readFile(packageManifestsPath, { encoding: 'utf-8' }) + ) as PackageManifest; + const patchPackageManifest = async ( packageManifestsPath: string, - version: string + packagesRefObj: Map ) => { - const packageManifest = JSON.parse( - await readFile(packageManifestsPath, { encoding: 'utf-8' }) - ) as PackageManifest; + const packageManifest = await getPackageManifest(packageManifestsPath); - packageManifest.version = version; - patchPackageList(packageManifest.dependencies, version); - patchPackageList(packageManifest.devDependencies, version); - patchPackageList(packageManifest.peerDependencies, version); + patchPackageList(packageManifest.dependencies, packagesRefObj); + patchPackageList(packageManifest.devDependencies, packagesRefObj); + patchPackageList(packageManifest.peerDependencies, packagesRefObj); await writeFile( packageManifestsPath, @@ -57,10 +59,6 @@ const patchPackageManifest = async ( }; const start = async () => { - const { version } = JSON.parse( - await readFile(join(rootDir, 'lerna.json'), { encoding: 'utf-8' }) - ) as { version: string }; - const packageManifestsPaths = await fg( ['**/package.json', '!**/node_modules/**/package.json', '!./package.json'], { @@ -68,8 +66,19 @@ const start = async () => { } ); - for (const packageManifestsPath of packageManifestsPaths) { - patchPackageManifest(join(rootDir, packageManifestsPath), version); + const packagesRefObj = new Map( + await Promise.all( + packageManifestsPaths.map(async (packageManifestsPath) => { + const packageManifest = await getPackageManifest( + join(rootDir, packageManifestsPath) + ); + return [packageManifest.name, packageManifest.version] as const; + }) + ) + ); + + for await (const packageManifestsPath of packageManifestsPaths) { + patchPackageManifest(join(rootDir, packageManifestsPath), packagesRefObj); } }; diff --git a/yarn.lock b/yarn.lock index 7d004eedfc..3dbf43dbe1 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6420,6 +6420,23 @@ __metadata: languageName: unknown linkType: soft +"@rocket.chat/fuselage-monorepo@workspace:.": + version: 0.0.0-use.local + resolution: "@rocket.chat/fuselage-monorepo@workspace:." + dependencies: + "@changesets/changelog-github": ~0.4.8 + "@changesets/cli": ~2.26.2 + bump: "workspace:~" + husky: ~7.0.4 + hygen: ~6.1.5 + lerna: ~4.0.0 + lint-staged: ~13.2.1 + turbo: ~1.1.10 + update-readme: "workspace:~" + webpack: ~5.78.0 + languageName: unknown + linkType: soft + "@rocket.chat/fuselage-polyfills@workspace:packages/fuselage-polyfills, @rocket.chat/fuselage-polyfills@workspace:~": version: 0.0.0-use.local resolution: "@rocket.chat/fuselage-polyfills@workspace:packages/fuselage-polyfills" @@ -6440,23 +6457,6 @@ __metadata: languageName: unknown linkType: soft -"@rocket.chat/fuselage-root@workspace:.": - version: 0.0.0-use.local - resolution: "@rocket.chat/fuselage-root@workspace:." - dependencies: - "@changesets/changelog-github": ~0.4.8 - "@changesets/cli": ~2.26.2 - bump: "workspace:~" - husky: ~7.0.4 - hygen: ~6.1.5 - lerna: ~4.0.0 - lint-staged: ~13.2.1 - turbo: ~1.1.10 - update-readme: "workspace:~" - webpack: ~5.78.0 - languageName: unknown - linkType: soft - "@rocket.chat/fuselage-toastbar@workspace:packages/fuselage-toastbar": version: 0.0.0-use.local resolution: "@rocket.chat/fuselage-toastbar@workspace:packages/fuselage-toastbar" @@ -8482,9 +8482,9 @@ __metadata: languageName: node linkType: hard -"@storybook/react-docgen-typescript-plugin@patch:@storybook/react-docgen-typescript-plugin@npm%3A1.0.2-canary.6.9d540b91e815f8fc2f8829189deb00553559ff63.0#./.yarn/patches/@storybook-react-docgen-typescript-plugin-npm-1.0.2-canary.6.9d540b91e815f8fc2f8829189deb00553559ff63.0-b31cc57c40.patch::locator=%40rocket.chat%2Ffuselage-root%40workspace%3A.": +"@storybook/react-docgen-typescript-plugin@patch:@storybook/react-docgen-typescript-plugin@npm%3A1.0.2-canary.6.9d540b91e815f8fc2f8829189deb00553559ff63.0#./.yarn/patches/@storybook-react-docgen-typescript-plugin-npm-1.0.2-canary.6.9d540b91e815f8fc2f8829189deb00553559ff63.0-b31cc57c40.patch::locator=%40rocket.chat%2Ffuselage-monorepo%40workspace%3A.": version: 1.0.2-canary.6.9d540b91e815f8fc2f8829189deb00553559ff63.0 - resolution: "@storybook/react-docgen-typescript-plugin@patch:@storybook/react-docgen-typescript-plugin@npm%3A1.0.2-canary.6.9d540b91e815f8fc2f8829189deb00553559ff63.0#./.yarn/patches/@storybook-react-docgen-typescript-plugin-npm-1.0.2-canary.6.9d540b91e815f8fc2f8829189deb00553559ff63.0-b31cc57c40.patch::version=1.0.2-canary.6.9d540b91e815f8fc2f8829189deb00553559ff63.0&hash=0878d5&locator=%40rocket.chat%2Ffuselage-root%40workspace%3A." + resolution: "@storybook/react-docgen-typescript-plugin@patch:@storybook/react-docgen-typescript-plugin@npm%3A1.0.2-canary.6.9d540b91e815f8fc2f8829189deb00553559ff63.0#./.yarn/patches/@storybook-react-docgen-typescript-plugin-npm-1.0.2-canary.6.9d540b91e815f8fc2f8829189deb00553559ff63.0-b31cc57c40.patch::version=1.0.2-canary.6.9d540b91e815f8fc2f8829189deb00553559ff63.0&hash=0878d5&locator=%40rocket.chat%2Ffuselage-monorepo%40workspace%3A." dependencies: debug: ^4.1.1 endent: ^2.0.1 From e577267b298374f45908fe72086b5148e9ed9719 Mon Sep 17 00:00:00 2001 From: dougfabris Date: Fri, 15 Sep 2023 14:56:54 -0300 Subject: [PATCH 2/3] chore: changeset --- .changeset/giant-parrots-serve.md | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 .changeset/giant-parrots-serve.md diff --git a/.changeset/giant-parrots-serve.md b/.changeset/giant-parrots-serve.md new file mode 100644 index 0000000000..07b20f5ac0 --- /dev/null +++ b/.changeset/giant-parrots-serve.md @@ -0,0 +1,9 @@ +--- +"@rocket.chat/fuselage": patch +"@rocket.chat/fuselage-hooks": patch +"@rocket.chat/logo": patch +"@rocket.chat/onboarding-ui": patch +"@rocket.chat/ui-kit": patch +--- + +chore: resolve-workspace-deps to publish pkg versions From 7371ddff7b14bb95a3cf754f8766d90f145c9b45 Mon Sep 17 00:00:00 2001 From: dougfabris Date: Fri, 15 Sep 2023 15:17:08 -0300 Subject: [PATCH 3/3] chore: concurrency --- .github/workflows/cd.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 125cb33b0c..a99853145b 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -5,6 +5,8 @@ on: branches: - main +concurrency: ${{ github.workflow }}-${{ github.ref }} + jobs: build-and-test: name: Build and Test