diff --git a/CHANGELOG.md b/CHANGELOG.md index 5cb263336..28b1badbe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## 1.45.0-rc.2 + +### JS API + +* Ship TypeScript type declarations with the package. + ## 1.45.0-rc.1 ### JS API diff --git a/package/package.json b/package/package.json index 6cee7fcfc..0674236e6 100644 --- a/package/package.json +++ b/package/package.json @@ -18,7 +18,9 @@ }, "dependencies": { "chokidar": ">=3.0.0 <4.0.0", - "immutable": "^4.0.0" + "immutable": "^4.0.0", + "source-map-js": ">=0.6.2 <2.0.0" }, - "keywords": ["style", "scss", "sass", "preprocessor", "css"] + "keywords": ["style", "scss", "sass", "preprocessor", "css"], + "types": "types/index.d.ts" } diff --git a/pkg/sass_api/CHANGELOG.md b/pkg/sass_api/CHANGELOG.md index 43aae1641..1220cce94 100644 --- a/pkg/sass_api/CHANGELOG.md +++ b/pkg/sass_api/CHANGELOG.md @@ -1,3 +1,5 @@ +## 1.0.0-beta.22 + ## 1.0.0-beta.21 * No user-visible changes. diff --git a/pkg/sass_api/pubspec.yaml b/pkg/sass_api/pubspec.yaml index 503488212..68fd1c7b7 100644 --- a/pkg/sass_api/pubspec.yaml +++ b/pkg/sass_api/pubspec.yaml @@ -2,7 +2,7 @@ name: sass_api # Note: Every time we add a new Sass AST node, we need to bump the *major* # version because it's a breaking change for anyone who's implementing the # visitor interface(s). -version: 1.0.0-beta.21 +version: 1.0.0-beta.22 description: Additional APIs for Dart Sass. homepage: https://github.com/sass/dart-sass @@ -10,7 +10,7 @@ environment: sdk: '>=2.12.0 <3.0.0' dependencies: - sass: 1.45.0-rc.1 + sass: 1.45.0-rc.2 dependency_overrides: sass: {path: ../..} diff --git a/pubspec.yaml b/pubspec.yaml index aa59a16c8..68b3d1e6e 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: sass -version: 1.45.0-rc.1 +version: 1.45.0-rc.2 description: A Sass implementation in Dart. homepage: https://github.com/sass/dart-sass diff --git a/tool/grind.dart b/tool/grind.dart index dbd890bf3..2ac623568 100644 --- a/tool/grind.dart +++ b/tool/grind.dart @@ -12,6 +12,7 @@ import 'package:path/path.dart' as p; import 'package:source_span/source_span.dart'; import 'grind/synchronize.dart'; +import 'grind/utils.dart'; export 'grind/bazel.dart'; export 'grind/benchmark.dart'; @@ -39,6 +40,7 @@ void main(List args) { json.decode(File("package/package.json").readAsStringSync()) as Map; pkg.npmReadme.fn = () => _readAndResolveMarkdown("package/README.npm.md"); + pkg.npmAdditionalFiles.fn = _fetchJSTypes; pkg.standaloneName.value = "dart-sass"; pkg.githubUser.fn = () => Platform.environment["GH_USER"]; pkg.githubPassword.fn = () => Platform.environment["GH_TOKEN"]; @@ -144,6 +146,20 @@ String _readAndResolveMarkdown(String path) => File(path) return included.substring(headerMatch.end, sectionEnd).trim(); }); +/// Returns a map from JS type declaration file names to their contnets. +Map _fetchJSTypes() { + var languageRepo = + cloneOrCheckout("https://github.com/sass/sass", "main", name: 'language'); + + var typeRoot = p.join(languageRepo, 'js-api-doc'); + return { + for (var entry in Directory(typeRoot).listSync(recursive: true)) + if (entry is File && entry.path.endsWith('.d.ts')) + p.join('types', p.relative(entry.path, from: typeRoot)): + entry.readAsStringSync() + }; +} + /// Throws a nice [SourceSpanException] associated with [match]. void _matchError(Match match, String message, {Object? url}) { var file = SourceFile.fromString(match.input, url: url); diff --git a/tool/grind/bazel.dart b/tool/grind/bazel.dart index c90ff4a9d..e891f2ab4 100644 --- a/tool/grind/bazel.dart +++ b/tool/grind/bazel.dart @@ -16,8 +16,8 @@ Future updateBazel() async { run("npm", arguments: ["install", "-g", "yarn"]); - var repo = await cloneOrCheckout( - "https://github.com/bazelbuild/rules_sass.git", "main"); + var repo = + cloneOrCheckout("https://github.com/bazelbuild/rules_sass.git", "main"); var packageFile = File(p.join(repo, "sass", "package.json")); log("updating ${packageFile.path}"); diff --git a/tool/grind/benchmark.dart b/tool/grind/benchmark.dart index ca50bca52..05480a36f 100644 --- a/tool/grind/benchmark.dart +++ b/tool/grind/benchmark.dart @@ -32,11 +32,11 @@ Future benchmarkGenerate() async { ".foo {a: b}", math.pow(2, 17), footer: '.bar {@extend .foo}'); - await cloneOrCheckout("https://github.com/twbs/bootstrap", "v4.1.3"); + cloneOrCheckout("https://github.com/twbs/bootstrap", "v4.1.3"); await _writeNTimes("${sources.path}/bootstrap.scss", "@import '../bootstrap/scss/bootstrap';", 16); - await cloneOrCheckout("https://github.com/alex-page/sass-a11ycolor", + cloneOrCheckout("https://github.com/alex-page/sass-a11ycolor", "2e7ef93ec06f8bbec80b632863e4b2811618af89"); File("${sources.path}/a11ycolor.scss").writeAsStringSync(""" @import '../sass-a11ycolor/dist'; @@ -55,14 +55,14 @@ Future benchmarkGenerate() async { } """); - await cloneOrCheckout("https://github.com/zaydek/duomo", "v0.7.12"); + cloneOrCheckout("https://github.com/zaydek/duomo", "v0.7.12"); File("${sources.path}/duomo.scss") .writeAsStringSync("@import '../duomo/scripts/duomo.scss'"); // Note: This version only supports Node Sass 5.x, which only supports up to // Node 14.x. Once there's a version that support Node Sass 6.x, we should use // that instead. - var carbon = await cloneOrCheckout( + var carbon = cloneOrCheckout( "https://github.com/carbon-design-system/ibm-cloud-cognitive", "@carbon/ibm-cloud-cognitive@0.93.2"); await runAsync("npm", arguments: ["install"], workingDirectory: carbon); @@ -101,9 +101,8 @@ Future _writeNTimes(String path, String text, num times, @Depends(benchmarkGenerate, "pkg-compile-snapshot", "pkg-compile-native", "pkg-npm-release") Future benchmark() async { - var libsass = - await cloneOrCheckout('https://github.com/sass/libsass', 'master'); - var sassc = await cloneOrCheckout('https://github.com/sass/sassc', 'master'); + var libsass = cloneOrCheckout('https://github.com/sass/libsass', 'master'); + var sassc = cloneOrCheckout('https://github.com/sass/sassc', 'master'); await runAsync("make", runOptions: RunOptions( diff --git a/tool/grind/frameworks.dart b/tool/grind/frameworks.dart index 400ca8c9a..72c4019f5 100644 --- a/tool/grind/frameworks.dart +++ b/tool/grind/frameworks.dart @@ -31,7 +31,7 @@ Future fetchBulma() => _getLatestRelease('jgthms/bulma'); /// If [pattern] is passed, this will clone the latest release that matches that /// pattern. Future _getLatestRelease(String slug, {Pattern? pattern}) async { - await cloneOrCheckout('git://github.com/$slug', + cloneOrCheckout('git://github.com/$slug', await _findLatestRelease(slug, pattern: pattern)); } diff --git a/tool/grind/utils.dart b/tool/grind/utils.dart index 7e2ce022d..1135865ee 100644 --- a/tool/grind/utils.dart +++ b/tool/grind/utils.dart @@ -2,7 +2,6 @@ // MIT-style license that can be found in the LICENSE file or at // https://opensource.org/licenses/MIT. -import 'dart:async'; import 'dart:convert'; import 'dart:io'; @@ -45,29 +44,33 @@ String environment(String name) { /// Ensure that the repository at [url] is cloned into the build directory and /// pointing to [ref]. /// +/// If [name] is passed, it's used as the basename of the directory for the +/// repo. Otherwise, [url]'s basename is used. +/// /// Returns the path to the repository. -Future cloneOrCheckout(String url, String ref) async { - var name = p.url.basename(url); - if (p.url.extension(name) == ".git") name = p.url.withoutExtension(name); +String cloneOrCheckout(String url, String ref, {String? name}) { + if (name == null) { + name = p.url.basename(url); + if (p.url.extension(name) == ".git") name = p.url.withoutExtension(name); + } var path = p.join("build", name); if (!Directory(p.join(path, '.git')).existsSync()) { delete(Directory(path)); - await runAsync("git", arguments: ["init", path]); - await runAsync("git", + run("git", arguments: ["init", path]); + run("git", arguments: ["config", "advice.detachedHead", "false"], workingDirectory: path); - await runAsync("git", + run("git", arguments: ["remote", "add", "origin", url], workingDirectory: path); } else { log("Updating $url"); } - await runAsync("git", + run("git", arguments: ["fetch", "origin", "--depth=1", ref], workingDirectory: path); - await runAsync("git", - arguments: ["checkout", "FETCH_HEAD"], workingDirectory: path); + run("git", arguments: ["checkout", "FETCH_HEAD"], workingDirectory: path); log(""); return path;