зеркало из https://github.com/microsoft/rnx-kit.git
test(align-deps): address pnpm issues (#2795)
This commit is contained in:
Родитель
76cda0e68b
Коммит
0f5a3f2873
|
@ -0,0 +1,2 @@
|
|||
---
|
||||
---
|
|
@ -13,6 +13,7 @@ fs.__setMockFileWriter = (writer) => {
|
|||
|
||||
fs.lstatSync = (...args) => actualFs.lstatSync(...args);
|
||||
fs.readFileSync = (...args) => data || actualFs.readFileSync(...args);
|
||||
fs.readlinkSync = (...args) => actualFs.readlinkSync(...args);
|
||||
fs.statSync = actualFs.statSync; // used by cosmiconfig
|
||||
fs.writeFileSync = undefined;
|
||||
|
||||
|
|
|
@ -6,6 +6,44 @@ const dependencies = {
|
|||
yargs: "^16.0.0",
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns available profiles.
|
||||
*
|
||||
* Note: We get available profiles from disk instead of importing
|
||||
* `@rnx-kit/align-deps` to avoid circular dependency.
|
||||
*
|
||||
* @returns {string[]}
|
||||
*/
|
||||
function getAvailableProfiles() {
|
||||
const profiles = [];
|
||||
|
||||
const fs = require("node:fs");
|
||||
const path = require("node:path");
|
||||
|
||||
const prefix = "profile-";
|
||||
const presetDir = path.resolve(
|
||||
__dirname,
|
||||
"..",
|
||||
"packages",
|
||||
"align-deps",
|
||||
"src",
|
||||
"presets",
|
||||
"microsoft",
|
||||
"react-native"
|
||||
);
|
||||
const files = fs.readdirSync(presetDir);
|
||||
for (const filename of files) {
|
||||
if (!filename.startsWith(prefix)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const version = path.basename(filename, ".ts").substring(prefix.length);
|
||||
profiles.push(version);
|
||||
}
|
||||
|
||||
return profiles;
|
||||
}
|
||||
|
||||
function makeTypesEntries() {
|
||||
return Object.entries(dependencies).reduce((types, [name, version]) => {
|
||||
const pkgName = `@types/${name}`;
|
||||
|
@ -58,10 +96,7 @@ const profile = {
|
|||
},
|
||||
};
|
||||
|
||||
const { presets } = require("@rnx-kit/align-deps");
|
||||
const profileNames = Object.keys(presets["microsoft/react-native"]);
|
||||
|
||||
module.exports = profileNames.reduce((preset, key) => {
|
||||
module.exports = getAvailableProfiles().reduce((preset, key) => {
|
||||
preset[key] = profile;
|
||||
return preset;
|
||||
}, {});
|
||||
|
|
Загрузка…
Ссылка в новой задаче