lol, dependency check was reversed

This commit is contained in:
Arpad Borsos 2022-07-09 17:37:48 +02:00
parent 7c190ef171
commit 07a2ee71bc
No known key found for this signature in database
GPG Key ID: FC7BCA77824B3298
5 changed files with 32 additions and 53 deletions

23
dist/restore/index.js vendored
View File

@ -61646,7 +61646,7 @@ class Workspace {
cwd: this.root,
}));
for (const pkg of meta.packages) {
if (!pkg.manifest_path.startsWith(this.root)) {
if (pkg.manifest_path.startsWith(this.root)) {
continue;
}
const targets = pkg.targets.filter((t) => t.kind[0] === "lib").map((t) => t.name);
@ -61875,7 +61875,7 @@ async function cleanTargetDir(targetDir, packages) {
if (dirent.isDirectory()) {
let dirName = external_path_default().join(dir.path, dirent.name);
// is it a profile dir, or a nested target dir?
let isNestedTarget = await exists(external_path_default().join(dirName, "CACHEDIR.TAG"));
let isNestedTarget = (await exists(external_path_default().join(dirName, "CACHEDIR.TAG"))) || (await exists(external_path_default().join(dirName, ".rustc_info.json")));
try {
if (isNestedTarget) {
await cleanTargetDir(dirName, packages);
@ -61891,19 +61891,10 @@ async function cleanTargetDir(targetDir, packages) {
}
}
await external_fs_default().promises.unlink(external_path_default().join(targetDir, "./.rustc_info.json"));
// TODO: remove all unknown files, clean all directories like profiles
try {
await cleanProfileTarget(external_path_default().join(targetDir, "debug"), packages);
}
catch { }
try {
await cleanProfileTarget(external_path_default().join(targetDir, "release"), packages);
}
catch { }
}
async function cleanProfileTarget(profileDir, packages) {
await lib_io.rmRF(external_path_default().join(profileDir, "./examples"));
await lib_io.rmRF(external_path_default().join(profileDir, "./incremental"));
await lib_io.rmRF(external_path_default().join(profileDir, "examples"));
await lib_io.rmRF(external_path_default().join(profileDir, "incremental"));
let dir;
// remove all *files* from the profile directory
dir = await external_fs_default().promises.opendir(profileDir);
@ -61913,8 +61904,8 @@ async function cleanProfileTarget(profileDir, packages) {
}
}
const keepPkg = new Set(packages.map((p) => p.name));
await rmExcept(external_path_default().join(profileDir, "./build"), keepPkg);
await rmExcept(external_path_default().join(profileDir, "./.fingerprint"), keepPkg);
await rmExcept(external_path_default().join(profileDir, "build"), keepPkg);
await rmExcept(external_path_default().join(profileDir, ".fingerprint"), keepPkg);
const keepDeps = new Set(packages.flatMap((p) => {
const names = [];
for (const n of [p.name, ...p.targets]) {
@ -61923,7 +61914,7 @@ async function cleanProfileTarget(profileDir, packages) {
}
return names;
}));
await rmExcept(external_path_default().join(profileDir, "./deps"), keepDeps);
await rmExcept(external_path_default().join(profileDir, "deps"), keepDeps);
}
async function cleanBin(config) {
const bins = await config.getCargoBins();

30
dist/save/index.js vendored
View File

@ -61646,7 +61646,7 @@ class Workspace {
cwd: this.root,
}));
for (const pkg of meta.packages) {
if (!pkg.manifest_path.startsWith(this.root)) {
if (pkg.manifest_path.startsWith(this.root)) {
continue;
}
const targets = pkg.targets.filter((t) => t.kind[0] === "lib").map((t) => t.name);
@ -61875,7 +61875,7 @@ async function cleanTargetDir(targetDir, packages) {
if (dirent.isDirectory()) {
let dirName = external_path_default().join(dir.path, dirent.name);
// is it a profile dir, or a nested target dir?
let isNestedTarget = await exists(external_path_default().join(dirName, "CACHEDIR.TAG"));
let isNestedTarget = (await exists(external_path_default().join(dirName, "CACHEDIR.TAG"))) || (await exists(external_path_default().join(dirName, ".rustc_info.json")));
try {
if (isNestedTarget) {
await cleanTargetDir(dirName, packages);
@ -61891,19 +61891,10 @@ async function cleanTargetDir(targetDir, packages) {
}
}
await external_fs_default().promises.unlink(external_path_default().join(targetDir, "./.rustc_info.json"));
// TODO: remove all unknown files, clean all directories like profiles
try {
await cleanProfileTarget(external_path_default().join(targetDir, "debug"), packages);
}
catch { }
try {
await cleanProfileTarget(external_path_default().join(targetDir, "release"), packages);
}
catch { }
}
async function cleanProfileTarget(profileDir, packages) {
await io.rmRF(external_path_default().join(profileDir, "./examples"));
await io.rmRF(external_path_default().join(profileDir, "./incremental"));
await io.rmRF(external_path_default().join(profileDir, "examples"));
await io.rmRF(external_path_default().join(profileDir, "incremental"));
let dir;
// remove all *files* from the profile directory
dir = await external_fs_default().promises.opendir(profileDir);
@ -61913,8 +61904,8 @@ async function cleanProfileTarget(profileDir, packages) {
}
}
const keepPkg = new Set(packages.map((p) => p.name));
await rmExcept(external_path_default().join(profileDir, "./build"), keepPkg);
await rmExcept(external_path_default().join(profileDir, "./.fingerprint"), keepPkg);
await rmExcept(external_path_default().join(profileDir, "build"), keepPkg);
await rmExcept(external_path_default().join(profileDir, ".fingerprint"), keepPkg);
const keepDeps = new Set(packages.flatMap((p) => {
const names = [];
for (const n of [p.name, ...p.targets]) {
@ -61923,7 +61914,7 @@ async function cleanProfileTarget(profileDir, packages) {
}
return names;
}));
await rmExcept(external_path_default().join(profileDir, "./deps"), keepDeps);
await rmExcept(external_path_default().join(profileDir, "deps"), keepDeps);
}
async function cleanBin(config) {
const bins = await config.getCargoBins();
@ -62062,21 +62053,22 @@ async function run() {
}
// TODO: remove this once https://github.com/actions/toolkit/pull/553 lands
await macOsWorkaround();
core.info(`... Cleaning Cache ...`);
const registryName = await getRegistryName(config);
const allPackages = [];
for (const workspace of config.workspaces) {
const packages = await workspace.getPackages();
allPackages.push(...packages);
try {
core.info(`... Cleaning ${workspace.target} ...`);
await cleanTargetDir(workspace.target, packages);
}
catch (e) {
core.info(`[warning] ${e.stack}`);
}
}
const registryName = await getRegistryName(config);
if (registryName) {
try {
core.info(`... Cleaning cargo registry ...`);
await cleanRegistry(config, registryName, allPackages);
}
catch (e) {
@ -62084,12 +62076,14 @@ async function run() {
}
}
try {
core.info(`... Cleaning cargo/bin ...`);
await cleanBin(config);
}
catch (e) {
core.info(`[warning] ${e.stack}`);
}
try {
core.info(`... Cleaning cargo git cache ...`);
await cleanGit(config, allPackages);
}
catch (e) {

View File

@ -14,7 +14,8 @@ export async function cleanTargetDir(targetDir: string, packages: Packages) {
if (dirent.isDirectory()) {
let dirName = path.join(dir.path, dirent.name);
// is it a profile dir, or a nested target dir?
let isNestedTarget = await exists(path.join(dirName, "CACHEDIR.TAG"));
let isNestedTarget =
(await exists(path.join(dirName, "CACHEDIR.TAG"))) || (await exists(path.join(dirName, ".rustc_info.json")));
try {
if (isNestedTarget) {
@ -29,19 +30,11 @@ export async function cleanTargetDir(targetDir: string, packages: Packages) {
}
await fs.promises.unlink(path.join(targetDir, "./.rustc_info.json"));
// TODO: remove all unknown files, clean all directories like profiles
try {
await cleanProfileTarget(path.join(targetDir, "debug"), packages);
} catch {}
try {
await cleanProfileTarget(path.join(targetDir, "release"), packages);
} catch {}
}
async function cleanProfileTarget(profileDir: string, packages: Packages) {
await io.rmRF(path.join(profileDir, "./examples"));
await io.rmRF(path.join(profileDir, "./incremental"));
await io.rmRF(path.join(profileDir, "examples"));
await io.rmRF(path.join(profileDir, "incremental"));
let dir: fs.Dir;
// remove all *files* from the profile directory
@ -53,8 +46,8 @@ async function cleanProfileTarget(profileDir: string, packages: Packages) {
}
const keepPkg = new Set(packages.map((p) => p.name));
await rmExcept(path.join(profileDir, "./build"), keepPkg);
await rmExcept(path.join(profileDir, "./.fingerprint"), keepPkg);
await rmExcept(path.join(profileDir, "build"), keepPkg);
await rmExcept(path.join(profileDir, ".fingerprint"), keepPkg);
const keepDeps = new Set(
packages.flatMap((p) => {
@ -66,7 +59,7 @@ async function cleanProfileTarget(profileDir: string, packages: Packages) {
return names;
}),
);
await rmExcept(path.join(profileDir, "./deps"), keepDeps);
await rmExcept(path.join(profileDir, "deps"), keepDeps);
}
export async function cleanBin(config: CacheConfig) {

View File

@ -32,23 +32,22 @@ async function run() {
// TODO: remove this once https://github.com/actions/toolkit/pull/553 lands
await macOsWorkaround();
core.info(`... Cleaning Cache ...`);
const registryName = await getRegistryName(config);
const allPackages = [];
for (const workspace of config.workspaces) {
const packages = await workspace.getPackages();
allPackages.push(...packages);
try {
core.info(`... Cleaning ${workspace.target} ...`);
await cleanTargetDir(workspace.target, packages);
} catch (e) {
core.info(`[warning] ${(e as any).stack}`);
}
}
const registryName = await getRegistryName(config);
if (registryName) {
try {
core.info(`... Cleaning cargo registry ...`);
await cleanRegistry(config, registryName, allPackages);
} catch (e) {
core.info(`[warning] ${(e as any).stack}`);
@ -56,12 +55,14 @@ async function run() {
}
try {
core.info(`... Cleaning cargo/bin ...`);
await cleanBin(config);
} catch (e) {
core.info(`[warning] ${(e as any).stack}`);
}
try {
core.info(`... Cleaning cargo git cache ...`);
await cleanGit(config, allPackages);
} catch (e) {
core.info(`[warning] ${(e as any).stack}`);

View File

@ -14,7 +14,7 @@ export class Workspace {
}),
);
for (const pkg of meta.packages) {
if (!pkg.manifest_path.startsWith(this.root)) {
if (pkg.manifest_path.startsWith(this.root)) {
continue;
}
const targets = pkg.targets.filter((t) => t.kind[0] === "lib").map((t) => t.name);