bump fs-extra types
Summary: `recursive` was dropped in when [dropping](https://github.com/jprichardson/node-fs-extra/issues/886) node v10 Reviewed By: aigoncharov Differential Revision: D48780242 fbshipit-source-id: 29349590a7f14da85fe8df28b20d9b418e7a8b1d
This commit is contained in:
committed by
Facebook GitHub Bot
parent
d04abff530
commit
f2ef26cd9a
@@ -24,7 +24,7 @@
|
|||||||
"@babel/traverse": "^7.20.13",
|
"@babel/traverse": "^7.20.13",
|
||||||
"@babel/types": "^7.20.7",
|
"@babel/types": "^7.20.7",
|
||||||
"@emotion/babel-plugin": "^11.10.6",
|
"@emotion/babel-plugin": "^11.10.6",
|
||||||
"@types/fs-extra": "^9.0.13",
|
"@types/fs-extra": "^11.0.0",
|
||||||
"@types/node": "^17.0.31",
|
"@types/node": "^17.0.31",
|
||||||
"fs-extra": "^11.1.0",
|
"fs-extra": "^11.1.0",
|
||||||
"tslib": "^2.4.1"
|
"tslib": "^2.4.1"
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
"p-map": "^4"
|
"p-map": "^4"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/fs-extra": "^9.0.13",
|
"@types/fs-extra": "^11.0.1",
|
||||||
"@types/mock-fs": "^4.13.1",
|
"@types/mock-fs": "^4.13.1",
|
||||||
"@types/node": "^17.0.31",
|
"@types/node": "^17.0.31",
|
||||||
"@types/npm-packlist": "^1.1.2",
|
"@types/npm-packlist": "^1.1.2",
|
||||||
|
|||||||
@@ -99,6 +99,7 @@ describe('getWatchFolders', () => {
|
|||||||
};
|
};
|
||||||
const readReadJson = fs.readJson;
|
const readReadJson = fs.readJson;
|
||||||
try {
|
try {
|
||||||
|
// @ts-expect-error readJson is read only and it is fine, this is a test
|
||||||
fs.readJson = readJsonMock as any;
|
fs.readJson = readJsonMock as any;
|
||||||
const resolvedFolders = await getWatchFolders(
|
const resolvedFolders = await getWatchFolders(
|
||||||
path.join(rootDir, 'local_module_2'),
|
path.join(rootDir, 'local_module_2'),
|
||||||
@@ -115,6 +116,7 @@ describe('getWatchFolders', () => {
|
|||||||
]
|
]
|
||||||
`);
|
`);
|
||||||
} finally {
|
} finally {
|
||||||
|
// @ts-expect-error readJson is read only and it is fine, this is a test
|
||||||
fs.readJson = readReadJson;
|
fs.readJson = readReadJson;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -29,7 +29,7 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@oclif/dev-cli": "^1",
|
"@oclif/dev-cli": "^1",
|
||||||
"@types/fs-extra": "^9.0.13",
|
"@types/fs-extra": "^11.0.0",
|
||||||
"@types/inquirer": "^7.3.3",
|
"@types/inquirer": "^7.3.3",
|
||||||
"@types/node": "^17.0.31",
|
"@types/node": "^17.0.31",
|
||||||
"@types/recursive-readdir": "^2.2.1",
|
"@types/recursive-readdir": "^2.2.1",
|
||||||
|
|||||||
@@ -30,21 +30,28 @@ const validPackageJson = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
beforeEach(() => {
|
jest.mock('fs-extra', () => {
|
||||||
jest.mock('fs-extra', () => jest.fn());
|
const mod = {
|
||||||
fs.pathExists = jest.fn().mockResolvedValue(true);
|
...jest.requireActual('fs-extra'),
|
||||||
fs.pathExistsSync = jest.fn().mockReturnValue(true);
|
readFile: jest.fn(),
|
||||||
// Required by some inconsistent node types for rw access.
|
pathExists: jest.fn().mockResolvedValue(true),
|
||||||
(fs.lstatSync as any) = jest.fn().mockReturnValue({
|
pathExistsSync: jest.fn().mockResolvedValue(true),
|
||||||
isFile: function () {
|
lstatSync: jest.fn().mockReturnValue({
|
||||||
return true;
|
isFile: function () {
|
||||||
},
|
return true;
|
||||||
});
|
},
|
||||||
|
}),
|
||||||
|
};
|
||||||
|
|
||||||
|
return {
|
||||||
|
...mod,
|
||||||
|
default: mod,
|
||||||
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
test('valid package json', async () => {
|
test('valid package json', async () => {
|
||||||
const json = JSON.stringify(validPackageJson);
|
const json = JSON.stringify(validPackageJson);
|
||||||
fs.readFile = jest.fn().mockResolvedValue(new Buffer(json));
|
(fs.readFile as any as jest.Mock).mockReturnValueOnce(new Buffer(json));
|
||||||
const result = await runLint('dir');
|
const result = await runLint('dir');
|
||||||
expect(result).toBe(null);
|
expect(result).toBe(null);
|
||||||
});
|
});
|
||||||
@@ -53,7 +60,7 @@ test('valid scoped package json', async () => {
|
|||||||
const testPackageJson = Object.assign({}, validPackageJson);
|
const testPackageJson = Object.assign({}, validPackageJson);
|
||||||
testPackageJson.name = '@test/flipper-plugin-package';
|
testPackageJson.name = '@test/flipper-plugin-package';
|
||||||
const json = JSON.stringify(testPackageJson);
|
const json = JSON.stringify(testPackageJson);
|
||||||
fs.readFile = jest.fn().mockResolvedValue(new Buffer(json));
|
(fs.readFile as any as jest.Mock).mockReturnValueOnce(new Buffer(json));
|
||||||
const result = await runLint('dir');
|
const result = await runLint('dir');
|
||||||
expect(result).toBe(null);
|
expect(result).toBe(null);
|
||||||
});
|
});
|
||||||
@@ -63,7 +70,7 @@ test('$schema field is required', async () => {
|
|||||||
// @ts-ignore cannot delete non-optional fields
|
// @ts-ignore cannot delete non-optional fields
|
||||||
delete testPackageJson.$schema;
|
delete testPackageJson.$schema;
|
||||||
const json = JSON.stringify(testPackageJson);
|
const json = JSON.stringify(testPackageJson);
|
||||||
fs.readFile = jest.fn().mockResolvedValue(new Buffer(json));
|
(fs.readFile as any as jest.Mock).mockReturnValueOnce(new Buffer(json));
|
||||||
const result = await runLint('dir');
|
const result = await runLint('dir');
|
||||||
expect(result).toMatchInlineSnapshot(`
|
expect(result).toMatchInlineSnapshot(`
|
||||||
[
|
[
|
||||||
@@ -82,7 +89,7 @@ test('supported schema is required', async () => {
|
|||||||
testPackageJson.$schema =
|
testPackageJson.$schema =
|
||||||
'https://fbflipper.com/schemas/plugin-package/v1.json';
|
'https://fbflipper.com/schemas/plugin-package/v1.json';
|
||||||
const json = JSON.stringify(testPackageJson);
|
const json = JSON.stringify(testPackageJson);
|
||||||
fs.readFile = jest.fn().mockResolvedValue(new Buffer(json));
|
(fs.readFile as any as jest.Mock).mockReturnValueOnce(new Buffer(json));
|
||||||
const result = await runLint('dir');
|
const result = await runLint('dir');
|
||||||
expect(result).toMatchInlineSnapshot(`
|
expect(result).toMatchInlineSnapshot(`
|
||||||
[
|
[
|
||||||
@@ -97,7 +104,7 @@ test('name is required', async () => {
|
|||||||
// @ts-ignore cannot delete non-optional fields
|
// @ts-ignore cannot delete non-optional fields
|
||||||
delete testPackageJson.name;
|
delete testPackageJson.name;
|
||||||
const json = JSON.stringify(testPackageJson);
|
const json = JSON.stringify(testPackageJson);
|
||||||
fs.readFile = jest.fn().mockResolvedValue(new Buffer(json));
|
(fs.readFile as any as jest.Mock).mockReturnValueOnce(new Buffer(json));
|
||||||
const result = await runLint('dir');
|
const result = await runLint('dir');
|
||||||
expect(result).toMatchInlineSnapshot(`
|
expect(result).toMatchInlineSnapshot(`
|
||||||
[
|
[
|
||||||
@@ -110,7 +117,7 @@ test('name must start with "flipper-plugin-"', async () => {
|
|||||||
const testPackageJson = Object.assign({}, validPackageJson);
|
const testPackageJson = Object.assign({}, validPackageJson);
|
||||||
testPackageJson.name = 'test-plugin';
|
testPackageJson.name = 'test-plugin';
|
||||||
const json = JSON.stringify(testPackageJson);
|
const json = JSON.stringify(testPackageJson);
|
||||||
fs.readFile = jest.fn().mockResolvedValue(new Buffer(json));
|
(fs.readFile as any as jest.Mock).mockReturnValueOnce(new Buffer(json));
|
||||||
const result = await runLint('dir');
|
const result = await runLint('dir');
|
||||||
expect(result).toMatchInlineSnapshot(`
|
expect(result).toMatchInlineSnapshot(`
|
||||||
[
|
[
|
||||||
@@ -123,7 +130,7 @@ test('keywords must contain "flipper-plugin"', async () => {
|
|||||||
const testPackageJson = Object.assign({}, validPackageJson);
|
const testPackageJson = Object.assign({}, validPackageJson);
|
||||||
testPackageJson.keywords = ['flipper', 'network'];
|
testPackageJson.keywords = ['flipper', 'network'];
|
||||||
const json = JSON.stringify(testPackageJson);
|
const json = JSON.stringify(testPackageJson);
|
||||||
fs.readFile = jest.fn().mockResolvedValue(new Buffer(json));
|
(fs.readFile as any as jest.Mock).mockReturnValueOnce(new Buffer(json));
|
||||||
const result = await runLint('dir');
|
const result = await runLint('dir');
|
||||||
expect(result).toMatchInlineSnapshot(`
|
expect(result).toMatchInlineSnapshot(`
|
||||||
[
|
[
|
||||||
@@ -135,13 +142,11 @@ test('keywords must contain "flipper-plugin"', async () => {
|
|||||||
test('flippeBundlerEntry must point to an existing file', async () => {
|
test('flippeBundlerEntry must point to an existing file', async () => {
|
||||||
const testPackageJson = Object.assign({}, validPackageJson);
|
const testPackageJson = Object.assign({}, validPackageJson);
|
||||||
testPackageJson.flipperBundlerEntry = 'unexisting/file';
|
testPackageJson.flipperBundlerEntry = 'unexisting/file';
|
||||||
fs.pathExistsSync = jest
|
(fs.pathExistsSync as any as jest.Mock).mockImplementation(
|
||||||
.fn()
|
(filePath) => !filePath.includes(path.join('unexisting', 'file')),
|
||||||
.mockImplementation(
|
);
|
||||||
(filePath) => !filePath.includes(path.join('unexisting', 'file')),
|
|
||||||
);
|
|
||||||
const json = JSON.stringify(testPackageJson);
|
const json = JSON.stringify(testPackageJson);
|
||||||
fs.readFile = jest.fn().mockResolvedValue(new Buffer(json));
|
(fs.readFile as any as jest.Mock).mockReturnValueOnce(new Buffer(json));
|
||||||
const result = await runLint('dir');
|
const result = await runLint('dir');
|
||||||
expect(result).toMatchInlineSnapshot(`
|
expect(result).toMatchInlineSnapshot(`
|
||||||
[
|
[
|
||||||
@@ -156,7 +161,7 @@ test('multiple validation errors reported', async () => {
|
|||||||
// @ts-ignore cannot delete non-optional fields
|
// @ts-ignore cannot delete non-optional fields
|
||||||
delete testPackageJson.flipperBundlerEntry;
|
delete testPackageJson.flipperBundlerEntry;
|
||||||
const json = JSON.stringify(testPackageJson);
|
const json = JSON.stringify(testPackageJson);
|
||||||
fs.readFile = jest.fn().mockResolvedValue(new Buffer(json));
|
(fs.readFile as any as jest.Mock).mockReturnValueOnce(new Buffer(json));
|
||||||
const result = await runLint('dir');
|
const result = await runLint('dir');
|
||||||
expect(result).toMatchInlineSnapshot(`
|
expect(result).toMatchInlineSnapshot(`
|
||||||
[
|
[
|
||||||
|
|||||||
@@ -10,25 +10,6 @@
|
|||||||
import runMigrate from '../utils/runMigrate';
|
import runMigrate from '../utils/runMigrate';
|
||||||
import fs from 'fs-extra';
|
import fs from 'fs-extra';
|
||||||
|
|
||||||
const packageJsonV1 = {
|
|
||||||
name: 'Fresco',
|
|
||||||
version: '1.0.0',
|
|
||||||
main: 'index.tsx',
|
|
||||||
license: 'MIT',
|
|
||||||
keywords: ['images'],
|
|
||||||
dependencies: {
|
|
||||||
flipper: 'latest',
|
|
||||||
},
|
|
||||||
scripts: {
|
|
||||||
prepack: 'yarn reset && yarn build',
|
|
||||||
},
|
|
||||||
title: 'Images',
|
|
||||||
icon: 'profile',
|
|
||||||
bugs: {
|
|
||||||
email: 'example@test.com',
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
const packageJsonV2 = {
|
const packageJsonV2 = {
|
||||||
$schema: 'https://fbflipper.com/schemas/plugin-package/v2.json',
|
$schema: 'https://fbflipper.com/schemas/plugin-package/v2.json',
|
||||||
name: 'flipper-plugin-network',
|
name: 'flipper-plugin-network',
|
||||||
@@ -53,18 +34,52 @@ const packageJsonV2 = {
|
|||||||
|
|
||||||
let convertedPackageJsonString: string | undefined;
|
let convertedPackageJsonString: string | undefined;
|
||||||
|
|
||||||
|
jest.mock('fs-extra', () => {
|
||||||
|
const packageJsonV1 = {
|
||||||
|
name: 'Fresco',
|
||||||
|
version: '1.0.0',
|
||||||
|
main: 'index.tsx',
|
||||||
|
license: 'MIT',
|
||||||
|
keywords: ['images'],
|
||||||
|
dependencies: {
|
||||||
|
flipper: 'latest',
|
||||||
|
},
|
||||||
|
scripts: {
|
||||||
|
prepack: 'yarn reset && yarn build',
|
||||||
|
},
|
||||||
|
title: 'Images',
|
||||||
|
icon: 'profile',
|
||||||
|
bugs: {
|
||||||
|
email: 'example@test.com',
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
const mod = {
|
||||||
|
...jest.requireActual('fs-extra'),
|
||||||
|
readFile: jest
|
||||||
|
.fn()
|
||||||
|
.mockResolvedValue(new Buffer(JSON.stringify(packageJsonV1))),
|
||||||
|
pathExists: jest.fn().mockResolvedValue(true),
|
||||||
|
pathExistsSync: jest.fn().mockResolvedValue(true),
|
||||||
|
readJson: jest.fn().mockResolvedValue(packageJsonV1),
|
||||||
|
writeFile: jest.fn(async (_path, content) => {
|
||||||
|
convertedPackageJsonString = content;
|
||||||
|
}),
|
||||||
|
lstatSync: jest.fn().mockReturnValue({
|
||||||
|
isFile: function () {
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
};
|
||||||
|
|
||||||
|
return {
|
||||||
|
...mod,
|
||||||
|
default: mod,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
jest.mock('fs-extra', () => jest.fn());
|
|
||||||
fs.pathExists = jest.fn().mockResolvedValue(true);
|
|
||||||
fs.pathExistsSync = jest.fn().mockReturnValue(true);
|
|
||||||
fs.readJson = jest.fn().mockResolvedValue(packageJsonV1);
|
|
||||||
fs.readFile = jest
|
|
||||||
.fn()
|
|
||||||
.mockResolvedValue(new Buffer(JSON.stringify(packageJsonV1)));
|
|
||||||
convertedPackageJsonString = undefined;
|
convertedPackageJsonString = undefined;
|
||||||
fs.writeFile = jest.fn().mockImplementation(async (_path, content) => {
|
|
||||||
convertedPackageJsonString = content;
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('converts package.json and adds dependencies', async () => {
|
test('converts package.json and adds dependencies', async () => {
|
||||||
@@ -134,10 +149,9 @@ test('converts package.json without changing dependencies', async () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('does not migrate already migrated packages', async () => {
|
test('does not migrate already migrated packages', async () => {
|
||||||
fs.readJson = jest.fn().mockResolvedValue(packageJsonV2);
|
(fs.readFile as any as jest.Mock).mockResolvedValue(
|
||||||
fs.readFile = jest
|
new Buffer(JSON.stringify(packageJsonV2)),
|
||||||
.fn()
|
);
|
||||||
.mockResolvedValue(new Buffer(JSON.stringify(packageJsonV2)));
|
|
||||||
const error = await runMigrate('dir');
|
const error = await runMigrate('dir');
|
||||||
expect(error).toBeUndefined();
|
expect(error).toBeUndefined();
|
||||||
expect(convertedPackageJsonString).toBeUndefined();
|
expect(convertedPackageJsonString).toBeUndefined();
|
||||||
|
|||||||
@@ -24,7 +24,7 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/decompress": "4.2.4",
|
"@types/decompress": "4.2.4",
|
||||||
"@types/fs-extra": "^9.0.13",
|
"@types/fs-extra": "^11.0.1",
|
||||||
"@types/mock-fs": "^4.13.1",
|
"@types/mock-fs": "^4.13.1",
|
||||||
"@types/node": "^17.0.31",
|
"@types/node": "^17.0.31",
|
||||||
"flipper-test-utils": "0.0.0",
|
"flipper-test-utils": "0.0.0",
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ test('getPluginDetailsV1', async () => {
|
|||||||
description: 'Description of Test Plugin',
|
description: 'Description of Test Plugin',
|
||||||
gatekeeper: 'GK_flipper_plugin_test',
|
gatekeeper: 'GK_flipper_plugin_test',
|
||||||
};
|
};
|
||||||
|
// @ts-expect-error this is read only and it is fine, this is a test
|
||||||
fs.readJson = jest.fn().mockImplementation(() => pluginV1);
|
fs.readJson = jest.fn().mockImplementation(() => pluginV1);
|
||||||
const details = await getInstalledPluginDetails(pluginPath);
|
const details = await getInstalledPluginDetails(pluginPath);
|
||||||
details.dir = normalizePath(details.dir);
|
details.dir = normalizePath(details.dir);
|
||||||
@@ -74,6 +75,7 @@ test('getPluginDetailsV2', async () => {
|
|||||||
description: 'Description of Test Plugin',
|
description: 'Description of Test Plugin',
|
||||||
gatekeeper: 'GK_flipper_plugin_test',
|
gatekeeper: 'GK_flipper_plugin_test',
|
||||||
};
|
};
|
||||||
|
// @ts-expect-error this is read only and it is fine, this is a test
|
||||||
fs.readJson = jest.fn().mockImplementation(() => pluginV2);
|
fs.readJson = jest.fn().mockImplementation(() => pluginV2);
|
||||||
const details = await getInstalledPluginDetails(pluginPath);
|
const details = await getInstalledPluginDetails(pluginPath);
|
||||||
details.dir = normalizePath(details.dir);
|
details.dir = normalizePath(details.dir);
|
||||||
@@ -121,6 +123,7 @@ test('id used as title if the latter omited', async () => {
|
|||||||
description: 'Description of Test Plugin',
|
description: 'Description of Test Plugin',
|
||||||
gatekeeper: 'GK_flipper_plugin_test',
|
gatekeeper: 'GK_flipper_plugin_test',
|
||||||
};
|
};
|
||||||
|
// @ts-expect-error this is read only and it is fine, this is a test
|
||||||
fs.readJson = jest.fn().mockImplementation(() => pluginV2);
|
fs.readJson = jest.fn().mockImplementation(() => pluginV2);
|
||||||
const details = await getInstalledPluginDetails(pluginPath);
|
const details = await getInstalledPluginDetails(pluginPath);
|
||||||
details.dir = normalizePath(details.dir);
|
details.dir = normalizePath(details.dir);
|
||||||
@@ -167,6 +170,7 @@ test('name without "flipper-plugin-" prefix is used as title if the latter omite
|
|||||||
description: 'Description of Test Plugin',
|
description: 'Description of Test Plugin',
|
||||||
gatekeeper: 'GK_flipper_plugin_test',
|
gatekeeper: 'GK_flipper_plugin_test',
|
||||||
};
|
};
|
||||||
|
// @ts-expect-error this is read only and it is fine, this is a test
|
||||||
fs.readJson = jest.fn().mockImplementation(() => pluginV2);
|
fs.readJson = jest.fn().mockImplementation(() => pluginV2);
|
||||||
const details = await getInstalledPluginDetails(pluginPath);
|
const details = await getInstalledPluginDetails(pluginPath);
|
||||||
details.dir = normalizePath(details.dir);
|
details.dir = normalizePath(details.dir);
|
||||||
@@ -216,6 +220,7 @@ test('flipper-plugin-version is parsed', async () => {
|
|||||||
'flipper-plugin': '^0.45',
|
'flipper-plugin': '^0.45',
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
// @ts-expect-error this is read only and it is fine, this is a test
|
||||||
fs.readJson = jest.fn().mockImplementation(() => pluginV2);
|
fs.readJson = jest.fn().mockImplementation(() => pluginV2);
|
||||||
const details = await getInstalledPluginDetails(pluginPath);
|
const details = await getInstalledPluginDetails(pluginPath);
|
||||||
details.dir = normalizePath(details.dir);
|
details.dir = normalizePath(details.dir);
|
||||||
@@ -269,6 +274,7 @@ test('plugin type and supported devices parsed', async () => {
|
|||||||
description: 'Description of Test Plugin',
|
description: 'Description of Test Plugin',
|
||||||
gatekeeper: 'GK_flipper_plugin_test',
|
gatekeeper: 'GK_flipper_plugin_test',
|
||||||
};
|
};
|
||||||
|
// @ts-expect-error this is read only and it is fine, this is a test
|
||||||
fs.readJson = jest.fn().mockImplementation(() => pluginV2);
|
fs.readJson = jest.fn().mockImplementation(() => pluginV2);
|
||||||
const details = await getInstalledPluginDetails(pluginPath);
|
const details = await getInstalledPluginDetails(pluginPath);
|
||||||
details.dir = normalizePath(details.dir);
|
details.dir = normalizePath(details.dir);
|
||||||
@@ -338,6 +344,7 @@ test('plugin type and supported apps parsed', async () => {
|
|||||||
description: 'Description of Test Plugin',
|
description: 'Description of Test Plugin',
|
||||||
gatekeeper: 'GK_flipper_plugin_test',
|
gatekeeper: 'GK_flipper_plugin_test',
|
||||||
};
|
};
|
||||||
|
// @ts-expect-error this is read only and it is fine, this is a test
|
||||||
fs.readJson = jest.fn().mockImplementation(() => pluginV2);
|
fs.readJson = jest.fn().mockImplementation(() => pluginV2);
|
||||||
const details = await getInstalledPluginDetails(pluginPath);
|
const details = await getInstalledPluginDetails(pluginPath);
|
||||||
details.dir = normalizePath(details.dir);
|
details.dir = normalizePath(details.dir);
|
||||||
@@ -417,7 +424,7 @@ test('can merge two package.json files', async () => {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
const mockedFs = jest.mocked(fs);
|
const mockedFs = jest.mocked(fs);
|
||||||
mockedFs.readJson.mockImplementation((file) => {
|
mockedFs.readJson.mockImplementation((file): any => {
|
||||||
if (file === path.join(pluginPath, 'package.json')) {
|
if (file === path.join(pluginPath, 'package.json')) {
|
||||||
return pluginBase;
|
return pluginBase;
|
||||||
} else if (file === path.join(pluginPath, 'fb', 'package.json')) {
|
} else if (file === path.join(pluginPath, 'fb', 'package.json')) {
|
||||||
|
|||||||
@@ -119,24 +119,32 @@ function collectFileContent(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
describe('pluginInstaller', () => {
|
jest.mock('fs-extra', () => {
|
||||||
let readJson: any;
|
const mod = {
|
||||||
beforeEach(() => {
|
...jest.requireActual('fs-extra'),
|
||||||
mockfs(installedPluginFiles);
|
readJson: jest.fn((file: string) => {
|
||||||
readJson = fs.readJson;
|
|
||||||
fs.readJson = (file: string) => {
|
|
||||||
const content = fileContent.get(normalizePath(file));
|
const content = fileContent.get(normalizePath(file));
|
||||||
if (content) {
|
if (content) {
|
||||||
return Promise.resolve(JSON.parse(content));
|
return Promise.resolve(JSON.parse(content));
|
||||||
} else {
|
} else {
|
||||||
return Promise.resolve(undefined);
|
return Promise.resolve(undefined);
|
||||||
}
|
}
|
||||||
};
|
}),
|
||||||
|
};
|
||||||
|
|
||||||
|
return {
|
||||||
|
...mod,
|
||||||
|
default: mod,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('pluginInstaller', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
mockfs(installedPluginFiles);
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
mockfs.restore();
|
mockfs.restore();
|
||||||
fs.readJson = readJson;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('getInstalledPlugins', async () => {
|
test('getInstalledPlugins', async () => {
|
||||||
|
|||||||
@@ -57,7 +57,6 @@ export async function prepareDefaultPlugins(isInsidersBuild: boolean = false) {
|
|||||||
`⚙️ Copying the provided default plugins dir "${forcedDefaultPluginsDir}"...`,
|
`⚙️ Copying the provided default plugins dir "${forcedDefaultPluginsDir}"...`,
|
||||||
);
|
);
|
||||||
await fs.copy(forcedDefaultPluginsDir, defaultPluginsDir, {
|
await fs.copy(forcedDefaultPluginsDir, defaultPluginsDir, {
|
||||||
recursive: true,
|
|
||||||
overwrite: true,
|
overwrite: true,
|
||||||
dereference: true,
|
dereference: true,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -59,7 +59,6 @@ async function copyPackageWithDependenciesRecursive(
|
|||||||
.then((l: Array<string>) => ignore().add(DEFAULT_BUILD_IGNORES.concat(l)));
|
.then((l: Array<string>) => ignore().add(DEFAULT_BUILD_IGNORES.concat(l)));
|
||||||
await fs.copy(packageDir, targetDir, {
|
await fs.copy(packageDir, targetDir, {
|
||||||
dereference: true,
|
dereference: true,
|
||||||
recursive: true,
|
|
||||||
filter: (src) => {
|
filter: (src) => {
|
||||||
const relativePath = path.relative(packageDir, src);
|
const relativePath = path.relative(packageDir, src);
|
||||||
return relativePath === '' || !ignores.ignores(relativePath);
|
return relativePath === '' || !ignores.ignores(relativePath);
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
"@types/adobe__node-fetch-retry": "^1.0.4",
|
"@types/adobe__node-fetch-retry": "^1.0.4",
|
||||||
"@types/babel__code-frame": "^7.0.3",
|
"@types/babel__code-frame": "^7.0.3",
|
||||||
"@types/detect-port": "^1.3.3",
|
"@types/detect-port": "^1.3.3",
|
||||||
"@types/fs-extra": "^9.0.13",
|
"@types/fs-extra": "^11.0.0",
|
||||||
"@types/node": "^17.0.31",
|
"@types/node": "^17.0.31",
|
||||||
"ansi-to-html": "^0.7.2",
|
"ansi-to-html": "^0.7.2",
|
||||||
"app-builder-lib": "23.6.0",
|
"app-builder-lib": "23.6.0",
|
||||||
@@ -24,7 +24,7 @@
|
|||||||
"flipper-common": "0.0.0",
|
"flipper-common": "0.0.0",
|
||||||
"flipper-pkg-lib": "0.0.0",
|
"flipper-pkg-lib": "0.0.0",
|
||||||
"flipper-plugin-lib": "0.0.0",
|
"flipper-plugin-lib": "0.0.0",
|
||||||
"fs-extra": "^10.1.0",
|
"fs-extra": "^11.0.0",
|
||||||
"glob": "^8.0.1",
|
"glob": "^8.0.1",
|
||||||
"ignore": "^5.2.4",
|
"ignore": "^5.2.4",
|
||||||
"metro": "^0.70.2",
|
"metro": "^0.70.2",
|
||||||
|
|||||||
@@ -4087,7 +4087,15 @@
|
|||||||
resolved "https://registry.yarnpkg.com/@types/file-saver/-/file-saver-2.0.5.tgz#9ee342a5d1314bb0928375424a2f162f97c310c7"
|
resolved "https://registry.yarnpkg.com/@types/file-saver/-/file-saver-2.0.5.tgz#9ee342a5d1314bb0928375424a2f162f97c310c7"
|
||||||
integrity sha512-zv9kNf3keYegP5oThGLaPk8E081DFDuwfqjtiTzm6PoxChdJ1raSuADf2YGCVIyrSynLrgc8JWv296s7Q7pQSQ==
|
integrity sha512-zv9kNf3keYegP5oThGLaPk8E081DFDuwfqjtiTzm6PoxChdJ1raSuADf2YGCVIyrSynLrgc8JWv296s7Q7pQSQ==
|
||||||
|
|
||||||
"@types/fs-extra@^9.0.11", "@types/fs-extra@^9.0.12", "@types/fs-extra@^9.0.13":
|
"@types/fs-extra@^11.0.0", "@types/fs-extra@^11.0.1":
|
||||||
|
version "11.0.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/@types/fs-extra/-/fs-extra-11.0.1.tgz#f542ec47810532a8a252127e6e105f487e0a6ea5"
|
||||||
|
integrity sha512-MxObHvNl4A69ofaTRU8DFqvgzzv8s9yRtaPPm5gud9HDNvpB3GPQFvNuTWAI59B9huVGV5jXYJwbCsmBsOGYWA==
|
||||||
|
dependencies:
|
||||||
|
"@types/jsonfile" "*"
|
||||||
|
"@types/node" "*"
|
||||||
|
|
||||||
|
"@types/fs-extra@^9.0.11", "@types/fs-extra@^9.0.12":
|
||||||
version "9.0.13"
|
version "9.0.13"
|
||||||
resolved "https://registry.yarnpkg.com/@types/fs-extra/-/fs-extra-9.0.13.tgz#7594fbae04fe7f1918ce8b3d213f74ff44ac1f45"
|
resolved "https://registry.yarnpkg.com/@types/fs-extra/-/fs-extra-9.0.13.tgz#7594fbae04fe7f1918ce8b3d213f74ff44ac1f45"
|
||||||
integrity sha512-nEnwB++1u5lVDM2UI4c1+5R+FYaKfaAzS4OococimjVm3nQw3TuzH5UNsocrcTBbhnerblyHj4A49qXbIiZdpA==
|
integrity sha512-nEnwB++1u5lVDM2UI4c1+5R+FYaKfaAzS4OococimjVm3nQw3TuzH5UNsocrcTBbhnerblyHj4A49qXbIiZdpA==
|
||||||
@@ -4210,6 +4218,13 @@
|
|||||||
resolved "https://registry.yarnpkg.com/@types/json5/-/json5-0.0.29.tgz#ee28707ae94e11d2b827bcbe5270bcea7f3e71ee"
|
resolved "https://registry.yarnpkg.com/@types/json5/-/json5-0.0.29.tgz#ee28707ae94e11d2b827bcbe5270bcea7f3e71ee"
|
||||||
integrity sha1-7ihweulOEdK4J7y+UnC86n8+ce4=
|
integrity sha1-7ihweulOEdK4J7y+UnC86n8+ce4=
|
||||||
|
|
||||||
|
"@types/jsonfile@*":
|
||||||
|
version "6.1.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/@types/jsonfile/-/jsonfile-6.1.1.tgz#ac84e9aefa74a2425a0fb3012bdea44f58970f1b"
|
||||||
|
integrity sha512-GSgiRCVeapDN+3pqA35IkQwasaCh/0YFH5dEF6S88iDvEn901DjOeH3/QPY+XYP1DFzDZPvIvfeEgk+7br5png==
|
||||||
|
dependencies:
|
||||||
|
"@types/node" "*"
|
||||||
|
|
||||||
"@types/jsonwebtoken@^9.0.1":
|
"@types/jsonwebtoken@^9.0.1":
|
||||||
version "9.0.1"
|
version "9.0.1"
|
||||||
resolved "https://registry.yarnpkg.com/@types/jsonwebtoken/-/jsonwebtoken-9.0.1.tgz#29b1369c4774200d6d6f63135bf3d1ba3ef997a4"
|
resolved "https://registry.yarnpkg.com/@types/jsonwebtoken/-/jsonwebtoken-9.0.1.tgz#29b1369c4774200d6d6f63135bf3d1ba3ef997a4"
|
||||||
@@ -8539,19 +8554,19 @@ fs-extra@^10.0.0, fs-extra@^10.1.0:
|
|||||||
jsonfile "^6.0.1"
|
jsonfile "^6.0.1"
|
||||||
universalify "^2.0.0"
|
universalify "^2.0.0"
|
||||||
|
|
||||||
fs-extra@^11.1.0:
|
fs-extra@^11.0.0, fs-extra@^11.1.1:
|
||||||
version "11.1.0"
|
version "11.1.1"
|
||||||
resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-11.1.0.tgz#5784b102104433bb0e090f48bfc4a30742c357ed"
|
resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-11.1.1.tgz#da69f7c39f3b002378b0954bb6ae7efdc0876e2d"
|
||||||
integrity sha512-0rcTq621PD5jM/e0a3EJoGC/1TC5ZBCERW82LQuwfGnCa1V8w7dpYH1yNu+SLb6E5dkeCBzKEyLGlFrnr+dUyw==
|
integrity sha512-MGIE4HOvQCeUCzmlHs0vXpih4ysz4wg9qiSAu6cd42lVwPbTM1TjV7RusoyQqMmk/95gdQZX72u+YW+c3eEpFQ==
|
||||||
dependencies:
|
dependencies:
|
||||||
graceful-fs "^4.2.0"
|
graceful-fs "^4.2.0"
|
||||||
jsonfile "^6.0.1"
|
jsonfile "^6.0.1"
|
||||||
universalify "^2.0.0"
|
universalify "^2.0.0"
|
||||||
|
|
||||||
fs-extra@^11.1.1:
|
fs-extra@^11.1.0:
|
||||||
version "11.1.1"
|
version "11.1.0"
|
||||||
resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-11.1.1.tgz#da69f7c39f3b002378b0954bb6ae7efdc0876e2d"
|
resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-11.1.0.tgz#5784b102104433bb0e090f48bfc4a30742c357ed"
|
||||||
integrity sha512-MGIE4HOvQCeUCzmlHs0vXpih4ysz4wg9qiSAu6cd42lVwPbTM1TjV7RusoyQqMmk/95gdQZX72u+YW+c3eEpFQ==
|
integrity sha512-0rcTq621PD5jM/e0a3EJoGC/1TC5ZBCERW82LQuwfGnCa1V8w7dpYH1yNu+SLb6E5dkeCBzKEyLGlFrnr+dUyw==
|
||||||
dependencies:
|
dependencies:
|
||||||
graceful-fs "^4.2.0"
|
graceful-fs "^4.2.0"
|
||||||
jsonfile "^6.0.1"
|
jsonfile "^6.0.1"
|
||||||
|
|||||||
Reference in New Issue
Block a user