Remove yarn-closure code
This commit is contained in:
+4
-46
@@ -27,7 +27,6 @@ const generate = async (project: Project, cache: Cache, report: Report) => {
|
||||
const { configuration, cwd } = project;
|
||||
const yarnPathAbs = configuration.get(`yarnPath`);
|
||||
const cacheFolderAbs = configuration.get(`cacheFolder`);
|
||||
const lockfileFilename = configuration.get(`lockfileFilename`);
|
||||
|
||||
let yarnPath = ppath.relative(cwd, yarnPathAbs);
|
||||
if (yarnPath.startsWith(`../`)) {
|
||||
@@ -47,48 +46,15 @@ const generate = async (project: Project, cache: Cache, report: Report) => {
|
||||
);
|
||||
}
|
||||
|
||||
// List files the derivation will depend on.
|
||||
const yarnClosureInput = new Set([
|
||||
`package.json`,
|
||||
lockfileFilename,
|
||||
yarnPath,
|
||||
]);
|
||||
for (const source of configuration.sources.values()) {
|
||||
if (!source.startsWith(`<`)) {
|
||||
yarnClosureInput.add(source);
|
||||
}
|
||||
}
|
||||
// TODO: Better way to find plugins? Re-parse rcfiles maybe?
|
||||
const pluginsDir = ppath.join(cwd, `.yarn/plugins` as Filename);
|
||||
if (xfs.existsSync(pluginsDir)) {
|
||||
for (const filename of xfs.readdirSync(pluginsDir)) {
|
||||
yarnClosureInput.add(ppath.join(pluginsDir, filename));
|
||||
}
|
||||
}
|
||||
|
||||
// Build Nix `filterSource` entries to match on.
|
||||
const yarnClosureEntries = new Set();
|
||||
for (const inputPath of yarnClosureInput) {
|
||||
// Filter paths not reachable during the build and warn. (These are often
|
||||
// just user global configuration files, but the warnings can help highlight
|
||||
// dependencies on private registries.)
|
||||
const relativePath = ppath.relative(cwd, inputPath);
|
||||
if (relativePath.startsWith(`../`)) {
|
||||
if (inputPath !== yarnPath) {
|
||||
const relativeSource = ppath.relative(cwd, source);
|
||||
if (relativeSource.startsWith(`../`)) {
|
||||
report.reportWarning(
|
||||
0,
|
||||
`The path ${inputPath} is outside the project and was ignored - it may not be reachable in the Nix build`
|
||||
`The config file ${source} is outside the project - it may not be reachable by the Nix build`
|
||||
);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
// Add the file itself.
|
||||
yarnClosureEntries.add(`regular:${relativePath}`);
|
||||
// Add directories leading up to the file.
|
||||
let dir = ppath.dirname(relativePath);
|
||||
while (dir !== `.`) {
|
||||
yarnClosureEntries.add(`directory:${dir}`);
|
||||
dir = ppath.dirname(dir);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,6 +84,7 @@ const generate = async (project: Project, cache: Cache, report: Report) => {
|
||||
const projectName = ident ? structUtils.stringifyIdent(ident) : `workspace`;
|
||||
const projectExpr = projectExprTmpl
|
||||
.replace(`@@PROJECT_NAME@@`, JSON.stringify(projectName))
|
||||
.replace(`@@YARN_PATH@@`, JSON.stringify(yarnPath))
|
||||
.replace(`@@CACHE_FOLDER@@`, JSON.stringify(cacheFolder))
|
||||
.replace(
|
||||
`@@CACHE_ENTRIES@@`,
|
||||
@@ -126,15 +93,6 @@ const generate = async (project: Project, cache: Cache, report: Report) => {
|
||||
.map((entry) => ` { ${entry.join(` `)} }\n`)
|
||||
.join(``) +
|
||||
` ]`
|
||||
)
|
||||
.replace(`@@YARN_PATH@@`, JSON.stringify(yarnPath))
|
||||
.replace(
|
||||
`@@YARN_CLOSURE_ENTRIES@@`,
|
||||
`[\n` +
|
||||
[...yarnClosureEntries]
|
||||
.map((entry) => ` ${JSON.stringify(entry)}\n`)
|
||||
.join(``) +
|
||||
` ]`
|
||||
);
|
||||
const projectExprPath = ppath.join(cwd, `yarn-project.nix` as Filename);
|
||||
xfs.writeFileSync(projectExprPath, projectExpr);
|
||||
|
||||
Reference in New Issue
Block a user