1fb6b778e7
* Update pnpm to v11 * Handle breaking changes * Attach pnpm hash * Remove redundant packageManager fields * Make lint-staged happy * Lockfile pnpm itself too * Update pnpm/action-setup for better v11 compatibility * Specify types to make tsc happier * Fix permissions * Check ulimit * Specify minimumReleaseAgeExclude * Run desktop tests * Revert "Run desktop tests" This reverts commit 911eb0ba2e9237d4b28e3bdaaf8f10ba6f22e827. * Revert "Check ulimit" This reverts commit f09eb59d715ba30a2e7fc5dba17dde092bd9bf17. * Reapply "Check ulimit" This reverts commit 83227c19ff5d07db91b6586f407f56870b00c041. * Run desktop tests * Switch nodeLinker & remove app-builder-lib patch * Fix webpack.config.ts * Fix .stylelintrc.cjs * Fix `events` package * Makes types happier * Make knip happy * Fix hak build * Make jest happy * Make pnpm-link happy * Remove dead file * Run playwright tests * Fix linux hak permissions in ci * Test * Remove ulimit checks * Disable skip * Update nx * Tweak line endings * Update screenshot * Iterate * Webpack fallback `events` --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Michael Telatynski <7t3chguy@gmail.com>
75 lines
3.1 KiB
JavaScript
Executable File
75 lines
3.1 KiB
JavaScript
Executable File
#!/usr/bin/env node
|
|
|
|
/*
|
|
Copyright 2026 Element Creations Ltd.
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial
|
|
Please see LICENSE files in the repository root for full details.
|
|
*/
|
|
|
|
// Utility script to mimic yarn classic `link` behaviour
|
|
// to enable rapid development of libraries like matrix-js-sdk using symlinks/directory junctions
|
|
// reads .link-config file for DEPENDENCY=PATH values and removes those dependencies from node_modules,
|
|
// replacing them with a symlink/directory junction.
|
|
// This tool is a helpful substitute to `pnpm link` as that modifies the package.json & pnpm-lock.yaml files.
|
|
|
|
import * as fs from "node:fs/promises";
|
|
import { join, dirname } from "node:path";
|
|
import { fileURLToPath } from "node:url";
|
|
import { execSync } from "node:child_process";
|
|
|
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
const configPath = join(__dirname, "..", ".link-config");
|
|
const nodeModulesPath = join(__dirname, "..", "node_modules");
|
|
|
|
try {
|
|
if (process.env.PLAYWRIGHT_COMMON_DOCKER) process.exit(0); // Skip in docker env
|
|
|
|
const configFile = await fs.readFile(configPath, "utf-8");
|
|
for (const line of configFile.trim().split("\n")) {
|
|
if (!line || line.startsWith("#")) continue;
|
|
const [dependency, path, dir] = line.split("=");
|
|
const nodeModules = dir ? join(dir, "node_modules") : nodeModulesPath;
|
|
const dependencyPath = join(nodeModules, dependency);
|
|
|
|
try {
|
|
try {
|
|
const stat = await fs.lstat(dependencyPath);
|
|
console.log(`Existing is ${stat.isSymbolicLink() ? "symlink" : "directory"}`);
|
|
if (stat.isSymbolicLink()) {
|
|
const linkPath = await fs.readlink(dependencyPath);
|
|
if (linkPath === path) {
|
|
// already done
|
|
continue;
|
|
} else {
|
|
await fs.unlink(dependencyPath);
|
|
}
|
|
} else {
|
|
await fs.rm(dependencyPath, { recursive: true });
|
|
}
|
|
} catch (e: any) {
|
|
// fs.lstat throws ENOENT if the path doesn't exist (on Windows)
|
|
if (e.code === "ENOENT") {
|
|
console.log("Received ENOENT error on dependency path - assuming it doesn't exist");
|
|
} else {
|
|
throw e;
|
|
}
|
|
}
|
|
|
|
console.log(`Linking ${dependency} to ${path}`);
|
|
await fs.symlink(path, dependencyPath, "junction"); // use a junction type to avoid EPERM errors on Windows
|
|
|
|
const pkgJson = await fs.readFile(join(path, "package.json"), "utf-8");
|
|
const pkgManager = JSON.parse(pkgJson)["packageManager"]?.split("@").at(0) ?? "yarn";
|
|
// pnpm install may have wiped out the `node_modules` dir so we have to restore it
|
|
execSync(`${pkgManager} install --ignore-scripts --frozen-lockfile`, {
|
|
cwd: dependencyPath,
|
|
});
|
|
} catch (e) {
|
|
console.error(`Failed to link ${dependency}`, e);
|
|
}
|
|
}
|
|
} catch {
|
|
// Ignore config file not existing
|
|
}
|