Skip to content

Commit

Permalink
Generate deprecations list from the language repo
Browse files Browse the repository at this point in the history
This updates the Deprecation enum to be generated from
spec/deprecations.yaml in the language repo.
  • Loading branch information
jathak committed May 21, 2024
1 parent 5121eb1 commit ce65b4e
Show file tree
Hide file tree
Showing 27 changed files with 126 additions and 115 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@ node_modules/
/doc/api
/pkg/*/doc/api

# Generated protocol buffer files.
# Generated Dart files.
*.pb*.dart
*.g.dart
2 changes: 1 addition & 1 deletion .pubignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# This should be identical to .gitignore except that it doesn't exclude
# generated protobuf files.
# generated Dart files.

.buildlog
.DS_Store
Expand Down
4 changes: 2 additions & 2 deletions lib/sass.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import 'src/async_import_cache.dart';
import 'src/callable.dart';
import 'src/compile.dart' as c;
import 'src/compile_result.dart';
import 'src/deprecation.dart';
import 'src/deprecation.g.dart';
import 'src/exception.dart';
import 'src/import_cache.dart';
import 'src/importer.dart';
Expand All @@ -25,7 +25,7 @@ import 'src/visitor/serialize.dart';

export 'src/callable.dart' show Callable, AsyncCallable;
export 'src/compile_result.dart';
export 'src/deprecation.dart';
export 'src/deprecation.g.dart';
export 'src/exception.dart' show SassException;
export 'src/importer.dart';
export 'src/logger.dart' show Logger;
Expand Down
2 changes: 1 addition & 1 deletion lib/src/ast/selector.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import 'package:meta/meta.dart';
import 'package:source_span/source_span.dart';

import '../deprecation.dart';
import '../deprecation.g.dart';
import '../evaluation_context.dart';
import '../exception.dart';
import '../visitor/any_selector.dart';
Expand Down
2 changes: 1 addition & 1 deletion lib/src/async_compile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import 'ast/sass.dart';
import 'async_import_cache.dart';
import 'callable.dart';
import 'compile_result.dart';
import 'deprecation.dart';
import 'deprecation.g.dart';
import 'importer.dart';
import 'importer/legacy_node.dart';
import 'importer/no_op.dart';
Expand Down
2 changes: 1 addition & 1 deletion lib/src/async_import_cache.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import 'package:package_config/package_config_types.dart';
import 'package:path/path.dart' as p;

import 'ast/sass.dart';
import 'deprecation.dart';
import 'deprecation.g.dart';
import 'importer.dart';
import 'importer/canonicalize_context.dart';
import 'importer/no_op.dart';
Expand Down
2 changes: 1 addition & 1 deletion lib/src/compile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import 'ast/sass.dart';
import 'import_cache.dart';
import 'callable.dart';
import 'compile_result.dart';
import 'deprecation.dart';
import 'deprecation.g.dart';
import 'importer.dart';
import 'importer/legacy_node.dart';
import 'importer/no_op.dart';
Expand Down
2 changes: 1 addition & 1 deletion lib/src/embedded/logger.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import 'package:path/path.dart' as p;
import 'package:source_span/source_span.dart';
import 'package:stack_trace/stack_trace.dart';

import '../deprecation.dart';
import '../deprecation.g.dart';
import '../logger.dart';
import '../util/nullable.dart';
import '../utils.dart';
Expand Down
2 changes: 1 addition & 1 deletion lib/src/evaluation_context.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import 'dart:async';

import 'package:source_span/source_span.dart';

import 'deprecation.dart';
import 'deprecation.g.dart';
import 'logger.dart';

/// An interface that exposes information about the current Sass evaluation.
Expand Down
2 changes: 1 addition & 1 deletion lib/src/functions/color.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import 'dart:collection';
import 'package:collection/collection.dart';

import '../callable.dart';
import '../deprecation.dart';
import '../deprecation.g.dart';
import '../evaluation_context.dart';
import '../exception.dart';
import '../module/built_in.dart';
Expand Down
2 changes: 1 addition & 1 deletion lib/src/functions/math.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import 'dart:math' as math;
import 'package:collection/collection.dart';

import '../callable.dart';
import '../deprecation.dart';
import '../deprecation.g.dart';
import '../evaluation_context.dart';
import '../exception.dart';
import '../module/built_in.dart';
Expand Down
2 changes: 1 addition & 1 deletion lib/src/import_cache.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import 'package:package_config/package_config_types.dart';
import 'package:path/path.dart' as p;

import 'ast/sass.dart';
import 'deprecation.dart';
import 'deprecation.g.dart';
import 'importer.dart';
import 'importer/canonicalize_context.dart';
import 'importer/no_op.dart';
Expand Down
2 changes: 1 addition & 1 deletion lib/src/importer/filesystem.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import 'package:meta/meta.dart';
import 'package:path/path.dart' as p;

import '../deprecation.dart';
import '../deprecation.g.dart';
import '../evaluation_context.dart';
import '../importer.dart';
import '../io.dart' as io;
Expand Down
2 changes: 1 addition & 1 deletion lib/src/js/deprecations.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import 'package:js/js.dart';
import 'package:pub_semver/pub_semver.dart';

import '../deprecation.dart' as dart show Deprecation;
import '../deprecation.g.dart' as dart show Deprecation;
import 'reflection.dart';

@JS()
Expand Down
2 changes: 1 addition & 1 deletion lib/src/logger.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import 'package:meta/meta.dart';
import 'package:source_span/source_span.dart';
import 'package:stack_trace/stack_trace.dart';

import 'deprecation.dart';
import 'deprecation.g.dart';
import 'logger/deprecation_processing.dart';
import 'logger/stderr.dart';

Expand Down
2 changes: 1 addition & 1 deletion lib/src/logger/deprecation_processing.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import 'package:pub_semver/pub_semver.dart';
import 'package:source_span/source_span.dart';
import 'package:stack_trace/stack_trace.dart';

import '../deprecation.dart';
import '../deprecation.g.dart';
import '../exception.dart';
import '../logger.dart';

Expand Down
2 changes: 1 addition & 1 deletion lib/src/logger/js_to_dart.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import 'package:source_span/source_span.dart';
import 'package:stack_trace/stack_trace.dart';
import 'package:term_glyph/term_glyph.dart' as glyph;

import '../deprecation.dart';
import '../deprecation.g.dart';
import '../logger.dart';
import '../js/deprecations.dart' show deprecations;
import '../js/logger.dart';
Expand Down
2 changes: 1 addition & 1 deletion lib/src/parse/scss.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import 'package:charcode/charcode.dart';

import '../ast/sass.dart';
import '../deprecation.dart';
import '../deprecation.g.dart';
import '../interpolation_buffer.dart';
import '../logger.dart';
import '../util/character.dart';
Expand Down
6 changes: 3 additions & 3 deletions lib/src/parse/stylesheet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import 'package:string_scanner/string_scanner.dart';

import '../ast/sass.dart';
import '../color_names.dart';
import '../deprecation.dart';
import '../deprecation.g.dart';
import '../exception.dart';
import '../interpolation_buffer.dart';
import '../logger.dart';
Expand Down Expand Up @@ -235,7 +235,7 @@ abstract class StylesheetParser extends Parser {
case 'default':
if (guarded) {
logger.warnForDeprecation(
Deprecation.duplicateVariableFlags,
Deprecation.duplicateVarFlags,
'!default should only be written once for each variable.\n'
'This will be an error in Dart Sass 2.0.0.',
span: scanner.spanFrom(flagStart));
Expand All @@ -248,7 +248,7 @@ abstract class StylesheetParser extends Parser {
scanner.spanFrom(flagStart));
} else if (global) {
logger.warnForDeprecation(
Deprecation.duplicateVariableFlags,
Deprecation.duplicateVarFlags,
'!global should only be written once for each variable.\n'
'This will be an error in Dart Sass 2.0.0.',
span: scanner.spanFrom(flagStart));
Expand Down
2 changes: 1 addition & 1 deletion lib/src/value.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import 'package:meta/meta.dart';

import 'ast/selector.dart';
import 'deprecation.dart';
import 'deprecation.g.dart';
import 'evaluation_context.dart';
import 'exception.dart';
import 'utils.dart';
Expand Down
2 changes: 1 addition & 1 deletion lib/src/value/calculation.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import 'dart:math' as math;
import 'package:charcode/charcode.dart';
import 'package:meta/meta.dart';

import '../deprecation.dart';
import '../deprecation.g.dart';
import '../evaluation_context.dart';
import '../exception.dart';
import '../callable.dart';
Expand Down
2 changes: 1 addition & 1 deletion lib/src/value/color.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import 'package:cli_pkg/js.dart';
import 'package:meta/meta.dart';
import 'package:source_span/source_span.dart';

import '../deprecation.dart';
import '../deprecation.g.dart';
import '../evaluation_context.dart';
import '../exception.dart';
import '../util/number.dart';
Expand Down
2 changes: 1 addition & 1 deletion lib/src/visitor/async_evaluate.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import '../callable.dart';
import '../color_names.dart';
import '../configuration.dart';
import '../configured_value.dart';
import '../deprecation.dart';
import '../deprecation.g.dart';
import '../evaluation_context.dart';
import '../exception.dart';
import '../extend/extension_store.dart';
Expand Down
2 changes: 1 addition & 1 deletion lib/src/visitor/evaluate.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import '../callable.dart';
import '../color_names.dart';
import '../configuration.dart';
import '../configured_value.dart';
import '../deprecation.dart';
import '../deprecation.g.dart';
import '../evaluation_context.dart';
import '../exception.dart';
import '../extend/extension_store.dart';
Expand Down
37 changes: 22 additions & 15 deletions tool/grind.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import 'package:grinder/grinder.dart';
import 'package:path/path.dart' as p;
import 'package:source_span/source_span.dart';

import 'grind/generate_deprecations.dart';
import 'grind/synchronize.dart';
import 'grind/utils.dart';

Expand Down Expand Up @@ -140,7 +141,7 @@ void npmInstall() =>
run(Platform.isWindows ? "npm.cmd" : "npm", arguments: ["install"]);

@Task('Runs the tasks that are required for running tests.')
@Depends(format, synchronize, protobuf, "pkg-npm-dev", npmInstall,
@Depends(format, synchronize, protobuf, deprecations, "pkg-npm-dev", npmInstall,
"pkg-standalone-dev")
void beforeTest() {}

Expand Down Expand Up @@ -213,9 +214,9 @@ String _readAndResolveMarkdown(String path) => File(path)

/// Returns a map from JS type declaration file names to their contnets.
Map<String, String> _fetchJSTypes() {
var languageRepo = _updateLanguageRepo();
updateLanguageRepo();

var typeRoot = p.join(languageRepo, 'js-api-doc');
var typeRoot = p.join('build/language', 'js-api-doc');
return {
for (var entry in Directory(typeRoot).listSync(recursive: true))
if (entry is File && entry.path.endsWith('.d.ts'))
Expand All @@ -231,6 +232,7 @@ void _matchError(Match match, String message, {Object? url}) {
}

@Task('Compile the protocol buffer definition to a Dart library.')
@Depends(updateLanguageRepo)
Future<void> protobuf() async {
Directory('build').createSync(recursive: true);

Expand All @@ -250,8 +252,6 @@ dart run protoc_plugin "\$@"
run('chmod', arguments: ['a+x', 'build/protoc-gen-dart']);
}

_updateLanguageRepo();

await runAsync("buf",
arguments: ["generate"],
runOptions: RunOptions(environment: {
Expand All @@ -261,6 +261,12 @@ dart run protoc_plugin "\$@"
}));
}

@Task('Generate deprecation.g.dart from the list in the language repo.')
@Depends(updateLanguageRepo)
Future<void> deprecations() async {
updateDeprecationFile(File('build/language/spec/deprecations.yaml'));
}

/// After building the NPM package, add default exports to
/// `build/npm/sass.node.mjs`.
///
Expand Down Expand Up @@ -322,18 +328,19 @@ String _updateHomebrewLanguageRevision(String formula) {
formula.substring(match.end);
}

/// Clones the main branch of `github.com/sass/sass` and returns the path to the
/// clone.
/// Clones the main branch of `github.com/sass/sass`.
///
/// If the `UPDATE_SASS_SASS_REPO` environment variable is `false`, this instead
/// assumes the repo that already exists at `build/language/sass`.
/// `UPDATE_SASS_PROTOCOL` is also checked as a deprecated alias for
/// `UPDATE_SASS_SASS_REPO`.
String _updateLanguageRepo() =>
// UPDATE_SASS_PROTOCOL is considered deprecated, because it doesn't apply as
// generically to other tasks.
Platform.environment['UPDATE_SASS_SASS_REPO'] != 'false' &&
Platform.environment['UPDATE_SASS_PROTOCOL'] != 'false'
? cloneOrCheckout("https://github.com/sass/sass.git", "main",
name: 'language')
: 'build/language';
@Task('Clones the main branch of `github.com/sass/sass` if necessary.')
void updateLanguageRepo() {
// UPDATE_SASS_PROTOCOL is considered deprecated, because it doesn't apply as
// generically to other tasks.
if (Platform.environment['UPDATE_SASS_SASS_REPO'] != 'false' &&
Platform.environment['UPDATE_SASS_PROTOCOL'] != 'false') {
cloneOrCheckout("https://github.com/sass/sass.git", "main",
name: 'language');
}
}
Loading

0 comments on commit ce65b4e

Please sign in to comment.