diff --git a/plugins/techdocs-node/package.json b/plugins/techdocs-node/package.json index 816dac3a00..9f8d41e9b2 100644 --- a/plugins/techdocs-node/package.json +++ b/plugins/techdocs-node/package.json @@ -63,7 +63,6 @@ "js-yaml": "^4.0.0", "json5": "^2.1.3", "mime-types": "^2.1.27", - "mock-fs": "^5.2.0", "p-limit": "^3.1.0", "recursive-readdir": "^2.2.2", "winston": "^3.2.1" @@ -74,7 +73,6 @@ "@types/fs-extra": "^9.0.5", "@types/js-yaml": "^4.0.0", "@types/mime-types": "^2.1.0", - "@types/mock-fs": "^4.13.0", "@types/recursive-readdir": "^2.2.0", "@types/supertest": "^2.0.8", "aws-sdk-client-mock": "^2.0.0", diff --git a/plugins/techdocs-node/src/testUtils/StorageFilesMock.ts b/plugins/techdocs-node/src/testUtils/StorageFilesMock.ts deleted file mode 100644 index dd28110d00..0000000000 --- a/plugins/techdocs-node/src/testUtils/StorageFilesMock.ts +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright 2020 The Backstage Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import os from 'os'; -import path from 'path'; -import fs from 'fs-extra'; -import { IStorageFilesMock } from './types'; - -export const storageRootDir: string = - os.platform() === 'win32' ? 'C:\\rootDir' : '/rootDir'; - -const encoding = 'utf8'; - -export class StorageFilesMock implements IStorageFilesMock { - static rootDir = storageRootDir; - - private files: Record; - - constructor() { - this.files = {}; - } - - public emptyFiles(): void { - this.files = {}; - } - - public fileExists(targetPath: string): boolean { - const filePath = path.join(storageRootDir, targetPath); - const posixPath = filePath.split(path.posix.sep).join(path.sep); - return this.files[posixPath] !== undefined; - } - - public readFile(targetPath: string): Buffer { - const filePath = path.join(storageRootDir, targetPath); - return Buffer.from(this.files[filePath] ?? '', encoding); - } - - public writeFile(targetPath: string, sourcePath: string): void; - public writeFile(targetPath: string, sourceBuffer: Buffer): void; - public writeFile(targetPath: string, source: string | Buffer): void { - const filePath = path.join(storageRootDir, targetPath); - if (typeof source === 'string') { - this.files[filePath] = fs.readFileSync(source).toString(encoding); - } else { - this.files[filePath] = source.toString(encoding); - } - } -} diff --git a/plugins/techdocs-node/src/testUtils/types.ts b/plugins/techdocs-node/src/testUtils/types.ts deleted file mode 100644 index b58e004ab8..0000000000 --- a/plugins/techdocs-node/src/testUtils/types.ts +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright 2020 The Backstage Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -export interface IStorageFilesMock { - emptyFiles(): void; - fileExists(targetPath: string): boolean; - readFile(targetPath: string): Buffer; - writeFile(targetPath: string, sourcePath: string): void; - writeFile(targetPath: string, sourceBuffer: Buffer): void; - writeFile(targetPath: string, source: string | Buffer): void; -} diff --git a/yarn.lock b/yarn.lock index 3b4b943ee8..334f8baae0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -9681,7 +9681,6 @@ __metadata: "@types/fs-extra": ^9.0.5 "@types/js-yaml": ^4.0.0 "@types/mime-types": ^2.1.0 - "@types/mock-fs": ^4.13.0 "@types/recursive-readdir": ^2.2.0 "@types/supertest": ^2.0.8 aws-sdk-client-mock: ^2.0.0 @@ -9692,7 +9691,6 @@ __metadata: js-yaml: ^4.0.0 json5: ^2.1.3 mime-types: ^2.1.27 - mock-fs: ^5.2.0 p-limit: ^3.1.0 recursive-readdir: ^2.2.2 supertest: ^6.1.3