Skip to content

Commit

Permalink
Merge branch 'main' into if
Browse files Browse the repository at this point in the history
  • Loading branch information
nex3 authored Jan 13, 2025
2 parents 80af1c0 + 8818d93 commit 23ff19d
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 55 deletions.
9 changes: 5 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,11 @@ jobs:
check-latest: true
registry-url: 'https://registry.npmjs.org'

- name: Get version
id: version
run: |
echo "version=$(jq .version pkg/sass-parser/package.json)" | tee --append "$GITHUB_OUTPUT"
# The repo package has a file dependency, but the released version needs
# a real dependency on the released version of Sass.
- run: npm install sass@${{ steps.version.outputs.version }}
Expand All @@ -137,10 +142,6 @@ jobs:
NODE_AUTH_TOKEN: '${{ secrets.NPM_TOKEN }}'
working-directory: pkg/sass-parser/

- name: Get version
id: version
run: |
echo "version=$(jq .version pkg/sass-parser/package.json)" | tee --append "$GITHUB_OUTPUT"
- run: git tag sass-parser/${{ steps.version.outputs.version }}
- run: git push --tag

Expand Down
10 changes: 6 additions & 4 deletions pkg/sass-parser/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
## 0.4.9

* Add support for parsing the `@include` rule.

* Add support for parsing declarations.

* Add support for parsing the `@if` and `@else` rules.

## 0.4.8

Add support for parsing the `@include` rule.

Add support for parsing the `@mixin` rule.
* Add support for parsing the `@mixin` rule.

Add support for parsing the `@return` rule.
* Add support for parsing the `@return` rule.

## 0.4.7

Expand Down
2 changes: 1 addition & 1 deletion pkg/sass-parser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
},
"dependencies": {
"postcss": ">=8.4.41 <8.5.0",
"sass": "file:../../build/npm"
"sass": "^1.83.1"
},
"devDependencies": {
"@types/jest": "^29.5.12",
Expand Down
1 change: 0 additions & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ dev_dependencies:
analyzer: ^6.8.0
archive: ^3.1.2
crypto: ^3.0.0
dart_style: ^3.0.0
dartdoc: ^8.0.14
grinder: ^0.9.0
node_preamble: ^2.0.2
Expand Down
39 changes: 21 additions & 18 deletions test/double_check_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,33 +14,24 @@ import 'package:pub_semver/pub_semver.dart';
import 'package:pubspec_parse/pubspec_parse.dart';
import 'package:test/test.dart';

import 'package:sass/src/util/map.dart';

import '../tool/grind/generate_deprecations.dart' as deprecations;
import '../tool/grind/synchronize.dart' as synchronize;

/// Tests that double-check that everything in the repo looks sensible.
void main() {
group("up-to-date generated", () {
group("synchronized file:", () {
synchronize.sources.forEach((sourcePath, targetPath) {
test(targetPath, () {
if (File(targetPath).readAsStringSync() !=
synchronize.synchronizeFile(sourcePath)) {
fail("$targetPath is out-of-date.\n"
"Run `dart run grinder` to update it.");
}
});
});
});

test("deprecations", () {
var inputText = File(deprecations.yamlPath).readAsStringSync();
var outputText = File(deprecations.dartPath).readAsStringSync();
var checksum = sha1.convert(utf8.encode(inputText));
if (!outputText.contains('// Checksum: $checksum')) {
fail('${deprecations.dartPath} is out-of-date.\n'
'Run `dart run grinder` to update it.');
for (var (sourcePath, targetPath) in synchronize.sources.pairs) {
test(targetPath, () => _assertChecksumMatches(sourcePath, targetPath));
}
});

test(
"deprecations",
() => _assertChecksumMatches(
deprecations.yamlPath, deprecations.dartPath));
},
// Windows sees different bytes than other OSes, possibly because of
// newline normalization issues.
Expand Down Expand Up @@ -182,3 +173,15 @@ void _checkVersionIncrementsAlong(
"at its major version as well");
}
}

/// Throws an error if the checksum in [outputPath] doesn't match the hash of
/// the contents of [inputPath].
void _assertChecksumMatches(String inputPath, String outputPath) {
var inputText = File(inputPath).readAsStringSync();
var outputText = File(outputPath).readAsStringSync();
var checksum = sha1.convert(utf8.encode(inputText));
if (!outputText.contains('// Checksum: $checksum')) {
fail('$outputPath is out-of-date.\n'
'Run `dart run grinder` to update it.');
}
}
13 changes: 0 additions & 13 deletions tool/assert-formatted.sh

This file was deleted.

10 changes: 3 additions & 7 deletions tool/grind/generate_deprecations.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ import 'dart:convert';
import 'dart:io';

import 'package:crypto/crypto.dart';
import 'package:dart_style/dart_style.dart';
import 'package:grinder/grinder.dart';
import 'package:pub_semver/pub_semver.dart';
import 'package:yaml/yaml.dart';

import 'utils.dart';
Expand All @@ -23,10 +21,9 @@ final _blockRegex =
@Depends(updateLanguageRepo)
void deprecations() {
var yamlFile = File(yamlPath);
var dartFile = File(dartPath);
var yamlText = yamlFile.readAsStringSync();
var data = loadYaml(yamlText, sourceUrl: yamlFile.uri) as Map;
var dartText = dartFile.readAsStringSync();
var dartText = File(dartPath).readAsStringSync();
var buffer = StringBuffer('''// START AUTOGENERATED CODE
//
// DO NOT EDIT. This section was generated from the language repo.
Expand Down Expand Up @@ -79,7 +76,6 @@ void deprecations() {
fail("Couldn't find block for generated code in lib/src/deprecation.dart");
}
var newCode = dartText.replaceFirst(_blockRegex, buffer.toString());
dartFile.writeAsStringSync(DartFormatter(
languageVersion: Version.parse(Platform.version.split(' ').first))
.format(newCode));
File(dartPath).writeAsStringSync(newCode);
DartFmt.format(dartPath);
}
13 changes: 6 additions & 7 deletions tool/grind/synchronize.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,11 @@ import 'package:analyzer/dart/ast/token.dart';
import 'package:analyzer/dart/ast/visitor.dart';
import 'package:collection/collection.dart';
import 'package:crypto/crypto.dart';
import 'package:dart_style/dart_style.dart';
import 'package:grinder/grinder.dart';
import 'package:path/path.dart' as p;
import 'package:pub_semver/pub_semver.dart';
import 'package:source_span/source_span.dart';

import 'package:sass/src/util/map.dart';
import 'package:sass/src/util/nullable.dart';

/// The files to compile to synchronous versions.
Expand Down Expand Up @@ -47,8 +46,10 @@ final _sharedClasses = const ['EvaluateResult'];
/// to a synchronous equivalent.
@Task('Compile async code to synchronous code.')
void synchronize() {
sources.forEach((source, target) =>
File(target).writeAsStringSync(synchronizeFile(source)));
for (var (source, target) in sources.pairs) {
File(target).writeAsStringSync(synchronizeFile(source));
DartFmt.format(target);
}
}

/// Returns the result of synchronizing [source].
Expand All @@ -59,9 +60,7 @@ String synchronizeFile(String source) {
parseFile(path: source, featureSet: FeatureSet.latestLanguageVersion())
.unit
.accept(visitor);
return DartFormatter(
languageVersion: Version.parse(Platform.version.split(' ').first))
.format(visitor.result);
return visitor.result;
}

/// The visitor that traverses the asynchronous parse tree and converts it to
Expand Down

0 comments on commit 23ff19d

Please sign in to comment.