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 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
feat: replaced lerna with changesets
  • Loading branch information
blunteshwar committed Jun 4, 2024
commit 9831d61d07f21f555248858c041f7f0760474c16
14 changes: 7 additions & 7 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": "changeset 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,8 +22,8 @@
"build:ts:watch": "wireit",
"build:types": "wireit",
"build:watch": "wireit",
"changeset-publish": "changeset publish --message \"chore: release new versions #publish\" --force-publish",
"custom-element-json": "changeset 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 @@ -32,7 +32,7 @@
"docs:review": "alex packages/**/*.md",
"docs:start": "yarn workspace documentation serve --watch",
"find": "test -f custom-elements.json",
"gen-react-wrapper": "rm -fr react && changeset 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",
Expand All @@ -45,12 +45,12 @@
"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",
"postchangeset-publish": "yarn build:react && changeset publish from-package --message \"chore: release new React Wrapper versions #publish\"",
"postcustom-element-json": "changeset 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",
"prechangeset-publish": "rimraf react && yarn get-ready && yarn custom-element-json && yarn build:confirm",
"precustom-element-json": "changeset 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 ||:",
"precustom-element-json": "node remove-custom-elements-json.js",
"preeleventy": "yarn docs:analyze",
"prepare": "husky install",
"prestorybook": "wireit",
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:https://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:https://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:https://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:https://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}`);
}
});
90 changes: 7 additions & 83 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5160,83 +5160,9 @@
resolved "https://registry.yarnpkg.com/@spectrum-css/vars/-/vars-9.0.8.tgz#6af3bcdace903b8461f5fcd4c9aa23e70128a456"
integrity sha512-rGfd7jqXOdR69bEjrRP58ynuIeJU0czPfwQvzhtCzg7jKVukV+efNHqrs086sC6xutB3W4TF71K/dZMr3oyTyg==

"@spectrum-web-components/base@^0.40.5":
version "0.40.5"
resolved "https://registry.yarnpkg.com/@spectrum-web-components/base/-/base-0.40.5.tgz#5e67bab5aa835d5ec3fa141abd14aaf5344ab9ee"
integrity sha512-lGvAkpWzaPuLBdKfFqQW5J4dBTsn8I9OxpfKoEifR9OdNEELJshNVs+9iZY+3AYx3s3Y2WRLnsGrxtWuNg595g==
dependencies:
lit "^2.5.0"

"@spectrum-web-components/button-group@^0.40.4-next.0":
version "0.40.5"
resolved "https://registry.yarnpkg.com/@spectrum-web-components/button-group/-/button-group-0.40.5.tgz#27a1ba1de8ceba2b09598126bd9769a470481f34"
integrity sha512-vgxgy4UcAOkiWQh/qN6Oex08Zxj24vP2uwUSBt4DqYqhKY/yupg8P+RhyQ0xfSQC70sTHyeGb1nxMZYus5qQUQ==
dependencies:
"@spectrum-web-components/base" "^0.40.5"
"@spectrum-web-components/button" "^0.40.5"

"@spectrum-web-components/button@^0.40.5":
version "0.40.5"
resolved "https://registry.yarnpkg.com/@spectrum-web-components/button/-/button-0.40.5.tgz#19424d1591390ca1b2255e4f6a3d60eacf4243bb"
integrity sha512-RWneeVltJgS3XWZlWd4cpzY6f8ZTaBRIJEy8RqPXeut90jb+VWZLdF/zhme8JpGK7hEfBcYGst31P06KebaIzw==
dependencies:
"@spectrum-web-components/base" "^0.40.5"
"@spectrum-web-components/clear-button" "^0.40.5"
"@spectrum-web-components/close-button" "^0.40.5"
"@spectrum-web-components/icon" "^0.40.5"
"@spectrum-web-components/icons-ui" "^0.40.5"
"@spectrum-web-components/shared" "^0.40.5"

"@spectrum-web-components/clear-button@^0.40.5":
version "0.40.5"
resolved "https://registry.yarnpkg.com/@spectrum-web-components/clear-button/-/clear-button-0.40.5.tgz#33c8d4ea19fc94bc4b2db6cb1076bd831011f855"
integrity sha512-5BzW9qGNYJj8O3WLaeVBVGt71bK60tpX6NTLQJWV/lcfSENMPEsO1ztziCrxJ5ENz8Y4hG20HTGlqamVfFmt6Q==
dependencies:
"@spectrum-web-components/base" "^0.40.5"

"@spectrum-web-components/close-button@^0.40.5":
version "0.40.5"
resolved "https://registry.yarnpkg.com/@spectrum-web-components/close-button/-/close-button-0.40.5.tgz#63a32235b7d6cc3c0a0e3ea6c19318d59174a781"
integrity sha512-ooSiUg1C7+GB6y2CoNusLmBor2huBSABG3Exo3BrQM2/viPf2BRUwnRj5ROh37VjdLCu3EUCpjxQ+n8nEcFKAA==
dependencies:
"@spectrum-web-components/base" "^0.40.5"

"@spectrum-web-components/eslint-plugin@file:./linters/eslint":
version "0.42.2"

"@spectrum-web-components/icon@^0.40.5":
version "0.40.5"
resolved "https://registry.yarnpkg.com/@spectrum-web-components/icon/-/icon-0.40.5.tgz#901013ae5f44fe27a19fcf02e0f8a43fe3e0df8a"
integrity sha512-uWzrsZshOfUSy33aep5/ww9ZVoL2asKSUnUAIz6DTH4cmPiT9kNdJXJr0Srru+Xy0DhjGIrpKRCMGLThfYB8Ow==
dependencies:
"@spectrum-web-components/base" "^0.40.5"
"@spectrum-web-components/iconset" "^0.40.5"

"@spectrum-web-components/icons-ui@^0.40.5":
version "0.40.5"
resolved "https://registry.yarnpkg.com/@spectrum-web-components/icons-ui/-/icons-ui-0.40.5.tgz#27b8e337fb162d090ea65ce7f1917a877bc1d226"
integrity sha512-bHYtTkFwAnz4jHWnmckOgvoEZPtskXfZXcM+us5J6kkOSfss4G6Npjra6+2Ud0OByGWD6KBilXbny3DBYLzAaA==
dependencies:
"@spectrum-web-components/base" "^0.40.5"
"@spectrum-web-components/icon" "^0.40.5"
"@spectrum-web-components/iconset" "^0.40.5"

"@spectrum-web-components/iconset@^0.40.5":
version "0.40.5"
resolved "https://registry.yarnpkg.com/@spectrum-web-components/iconset/-/iconset-0.40.5.tgz#1b202059e26d4cbb7607596d3c4f7985494b1f01"
integrity sha512-MY0VFg7yH/j3M7BIIROFR0LGFNj3WJs8VVbV47Req4nQTx6VPOIndnK8uhjFFMleXqEX8w/jVSqZgiD1PQ6w/w==
dependencies:
"@spectrum-web-components/base" "^0.40.5"

"@spectrum-web-components/shared@^0.40.5":
version "0.40.5"
resolved "https://registry.yarnpkg.com/@spectrum-web-components/shared/-/shared-0.40.5.tgz#d02311beed2b058f9d0930d7c2e4d2db58d6c09b"
integrity sha512-JyeBukaNmaacvl8Q0ezdbFRzBm/o/2uHmF7kOmWjElpe1KGH6RQ7JgRP9eiUW4ofMYKTOu5F7X5qqeTdvG9Z3g==
dependencies:
"@lit-labs/observers" "^2.0.0"
"@spectrum-web-components/base" "^0.40.5"
focus-visible "^5.1.0"

"@storybook/addon-a11y@^7.5.0":
version "7.6.17"
resolved "https://registry.yarnpkg.com/@storybook/addon-a11y/-/addon-a11y-7.6.17.tgz#77209c23b6908d52dc470a3318d76a0ffe9d47cb"
Expand Down Expand Up @@ -18245,7 +18171,7 @@ [email protected], minimist@^1.1.0, minimist@^1.1.3, minimist@^1.2.0, minimist@^1.2
resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.8.tgz#c1a464e7693302e082a075cee0c057741ac4772c"
integrity sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==

minipass@^3.0.0, minipass@^3.1.1:
minipass@^3.0.0:
version "3.3.4"
resolved "https://registry.yarnpkg.com/minipass/-/minipass-3.3.4.tgz#ca99f95dd77c43c7a76bf51e6d200025eee0ffae"
integrity sha512-I9WPbWHCGu8W+6k1ZiGpPu0GkoKBeorkfKNuAFBNS1HNFJvke82sxvI5bzcCNpWPorkOO5QQ+zomzzwRxejXiw==
Expand All @@ -18262,6 +18188,11 @@ minipass@^5.0.0:
resolved "https://registry.yarnpkg.com/minipass/-/minipass-7.0.3.tgz#05ea638da44e475037ed94d1c7efcc76a25e1974"
integrity sha512-LhbbwCfz3vsb12j/WkWQPZfKTsgqIe1Nf/ti1pKjYESGLHIVjWU96G9/ljLH4F9mWNVhlQOm0VySdAWzf05dpg==

minipass@^7.0.3:
version "7.1.2"
resolved "https://registry.yarnpkg.com/minipass/-/minipass-7.1.2.tgz#93a9626ce5e5e66bd4db86849e7515e92340a707"
integrity sha512-qOOzS1cBTWYF4BH8fVePDBOO9iptMnGUEZwNc/cMWnTV2nVLZ7VoNWEPHkYczZA0pdoA7dl6e7FL659nX9S2aw==

minizlib@^2.1.1:
version "2.1.2"
resolved "https://registry.yarnpkg.com/minizlib/-/minizlib-2.1.2.tgz#e90d3466ba209b932451508a11ce3d3632145931"
Expand Down Expand Up @@ -22713,14 +22644,7 @@ sprintf-js@~1.0.2:
resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c"
integrity sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=

[email protected], ssri@^9.0.0:
version "9.0.1"
resolved "https://registry.yarnpkg.com/ssri/-/ssri-9.0.1.tgz#544d4c357a8d7b71a19700074b6883fcb4eae057"
integrity sha512-o57Wcn66jMQvfHG1FlYbWeZWW/dHZhJXjpIcTfXldXEk5nz5lStPo3mK0OJQfGR3RbZUlbISexbljkJzuEj/8Q==
dependencies:
minipass "^3.1.1"

ssri@^10.0.0, ssri@^10.0.1, ssri@^10.0.5:
ssri@^10.0.5:
version "10.0.5"
resolved "https://registry.yarnpkg.com/ssri/-/ssri-10.0.5.tgz#e49efcd6e36385196cb515d3a2ad6c3f0265ef8c"
integrity sha512-bSf16tAFkGeRlUNDjXu8FzaMQt6g2HZJrun7mtMbIPOddxt3GLMSz5VWUWcqTJUPfLEaDIepGxv+bYQW49596A==
Expand Down