Enable workspaces from dart 3.5 (#4226)
diff --git a/lib/src/language_version.dart b/lib/src/language_version.dart
index 63ac0e1..5787444 100644
--- a/lib/src/language_version.dart
+++ b/lib/src/language_version.dart
@@ -108,8 +108,7 @@
static const defaultLanguageVersion = LanguageVersion(2, 7);
static const firstVersionWithNullSafety = LanguageVersion(2, 12);
static const firstVersionWithShorterHostedSyntax = LanguageVersion(2, 15);
- // TODO(https://github.com/dart-lang/pub/issues/4127) update when we know actual version.
- static const firstVersionWithWorkspaces = LanguageVersion(3, 7);
+ static const firstVersionWithWorkspaces = LanguageVersion(3, 5);
/// Transform language version to string that can be parsed with
/// [LanguageVersion.parse].
diff --git a/test/descriptor.dart b/test/descriptor.dart
index 915082b..7749e92 100644
--- a/test/descriptor.dart
+++ b/test/descriptor.dart
@@ -117,7 +117,7 @@
}) {
var map = packageMap(name, version, deps, devDeps);
if (resolutionWorkspace && sdk == null) {
- sdk = '3.7.0';
+ sdk = '3.5.0';
}
if (sdk != null) {
map['environment'] = {'sdk': sdk};
diff --git a/test/pubspec_test.dart b/test/pubspec_test.dart
index e714f2e..cbbb0cf 100644
--- a/test/pubspec_test.dart
+++ b/test/pubspec_test.dart
@@ -351,7 +351,7 @@
Pubspec.parse(
'''
environment:
- sdk: ^3.7.0
+ sdk: ^3.5.0
workspace: ['a', 'b', 'c']
''',
sources,
@@ -366,7 +366,7 @@
Pubspec.parse(
'''
environment:
- sdk: ^3.7.0
+ sdk: ^3.5.0
resolution: workspace
''',
sources,
@@ -416,7 +416,7 @@
expectPubspecException(
'''
environment:
- sdk: ^3.7.0
+ sdk: ^3.5.0
workspace: 'a string'
''',
(pubspec) => pubspec.workspace,
@@ -427,7 +427,7 @@
expectPubspecException(
'''
environment:
- sdk: ^3.7.0
+ sdk: ^3.5.0
workspace: ['a string', 24]
''',
(pubspec) => pubspec.workspace,
@@ -438,7 +438,7 @@
expectPubspecException(
'''
environment:
- sdk: ^3.7.0
+ sdk: ^3.5.0
resolution: "sometimes"''',
(pubspec) => pubspec.resolution,
);
diff --git a/test/workspace_test.dart b/test/workspace_test.dart
index f78c514..4aca553 100644
--- a/test/workspace_test.dart
+++ b/test/workspace_test.dart
@@ -23,7 +23,7 @@
extras: {
'workspace': ['pkgs/a'],
},
- sdk: '^3.7.0',
+ sdk: '^3.5.0',
),
dir('pkgs', [
dir('a', [
@@ -37,7 +37,7 @@
]),
]).create();
await pubGet(
- environment: {'_PUB_TEST_SDK_VERSION': '3.7.0'},
+ environment: {'_PUB_TEST_SDK_VERSION': '3.5.0'},
output: contains('+ dev_dep'),
);
final lockfile = loadYaml(
@@ -49,7 +49,7 @@
packageConfigEntry(name: 'dev_dep', version: '1.0.0'),
packageConfigEntry(name: 'a', path: './pkgs/a'),
],
- generatorVersion: '3.7.0',
+ generatorVersion: '3.5.0',
).validate();
});
@@ -64,7 +64,7 @@
extras: {
'workspace': ['pkgs/a', 'pkgs/b'],
},
- sdk: '^3.7.0',
+ sdk: '^3.5.0',
),
dir('pkgs', [
dir('a', [
@@ -87,7 +87,7 @@
]),
]),
]).create();
- await pubGet(environment: {'_PUB_TEST_SDK_VERSION': '3.7.0'});
+ await pubGet(environment: {'_PUB_TEST_SDK_VERSION': '3.5.0'});
final lockfile = loadYaml(
File(p.join(sandbox, appPath, 'pubspec.lock')).readAsStringSync(),
);
@@ -97,7 +97,7 @@
packageConfigEntry(name: 'a', path: './pkgs/a'),
packageConfigEntry(name: 'b', path: './pkgs/b'),
],
- generatorVersion: '3.7.0',
+ generatorVersion: '3.5.0',
).validate();
});
@@ -111,7 +111,7 @@
extras: {
'workspace': ['pkgs/a'],
},
- sdk: '^3.7.0',
+ sdk: '^3.5.0',
),
dir('pkgs', [
dir('a', [
@@ -136,7 +136,7 @@
]),
]),
]).create();
- await pubGet(environment: {'_PUB_TEST_SDK_VERSION': '3.7.0'});
+ await pubGet(environment: {'_PUB_TEST_SDK_VERSION': '3.5.0'});
final lockfile = loadYaml(
File(p.join(sandbox, appPath, 'pubspec.lock')).readAsStringSync(),
);
@@ -147,7 +147,7 @@
packageConfigEntry(name: 'a', path: './pkgs/a'),
packageConfigEntry(name: 'example', path: './pkgs/a/example'),
],
- generatorVersion: '3.7.0',
+ generatorVersion: '3.5.0',
).validate();
});
@@ -160,7 +160,7 @@
extras: {
'workspace': ['pkgs/a'],
},
- sdk: '^3.7.0',
+ sdk: '^3.5.0',
),
dir('pkgs', [
dir('a', [
@@ -174,7 +174,7 @@
]),
]).create();
await pubGet(
- environment: {'_PUB_TEST_SDK_VERSION': '3.7.0'},
+ environment: {'_PUB_TEST_SDK_VERSION': '3.5.0'},
error: contains(
'Because myapp depends on a which depends on myapp ^0.2.3, myapp ^0.2.3 is required',
),
@@ -191,7 +191,7 @@
extras: {
'workspace': ['pkgs/a'],
},
- sdk: '^3.7.0',
+ sdk: '^3.5.0',
),
dir('pkgs', [
dir('a', [
@@ -206,7 +206,7 @@
]),
]),
]).create();
- await pubGet(environment: {'_PUB_TEST_SDK_VERSION': '3.7.0'});
+ await pubGet(environment: {'_PUB_TEST_SDK_VERSION': '3.5.0'});
});
test('reports errors in workspace pubspec.yamls correctly', () async {
@@ -217,7 +217,7 @@
extras: {
'workspace': ['pkgs/a'],
},
- sdk: '^3.7.0',
+ sdk: '^3.5.0',
),
dir('pkgs', [
dir('a', [
@@ -234,7 +234,7 @@
]).create();
final s = p.separator;
await pubGet(
- environment: {'_PUB_TEST_SDK_VERSION': '3.7.0'},
+ environment: {'_PUB_TEST_SDK_VERSION': '3.5.0'},
error: contains(
'Error on line 1, column 118 of pkgs${s}a${s}pubspec.yaml: A dependency specification must be a string or a mapping.',
),
@@ -250,7 +250,7 @@
extras: {
'workspace': ['pkgs/a'],
},
- sdk: '^3.7.0',
+ sdk: '^3.5.0',
),
dir('pkgs', [
dir('a', [
@@ -266,7 +266,7 @@
]),
]).create();
await pubGet(
- environment: {'_PUB_TEST_SDK_VERSION': '3.7.0'},
+ environment: {'_PUB_TEST_SDK_VERSION': '3.5.0'},
error: contains(
'Because every version of a depends on foo from unknown source "posted", version solving failed.',
),
@@ -281,7 +281,7 @@
extras: {
'workspace': ['pkgs/a'],
},
- sdk: '^3.7.0',
+ sdk: '^3.5.0',
),
dir('pkgs', [
dir('a', [
@@ -294,7 +294,7 @@
]).create();
final s = p.separator;
await pubGet(
- environment: {'_PUB_TEST_SDK_VERSION': '3.7.0'},
+ environment: {'_PUB_TEST_SDK_VERSION': '3.5.0'},
error: contains(
'pkgs${s}a${s}pubspec.yaml is included in the workspace from .${s}pubspec.yaml, but does not have `resolution: workspace`.',
),
@@ -309,7 +309,7 @@
extras: {
'workspace': ['pkgs/a'],
},
- sdk: '^3.7.0',
+ sdk: '^3.5.0',
),
dir('pkgs', [
dir('a', [
@@ -325,27 +325,27 @@
]),
]).create();
await pubGet(
- environment: {'_PUB_TEST_SDK_VERSION': '3.7.0'},
+ environment: {'_PUB_TEST_SDK_VERSION': '3.5.0'},
workingDirectory: p.join(sandbox, appPath, 'pkgs'),
output: contains('Resolving dependencies in `..`...'),
);
final s = p.separator;
await pubGet(
- environment: {'_PUB_TEST_SDK_VERSION': '3.7.0'},
+ environment: {'_PUB_TEST_SDK_VERSION': '3.5.0'},
workingDirectory: p.join(sandbox, appPath, 'pkgs', 'a'),
output: contains('Resolving dependencies in `..$s..`...'),
);
await pubGet(
args: ['-C$appPath/pkgs'],
- environment: {'_PUB_TEST_SDK_VERSION': '3.7.0'},
+ environment: {'_PUB_TEST_SDK_VERSION': '3.5.0'},
workingDirectory: sandbox,
output: contains('Resolving dependencies in `$appPath`...'),
);
await pubGet(
args: ['-C..'],
- environment: {'_PUB_TEST_SDK_VERSION': '3.7.0'},
+ environment: {'_PUB_TEST_SDK_VERSION': '3.5.0'},
workingDirectory: p.join(
sandbox,
appPath,
@@ -363,7 +363,7 @@
extras: {
'workspace': ['a'],
},
- sdk: '^3.7.0',
+ sdk: '^3.5.0',
),
dir('a', [
libPubspec(
@@ -377,7 +377,7 @@
]),
]).create();
await pubGet(
- environment: {'_PUB_TEST_SDK_VERSION': '3.7.0'},
+ environment: {'_PUB_TEST_SDK_VERSION': '3.5.0'},
error: contains(
'Could not find a file named "pubspec.yaml" in "${p.join(sandbox, appPath, 'a', 'b')}".\n'
'That was included in the workspace of ${p.join('.', 'a', 'pubspec.yaml')}.\n'
@@ -420,7 +420,7 @@
'workspace': ['pkgs/a', 'pkgs/b'],
},
deps: {'both': '^1.0.0', 'b': null},
- sdk: '^3.7.0',
+ sdk: '^3.5.0',
),
dir('bin', [file('myappmain.dart')]),
dir('pkgs', [
@@ -447,10 +447,10 @@
]).create();
await runPub(
args: ['deps'],
- environment: {'_PUB_TEST_SDK_VERSION': '3.7.0'},
+ environment: {'_PUB_TEST_SDK_VERSION': '3.5.0'},
output: contains(
'''
-Dart SDK 3.7.0
+Dart SDK 3.5.0
a 1.1.1
├── both...
├── foo 1.0.0
@@ -467,9 +467,9 @@
await runPub(
args: ['deps', '--style=list', '--dev'],
- environment: {'_PUB_TEST_SDK_VERSION': '3.7.0'},
+ environment: {'_PUB_TEST_SDK_VERSION': '3.5.0'},
output: '''
-Dart SDK 3.7.0
+Dart SDK 3.5.0
myapp 1.2.3
dependencies:
@@ -504,9 +504,9 @@
await runPub(
args: ['deps', '--style=list', '--no-dev'],
- environment: {'_PUB_TEST_SDK_VERSION': '3.7.0'},
+ environment: {'_PUB_TEST_SDK_VERSION': '3.5.0'},
output: '''
-Dart SDK 3.7.0
+Dart SDK 3.5.0
myapp 1.2.3
dependencies:
@@ -537,9 +537,9 @@
);
await runPub(
args: ['deps', '--style=compact'],
- environment: {'_PUB_TEST_SDK_VERSION': '3.7.0'},
+ environment: {'_PUB_TEST_SDK_VERSION': '3.5.0'},
output: '''
- Dart SDK 3.7.0
+ Dart SDK 3.5.0
myapp 1.2.3
dependencies:
@@ -566,7 +566,7 @@
);
await runPub(
args: ['deps', '--executables'],
- environment: {'_PUB_TEST_SDK_VERSION': '3.7.0'},
+ environment: {'_PUB_TEST_SDK_VERSION': '3.5.0'},
output: '''
myapp:myappmain
both:bothmain
@@ -577,7 +577,7 @@
test('`pub add` acts on the work package', () async {
final server = await servePackages();
- server.serve('foo', '1.0.0', sdk: '^3.7.0');
+ server.serve('foo', '1.0.0', sdk: '^3.5.0');
await dir(appPath, [
libPubspec(
'myapp',
@@ -585,7 +585,7 @@
extras: {
'workspace': ['pkgs/a'],
},
- sdk: '^3.7.0',
+ sdk: '^3.5.0',
),
dir('pkgs', [
dir('a', [
@@ -598,13 +598,13 @@
]),
]).create();
- await pubGet(environment: {'_PUB_TEST_SDK_VERSION': '3.7.0'});
+ await pubGet(environment: {'_PUB_TEST_SDK_VERSION': '3.5.0'});
final aDir = p.join(sandbox, appPath, 'pkgs', 'a');
await pubAdd(
args: ['foo'],
output: contains('+ foo 1.0.0'),
workingDirectory: aDir,
- environment: {'_PUB_TEST_SDK_VERSION': '3.7.0'},
+ environment: {'_PUB_TEST_SDK_VERSION': '3.5.0'},
);
await dir(appPath, [
dir('pkgs', [
@@ -622,7 +622,7 @@
test('`pub remove` acts on the work package', () async {
final server = await servePackages();
- server.serve('foo', '1.0.0', sdk: '^3.7.0');
+ server.serve('foo', '1.0.0', sdk: '^3.5.0');
await dir(appPath, [
libPubspec(
'myapp',
@@ -631,7 +631,7 @@
'workspace': ['pkgs/a'],
},
deps: {'foo': '^1.0.0'},
- sdk: '^3.7.0',
+ sdk: '^3.5.0',
),
dir('pkgs', [
dir('a', [
@@ -645,13 +645,13 @@
]),
]).create();
- await pubGet(environment: {'_PUB_TEST_SDK_VERSION': '3.7.0'});
+ await pubGet(environment: {'_PUB_TEST_SDK_VERSION': '3.5.0'});
final aDir = p.join(sandbox, appPath, 'pkgs', 'a');
await pubRemove(
args: ['foo'],
output: isNot(contains('- foo 1.0.0')),
workingDirectory: aDir,
- environment: {'_PUB_TEST_SDK_VERSION': '3.7.0'},
+ environment: {'_PUB_TEST_SDK_VERSION': '3.5.0'},
);
await dir(appPath, [
dir('pkgs', [
@@ -669,7 +669,7 @@
args: ['foo'],
output: contains('- foo 1.0.0'),
workingDirectory: path(appPath),
- environment: {'_PUB_TEST_SDK_VERSION': '3.7.0'},
+ environment: {'_PUB_TEST_SDK_VERSION': '3.5.0'},
);
});
@@ -682,7 +682,7 @@
extras: {
'workspace': ['pkgs/a'],
},
- sdk: '^3.7.0',
+ sdk: '^3.5.0',
),
dir('pkgs', [
dir(
@@ -708,7 +708,7 @@
unmanagedPackageConfig.createSync(recursive: true);
unmanagedLockFile.createSync(recursive: true);
- await pubGet(environment: {'_PUB_TEST_SDK_VERSION': '3.7.0'});
+ await pubGet(environment: {'_PUB_TEST_SDK_VERSION': '3.5.0'});
expect(strayLockFile.statSync().type, FileSystemEntityType.notFound);
expect(strayPackageConfig.statSync().type, FileSystemEntityType.notFound);
@@ -724,7 +724,7 @@
libPubspec(
'myapp',
'1.2.3',
- sdk: '^3.7.0',
+ sdk: '^3.5.0',
extras: {
'workspace': ['pkgs/a', 'pkgs'],
},
@@ -754,7 +754,7 @@
`.${s}pkgs${s}a${s}pubspec.yaml` is included in the workspace, both from:
* `.${s}pkgs${s}pubspec.yaml` and
* .${s}pubspec.yaml.''',
- environment: {'_PUB_TEST_SDK_VERSION': '3.7.0'},
+ environment: {'_PUB_TEST_SDK_VERSION': '3.5.0'},
);
});
@@ -765,14 +765,14 @@
libPubspec(
'myapp',
'1.2.3',
- sdk: '^3.7.0',
+ sdk: '^3.5.0',
extras: {
'workspace': ['../'],
},
),
]).create();
await pubGet(
- environment: {'_PUB_TEST_SDK_VERSION': '3.7.0'},
+ environment: {'_PUB_TEST_SDK_VERSION': '3.5.0'},
error: contains('"workspace" members must be subdirectories'),
exitCode: DATA,
);
@@ -783,14 +783,14 @@
libPubspec(
'myapp',
'1.2.3',
- sdk: '^3.7.0',
+ sdk: '^3.5.0',
extras: {
'workspace': ['.'],
},
),
]).create();
await pubGet(
- environment: {'_PUB_TEST_SDK_VERSION': '3.7.0'},
+ environment: {'_PUB_TEST_SDK_VERSION': '3.5.0'},
error: contains('"workspace" members must be subdirectories'),
exitCode: DATA,
);
@@ -802,14 +802,14 @@
libPubspec(
'myapp',
'1.2.3',
- sdk: '^3.7.0',
+ sdk: '^3.5.0',
extras: {
'workspace': [p.join(sandbox, appPath, 'a')],
},
),
]).create();
await pubGet(
- environment: {'_PUB_TEST_SDK_VERSION': '3.7.0'},
+ environment: {'_PUB_TEST_SDK_VERSION': '3.5.0'},
error: contains('"workspace" members must be relative paths'),
exitCode: DATA,
);
@@ -824,7 +824,7 @@
'myapp',
'1.2.3',
deps: {'foo': '^1.0.0'},
- sdk: '^3.7.0',
+ sdk: '^3.5.0',
extras: {
'workspace': ['a'],
},
@@ -838,11 +838,11 @@
),
]),
]).create();
- await pubGet(environment: {'_PUB_TEST_SDK_VERSION': '3.7.0'});
+ await pubGet(environment: {'_PUB_TEST_SDK_VERSION': '3.5.0'});
server.serve('foo', '1.5.0');
server.serve('bar', '1.5.0');
await pubUpgrade(
- environment: {'_PUB_TEST_SDK_VERSION': '3.7.0'},
+ environment: {'_PUB_TEST_SDK_VERSION': '3.5.0'},
output: contains(
'''
> bar 1.5.0 (was 1.0.0)
@@ -862,7 +862,7 @@
'myapp',
'1.2.3',
deps: {'foo': '^1.0.0', 'bar': '1.0.0'},
- sdk: '^3.7.0',
+ sdk: '^3.5.0',
extras: {
'workspace': ['a'],
},
@@ -878,12 +878,12 @@
]).create();
await pubGet(
- environment: {'_PUB_TEST_SDK_VERSION': '3.7.0'},
+ environment: {'_PUB_TEST_SDK_VERSION': '3.5.0'},
output: contains('+ foo 1.5.0'),
);
await pubUpgrade(
args: ['--major-versions'],
- environment: {'_PUB_TEST_SDK_VERSION': '3.7.0'},
+ environment: {'_PUB_TEST_SDK_VERSION': '3.5.0'},
output: contains(
'''
Changed 2 constraints in pubspec.yaml:
@@ -900,7 +900,7 @@
'myapp',
'1.2.3',
deps: {'foo': '^2.0.0', 'bar': '^2.0.0'},
- sdk: '^3.7.0',
+ sdk: '^3.5.0',
extras: {
'workspace': ['a'],
},
@@ -927,7 +927,7 @@
'myapp',
'1.2.3',
deps: {'foo': '^1.0.0', 'bar': '1.0.0'},
- sdk: '^3.7.0',
+ sdk: '^3.5.0',
extras: {
'workspace': ['a'],
},
@@ -943,12 +943,12 @@
]).create();
await pubGet(
- environment: {'_PUB_TEST_SDK_VERSION': '3.7.0'},
+ environment: {'_PUB_TEST_SDK_VERSION': '3.5.0'},
output: contains('+ foo 1.5.0'),
);
await pubUpgrade(
args: ['--major-versions', 'foo'],
- environment: {'_PUB_TEST_SDK_VERSION': '3.7.0'},
+ environment: {'_PUB_TEST_SDK_VERSION': '3.5.0'},
output: contains(
'''
Changed 1 constraint in pubspec.yaml:
@@ -961,7 +961,7 @@
// Second run should mention "any pubspec.yaml".
await pubUpgrade(
args: ['--major-versions', 'foo'],
- environment: {'_PUB_TEST_SDK_VERSION': '3.7.0'},
+ environment: {'_PUB_TEST_SDK_VERSION': '3.5.0'},
output: contains(
'''
No changes to any pubspec.yaml!''',
@@ -969,7 +969,7 @@
);
await pubUpgrade(
args: ['--major-versions', 'foo', '--dry-run'],
- environment: {'_PUB_TEST_SDK_VERSION': '3.7.0'},
+ environment: {'_PUB_TEST_SDK_VERSION': '3.5.0'},
output: contains(
'''
No changes would be made to any pubspec.yaml!''',
@@ -981,7 +981,7 @@
'myapp',
'1.2.3',
deps: {'foo': '^2.0.0', 'bar': '1.0.0'},
- sdk: '^3.7.0',
+ sdk: '^3.5.0',
extras: {
'workspace': ['a'],
},
@@ -1006,7 +1006,7 @@
'myapp',
'1.2.3',
deps: {'foo': '^1.0.0', 'bar': '^1.0.0'},
- sdk: '^3.7.0',
+ sdk: '^3.5.0',
extras: {
'workspace': ['a', 'b'],
},
@@ -1030,12 +1030,12 @@
]).create();
await pubGet(
- environment: {'_PUB_TEST_SDK_VERSION': '3.7.0'},
+ environment: {'_PUB_TEST_SDK_VERSION': '3.5.0'},
output: contains('+ foo 1.5.0'),
);
await pubUpgrade(
args: ['--tighten'],
- environment: {'_PUB_TEST_SDK_VERSION': '3.7.0'},
+ environment: {'_PUB_TEST_SDK_VERSION': '3.5.0'},
output: contains(
'''
Changed 2 constraints in pubspec.yaml:
@@ -1052,7 +1052,7 @@
'myapp',
'1.2.3',
deps: {'foo': '^1.5.0', 'bar': '^1.5.0'},
- sdk: '^3.7.0',
+ sdk: '^3.5.0',
extras: {
'workspace': ['a', 'b'],
},
@@ -1086,7 +1086,7 @@
'myapp',
'1.2.3',
deps: {'foo': '^1.0.0', 'bar': '^1.0.0'},
- sdk: '^3.7.0',
+ sdk: '^3.5.0',
extras: {
'workspace': ['a', 'b'],
},
@@ -1110,12 +1110,12 @@
]).create();
await pubGet(
- environment: {'_PUB_TEST_SDK_VERSION': '3.7.0'},
+ environment: {'_PUB_TEST_SDK_VERSION': '3.5.0'},
output: contains('+ foo 1.5.0'),
);
await pubUpgrade(
args: ['--tighten', '--major-versions'],
- environment: {'_PUB_TEST_SDK_VERSION': '3.7.0'},
+ environment: {'_PUB_TEST_SDK_VERSION': '3.5.0'},
output: contains(
'''
Changed 2 constraints in pubspec.yaml: