Skip to content

chore: script clean-up for packages and tokens[swc-808] #5419

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

Open
wants to merge 1 commit into
base: CSS-Cutoff
Choose a base branch
from

Conversation

castastrophe
Copy link
Collaborator

@castastrophe castastrophe commented Apr 30, 2025

Description

Process-spectrum is a command that runs several scripts that auto-generate and compile stylesheets from @spectrum-css repo and the spectrum-config defined in component directories. This rewrites every stylesheet each time it runs to catch differences in the output. 

Process-spectrum runs in many of our commands in the package.json as a dependency or directly called. We need to remove it and check that yarn build no longer compiles styles.

Related issue(s)

  • SWC-808
  • SWC-809

How has this been tested?

  • I expect the Spectrum CSS assets not to be imported or regenerated by the yarn build command
  • I expect all previously generated CSS files are checked into the repository, where they will become the source for future edits.
  • I expect all commands besides process-spectrum continue to run correctly and produce correct output; all tests still pass.

Checklist

  • I have signed the Adobe Open Source CLA.
  • My code follows the code style of this project.
  • If my change required a change to the documentation, I have updated the documentation in this pull request.
  • I have read the CONTRIBUTING document.
  • [n/a] I have added tests to cover my changes.
  • All new and existing tests passed.
  • I have reviewed at the Accessibility Practices for this feature, see: Aria Practices

Best practices

This repository uses conventional commit syntax for each commit message; note that the GitHub UI does not use this by default so be cautious when accepting suggested changes. Avoid the "Update branch" button on the pull request and opt instead for rebasing your branch against main.

Copy link

changeset-bot bot commented Apr 30, 2025

⚠️ No Changeset found

Latest commit: 555d6a7

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@@ -50,7 +50,6 @@
"lint:versions": "node ./scripts/lint-versions.js",
"new-package": "cd projects/templates && plop",
"postcustom-element-json": "node ./tasks/run-check-cem.js",
"postdocs:analyze": "node ./scripts/add-custom-properties.js --src=\"projects/documentation/custom-elements.json\"",
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is reading in spectrum-vars.json files from the packages in this repo and those files are legacy and no longer created or committed.

Copy link

Branch preview

Review the following VRT differences

When a visual regression test fails (or has previously failed while working on this branch), its results can be found in the following URLs:

If the changes are expected, update the current_golden_images_cache hash in the circleci config to accept the new images. Instructions are included in that file.
If the changes are unexpected, you can investigate the cause of the differences and update the code accordingly.

Copy link

Tachometer results

Currently, no packages are changed by this PR...

@castastrophe castastrophe force-pushed the castastrophe/swc-808-disable-process-spectrum branch 3 times, most recently from e0f9c5f to 5945a6d Compare May 1, 2025 16:53
@@ -14,7 +14,7 @@ governing permissions and limitations under the License.

import chokidar from 'chokidar';
import debounce from 'debounce';
import { processCSS } from './css-tools.js';
import { processCSS } from './build-css.js';
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The css-tools file only had 1 task in it so I pulled that into build-css to simplify things a bit.

}
} else {
console.warn(`check-cem.js not found for ${pkg.name}`);
async function checkCEM(pkg) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I pulled this functionality directly into the run script here since it seemed like an unnecessary abstraction.

'ui-icons',
'dist'
)
const spectrumIconsPath = path.join(
Copy link
Collaborator Author

@castastrophe castastrophe May 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

path.resolve + path.join functions cause the drive to be listed twice in windows so I cleaned that up while I was here.

@@ -60,8 +60,6 @@
"case": "^1.6.1",
"cheerio": "^1.0.0-rc.2",
"fast-glob": "^3.2.12",
"fs": "^0.0.1-security",
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fs and path are bundled with node and don't need to be pulled in explicitly (in fact it can be a risk).

@castastrophe castastrophe force-pushed the castastrophe/swc-808-disable-process-spectrum branch from 5945a6d to 1045ca1 Compare May 1, 2025 19:52
@castastrophe castastrophe force-pushed the castastrophe/swc-808-disable-process-spectrum branch from 1045ca1 to 618cb83 Compare May 5, 2025 13:38
@castastrophe castastrophe force-pushed the castastrophe/swc-808-disable-process-spectrum branch 2 times, most recently from 11d4edb to 4f12157 Compare May 6, 2025 17:13
@@ -1,5 +1 @@
cem-react-wrapper.config.js @jianliao
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can loop in Jian if needed but we can also code review these too.

@castastrophe castastrophe force-pushed the castastrophe/swc-808-disable-process-spectrum branch from 4f12157 to 8a82d29 Compare May 6, 2025 17:33
@@ -31,7 +31,6 @@ custom-elements.json
packages/*/src/**/*.css.js
packages/*/custom-elements.json
packages/**/*.js
packages/**/spectrum-vars.json
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a legacy asset from the vars and expressvars days. Might be worth looking into copying over the metadata.json functionality from CSS though.

@@ -1,106 +0,0 @@
# Component Inventory

Availability of [Spectrum](https://spectrum.adobe.com) components in [Spectrum CSS](https://opensource.adobe.com/spectrum-css/)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not being updated regularly anymore and the script to do so was based on outdated dependency structures. If we want to bring this back, we'll need to find new ways to automate it.

@@ -22,7 +22,6 @@ import {
overviewDestinationTemplate,
overviewPartialTemplate,
} from './component-template-parts.js';
import { gatherUrls } from './gather-spectrum-urls.js';
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fetching assets that no longer exist for the CSS packages.

import fg from 'fast-glob';
import { processCSS } from './css-tools.js';
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We didn't really need this abstraction since build-css is the only script calling css-tools. I pulled that functionality directly into this script as a single-source-of-truth.

import { buildPackage } from './ts-tools.js';
import { generateIconWrapper } from '../scripts/cem-plugin-react-wrapper.js';
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similarly to the build-css script, this one didn't need these abstractions or to call the exec functionality when the node utilities exist.

"create-git-tag": "node --no-warnings tasks/create-git-tag.js",
"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",
"custom-element-json": "yarn custom-element-json:clean && node tasks/custom-element-json.js && yarn custom-element-json:validate",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

love this improvement

"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",
"build:icons": "wireit",
"build:react": "node ./tasks/build-react.js && tsc --build tsconfig-react-wrapper.json",
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I combined the gen-react-wrapper and build-react tasks into one script

@@ -10,34 +10,32 @@
},
"scripts": {
"analyze": "lit-analyzer \"{packages,tools}/*/src/**/!(*.css).ts\"",
"analyze:docs": "cem analyze --globs \"packages/**/*.ts\" --exclude \"**/*.d.ts\" --exclude \"**/stories/**\" --exclude \"**/icons/**\" --exclude \"**/elements/**\" --outdir projects/documentation --litelement",
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was previous docs: analyze but I was aiming to group the cem tasks together so we can get a view of the manifests being generated.

"build": "wireit",
"build:clear-cache": "rimraf packages/*/tsconfig.tsbuildinfo && rimraf tools/*/tsconfig.tsbuildinfo",
"build:component-inventory": "node ./tasks/build-component-inventory.js",
"build:clean": "rimraf packages/*/tsconfig.tsbuildinfo tools/*/tsconfig.tsbuildinfo",
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I migrated build:clear-cache to build:clean. Clear-cache wasn't being used anywhere else but it seemed right to keep it as an available shorthand script.

"build": "wireit",
"build:clear-cache": "rimraf packages/*/tsconfig.tsbuildinfo && rimraf tools/*/tsconfig.tsbuildinfo",
"build:component-inventory": "node ./tasks/build-component-inventory.js",
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The component inventory was really out-of-date and leveraging assets we no longer have in our node_modules resources so if we want to build something similar in the future, we'll need a different way to go about it.

Comment on lines +27 to +28
"changeset-publish": "yarn prepublishOnly && yarn changeset version && yarn install && yarn lint:versions --fix && yarn update-version && yarn changeset publish && yarn postpublish",
"changeset-snapshot-publish": "yarn prepublishOnly && yarn changeset version --snapshot && yarn install && yarn lint:versions --fix && yarn update-version && yarn changeset publish --no-git-tag --tag snapshot",
Copy link
Collaborator Author

@castastrophe castastrophe May 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question about the changeset-publish command. Why are we setting changeset not to create the tags and then using a script to do it? Can't we just let changeset push the git tags?

"docs:production": "yarn workspace documentation build:production",
"docs:review": "alex packages/**/*.md",
"docs:start": "yarn workspace documentation serve --watch",
"find": "test -f custom-elements.json",
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This wasn't being used anywhere and I don't see much value in it.

"docs:production": "yarn workspace documentation build:production",
"docs:review": "alex packages/**/*.md",
"docs:start": "yarn workspace documentation serve --watch",
"find": "test -f custom-elements.json",
"format:css": "yarn lint:css --fix && pretty-quick --pattern \"{packages,tools}/**/*.css\"",
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed this formatter since we're looking to migrate to lint-staged but we can bring back a forced formatting command if we need it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does lint-staged need to be merged in first?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No I don't think it does, the format:css command isn't called by anything so it's really just a question of if anyone is manually using this one.

@@ -48,31 +46,20 @@
"lint:packagejson": "pretty-quick --pattern package.json --pattern \"packages/*/package.json\" --pattern \"projects/*/package.json\" --pattern \"tools/*/package.json\" --pattern \"react/*/package.json\"",
"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",
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can see this updated below, we don't have to move into the directory to run the command since we can leverage yarn workspaces

@castastrophe castastrophe self-assigned this May 6, 2025
@castastrophe castastrophe marked this pull request as ready for review May 6, 2025 17:44
@castastrophe castastrophe requested a review from a team as a code owner May 6, 2025 17:44
@castastrophe castastrophe requested review from TarunAdobe and removed request for a team May 6, 2025 17:48
@castastrophe castastrophe force-pushed the castastrophe/swc-808-disable-process-spectrum branch from 8a82d29 to 555d6a7 Compare May 6, 2025 17:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants