diff --git a/package-lock.json b/package-lock.json index fcfee22..db8c6f9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,9 +1,27 @@ { "name": "server", - "version": "0.5.0", + "version": "0.7.0", "lockfileVersion": 1, "requires": true, "dependencies": { + "@a2r/fs": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/@a2r/fs/-/fs-1.1.4.tgz", + "integrity": "sha512-y/Ym4qPvnXQYtRQ6WrrSyablw6YEZp1dGVITXTtNcLGPqjfMlk/crtfE2CqdpgQLaOU+mqBrei+koJb9OsjRvw==", + "requires": { + "rimraf": "^3.0.2" + }, + "dependencies": { + "rimraf": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", + "integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==", + "requires": { + "glob": "^7.1.3" + } + } + } + }, "@a2r/telemetry": { "version": "1.0.30", "resolved": "https://registry.npmjs.org/@a2r/telemetry/-/telemetry-1.0.30.tgz", diff --git a/package.json b/package.json index 345d8f8..33c57b9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "server", - "version": "0.7.0", + "version": "0.8.0", "description": "Application logic and runtime server", "engines": { "node": ">=12" @@ -45,11 +45,12 @@ "license": "MIT", "homepage": "https://a2r.com/", "dependencies": { + "@a2r/fs": "^1.1.4", "@a2r/telemetry": "^1.0.29", "chalk": "^4.0.0", "express": "^4.17.1", - "socket.io": "^2.2.0", - "snyk": "^1.328.0" + "snyk": "^1.328.0", + "socket.io": "^2.2.0" }, "devDependencies": { "@types/express": "^4.17.6", diff --git a/tools/fs.ts b/tools/fs.ts deleted file mode 100644 index 1c23270..0000000 --- a/tools/fs.ts +++ /dev/null @@ -1,41 +0,0 @@ -import fs from 'fs'; -import util from 'util'; -import path from 'path'; - -/** - * Read a directory. - */ -export const readDir = util.promisify(fs.readdir); - -/** - * Gets files recursively - * @param folderPath Path to get files from - */ -export const getFilesRecursively = async ( - folderPath: string, - extName?: string[], -): Promise => { - const contents = await readDir(folderPath, { - encoding: 'utf8', - withFileTypes: true, - }); - const files = await Promise.all( - contents.map( - async (content): Promise => { - if (content.isDirectory()) { - const folderFiles = await getFilesRecursively( - path.resolve(folderPath, content.name), - extName, - ); - return folderFiles; - } - const ext = path.extname(content.name); - if (!extName || !extName.length || extName.indexOf(ext) !== -1) { - return [path.resolve(folderPath, content.name)]; - } - return []; - }, - ), - ); - return files.reduce((t, f) => [...t, ...f], []); -}; \ No newline at end of file diff --git a/utils/getApi.ts b/utils/getApi.ts index b88dbbb..8121b06 100644 --- a/utils/getApi.ts +++ b/utils/getApi.ts @@ -1,9 +1,8 @@ import path from 'path'; +import { getFilesRecursively } from '@a2r/fs'; import { APIStructure, APIModule } from '../model/api'; -import { getFilesRecursively } from '../tools/fs'; - import { apiFileExtension } from '../settings'; /**