Skip to content

Commit 3ff495e

Browse files
chore(tooling): adapt publishing workflow for new monorepo structure (#5851)
* chore: update and streamline publishing workflow for new monorepo structure Refactors the publishing and release management workflow to support the dual-generation monorepo architecture: - Update Changesets configuration to recognize both 1st-gen and 2nd-gen workspaces, enabling independent versioning strategies - Refactor release scripts to delegate to generation-specific publishing workflows rather than operating on a flat package structure - Update CI/CD publishing jobs to build, test, and publish both generations with appropriate dependency handling for the shared Core library - Preserve existing 1st-gen package publishing behavior to avoid disruption to current consumers This workflow enables continuous delivery of improvements to 1st-gen customers while supporting independent 2nd-gen package releases.
1 parent 22de59a commit 3ff495e

File tree

25 files changed

+407
-301
lines changed

25 files changed

+407
-301
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ parameters:
2222
# 3. Commit this change to the PR branch where the changes exist.
2323
current_golden_images_hash:
2424
type: string
25-
default: fe5761e6acafee627d7782f8f8856ca05a69260c
25+
default: 89cb380330cef18d34c0d4cf893790d9c7167b08
2626
wireit_cache_name:
2727
type: string
2828
default: wireit

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20.13.1
1+
20.19.0

1st-gen/package.json

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@
1818
"scripts": {
1919
"analyze": "lit-analyzer \"{packages,tools}/*/src/**/!(*.css).ts\"",
2020
"build": "wireit",
21-
"prebuild": "wireit",
22-
"build:clear-cache": "rimraf packages/*/tsconfig.tsbuildinfo && rimraf tools/*/tsconfig.tsbuildinfo",
21+
"build:clear-cache": "rimraf .wireit && rimraf packages/*/tsconfig.tsbuildinfo && rimraf tools/*/tsconfig.tsbuildinfo",
2322
"build:confirm": "node ./scripts/confirm-build.js",
2423
"build:css": "wireit",
2524
"build:css:watch": "wireit",
@@ -30,11 +29,10 @@
3029
"build:types": "wireit",
3130
"build:watch": "wireit",
3231
"changelog:global": "node ./scripts/update-global-changelog.js",
33-
"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",
34-
"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",
3532
"chromatic": "chromatic --build-script-name storybook:build # note that --project-token must be set in your env variables",
3633
"create-git-tag": "node --no-warnings ./scripts/create-git-tag.js",
3734
"custom-element-json": "node ./scripts/custom-element-json.js",
35+
"dev:core": "yarn workspace @spectrum-web-components/core dev",
3836
"docs:analyze": "cem analyze --globs \"packages/**/*.ts\" --exclude \"**/*.d.ts\" --exclude \"**/stories/**\" --exclude \"**/icons/**\" --exclude \"**/elements/**\" --outdir projects/documentation --litelement",
3937
"docs:build": "yarn workspace documentation build",
4038
"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 @@
5048
"new-package": "yarn workspace swc-templates plop",
5149
"postinstall": "husky || true",
5250
"postpack": "pinst --enable",
53-
"postpublish": "yarn prepublish:react && yarn publish:react && yarn postpublish:react",
54-
"postpublish:react": "git reset --hard HEAD^ && git prune && rimraf react",
51+
"prebuild": "wireit",
5552
"preeleventy": "yarn docs:analyze",
5653
"prepack": "pinst --disable",
57-
"prepublish:react": "yarn build:react && sed -i \"\" \"s/react/# react/g\" .gitignore && git commit -am \"Commit React Wrappers\" --no-verify",
58-
"prepublishOnly": "rimraf react && yarn build && yarn custom-element-json && yarn build:confirm && yarn changelog:global",
5954
"prestorybook": "wireit",
6055
"prestorybook:build": "cem analyze --outdir storybook/",
6156
"pretest:bench": "yarn build:tests && test -f test/benchmark/cli.js ||:",
6257
"pretest:visual": "yarn build && yarn build",
6358
"process-icons": "wireit",
64-
"publish:react": "yarn changeset publish --no-git-tag --tag latest --no-push",
65-
"push-to-remote": "git add . && git commit -m \"chore: release new versions #publish\" && git push",
66-
"dev:core": "yarn workspace @spectrum-web-components/core dev",
6759
"start": "run-p dev:core storybook",
6860
"storybook": "wireit",
6961
"storybook:build": "NODE_ENV=production storybook build -o projects/documentation/dist/storybook -c storybook",
@@ -85,7 +77,6 @@
8577
"test:watch": "yarn test:watch:focus unit",
8678
"test:watch:flags:focus": "yarn build && run-p build:watch \"test:start --watch --group {1} --config web-test-runner.config.ci-chromium-flags.js\" --",
8779
"test:watch:focus": "yarn dev:core & yarn build && run-p build:watch \"test:start --watch --group {1}\" --",
88-
"version:update": "genversion --verbose --semi --esm ./tools/base/src/version.js",
8980
"vrt:preview": "yarn wds --config test/visual/wds-vrt.config.js"
9081
},
9182
"workspaces": [
@@ -99,7 +90,7 @@
9990
"@changesets/changelog-github": "0.5.1",
10091
"@changesets/cli": "2.29.7",
10192
"@commitlint/cli": "19.8.1",
102-
"@commitlint/config-conventional": "^19.8.1",
93+
"@commitlint/config-conventional": "19.8.1",
10394
"@custom-elements-manifest/analyzer": "0.10.6",
10495
"@geometricpanda/storybook-addon-badges": "2.0.5",
10596
"@lit/react": "1.0.8",
@@ -176,7 +167,7 @@
176167
"jsonc-eslint-parser": "2.4.1",
177168
"latest-version": "9.0.0",
178169
"lightningcss": "1.30.1",
179-
"lint-staged": "^16.1.2",
170+
"lint-staged": "16.2.6",
180171
"lit": "^2.5.0 || ^3.1.3",
181172
"lit-analyzer": "2.0.3",
182173
"lit-html": "^2.4.0 || ^3.1.3",
@@ -190,7 +181,7 @@
190181
"prettier-plugin-package": "1.4.0",
191182
"pretty-bytes": "7.1.0",
192183
"re-template-tag": "2.0.1",
193-
"replace-in-file": "^8.3.0",
184+
"replace-in-file": "8.3.0",
194185
"rimraf": "6.0.1",
195186
"rollup": "4.52.2",
196187
"sinon": "17.0.2",
@@ -216,10 +207,6 @@
216207
"lit-element",
217208
"lit-html"
218209
],
219-
"engines": {
220-
"node": ">=20",
221-
"yarn": ">=4.6.0"
222-
},
223210
"wireit": {
224211
"build": {
225212
"dependencies": [

1st-gen/packages/picker/stories/picker.stories.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -774,6 +774,9 @@ custom.args = {
774774
open: true,
775775
};
776776
custom.decorators = [isOverlayOpen];
777+
custom.swc_vrt = {
778+
skip: true,
779+
};
777780

778781
export const BackgroundClickTest = (): TemplateResult => {
779782
return html`

1st-gen/projects/css-custom-vars-viewer/package.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,6 @@
1313
"./sp-css-table.js": "./dist/src/sp-css-table.js",
1414
"./custom-vars-viewer.js": "./dist/src/custom-vars-viewer.js"
1515
},
16-
"engines": {
17-
"node": ">=16.14.2",
18-
"yarn": ">=1.16.0"
19-
},
2016
"scripts": {
2117
"analyze": "cem analyze --litelement",
2218
"build": "yarn parse-json && tsc && npm run analyze -- --exclude dist",

1st-gen/projects/documentation/rollup.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ export default async () => {
240240
replacement: '../../packages/',
241241
},
242242
{
243-
find: /^@swc\/core\/(.*)$/,
243+
find: /^@spectrum-web-components\/core\/(.*)$/,
244244
replacement: path.resolve(
245245
'../../../2nd-gen/packages/core/dist/$1'
246246
),

1st-gen/scripts/cem-tools.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,16 @@ export function getWorkspacePackages(
7575
.filter(
7676
(pkg) =>
7777
!ignoredPackages.includes(pkg.name) &&
78-
pkg.name !== '@spectrum-web-components/1st-gen'
78+
pkg.name !== '@spectrum-web-components/1st-gen' &&
79+
pkg.name !== '@spectrum-web-components/2nd-gen' &&
80+
// Only include packages in 1st-gen packages/ and tools/ directories
81+
(pkg.location.startsWith('1st-gen/packages/') ||
82+
pkg.location.startsWith('1st-gen/tools/'))
7983
)
8084
.map((pkg) => ({
8185
name: pkg.name,
82-
path: pkg.location,
86+
// Remove '1st-gen/' prefix since rootDir is already set to 1st-gen
87+
path: pkg.location.replace(/^1st-gen\//, ''),
8388
}));
8489
}
8590

@@ -112,14 +117,15 @@ export async function customElementJson(
112117
})
113118
.then(async () => {
114119
const outdir = options.outdir ?? pkg.path;
120+
const packageName = pkg.name || pkg.path || 'unknown';
115121
// Check if the custom-elements.json file exists
116122
if (fs.existsSync(path.join(outdir, 'custom-elements.json'))) {
117123
console.log(
118-
`${'✓'.green} ${pkg.name.cyan} has a custom-elements.json file`
124+
`${'✓'.green} ${packageName.cyan} has a custom-elements.json file`
119125
);
120126
} else {
121127
console.log(
122-
`${'❌'.red} ${pkg.name.cyan} does not have a custom-elements.json file`
128+
`${'❌'.red} ${packageName.cyan} does not have a custom-elements.json file`
123129
);
124130
}
125131
})

1st-gen/scripts/confirm-build.js

Lines changed: 30 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,15 @@
1414

1515
import fs from 'fs';
1616
import path from 'path';
17+
import { fileURLToPath } from 'url';
18+
import { dirname } from 'path';
1719

1820
import glob from 'fast-glob';
1921
import 'colors';
22+
import { version } from '@spectrum-web-components/base/src/version.js';
23+
24+
const __dirname = dirname(fileURLToPath(import.meta.url));
25+
const rootDir = path.join(__dirname, '..');
2026

2127
async function verifyCustomElementsJson() {
2228
// Components that don't need their own custom-elements.json manifest
@@ -27,13 +33,20 @@ async function verifyCustomElementsJson() {
2733
'packages/close-button',
2834
]);
2935

30-
const packages = glob.sync('packages/*/', { onlyDirectories: true });
36+
const packages = glob.sync('packages/*/', {
37+
onlyDirectories: true,
38+
cwd: rootDir,
39+
});
3140
const checks = packages.map(async (pkg) => {
3241
const pkgPath = pkg.replace(/\/$/, '');
3342
if (customElementsIgnoreList.has(pkgPath)) {
3443
return;
3544
}
36-
const customElementsPath = path.join(pkg, 'custom-elements.json');
45+
const customElementsPath = path.join(
46+
rootDir,
47+
pkg,
48+
'custom-elements.json'
49+
);
3750
if (!fs.existsSync(customElementsPath)) {
3851
throw new Error(`Missing custom-elements.json in ${pkg}`);
3952
}
@@ -42,38 +55,31 @@ async function verifyCustomElementsJson() {
4255
return Promise.all(checks);
4356
}
4457

45-
function verifyVersionJs() {
58+
function verifyVersionSync() {
4659
let basePackageJson;
4760
try {
4861
basePackageJson = JSON.parse(
49-
fs.readFileSync('tools/base/package.json', 'utf8')
62+
fs.readFileSync(
63+
path.join(rootDir, 'tools/base/package.json'),
64+
'utf8'
65+
)
5066
);
5167
} catch (error) {
5268
throw new Error('Failed to read tools/base/package.json');
5369
}
54-
const versionJsPath = 'tools/base/src/version.js';
55-
56-
if (!fs.existsSync(versionJsPath)) {
57-
throw new Error('version.js file is missing');
58-
}
5970

60-
const versionContent = fs.readFileSync(versionJsPath, 'utf8');
61-
const versionMatch = versionContent.match(/version = ['"]([^'"]+)['"]/);
62-
63-
if (!versionMatch) {
64-
throw new Error('Could not find version in version.js');
65-
}
66-
67-
const versionJs = versionMatch[1];
68-
if (versionJs !== basePackageJson.version) {
71+
if (version !== basePackageJson.version) {
6972
throw new Error(
70-
`Version mismatch: version.js (${versionJs}) does not match tools/base/package.json (${basePackageJson.version})`
73+
`Version mismatch: version.js (${version}) does not match tools/base/package.json (${basePackageJson.version})`
7174
);
7275
}
7376
}
7477

7578
async function verifyBuildArtifacts() {
76-
const packages = glob.sync('packages/*/', { onlyDirectories: true });
79+
const packages = glob.sync('packages/*/', {
80+
onlyDirectories: true,
81+
cwd: rootDir,
82+
});
7783
const requiredFilesIgnoreList = new Set([
7884
'packages/clear-button', // extends button
7985
'packages/close-button', // extends button
@@ -97,7 +103,7 @@ async function verifyBuildArtifacts() {
97103
const checks = packages.map(async (pkg) => {
98104
const pkgPath = pkg.replace(/\/$/, '');
99105

100-
const srcPath = path.join(pkg, 'src');
106+
const srcPath = path.join(rootDir, pkg, 'src');
101107
if (!fs.existsSync(srcPath)) {
102108
throw new Error(`Missing src directory in ${pkg}`);
103109
}
@@ -114,7 +120,7 @@ async function verifyBuildArtifacts() {
114120

115121
// Verify all required files exist for this package
116122
for (const [filePattern, description] of requiredFiles) {
117-
const pattern = path.join(pkg, filePattern);
123+
const pattern = path.join(rootDir, pkg, filePattern);
118124
const files = glob.sync(pattern);
119125
if (files.length === 0) {
120126
throw new Error(
@@ -131,8 +137,8 @@ async function main() {
131137
console.log('Verifying custom-elements.json files...'.cyan);
132138
await verifyCustomElementsJson();
133139

134-
console.log('Verifying version.js...'.cyan);
135-
verifyVersionJs();
140+
console.log('Verifying version synchronization...'.cyan);
141+
verifyVersionSync();
136142

137143
console.log('Verifying build artifacts...'.cyan);
138144
await verifyBuildArtifacts();

1st-gen/scripts/update-global-changelog.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ async function processChangesets() {
143143
const coreChanges = extractChanges(
144144
frontmatter,
145145
cleanDescription,
146-
/['"]@swc\/core['"]:\s*(major|minor|patch)/g
146+
/['"]@spectrum-web-components\/core['"]:\s*(major|minor|patch)/g
147147
);
148148

149149
// Merge results into categorized buckets
@@ -299,8 +299,8 @@ function updateChangelogFile(
299299
* Reads changeset files, categorizes changes by type (major/minor/patch),
300300
* and updates both the 1st-gen and @spectrum-web-components/core changelogs accordingly.
301301
*
302-
* Should be run during the release process after prepublishOnly but before
303-
* changeset version. Automatically called by `yarn changeset-publish`.
302+
* Should be run during the release process before changeset version.
303+
* Automatically called by the unified publish script for regular releases.
304304
*
305305
* @returns {Promise<void>}
306306
* @throws {Error} If there's an issue with git tags or file operations

1st-gen/test/visual/rollup.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export default {
2727
alias({
2828
entries: [
2929
{
30-
find: /^@swc\/core\/(.*)$/,
30+
find: /^@spectrum-web-components\/core\/(.*)$/,
3131
replacement: path.resolve(
3232
process.cwd(),
3333
'../2nd-gen/packages/core/dist/$1'

0 commit comments

Comments
 (0)