chore(repo): remove bun's workaround to make it work with verdaccio (#30468)
This commit is contained in:
parent
da8baa95da
commit
d9cb931116
@ -341,51 +341,6 @@ export function runCreateWorkspace(
|
|||||||
command += ` --prefix=${prefix}`;
|
command += ` --prefix=${prefix}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (packageManager === 'bun') {
|
|
||||||
/**
|
|
||||||
* `bunx` does not seem to work well at all with custom registries, I tried many combinations of flags and config files.
|
|
||||||
*
|
|
||||||
* The only viable workaround currently seems to be to write a package.json and a bunfig.toml in the e2e directory,
|
|
||||||
* install create-nx-workspace using `bun install` (which _does_ seem to respect the registry settings), and _then_
|
|
||||||
* run `bunx create-nx-workspace` (but without the version number added with @{version}).
|
|
||||||
*/
|
|
||||||
writeFileSync(
|
|
||||||
join(cwd, 'bunfig.toml'),
|
|
||||||
// Also set up a dedicated cache directory to hopefully avoid conflicts with the global cache
|
|
||||||
`
|
|
||||||
[install]
|
|
||||||
cache = ".bun-cache"
|
|
||||||
registry = "${registry}"
|
|
||||||
`.trim()
|
|
||||||
);
|
|
||||||
writeFileSync(
|
|
||||||
join(cwd, 'package.json'),
|
|
||||||
`
|
|
||||||
{
|
|
||||||
"private": true,
|
|
||||||
"name": "only-here-to-make-bunx-happy"
|
|
||||||
}
|
|
||||||
`
|
|
||||||
);
|
|
||||||
const output = execSync('bun install create-nx-workspace', {
|
|
||||||
cwd,
|
|
||||||
stdio: 'pipe',
|
|
||||||
env: {
|
|
||||||
CI: 'true',
|
|
||||||
...process.env,
|
|
||||||
},
|
|
||||||
encoding: 'utf-8',
|
|
||||||
});
|
|
||||||
const publishedVersion = getPublishedVersion();
|
|
||||||
// Ensure that it installed the version published for the e2e tests
|
|
||||||
if (!output.includes(publishedVersion)) {
|
|
||||||
console.error(output);
|
|
||||||
throw new Error(
|
|
||||||
`bunx create-nx-workspace did not install the version published for the e2e tests: ${publishedVersion}, in ${cwd}`
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const create = execSync(`${command}${isVerbose() ? ' --verbose' : ''}`, {
|
const create = execSync(`${command}${isVerbose() ? ' --verbose' : ''}`, {
|
||||||
cwd,
|
cwd,
|
||||||
@ -406,32 +361,10 @@ registry = "${registry}"
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (packageManager === 'bun') {
|
|
||||||
// We also have to add an explicit bunfig.toml in the workspace itself as bun does not seem to use the setting applied by the local registry logic
|
|
||||||
// (via `npm set config registry`), unlike all other package managers.
|
|
||||||
updateFile(
|
|
||||||
'bunfig.toml',
|
|
||||||
`
|
|
||||||
[install]
|
|
||||||
registry = { url = "${registry}", token = "secretVerdaccioToken" }
|
|
||||||
`.trim()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return create;
|
return create;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
logError(`Original command: ${command}`, `${e.stdout}\n\n${e.stderr}`);
|
logError(`Original command: ${command}`, `${e.stdout}\n\n${e.stderr}`);
|
||||||
throw e;
|
throw e;
|
||||||
} finally {
|
|
||||||
// Clean up files related to bun workarounds
|
|
||||||
if (packageManager === 'bun') {
|
|
||||||
removeSync(join(cwd, 'bunfig.toml'));
|
|
||||||
removeSync(join(cwd, 'package.json'));
|
|
||||||
removeSync(join(cwd, '.bun-cache'));
|
|
||||||
removeSync(join(cwd, 'node_modules'));
|
|
||||||
removeSync(join(cwd, 'bun.lock'));
|
|
||||||
removeSync(join(cwd, 'bun.lockb'));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user