Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion .devcontainer/cargo/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"version": "lts"
}
},
"onCreateCommand": "node scripts/prepare-demo.mjs cargo",
"onCreateCommand": ".devcontainer/cargo/setup.sh",
"waitFor": "onCreateCommand",
"customizations": {
"vscode": {
Expand Down
26 changes: 26 additions & 0 deletions .devcontainer/cargo/setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env bash
# Creation-time setup for the Rust demo Codespace.
#
# Drift's Rust surface diff shells out to `cargo public-api`, which reads
# rustdoc's unstable JSON output and so needs the nightly toolchain. Drift will
# install both itself on first analysis (`tools.autoInstall` defaults to true),
# but `cargo install cargo-public-api` compiles from source — several minutes
# with the Drift panel apparently frozen. Doing it here moves that wait into
# the Codespace build, where it belongs.
#
# cargo-public-api is pinned; the nightly channel is not, matching what Drift's
# own auto-install does (`rustup toolchain install nightly --profile minimal`).
set -euo pipefail

CARGO_PUBLIC_API_VERSION="0.52.0"

echo "==> Installing nightly toolchain (required by cargo public-api)"
rustup toolchain install nightly --profile minimal

echo "==> Installing cargo-public-api $CARGO_PUBLIC_API_VERSION"
cargo install cargo-public-api --locked --version "$CARGO_PUBLIC_API_VERSION"

echo "==> Preparing the Rust demo"
node scripts/prepare-demo.mjs cargo

echo "==> Rust demo ready"
2 changes: 1 addition & 1 deletion .devcontainer/vcpkg/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"codespaces": {
"openFiles": [
"demos/vcpkg/DEMO.md",
"demos/vcpkg/src/main.cpp",
"demos/vcpkg/src/tests.cpp",
"demos/vcpkg/vcpkg.json"
]
}
Expand Down
88 changes: 45 additions & 43 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,55 +1,60 @@
# Drift demos

Example projects for Drift's **Try Drift in your browser** experience. Each one
is a tiny real project pinned to an old version of a real dependency, with
source code that uses APIs the newer version breaks.
Small example projects for trying [Drift](https://github.com/trydrift/drift) in
the browser. Each one is pinned to an old version of a real dependency and uses
an API the newer version breaks.

Open one in a Codespace and Drift is already installed, the upgrade is already
applied, and there is something real for it to find.
Open one in a Codespace: Drift is installed, the upgrade is already applied, and
there is something real for it to find.

## How it works
## How the demo state works

Each demo is committed at the **old** dependency version, with source code that
was correct for it. Codespace creation edits the manifest to the **new** version
and leaves the source alone:
Each demo is committed at the **old** dependency version, with source that was
correct for it. Codespace creation edits the manifest to the **new** version and
leaves the source alone:

```
committed: dependency@OLD + source written for OLD
after setup: dependency@NEW + source written for OLD ← Drift analyses this
```

`git status` in a fresh Codespace shows only the manifest as modified. Every
breaking usage in the source is marked with a `BREAKING` comment explaining what
changed and why it no longer works.
`git status` in a fresh Codespace shows only the manifest as modified. Each
breaking usage carries a `BREAKING` comment naming the change.

## The demos

| Ecosystem | Language | Dependency | Upgrade |
| --- | --- | --- | --- |
| `npm` | JavaScript / TypeScript | `axios` | 0.21.4 → 1.7.7 |
| `pypi` | Python | `werkzeug` | 2.0.3 → 2.1.0 |
| `go` | Go | `golang.org/x/exp` | 2023-05 → 2023-10 |
| `cargo` | Rust | `clap` | 2.34.0 → 4.5.4 |
| `maven` | Java / Kotlin / Scala | `com.google.guava:guava` | 20.0 → 21.0 |
| `rubygems` | Ruby | `rack` | 3.0.0 → 3.1.0 |
| `nuget` | .NET | `AutoMapper` | 8.1.1 → 9.0.0 |
| `packagist` | PHP | `monolog/monolog` | 2.9.3 → 3.5.0 |
| `hex` | Elixir / Erlang | `plug` | 1.13.6 → 1.15.0 |
| `pub` | Dart / Flutter | `dio` | 4.0.6 → 5.0.0 |
| `swift` | Swift | `Alamofire` | 4.9.1 → 5.9.1 |
| `cocoapods` | CocoaPods | `Alamofire` | 4.9.1 → 5.9.1 |
| `opam` | OCaml | `lwt` | 4.5.0 → 5.7.0 |
| `conan` | C / C++ (Conan) | `fmt` | 9.1.0 → 10.2.1 |
| `vcpkg` | C / C++ (vcpkg) | `spdlog` | 1.11.0 → 1.14.1 |
| `arduino` | Arduino / PlatformIO | `ArduinoJson` | 5.13.5 → 6.21.3 |

## Launching one
Demos aim for **1–3 clear, documented breaks** — one indisputable example beats
several arguable ones.

```
https://codespaces.new/trydrift/demo?quickstart=1&devcontainer_path=.devcontainer%2F<ecosystem>%2Fdevcontainer.json
```
## The demos

Requires a GitHub account, and runs on your own GitHub Codespaces allowance.
<!-- demos:start -->

| Ecosystem | Language | Dependency | Upgrade | Try |
| --- | --- | --- | --- | --- |
| `npm` | JavaScript / TypeScript | `axios` | 0.21.4 → 1.7.7 | [Open](https://codespaces.new/trydrift/demo?quickstart=1&devcontainer_path=.devcontainer%2Fnpm%2Fdevcontainer.json) |
| `pypi` | Python | `werkzeug` | 2.0.3 → 2.1.0 | [Open](https://codespaces.new/trydrift/demo?quickstart=1&devcontainer_path=.devcontainer%2Fpypi%2Fdevcontainer.json) |
| `go` | Go | `golang.org/x/exp` | 2023-05-22 → 2023-10-06 | [Open](https://codespaces.new/trydrift/demo?quickstart=1&devcontainer_path=.devcontainer%2Fgo%2Fdevcontainer.json) |
| `cargo` | Rust | `clap` | 2.34.0 → 4.5.4 | [Open](https://codespaces.new/trydrift/demo?quickstart=1&devcontainer_path=.devcontainer%2Fcargo%2Fdevcontainer.json) |
| `maven` | Java / Kotlin / Scala | `com.google.guava:guava` | 20.0 → 21.0 | [Open](https://codespaces.new/trydrift/demo?quickstart=1&devcontainer_path=.devcontainer%2Fmaven%2Fdevcontainer.json) |
| `rubygems` | Ruby | `rack` | 3.0.0 → 3.1.0 | [Open](https://codespaces.new/trydrift/demo?quickstart=1&devcontainer_path=.devcontainer%2Frubygems%2Fdevcontainer.json) |
| `nuget` | .NET | `AutoMapper` | 8.1.1 → 9.0.0 | [Open](https://codespaces.new/trydrift/demo?quickstart=1&devcontainer_path=.devcontainer%2Fnuget%2Fdevcontainer.json) |
| `packagist` | PHP | `monolog/monolog` | 2.9.3 → 3.5.0 | [Open](https://codespaces.new/trydrift/demo?quickstart=1&devcontainer_path=.devcontainer%2Fpackagist%2Fdevcontainer.json) |
| `hex` | Elixir / Erlang | `plug` | 1.13.6 → 1.15.0 | [Open](https://codespaces.new/trydrift/demo?quickstart=1&devcontainer_path=.devcontainer%2Fhex%2Fdevcontainer.json) |
| `pub` | Dart / Flutter | `dio` | 4.0.6 → 5.0.0 | [Open](https://codespaces.new/trydrift/demo?quickstart=1&devcontainer_path=.devcontainer%2Fpub%2Fdevcontainer.json) |
| `swift` | Swift | `https://github.com/Alamofire/Alamofire` | 4.9.1 → 5.9.1 | [Open](https://codespaces.new/trydrift/demo?quickstart=1&devcontainer_path=.devcontainer%2Fswift%2Fdevcontainer.json) |
| `cocoapods` | CocoaPods | `Alamofire` | 4.9.1 → 5.9.1 | [Open](https://codespaces.new/trydrift/demo?quickstart=1&devcontainer_path=.devcontainer%2Fcocoapods%2Fdevcontainer.json) |
| `opam` | OCaml | `lwt` | 4.5.0 → 5.7.0 | [Open](https://codespaces.new/trydrift/demo?quickstart=1&devcontainer_path=.devcontainer%2Fopam%2Fdevcontainer.json) |
| `conan` | C / C++ (Conan) | `fmt` | 9.1.0 → 10.2.1 | [Open](https://codespaces.new/trydrift/demo?quickstart=1&devcontainer_path=.devcontainer%2Fconan%2Fdevcontainer.json) |
| `vcpkg` | C / C++ (vcpkg) | `catch2` | 2.13.9 → 3.5.2 | [Open](https://codespaces.new/trydrift/demo?quickstart=1&devcontainer_path=.devcontainer%2Fvcpkg%2Fdevcontainer.json) |
| `arduino` | Arduino / PlatformIO | `bblanchon/ArduinoJson` | 5.13.5 → 6.21.3 | [Open](https://codespaces.new/trydrift/demo?quickstart=1&devcontainer_path=.devcontainer%2Farduino%2Fdevcontainer.json) |

<!-- demos:end -->

Launching one requires a GitHub account and uses your own GitHub Codespaces
allowance.

> These are prepared fixtures. No demo has been smoke-tested in a real Codespace
> yet, and the `drift.drift` Marketplace install cannot be verified until the
> extension is published.

## Layout

Expand All @@ -58,7 +63,7 @@ demos/<ecosystem>/
├── DEMO.md generated from the BREAKING comments in the source
├── demo.json dependency, versions, and the manifest edit
├── <manifest> pinned to the old version
└── <source> uses APIs the new version breaks
└── <source> uses an API the new version breaks
```

## Scripts
Expand All @@ -68,9 +73,6 @@ node scripts/prepare-demo.mjs <ecosystem> # apply the upgrade (what the Codesp
node scripts/reset-demo.mjs <ecosystem> # put the manifest back
node scripts/sync-devcontainers.mjs # regenerate .devcontainer/*
node scripts/make-demo-docs.mjs # regenerate DEMO.md files
node scripts/make-readme.mjs # regenerate the table above
node scripts/check-demos.mjs # sanity check, no toolchains needed
```

## Drift

https://github.com/trydrift/drift
2 changes: 1 addition & 1 deletion demos/arduino/DEMO.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ The Codespace upgraded it to **6.21.3** and left the source code alone, so
`src/main.cpp` is now written against an API that no longer exists. That is
the situation Drift is built to analyse.

5 breaking changes in this demo:
The 5 breaking changes in this demo:

1. StaticJsonBuffer was removed in ArduinoJson 6, replaced by StaticJsonDocument. The buffer/document split is gone entirely.
2. JsonObject was a reference type created from the buffer in v5 (`JsonObject& root = jsonBuffer.createObject()`). In v6 it is a value type obtained from a document with `doc.to<JsonObject>()`.
Expand Down
2 changes: 1 addition & 1 deletion demos/cargo/DEMO.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ The Codespace upgraded it to **4.5.4** and left the source code alone, so
`src/main.rs` is now written against an API that no longer exists. That is
the situation Drift is built to analyse.

5 breaking changes in this demo:
The 5 breaking changes in this demo:

1. `clap::App` was renamed to `clap::Command` in clap 3 and the old name was removed in clap 4. This import no longer resolves.
2. `clap::SubCommand` was removed in clap 3 — subcommands are just `Command` values now, built with `Command::new(..)`.
Expand Down
2 changes: 1 addition & 1 deletion demos/cocoapods/DEMO.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ The Codespace upgraded it to **5.9.1** and left the source code alone, so
`DriftDemo/NetworkService.swift` is now written against an API that no longer exists. That is
the situation Drift is built to analyse.

5 breaking changes in this demo:
The 5 breaking changes in this demo:

1. SessionManager was removed in Alamofire 5, replaced by Session/AF.
2. Alamofire 5 removed the SessionDelegate hooks that were assigned like this; retry and adapt are handled by a RequestInterceptor now.
Expand Down
6 changes: 2 additions & 4 deletions demos/conan/DEMO.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@ The Codespace upgraded it to **10.2.1** and left the source code alone, so
`src/main.cpp` is now written against an API that no longer exists. That is
the situation Drift is built to analyse.

3 breaking changes in this demo:
The breaking change in this demo:

1. fmt 10 made compile-time format-string checking the default for fmt::format. A runtime std::string as the format argument is now a compile error unless you wrap it in fmt::runtime(..).
2. fmt::join moved out of <fmt/format.h> into <fmt/ranges.h> in fmt 10, so this no longer resolves with the headers included above.
3. fmt::print(FILE*, ..) with a non-constexpr format string is affected by the same compile-time checking change as fmt::format above.
1. fmt 10.0.0 "removed deprecated implicit conversions for enums and conversions to primitive types for compatibility with std::format and to prevent potential ODR violations. Use `format_as` instead."

## Try it

Expand Down
38 changes: 15 additions & 23 deletions demos/conan/src/main.cpp
Original file line number Diff line number Diff line change
@@ -1,35 +1,27 @@
#include <fmt/core.h>
#include <fmt/format.h>

#include <string>
#include <vector>

// This file is written against fmt 9.1.
// The Codespace upgraded the dependency to fmt 10.2 without touching this
// code. fmt 10 tightened its API considerably, so every marked call below
// stopped compiling.
// The Codespace upgraded the dependency to fmt 10.2 without touching this code.

std::string report(const std::string& name, int count) {
// ── BREAKING 1 ────────────────────────────────────────────────────────
// fmt 10 made compile-time format-string checking the default for
// fmt::format. A runtime std::string as the format argument is now a
// compile error unless you wrap it in fmt::runtime(..).
std::string pattern = "{}: {} items\n";
return fmt::format(pattern, name, count);
}
// An ordinary unscoped enum, formatted directly.
enum LogLevel { Debug, Info, Warning, Error };

std::string join_names(const std::vector<std::string>& names) {
// ── BREAKING 2 ────────────────────────────────────────────────────────
// fmt::join moved out of <fmt/format.h> into <fmt/ranges.h> in fmt 10, so
// this no longer resolves with the headers included above.
return fmt::format("{}", fmt::join(names, ", "));
// ── BREAKING ──────────────────────────────────────────────────────────────
// fmt 10.0.0 "removed deprecated implicit conversions for enums and
// conversions to primitive types for compatibility with std::format and to
// prevent potential ODR violations. Use `format_as` instead."
//
// In fmt 9 an unscoped enum was implicitly mapped to its underlying integer,
// so this compiled and printed "level=2". In fmt 10 that conversion is gone
// and LogLevel has no formatter, so this is a compile error until the project
// adds `auto format_as(LogLevel l) { return fmt::underlying(l); }`.
std::string describe(LogLevel level) {
return fmt::format("level={}", level);
}

int main() {
// ── BREAKING 3 ────────────────────────────────────────────────────────
// fmt::print(FILE*, ..) with a non-constexpr format string is affected by
// the same compile-time checking change as fmt::format above.
fmt::print(stdout, report("widgets", 3));
fmt::print("{}\n", join_names({"ada", "grace"}));
fmt::print("{}\n", describe(Warning));
return 0;
}
2 changes: 1 addition & 1 deletion demos/go/DEMO.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ The Codespace upgraded it to **v0.0.0-20231006140011-7918f672742d** and left the
`main.go` is now written against an API that no longer exists. That is
the situation Drift is built to analyse.

4 breaking changes in this demo:
The 4 breaking changes in this demo:

1. slices.SortFunc took `func(a, b E) bool` (a "less" predicate). It now takes `func(a, b E) int` (a "compare" function, like cmp.Compare).
2. Same change for the stable variant.
Expand Down
6 changes: 2 additions & 4 deletions demos/hex/DEMO.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@ The Codespace upgraded it to **1.15.0** and left the source code alone, so
`lib/server.ex` is now written against an API that no longer exists. That is
the situation Drift is built to analyse.

3 breaking changes in this demo:
The breaking change in this demo:

1. Plug.Adapters.Cowboy2 was removed in Plug 1.15. It had been a deprecated shim for the separate :plug_cowboy package since Plug 1.7.
2. Plug.Adapters.Test.Conn was removed in the same sweep; the test helper is Plug.Test now.
3. Plug.Parsers.JSON was removed — JSON parsing goes through Plug.Parsers with a :json_decoder option.
1. Plug.Adapters.Cowboy2 was removed in Plug 1.15. It had been a deprecated shim for the separate :plug_cowboy package since Plug 1.7, and lib/plug/adapters/cowboy2.ex is simply gone from the 1.15 release, so this call raises UndefinedFunctionError.

## Try it

Expand Down
23 changes: 5 additions & 18 deletions demos/hex/lib/server.ex
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,15 @@ defmodule DriftDemo.Server do
HTTP entry point.

This module is written against Plug 1.13. The Codespace upgraded the
dependency to Plug 1.15 without touching this code, so every marked call
below refers to something that no longer exists.
dependency to Plug 1.15 without touching this code.
"""

# ── BREAKING 1 ──────────────────────────────────────────────────────────
# ── BREAKING ────────────────────────────────────────────────────────────
# Plug.Adapters.Cowboy2 was removed in Plug 1.15. It had been a deprecated
# shim for the separate :plug_cowboy package since Plug 1.7.
# shim for the separate :plug_cowboy package since Plug 1.7, and
# lib/plug/adapters/cowboy2.ex is simply gone from the 1.15 release, so this
# call raises UndefinedFunctionError.
def child_spec(port) do
Plug.Adapters.Cowboy2.child_spec(scheme: :http, plug: __MODULE__, options: [port: port])
end

# ── BREAKING 2 ──────────────────────────────────────────────────────────
# Plug.Adapters.Test.Conn was removed in the same sweep; the test helper is
# Plug.Test now.
def test_conn(method, path) do
Plug.Adapters.Test.Conn.conn(%Plug.Conn{}, method, path, nil)
end

# ── BREAKING 3 ──────────────────────────────────────────────────────────
# Plug.Parsers.JSON was removed — JSON parsing goes through
# Plug.Parsers with a :json_decoder option.
def parser_opts do
[parsers: [Plug.Parsers.JSON], pass: ["application/json"]]
end
end
2 changes: 1 addition & 1 deletion demos/maven/DEMO.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ The Codespace upgraded it to **21.0** and left the source code alone, so
`src/main/java/com/example/demo/Config.java` is now written against an API that no longer exists. That is
the situation Drift is built to analyse.

4 breaking changes in this demo:
The 4 breaking changes in this demo:

1. Objects.firstNonNull was removed in Guava 21. It moved to MoreObjects.firstNonNull back in Guava 18 and the old alias is now gone.
2. Objects.toStringHelper was removed in Guava 21 for the same reason — it is MoreObjects.toStringHelper now.
Expand Down
2 changes: 1 addition & 1 deletion demos/npm/DEMO.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ The Codespace upgraded it to **1.7.7** and left the source code alone, so
`src/api-client.ts` is now written against an API that no longer exists. That is
the situation Drift is built to analyse.

3 breaking changes in this demo:
The 3 breaking changes in this demo:

1. `AxiosTransformer` was removed in axios 1.0. Response transformers are now typed as `AxiosResponseTransformer` (and request ones as `AxiosRequestTransformer`), so this import no longer resolves at all.
2. `AxiosProxyConfig` used to carry `username` / `password` directly. In axios 1.0 those moved into a nested `auth: { username, password }` object, so these two properties no longer exist on the type.
Expand Down
2 changes: 1 addition & 1 deletion demos/nuget/DEMO.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ The Codespace upgraded it to **9.0.0** and left the source code alone, so
`Mapping.cs` is now written against an API that no longer exists. That is
the situation Drift is built to analyse.

5 breaking changes in this demo:
The 5 breaking changes in this demo:

1. The static Mapper.Initialize was removed in AutoMapper 9. You build a MapperConfiguration and inject IMapper instead.
2. IMapperConfigurationExpression.CreateMissingTypeMaps was removed in AutoMapper 9; every mapping must be declared explicitly.
Expand Down
6 changes: 2 additions & 4 deletions demos/opam/DEMO.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@ The Codespace upgraded it to **5.7.0** and left the source code alone, so
`lib/scheduler.ml` is now written against an API that no longer exists. That is
the situation Drift is built to analyse.

3 breaking changes in this demo:
The breaking change in this demo:

1. Lwt_sequence was removed from Lwt's public API in Lwt 5.0. It is an internal module now; consumers were told to vendor it.
2. Lwt.wrap1 (and wrap2..wrap7) were removed in Lwt 5.0.
3. Lwt.add_task_l and Lwt.add_task_r were removed in Lwt 5.0 along with the public Lwt_sequence they operated on.
1. Lwt 5.0.0 narrowed [Lwt.async] from [(unit -> _ t) -> unit] to [(unit -> unit t) -> unit]: the callback must now evaluate to [unit Lwt.t] rather than any ['a Lwt.t]. The callback below returns [int Lwt.t], which compiled under Lwt 4 and is a type error under Lwt 5.

## Try it

Expand Down
Loading
Loading