Skip to content

Commit 2592754

Browse files
authored
chore: update compare script to fix an issue when runs are parallelized (#2405)
1 parent e28f5da commit 2592754

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,12 @@ This project is leveraging caching from [Nx](https://nx.dev/) to speed up the bu
337337

338338
This project includes several small scripts to help with common tasks.
339339

340-
- `yarn compare`: This compares the current version of components with the previous versions published to NPM and output a list of all the changes that have been made. This is useful for reviewing changes before a release. The information is provided in the command-line output as well as in a simple web page that is opened in your default browser upon completion. The web page includes links to the visual diffs for each component when the file sizes have changed. Components with no changes are not included in the output.
340+
- `yarn compare`: This compares the current version of components with the previous versions published to NPM and output a list of all the changes that have been made. This is useful for reviewing changes before a release. The information is provided in the command-line output as well as in a simple web page that is opened in your default browser upon completion. The web page includes links to the visual diffs for each component when the file sizes have changed.
341+
- Components with no changes are not included in the output.
342+
- To run comparisons on one or multiple components, `yarn compare` accepts a list of components as arguments. For example, `yarn compare button` will compare the current version of the button component with the previous version published to NPM. `yarn compare button checkbox` will compare the current version of the button and checkbox components with the previous versions published to NPM.
343+
- Named components should be space-separated.
344+
- Running `yarn compare` with no inputs will automatically run against all packages.
345+
- **Note** that you must run `yarn build` before running `yarn compare` to ensure that the latest build is being compared.
341346
- `yarn refresh:env`: This copies values for the project's `.env` file (an asset never committed to the repo as it contains login secrets) by using the `.env.example` file as a template. This script is useful when you need to update the `.env` file with new values from the `.env.example` file or when you checkout or clean the repo and need to restore the `.env` file.
342347
- `yarn refresh:directory`: This will remove any deprecated package folders that are no longer in use. The goal is to make migrating to a new project architecture easier for the most number of users.
343348
- `yarn lint:components`: Provides helpful updates and warnings for a component's package.json file. This helps keep all components in alignment.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"clean:docs": "rimraf dist",
2828
"clean:preview": "nx clean storybook",
2929
"cleaner": "nx run-many --target clean --projects",
30-
"compare": "nx run-many --verbose --target compare --projects",
30+
"compare": "node ./tasks/compare-compiled-output.js",
3131
"predev": "nx run-many --projects ui-icons,tokens --target build",
3232
"dev": "NODE_ENV=development BROWSERSYNC_OPEN=true gulp dev",
3333
"preinstall": "command -v nvm >/dev/null 2>&1 && nvm use || exit 0",

tasks/compare-compiled-output.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ async function processComponent(
136136
if (!component) return Promise.reject("No component specified.");
137137

138138
cleanAndMkdir(join(output, "diffs", component));
139-
cleanAndMkdir(join(output, "latest"));
139+
cleanAndMkdir(join(pathing.latest, component));
140140

141141
const pkgPath = require.resolve(`@spectrum-css/${component}/package.json`) ?? join(cwd, component, "package.json");
142142
const pkg = pkgPath && existsSync(pkgPath)
@@ -213,18 +213,18 @@ async function processComponent(
213213
await tar
214214
.extract({
215215
file: tarballPath,
216-
cwd: join(output, "latest"),
216+
cwd: join(pathing.latest, component),
217217
// Only unpack the dist folder
218218
filter: (path) => path.startsWith("package/dist"),
219219
strip: 2,
220220
})
221221
.catch((err) => warnings.push(err));
222222
}
223223

224-
if (existsSync(join(output, "latest"))) {
224+
if (existsSync(join(pathing.latest, component))) {
225225
const files =
226226
(await fg("**/*.css", {
227-
cwd: join(output, "latest"),
227+
cwd: join(pathing.latest, component),
228228
})) ?? [];
229229

230230
if (files.length > 0) found++;
@@ -251,7 +251,7 @@ async function processComponent(
251251
processFile(
252252
filename,
253253
join(cwd, component, "dist"),
254-
join(output, "latest")
254+
join(pathing.latest, component)
255255
)
256256
)
257257
).then((results) => {

0 commit comments

Comments
 (0)