Skip to content
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

chore: add changesets remove lerna #4294

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions .changeset/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Changesets

Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
with multi-package repos, or single-package repos to help you version and publish your code. You can
find the full documentation for it [in our repository](https://github.com/changesets/changesets)

We have a quick list of common questions to get you started engaging with this project in
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)
16 changes: 16 additions & 0 deletions .changeset/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"$schema": "https://unpkg.com/@changesets/config@3.0.0/schema.json",
"changelog": [
"@changesets/changelog-github",
{
"repo": "adobe/spectrum-web-components"
}
],
"commit": false,
"fixed": [["@spectrum-web-components/*"]],
"linked": [],
blunteshwar marked this conversation as resolved.
Show resolved Hide resolved
"access": "public",
"baseBranch": "main",
"updateInternalDependencies": "patch",
"ignore": []
}
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# logging / private config
lerna-debug.log
yarn-error.log
.DS_STORE
.DS_Store
Expand Down
2 changes: 2 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ type(scope?): subject #scope is optional, but should reference the package you a

We maintain a specific standard of commit messages while committing to the respository. See [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/#summary)

To ensure that we release your changes properly, [add a changeset](https://github.com/changesets/changesets/blob/main/docs/adding-a-changeset.md) to your branch, [following the steps outlined in the "multi-package repository" section of the Changesets docs](https://github.com/changesets/changesets/blob/main/docs/adding-a-changeset.md#i-am-in-a-multi-package-repository-a-mono-repo) via the `yarn changeset` command. Once complete, stage the change and commit it to your branch.

## Do you want to contribute to the Spectrum Web Components documentation?

Please read [Contributing Guidelines for documentation](https://github.com/adobe/spectrum-web-components#documentation)
Expand Down
6 changes: 3 additions & 3 deletions RELEASE_PROCESS.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Users with permissions in the `@spectrum-web-components` organization on NPM can
3. Run `nvm use` assumes a Node Version Manager install, and confirm your on an operable version of Node.
4. `yarn install`
5. `npm whoami` ensure that you are logged in with the user account for the public NPM registry
6. `yarn lerna-publish`
6. `yarn changeset-publish`
7. Scan the version summary for any unexpected changes.
- Changes to the _major_ versions number are likely to point to undesired version numbers.
- Changes to the _minor_ or _feature_ version number should be confirmed as correct against the changes that have been made since the last release.
Expand All @@ -23,10 +23,10 @@ Users with permissions in the `@spectrum-web-components` organization on NPM can

The docs site will publish automatically if the `#publish` string is included in the commit message and the check suite runs successfully.

If publishing fails with an error, check the [list of tags](https://github.com/adobe/spectrum-web-components/tags) to see if new tags have been released for your publishing attempt. If they have, then `yarn lerna-publish` will no longer work. Instead, you'll need to run:
If publishing fails with an error, check the [list of tags](https://github.com/adobe/spectrum-web-components/tags) to see if new tags have been released for your publishing attempt. If they have, then `yarn changeset-publish` will no longer work. Instead, you'll need to run:

```
yarn lerna-publish from-package
yarn changeset-publish from-package
```

## Publishing the docs site manually
Expand Down
5 changes: 1 addition & 4 deletions commitlint.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,5 @@ OF ANY KIND, either express or implied. See the License for the specific languag
governing permissions and limitations under the License.
*/
module.exports = {
extends: [
'@commitlint/config-conventional',
'@commitlint/config-lerna-scopes',
],
extends: ['@commitlint/config-conventional'],
};
17 changes: 0 additions & 17 deletions lerna.json

This file was deleted.

20 changes: 10 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"build": "wireit",
"build:clear-cache": "rimraf packages/*/tsconfig.tsbuildinfo && rimraf tools/*/tsconfig.tsbuildinfo",
"build:component-inventory": "node ./tasks/build-component-inventory.js",
"build:confirm": "lerna exec --ignore \"{@spectrum-web-components/{base,bundle,close-button,clear-button,iconset,modal,opacity-shared,opacity-checkerboard,styles,custom-vars-viewer,eslint-plugin},stylelint-header,@swc-react/*,documentation,example-project-rollup,example-project-webpack,swc-templates,@types/swc}\" -- test -f src/index.js",
"build:confirm": "node ./tasks/confirm-build.js",
"build:css": "wireit",
"build:css:watch": "wireit",
"build:react": "yarn gen-react-wrapper && node ./tasks/build-react.js && yarn tsc --build tsconfig-react-wrapper.json",
Expand All @@ -22,7 +22,8 @@
"build:ts:watch": "wireit",
"build:types": "wireit",
"build:watch": "wireit",
"custom-element-json": "lerna exec --ignore \"{@spectrum-web-components/{base,bundle,clear-button,close-button,modal,iconset,shared,opacity-checkerboard,styles,custom-vars-viewer,eslint-plugin},stylelint-header,@swc-react/*,documentation,example-project-rollup,example-project-webpack,swc-templates,@types/swc}\" -- cem analyze --config ../../custom-elements-manifest.config.js --packagejson",
"changeset-publish": "yarn changeset version && yarn changeset publish",
"custom-element-json": "node tasks/custom-element-json.js",
"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",
Expand All @@ -31,12 +32,11 @@
"docs:review": "alex packages/**/*.md",
"docs:start": "yarn workspace documentation serve --watch",
"find": "test -f custom-elements.json",
"gen-react-wrapper": "rm -fr react && lerna exec --ignore \"{@spectrum-web-components/{base,bundle,custom-vars-viewer,modal,iconset,shared,opacity-checkerboard,styles,reactive-controllers,eslint-plugin},stylelint-header,@swc-react/*,documentation,example-project-rollup,example-project-webpack,swc-templates,@types/swc}\" -- cem analyze --config ../../cem-react-wrapper.config.js && node ./scripts/generate-icon-react-wrapper.js",
"gen-react-wrapper": "rm -fr react && yarn changeset version && yarn changeset publish && yarn cem-react-wrapper && node ./scripts/generate-icon-react-wrapper.js",
"get-ready": "yarn build",
"icons": "wireit",
"icons:ui": "wireit",
"icons:workflow": "wireit",
"lerna-publish": "lerna publish --message \"chore: release new versions #publish\" --force-publish",
"lint": "run-p lint:js lint:docs lint:ts lint:css lint:packagejson",
"lint:css": "stylelint \"packages/**/*.css\" \"tools/**/*.css\"",
"lint:docs": "eslint -f pretty \"projects/documentation/**/*.ts\"",
Expand All @@ -45,13 +45,13 @@
"lint:ts": "pretty-quick --pattern \"packages/**/*.ts\" && eslint -f pretty \"packages/**/*.ts\" && pretty-quick --pattern \"tools/**/*.ts\" && eslint -f pretty \"tools/**/*.ts\"",
"lint:versions": "node ./scripts/lint-versions.js",
"new-package": "cd projects/templates && plop",
"postcustom-element-json": "lerna exec --ignore \"{@spectrum-web-components/{base,bundle,clear-button,close-button,iconset,modal,shared,opacity-checkerboard,styles,custom-vars-viewer,reactive-controllers,vrt-compare,eslint-plugin},stylelint-header,@swc-react/*,documentation,example-project-rollup,example-project-webpack,swc-templates,@types/swc}\" -- node ../../tasks/check-cem.js",
"postchangeset-publish": "yarn build:react && yarn changeset version && yarn changeset publish --no-git-tag --no-push && git add . && git commit -m \"chore: release new React Wrapper versions #publish\" && git push",
"postcustom-element-json": "node ./tasks/run-check-cem.js",
"postdocs:analyze": "node ./scripts/add-custom-properties.js --src=\"projects/documentation/custom-elements.json\"",
"postinstall": "patch-package && yarn get-ready",
"postlerna-publish": "yarn build:react && lerna publish from-package --message \"chore: release new Reach Wrapper versions #publish\"",
"precustom-element-json": "lerna exec --ignore \"{@spectrum-web-components/{base,bundle,iconset,modal,shared,opacity-checkerboard,styles,custom-vars-viewer,reactive-controllers,eslint-plugin},stylelint-header,@swc-react/*,documentation,example-project-rollup,example-project-webpack,swc-templates,@types/swc}\" -- rm custom-elements.json ||:",
"prechangeset-publish": "rimraf react && yarn get-ready && yarn custom-element-json && yarn build:confirm",
"precustom-element-json": "node remove-custom-elements-json.js",
"preeleventy": "yarn docs:analyze",
"prelerna-publish": "rimraf react && yarn get-ready && yarn custom-element-json && yarn build:confirm",
"prepare": "husky install",
"prestorybook": "wireit",
"prestorybook:build": "cem analyze --outdir storybook/",
Expand Down Expand Up @@ -93,9 +93,10 @@
"common-tags": "^1.8.0"
},
"devDependencies": {
"@changesets/changelog-github": "^0.5.0",
"@changesets/cli": "^2.27.1",
"@commitlint/cli": "^19.2.1",
"@commitlint/config-conventional": "^19.1.0",
"@commitlint/config-lerna-scopes": "^19.0.0",
"@custom-elements-manifest/analyzer": "^0.9.0",
"@lit/react": "^1.0.2",
"@netlify/build": "^29.1.0",
Expand Down Expand Up @@ -161,7 +162,6 @@
"gunzip-maybe": "^1.4.2",
"husky": "^9.0.10",
"latest-version": "^7.0.0",
"lerna": "^6.6.2",
"lightningcss": "^1.24.0",
"lit": "^2.5.0",
"lit-analyzer": "^2.0.3",
Expand Down
4 changes: 1 addition & 3 deletions tasks/build-preview-urls-comment.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ import crypto from 'crypto';
const getChangedPackages = () => {
let command;
try {
command = execSync(
'yarn --silent lerna ls --since origin/main --json --loglevel silent'
);
command = execSync('yarn changeset since --base origin/main --json');
} catch (error) {
console.log(error.message);
console.log(error.stdout.toString());
Expand Down
45 changes: 45 additions & 0 deletions tasks/confirm-build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
Copyright 2022 Adobe. All rights reserved.
This file is licensed to you under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. You may obtain a copy
of the License at http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
OF ANY KIND, either express or implied. See the License for the specific language
governing permissions and limitations under the License.
*/

import { execSync } from 'child_process';
import fs from 'fs';
import path from 'path';

// Define the directory where packages are located
const packagesDir = path.resolve(__dirname, 'packages');

// Get a list of all packages except those you want to ignore
const ignoredPackages = [
'@spectrum-web-components/base',
'@spectrum-web-components/bundle',
// Add other packages you want to ignore here
];
const allPackages = fs
.readdirSync(packagesDir)
.filter((pkg) => !ignoredPackages.includes(pkg));

// Define the command to execute
const command = 'test -f src/index.js';

// Execute the command in each package directory
allPackages.forEach((pkg) => {
const pkgDir = path.resolve(packagesDir, pkg);
try {
// Execute the command in the package directory
execSync(command, { cwd: pkgDir, stdio: 'inherit' });
} catch (error) {
console.error(`Error executing command in package ${pkg}:`, error);
process.exit(1);
}
});

console.log('Build confirmation completed successfully for all packages.');
23 changes: 23 additions & 0 deletions tasks/custom-element-json.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
Copyright 2022 Adobe. All rights reserved.
This file is licensed to you under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. You may obtain a copy
of the License at http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
OF ANY KIND, either express or implied. See the License for the specific language
governing permissions and limitations under the License.
*/
import { execSync } from 'child_process';

// Define the command to execute
const command = `cem analyze --config ../../custom-elements-manifest.config.js --packagejson`;

try {
// Execute the command using Change Sets
execSync(command, { stdio: 'inherit' });
} catch (error) {
console.error('Error executing custom-element-json command:', error);
process.exit(1);
}
66 changes: 66 additions & 0 deletions tasks/remove-custom-elements-json.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/*
Copyright 2022 Adobe. All rights reserved.
This file is licensed to you under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. You may obtain a copy
of the License at http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
OF ANY KIND, either express or implied. See the License for the specific language
governing permissions and limitations under the License.
*/

import { execSync } from 'child_process';
import fs from 'fs';
import path from 'path';

// Define the packages to ignore
const ignorePackages = [
'@spectrum-web-components/base',
'@spectrum-web-components/bundle',
'@spectrum-web-components/iconset',
'@spectrum-web-components/modal',
'@spectrum-web-components/shared',
'@spectrum-web-components/opacity-checkerboard',
'@spectrum-web-components/styles',
'@spectrum-web-components/custom-vars-viewer',
'@spectrum-web-components/reactive-controllers',
'@spectrum-web-components/eslint-plugin',
'stylelint-header',
'@swc-react/*',
'documentation',
'example-project-rollup',
'example-project-webpack',
'swc-templates',
'@types/swc',
];

// Get the list of workspace packages
const workspacePackages = JSON.parse(
execSync('yarn workspaces info --json').toString()
);
const packagesInfo = JSON.parse(workspacePackages.data);

// Remove custom-elements.json for each package except the ignored ones
Object.keys(packagesInfo).forEach((pkgName) => {
if (
!ignorePackages.some((ignore) =>
new RegExp(ignore.replace('*', '.*')).test(pkgName)
)
) {
const packageLocation = packagesInfo[pkgName].location;
const customElementsJsonPath = path.join(
packageLocation,
'custom-elements.json'
);

if (fs.existsSync(customElementsJsonPath)) {
console.log(`Removing custom-elements.json for ${pkgName}`);
fs.unlinkSync(customElementsJsonPath);
} else {
console.warn(`custom-elements.json not found for ${pkgName}`);
}
} else {
console.log(`Ignoring package ${pkgName}`);
}
});
69 changes: 69 additions & 0 deletions tasks/run-check-cem.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*
Copyright 2022 Adobe. All rights reserved.
This file is licensed to you under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. You may obtain a copy
of the License at http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
OF ANY KIND, either express or implied. See the License for the specific language
governing permissions and limitations under the License.
*/

import { execSync } from 'child_process';
import fs from 'fs';
import path from 'path';

// Define the packages to ignore
const ignorePackages = [
'@spectrum-web-components/base',
'@spectrum-web-components/bundle',
'@spectrum-web-components/clear-button',
'@spectrum-web-components/close-button',
'@spectrum-web-components/iconset',
'@spectrum-web-components/modal',
'@spectrum-web-components/shared',
'@spectrum-web-components/opacity-checkerboard',
'@spectrum-web-components/styles',
'@spectrum-web-components/custom-vars-viewer',
'@spectrum-web-components/reactive-controllers',
'@spectrum-web-components/vrt-compare',
'@spectrum-web-components/eslint-plugin',
'stylelint-header',
'@swc-react/*',
'documentation',
'example-project-rollup',
'example-project-webpack',
'swc-templates',
'@types/swc',
];

// Get the list of workspace packages
const workspacePackages = JSON.parse(
execSync('yarn workspaces info --json').toString()
);
const packagesInfo = JSON.parse(workspacePackages.data);

// Execute check-cem.js for each package except the ignored ones
Object.keys(packagesInfo).forEach((pkgName) => {
if (
!ignorePackages.some((ignore) =>
new RegExp(ignore.replace('*', '.*')).test(pkgName)
)
) {
const packageLocation = packagesInfo[pkgName].location;
const checkCemPath = path.join(
packageLocation,
'../../tasks/check-cem.js'
);

if (fs.existsSync(checkCemPath)) {
console.log(`Running check-cem.js for ${pkgName}`);
execSync(`node ${checkCemPath}`, { stdio: 'inherit' });
} else {
console.warn(`check-cem.js not found for ${pkgName}`);
}
} else {
console.log(`Ignoring package ${pkgName}`);
}
});