-
Notifications
You must be signed in to change notification settings - Fork 53
[package:mime] generate a markdown table of the current mime mappings #2038
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Related to #2028. |
Package publishing
Documentation at https://github.com/dart-lang/ecosystem/wiki/Publishing-automation. |
PR HealthBreaking changes ✔️
Changelog Entry ✔️
Changes to files need to be accounted for in their respective changelogs.
Coverage
|
File | Coverage |
---|---|
pkgs/mime/tool/media_types.dart | 💔 Not covered |
This check for test coverage is informational (issues shown here will not fail the PR).
This check can be disabled by tagging the PR with skip-coverage-check
.
API leaks ✔️
The following packages contain symbols visible in the public API, but not exported by the library. Export these symbols or remove them from your publicly visible API.
Package | Leaked API symbols |
---|
License Headers ✔️
// Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
Files |
---|
no missing headers |
All source files should start with a license header.
Unrelated files missing license headers
Files |
---|
pkgs/bazel_worker/benchmark/benchmark.dart |
pkgs/bazel_worker/example/client.dart |
pkgs/bazel_worker/example/worker.dart |
pkgs/benchmark_harness/integration_test/perf_benchmark_test.dart |
pkgs/boolean_selector/example/example.dart |
pkgs/clock/lib/clock.dart |
pkgs/clock/lib/src/clock.dart |
pkgs/clock/lib/src/default.dart |
pkgs/clock/lib/src/stopwatch.dart |
pkgs/clock/lib/src/utils.dart |
pkgs/clock/test/clock_test.dart |
pkgs/clock/test/default_test.dart |
pkgs/clock/test/stopwatch_test.dart |
pkgs/clock/test/utils.dart |
pkgs/coverage/lib/src/coverage_options.dart |
pkgs/coverage/test/collect_coverage_config_test.dart |
pkgs/coverage/test/config_file_locator_test.dart |
pkgs/html/example/main.dart |
pkgs/html/lib/dom.dart |
pkgs/html/lib/dom_parsing.dart |
pkgs/html/lib/html_escape.dart |
pkgs/html/lib/parser.dart |
pkgs/html/lib/src/constants.dart |
pkgs/html/lib/src/encoding_parser.dart |
pkgs/html/lib/src/html_input_stream.dart |
pkgs/html/lib/src/list_proxy.dart |
pkgs/html/lib/src/query_selector.dart |
pkgs/html/lib/src/token.dart |
pkgs/html/lib/src/tokenizer.dart |
pkgs/html/lib/src/treebuilder.dart |
pkgs/html/lib/src/utils.dart |
pkgs/html/test/dom_test.dart |
pkgs/html/test/parser_feature_test.dart |
pkgs/html/test/parser_test.dart |
pkgs/html/test/query_selector_test.dart |
pkgs/html/test/selectors/level1_baseline_test.dart |
pkgs/html/test/selectors/level1_lib.dart |
pkgs/html/test/selectors/selectors.dart |
pkgs/html/test/support.dart |
pkgs/html/test/tokenizer_test.dart |
pkgs/pubspec_parse/test/git_uri_test.dart |
pkgs/stack_trace/example/example.dart |
pkgs/watcher/test/custom_watcher_factory_test.dart |
pkgs/yaml_edit/example/example.dart |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some comments are suggestions for more functionality, or error checking, reporting and/or recovery, which we can add later.
It's good to have the file. We can always bikeshed to script.
pkgs/mime/tool/mime_types.dart
Outdated
import 'package:mime/mime.dart'; | ||
import 'package:mime/src/default_extension_map.dart'; | ||
|
||
void main(List<String> args) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can remove List<String> args
when it isn't used.
(Could also use it, and allow a first argument to point to the file to update.
That would allow us to create a test for whether this code should be run by
making a copy of the doc/mimetypes.md
file, calling this main
with the path of the copy, and then checking if the files differ. Which I think we should do, so when you run tests, you're told if you need to update the doc.
If we do take the file on input, we should do better validation of it, like require it to exist, end in .md
, and contain two markers, to avoid overwriting a wrong file.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For other similar systems, I've either had this script take an option --verify
flag, which will fail if it would have written out differences, and run that on a CI, or, have the CI run the generate script, and then fail if git diff
shows any differences.
Likely the 2nd would work here? It's pretty simple and will ensure that the file is always up-to-date.
pkgs/mime/tool/mime_types.dart
Outdated
contents.substring(0, contents.indexOf(marker) + marker.length); | ||
final suffix = contents.substring(contents.lastIndexOf(marker)); | ||
|
||
final buf = StringBuffer(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Put the prefix in to the buffer from the start.
final buffer = StringBuffer(prefix);
and add the suffix at the end. Might as well use the buffer when we have it.
pkgs/mime/tool/mime_types.dart
Outdated
// Find all their extensions. | ||
final mimeToExts = <String, List<String>>{}; | ||
|
||
for (final entry in defaultExtensionMap.entries) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can use pattern:
for (final MapEntry(key: ext, value: media) in defaultExtensionMap.entries) {
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the review! Updated.
pkgs/mime/tool/mime_types.dart
Outdated
import 'package:mime/mime.dart'; | ||
import 'package:mime/src/default_extension_map.dart'; | ||
|
||
void main(List<String> args) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For other similar systems, I've either had this script take an option --verify
flag, which will fail if it would have written out differences, and run that on a CI, or, have the CI run the generate script, and then fail if git diff
shows any differences.
Likely the 2nd would work here? It's pretty simple and will ensure that the file is always up-to-date.
Revisions updated by `dart tools/rev_sdk_deps.dart`. core (https://github.com/dart-lang/core/compare/9f43210..61e6771): 61e67710 2025-03-12 Moritz Check for mandatory when using option (dart-lang/core#871) 77d33c83 2025-03-04 Devon Carew Update publish.yaml (dart-lang/core#870) db610bb5 2025-02-28 Erik Ernst Adjust the implements clause of IntX (dart-lang/core#866) 22d8879f 2025-02-27 Devon Carew [package:lints] fix the changelog (dart-lang/core#867) 2f0325e9 2025-02-26 Devon Carew Contribute a Gemini Code Assist config (dart-lang/core#865) ecosystem (https://github.com/dart-lang/ecosystem/compare/a3cc42d..5b8e6b8): 5b8e6b8 2025-03-17 Devon Carew [dart_flutter_team_lints] remove 'discarded_futures'; prep for publishing (dart-lang/ecosystem#347) b96e5d2 2025-03-14 Devon Carew Add the discarded_futures lint; rev for publishing (dart-lang/ecosystem#346) http (https://github.com/dart-lang/http/compare/001665e..9129a96): 9129a96 2025-03-13 Brian Quinlan Prepare to release cupertino_http 2.1.0 (dart-lang/http#1727) 91d8719 2025-03-13 Brian Quinlan Upgrade to `package:objective_c` 7.0.0 (dart-lang/http#1726) i18n (https://github.com/dart-lang/i18n/compare/b09c822..d9cce0b): d9cce0b 2025-03-13 Moritz Grab new artifacts from version `intl4x-icu-v.0.11.2-artifacts` (dart-lang/i18n#957) protobuf (https://github.com/dart-lang/protobuf/compare/7838e44..0bab78d): 0bab78d 2025-03-14 Devon Carew rename -dev pubspec versions to -wip (google/protobuf.dart#968) tools (https://github.com/dart-lang/tools/compare/9c53358..62bc13b): 62bc13bc 2025-03-17 Kevin Moore [markdown, stream_transform] Fix deprecated usage of pkg:web (dart-lang/tools#2046) f1a5e7a2 2025-03-17 Devon Carew [package:markdown] update package:web references in the example (dart-lang/tools#2039) a4ae1759 2025-03-17 Nate Bosch [package_config] Update language version and reformat (dart-lang/tools#2040) a2af1447 2025-03-17 Nate Bosch [package_config] Remove unnecessary casts to Uint8List (dart-lang/tools#2041) 07ebd15d 2025-03-14 Devon Carew [package:mime] generate a markdown table of the current mime mappings (dart-lang/tools#2038) 920fdb64 2025-03-13 dependabot[bot] Bump dart-lang/setup-dart from 1.7.0 to 1.7.1 in the github-actions group (dart-lang/tools#2022) b55643da 2025-03-13 David Iglesias [html] Allow ampersands in attribute values. (dart-lang/tools#2036) Change-Id: I2998ebecfdc7b1790a74a8ab2128895694658a5f Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/416023 Reviewed-by: Konstantin Shcheglov <scheglov@google.com> Commit-Queue: Devon Carew <devoncarew@google.com>
If we change the system of truth for our mime / ext. mappings, the diffs to this file will help us be aware of changes (new mime types, changed ext. defaults, ...).
Contribution guidelines:
dart format
.Note that many Dart repos have a weekly cadence for reviewing PRs - please allow for some latency before initial review feedback.