Skip to content

Commit c9608e5

Browse files
committed
chore: process-spectrum part 1 [swc-808]
1 parent 25bc2cf commit c9608e5

File tree

10 files changed

+16
-1674
lines changed

10 files changed

+16
-1674
lines changed

.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ custom-elements.json
3131
packages/*/src/**/*.css.js
3232
packages/*/custom-elements.json
3333
packages/**/*.js
34-
packages/**/spectrum-vars.json
3534
packages/**/*.js.map
3635
packages/**/*.d.ts
3736
packages/**/*.test-vrt.ts
@@ -50,7 +49,6 @@ projects/**/*.d.ts
5049

5150
tools/*/src/**/*.css.js
5251
tools/*/custom-elements.json
53-
tools/**/spectrum-vars.json
5452
tools/**/*.js
5553
tools/**/*.js.map
5654
tools/**/*.d.ts

.vscode/settings.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
22
"files.exclude": {
33
"**/*.css.ts": { "when": "$(basename)" },
4-
"packages/*/src/spectrum-vars.json": true,
54
"packages/**/*.js.map": true,
65
"packages/**/*.js": { "when": "$(basename).ts" },
76
"packages/**/*.dev.js": { "when": "$(basename).js" },

README.md

Lines changed: 16 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -77,48 +77,37 @@ In the case that you'd like to serve and test a static build of the documentatio
7777
yarn docs:build
7878
```
7979

80-
# Updating Spectrum CSS
81-
82-
There are two mechanisms for broadly updating SWC's Spectrum CSS dependencies:
83-
84-
- `yarn update:spectrum-css` brings all Spectrum CSS dependencies to 'latest'
85-
- `yarn update:spectrum-css:nonbreaking` brings them to the latest minor or patch version
86-
87-
We aim to keep Spectrum CSS as current as possible, to track the Spectrum design system closely.
88-
The `:nonbreaking` variant lets us release patch updates quickly in cases where more work is required to be compatible with 'latest.'
89-
90-
# Advanced development
80+
## Advanced development
9181

9282
There are several commands that can be useful in specific scenarios:
9383

9484
- `yarn build:clear-cache` to remove previously created artifacts of the `tsc build` process.
9585
- `yarn process-icons` to make sure that the most recent icons are included.
96-
- `yarn process-spectrum` to process the spectrum CSS style sources into the individual packages.
9786
- `yarn build` to make sure the available JS has been built from the current TS source.
9887

99-
## Linting
88+
### Linting
10089

10190
The project will be linted on a pre-commit hook, but you can also run the lint suite with `yarn lint`. It uses ESLint to lint the JS / TS files, and StyleLint to lint the CSS files.
10291

103-
### Dependency linting
92+
#### Dependency linting
10493

10594
There are downstream issues that can arise from multiple packages in this mono-repo using dependencies with mismatched version strings. By default, [changesets](https://opensource.adobe.com/spectrum-web-components/guides/writing-changesets/) will bump version numbers of internal dependencies when the various packages are published and the depended version is pointing to the latest release, which can help to mitigate this issue. Running `yarn lint:versions` will check that all version strings for each dependency match across the repo.
10695

10796
`yarn list:versions --fix` will modify the `package.json` files, updating all dependencies to the latest version available in the library — _a potentially dangerous operation_. If this is what you want to do when `yarn lint:versions` discovers mismatched versions, this step can greatly reduce the amount of work to achieve matching version numbers.
10897

109-
## Testing
98+
### Testing
11099

111-
### Unit tests
100+
#### Unit tests
112101

113102
Unit tests are run with [Web Test Runner](https://modern-web.dev/docs/test-runner/overview/) in Playwright using the Chai, Mocha and Sinon helper libraries. These tests can be executed with:
114103

115-
```
104+
```sh
116105
yarn test
117106
```
118107

119108
During development you may wish to use `yarn test:watch` to automatically build and re-run the test suites.
120109

121-
### Screenshot testing
110+
#### Screenshot testing
122111

123112
Note: visual regression is done automatically on pull requests via CircleCI; however, the following outlines how you can run these tests local to your machine.
124113

@@ -144,17 +133,17 @@ yarn test:visual vrt-${component name}-single
144133
eg: yarn test:visual vrt-accordion-single
145134
```
146135

147-
#### Screenshot coverage
136+
##### Screenshot coverage
148137

149138
Visual regression testing is done against screens derived from the exports of the `*.stories.js` files in each package. As you add packages or story files to existing packages, they will automatically be added to the visual regression suite and will require updating the cache key (outlined below).
150139

151-
#### Keeping CI assets updated
140+
##### Keeping CI assets updated
152141

153142
If you find the `visual-*` jobs failing on CircleCI for reasons that you expect (you've updated the Spectrum CSS dependencies, you've added new tests, etc.) then you will need to update the golden images cache key before your build will pass. You can review and share the diffs for a test pass via a URL shaped like `vrt--spectrum-wc.netlify.app/${branchName}`. Before updating the cache key, be sure that the updated caches are both complete (there are times when process errors prevent images from being correctly created or when certain test passes take longer than others) and appear as expected. If you agree with the updated cache content, update the golden images cache key as follows.
154143

155144
Your failing branch will have created a new cache with a key of `v1-golden-images-{{ .Revision }}-<< parameters.regression_color >>-<< parameters.regression_scale >>-<< parameters.dir >>-{{ epoch }}`. Here `{{ .Revision }}` outlines the git commit hash of the current CI pass. In `.circleci/config.yml`, you will use that to update the cache that is requested at the beginning of the `run-regressions` job. As part of the review site, the git commit hash will be listed in the side navigation UI for easy access, use this number to update the `current_golden_images_hash` paramater that appears as follows:
156145

157-
```
146+
```yaml
158147
parameters:
159148
current_golden_images_hash:
160149
type: string
@@ -163,18 +152,18 @@ parameters:
163152
164153
This will ensure that tests on this branch point to this cache key for at least the next 30 days (keep-alive time of caches on CircleCI). Once the branch is merged to `main`, a cache key of `v2-golden-images-main-<< parameters.regression_color >>-<< parameters.regression_scale >>-<< parameters.regression_dir >>-{{ epoch }}` will be created on each successful build of `main` that will be long-lived and act as the "fallback" once the revision keyed cache has expired.
165154

166-
## Benchmarking
155+
### Benchmarking
167156

168157
You can acquire current runtimes for the individual elements with:
169158

170-
```
159+
```sh
171160
yarn build:tests
172161
yarn test:bench
173162
```
174163

175164
This will run the defined [Tachometer](https://www.npmjs.com/package/tachometer) tests and report the current runtime cost of each individual element. When not making changes to the benchmarks on your local machine, you can skip `yarn build:tests` for later passes.
176165

177-
## Anatomy of a component
166+
### Anatomy of a component
178167

179168
There is extended documentation on adding a new component to the library in the [documentation site](https://opensource.adobe.com/spectrum-web-components/guides/generating-components). However, at a high level, you will be building the following structure:
180169

@@ -198,19 +187,19 @@ There is extended documentation on adding a new component to the library in the
198187

199188
For a list of component waiting to be implemented, visit our [`missing components`](https://github.com/adobe/spectrum-web-components/labels/missing%20components) tag.
200189

201-
## IDE Notes
190+
### IDE Notes
202191

203192
The build process compiles `.css` files using PostCSS and wraps them in the `lit-html` `css` template tag and writes out a `.css.ts` file for easy import into TypeScript files. This file should not be edited, and is ignored by `.gitignore`, but you may also wish to hide the files in your IDE.
204193

205-
# Contributing
194+
## Contributing
206195

207196
We'd be very grateful if you contributed to the project! Check out our [contribution guidelines](CONTRIBUTING.md) for more information.
208197

209198
<a name="patches"></a>
210199

211200
<details><summary><strong>Active patches</strong></summary>
212201

213-
### lru-cache
202+
#### lru-cache
214203

215204
The `lru-cache` leveraged by `@web/dev-server` can interact negatively with ARM based macOS machines causing a critical hang in the cache of transpiled file responses. This only effects development time operations and specifically effects the local test passes. To avoid this `[email protected]` has been patched to make its `set` method a noop, avoiding the caching process all together.
216205

package.json

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
"lint:versions": "node ./scripts/lint-versions.js",
4545
"new-package": "cd projects/templates && plop",
4646
"postcustom-element-json": "node ./tasks/run-check-cem.js",
47-
"postdocs:analyze": "node ./scripts/add-custom-properties.js --src=\"projects/documentation/custom-elements.json\"",
4847
"postinstall": "husky || true && patch-package",
4948
"postpublish": "yarn prepublish:react && yarn publish:react && yarn postpublish:react",
5049
"postpublish:react": "git reset --hard HEAD^ && git prune && rimraf react",
@@ -59,7 +58,6 @@
5958
"pretest:bench": "yarn build:tests && test -f test/benchmark/cli.js ||:",
6059
"pretest:visual": "yarn build && yarn build",
6160
"process-icons": "wireit",
62-
"process-spectrum": "wireit",
6361
"publish:react": "yarn changeset publish --no-git-tag --tag snapshot --no-push",
6462
"push-to-remote": "git add . && git commit -m \"chore: release new versions #publish\" && git push",
6563
"start": "yarn storybook",
@@ -83,9 +81,6 @@
8381
"test:watch": "yarn test:watch:focus unit",
8482
"test:watch:flags:focus": "yarn build && run-p build:watch \"test:start --watch --group {1} --config web-test-runner.config.ci-chromium-flags.js\" --",
8583
"test:watch:focus": "yarn build && run-p build:watch \"test:start --watch --group {1}\" --",
86-
"update:spectrum-css": "node ./scripts/update-spectrum-css.js --latest || yarn update:spectrum-css:cleanup",
87-
"update:spectrum-css:cleanup": "yarn --ignore-scripts && yarn process-spectrum && yarn lint",
88-
"update:spectrum-css:nonbreaking": "node ./scripts/update-spectrum-css.js || yarn update:spectrum-css:cleanup",
8984
"verify-build-artifacts": "node ./scripts/verify-build-artifacts.js",
9085
"vrt:preview": "yarn wds --config test/visual/wds-vrt.config.js",
9186
"vrt:quick-link": "yarn netlify deploy --alias=vrt --dir=projects/vrt-quick-link"
@@ -206,9 +201,6 @@
206201
},
207202
"build:css": {
208203
"command": "node ./tasks/build-css.js",
209-
"dependencies": [
210-
"process-spectrum"
211-
],
212204
"files": [
213205
"packages/**/*.css",
214206
"tools/**/*.css",
@@ -379,33 +371,6 @@
379371
"icons:workflow"
380372
]
381373
},
382-
"process-spectrum": {
383-
"command": "node ./scripts/spectrum-vars.js && node ./tasks/process-spectrum.js && node ./scripts/generate-tokens.js && yarn lint",
384-
"files": [
385-
"tasks/process-spectrum.js",
386-
"packages/**/spectrum-config.js",
387-
"tools/**/spectrum-config.js",
388-
"node_modules/@spectrum-css/**/index-vars.css",
389-
"scripts/generate-tokens.js",
390-
"scripts/generate-tokens-wrapper.js",
391-
"node_modules/@spectrum-css/**/*.css",
392-
"scripts/spectrum-vars.js",
393-
"tools/styles/package.json",
394-
".prettierrc.yaml",
395-
".stylelintrc.json"
396-
],
397-
"output": [
398-
"packages/*/src/spectrum-*.css",
399-
"tools/*/src/spectrum-*.css",
400-
"tools/styles/*.css",
401-
"tools/styles/express/*.css",
402-
"!tools/styles/scale-*.css",
403-
"!tools/styles/theme-*.css",
404-
"!tools/styles/express/scale-*.css",
405-
"!tools/styles/express/theme-*.css"
406-
],
407-
"clean": false
408-
},
409374
"storybook": {
410375
"command": "storybook dev -p 8080 -c storybook",
411376
"service": true,

projects/templates/plop-templates/spectrum-config.js.hbs

Lines changed: 0 additions & 25 deletions
This file was deleted.

scripts/add-custom-properties.js

Lines changed: 0 additions & 69 deletions
This file was deleted.

0 commit comments

Comments
 (0)