mirror of
https://github.com/Swatinem/rust-cache
synced 2025-04-05 21:24:07 +00:00
parent
a4a1d8e7a6
commit
d38127a85b
|
@ -1,5 +1,9 @@
|
||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## 1.0.2
|
||||||
|
|
||||||
|
- Don’t prune targets that have a different name from the crate, but do prune targets from the workspace.
|
||||||
|
|
||||||
## 1.0.1
|
## 1.0.1
|
||||||
|
|
||||||
- Improved logging output.
|
- Improved logging output.
|
||||||
|
|
16
dist/save/index.js
vendored
16
dist/save/index.js
vendored
|
@ -54793,8 +54793,14 @@ async function getIndexRef(registryName) {
|
||||||
return (await getCmdOutput("git", ["rev-parse", "--short", "origin/master"], { cwd })).trim();
|
return (await getCmdOutput("git", ["rev-parse", "--short", "origin/master"], { cwd })).trim();
|
||||||
}
|
}
|
||||||
async function getPackages() {
|
async function getPackages() {
|
||||||
|
const cwd = process.cwd();
|
||||||
const meta = JSON.parse(await getCmdOutput("cargo", ["metadata", "--all-features", "--format-version", "1"]));
|
const meta = JSON.parse(await getCmdOutput("cargo", ["metadata", "--all-features", "--format-version", "1"]));
|
||||||
return meta.packages.map(({ name, version }) => ({ name, version }));
|
return meta.packages
|
||||||
|
.filter((p) => !p.manifest_path.startsWith(cwd))
|
||||||
|
.map((p) => {
|
||||||
|
const targets = p.targets.filter((t) => t.kind[0] === "lib").map((t) => t.name);
|
||||||
|
return { name: p.name, version: p.version, targets };
|
||||||
|
});
|
||||||
}
|
}
|
||||||
async function pruneRegistryCache(registryName, packages) {
|
async function pruneRegistryCache(registryName, packages) {
|
||||||
var e_1, _a;
|
var e_1, _a;
|
||||||
|
@ -54846,8 +54852,12 @@ async function pruneTarget(packages) {
|
||||||
await rmExcept("./target/debug/build", keepPkg);
|
await rmExcept("./target/debug/build", keepPkg);
|
||||||
await rmExcept("./target/debug/.fingerprint", keepPkg);
|
await rmExcept("./target/debug/.fingerprint", keepPkg);
|
||||||
const keepDeps = new Set(packages.flatMap((p) => {
|
const keepDeps = new Set(packages.flatMap((p) => {
|
||||||
const name = p.name.replace(/-/g, "_");
|
const names = [];
|
||||||
return [name, `lib${name}`];
|
for (const n of [p.name, ...p.targets]) {
|
||||||
|
const name = n.replace(/-/g, "_");
|
||||||
|
names.push(name, `lib${name}`);
|
||||||
|
}
|
||||||
|
return names;
|
||||||
}));
|
}));
|
||||||
await rmExcept("./target/debug/deps", keepDeps);
|
await rmExcept("./target/debug/deps", keepDeps);
|
||||||
}
|
}
|
||||||
|
|
29
src/save.ts
29
src/save.ts
|
@ -68,13 +68,30 @@ async function getIndexRef(registryName: string) {
|
||||||
interface PackageDefinition {
|
interface PackageDefinition {
|
||||||
name: string;
|
name: string;
|
||||||
version: string;
|
version: string;
|
||||||
|
targets: Array<string>;
|
||||||
}
|
}
|
||||||
|
|
||||||
type Packages = Array<PackageDefinition>;
|
type Packages = Array<PackageDefinition>;
|
||||||
|
|
||||||
|
interface Meta {
|
||||||
|
packages: Array<{
|
||||||
|
name: string;
|
||||||
|
version: string;
|
||||||
|
manifest_path: string;
|
||||||
|
targets: Array<{ kind: Array<string>; name: string }>;
|
||||||
|
}>;
|
||||||
|
}
|
||||||
|
|
||||||
async function getPackages(): Promise<Packages> {
|
async function getPackages(): Promise<Packages> {
|
||||||
const meta = JSON.parse(await getCmdOutput("cargo", ["metadata", "--all-features", "--format-version", "1"]));
|
const cwd = process.cwd();
|
||||||
return meta.packages.map(({ name, version }: any) => ({ name, version }));
|
const meta: Meta = JSON.parse(await getCmdOutput("cargo", ["metadata", "--all-features", "--format-version", "1"]));
|
||||||
|
|
||||||
|
return meta.packages
|
||||||
|
.filter((p) => !p.manifest_path.startsWith(cwd))
|
||||||
|
.map((p) => {
|
||||||
|
const targets = p.targets.filter((t) => t.kind[0] === "lib").map((t) => t.name);
|
||||||
|
return { name: p.name, version: p.version, targets };
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async function pruneRegistryCache(registryName: string, packages: Packages) {
|
async function pruneRegistryCache(registryName: string, packages: Packages) {
|
||||||
|
@ -111,8 +128,12 @@ async function pruneTarget(packages: Packages) {
|
||||||
|
|
||||||
const keepDeps = new Set(
|
const keepDeps = new Set(
|
||||||
packages.flatMap((p) => {
|
packages.flatMap((p) => {
|
||||||
const name = p.name.replace(/-/g, "_");
|
const names = [];
|
||||||
return [name, `lib${name}`];
|
for (const n of [p.name, ...p.targets]) {
|
||||||
|
const name = n.replace(/-/g, "_");
|
||||||
|
names.push(name, `lib${name}`);
|
||||||
|
}
|
||||||
|
return names;
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
await rmExcept("./target/debug/deps", keepDeps);
|
await rmExcept("./target/debug/deps", keepDeps);
|
||||||
|
|
Loading…
Reference in a new issue