Skip to content

Commit 1bd7004

Browse files
committed
Merge branch 'main' of github.com:adobe/react-spectrum into autocomplete_audit_for_release
2 parents 675c41f + 50c7ada commit 1bd7004

File tree

102 files changed

+2421
-1052
lines changed

Some content is hidden

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

102 files changed

+2421
-1052
lines changed

.storybook-s2/docs/Illustrations.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export function Illustrations() {
3636
size="XS"
3737
isQuiet
3838
aria-label="Copy"
39-
onPress={() => navigator.clipboard.writeText(`import ${name} from '@react-spectrum/s2/illustrations/${gradientStyle}/${icon}';`)}>
39+
onPress={() => navigator.clipboard.writeText(`import ${name} from '@react-spectrum/s2/illustrations/gradient/${gradientStyle}/${icon}';`)}>
4040
<Paste />
4141
</ActionButton>
4242
</span>

.storybook-s2/docs/StyleMacro.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ export function StyleMacro() {
130130
<li className={style({font: 'code-xl'})}>code-xl</li>
131131
</ul>
132132
</div>
133-
<InlineAlert variant="notice" styles={style({maxWidth: '[600px]'})}>
133+
<InlineAlert variant="notice" styles={style({maxWidth: 600})}>
134134
<Heading>Important Note</Heading>
135135
<Content>Only use <code className={style({font: 'code-xs', backgroundColor: 'layer-1', paddingX: 2, borderWidth: 1, borderColor: 'gray-100', borderStyle: 'solid', borderRadius: 'sm'})}>{'<Heading>'}</code> and <code className={style({font: 'code-xs', backgroundColor: 'layer-1', paddingX: 2, borderWidth: 1, borderColor: 'gray-100', borderStyle: 'solid', borderRadius: 'sm'})}>{'<Text>'}</code> inside other Spectrum components with predefined styles, such as <code className={style({font: 'code-xs', backgroundColor: 'layer-1', paddingX: 2, borderWidth: 1, borderColor: 'gray-100', borderStyle: 'solid', borderRadius: 'sm'})}>{'<Dialog>'}</code> and <code className={style({font: 'code-xs', backgroundColor: 'layer-1', paddingX: 2, borderWidth: 1, borderColor: 'gray-100', borderStyle: 'solid', borderRadius: 'sm'})}>{'<MenuItem>'}</code>. They do not include any styles by default, and should not be used standalone. Use HTML elements with the style macro directly instead.</Content>
136136
</InlineAlert>

.yarn/plugins/plugin-nightly-prep.js

Lines changed: 301 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,301 @@
1+
// From https://github.com/yarnpkg/berry/blob/master/packages/plugin-version/sources/commands/version/apply.ts in accordance with the BSD license, see Notice.txt
2+
3+
const Decision = {
4+
UNDECIDED: 'undecided',
5+
DECLINE: 'decline',
6+
MAJOR: 'major',
7+
MINOR: 'minor',
8+
PATCH: 'patch',
9+
PRERELEASE: 'prerelease'
10+
};
11+
12+
module.exports = {
13+
name: `plugin-nightly-prep`,
14+
factory: require => {
15+
const {PortablePath, npath, ppath, xfs} = require('@yarnpkg/fslib');
16+
const {BaseCommand} = require(`@yarnpkg/cli`);
17+
const {Project, Configuration, Cache, StreamReport, structUtils, Manifest, miscUtils, MessageName, WorkspaceResolver} = require(`@yarnpkg/core`);
18+
const {Command, Option} = require(`clipanion`);
19+
const {parseSyml, stringifySyml} = require(`@yarnpkg/parsers`);
20+
21+
class NightlyPrepCommand extends BaseCommand {
22+
static paths = [[`apply-nightly`]];
23+
24+
// Show descriptive usage for a --help argument passed to this command
25+
static usage = Command.Usage({
26+
description: `apply nightly version bumps`,
27+
details: `
28+
This command will update all references in every workspace package json to point to the exact nightly version, no range.
29+
`,
30+
examples: [[
31+
`yarn apply-nightly`,
32+
]],
33+
});
34+
35+
all = Option.Boolean(`--all`, false, {
36+
description: `Apply the deferred version changes on all workspaces`,
37+
});
38+
39+
async execute() {
40+
const configuration = await Configuration.find(this.context.cwd, this.context.plugins);
41+
const {project, workspace} = await Project.find(configuration, this.context.cwd);
42+
const cache = await Cache.find(configuration);
43+
44+
const applyReport = await StreamReport.start({
45+
configuration,
46+
json: this.json,
47+
stdout: this.context.stdout,
48+
}, async report => {
49+
const prerelease = this.prerelease
50+
? typeof this.prerelease !== `boolean` ? this.prerelease : `rc.%n`
51+
: null;
52+
53+
const allReleases = await resolveVersionFiles(project, xfs, ppath, parseSyml, structUtils, {prerelease});
54+
let filteredReleases = new Map();
55+
56+
if (this.all) {
57+
filteredReleases = allReleases;
58+
} else {
59+
const relevantWorkspaces = this.recursive
60+
? workspace.getRecursiveWorkspaceDependencies()
61+
: [workspace];
62+
63+
for (const child of relevantWorkspaces) {
64+
const release = allReleases.get(child);
65+
if (typeof release !== `undefined`) {
66+
filteredReleases.set(child, release);
67+
}
68+
}
69+
}
70+
71+
if (filteredReleases.size === 0) {
72+
const protip = allReleases.size > 0
73+
? ` Did you want to add --all?`
74+
: ``;
75+
76+
report.reportWarning(MessageName.UNNAMED, `The current workspace doesn't seem to require a version bump.${protip}`);
77+
return;
78+
}
79+
80+
applyReleases(project, filteredReleases, Manifest, miscUtils, structUtils, MessageName, npath, WorkspaceResolver, {report});
81+
82+
if (!this.dryRun) {
83+
if (!prerelease) {
84+
if (this.all) {
85+
await clearVersionFiles(project, xfs);
86+
} else {
87+
await updateVersionFiles(project, [...filteredReleases.keys()], xfs, parseSyml, stringifySyml, structUtils);
88+
}
89+
}
90+
91+
report.reportSeparator();
92+
}
93+
});
94+
95+
if (this.dryRun || applyReport.hasErrors())
96+
return applyReport.exitCode();
97+
98+
return await project.installWithNewReport({
99+
json: this.json,
100+
stdout: this.context.stdout,
101+
}, {
102+
cache,
103+
});
104+
}
105+
}
106+
107+
return {
108+
commands: [
109+
NightlyPrepCommand,
110+
],
111+
};
112+
}
113+
};
114+
115+
async function resolveVersionFiles(project, xfs, ppath, parseSyml, structUtils, miscUtils, {prerelease = null} = {}) {
116+
let candidateReleases = new Map();
117+
118+
const deferredVersionFolder = project.configuration.get(`deferredVersionFolder`);
119+
if (!xfs.existsSync(deferredVersionFolder))
120+
return candidateReleases;
121+
122+
const deferredVersionFiles = await xfs.readdirPromise(deferredVersionFolder);
123+
124+
for (const entry of deferredVersionFiles) {
125+
if (!entry.endsWith(`.yml`))
126+
continue;
127+
128+
const versionPath = ppath.join(deferredVersionFolder, entry);
129+
const versionContent = await xfs.readFilePromise(versionPath, `utf8`);
130+
const versionData = parseSyml(versionContent);
131+
132+
133+
for (const [identStr, decision] of Object.entries(versionData.releases || {})) {
134+
if (decision === Decision.DECLINE)
135+
continue;
136+
137+
const ident = structUtils.parseIdent(identStr);
138+
139+
const workspace = project.tryWorkspaceByIdent(ident);
140+
if (workspace === null)
141+
throw new Error(`Assertion failed: Expected a release definition file to only reference existing workspaces (${ppath.basename(versionPath)} references ${identStr})`);
142+
143+
if (workspace.manifest.version === null)
144+
throw new Error(`Assertion failed: Expected the workspace to have a version (${structUtils.prettyLocator(project.configuration, workspace.anchoredLocator)})`);
145+
146+
// If there's a `stableVersion` field, then we assume that `version`
147+
// contains a prerelease version and that we need to base the version
148+
// bump relative to the latest stable instead.
149+
const baseVersion = workspace.manifest.raw.stableVersion ?? workspace.manifest.version;
150+
const suggestedRelease = applyStrategy(baseVersion, validateReleaseDecision(decision, miscUtils), miscUtils);
151+
152+
if (suggestedRelease === null)
153+
throw new Error(`Assertion failed: Expected ${baseVersion} to support being bumped via strategy ${decision}`);
154+
155+
const bestRelease = suggestedRelease;
156+
157+
candidateReleases.set(workspace, bestRelease);
158+
}
159+
}
160+
161+
if (prerelease) {
162+
candidateReleases = new Map([...candidateReleases].map(([workspace, release]) => {
163+
return [workspace, applyPrerelease(release, {current: workspace.manifest.version, prerelease})];
164+
}));
165+
}
166+
167+
return candidateReleases;
168+
}
169+
170+
function applyReleases(project, newVersions, Manifest, miscUtils, structUtils, MessageName, npath, WorkspaceResolver, {report}) {
171+
const allDependents = new Map();
172+
173+
// First we compute the reverse map to figure out which workspace is
174+
// depended upon by which other.
175+
//
176+
// Note that we need to do this before applying the new versions,
177+
// otherwise the `findWorkspacesByDescriptor` calls won't be able to
178+
// resolve the workspaces anymore (because the workspace versions will
179+
// have changed and won't match the outdated dependencies).
180+
181+
for (const dependent of project.workspaces) {
182+
for (const set of Manifest.allDependencies) {
183+
for (const descriptor of dependent.manifest[set].values()) {
184+
const workspace = project.tryWorkspaceByDescriptor(descriptor);
185+
if (workspace === null)
186+
continue;
187+
188+
// We only care about workspaces that depend on a workspace that will
189+
// receive a fresh update
190+
if (!newVersions.has(workspace))
191+
continue;
192+
193+
const dependents = miscUtils.getArrayWithDefault(allDependents, workspace);
194+
dependents.push([dependent, set, descriptor.identHash]);
195+
}
196+
}
197+
}
198+
199+
// Now that we know which workspaces depend on which others, we can
200+
// proceed to update everything at once using our accumulated knowledge.
201+
202+
for (const [workspace, newVersion] of newVersions) {
203+
const oldVersion = workspace.manifest.version;
204+
workspace.manifest.version = newVersion;
205+
206+
const identString = workspace.manifest.name !== null
207+
? structUtils.stringifyIdent(workspace.manifest.name)
208+
: null;
209+
210+
report.reportInfo(MessageName.UNNAMED, `${structUtils.prettyLocator(project.configuration, workspace.anchoredLocator)}: Bumped to ${newVersion}`);
211+
report.reportJson({cwd: npath.fromPortablePath(workspace.cwd), ident: identString, oldVersion, newVersion});
212+
213+
const dependents = allDependents.get(workspace);
214+
if (typeof dependents === `undefined`)
215+
continue;
216+
217+
for (const [dependent, set, identHash] of dependents) {
218+
const descriptor = dependent.manifest[set].get(identHash);
219+
if (typeof descriptor === `undefined`)
220+
throw new Error(`Assertion failed: The dependency should have existed`);
221+
222+
let range = descriptor.range;
223+
let useWorkspaceProtocol = false;
224+
225+
if (range.startsWith(WorkspaceResolver.protocol)) {
226+
range = range.slice(WorkspaceResolver.protocol.length);
227+
useWorkspaceProtocol = true;
228+
229+
// Workspaces referenced through their path never get upgraded ("workspace:packages/yarnpkg-core")
230+
if (range === workspace.relativeCwd) {
231+
continue;
232+
}
233+
}
234+
235+
let newRange = `${newVersion}`;
236+
if (useWorkspaceProtocol)
237+
newRange = `${WorkspaceResolver.protocol}${newRange}`;
238+
239+
const newDescriptor = structUtils.makeDescriptor(descriptor, newRange);
240+
dependent.manifest[set].set(identHash, newDescriptor);
241+
}
242+
}
243+
}
244+
245+
async function clearVersionFiles(project, xfs) {
246+
const deferredVersionFolder = project.configuration.get(`deferredVersionFolder`);
247+
if (!xfs.existsSync(deferredVersionFolder))
248+
return;
249+
250+
await xfs.removePromise(deferredVersionFolder);
251+
}
252+
253+
async function updateVersionFiles(project, workspaces, xfs, parseSyml, stringifySyml, structUtils) {
254+
const workspaceSet = new Set(workspaces);
255+
256+
const deferredVersionFolder = project.configuration.get(`deferredVersionFolder`);
257+
if (!xfs.existsSync(deferredVersionFolder))
258+
return;
259+
260+
const deferredVersionFiles = await xfs.readdirPromise(deferredVersionFolder);
261+
262+
for (const entry of deferredVersionFiles) {
263+
if (!entry.endsWith(`.yml`))
264+
continue;
265+
266+
const versionPath = ppath.join(deferredVersionFolder, entry);
267+
const versionContent = await xfs.readFilePromise(versionPath, `utf8`);
268+
const versionData = parseSyml(versionContent);
269+
270+
const releases = versionData?.releases;
271+
if (!releases)
272+
continue;
273+
274+
for (const locatorStr of Object.keys(releases)) {
275+
const ident = structUtils.parseIdent(locatorStr);
276+
const workspace = project.tryWorkspaceByIdent(ident);
277+
278+
if (workspace === null || workspaceSet.has(workspace)) {
279+
delete versionData.releases[locatorStr];
280+
}
281+
}
282+
283+
if (Object.keys(versionData.releases).length > 0) {
284+
await xfs.changeFilePromise(versionPath, stringifySyml(
285+
new stringifySyml.PreserveOrdering(
286+
versionData,
287+
),
288+
));
289+
} else {
290+
await xfs.unlinkPromise(versionPath);
291+
}
292+
}
293+
}
294+
295+
function applyStrategy(version, strategy) {
296+
return strategy;
297+
}
298+
299+
function validateReleaseDecision(decision, miscUtils) {
300+
return decision;
301+
}

.yarnrc.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,6 @@ unsafeHttpWhitelist:
99
- localhost
1010

1111
yarnPath: .yarn/releases/yarn-4.2.2.cjs
12+
13+
plugins:
14+
- .yarn/plugins/plugin-nightly-prep.js

NOTICE.txt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,3 +192,22 @@ This codebase contains a modified portion of code from the TC39 Temporal proposa
192192
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
193193
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
194194
SUCH DAMAGE.
195+
196+
197+
-------------------------------------------------------------------------------
198+
This codebase contains a modified portion of code from Yarn berry which can be obtained at:
199+
* SOURCE:
200+
* https://github.com/yarnpkg/berry
201+
202+
* LICENSE:
203+
BSD 2-Clause License
204+
205+
Copyright (c) 2016-present, Yarn Contributors. All rights reserved.
206+
207+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
208+
209+
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
210+
211+
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
212+
213+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
"chromatic:forced-colors": "NODE_ENV=production CHROMATIC=1 chromatic --project-token $CHROMATIC_FC_PROJECT_TOKEN --build-script-name 'build:chromatic-fc'",
4747
"merge:css": "babel-node --presets @babel/env ./scripts/merge-spectrum-css.js",
4848
"release": "lerna publish from-package --yes",
49-
"version:nightly": "yarn workspaces foreach --all --no-private -t version -d 3.0.0-nightly-$(git rev-parse --short HEAD)-$(date +'%y%m%d') && yarn version apply --all",
49+
"version:nightly": "yarn workspaces foreach --all --no-private -t version -d 3.0.0-nightly-$(git rev-parse --short HEAD)-$(date +'%y%m%d') && yarn apply-nightly --all",
5050
"publish:nightly": "yarn workspaces foreach --all --no-private -t npm publish --tag nightly --access public",
5151
"build:api-published": "node scripts/buildPublishedAPI.js",
5252
"build:api-branch": "node scripts/buildBranchAPI.js",

packages/@internationalized/date/src/string.ts

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -234,16 +234,14 @@ export function parseDuration(value: string): Required<DateTimeDuration> {
234234

235235
const parseDurationGroup = (
236236
group: string | undefined,
237-
isNegative: boolean,
238-
min: number,
239-
max: number
237+
isNegative: boolean
240238
): number => {
241239
if (!group) {
242240
return 0;
243241
}
244242
try {
245243
const sign = isNegative ? -1 : 1;
246-
return sign * parseNumber(group.replace(',', '.'), min, max);
244+
return sign * Number(group.replace(',', '.'));
247245
} catch {
248246
throw new Error(`Invalid ISO 8601 Duration string: ${value}`);
249247
}
@@ -267,13 +265,13 @@ export function parseDuration(value: string): Required<DateTimeDuration> {
267265
}
268266

269267
const duration: Mutable<DateTimeDuration> = {
270-
years: parseDurationGroup(match.groups?.years, isNegative, 0, 9999),
271-
months: parseDurationGroup(match.groups?.months, isNegative, 0, 12),
272-
weeks: parseDurationGroup(match.groups?.weeks, isNegative, 0, Infinity),
273-
days: parseDurationGroup(match.groups?.days, isNegative, 0, 31),
274-
hours: parseDurationGroup(match.groups?.hours, isNegative, 0, 23),
275-
minutes: parseDurationGroup(match.groups?.minutes, isNegative, 0, 59),
276-
seconds: parseDurationGroup(match.groups?.seconds, isNegative, 0, 59)
268+
years: parseDurationGroup(match.groups?.years, isNegative),
269+
months: parseDurationGroup(match.groups?.months, isNegative),
270+
weeks: parseDurationGroup(match.groups?.weeks, isNegative),
271+
days: parseDurationGroup(match.groups?.days, isNegative),
272+
hours: parseDurationGroup(match.groups?.hours, isNegative),
273+
minutes: parseDurationGroup(match.groups?.minutes, isNegative),
274+
seconds: parseDurationGroup(match.groups?.seconds, isNegative)
277275
};
278276

279277
if (duration.hours !== undefined && ((duration.hours % 1) !== 0) && (duration.minutes || duration.seconds)) {

0 commit comments

Comments
 (0)