Skip to content

Commit 3179e76

Browse files
authored
Merge branch 'main' into patch-1
2 parents aa59a32 + 84f7774 commit 3179e76

File tree

205 files changed

+5706
-7532
lines changed

Some content is hidden

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

205 files changed

+5706
-7532
lines changed

.github/workflows/codeql-analysis.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333

3434
# Initializes the CodeQL tools for scanning.
3535
- name: Initialize CodeQL
36-
uses: github/codeql-action/init@e8893c57a1f3a2b659b6b55564fdfdbbd2982911
36+
uses: github/codeql-action/init@05963f47d870e2cb19a537396c1f668a348c7d8f
3737
with:
3838
languages: ${{ matrix.language }}
3939
# If you wish to specify custom queries, you can do so here or in a config file.
@@ -44,7 +44,7 @@ jobs:
4444
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
4545
# If this step fails, then you should remove it and run the build manually (see below)
4646
- name: Autobuild
47-
uses: github/codeql-action/autobuild@e8893c57a1f3a2b659b6b55564fdfdbbd2982911
47+
uses: github/codeql-action/autobuild@05963f47d870e2cb19a537396c1f668a348c7d8f
4848

4949
# ℹ️ Command-line programs to run using the OS shell.
5050
# 📚 https://git.io/JvXDl
@@ -58,4 +58,4 @@ jobs:
5858
# make release
5959

6060
- name: Perform CodeQL Analysis
61-
uses: github/codeql-action/analyze@e8893c57a1f3a2b659b6b55564fdfdbbd2982911
61+
uses: github/codeql-action/analyze@05963f47d870e2cb19a537396c1f668a348c7d8f

.github/workflows/scorecards-analysis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,6 @@ jobs:
4949

5050
# Upload the results to GitHub's code scanning dashboard.
5151
- name: "Upload to code-scanning"
52-
uses: github/codeql-action/upload-sarif@e8893c57a1f3a2b659b6b55564fdfdbbd2982911
52+
uses: github/codeql-action/upload-sarif@05963f47d870e2cb19a537396c1f668a348c7d8f
5353
with:
5454
sarif_file: results.sarif

.github/workflows/test.yml

+14-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ env:
2525

2626
jobs:
2727
test:
28-
name: Check excerpts and run tests
28+
name: Analyze and test code examples
2929
runs-on: ubuntu-latest
3030
strategy:
3131
fail-fast: false
@@ -51,6 +51,19 @@ jobs:
5151
run: dart run dart_site analyze-dart
5252
- name: Run Dart tests
5353
run: dart run dart_site test-dart
54+
55+
excerpts:
56+
name: Check if code excerpts are up to date
57+
runs-on: ubuntu-latest
58+
steps:
59+
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
60+
with:
61+
submodules: recursive
62+
- uses: dart-lang/setup-dart@fedb1266e91cf51be2fdb382869461a434b920a3
63+
with:
64+
sdk: stable
65+
- name: Fetch Dart packages
66+
run: dart pub get
5467
- name: Check if excerpts are up to date
5568
run: dart run dart_site refresh-excerpts --fail-on-update
5669

README.md

+34-21
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,15 @@ dart --version
6161

6262
#### Node.js
6363

64-
The latest stable LTS release of Node.js is required to build the site.
64+
The **latest** stable LTS release of Node.js is required to build the site.
6565
If you don't have Node.js or need to update, download your
6666
computer's corresponding version and follow the instructions
6767
from the [Node.js download archive][].
68-
If you prefer, you can use a version manager such as [nvm][].
68+
If you prefer, you can use a version manager such as [nvm][],
69+
and run `nvm install` from the repository's root directory.
6970

7071
If you already have Node installed, verify it's available on your path
71-
and already the latest stable version _(`20` or later)_:
72+
and already the latest stable version _(currently `20.10` or later)_:
7273

7374
```terminal
7475
node --version
@@ -137,60 +138,72 @@ following the instructions in [Get the prerequisites](#get-the-prerequisites).
137138
dart pub get
138139
```
139140

140-
3. From the root directory of the repository,
141-
enable [`corepack`][] to set up [`pnpm`][].
142-
`corepack` comes bundled with Node and `pnpm`
143-
is an alternative, efficient package manager for npm packages.
144-
If you already have `pnpm` installed or installed it a different way,
145-
you can skip the `corepack` commands.
141+
3. Install [`pnpm`][] using your preferred [installation method][pnpm-install].
142+
`pnpm` is an alternative, efficient package manager for npm packages.
143+
If you already have `pnpm`, verify you have the latest stable version.
144+
We recommend using [`corepack`][] to install and manage `pnpm` versions,
145+
since it is bundled with most installations of Node.
146+
147+
If you haven't used `corepack` before, you'll need to
148+
first enable it with `corepack enable`.
149+
Then, to install the correct `pnpm` version, from the
150+
root directory of the repository, run `corepack install`:
146151

147152
```terminal
148153
corepack enable
149154
corepack install
150155
```
151156

152157
4. Once you have `pnpm` installed and setup,
153-
fetch the site's npm dependencies.
154-
We recommend you use `pnpm`, but you can also use `npm`.
158+
fetch the site's npm dependencies using `pnpm install`.
159+
We highly recommend you use `pnpm`, but you can also use `npm`.
155160

156161
```terminal
157162
pnpm install
158163
```
159164

160-
5. From the root directory, serve the site locally.
165+
5. From the root directory, run the `dash_site` tool to
166+
validate your setup and learn about the available commands.
167+
168+
```terminal
169+
./dash_site --help
170+
```
171+
172+
6. From the root directory, serve the site locally.
161173

162174
```terminal
163-
dart run dart_site serve
175+
./dash_site serve
164176
```
165177

166178
This command generates and serves the site on a
167179
local port that's printed to your terminal.
168180

169-
6. View your changes in the browser by navigating to <http://localhost:4000>.
181+
7. View your changes in the browser by navigating to <http://localhost:4000>.
170182

171183
Note the port might be different if `4000` is taken.
172184

173-
To instead view the source of generated site files,
174-
check the `_site` directory.
185+
If you want to check the raw, generated HTML output and structure,
186+
view the `_site` directory in a file explorer or an IDE.
175187

176-
7. Make your changes to the local repo.
188+
8. Make your changes to the local repo.
177189

178190
The site should automatically rebuild on most changes, but if
179191
something doesn't update, exit the process and rerun the command.
180192
Improvements to this functionality are planned.
181193
Please open a new issue to track the issue if this occurs.
182194

183-
8. Commit your changes to the branch and submit your PR.
195+
9. Commit your changes to the branch and submit your PR.
184196

185197
If your change is large, or you'd like to test it,
186198
consider [validating your changes](#validate-your-changes).
187199

188200
> [!TIP]
189201
> To find additional commands that you can run,
190-
> run `dart run dart_site --help` from the repository's root directory.
202+
> run `./dash_site --help` from the repository's root directory.
191203
192204
[`corepack`]: https://nodejs.org/api/corepack.html
193205
[`pnpm`]: https://pnpm.io/
206+
[pnpm-install]: https://pnpm.io/installation
194207

195208
## Validate your changes
196209

@@ -201,7 +214,7 @@ commit your work, then run the following command to
201214
verify it is up to date and matches the site standards.
202215

203216
```terminal
204-
dart run dart_site check-all
217+
./dash_site check-all
205218
```
206219

207220
If this script reports any errors or warnings,
@@ -241,7 +254,7 @@ you can build a full version and upload it to Firebase.
241254
2. From the root directory of the repository, build the site:
242255
243256
```terminal
244-
dart run dart_site build
257+
./dash_site build
245258
```
246259

247260
This will build the site and copy it to your local `_site` directory.

analysis_options.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
analyzer:
2-
exclude: [_site, site-shared, src, tmp, tool/dartpad_picker, tool/get_dart]
2+
exclude: [_site, site-shared, src, tmp, tool/get_dart]

dash_site

+104
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
#!/bin/bash
2+
3+
REQUIRED_DART_VERSION="3.3"
4+
REQUIRED_NODE_VERSION="20.10"
5+
REQUIRED_PNPM_VERSION="8.14"
6+
7+
# Check that the 'dart' command is available on the user's path.
8+
if ! command -v dart &> /dev/null; then
9+
echo "Dart not found. To learn how to setup Dart, follow the instructions at https://dart.dev/get-dart."
10+
exit 1
11+
fi
12+
13+
# Check that the current version of a tool is the same or
14+
# newer than a required version.
15+
version_is_new_enough() {
16+
required_version="$1"
17+
current_version="$2"
18+
19+
# Split the version strings into lists based on the dot separators.
20+
IFS='.' read -ra required_list <<< "$required_version"
21+
IFS='.' read -ra current_list <<< "$current_version"
22+
23+
# Compare each portion of the version number.
24+
for ((i = 0; i < ${#required_list[@]}; i += 1)); do
25+
required_segment="${required_list[i]:-0}"
26+
current_segment="${current_list[i]:-0}"
27+
28+
if [[ "$required_segment" -gt "$current_segment" ]]; then
29+
# The current version is too low.
30+
return 0
31+
elif [[ "$required_segment" -lt "$current_segment" ]]; then
32+
# The current version is higher, which is ok.
33+
return 1
34+
fi
35+
done
36+
37+
# The current version is (mostly) the same as the required version.
38+
return 1
39+
}
40+
41+
42+
# Determine the available Dart SDK version.
43+
dart_version=$(dart --version | grep -oE 'Dart SDK version: [0-9.]+' | cut -d ' ' -f 4)
44+
45+
# Validate the version of the installed Dart SDK.
46+
if version_is_new_enough "$REQUIRED_DART_VERSION" "$dart_version"; then
47+
echo "Dart version $dart_version is too low. Version $REQUIRED_DART_VERSION or later is required."
48+
exit 1
49+
fi
50+
51+
# Check that the 'node' command is available on the user's path.
52+
if ! command -v node &> /dev/null; then
53+
echo "'node' command not found. To learn how to install and setup Node, reference the repository README."
54+
exit 1
55+
fi
56+
57+
# Determine the available Node version.
58+
node_version=$(node --version | cut -d 'v' -f 2)
59+
60+
# Validate the version of the Node installation.
61+
if version_is_new_enough "$REQUIRED_NODE_VERSION" "$node_version"; then
62+
echo "Node version $node_version is too low. Version $REQUIRED_NODE_VERSION or later is required."
63+
exit 1
64+
fi
65+
66+
# Check that the 'npx' command is available on the user's path.
67+
if ! command -v npx &> /dev/null; then
68+
echo "'npx' command from Node not found. Check your Node installation."
69+
exit 1
70+
fi
71+
72+
# Run extra logic if the 'pnpm' command is available on the user's path.
73+
if command -v pnpm &> /dev/null; then
74+
# Determine the available pnpm version.
75+
pnpm_version=$(pnpm --version)
76+
77+
# Validate the version of the pnpm installation.
78+
if version_is_new_enough "$REQUIRED_PNPM_VERSION" "$pnpm_version"; then
79+
echo "pnpm version $pnpm_version is too low. Version $REQUIRED_PNPM_VERSION or later is required."
80+
exit 1
81+
fi
82+
fi
83+
84+
# Verify that Node packages have been installed.
85+
if [[ ! -d "node_modules" ]]; then
86+
if command -v pnpm &> /dev/null; then
87+
echo "Node packages not found. Installing with 'pnpm install'..."
88+
pnpm install
89+
elif command -v npm &> /dev/null; then
90+
echo "Node packages not found. Installing with 'npm install'..."
91+
npm install
92+
else
93+
echo "Neither 'pnpm' nor 'npm' found. To learn how to setup pnpm, reference the repository README."
94+
exit 1
95+
fi
96+
fi
97+
98+
# Verify that Dart dependencies have been retrieved.
99+
if [[ ! -d ".dart_tool" ]]; then
100+
dart pub get
101+
fi
102+
103+
# Run the Dart site tool and pass through all arguments.
104+
dart run dart_site "$@"

eleventy.config.js

+1
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ export default function (eleventyConfig) {
9191

9292
eleventyConfig.addPassthroughCopy('src/content/assets/dash');
9393
eleventyConfig.addPassthroughCopy('src/content/assets/js');
94+
eleventyConfig.addPassthroughCopy({'site-shared/packages/inject_dartpad/lib/inject_dartpad.js': 'assets/js/inject_dartpad.js'});
9495
eleventyConfig.addPassthroughCopy('src/content/assets/img', { expand: true });
9596
eleventyConfig.addPassthroughCopy('src/content/f', {
9697
expand: true,

examples/analysis/pubspec.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: examples
22
description: dart.dev example code.
33

44
environment:
5-
sdk: ^3.2.0
5+
sdk: ^3.3.0
66

77
dependencies:
88
examples_util: {path: ../util}

examples/analysis_alt/pubspec.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: examples
22
description: dart.dev example code.
33

44
environment:
5-
sdk: ^3.2.0
5+
sdk: ^3.3.0
66

77
dev_dependencies:
88
lints: ^3.0.0

examples/async_await/bin/futures_intro.dart

+6-3
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,16 @@ Future<void> fetchUserOrder() {
77

88
// #docregion error
99
Future<void> fetchUserOrderError() {
10-
// Imagine that this function is fetching user info but encounters a bug
11-
return Future.delayed(const Duration(seconds: 2),
12-
() => throw Exception('Logout failed: user ID is invalid'));
10+
// Imagine that this function is fetching user info but encounters a bug.
11+
return Future.delayed(
12+
const Duration(seconds: 2),
13+
() => throw Exception('Logout failed: user ID is invalid'),
14+
);
1315
}
1416
// #docregion ''
1517

1618
void main() {
1719
fetchUserOrder();
1820
print('Fetching user order...');
1921
}
22+
// #enddocregion error

examples/async_await/bin/get_order_sync_bad.dart

+1
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,4 @@ void main() {
1919
print('Fetching user order...');
2020
print(createOrderMessage());
2121
}
22+
// #enddocregion no-warning

examples/async_await/pubspec.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ name: async_await
22
description: dart.dev example code.
33

44
environment:
5-
sdk: ^3.2.0
5+
sdk: ^3.3.0
66

77
dependencies:
88
examples_util: {path: ../util}
99

1010
dev_dependencies:
1111
lints: ^3.0.0
12-
test: ^1.24.6
12+
test: ^1.25.2

examples/build_runner_usage/pubspec.yaml

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ name: build_runner_usage
22
description: dart.dev build_runner example code.
33

44
environment:
5-
sdk: ^3.2.0
5+
sdk: ^3.3.0
66

77
dev_dependencies:
88
args: ^2.4.0
9-
build_runner: ^2.4.6
10-
build_test: ^2.2.0
9+
build_runner: ^2.4.8
10+
build_test: ^2.2.2
1111
lints: ^3.0.0

examples/cli/bin/dcat.dart

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,12 @@ Future<void> dcat(List<String> paths, {bool showLineNumbers = false}) async {
4343
.transform(const LineSplitter());
4444
try {
4545
await for (final line in lines) {
46-
// #docregion showLineNumbers
46+
// #docregion show-line-numbers
4747
if (showLineNumbers) {
4848
stdout.write('${lineNumber++} ');
4949
}
5050
stdout.writeln(line);
51-
// #enddocregion showLineNumbers
51+
// #enddocregion show-line-numbers
5252
}
5353
} catch (_) {
5454
await _handleError(path);

0 commit comments

Comments
 (0)