Skip to content

Commit 72fabca

Browse files
authored
chore: Update to Node 20 (#6385)
* Update to Node 22 * go to node 20 instead * fix formatting test * run verdaccio build * turn off verdaccio build * try limiting concurrent tests * try to debug on ci where error happens more * keep debugging * try a longer timeout * remove debugging * turn on verdaccio build * fix lint * update yarn lock * fix verdaccio and tsdiffer * fix node corepack * fix forkpoint * try to fix buildWebsite * turn verdaccio build back off * fix rebase * turn on verdaccio on CI * turn off verdaccio again and remove concurrency restriction * turn back on verdaccio * fix spectrum-css local builder * remove obselete patch * fix lint and flakey ssr * remove verdaccio * update to latest node 20 * remove leftovers
1 parent b0c0454 commit 72fabca

File tree

20 files changed

+981
-3335
lines changed

20 files changed

+981
-3335
lines changed

.circleci/config.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,22 @@ orbs:
1919
executors:
2020
rsp:
2121
docker:
22-
- image: cimg/node:18.20.3
22+
- image: cimg/node:20.18.2
2323
environment:
2424
CACHE_VERSION: v1
2525
working_directory: ~/react-spectrum
2626

2727
rsp-large:
2828
docker:
29-
- image: cimg/node:18.20.3
29+
- image: cimg/node:20.18.2
3030
resource_class: large
3131
environment:
3232
CACHE_VERSION: v1
3333
working_directory: ~/react-spectrum
3434

3535
rsp-xlarge:
3636
docker:
37-
- image: cimg/node:18.20.3
37+
- image: cimg/node:20.18.2
3838
resource_class: xlarge
3939
environment:
4040
CACHE_VERSION: v1

.github/actions/branch/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: 'Branch from fork'
22
description: 'creates a branch based off PR from fork'
33
runs:
4-
using: 'node18'
4+
using: 'node20'
55
main: 'index.js'

.github/actions/comment/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: 'PR Comment'
22
description: 'Comment on the PR attached to a commit'
33
runs:
4-
using: 'node12'
4+
using: 'node20'
55
main: 'index.js'
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: 'Check permissions'
22
description: 'Checks if commentor has write access or above'
33
runs:
4-
using: 'node18'
4+
using: 'node20'
55
main: 'index.js'

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
18.*
1+
20.*

examples/remix/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"vite-tsconfig-paths": "^4.2.1"
3131
},
3232
"engines": {
33-
"node": ">=18.0.0"
33+
"node": ">=20.0.0"
3434
},
3535
"workspaces": [
3636
"../../packages/react-aria-components",

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"test-storybook": "test-storybook --url http://localhost:9003 --browsers chromium --no-cache",
3434
"test:docs": "yarn playwright install && node scripts/testDocs.js",
3535
"build": "make build",
36-
"test:ssr": "cross-env STRICT_MODE=1 yarn jest --config jest.ssr.config.js",
36+
"test:ssr": "cross-env STRICT_MODE=1 yarn jest --runInBand --config jest.ssr.config.js",
3737
"ci-test": "cross-env STRICT_MODE=1 yarn jest --maxWorkers=2 && cross-env STRICT_MODE=1 yarn test:ssr --runInBand",
3838
"lint": "concurrently \"yarn check-types\" \"eslint packages\" \"node scripts/lint-packages.js\" \"yarn constraints\"",
3939
"jest": "jest",
@@ -101,7 +101,7 @@
101101
"@parcel/transformer-svg-react": "^2.14.0",
102102
"@parcel/transformer-typescript-types": "^2.14.0",
103103
"@react-spectrum/s2-icon-builder": "^0.2.0",
104-
"@spectrum-css/component-builder": "1.0.1",
104+
"@spectrum-css/component-builder": "workspace:^",
105105
"@spectrum-css/vars": "^2.3.0",
106106
"@storybook/addon-a11y": "patch:@storybook/addon-a11y@npm%3A^7.6.19#~/.yarn/patches/@storybook-addon-a11y-npm-7.6.19-04b470eae0.patch",
107107
"@storybook/addon-actions": "^7.6.19",
Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
/*
2+
Copyright 2019 Adobe. All rights reserved.
3+
This file is licensed to you under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License. You may obtain a copy
5+
of the License at http://www.apache.org/licenses/LICENSE-2.0
6+
7+
Unless required by applicable law or agreed to in writing, software distributed under
8+
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9+
OF ANY KIND, either express or implied. See the License for the specific language
10+
governing permissions and limitations under the License.
11+
*/
12+
13+
const gulp = require('gulp');
14+
const postcss = require('postcss');
15+
const concat = require('gulp-concat');
16+
const through = require('through2');
17+
const fsp = require('fs').promises;
18+
const logger = require('gulplog');
19+
const path = require('path');
20+
21+
function getVarsFromCSS(css) {
22+
let variableList = [];
23+
let root = postcss.parse(css);
24+
25+
root.walkRules((rule, ruleIndex) => {
26+
rule.walkDecls((decl) => {
27+
let matches = decl.value.match(/var\(.*?\)/g);
28+
if (matches) {
29+
matches.forEach(function (match) {
30+
let varName = match.replace(/var\((--[\w-]+),?.*?\)/, '$1').trim();
31+
if (variableList.indexOf(varName) === -1) {
32+
variableList.push(varName);
33+
}
34+
});
35+
}
36+
});
37+
});
38+
return variableList;
39+
}
40+
41+
function getVarValues(css) {
42+
let root = postcss.parse(css);
43+
let variables = {};
44+
45+
root.walkRules((rule, ruleIndex) => {
46+
rule.walkDecls((decl) => {
47+
variables[decl.prop] = decl.value;
48+
});
49+
});
50+
51+
return variables;
52+
}
53+
54+
function getClassNames(contents, pkgName) {
55+
let classNames = [];
56+
57+
if (classNames.length === 0) {
58+
logger.error(`Could not find classNames for ${pkgName}, assuming no classNames`);
59+
classNames.push('');
60+
}
61+
62+
logger.debug(`Found classNames ${classNames.join(', ')} for ${pkgName}`);
63+
64+
return classNames;
65+
}
66+
67+
function resolveValue(value, vars) {
68+
if (value) {
69+
let match = value.match(/var\((.+),?.*?\)/);
70+
if (match) {
71+
return match[1];
72+
}
73+
return value;
74+
}
75+
}
76+
77+
const varDir = path.join(path.dirname(require.resolve('@spectrum-css/vars')), '..');
78+
79+
async function readDNAVariables(file) {
80+
let css = await fsp.readFile(path.join(varDir, 'css', file));
81+
let vars = getVarValues(css);
82+
return vars;
83+
}
84+
85+
function getVariableDeclarations(classNames, vars) {
86+
let varNames = Object.keys(vars);
87+
if (varNames.length) {
88+
return `
89+
${classNames.map((className) => `${className}`).join(',\n')} {
90+
${varNames.map((varName) => ` ${varName}: ${vars[varName]};`).join('\n')}
91+
}
92+
`;
93+
}
94+
95+
return '';
96+
}
97+
98+
function getAllVars() {
99+
return new Promise((resolve, reject) => {
100+
let variableList;
101+
102+
gulp.src([
103+
`${varDir}/css/themes/*.css`,
104+
`${varDir}/css/scales/*.css`,
105+
`${varDir}/css/components/*.css`,
106+
`${varDir}/css/globals/*.css`
107+
])
108+
.pipe(concat('everything.css'))
109+
.pipe(through.obj(function getAllVars(file, enc, cb) {
110+
variableList = getVarValues(file.contents.toString());
111+
112+
cb(null, file);
113+
}))
114+
.on('finish', () => {
115+
resolve(variableList);
116+
})
117+
.on('error', reject);
118+
});
119+
}
120+
121+
function getAllComponentVars() {
122+
return new Promise((resolve, reject) => {
123+
let variableList;
124+
125+
gulp.src([
126+
`${varDir}/css/components/*.css`,
127+
`${varDir}/css/globals/*.css`
128+
])
129+
.pipe(concat('everything.css'))
130+
.pipe(through.obj(function getAllVars(file, enc, cb) {
131+
variableList = getVarValues(file.contents.toString());
132+
133+
cb(null, file);
134+
}))
135+
.on('finish', () => {
136+
resolve(variableList);
137+
})
138+
.on('error', reject);
139+
});
140+
}
141+
142+
exports.getAllComponentVars = getAllComponentVars;
143+
exports.getAllVars = getAllVars;
144+
exports.getVarsFromCSS = getVarsFromCSS;
145+
exports.getVarValues = getVarValues;
146+
exports.getClassNames = getClassNames;
147+
exports.resolveValue = resolveValue;
148+
exports.readDNAVariables = readDNAVariables;
149+
exports.getVariableDeclarations = getVariableDeclarations;
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
/*
2+
Copyright 2019 Adobe. All rights reserved.
3+
This file is licensed to you under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License. You may obtain a copy
5+
of the License at http://www.apache.org/licenses/LICENSE-2.0
6+
7+
Unless required by applicable law or agreed to in writing, software distributed under
8+
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9+
OF ANY KIND, either express or implied. See the License for the specific language
10+
governing permissions and limitations under the License.
11+
*/
12+
var valueParser = require('postcss-value-parser');
13+
let varUtils = require('../lib/varUtils.js');
14+
15+
// match custom property inclusions
16+
const customPropertiesRegExp = /(^|[^\w-])var\([\W\w]+\)/;
17+
18+
let staticVars;
19+
let allVars;
20+
async function fetchVars() {
21+
if (staticVars && allVars) {
22+
return true;
23+
}
24+
25+
// Read in all static vars
26+
staticVars = Object.assign(
27+
{},
28+
await varUtils.readDNAVariables('globals/spectrum-staticAliases.css'),
29+
await varUtils.readDNAVariables('globals/spectrum-fontGlobals.css'),
30+
await varUtils.readDNAVariables('globals/spectrum-fontGlobals.css'),
31+
await varUtils.readDNAVariables('globals/spectrum-dimensionGlobals.css'),
32+
await varUtils.readDNAVariables('globals/spectrum-colorGlobals.css'),
33+
await varUtils.readDNAVariables('globals/spectrum-animationGlobals.css')
34+
);
35+
36+
// Read in all variables so we have the value they resolve to
37+
allVars = await varUtils.getAllComponentVars();
38+
39+
return true;
40+
}
41+
42+
let fetchVarsPromise;
43+
module.exports = function () {
44+
return {
45+
postcssPlugin: 'postcss-custom-properties-mapping',
46+
OnceExit: async function (root, result) {
47+
fetchVarsPromise ??= fetchVars();
48+
await fetchVarsPromise;
49+
50+
root.walkRules((rule, ruleIndex) => {
51+
rule.walkDecls((decl) => {
52+
if (customPropertiesRegExp.test(decl.value)) {
53+
let value = valueParser(decl.value);
54+
55+
value.walk((node, index, nodes) => {
56+
if (node.type === 'function' && node.value === 'var') {
57+
let v = node.nodes[0].value;
58+
59+
// If the value is static, replace the variable with the value.
60+
// Otherwise, change the variable name to the mapped name.
61+
if (staticVars[v]) {
62+
nodes.splice(index, 1, ...valueParser(`var(${v}, ${staticVars[v]})`).nodes);
63+
} else if (allVars[v]) {
64+
nodes.splice(index, 1, ...valueParser(`var(${v}, ${allVars[v]})`).nodes);
65+
}
66+
}
67+
});
68+
69+
decl.value = value.toString();
70+
}
71+
});
72+
});
73+
}
74+
};
75+
};
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
Copyright 2019 Adobe. All rights reserved.
3+
This file is licensed to you under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License. You may obtain a copy
5+
of the License at http://www.apache.org/licenses/LICENSE-2.0
6+
7+
Unless required by applicable law or agreed to in writing, software distributed under
8+
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9+
OF ANY KIND, either express or implied. See the License for the specific language
10+
governing permissions and limitations under the License.
11+
*/
12+
13+
module.exports = function (opts) {
14+
opts = opts || {};
15+
16+
return function (root, result) {
17+
root.walkRules((rule, ruleIndex) => {
18+
rule.walkDecls((decl) => {
19+
if (decl.value.match('xvar(.*?)')) {
20+
decl.value = decl.value.substr(1);
21+
}
22+
if (decl.prop.substr(0, 3) === 'x--') {
23+
decl.prop = decl.prop.substr(1);
24+
}
25+
});
26+
});
27+
};
28+
};

0 commit comments

Comments
 (0)