Skip to content

Commit 6bd6ad6

Browse files
authored
Switch to the sass_api package (#223)
Fixes #209.
1 parent 4616db5 commit 6bd6ad6

16 files changed

+27
-92
lines changed

lib/src/exception.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// license that can be found in the LICENSE file or at
55
// https://opensource.org/licenses/MIT.
66

7-
import 'package:sass/sass.dart';
7+
import 'package:sass_api/sass_api.dart';
88
import 'package:source_span/source_span.dart';
99

1010
/// An exception thrown by a migrator.

lib/src/migration_visitor.dart

+1-8
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,9 @@ import 'dart:collection';
88

99
import 'package:meta/meta.dart';
1010
import 'package:path/path.dart' as p;
11+
import 'package:sass_api/sass_api.dart';
1112
import 'package:source_span/source_span.dart';
1213

13-
// The sass package's API is not necessarily stable. It is being imported with
14-
// the Sass team's explicit knowledge and approval. See
15-
// https://github.com/sass/dart-sass/issues/236.
16-
import 'package:sass/src/ast/sass.dart';
17-
import 'package:sass/src/importer.dart';
18-
import 'package:sass/src/import_cache.dart';
19-
import 'package:sass/src/visitor/recursive_ast.dart';
20-
2114
import 'exception.dart';
2215
import 'patch.dart';
2316

lib/src/migrator.dart

+2-9
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,16 @@
44
// license that can be found in the LICENSE file or at
55
// https://opensource.org/licenses/MIT.
66

7-
// The sass package's API is not necessarily stable. It is being imported with
8-
// the Sass team's explicit knowledge and approval. See
9-
// https://github.com/sass/dart-sass/issues/236.
10-
import 'package:sass/sass.dart';
11-
import 'package:sass/src/ast/sass.dart';
12-
import 'package:sass/src/importer.dart';
13-
import 'package:sass/src/import_cache.dart';
14-
157
import 'package:args/command_runner.dart';
168
import 'package:glob/glob.dart';
179
import 'package:meta/meta.dart';
1810
import 'package:path/path.dart' as p;
19-
import 'package:sass_migrator/src/util/node_modules_importer.dart';
11+
import 'package:sass_api/sass_api.dart';
2012
import 'package:source_span/source_span.dart';
2113

2214
import 'exception.dart';
2315
import 'io.dart';
16+
import 'util/node_modules_importer.dart';
2417
import 'utils.dart';
2518

2619
/// A migrator is a command that migrates the entrypoints provided to it and

lib/src/migrators/division.dart

+6-12
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,12 @@
55
// https://opensource.org/licenses/MIT.
66

77
import 'package:args/args.dart';
8-
import 'package:sass/sass.dart';
9-
10-
// The sass package's API is not necessarily stable. It is being imported with
11-
// the Sass team's explicit knowledge and approval. See
12-
// https://github.com/sass/dart-sass/issues/236.
13-
import 'package:sass/src/ast/sass.dart';
14-
import 'package:sass/src/import_cache.dart';
15-
16-
import 'package:sass_migrator/src/migration_visitor.dart';
17-
import 'package:sass_migrator/src/migrator.dart';
18-
import 'package:sass_migrator/src/patch.dart';
19-
import 'package:sass_migrator/src/utils.dart';
8+
import 'package:sass_api/sass_api.dart';
9+
10+
import '../migration_visitor.dart';
11+
import '../migrator.dart';
12+
import '../patch.dart';
13+
import '../utils.dart';
2014

2115
/// Migrates stylesheets that use the `/` operator for division to use the
2216
/// `divide` function instead.

lib/src/migrators/module.dart

+2-9
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,10 @@
44
// license that can be found in the LICENSE file or at
55
// https://opensource.org/licenses/MIT.
66

7-
// The sass package's API is not necessarily stable. It is being imported with
8-
// the Sass team's explicit knowledge and approval. See
9-
// https://github.com/sass/dart-sass/issues/236.
10-
import 'package:sass/src/ast/sass.dart';
11-
import 'package:sass/src/importer.dart';
12-
import 'package:sass/src/import_cache.dart';
13-
import 'package:sass/src/parse/parser.dart';
14-
157
import 'package:args/args.dart';
168
import 'package:collection/collection.dart';
179
import 'package:path/path.dart' as p;
10+
import 'package:sass_api/sass_api.dart';
1811
import 'package:source_span/source_span.dart';
1912
import 'package:tuple/tuple.dart';
2013

@@ -1320,7 +1313,7 @@ class _ModuleMigrationVisitor extends MigrationVisitor {
13201313
prefixesToRemove.where((prefix) =>
13211314
prefix.length < identifier.length &&
13221315
identifier.startsWith(prefix) &&
1323-
Parser.isIdentifier(identifier.substring(prefix.length))),
1316+
isIdentifier(identifier.substring(prefix.length))),
13241317
(prefix) => prefix.length);
13251318

13261319
/// Disallows `@use` after `@at-root` rules.

lib/src/migrators/module/member_declaration.dart

+1-5
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,8 @@
44
// license that can be found in the LICENSE file or at
55
// https://opensource.org/licenses/MIT.
66

7-
// The sass package's API is not necessarily stable. It is being imported with
8-
// the Sass team's explicit knowledge and approval. See
9-
// https://github.com/sass/dart-sass/issues/236.
10-
import 'package:sass/src/ast/sass.dart';
11-
127
import 'package:path/path.dart' as p;
8+
import 'package:sass_api/sass_api.dart';
139

1410
import '../../utils.dart';
1511

lib/src/migrators/module/reference_source.dart

+3-6
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,10 @@
44
// license that can be found in the LICENSE file or at
55
// https://opensource.org/licenses/MIT.
66

7-
// The sass package's API is not necessarily stable. It is being imported with
8-
// the Sass team's explicit knowledge and approval. See
9-
// https://github.com/sass/dart-sass/issues/236.
10-
import 'package:sass/src/ast/sass.dart';
11-
import 'package:sass_migrator/src/utils.dart';
12-
137
import 'package:path/path.dart' as p;
8+
import 'package:sass_api/sass_api.dart';
9+
10+
import '../../utils.dart';
1411

1512
/// A [ReferenceSource] is used to track where a referenced member came from.
1613
abstract class ReferenceSource {

lib/src/migrators/module/references.dart

+1-9
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,9 @@
44
// license that can be found in the LICENSE file or at
55
// https://opensource.org/licenses/MIT.
66

7-
// The sass package's API is not necessarily stable. It is being imported with
8-
// the Sass team's explicit knowledge and approval. See
9-
// https://github.com/sass/dart-sass/issues/236.
10-
import 'package:sass/src/ast/node.dart';
11-
import 'package:sass/src/ast/sass.dart';
12-
import 'package:sass/src/importer.dart';
13-
import 'package:sass/src/import_cache.dart';
14-
import 'package:sass/src/visitor/recursive_ast.dart';
15-
167
import 'package:collection/collection.dart';
178
import 'package:path/path.dart' as p;
9+
import 'package:sass_api/sass_api.dart';
1810

1911
import '../../exception.dart';
2012
import '../../util/bidirectional_map.dart';

lib/src/migrators/module/scope.dart

+1-4
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,7 @@
44
// license that can be found in the LICENSE file or at
55
// https://opensource.org/licenses/MIT.
66

7-
// The sass package's API is not necessarily stable. It is being imported with
8-
// the Sass team's explicit knowledge and approval. See
9-
// https://github.com/sass/dart-sass/issues/236.
10-
import 'package:sass/src/ast/sass.dart';
7+
import 'package:sass_api/sass_api.dart';
118

129
import 'member_declaration.dart';
1310

lib/src/migrators/module/unreferencable_members.dart

+1-4
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,7 @@
44
// license that can be found in the LICENSE file or at
55
// https://opensource.org/licenses/MIT.
66

7-
// The sass package's API is not necessarily stable. It is being imported with
8-
// the Sass team's explicit knowledge and approval. See
9-
// https://github.com/sass/dart-sass/issues/236.
10-
import 'package:sass/src/ast/sass.dart';
7+
import 'package:sass_api/sass_api.dart';
118

129
import 'member_declaration.dart';
1310
import 'unreferencable_type.dart';

lib/src/migrators/module/unreferencable_type.dart

+1-5
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,9 @@
44
// license that can be found in the LICENSE file or at
55
// https://opensource.org/licenses/MIT.
66

7-
// The sass package's API is not necessarily stable. It is being imported with
8-
// the Sass team's explicit knowledge and approval. See
9-
// https://github.com/sass/dart-sass/issues/236.
10-
import 'package:sass/src/ast/sass.dart';
11-
127
import 'package:meta/meta.dart';
138
import 'package:path/path.dart' as p;
9+
import 'package:sass_api/sass_api.dart';
1410

1511
import '../../exception.dart';
1612

lib/src/migrators/namespace.dart

+2-9
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,9 @@
55
// https://opensource.org/licenses/MIT.
66

77
import 'package:args/args.dart';
8-
import 'package:sass/sass.dart';
8+
import 'package:sass_api/sass_api.dart';
99
import 'package:source_span/source_span.dart';
1010

11-
// The sass package's API is not necessarily stable. It is being imported with
12-
// the Sass team's explicit knowledge and approval. See
13-
// https://github.com/sass/dart-sass/issues/236.
14-
import 'package:sass/src/ast/sass.dart';
15-
import 'package:sass/src/exception.dart';
16-
import 'package:sass/src/import_cache.dart';
17-
1811
import '../migration_visitor.dart';
1912
import '../migrator.dart';
2013
import '../patch.dart';
@@ -107,7 +100,7 @@ class _NamespaceMigrationVisitor extends MigrationVisitor {
107100

108101
// If there's still a conflict, fail unless --force is passed.
109102
if (!forceRename) {
110-
throw MultiSpanSassException(
103+
throw MultiSourceSpanException(
111104
'Rename failed. ${rules.length} rules would use namespace '
112105
'"$newNamespace".\n'
113106
'Run with --force to rename with numerical suffixes.',

lib/src/util/node_modules_importer.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// https://opensource.org/licenses/MIT.
66

77
import 'package:path/path.dart' as p;
8-
import 'package:sass/sass.dart';
8+
import 'package:sass_api/sass_api.dart';
99

1010
import '../io.dart';
1111

lib/src/utils.dart

+1-6
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,10 @@
55
// https://opensource.org/licenses/MIT.
66

77
import 'package:charcode/charcode.dart';
8+
import 'package:sass_api/sass_api.dart';
89
import 'package:source_span/source_span.dart';
910
import 'package:tuple/tuple.dart';
1011

11-
// The sass package's API is not necessarily stable. It is being imported with
12-
// the Sass team's explicit knowledge and approval. See
13-
// https://github.com/sass/dart-sass/issues/236.
14-
import 'package:sass/src/ast/sass.dart';
15-
import 'package:sass/src/ast/node.dart';
16-
1712
import 'io.dart';
1813
import 'patch.dart';
1914

pubspec.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: sass_migrator
2-
version: 1.5.5-dev
2+
version: 1.5.5
33
description: A tool for running migrations on Sass files
44
homepage: https://github.com/sass/migrator
55

@@ -17,7 +17,7 @@ dependencies:
1717
node_interop: ^2.0.2
1818
node_io: ^2.1.0
1919
path: ^1.8.0
20-
sass: ^1.44.0
20+
sass_api: ^1.0.0-beta.48
2121
source_span: ^1.8.1
2222
string_scanner: ^1.1.0
2323
term_glyph: ^1.2.0

test/migrators/namespace/conflict_no_force.hrx

+1-2
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,12 @@ a {
1111
}
1212

1313
<==> error.txt
14-
Error: Rename failed. 2 rules would use namespace "library".
14+
Error on line 1, column 1 of entrypoint.scss: Rename failed. 2 rules would use namespace "library".
1515
Run with --force to rename with numerical suffixes.
1616
,
1717
1 | @use "library-a";
1818
| ^^^^^^^^^^^^^^^^
1919
2 | @use "library-b";
2020
| ================
2121
'
22-
entrypoint.scss 1:1 root stylesheet
2322
Migration failed!

0 commit comments

Comments
 (0)