diff --git a/index.ts b/index.ts index f68aa35..6377335 100644 --- a/index.ts +++ b/index.ts @@ -1,9 +1,9 @@ import path from 'path'; import chokidar from 'chokidar'; +import { ensureDir } from '@a2r/fs'; import { targetPath, proxyPath } from './settings'; import initWatchers from './utils/initWatchers'; -import { ensureDir } from './tools/fs'; import { isJest } from './tools/isJest'; /** diff --git a/package-lock.json b/package-lock.json index c0c2f1c..fd520e2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,9 +1,17 @@ { "name": "watcher", - "version": "0.6.0", + "version": "0.8.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" + } + }, "@a2r/telemetry": { "version": "1.0.30", "resolved": "https://registry.npmjs.org/@a2r/telemetry/-/telemetry-1.0.30.tgz", @@ -8901,9 +8909,9 @@ } }, "snyk": { - "version": "1.328.0", - "resolved": "https://registry.npmjs.org/snyk/-/snyk-1.328.0.tgz", - "integrity": "sha512-wdbyIA5dTZD6nGxO2z3r/V4XSBLOuW08Vu87u93tbdihhanxe8sC37/ChzysGNvee/IcW98/hxwZf+pmVka0bA==", + "version": "1.329.0", + "resolved": "https://registry.npmjs.org/snyk/-/snyk-1.329.0.tgz", + "integrity": "sha512-eDHfnLYgxVSuAzIJPBBhPqRN+6c5eWsQA+ff67OR9Qn4JUgI3MSuyxPJ3o6JPoyE/qYZfKhdFnyqBBz1eUu3oQ==", "requires": { "@snyk/cli-interface": "2.6.0", "@snyk/dep-graph": "1.18.3", diff --git a/package.json b/package.json index ff24612..756c8d8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "watcher", - "version": "0.8.0", + "version": "0.9.0", "description": "API and model watcher", "engines": { "node": ">=12" @@ -38,11 +38,11 @@ "license": "ISC", "homepage": "https://a2r.com/", "dependencies": { + "@a2r/fs": "^1.1.4", "@a2r/telemetry": "^1.0.30", "chalk": "^4.0.0", "chokidar": "^3.4.0", - "rimraf": "^3.0.2", - "snyk": "^1.328.0", + "snyk": "^1.329.0", "socket.io": "^2.3.0", "typescript": "^3.9.3", "winston": "^3.2.1", diff --git a/test/tests/api/apiProxy.ts b/test/tests/api/apiProxy.ts index 8286be5..0bd4fba 100644 --- a/test/tests/api/apiProxy.ts +++ b/test/tests/api/apiProxy.ts @@ -1,8 +1,8 @@ import path from 'path'; import waitForExpect from 'wait-for-expect'; +import { emptyFolder, exists } from '@a2r/fs'; import { build } from '../../../utils/apiProxy'; -import { emptyFolder, exists } from '../../../tools/fs'; const apiSourcePath = path.resolve(__dirname, '../../mocks/server/module-info/api'); const proxyTargetPath = path.resolve(__dirname, '../../mocks/.a2r/api-proxy/api'); diff --git a/test/tests/api/isClientContent.ts b/test/tests/api/isClientContent.ts index cfc530e..8ece57b 100644 --- a/test/tests/api/isClientContent.ts +++ b/test/tests/api/isClientContent.ts @@ -1,6 +1,6 @@ import path from 'path'; +import { readFile } from '@a2r/fs'; -import { readFile } from '../../../tools/fs'; import getIsClientContent from '../../../utils/getIsClientContent'; const isClientPath = path.resolve(__dirname, '../../../tools/isClient.ts'); diff --git a/test/tests/api/modelImports.ts b/test/tests/api/modelImports.ts index 76a4a84..d5cbb38 100644 --- a/test/tests/api/modelImports.ts +++ b/test/tests/api/modelImports.ts @@ -1,8 +1,8 @@ import path from 'path'; import waitForExpect from 'wait-for-expect'; +import { emptyFolder, exists } from '@a2r/fs'; import { build } from '../../../utils/apiProxy'; -import { emptyFolder, exists } from '../../../tools/fs'; const apiSourcePath = path.resolve(__dirname, '../../mocks/server/model-imports/api'); const proxyTargetPath = path.resolve(__dirname, '../../mocks/.a2r/model-imports/api'); diff --git a/test/tests/fs/copyContents.ts b/test/tests/fs/copyContents.ts deleted file mode 100644 index e9d8e15..0000000 --- a/test/tests/fs/copyContents.ts +++ /dev/null @@ -1,30 +0,0 @@ -import path from 'path'; - -import { copyContents, exists, emptyFolder, rmDir } from '../../../tools/fs'; - -const src = path.resolve(__dirname, '../../mocks/server'); -const dest = path.resolve(__dirname, '../../mocks/server-copy'); -const insideFolder = path.resolve(dest, 'api'); - -/** - * Method should copy folders and files recursively - */ -test('Copy contents should copy folders recursively', async (): Promise => { - expect(await exists(dest)).toBe(false); - await copyContents(src, dest); - expect(await exists(dest)).toBe(true); - expect(await exists(insideFolder)).toBe(true); -}); - -/** - * Method should copy folders and files recursively - */ -test('Copy contents should avoid copying existing', async (): Promise => { - await copyContents(src, dest); - await copyContents(src, dest, false); -}); - -afterAll(async (): Promise => { - await emptyFolder(dest); - await rmDir(dest); -}); \ No newline at end of file diff --git a/test/tests/fs/emptyFolder.ts b/test/tests/fs/emptyFolder.ts deleted file mode 100644 index 208c673..0000000 --- a/test/tests/fs/emptyFolder.ts +++ /dev/null @@ -1,16 +0,0 @@ -import path from 'path'; - -import { emptyFolder, exists, rmDir } from '../../../tools/fs'; - -const mocksPath = path.resolve(__dirname, '../../mocks/fs'); - -/** - * Empty folder should work even if path doesn't exist - */ -test(`Empty folder should work even if path doesn't exist`, async (): Promise => { - const newFolder = path.resolve(mocksPath, 'empty-new'); - expect(await exists(newFolder)).toBe(false); - await emptyFolder(newFolder); - expect(await exists(newFolder)).toBe(true); - await rmDir(newFolder); -}); diff --git a/test/tests/fs/ensureDir.ts b/test/tests/fs/ensureDir.ts deleted file mode 100644 index 7c54e1e..0000000 --- a/test/tests/fs/ensureDir.ts +++ /dev/null @@ -1,22 +0,0 @@ -import path from 'path'; - -import { ensureDir, mkDir, exists, rmDir } from '../../../tools/fs'; - -const ensurePath = path.resolve(__dirname, '../../mocks/ensure'); -const pathToEnsure = path.resolve(ensurePath, 'fail'); - -/** - * Function should fail when being asked to ensure a folder whose parent doesn't exists with `recursive` set to `false` - */ -test('Ensure dir should fail', async (): Promise => { - expect(ensureDir(pathToEnsure, {}, false)).rejects.toThrow(); - expect(ensureDir(pathToEnsure, {}, false)).rejects.toHaveProperty('code'); - expect(ensureDir(pathToEnsure, {}, false)).rejects.not.toHaveProperty('code', 'EEXIST'); - await mkDir(ensurePath, { mode: 0o000 }); - expect(await exists(ensurePath)).toBe(true); - expect(ensureDir(pathToEnsure, {}, false)).rejects.not.toHaveProperty('code', 'EEXIST'); -}); - -afterAll(async (): Promise => { - await rmDir(ensurePath); -}); \ No newline at end of file diff --git a/test/tests/fs/getFilesRecursively.ts b/test/tests/fs/getFilesRecursively.ts deleted file mode 100644 index 052e640..0000000 --- a/test/tests/fs/getFilesRecursively.ts +++ /dev/null @@ -1,17 +0,0 @@ -import path from 'path'; - -import { getFilesRecursively } from '../../../tools/fs'; - -const recursivePath = path.resolve(__dirname, '../../mocks/fs/recursive'); - -/** - * Function should return all files recursively from path - */ -test('Get files recursively', async (): Promise => { - const files = await getFilesRecursively(recursivePath); - const file1 = path.resolve(recursivePath, 'path-1', 'file-1.txt'); - const file2 = path.resolve(recursivePath, 'path-2', 'file-2.txt'); - expect(files.length).toBe(2); - expect(files).toContain(file1); - expect(files).toContain(file2); -}); \ No newline at end of file diff --git a/test/tests/ts/getExportsIdentifiersFromNodes.ts b/test/tests/ts/getExportsIdentifiersFromNodes.ts index 3e48b54..c4a4f2b 100644 --- a/test/tests/ts/getExportsIdentifiersFromNodes.ts +++ b/test/tests/ts/getExportsIdentifiersFromNodes.ts @@ -1,8 +1,8 @@ import ts from 'typescript'; import path from 'path'; +import { readFile } from '@a2r/fs'; import getExportsIdentifiersFromNodes from '../../../utils/getExportsIdentifiersFromNodes'; -import { readFile } from '../../../tools/fs'; const modelSourcePath = path.resolve(__dirname, '../../mocks/server/model-imports/model'); diff --git a/test/tests/ts/getFunctionDocContainer.ts b/test/tests/ts/getFunctionDocContainer.ts index f80ec09..9804e2d 100644 --- a/test/tests/ts/getFunctionDocContainer.ts +++ b/test/tests/ts/getFunctionDocContainer.ts @@ -1,7 +1,7 @@ import ts from 'typescript'; import path from 'path'; +import { readFile } from '@a2r/fs'; -import { readFile } from '../../../tools/fs'; import getMainMethodName from '../../../utils/getMainMethodName'; import getMainMethodNode from '../../../utils/getMainMethodNode'; import getFunctionDocContainer from '../../../utils/getFunctionDocContainer'; diff --git a/test/tests/ts/getFunctionName.ts b/test/tests/ts/getFunctionName.ts index 05282eb..ff8df08 100644 --- a/test/tests/ts/getFunctionName.ts +++ b/test/tests/ts/getFunctionName.ts @@ -1,7 +1,7 @@ import ts from 'typescript'; import path from 'path'; +import { readFile } from '@a2r/fs'; -import { readFile } from '../../../tools/fs'; import getMainMethodName from '../../../utils/getMainMethodName'; import getMainMethodNode from '../../../utils/getMainMethodNode'; import getFunctionName from '../../../utils/getFunctionName'; diff --git a/test/tests/ts/getFunctionReturnTypeInfo.ts b/test/tests/ts/getFunctionReturnTypeInfo.ts index 7e9b319..a337245 100644 --- a/test/tests/ts/getFunctionReturnTypeInfo.ts +++ b/test/tests/ts/getFunctionReturnTypeInfo.ts @@ -1,10 +1,10 @@ import ts from 'typescript'; import path from 'path'; +import { readFile } from '@a2r/fs'; import getFunctionReturnTypeInfo from '../../../utils/getFunctionReturnTypeInfo'; import getMainMethodName from '../../../utils/getMainMethodName'; import getMainMethodNode from '../../../utils/getMainMethodNode'; -import { readFile } from '../../../tools/fs'; const filePath = path.resolve(__dirname, '../../mocks/server/no-return/no-return.ts'); diff --git a/test/tests/ts/getMainMethodName.ts b/test/tests/ts/getMainMethodName.ts index 0b27fbf..afeb108 100644 --- a/test/tests/ts/getMainMethodName.ts +++ b/test/tests/ts/getMainMethodName.ts @@ -1,7 +1,7 @@ import ts from 'typescript'; import path from 'path'; +import { readFile } from '@a2r/fs'; -import { readFile } from '../../../tools/fs'; import getMainMethodName from '../../../utils/getMainMethodName'; const apiPath = path.resolve(__dirname, '../../mocks/server/api'); diff --git a/test/tests/ts/getMainMethodNode.ts b/test/tests/ts/getMainMethodNode.ts index 408b5e1..10493b6 100644 --- a/test/tests/ts/getMainMethodNode.ts +++ b/test/tests/ts/getMainMethodNode.ts @@ -1,7 +1,7 @@ import ts from 'typescript'; import path from 'path'; +import { readFile } from '@a2r/fs'; -import { readFile } from '../../../tools/fs'; import getMainMethodNode from '../../../utils/getMainMethodNode'; const apiPath = path.resolve(__dirname, '../../mocks/server/api'); diff --git a/test/tests/ts/getModelImports.ts b/test/tests/ts/getModelImports.ts index 468ab29..b52b985 100644 --- a/test/tests/ts/getModelImports.ts +++ b/test/tests/ts/getModelImports.ts @@ -1,7 +1,7 @@ import ts from 'typescript'; import path from 'path'; +import { readFile, getFilesRecursively } from '@a2r/fs'; -import { readFile, getFilesRecursively } from '../../../tools/fs'; import getModelImports from '../../../utils/getModelImports'; import getGroupedModelImports from '../../../utils/getGroupedModelImports'; import { ModelImport } from '../../../model/api'; @@ -34,23 +34,27 @@ test('Get model imports', async (): Promise => { test('Group model imports from same path', async (): Promise => { const apiPath = path.resolve(mainPath, 'api'); const files = await getFilesRecursively(apiPath, ['.ts']); - const fileImports = await Promise.all(files.map(async (filePath): Promise => { - const content = await readFile(filePath, 'utf8'); - const sourceFile = ts.createSourceFile( - filePath, - content, - ts.ScriptTarget.Latest, - false, - ts.ScriptKind.TS, - ); - - const children = sourceFile.getChildren(sourceFile); - - return getModelImports(children, sourceFile); - })); + const fileImports: ModelImport[][] = await Promise.all( + files.map( + async (filePath): Promise => { + const content = await readFile(filePath, 'utf8'); + const sourceFile = ts.createSourceFile( + filePath, + content, + ts.ScriptTarget.Latest, + false, + ts.ScriptKind.TS, + ); + + const children = sourceFile.getChildren(sourceFile); + + return getModelImports(children, sourceFile); + }, + ), + ); const imports = fileImports.reduce((t, i) => [...t, ...i], []); expect(imports.length).toBe(5); const groupedImports = getGroupedModelImports(imports); expect(groupedImports.length).toBe(3); -}); \ No newline at end of file +}); diff --git a/test/tests/validations/stressValidator.ts b/test/tests/validations/stressValidator.ts index e0b1773..f06a180 100644 --- a/test/tests/validations/stressValidator.ts +++ b/test/tests/validations/stressValidator.ts @@ -1,5 +1,6 @@ import path from 'path'; import waitForExpect from 'wait-for-expect'; +import { mkDir, emptyFolder, exists, writeFile } from '@a2r/fs'; import { WatcherOptions, OnReady } from '../../../model/watcher'; @@ -7,7 +8,6 @@ import onError from '../../../utils/onError'; import Validator from '../../../utils/runtimeValidator'; import watchFolder from '../../../utils/watchFolder'; import fileValidation from '../../../utils/modelFileValidation'; -import { mkDir, emptyFolder, exists, writeFile } from '../../../tools/fs'; const serverPath = path.resolve( __dirname, diff --git a/test/tests/validations/validator.ts b/test/tests/validations/validator.ts index 0a35f4b..00a5c14 100644 --- a/test/tests/validations/validator.ts +++ b/test/tests/validations/validator.ts @@ -1,12 +1,5 @@ import path from 'path'; import waitForExpect from 'wait-for-expect'; - -import { WatcherOptions, OnReady } from '../../../model/watcher'; - -import onError from '../../../utils/onError'; -import Validator from '../../../utils/runtimeValidator'; -import watchFolder from '../../../utils/watchFolder'; -import fileValidation from '../../../utils/modelFileValidation'; import { mkDir, emptyFolder, @@ -14,8 +7,14 @@ import { writeFile, unlink, rmDir, -} from '../../../tools/fs'; +} from '@a2r/fs'; +import { WatcherOptions, OnReady } from '../../../model/watcher'; + +import onError from '../../../utils/onError'; +import Validator from '../../../utils/runtimeValidator'; +import watchFolder from '../../../utils/watchFolder'; +import fileValidation from '../../../utils/modelFileValidation'; const serverPath = path.resolve(__dirname, '../../mocks/server/validator'); beforeAll(async () => { diff --git a/test/tests/watcher/initWatchers.ts b/test/tests/watcher/initWatchers.ts index 71200e3..9b0b229 100644 --- a/test/tests/watcher/initWatchers.ts +++ b/test/tests/watcher/initWatchers.ts @@ -1,8 +1,8 @@ import path from 'path'; import waitForExpect from 'wait-for-expect'; +import { emptyFolder, ensureDir, writeFile, exists } from '@a2r/fs'; import { apiPath, modelPath, proxyPath } from '../../../settings'; -import { emptyFolder, ensureDir, writeFile, exists } from '../../../tools/fs'; import initWatchers from '../../../utils/initWatchers'; import { setForceDisableJestDetection } from '../../../tools/isJest'; diff --git a/test/tests/watcher/watchFolder.ts b/test/tests/watcher/watchFolder.ts index 8857e4c..9a42e27 100644 --- a/test/tests/watcher/watchFolder.ts +++ b/test/tests/watcher/watchFolder.ts @@ -1,8 +1,8 @@ import path from 'path'; import chokidar from 'chokidar'; +import { emptyFolder } from '@a2r/fs'; import { Omit } from '../../../@types'; -import { emptyFolder } from '../../../tools/fs'; import onError from '../../../utils/onError'; import watchFolder from '../../../utils/watchFolder'; import { WatcherOptions } from '../../../model/watcher'; diff --git a/tools/fs.ts b/tools/fs.ts deleted file mode 100644 index 2ddd68b..0000000 --- a/tools/fs.ts +++ /dev/null @@ -1,165 +0,0 @@ -import fs from 'fs'; -import util from 'util'; -import path from 'path'; -import originalRimraf from 'rimraf'; - -/** - * Create a directory - */ -export const mkDir = util.promisify(fs.mkdir); - -/** - * Delete a directory. - */ -export const rmDir = util.promisify(fs.rmdir); - -/** - * The [UNIX command](http://en.wikipedia.org/wiki/Rm_(Unix)) `rm -rf` for node - */ -export const rimraf = util.promisify(originalRimraf); - -/** - * Writes data to a file, replacing the file if it already exists. - */ -export const writeFile = util.promisify(fs.writeFile); - -/** - * Read a directory. - */ -export const readDir = util.promisify(fs.readdir); - -/** - * Reads the entire contents of a file. - */ -export const readFile = util.promisify(fs.readFile); - -/** - * Copies `src` to `dest`. By default, dest is overwritten if it already exists. No arguments other than a possible exception are given to the callback function. Node.js makes no guarantees about the atomicity of the copy operation. If an error occurs after the destination file has been opened for writing, Node.js will attempt to remove the destination. - */ -export const copyFile = util.promisify(fs.copyFile); - -/** - * Deletes a name and possibly the file it refers to. - */ -export const unlink = util.promisify(fs.unlink); - -/** - * Test whether or not the given path exists by checking with the file system. - * @param {fs.PathLike} pathToCheck A path to a file or directory. If a URL is provided, it must use the `file:` protocol. URL support is experimental. - */ -export const exists = (pathToCheck: fs.PathLike): Promise => - new Promise((resolve): void => { - fs.access(pathToCheck, fs.constants.F_OK, (err): void => { - if (err) { - return resolve(false); - } - return resolve(true); - }); - }); - -/** - * Empties given folder by removing it and creating it again - * @param {string} folderPath Folder path to be emptied - */ -export const emptyFolder = async (folderPath: string): Promise => { - const pathExists = await exists(folderPath); - if (pathExists) { - await rimraf(folderPath); - } - await mkDir(folderPath, { recursive: true }); -}; - -/** - * Ensures that given dir path exists - * @param {string} folderPath Path to ensure - * @param {fs.MakeDirectoryOptions} options Options - */ -export const ensureDir = async ( - folderPath: string, - options?: fs.MakeDirectoryOptions, - recursive = true, -): Promise => { - await new Promise((resolve, reject): void => { - fs.mkdir( - folderPath, - { ...(options || {}), recursive }, - (err: NodeJS.ErrnoException | null): void => { - if (err && err.code !== 'EEXIST') { - reject(err); - } else { - resolve(); - } - }, - ); - }); -}; - -/** - * 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], []); -}; - -/** - * Copies contents recursively from `fromPath` to `destPath` - * @param {string} fromPath Source path - * @param {string} destPath Destination path - * @param {string} [relativePath=''] Relative path - */ -export const copyContents = async ( - fromPath: string, - destPath: string, - hard = true, - relativePath = '', -): Promise => { - const contentsPath = path.resolve(fromPath, relativePath); - await ensureDir(destPath); - const contents = await readDir(contentsPath, { withFileTypes: true }); - await Promise.all( - contents.map( - async (pathInfo: fs.Dirent): Promise => { - const { name: relPath } = pathInfo; - const fullRelPath = path.join(relativePath, relPath); - const sourcePath = path.resolve(fromPath, fullRelPath); - const targetPath = path.resolve(destPath, fullRelPath); - - if (pathInfo.isDirectory()) { - await ensureDir(targetPath); - await copyContents(fromPath, destPath, hard, fullRelPath); - } else { - const write = hard || !(await exists(targetPath)); - if (write) { - await copyFile(sourcePath, targetPath); - } - } - }, - ), - ); -}; diff --git a/utils/apiFileValidation.ts b/utils/apiFileValidation.ts index ab9e94e..399f380 100644 --- a/utils/apiFileValidation.ts +++ b/utils/apiFileValidation.ts @@ -1,7 +1,7 @@ import ts from 'typescript'; import { out } from '@a2r/telemetry'; +import { readFile } from '@a2r/fs'; -import { readFile } from '../tools/fs'; import { fullPath, method } from '../tools/colors'; import getMainMethodName from './getMainMethodName'; import getMainMethodNode from './getMainMethodNode'; diff --git a/utils/apiProxy.ts b/utils/apiProxy.ts index f1f59dc..2dfd579 100644 --- a/utils/apiProxy.ts +++ b/utils/apiProxy.ts @@ -1,6 +1,7 @@ import ts from 'typescript'; import path from 'path'; import { out } from '@a2r/telemetry'; +import { getFilesRecursively, writeFile } from '@a2r/fs'; import { APIStructure, @@ -10,7 +11,6 @@ import { } from '../model/api'; import { defaultApiSourcePath, defaultProxyTargetPath } from '../settings'; -import { getFilesRecursively, writeFile } from '../tools/fs'; import getModuleInfo from './getModuleInfo'; import getGroupedModelImports from './getGroupedModelImports'; import getProxyMethod from './getProxyMethod'; diff --git a/utils/getModuleInfo.ts b/utils/getModuleInfo.ts index 3862ed4..da71acd 100644 --- a/utils/getModuleInfo.ts +++ b/utils/getModuleInfo.ts @@ -1,9 +1,9 @@ import ts from 'typescript'; import path from 'path'; +import { readFile } from '@a2r/fs'; import { ModuleInfo } from '../model/api'; -import { readFile } from '../tools/fs'; import getMainMethodName from './getMainMethodName'; import getMainMethodNode from './getMainMethodNode'; import getFunctionDocContainer from './getFunctionDocContainer'; diff --git a/utils/initWatchers.ts b/utils/initWatchers.ts index 710decc..85c15d0 100644 --- a/utils/initWatchers.ts +++ b/utils/initWatchers.ts @@ -1,11 +1,11 @@ import path from 'path'; import chokidar from 'chokidar'; import { out } from '@a2r/telemetry'; +import { exists, emptyFolder } from '@a2r/fs'; import { WatcherOptions, OnReady } from '../model/watcher'; import { apiPath, modelPath, proxyPath } from '../settings'; -import { exists, emptyFolder } from '../tools/fs'; import { fullPath } from '../tools/colors'; import watchFolder from './watchFolder'; import onError from './onError'; diff --git a/utils/modelFileValidation.ts b/utils/modelFileValidation.ts index d6263ad..8848264 100644 --- a/utils/modelFileValidation.ts +++ b/utils/modelFileValidation.ts @@ -1,8 +1,8 @@ import ts from 'typescript'; -import { out } from '@a2r/telemetry'; import chalk from 'chalk'; +import { out } from '@a2r/telemetry'; +import { readFile } from '@a2r/fs'; -import { readFile } from '../tools/fs'; import { fullPath } from '../tools/colors'; import getExportsIdentifiersFromNodes from './getExportsIdentifiersFromNodes'; diff --git a/utils/onModelValidation.ts b/utils/onModelValidation.ts index 672390e..6af79f7 100644 --- a/utils/onModelValidation.ts +++ b/utils/onModelValidation.ts @@ -1,6 +1,7 @@ +import { copyContents, emptyFolder } from '@a2r/fs'; + import { OnValidation } from '../model/watcher'; -import { copyContents, emptyFolder } from '../tools/fs'; import { isJest } from '../tools/isJest'; /** diff --git a/utils/runtimeValidator.ts b/utils/runtimeValidator.ts index 6e560ba..58a50c9 100644 --- a/utils/runtimeValidator.ts +++ b/utils/runtimeValidator.ts @@ -1,9 +1,8 @@ import { out } from '@a2r/telemetry'; +import { getFilesRecursively } from '@a2r/fs'; import { ProcessInfo, OnValidation } from '../model/watcher'; -import { getFilesRecursively } from '../tools/fs'; - /** * Will handle files changes and validate them before */ diff --git a/utils/watchFolder.ts b/utils/watchFolder.ts index 9792dc8..bd60049 100644 --- a/utils/watchFolder.ts +++ b/utils/watchFolder.ts @@ -1,7 +1,7 @@ import path from 'path'; import chokidar from 'chokidar'; +import { exists } from '@a2r/fs'; -import { exists } from '../tools/fs'; import { WatcherOptions } from '../model/watcher'; /**