Skip to content

Commit 8370f01

Browse files
committed
chore: move tasks into scripts [swc-854] (#5476)
* chore: move tasks into scripts [swc-854] * chore: update custom element manifest scripts to simpify
1 parent 81fd690 commit 8370f01

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+724
-2044
lines changed

.eslintrc.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,16 @@
7979
],
8080
"overrides": [
8181
{
82-
"files": ["tasks/*", "scripts/*"],
82+
"files": ["scripts/*"],
8383
"rules": {
8484
"no-console": ["off"]
8585
}
86+
},
87+
{
88+
"files": ["react/**/*.ts"],
89+
"rules": {
90+
"@typescript-eslint/no-explicit-any": "off"
91+
}
8692
}
8793
]
8894
}

.github/CODEOWNERS

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1 @@
1-
cem-react-wrapper.config.js @jianliao
2-
scripts/cem-plugin-react-wrappers.js @jianliao
3-
scripts/generate-icon-react-wrapper.js @jianliao
4-
tasks/build-react.js @jianliao
5-
* @adobe/swc-maintainers
1+
* @adobe/swc-maintainers

tasks/build-tachometer-comment.js renamed to .github/scripts/build-tachometer-comment.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ OF ANY KIND, either express or implied. See the License for the specific languag
1111
governing permissions and limitations under the License.
1212
*/
1313

14-
import fg from 'fast-glob';
1514
import fs from 'fs';
15+
16+
import fg from 'fast-glob';
1617
import prettyBytes from 'pretty-bytes';
1718

1819
const getTachometerResults = () => {
@@ -156,7 +157,7 @@ export const buildTachometerComment = () => {
156157
const firefoxTables = results.firefox.map(buildTable);
157158
const chromeBody = chromeTables.length
158159
? chromeTables.join(`
159-
160+
160161
`)
161162
: 'Currently, no packages are changed by this PR...';
162163
const firefoxBody = firefoxTables.length
File renamed without changes.

.github/workflows/browser-tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ jobs:
9393
uses: actions/github-script@v7
9494
with:
9595
script: |
96-
const { buildTachometerComment } = await import('${{ github.workspace }}/tasks/build-tachometer-comment.js');
96+
const { buildTachometerComment } = await import('${{ github.workspace }}/.github/scripts/build-tachometer-comment.js');
97+
const { commentOrUpdate } = await import('${{ github.workspace }}/.github/scripts/comment-or-update.js');
9798
const body = buildTachometerComment();
98-
const { commentOrUpdate } = await import('${{ github.workspace }}/tasks/comment-or-update.js');
9999
commentOrUpdate(github, context, '## Tachometer results', body);

.github/workflows/urls-smoke-test.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,9 @@ jobs:
3939
uses: actions/github-script@v7
4040
with:
4141
script: |
42-
const { buildPreviewURLComment } = await import('${{ github.workspace }}/tasks/build-preview-urls-comment.js');
42+
const { buildPreviewURLComment, getDocPreviewURL } = await import('${{ github.workspace }}/.github/scripts/build-preview-urls-comment.js');
43+
const { commentOrUpdate } = await import('${{ github.workspace }}/.github/scripts/comment-or-update.js');
4344
const body = buildPreviewURLComment(process.env.GITHUB_HEAD_REF);
44-
const { getDocPreviewURL } = await import('${{ github.workspace }}/tasks/build-preview-urls-comment.js');
45-
const { commentOrUpdate } = await import('${{ github.workspace }}/tasks/comment-or-update.js');
4645
commentOrUpdate(github, context, '## Branch preview', body);
4746
4847
playwright-smoke-tests:

RELEASE_PROCESS.md

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,22 @@
22

33
Users with permissions in the `@spectrum-web-components` organization on NPM can follow these steps to create and publish a new version.
44

5-
- [Prerequisites](#prerequisites)
6-
- [Main successfully builds](#main-successfully-builds)
7-
- [The correct version of Node is installed](#the-correct-version-of-node-is-installed)
8-
- [Using Node Version Manager](#using-node-version-manager)
9-
- [Manually checking](#manually-checking)
10-
- [Troubleshooting](#troubleshooting)
11-
- [Github Token is set up](#github-token-is-set-up)
12-
- [Generate a Github token](#generate-a-github-token)
13-
- [Logged in to NPM](#logged-in-to-npm)
14-
- [NPM 2FA authenticator app](#npm-2fa-authenticator-app)
15-
- [Releasing to NPM — the good stuff](#releasing-to-npm--the-good-stuff)
16-
- [Troubleshooting](#troubleshooting-1)
17-
- [Publishing the documentation site manually](#publishing-the-documentation-site-manually)
18-
- [From GitHub](#from-github)
19-
- [From the terminal](#from-the-terminal)
20-
- [References](#references)
5+
- [Prerequisites](#prerequisites)
6+
- [Main successfully builds](#main-successfully-builds)
7+
- [The correct version of Node is installed](#the-correct-version-of-node-is-installed)
8+
- [Using Node Version Manager](#using-node-version-manager)
9+
- [Manually checking](#manually-checking)
10+
- [Troubleshooting](#troubleshooting)
11+
- [Github Token is set up](#github-token-is-set-up)
12+
- [Generate a Github token](#generate-a-github-token)
13+
- [Logged in to NPM](#logged-in-to-npm)
14+
- [NPM 2FA authenticator app](#npm-2fa-authenticator-app)
15+
- [Releasing to NPM — the good stuff](#releasing-to-npm--the-good-stuff)
16+
- [Troubleshooting](#troubleshooting-1)
17+
- [Publishing the documentation site manually](#publishing-the-documentation-site-manually)
18+
- [From GitHub](#from-github)
19+
- [From the terminal](#from-the-terminal)
20+
- [References](#references)
2121

2222
## Prerequisites
2323

@@ -94,22 +94,22 @@ If not logged in, run `npm login` to sign in to your account.
9494
1. In your IDE search `': major` , `': minor`, `': patch` , based on the results in the order of this search list, the highest level takes precedence
9595
1. exclude files: `.changeset/README.md`
9696
4. Open your authenticator app to have it ready
97-
5. Run`yarn changeset-publish`
97+
5. Run`yarn publish:changeset`
9898
6. Enter the one-time password from your authenticator for NPM.
9999
1. Wait for a fresh password; a stale timer might cause issues.
100100
7. After the SWC packages are released, the React Wrapper packages will be generated.
101101
1. This multi-phase approach ensures that the wrapped packages share the same version as the standard packages.
102102
8. Enter a new one-time password from your authenticator for NPM.
103-
9. The `yarn changeset-publish` command will automatically commit the changes to main with a commit message of `chore: release new versions #publish`
103+
9. The `yarn publish:changeset` command will automatically commit the changes to main with a commit message of `chore: release new versions #publish`
104104
1. The docs site will publish automatically if the `#publish` string is included in the commit message and the check suite runs successfully.
105105
10. Confirm the build on `main` passes
106106

107107
### Troubleshooting
108108

109109
If publishing fails with an error:
110110

111-
- 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.
112-
- If they were, run `yarn changeset-publish` again.
111+
- 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.
112+
- If they were, run `yarn publish:changeset` again.
113113

114114
---
115115

cem-react-wrapper.config.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,17 @@ OF ANY KIND, either express or implied. See the License for the specific languag
1010
governing permissions and limitations under the License.
1111
*/
1212

13-
import reactWrapperPlugin from './scripts/cem-plugin-react-wrapper.js';
14-
import defineElementPlugin from './scripts/define-element-plugin.js';
1513
import { readFileSync } from 'fs';
16-
import { resolve } from 'path';
14+
import { dirname, join } from 'path';
15+
import { fileURLToPath } from 'url';
16+
1717
import yaml from 'js-yaml';
1818

19+
import defineElementPlugin from './scripts/define-element-plugin.js';
20+
import reactWrapperPlugin from './scripts/cem-plugin-react-wrapper.js';
21+
22+
const __dirname = dirname(fileURLToPath(import.meta.url));
23+
1924
export default {
2025
globs: ['**/sp-*.ts', '**/overlay-trigger.ts', '**/src/[A-Z]*.ts'],
2126
exclude: [
@@ -26,16 +31,15 @@ export default {
2631
'node_modules/*',
2732
'**/*.dev.*',
2833
],
29-
outdir: '.',
3034
litelement: true,
3135
packagejson: false,
3236
plugins: [
3337
defineElementPlugin(),
3438
reactWrapperPlugin({
3539
exclude: ['StoryDecorator', 'TooltipOpenable'],
36-
outDir: '../../react',
40+
outDir: join(__dirname, 'react'),
3741
prettierConfig: yaml.load(
38-
readFileSync(resolve('../../.prettierrc.yaml'))
42+
readFileSync(join(__dirname, '.prettierrc.yaml'))
3943
),
4044
}),
4145
],

package.json

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,9 @@
1212
"analyze": "lit-analyzer \"{packages,tools}/*/src/**/!(*.css).ts\"",
1313
"build": "wireit",
1414
"build:clear-cache": "rimraf packages/*/tsconfig.tsbuildinfo && rimraf tools/*/tsconfig.tsbuildinfo",
15-
"build:component-inventory": "node ./tasks/build-component-inventory.js",
16-
"build:confirm": "node ./tasks/confirm-build.js",
1715
"build:css": "wireit",
1816
"build:css:watch": "wireit",
19-
"build:react": "yarn gen-react-wrapper && node ./tasks/build-react.js && yarn tsc --build tsconfig-react-wrapper.json",
17+
"build:react": "rimraf react && node ./scripts/build-react.js && tsc --build tsconfig-react-wrapper.json",
2018
"build:tests": "tsc --build test/tsconfig.json && tsc --build test/tsconfig-node.json",
2119
"build:ts": "wireit",
2220
"build:ts:watch": "wireit",
@@ -25,8 +23,7 @@
2523
"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",
2624
"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",
2725
"chromatic": "chromatic --build-script-name storybook:build # note that --project-token must be set in your env variables",
28-
"create-git-tag": "node --no-warnings tasks/create-git-tag.js",
29-
"custom-element-json": "node tasks/custom-element-json.js",
26+
"custom-element-json": "node ./scripts/custom-element-json.js",
3027
"docs:analyze": "cem analyze --globs \"packages/**/*.ts\" --exclude \"**/*.d.ts\" --exclude \"**/stories/**\" --exclude \"**/icons/**\" --exclude \"**/elements/**\" --outdir projects/documentation --litelement",
3128
"docs:build": "yarn workspace documentation build",
3229
"docs:ci": "yarn docs:analyze && run-p docs:production storybook:build && cp projects/documentation/custom-elements.json projects/documentation/dist/storybook",
@@ -35,18 +32,15 @@
3532
"docs:review": "alex packages/**/*.md",
3633
"docs:start": "yarn workspace documentation serve --watch",
3734
"find": "test -f custom-elements.json",
38-
"gen-react-wrapper": "node ./tasks/gen-react-wrapper.js",
3935
"icons": "wireit",
4036
"icons:ui": "wireit",
4137
"icons:workflow": "wireit",
4238
"lint": "git status --porcelain && git add . && lint-staged --allow-empty",
4339
"new-package": "cd projects/templates && plop",
44-
"postcustom-element-json": "node ./tasks/run-check-cem.js",
4540
"postinstall": "husky || true && patch-package",
4641
"postpack": "pinst --enable",
4742
"postpublish": "yarn prepublish:react && yarn publish:react && yarn postpublish:react",
4843
"postpublish:react": "git reset --hard HEAD^ && git prune && rimraf react",
49-
"precustom-element-json": "node tasks/remove-custom-elements-json.js",
5044
"preeleventy": "yarn docs:analyze",
5145
"prepack": "pinst --disable",
5246
"prepublish:react": "yarn build:react && sed -i \"\" \"s/react/# react/g\" .gitignore && git commit -am \"Commit React Wrappers\" --no-verify",
@@ -65,7 +59,7 @@
6559
"storybook:run": "web-dev-server --config wds-storybook.config.js",
6660
"test": "yarn test:focus unit",
6761
"test:bench": "yarn build:tests && node test/benchmark/cli.js",
68-
"test:changed": "node ./tasks/test-changes.js",
62+
"test:changed": "node ./scripts/test-changes.js",
6963
"test:ci": "yarn test:start",
7064
"test:create": "wireit",
7165
"test:errors": "yarn test | grep -A 32 ❌",
@@ -99,7 +93,7 @@
9993
"@rollup/plugin-commonjs": "^25.0.7",
10094
"@rollup/plugin-json": "^6.0.1",
10195
"@rollup/plugin-node-resolve": "^15.2.3",
102-
"@sindresorhus/slugify": "^2.1.1",
96+
"@sindresorhus/slugify": "^2.2.1",
10397
"@spectrum-web-components/eslint-plugin": "file:./linters/eslint",
10498
"@storybook/addon-a11y": "^8.6.12",
10599
"@storybook/addon-designs": "^8.2.1",
@@ -140,6 +134,7 @@
140134
"chromedriver": "^136.0.0",
141135
"colors": "^1.4.0",
142136
"common-tags": "^1.8.2",
137+
"crypto": "^1.0.1",
143138
"custom-elements-manifest": "^2.0.0",
144139
"debounce": "^2.0.0",
145140
"deepmerge": "^4.2.2",
@@ -154,7 +149,7 @@
154149
"eslint-plugin-require-extensions": "^0.1.3",
155150
"eslint-plugin-storybook": "^0.8.0",
156151
"express": "^4.16.4",
157-
"fast-glob": "^3.2.12",
152+
"fast-glob": "^3.3.3",
158153
"fs-extra": "^11.1.1",
159154
"geckodriver": "^4.3.0",
160155
"genversion": "^3.1.1",
@@ -176,9 +171,9 @@
176171
"pinst": "^3.0.0",
177172
"prettier": "^3.5.3",
178173
"prettier-plugin-package": "^1.3.0",
179-
"pretty-bytes": "^6.1.1",
174+
"pretty-bytes": "^7.0.0",
180175
"re-template-tag": "^2.0.1",
181-
"rimraf": "^5.0.1",
176+
"rimraf": "^6.0.1",
182177
"rollup": "^4.12.0",
183178
"sinon": "^17.0.1",
184179
"storybook": "^8.6.12",
@@ -195,16 +190,16 @@
195190
},
196191
"wireit": {
197192
"build:css:watch": {
198-
"command": "node ./tasks/watch-css.js",
193+
"command": "node ./scripts/watch-css.js",
199194
"service": true
200195
},
201196
"build:css": {
202-
"command": "node ./tasks/build-css.js",
197+
"command": "node ./scripts/build-css.js",
203198
"files": [
204199
"packages/**/*.css",
205200
"tools/**/*.css",
206-
"tasks/build-css.js",
207-
"tasks/css-tools.js"
201+
"scripts/build-css.js",
202+
"scripts/css-tools.js"
208203
],
209204
"output": [
210205
"packages/**/*.css.ts",
@@ -213,11 +208,11 @@
213208
"clean": "if-file-deleted"
214209
},
215210
"build:ts:watch": {
216-
"command": "node ./tasks/watch-packages.js",
211+
"command": "node ./scripts/watch-ts.js",
217212
"service": true
218213
},
219214
"build:ts": {
220-
"command": "node ./tasks/esbuild-packages.js",
215+
"command": "node ./scripts/build-ts.js",
221216
"dependencies": [
222217
"process-icons",
223218
"test:create",
@@ -235,8 +230,7 @@
235230
"!projects/templates/**/*",
236231
"tools/**/*.ts",
237232
"!tools/**/*.d.ts",
238-
"tasks/esbuild-packages.js",
239-
"tasks/ts-tools.js",
233+
"scripts/build-ts.js",
240234
"packages/**/exports.json",
241235
"tools/**/exports.json"
242236
],

packages/icons-ui/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
"@spectrum-css/ui-icons-s2": "npm:@spectrum-css/[email protected]",
6060
"case": "^1.6.1",
6161
"cheerio": "^1.0.0-rc.2",
62-
"fast-glob": "^3.2.12",
62+
"fast-glob": "^3.3.3",
6363
"fs": "^0.0.1-security",
6464
"path": "^0.12.7",
6565
"prettier": "^3.5.3"

packages/icons-workflow/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
"@adobe/spectrum-css-workflow-icons-s2": "npm:@adobe/[email protected]",
6060
"case": "^1.6.1",
6161
"cheerio": "^1.0.0-rc.2",
62-
"fast-glob": "^3.2.12",
62+
"fast-glob": "^3.3.3",
6363
"fs": "^0.0.1-security",
6464
"path": "^0.12.7",
6565
"prettier": "^3.5.3"

projects/documentation/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
"posthtml-attrs-parser": "^1.0.1",
5050
"posthtml-match-helper": "^2.0.0",
5151
"prismjs": "^1.29.0",
52-
"rimraf": "^5.0.1",
52+
"rimraf": "^6.0.1",
5353
"rollup": "^4.12.0",
5454
"rollup-plugin-lit-css": "^5.0.0",
5555
"rollup-plugin-minify-html-literals": "^1.2.6",

projects/example-project-rollup/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
"eslint": "^8.23.0",
4040
"eslint-config-prettier": "^9.1.0",
4141
"prettier": "^3.5.3",
42-
"rimraf": "^5.0.1",
42+
"rimraf": "^6.0.1",
4343
"rollup": "^4.12.0",
4444
"rollup-plugin-styles": "^4.0.0",
4545
"rollup-plugin-visualizer": "^5.12.0",

scripts/build-css.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/usr/bin/env node
2+
3+
/**
4+
* Copyright 2025 Adobe. All rights reserved.
5+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License. You may obtain a copy
7+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software distributed under
10+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
11+
* OF ANY KIND, either express or implied. See the License for the specific language
12+
* governing permissions and limitations under the License.
13+
*/
14+
15+
import fg from 'fast-glob';
16+
import 'colors';
17+
18+
import { processCSS } from './css-tools.js';
19+
20+
async function buildCSS() {
21+
const promises = [];
22+
for (const cssPath of await fg([
23+
'./packages/*/src/**/*.css',
24+
'./tools/*/src/*.css',
25+
'./tools/*/src/**/*.css',
26+
])) {
27+
promises.push(
28+
processCSS(cssPath)
29+
.then(() => console.log(`Processed ${cssPath.yellow}`))
30+
.catch((error) =>
31+
console.error(`Error processing ${cssPath}`, error)
32+
)
33+
);
34+
}
35+
36+
return Promise.all(promises);
37+
}
38+
39+
await buildCSS();

0 commit comments

Comments
 (0)