-
Notifications
You must be signed in to change notification settings - Fork 235
chore(tooling): adapt publishing workflow for new monorepo structure #5851
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
Changes from 4 commits
6abfbae
89cb380
f9e67bc
fe65f32
33aa554
5722ab6
f4e2ac6
87ff985
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| 20.13.1 | ||
| 20.19.0 | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,8 +18,7 @@ | |
| "scripts": { | ||
| "analyze": "lit-analyzer \"{packages,tools}/*/src/**/!(*.css).ts\"", | ||
| "build": "wireit", | ||
| "prebuild": "wireit", | ||
| "build:clear-cache": "rimraf packages/*/tsconfig.tsbuildinfo && rimraf tools/*/tsconfig.tsbuildinfo", | ||
| "build:clear-cache": "rimraf .wireit && rimraf packages/*/tsconfig.tsbuildinfo && rimraf tools/*/tsconfig.tsbuildinfo", | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cleaning |
||
| "build:confirm": "node ./scripts/confirm-build.js", | ||
| "build:css": "wireit", | ||
| "build:css:watch": "wireit", | ||
|
|
@@ -30,11 +29,10 @@ | |
| "build:types": "wireit", | ||
| "build:watch": "wireit", | ||
| "changelog:global": "node ./scripts/update-global-changelog.js", | ||
| "changeset-publish": "yarn prepublishOnly && yarn changeset version && yarn constraints --fix && yarn install --refresh-lockfile && yarn version:update && yarn changeset publish --no-git-tag && yarn push-to-remote && yarn create-git-tag && yarn postpublish", | ||
| "changeset-snapshot-publish": "yarn prepublishOnly && yarn changeset version --snapshot snapshot && yarn constraints --fix && yarn install --refresh-lockfile && yarn version:update && yarn changeset publish --no-git-tag --tag snapshot", | ||
| "chromatic": "chromatic --build-script-name storybook:build # note that --project-token must be set in your env variables", | ||
| "create-git-tag": "node --no-warnings ./scripts/create-git-tag.js", | ||
| "custom-element-json": "node ./scripts/custom-element-json.js", | ||
| "dev:core": "yarn workspace @spectrum-web-components/core dev", | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not new, just got re-ordered. |
||
| "docs:analyze": "cem analyze --globs \"packages/**/*.ts\" --exclude \"**/*.d.ts\" --exclude \"**/stories/**\" --exclude \"**/icons/**\" --exclude \"**/elements/**\" --outdir projects/documentation --litelement", | ||
| "docs:build": "yarn workspace documentation build", | ||
| "docs:ci": "yarn docs:analyze && run-p docs:production storybook:build && cp projects/documentation/custom-elements.json projects/documentation/dist/storybook", | ||
|
|
@@ -50,20 +48,14 @@ | |
| "new-package": "yarn workspace swc-templates plop", | ||
| "postinstall": "husky || true", | ||
| "postpack": "pinst --enable", | ||
| "postpublish": "yarn prepublish:react && yarn publish:react && yarn postpublish:react", | ||
| "postpublish:react": "git reset --hard HEAD^ && git prune && rimraf react", | ||
| "prebuild": "wireit", | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not new, just got re-ordered. |
||
| "preeleventy": "yarn docs:analyze", | ||
| "prepack": "pinst --disable", | ||
| "prepublish:react": "yarn build:react && sed -i \"\" \"s/react/# react/g\" .gitignore && git commit -am \"Commit React Wrappers\" --no-verify", | ||
| "prepublishOnly": "rimraf react && yarn build && yarn custom-element-json && yarn build:confirm && yarn changelog:global", | ||
| "prestorybook": "wireit", | ||
| "prestorybook:build": "cem analyze --outdir storybook/", | ||
| "pretest:bench": "yarn build:tests && test -f test/benchmark/cli.js ||:", | ||
| "pretest:visual": "yarn build && yarn build", | ||
| "process-icons": "wireit", | ||
| "publish:react": "yarn changeset publish --no-git-tag --tag latest --no-push", | ||
| "push-to-remote": "git add . && git commit -m \"chore: release new versions #publish\" && git push", | ||
| "dev:core": "yarn workspace @spectrum-web-components/core dev", | ||
| "start": "run-p dev:core storybook", | ||
| "storybook": "wireit", | ||
| "storybook:build": "NODE_ENV=production storybook build -o projects/documentation/dist/storybook -c storybook", | ||
|
|
@@ -85,7 +77,6 @@ | |
| "test:watch": "yarn test:watch:focus unit", | ||
| "test:watch:flags:focus": "yarn build && run-p build:watch \"test:start --watch --group {1} --config web-test-runner.config.ci-chromium-flags.js\" --", | ||
| "test:watch:focus": "yarn dev:core & yarn build && run-p build:watch \"test:start --watch --group {1}\" --", | ||
| "version:update": "genversion --verbose --semi --esm ./tools/base/src/version.js", | ||
| "vrt:preview": "yarn wds --config test/visual/wds-vrt.config.js" | ||
| }, | ||
| "workspaces": [ | ||
|
|
@@ -99,7 +90,7 @@ | |
| "@changesets/changelog-github": "0.5.1", | ||
| "@changesets/cli": "2.29.7", | ||
| "@commitlint/cli": "19.8.1", | ||
| "@commitlint/config-conventional": "^19.8.1", | ||
| "@commitlint/config-conventional": "19.8.1", | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pinning versions. |
||
| "@custom-elements-manifest/analyzer": "0.10.6", | ||
| "@geometricpanda/storybook-addon-badges": "2.0.5", | ||
| "@lit/react": "1.0.8", | ||
|
|
@@ -176,7 +167,7 @@ | |
| "jsonc-eslint-parser": "2.4.1", | ||
| "latest-version": "9.0.0", | ||
| "lightningcss": "1.30.1", | ||
| "lint-staged": "^16.1.2", | ||
| "lint-staged": "16.2.6", | ||
| "lit": "^2.5.0 || ^3.1.3", | ||
| "lit-analyzer": "2.0.3", | ||
| "lit-html": "^2.4.0 || ^3.1.3", | ||
|
|
@@ -190,7 +181,7 @@ | |
| "prettier-plugin-package": "1.4.0", | ||
| "pretty-bytes": "7.1.0", | ||
| "re-template-tag": "2.0.1", | ||
| "replace-in-file": "^8.3.0", | ||
| "replace-in-file": "8.3.0", | ||
| "rimraf": "6.0.1", | ||
| "rollup": "4.52.2", | ||
| "sinon": "17.0.2", | ||
|
|
@@ -216,10 +207,6 @@ | |
| "lit-element", | ||
| "lit-html" | ||
| ], | ||
| "engines": { | ||
| "node": ">=20", | ||
| "yarn": ">=4.6.0" | ||
| }, | ||
|
Comment on lines
-219
to
-222
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Any reason to remove this? |
||
| "wireit": { | ||
| "build": { | ||
| "dependencies": [ | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -774,6 +774,9 @@ custom.args = { | |
| open: true, | ||
| }; | ||
| custom.decorators = [isOverlayOpen]; | ||
| custom.swc_vrt = { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Skipping a known flaky test |
||
| skip: true, | ||
| }; | ||
|
|
||
| export const BackgroundClickTest = (): TemplateResult => { | ||
| return html` | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -240,7 +240,7 @@ export default async () => { | |
| replacement: '../../packages/', | ||
| }, | ||
| { | ||
| find: /^@swc\/core\/(.*)$/, | ||
| find: /^@spectrum-web-components\/core\/(.*)$/, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix regex from old |
||
| replacement: path.resolve( | ||
| '../../../2nd-gen/packages/core/dist/$1' | ||
| ), | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,10 +14,15 @@ | |
|
|
||
| import fs from 'fs'; | ||
| import path from 'path'; | ||
| import { fileURLToPath } from 'url'; | ||
| import { dirname } from 'path'; | ||
|
|
||
| import glob from 'fast-glob'; | ||
| import 'colors'; | ||
|
|
||
| const __dirname = dirname(fileURLToPath(import.meta.url)); | ||
| const rootDir = path.join(__dirname, '..'); | ||
|
|
||
| async function verifyCustomElementsJson() { | ||
| // Components that don't need their own custom-elements.json manifest | ||
| const customElementsIgnoreList = new Set([ | ||
|
|
@@ -27,13 +32,20 @@ async function verifyCustomElementsJson() { | |
| 'packages/close-button', | ||
| ]); | ||
|
|
||
| const packages = glob.sync('packages/*/', { onlyDirectories: true }); | ||
| const packages = glob.sync('packages/*/', { | ||
| onlyDirectories: true, | ||
| cwd: rootDir, | ||
| }); | ||
| const checks = packages.map(async (pkg) => { | ||
| const pkgPath = pkg.replace(/\/$/, ''); | ||
| if (customElementsIgnoreList.has(pkgPath)) { | ||
| return; | ||
| } | ||
| const customElementsPath = path.join(pkg, 'custom-elements.json'); | ||
| const customElementsPath = path.join( | ||
| rootDir, | ||
| pkg, | ||
| 'custom-elements.json' | ||
| ); | ||
| if (!fs.existsSync(customElementsPath)) { | ||
| throw new Error(`Missing custom-elements.json in ${pkg}`); | ||
| } | ||
|
|
@@ -42,38 +54,47 @@ async function verifyCustomElementsJson() { | |
| return Promise.all(checks); | ||
| } | ||
|
|
||
| function verifyVersionJs() { | ||
| function verifyVersionTs() { | ||
|
||
| let basePackageJson; | ||
| try { | ||
| basePackageJson = JSON.parse( | ||
| fs.readFileSync('tools/base/package.json', 'utf8') | ||
| fs.readFileSync( | ||
| path.join(rootDir, 'tools/base/package.json'), | ||
| 'utf8' | ||
| ) | ||
| ); | ||
| } catch (error) { | ||
| throw new Error('Failed to read tools/base/package.json'); | ||
| } | ||
| const versionJsPath = 'tools/base/src/version.js'; | ||
| const versionTsPath = path.join( | ||
| rootDir, | ||
| '../2nd-gen/packages/core/shared/base/version.ts' | ||
| ); | ||
|
|
||
| if (!fs.existsSync(versionJsPath)) { | ||
| throw new Error('version.js file is missing'); | ||
| if (!fs.existsSync(versionTsPath)) { | ||
| throw new Error('2nd-gen version.ts file is missing'); | ||
| } | ||
|
|
||
| const versionContent = fs.readFileSync(versionJsPath, 'utf8'); | ||
| const versionContent = fs.readFileSync(versionTsPath, 'utf8'); | ||
| const versionMatch = versionContent.match(/version = ['"]([^'"]+)['"]/); | ||
|
|
||
| if (!versionMatch) { | ||
| throw new Error('Could not find version in version.js'); | ||
| throw new Error('Could not find version in 2nd-gen version.ts'); | ||
| } | ||
|
|
||
| const versionJs = versionMatch[1]; | ||
| if (versionJs !== basePackageJson.version) { | ||
| const versionTs = versionMatch[1]; | ||
| if (versionTs !== basePackageJson.version) { | ||
| throw new Error( | ||
| `Version mismatch: version.js (${versionJs}) does not match tools/base/package.json (${basePackageJson.version})` | ||
| `Version mismatch: 2nd-gen version.ts (${versionTs}) does not match 1st-gen tools/base/package.json (${basePackageJson.version})` | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| async function verifyBuildArtifacts() { | ||
| const packages = glob.sync('packages/*/', { onlyDirectories: true }); | ||
| const packages = glob.sync('packages/*/', { | ||
| onlyDirectories: true, | ||
| cwd: rootDir, | ||
| }); | ||
| const requiredFilesIgnoreList = new Set([ | ||
| 'packages/clear-button', // extends button | ||
| 'packages/close-button', // extends button | ||
|
|
@@ -97,7 +118,7 @@ async function verifyBuildArtifacts() { | |
| const checks = packages.map(async (pkg) => { | ||
| const pkgPath = pkg.replace(/\/$/, ''); | ||
|
|
||
| const srcPath = path.join(pkg, 'src'); | ||
| const srcPath = path.join(rootDir, pkg, 'src'); | ||
| if (!fs.existsSync(srcPath)) { | ||
| throw new Error(`Missing src directory in ${pkg}`); | ||
| } | ||
|
|
@@ -114,7 +135,7 @@ async function verifyBuildArtifacts() { | |
|
|
||
| // Verify all required files exist for this package | ||
| for (const [filePattern, description] of requiredFiles) { | ||
| const pattern = path.join(pkg, filePattern); | ||
| const pattern = path.join(rootDir, pkg, filePattern); | ||
| const files = glob.sync(pattern); | ||
| if (files.length === 0) { | ||
| throw new Error( | ||
|
|
@@ -131,8 +152,8 @@ async function main() { | |
| console.log('Verifying custom-elements.json files...'.cyan); | ||
| await verifyCustomElementsJson(); | ||
|
|
||
| console.log('Verifying version.js...'.cyan); | ||
| verifyVersionJs(); | ||
| console.log('Verifying 2nd-gen version.ts synced with 1st-gen...'.cyan); | ||
| verifyVersionTs(); | ||
|
|
||
| console.log('Verifying build artifacts...'.cyan); | ||
| await verifyBuildArtifacts(); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,7 +21,7 @@ | |
| * into organized changelog entries. | ||
| */ | ||
|
|
||
| import { version as currentVersion } from '@spectrum-web-components/base/src/version.js'; | ||
| import { version as currentVersion } from '@spectrum-web-components/core/shared/base/version.js'; | ||
|
||
| import { execSync } from 'child_process'; | ||
| import fs from 'fs'; | ||
| import { promises as fsPromises } from 'fs'; | ||
|
|
@@ -143,7 +143,7 @@ async function processChangesets() { | |
| const coreChanges = extractChanges( | ||
| frontmatter, | ||
| cleanDescription, | ||
| /['"]@swc\/core['"]:\s*(major|minor|patch)/g | ||
| /['"]@spectrum-web-components\/core['"]:\s*(major|minor|patch)/g | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix regex from old @swc-core -> @spectrum-web-components/core |
||
| ); | ||
|
|
||
| // Merge results into categorized buckets | ||
|
|
@@ -299,8 +299,8 @@ function updateChangelogFile( | |
| * Reads changeset files, categorizes changes by type (major/minor/patch), | ||
| * and updates both the 1st-gen and @spectrum-web-components/core changelogs accordingly. | ||
| * | ||
| * Should be run during the release process after prepublishOnly but before | ||
| * changeset version. Automatically called by `yarn changeset-publish`. | ||
| * Should be run during the release process before changeset version. | ||
| * Automatically called by the unified publish script for regular releases. | ||
| * | ||
| * @returns {Promise<void>} | ||
| * @throws {Error} If there's an issue with git tags or file operations | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,7 +27,7 @@ export default { | |
| alias({ | ||
| entries: [ | ||
| { | ||
| find: /^@swc\/core\/(.*)$/, | ||
| find: /^@spectrum-web-components\/core\/(.*)$/, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix regex from old @swc-core -> @spectrum-web-components/core |
||
| replacement: path.resolve( | ||
| process.cwd(), | ||
| '../2nd-gen/packages/core/dist/$1' | ||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This needs to stay!! |
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,7 +11,7 @@ | |
| */ | ||
| import { SpectrumElement } from '@spectrum-web-components/base'; | ||
| import { elementUpdated, expect, fixture, html } from '@open-wc/testing'; | ||
| import { version } from '@spectrum-web-components/base/src/version.js'; | ||
| import { version } from '@spectrum-web-components/core/shared/base/version.js'; | ||
|
||
|
|
||
| class DirElement extends SpectrumElement {} | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -290,6 +290,7 @@ | |
| ], | ||
| "dependencies": { | ||
| "@spectrum-web-components/base": "1.9.0", | ||
| "@spectrum-web-components/core": "0.0.1", | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Theme now depends on import { version } from '@spectrum-web-components/core/shared/base/version.js'; |
||
| "@spectrum-web-components/styles": "1.9.0" | ||
| }, | ||
| "types": "./src/index.d.ts", | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -58,7 +58,7 @@ export default { | |
| alias({ | ||
| entries: [ | ||
| { | ||
| find: /^@swc\/core\/(.*)$/, | ||
| find: /^@spectrum-web-components\/core\/(.*)$/, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix regex |
||
| replacement: path.resolve( | ||
| __dirname, | ||
| '../2nd-gen/packages/core/dist/$1' | ||
|
|
||
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.
Bumping minimum version for Storybook 10 compatibility.