diff --git a/packages/server/src/api/controllers/plugin.ts b/packages/server/src/api/controllers/plugin/index.ts similarity index 95% rename from packages/server/src/api/controllers/plugin.ts rename to packages/server/src/api/controllers/plugin/index.ts index 3941798ac4..de4aa2a50a 100644 --- a/packages/server/src/api/controllers/plugin.ts +++ b/packages/server/src/api/controllers/plugin/index.ts @@ -1,20 +1,20 @@ -import { ObjectStoreBuckets } from "../../constants" -import { loadJSFile } from "../../utilities/fileSystem" +import { ObjectStoreBuckets } from "../../../constants" +import { loadJSFile } from "../../../utilities/fileSystem" import { uploadedNpmPlugin, uploadedUrlPlugin, uploadedGithubPlugin, uploadedFilePlugin, -} from "./plugin/utils" +} from "./utils" import { getGlobalDB } from "@budibase/backend-core/tenancy" import { validate } from "@budibase/backend-core/plugins" -import { generatePluginID, getPluginParams } from "../../db/utils" +import { generatePluginID, getPluginParams } from "../../../db/utils" import { uploadDirectory, deleteFolder, } from "@budibase/backend-core/objectStore" import { PluginType, FileType } from "@budibase/types" -import env from "../../environment" +import env from "../../../environment" export async function getPlugins(type?: PluginType) { const db = getGlobalDB() diff --git a/packages/server/src/utilities/fileSystem/index.js b/packages/server/src/utilities/fileSystem/index.js index ef9088dd3e..40cc456356 100644 --- a/packages/server/src/utilities/fileSystem/index.js +++ b/packages/server/src/utilities/fileSystem/index.js @@ -426,36 +426,34 @@ exports.getDatasourcePlugin = async (name, url, hash) => { /** * Find for a file recursively from start path applying filter, return first match */ -const findFileRec = (startPath, filter) => { +exports.findFileRec = (startPath, filter) => { if (!fs.existsSync(startPath)) { return } - var files = fs.readdirSync(startPath) + const files = fs.readdirSync(startPath) for (let i = 0, len = files.length; i < len; i++) { const filename = join(startPath, files[i]) const stat = fs.lstatSync(filename) if (stat.isDirectory()) { - return findFileRec(filename, filter) + return exports.findFileRec(filename, filter) } else if (filename.endsWith(filter)) { return filename } } } -exports.findFileRec = findFileRec /** * Remove a folder which is not empty from the file system */ -const deleteFolderFileSystem = path => { +exports.deleteFolderFileSystem = path => { if (!fs.existsSync(path)) { return } fs.rmSync(path, { recursive: true, force: true }) } -exports.deleteFolderFileSystem = deleteFolderFileSystem /** * Full function definition for below can be found in the utilities.