mirror of
https://github.com/danog/dart-sass.git
synced 2025-01-22 13:51:31 +01:00
parent
66ab368582
commit
1c773f1cb1
@ -1,6 +1,7 @@
|
||||
## 1.0.0-beta.8
|
||||
|
||||
* Support version 1.0.0-beta.11 of the Sass embedded protocol:
|
||||
* Set CanonicalizeRequest.from_import.
|
||||
* Support `VersionRequest` and `VersionResponse`.
|
||||
* Set `CanonicalizeRequest.from_import`.
|
||||
|
||||
* Properly throw errors for range checks for colors.
|
||||
|
@ -56,6 +56,19 @@ class Dispatcher {
|
||||
}
|
||||
|
||||
switch (message.whichMessage()) {
|
||||
case InboundMessage_Message.versionRequest:
|
||||
_send(OutboundMessage()
|
||||
..versionResponse = (OutboundMessage_VersionResponse()
|
||||
..protocolVersion =
|
||||
const String.fromEnvironment("protocol-version")
|
||||
..compilerVersion =
|
||||
const String.fromEnvironment("compiler-version")
|
||||
..implementationVersion =
|
||||
const String.fromEnvironment("implementation-version")
|
||||
..implementationName = "Dart Sass"
|
||||
..id = message.versionRequest.id));
|
||||
break;
|
||||
|
||||
case InboundMessage_Message.compileRequest:
|
||||
var request = message.compileRequest;
|
||||
var response = await callback(request);
|
||||
|
@ -22,9 +22,12 @@ dependencies:
|
||||
typed_data: ^1.1.0
|
||||
|
||||
dev_dependencies:
|
||||
cli_pkg: ^1.2.0
|
||||
cli_pkg: ^1.4.0
|
||||
grinder: ^0.9.0
|
||||
protoc_plugin: ^20.0.0
|
||||
path: ^1.6.0
|
||||
test: ^1.0.0
|
||||
test_descriptor: ^2.0.0
|
||||
yaml: ^3.1.0
|
||||
pubspec_parse: ^1.0.0
|
||||
pub_semver: ^2.0.0
|
||||
|
@ -3,6 +3,7 @@
|
||||
// https://opensource.org/licenses/MIT.
|
||||
|
||||
import 'package:path/path.dart' as p;
|
||||
import 'package:pub_semver/pub_semver.dart';
|
||||
import 'package:source_maps/source_maps.dart' as source_maps;
|
||||
import 'package:test/test.dart';
|
||||
import 'package:test_descriptor/test_descriptor.dart' as d;
|
||||
@ -33,6 +34,19 @@ void main() {
|
||||
});
|
||||
});
|
||||
|
||||
test("a version response is valid", () async {
|
||||
process.inbound.add(InboundMessage()
|
||||
..versionRequest = (InboundMessage_VersionRequest()..id = 123));
|
||||
var response = (await process.outbound.next).versionResponse;
|
||||
expect(response.id, equals(123));
|
||||
|
||||
Version.parse(response.protocolVersion); // shouldn't throw
|
||||
Version.parse(response.compilerVersion); // shouldn't throw
|
||||
Version.parse(response.implementationVersion); // shouldn't throw
|
||||
expect(response.implementationName, equals("Dart Sass"));
|
||||
await process.kill();
|
||||
});
|
||||
|
||||
group("compiles CSS from", () {
|
||||
test("an SCSS string by default", () async {
|
||||
process.inbound.add(compileString("a {b: 1px + 2px}"));
|
||||
@ -41,22 +55,21 @@ void main() {
|
||||
});
|
||||
|
||||
test("an SCSS string explicitly", () async {
|
||||
process.inbound.add(compileString("a {b: 1px + 2px}",
|
||||
syntax: Syntax.SCSS));
|
||||
process.inbound
|
||||
.add(compileString("a {b: 1px + 2px}", syntax: Syntax.SCSS));
|
||||
await expectLater(process.outbound, emits(isSuccess("a { b: 3px; }")));
|
||||
await process.kill();
|
||||
});
|
||||
|
||||
test("an indented syntax string", () async {
|
||||
process.inbound.add(compileString("a\n b: 1px + 2px",
|
||||
syntax: Syntax.INDENTED));
|
||||
process.inbound
|
||||
.add(compileString("a\n b: 1px + 2px", syntax: Syntax.INDENTED));
|
||||
await expectLater(process.outbound, emits(isSuccess("a { b: 3px; }")));
|
||||
await process.kill();
|
||||
});
|
||||
|
||||
test("a plain CSS string", () async {
|
||||
process.inbound
|
||||
.add(compileString("a {b: c}", syntax: Syntax.CSS));
|
||||
process.inbound.add(compileString("a {b: c}", syntax: Syntax.CSS));
|
||||
await expectLater(process.outbound, emits(isSuccess("a { b: c; }")));
|
||||
await process.kill();
|
||||
});
|
||||
@ -84,16 +97,16 @@ void main() {
|
||||
|
||||
group("compiles CSS in", () {
|
||||
test("expanded mode", () async {
|
||||
process.inbound.add(compileString("a {b: 1px + 2px}",
|
||||
style: OutputStyle.EXPANDED));
|
||||
process.inbound
|
||||
.add(compileString("a {b: 1px + 2px}", style: OutputStyle.EXPANDED));
|
||||
await expectLater(
|
||||
process.outbound, emits(isSuccess(equals("a {\n b: 3px;\n}"))));
|
||||
await process.kill();
|
||||
});
|
||||
|
||||
test("compressed mode", () async {
|
||||
process.inbound.add(compileString("a {b: 1px + 2px}",
|
||||
style: OutputStyle.COMPRESSED));
|
||||
process.inbound.add(
|
||||
compileString("a {b: 1px + 2px}", style: OutputStyle.COMPRESSED));
|
||||
await expectLater(process.outbound, emits(isSuccess(equals("a{b:3px}"))));
|
||||
await process.kill();
|
||||
});
|
||||
@ -204,8 +217,7 @@ void main() {
|
||||
|
||||
var logEvent = getLogEvent(await process.outbound.next);
|
||||
expect(logEvent.compilationId, equals(0));
|
||||
expect(logEvent.type,
|
||||
equals(LogEventType.DEPRECATION_WARNING));
|
||||
expect(logEvent.type, equals(LogEventType.DEPRECATION_WARNING));
|
||||
expect(
|
||||
logEvent.message,
|
||||
equals(
|
||||
@ -226,8 +238,7 @@ void main() {
|
||||
|
||||
var logEvent = getLogEvent(await process.outbound.next);
|
||||
expect(logEvent.compilationId, equals(0));
|
||||
expect(logEvent.type,
|
||||
equals(LogEventType.DEPRECATION_WARNING));
|
||||
expect(logEvent.type, equals(LogEventType.DEPRECATION_WARNING));
|
||||
expect(
|
||||
logEvent.message,
|
||||
equals("As of Dart Sass 2.0.0, !global assignments won't be able to "
|
||||
@ -358,8 +369,8 @@ a {
|
||||
});
|
||||
|
||||
test("caused by using Sass features in CSS", () async {
|
||||
process.inbound.add(
|
||||
compileString("a {b: 1px + 2px}", syntax: Syntax.CSS));
|
||||
process.inbound
|
||||
.add(compileString("a {b: 1px + 2px}", syntax: Syntax.CSS));
|
||||
|
||||
var failure = getCompileFailure(await process.outbound.next);
|
||||
expect(failure.message, equals("Operators aren't allowed in plain CSS."));
|
||||
|
@ -6,16 +6,32 @@ import 'dart:io';
|
||||
|
||||
import 'package:cli_pkg/cli_pkg.dart' as pkg;
|
||||
import 'package:grinder/grinder.dart';
|
||||
import 'package:yaml/yaml.dart';
|
||||
|
||||
import 'utils.dart';
|
||||
|
||||
main(List<String> args) {
|
||||
pkg.githubBearerToken.fn = () => Platform.environment["GH_BEARER_TOKEN"]!;
|
||||
|
||||
pkg.environmentConstants.fn = () => {
|
||||
...pkg.environmentConstants.defaultValue,
|
||||
"protocol-version":
|
||||
File('build/embedded-protocol/VERSION').readAsStringSync().trim(),
|
||||
"compiler-version": pkg.pubspec.version!.toString(),
|
||||
"implementation-version": _implementationVersion
|
||||
};
|
||||
|
||||
pkg.addGithubTasks();
|
||||
grind(args);
|
||||
}
|
||||
|
||||
/// Returns the version of Dart Sass that this package uses.
|
||||
String get _implementationVersion {
|
||||
var lockfile = loadYaml(File('pubspec.lock').readAsStringSync(),
|
||||
sourceUrl: Uri(path: 'pubspec.lock'));
|
||||
return lockfile['packages']['sass']['version'];
|
||||
}
|
||||
|
||||
@Task('Compile the protocol buffer definition to a Dart library.')
|
||||
protobuf() async {
|
||||
Directory('build').createSync(recursive: true);
|
||||
|
Loading…
x
Reference in New Issue
Block a user