Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions .github/workflows/dart.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,23 +39,23 @@ jobs:
- name: mono_repo self validate
run: dart pub global run mono_repo generate --validate
job_002:
name: "analyzer_and_format; Dart 3.5.0; PKGS: pkgs/analysis_defaults, pkgs/dash_design, pkgs/excerpter, pkgs/inject_dartpad; `dart format --output=none --set-exit-if-changed .`, `dart analyze --fatal-infos .`"
name: "analyzer_and_format; Dart 3.7.0; PKGS: pkgs/analysis_defaults, pkgs/dash_design, pkgs/excerpter, pkgs/inject_dartpad; `dart format --output=none --set-exit-if-changed .`, `dart analyze --fatal-infos .`"
runs-on: ubuntu-latest
steps:
- name: Cache Pub hosted dependencies
uses: actions/cache@d4323d4df104b026a6aa633fdb11d772146be0bf
with:
path: "~/.pub-cache/hosted"
key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.5.0;packages:pkgs/analysis_defaults-pkgs/dash_design-pkgs/excerpter-pkgs/inject_dartpad;commands:format-analyze"
key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.7.0;packages:pkgs/analysis_defaults-pkgs/dash_design-pkgs/excerpter-pkgs/inject_dartpad;commands:format-analyze"
restore-keys: |
os:ubuntu-latest;pub-cache-hosted;sdk:3.5.0;packages:pkgs/analysis_defaults-pkgs/dash_design-pkgs/excerpter-pkgs/inject_dartpad
os:ubuntu-latest;pub-cache-hosted;sdk:3.5.0
os:ubuntu-latest;pub-cache-hosted;sdk:3.7.0;packages:pkgs/analysis_defaults-pkgs/dash_design-pkgs/excerpter-pkgs/inject_dartpad
os:ubuntu-latest;pub-cache-hosted;sdk:3.7.0
os:ubuntu-latest;pub-cache-hosted
os:ubuntu-latest
- name: Setup Dart SDK
uses: dart-lang/setup-dart@e51d8e571e22473a2ddebf0ef8a2123f0ab2c02c
with:
sdk: "3.5.0"
sdk: "3.7.0"
- id: checkout
name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
Expand Down Expand Up @@ -185,23 +185,23 @@ jobs:
if: "always() && steps.pkgs_inject_dartpad_pub_upgrade.conclusion == 'success'"
working-directory: pkgs/inject_dartpad
job_004:
name: "unit_test; Dart 3.5.0; PKG: pkgs/excerpter; `dart test`"
name: "unit_test; Dart 3.7.0; PKG: pkgs/excerpter; `dart test`"
runs-on: ubuntu-latest
steps:
- name: Cache Pub hosted dependencies
uses: actions/cache@d4323d4df104b026a6aa633fdb11d772146be0bf
with:
path: "~/.pub-cache/hosted"
key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.5.0;packages:pkgs/excerpter;commands:test"
key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.7.0;packages:pkgs/excerpter;commands:test"
restore-keys: |
os:ubuntu-latest;pub-cache-hosted;sdk:3.5.0;packages:pkgs/excerpter
os:ubuntu-latest;pub-cache-hosted;sdk:3.5.0
os:ubuntu-latest;pub-cache-hosted;sdk:3.7.0;packages:pkgs/excerpter
os:ubuntu-latest;pub-cache-hosted;sdk:3.7.0
os:ubuntu-latest;pub-cache-hosted
os:ubuntu-latest
- name: Setup Dart SDK
uses: dart-lang/setup-dart@e51d8e571e22473a2ddebf0ef8a2123f0ab2c02c
with:
sdk: "3.5.0"
sdk: "3.7.0"
- id: checkout
name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
Expand Down
1 change: 1 addition & 0 deletions pkgs/analysis_defaults/lib/analysis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@ linter:
- unnecessary_breaks
- unnecessary_null_aware_operator_on_extension_on_nullable
- use_enums
- use_truncating_division
4 changes: 2 additions & 2 deletions pkgs/analysis_defaults/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ description: Analysis defaults for Dart/Flutter site tools.
publish_to: none

environment:
sdk: ^3.5.0
sdk: ^3.7.0

# NOTE: Code is not allowed in this package.
# Do not add dependencies besides the underlying lints package.
dependencies:
dart_flutter_team_lints: ^3.2.1
dart_flutter_team_lints: ^3.4.0
2 changes: 1 addition & 1 deletion pkgs/dash_design/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ publish_to: none
repository: https://github.com/dart-lang/site-shared/tree/main/pkgs/dash_design

environment:
sdk: ^3.5.0
sdk: ^3.7.0

dev_dependencies:
analysis_defaults:
Expand Down
6 changes: 4 additions & 2 deletions pkgs/dash_design/test/style_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ import 'package:test/test.dart';

void main() {
test('Can build styles.scss file', () {
final compileResult = sass.compileToResult(_stylesPath!,
fatalDeprecations: sass.Deprecation.values.where((d) => !d.isFuture));
final compileResult = sass.compileToResult(
_stylesPath!,
fatalDeprecations: sass.Deprecation.values.where((d) => !d.isFuture),
);
expect(compileResult.css, contains('--dash-default-font-family'));
});
}
Expand Down
100 changes: 55 additions & 45 deletions pkgs/excerpter/bin/excerpter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ Future<void> runExcerpter(final List<String> arguments) async {
final excludePaths = results[_excludeOption] as List<String>? ?? const [];
final plasterContent = results[_plasterContentOption] as String? ?? '...';
final replaceInstructions = results[_replaceOption] as String?;
final baseSourcePath =
path.absolute(results[_baseSourcePathOption] as String? ?? path.current);
final baseSourcePath = path.absolute(
results[_baseSourcePathOption] as String? ?? path.current,
);

if (results.rest.length != 1) {
_printUsageAndExit(
Expand All @@ -36,12 +37,13 @@ Future<void> runExcerpter(final List<String> arguments) async {
}
final updatePath = path.absolute(results.rest.first);

final replaceTransforms = replaceInstructions == null
? const <ReplaceTransform>[]
: stringToReplaceTransforms(
replaceInstructions,
(e) => _printUsageAndExit(message: e),
);
final replaceTransforms =
replaceInstructions == null
? const <ReplaceTransform>[]
: stringToReplaceTransforms(
replaceInstructions,
(e) => _printUsageAndExit(message: e),
);

final updater = Updater(
baseSourcePath: baseSourcePath,
Expand All @@ -68,11 +70,13 @@ Future<void> runExcerpter(final List<String> arguments) async {
print('');
}

print('Processed ${result.filesVisited} out of '
'${result.totalFilesToVisit} files: '
'${result.excerptsNeedingUpdates} out of '
'${result.excerptsVisited} excerpts visited '
'${result.madeUpdates ? 'were updated' : 'need to be updated'}.');
print(
'Processed ${result.filesVisited} out of '
'${result.totalFilesToVisit} files: '
'${result.excerptsNeedingUpdates} out of '
'${result.excerptsVisited} excerpts visited '
'${result.madeUpdates ? 'were updated' : 'need to be updated'}.',
);

if (result.errors.length case final amountOfErrors when amountOfErrors > 0) {
io.exitCode = amountOfErrors;
Expand All @@ -81,38 +85,44 @@ Future<void> runExcerpter(final List<String> arguments) async {
}
}

final _argParser = ArgParser()
..addFlag(
_dryRunFlag,
negatable: false,
help: 'If the updater should only report if excerpts need to be updated.',
)
..addFlag(
_failOnUpdateFlag,
negatable: false,
help:
'Report a non-zero exit code if an excerpt is or needs to be updated.',
)
..addMultiOption(
_excludeOption,
help: 'Regular expressions of paths to exclude when '
'processing a directory recursively.\n'
'Dot files and directories are always excluded.',
)
..addOption(
_baseSourcePathOption,
help: 'The path to the directory containing the source files that '
'excerpt regions should be retrieved from.',
)
..addOption(
_plasterContentOption,
help: 'The default plaster content, such as "..." or "···".',
)
..addOption(
_replaceOption,
help: 'A replacement to run on every excerpt.\n'
'Refer to the package docs for syntax help.',
);
final _argParser =
ArgParser()
..addFlag(
_dryRunFlag,
negatable: false,
help:
'If the updater should only report if excerpts need to be updated.',
)
..addFlag(
_failOnUpdateFlag,
negatable: false,
help:
'Report a non-zero exit code if '
'an excerpt is or needs to be updated.',
)
..addMultiOption(
_excludeOption,
help:
'Regular expressions of paths to exclude when '
'processing a directory recursively.\n'
'Dot files and directories are always excluded.',
)
..addOption(
_baseSourcePathOption,
help:
'The path to the directory containing the source files that '
'excerpt regions should be retrieved from.',
)
..addOption(
_plasterContentOption,
help: 'The default plaster content, such as "..." or "···".',
)
..addOption(
_replaceOption,
help:
'A replacement to run on every excerpt.\n'
'Refer to the package docs for syntax help.',
);

/// Print the usage information for this command,
/// optionally with the specified error [message] and [exitCode],
Expand Down
5 changes: 3 additions & 2 deletions pkgs/excerpter/lib/src/extract.dart
Original file line number Diff line number Diff line change
Expand Up @@ -210,5 +210,6 @@ final class ExtractException implements Exception {

const String _entireFileRegionName = '';

final RegExp _docRegionDirective =
RegExp(r'^.*?#(?<end>end)?docregion\s(?<regions>[a-zA-Z0-9,_\-\s]+).*?$');
final RegExp _docRegionDirective = RegExp(
r'^.*?#(?<end>end)?docregion\s(?<regions>[a-zA-Z0-9,_\-\s]+).*?$',
);
44 changes: 23 additions & 21 deletions pkgs/excerpter/lib/src/inject.dart
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,9 @@ final class FileUpdater {
}

final lineAfterInstruction = originalLines[lineIndex];
final fencedCodeBlock =
_codeBlockStart.firstMatch(lineAfterInstruction);
final fencedCodeBlock = _codeBlockStart.firstMatch(
lineAfterInstruction,
);
if (fencedCodeBlock == null) {
reportError(
'An inject instruction must be followed by a code block '
Expand Down Expand Up @@ -206,13 +207,15 @@ final class FileUpdater {
}

// Add back the indentation from the file and any from the instruction.
updatedLines =
IndentTransform(instructionIndent + (instruction.indentBy ?? 0))
.transform(updatedLines);
updatedLines = IndentTransform(
instructionIndent + (instruction.indentBy ?? 0),
).transform(updatedLines);

final updatedExcerpt = updatedLines.join('\n');
if (!(const IterableEquality<String>()
.equals(oldLines, updatedLines))) {
if (!(const IterableEquality<String>().equals(
oldLines,
updatedLines,
))) {
excerptsUpdated.add((
instructionLine: instructionLineNumber,
updated: updatedExcerpt,
Expand Down Expand Up @@ -308,11 +311,13 @@ final RegExp _instructionPattern = RegExp(

final RegExp _instructionStart = RegExp(r'^<\?code-excerpt');

final RegExp _codeBlockStart =
RegExp(r'^\s*(?<backticks>`{3,})(?<language>\S+).*?$');
final RegExp _codeBlockStart = RegExp(
r'^\s*(?<backticks>`{3,})(?<language>\S+).*?$',
);

final RegExp _splitArgs =
RegExp(r'(?<arg>[-\w]+)\s*(=\s*"(?<value>.*?)"\s*)\s*');
final RegExp _splitArgs = RegExp(
r'(?<arg>[-\w]+)\s*(=\s*"(?<value>.*?)"\s*)\s*',
);

/// A code excerpt set or injection instruction
/// found in a file being processed.
Expand Down Expand Up @@ -340,21 +345,20 @@ sealed class _Instruction {

if (path == null) {
if (argumentPairs.length != 1) {
reportError(
'A set instruction must have only one argument specified.',
);
reportError('A set instruction must have only one argument specified.');
}
final argName = argumentPairs.first.arg;
final argValue = argumentPairs.first.value;
return switch (argName) {
'path-base' => _SetPathBaseInstruction(argValue),
'plaster' => _SetPlasterInstruction(argValue),
'replace' => _SetFileReplaceInstruction(
stringToReplaceTransforms(argValue, reportError)),
stringToReplaceTransforms(argValue, reportError),
),
_ => reportError(
'A set instruction can only specify the '
'`path-base`, `plaster`, and `replace` arguments.',
),
'A set instruction can only specify the '
'`path-base`, `plaster`, and `replace` arguments.',
),
};
}

Expand Down Expand Up @@ -461,9 +465,7 @@ final class _InjectInstruction extends _Instruction {
final indentBy = indentByString == null ? null : int.parse(indentByString);

if (indentBy != null && indentBy < 0) {
reportError(
'The `indent-by` argument must be positive.',
);
reportError('The `indent-by` argument must be positive.');
}

return _InjectInstruction(
Expand Down
Loading