Skip to content
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 3 additions & 31 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ ENV PUB_CACHE=/opt/dart/pub-cache \
PUB_ENVIRONMENT="dependabot" \
PATH="${PATH}:/opt/dart/dart-sdk/bin"

ARG DART_VERSION=2.16.2
ARG DART_VERSION=2.17.0
RUN DART_ARCH=${TARGETARCH} \
&& if [ "$TARGETARCH" = "amd64" ]; then DART_ARCH=x64; fi \
&& curl --connect-timeout 15 --retry 5 "https://storage.googleapis.com/dart-archive/channels/stable/release/${DART_VERSION}/sdk/dartsdk-linux-${DART_ARCH}-release.zip" > "/tmp/dart-sdk.zip" \
Expand All @@ -248,42 +248,13 @@ RUN DART_ARCH=${TARGETARCH} \
&& chmod -R o+rx "/opt/dart/dart-sdk" \
&& rm "/tmp/dart-sdk.zip" \
&& dart --version
# We pull the dependency_services from the dart-lang/pub repo as it is not
# exposed from the Dart SDK (yet...).
RUN git clone https://github.com/dart-lang/pub.git /opt/dart/pub \
&& git -C /opt/dart/pub checkout 6f20a94b074a1c2dc82d429fa04d365b4bcf65b6 \
&& dart pub global activate --source path /opt/dart/pub \
&& chmod -R o+r "/opt/dart/pub" \
&& chown -R dependabot:dependabot "$PUB_CACHE" \
&& chown -R dependabot:dependabot /opt/dart/pub

# Install Flutter
ARG FLUTTER_VERSION=2.10.3
RUN curl --connect-timeout 15 --retry 5 "https://storage.googleapis.com/flutter_infra_release/releases/stable/linux/flutter_linux_${FLUTTER_VERSION}-stable.tar.xz" > "/tmp/flutter.xz" \
&& tar xf "/tmp/flutter.xz" -C /opt/dart \
&& rm "/tmp/flutter.xz" \
&& chmod -R o+rx "/opt/dart/flutter" \
&& chown -R dependabot:dependabot "/opt/dart/flutter" \
# To reduce space usage we delete all of the flutter sdk except the few
# things needed for pub resolutions:
# * The version file
# * The flutter sdk packages.
&& find "/opt/dart/flutter" \
! -path '/opt/dart/flutter/version' \
! -path '/opt/dart/flutter/packages/*' \
! -path '/opt/dart/flutter/packages' \
! -path '/opt/dart/flutter/bin/cache/pkg/*' \
! -path /opt/dart/flutter/bin/cache/pkg \
! -path /opt/dart/flutter/bin/cache \
! -path /opt/dart/flutter/bin \
! -path /opt/dart/flutter \
-delete

COPY --chown=dependabot:dependabot LICENSE /home/dependabot
COPY --chown=dependabot:dependabot composer/helpers /opt/composer/helpers
COPY --chown=dependabot:dependabot bundler/helpers /opt/bundler/helpers
COPY --chown=dependabot:dependabot go_modules/helpers /opt/go_modules/helpers
COPY --chown=dependabot:dependabot hex/helpers /opt/hex/helpers
COPY --chown=dependabot:dependabot pub/helpers /opt/pub/helpers
COPY --chown=dependabot:dependabot npm_and_yarn/helpers /opt/npm_and_yarn/helpers
COPY --chown=dependabot:dependabot python/helpers /opt/python/helpers
COPY --chown=dependabot:dependabot terraform/helpers /opt/terraform/helpers
Expand All @@ -300,6 +271,7 @@ RUN bash /opt/composer/helpers/v2/build
RUN bash /opt/go_modules/helpers/build
RUN bash /opt/hex/helpers/build
RUN bash /opt/npm_and_yarn/helpers/build
RUN bash /opt/pub/helpers/build
RUN bash /opt/python/helpers/build
RUN bash /opt/terraform/helpers/build

Expand Down
2 changes: 2 additions & 0 deletions pub/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@
/tmp
/dependabot-*.gem
Gemfile.lock
.dart_tool/
.packages
28 changes: 23 additions & 5 deletions pub/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ Dart (pub) support for [`dependabot-core`][core-repo].
- If the version found is ignored (by dependabot config) no update will happen (even if, an earlier version could be used)
- Limited metadata support (just retrieves the repository link).
- No support for auhtentication of private package repositories (mostly a configuration issue).
- Only stable versions of Dart and Flutter supported.
- `updated_dependencies_after_full_unlock` only allows updating to a later version, if the latest version that is mutually compatible with other dependencies is the latest version of the said package. This is a dependabot limitation.

### Running locally
Expand All @@ -36,6 +35,8 @@ Dart (pub) support for [`dependabot-core`][core-repo].
The `dart pub` repo offers an experimental dependency services interface which
allows checking for available updates.

It is implemented as helpers/bin/dependency_services.dart, that is mainly a wrapper around the implementation in the [pub client](https://github.com/dart-lang/pub).

#### List Dependencies

```js
Expand Down Expand Up @@ -83,16 +84,16 @@ allows checking for available updates.
"latest": "<version>",

// In the following possible upgrades are listed for different
//
//
// The constraints are given in three versions, according to different
// strategies for updating constraint to allow the new version of a
// strategies for updating constraint to allow the new version of a
// package:
//
// * "constraintBumped": always update the constraint lower bound to match
// the new version.
// * "constraintBumpedIfNeeded": leave the constraint if the original
// constraint allows the new version.
// * "constraintWidened": extend only the upper bound to include the new
// * "constraintWidened": extend only the upper bound to include the new
// version.

// If it is possible to upgrade the current version without making any
Expand Down Expand Up @@ -228,4 +229,21 @@ the url of the repository.
"type": "git" || "hosted" || "path" || "sdk", // Name of the source.
... // Other keys are free form json information about the dependency
}
```
```
## Detection of Flutter and Dart SDK versions.

`dependency_services` should be run in the context of the right Flutter and
Dart SDK versions as these will affect package resolution.

The pub dependabot integration supports the flutter releases on the `stable` and
`beta`
[channel](https://github.com/flutter/flutter/wiki/Flutter-build-release-channels).
Each Flutter release comes with a matching Dart release.

The helpers/bin/infer_sdk_versions.dart script will parse the root pubspec, and
Comment thread
sigurdm marked this conversation as resolved.
Outdated
try to determine the right release based on the sdk constraints and the list of
Comment thread
sigurdm marked this conversation as resolved.
Outdated
available releases:

* The latest stable release that matches the sdk constraints will be chosen
Comment thread
sigurdm marked this conversation as resolved.
Outdated
* If there is no stable release it will choose the newest beta that matches the
sdk constraints.
Comment thread
sigurdm marked this conversation as resolved.
Outdated
96 changes: 96 additions & 0 deletions pub/dependency_services/pubspec.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
# Generated by pub
# See https://dart.dev/tools/pub/glossary#lockfile
packages:
args:
dependency: "direct main"
description:
name: args
url: "https://pub.dartlang.org"
source: hosted
version: "2.3.1"
async:
dependency: transitive
description:
name: async
url: "https://pub.dartlang.org"
source: hosted
version: "2.9.0"
collection:
dependency: "direct main"
description:
name: collection
url: "https://pub.dartlang.org"
source: hosted
version: "1.16.0"
http:
dependency: "direct main"
description:
name: http
url: "https://pub.dartlang.org"
source: hosted
version: "0.13.4"
http_parser:
dependency: transitive
description:
name: http_parser
url: "https://pub.dartlang.org"
source: hosted
version: "4.0.1"
meta:
dependency: transitive
description:
name: meta
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.0"
path:
dependency: "direct main"
description:
name: path
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.2"
pub_semver:
dependency: "direct main"
description:
name: pub_semver
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.1"
source_span:
dependency: transitive
description:
name: source_span
url: "https://pub.dartlang.org"
source: hosted
version: "1.9.0"
string_scanner:
dependency: transitive
description:
name: string_scanner
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.1"
term_glyph:
dependency: transitive
description:
name: term_glyph
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0"
typed_data:
dependency: transitive
description:
name: typed_data
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.1"
yaml:
dependency: "direct main"
description:
name: yaml
url: "https://pub.dartlang.org"
source: hosted
version: "3.1.1"
sdks:
dart: ">=2.16.0 <3.0.0"
11 changes: 11 additions & 0 deletions pub/dependency_services/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: helpers
environment:
sdk: '>=2.16.0 <3.0.0'

dependencies:
path: ^1.8.2
yaml: ^3.1.1
args: ^2.3.1
collection: ^1.16.0
pub_semver: ^2.1.1
http: ^0.13.4
78 changes: 78 additions & 0 deletions pub/helpers/bin/dependency_services.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/// Support for automated upgrades.
library dependency_services;

import 'dart:async';

import 'package:args/args.dart';
import 'package:args/command_runner.dart';
import 'package:pub/src/command.dart';
import 'package:pub/src/command/dependency_services.dart';
import 'package:pub/src/exit_codes.dart' as exit_codes;
import 'package:pub/src/io.dart';
import 'package:pub/src/log.dart' as log;

class _DependencyServicesCommandRunner extends CommandRunner<int>
implements PubTopLevel {
@override
String? get directory => argResults['directory'];

@override
bool get captureStackChains => argResults['verbose'];

@override
bool get trace => argResults['verbose'];

ArgResults? _argResults;

/// The top-level options parsed by the command runner.
@override
ArgResults get argResults {
final a = _argResults;
if (a == null) {
throw StateError(
'argResults cannot be used before Command.run is called.');
}
return a;
}

_DependencyServicesCommandRunner()
: super('dependency_services', 'Support for automatic upgrades',
usageLineLength: lineLength) {
argParser.addFlag('verbose',
abbr: 'v', negatable: false, help: 'Shortcut for "--verbosity=all".');
argParser.addOption(
'directory',
abbr: 'C',
help: 'Run the subcommand in the directory<dir>.',
defaultsTo: '.',
valueHelp: 'dir',
);

addCommand(DependencyServicesListCommand());
addCommand(DependencyServicesReportCommand());
addCommand(DependencyServicesApplyCommand());
}

@override
Future<int> run(Iterable<String> args) async {
try {
_argResults = parse(args);
return await runCommand(argResults) ?? exit_codes.SUCCESS;
} on UsageException catch (error) {
log.exception(error);
return exit_codes.USAGE;
}
}

@override
void printUsage() {
log.message(usage);
}

@override
log.Verbosity get verbosity => log.Verbosity.normal;
}

Future<void> main(List<String> arguments) async {
await flushThenExit(await _DependencyServicesCommandRunner().run(arguments));
}
Loading