@powerlines/plugin-esbuild 0.5.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/package.json +10 -6
  2. package/dist/chunk-54IL5JZD.js +0 -3
  3. package/dist/chunk-54IL5JZD.js.map +0 -1
  4. package/dist/chunk-DKSPBMRI.cjs +0 -1472
  5. package/dist/chunk-DKSPBMRI.cjs.map +0 -1
  6. package/dist/chunk-DXDH2OBY.js +0 -3
  7. package/dist/chunk-DXDH2OBY.js.map +0 -1
  8. package/dist/chunk-EWDQEFTW.js +0 -3
  9. package/dist/chunk-EWDQEFTW.js.map +0 -1
  10. package/dist/chunk-FGTVQNHX.js +0 -1461
  11. package/dist/chunk-FGTVQNHX.js.map +0 -1
  12. package/dist/chunk-MTB74RUM.cjs +0 -4
  13. package/dist/chunk-MTB74RUM.cjs.map +0 -1
  14. package/dist/chunk-R6NPMTZP.cjs +0 -4
  15. package/dist/chunk-R6NPMTZP.cjs.map +0 -1
  16. package/dist/chunk-ZJGSECAJ.cjs +0 -4
  17. package/dist/chunk-ZJGSECAJ.cjs.map +0 -1
  18. package/dist/helpers/index.cjs +0 -13
  19. package/dist/helpers/index.cjs.map +0 -1
  20. package/dist/helpers/index.d.cts +0 -6
  21. package/dist/helpers/index.d.ts +0 -6
  22. package/dist/helpers/index.js +0 -4
  23. package/dist/helpers/index.js.map +0 -1
  24. package/dist/helpers/unplugin.cjs +0 -12
  25. package/dist/helpers/unplugin.cjs.map +0 -1
  26. package/dist/helpers/unplugin.d.cts +0 -9
  27. package/dist/helpers/unplugin.d.ts +0 -9
  28. package/dist/helpers/unplugin.js +0 -3
  29. package/dist/helpers/unplugin.js.map +0 -1
  30. package/dist/index.cjs +0 -107
  31. package/dist/index.cjs.map +0 -1
  32. package/dist/index.d.cts +0 -15
  33. package/dist/index.d.ts +0 -15
  34. package/dist/index.js +0 -95
  35. package/dist/index.js.map +0 -1
  36. package/dist/types/index.cjs +0 -7
  37. package/dist/types/index.cjs.map +0 -1
  38. package/dist/types/index.d.cts +0 -4
  39. package/dist/types/index.d.ts +0 -4
  40. package/dist/types/index.js +0 -4
  41. package/dist/types/index.js.map +0 -1
  42. package/dist/types/plugin.cjs +0 -6
  43. package/dist/types/plugin.cjs.map +0 -1
  44. package/dist/types/plugin.d.cts +0 -9
  45. package/dist/types/plugin.d.ts +0 -9
  46. package/dist/types/plugin.js +0 -3
  47. package/dist/types/plugin.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../powerlines/src/types/vfs.ts","../../powerlines/src/lib/entry.ts","../../powerlines/src/lib/logger.ts","../../powerlines/src/internal/helpers/vfs.ts","../../powerlines/src/internal/helpers/eslint.ts","../../powerlines/src/lib/utilities/source-file.ts","../../powerlines/src/lib/unplugin/resolve-id.ts","../../powerlines/src/lib/unplugin/plugin.ts","../src/helpers/unplugin.ts"],"names":["__VFS_INIT__","__VFS_REVERT__","__VFS_CACHE__","__VFS_RESOLVER__","__VFS_VIRTUAL__","__VFS_UNIFIED__","resolveEntryInputFile","context","typeDefinition","replacePath","file","joinPaths","workspaceConfig","workspaceRoot","config","projectRoot","resolveEntryOutput","sourceRoot","replace","findFileExtensionSafe","BADGE_COLORS","extendLog","logFn","name","type","args","chalk","inverse","hex","split","map","char","charCodeAt","reduce","ret","charCode","length","titleCase","join","VirtualFileSystem","Map","Volume","cloneFS","fs","Union","constructor","serialized","Object","entries","builtinIdMap","existsSync","dataPath","mkdirSync","recursive","cachePath","output","outputPath","use","mode","virtualFiles","keys","fromJSON","artifactsPath","builtinsPath","entryPath","dtsPath","projectType","log","patchFS","Error","runtimeIds","Array","from","id","formatRuntimeId","isBuiltinFile","pathOrId","options","values","find","path","resolvePath","isValidBuiltinId","startsWith","builtinPrefix","isVirtualFile","resolvedPath","isTsconfigPath","tsconfig","paths","some","replaceAll","isMatchingBuiltinId","resolvedId","resolveId","get","listBuiltinFiles","runtimeFiles","contents","readFile","push","readdirSync","resolveFS","toFilePath","unlinkSync","formattedPath","fileExistsSync","LogLevelLabel","TRACE","delete","clearResolverCache","unlink","isFunction","promises","rmdirSync","directoryExistsSync","defu","rmdir","rm","force","filePath","mkdir","result","readdir","undefined","has","toString","readFileSync","content","isBuffer","bufferToString","set","writeFile","data","absolutePath","formatAbsoluteFilePath","findFilePath","resolveOutputMode","prettyBytes","Blob","toArray","size","ifs","omit","writeFileSync","writeStream","createWriteStream","write","close","writeBuiltinFile","formattedId","skipFormat","format","resolveConfig","_options","isSetString","encoding","DEBUG","writeEntryFile","isAbsolutePath","writeFileToDisk","resolvedConfig","pathExistsSync","lstatSync","isFile","isDirectory","stat","statSync","lstat","resolveTsconfigPath","tsconfigPathKey","filter","tsconfigPath","resolvePathName","resolveTsconfigPathPackage","tsconfigPathKeys","realpathSync","resolverKey","withExtension","murmurhash","formatFilePath","RegExp","checkVariants","resolveParentPaths","request","current","flat","includes","Boolean","p","pathOrUrl","isParentPath","key","forEach","FILE_PREFIX","slice","FS_METHODS","FS_PROMISE_METHODS","originalFS","clonedFS","method","prop","bind","vfs","callback","defineProperty","value","parentPath","checkExtensions","checkIndex","MessageSeverity","getString","code","isString","isSetObject","NON_NODE_MODULE_REGEX","handleResolveId","importer","external","tsconfigPathPackage","noExternal","skipResolve","skipNodeModulesBundle","match","resolvePatterns","test","createUnplugin","ctx","buildStart","$$internal","callHook","sequential","opts","isEntry","order","build","load","transform","transformed","handler","environment","selectHooks","apply","buildEnd","writeBundle","include","buildFinish","vite","sharedDuringBuild","error","FATAL","message","createESBuildPlugin","createEsbuildPlugin"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCO,IAAMA,YAAAA,GAAe,cAAA;AAGrB,IAAMC,cAAAA,GAAiB,gBAAA;AAGvB,IAAMC,aAAAA,GAAgB,eAAA;AAGtB,IAAMC,gBAAAA,GAAmB,k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A,WAAAA,EAAAA,aAAAA,CAAAA;AAQf,MAAA,OAAO;QACL7N,IAAAA,EAAM,YAAA;QACNuE,SAAAA,EAAW;UACT6E,MAAAA,EAAQ;YACNlG,EAAAA,EAAI;cACF4K,OAAAA,EAAS;AAAC,gBAAA;;AACZ;AACF,WAAA;UACAN,OAAAA,EAASjJ;AACX,SAAA;QACA8I,IAAAA,EAAM;UACJjE,MAAAA,EAAQ;YACNlG,EAAAA,EAAI;cACF4K,OAAAA,EAAS;AAAC,gBAAA,IAAA;AAAM,gBAAA;;AAClB;AACF,WAAA;UACAN,OAAAA,EAASH;AACX,SAAA;AACAC,QAAAA,SAAAA;AACAT,QAAAA,UAAAA;QACAkB,WAAAA,EAAaH,QAAAA;AACbC,QAAAA,WAAAA;QACAG,IAAAA,EAAM;UACJC,iBAAAA,EAAmB;AACrB;AACF,OAAA;AACF,IAAA,CAAA,CAAA,OAASC,KAAAA,EAAO;AACdtL,MAAAA,GAAAA,CAAIwC,mBAAAA,CAAc+I,KAAAA,EAAQD,KAAAA,EAAiBE,OAAAA,CAAAA;AAE3C,MAAA,MAAMF,KAAAA;AACR,IAAA;AACF,EAAA,CAAA;AACF;AA/MgBvB,MAAAA,CAAAA,cAAAA,EAAAA,gBAAAA,CAAAA;AC9BT,SAAS0B,oBAAoBrP,OAAAA,EAA6B;AAC/D,EAAA,OAAOsP,4BAAAA,CACL3B,eAAe3N,OAAAA,EAAS;IACtBsN,WAAAA,EAAa;GACf,CAAA,CAAA,CACA,EAAC,CAAA;AACL;AANgB+B,MAAAA,CAAAA,mBAAAA,EAAAA,qBAAAA,CAAAA","file":"chunk-DKSPBMRI.cjs","sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type { Volume } from \"memfs\";\nimport type {\n MakeDirectoryOptions as FsMakeDirectoryOptions,\n WriteFileOptions as FsWriteFileOptions,\n Mode,\n PathLike,\n PathOrFileDescriptor,\n RmDirOptions,\n RmOptions,\n Stats,\n StatSyncOptions\n} from \"node:fs\";\nimport type { IUnionFs } from \"unionfs\";\n\nexport type VirtualFileExtension = \"js\" | \"ts\" | \"jsx\" | \"tsx\";\n\n// eslint-disable-next-line ts/naming-convention\nexport const __VFS_INIT__ = \"__VFS_INIT__\";\n\n// eslint-disable-next-line ts/naming-convention\nexport const __VFS_REVERT__ = \"__VFS_REVERT__\";\n\n// eslint-disable-next-line ts/naming-convention\nexport const __VFS_CACHE__ = \"__VFS_CACHE__\";\n\n// eslint-disable-next-line ts/naming-convention\nexport const __VFS_RESOLVER__ = \"__VFS_RESOLVER__\";\n\n// eslint-disable-next-line ts/naming-convention\nexport const __VFS_VIRTUAL__ = \"__VFS_VIRTUAL__\";\n\n// eslint-disable-next-line ts/naming-convention\nexport const __VFS_UNIFIED__ = \"__VFS_UNIFIED__\";\n\nexport interface VirtualFile {\n /**\n * A virtual path to the file in the virtual file system.\n */\n path: string;\n\n /**\n * The contents of the virtual file.\n */\n contents: string;\n}\n\nexport interface VirtualBuiltinFile extends VirtualFile {\n /**\n * The unique identifier for the virtual file.\n *\n * @remarks\n * This property is read-only and is set when the file is created.\n */\n id: string;\n}\n\nexport type OutputModeType = \"fs\" | \"virtual\";\n\nexport interface ResolveFSOptions {\n mode?: OutputModeType;\n}\n\nexport type MakeDirectoryOptions = (Mode | FsMakeDirectoryOptions) &\n ResolveFSOptions;\n\nexport interface ResolvePathOptions extends ResolveFSOptions {\n /**\n * Should the resolved path include the file extension?\n *\n * @defaultValue true\n */\n withExtension?: boolean;\n\n /**\n * The paths to search for the file.\n */\n paths?: string[];\n\n /**\n * The type of the path to resolve.\n */\n type?: \"file\" | \"directory\";\n}\n\nexport type WriteFileOptions = FsWriteFileOptions & ResolveFSOptions;\n\nexport interface WriteBuiltinFileOptions extends ResolveFSOptions {\n skipFormat?: boolean;\n}\n\nexport interface VirtualFileSystemInterface {\n [__VFS_INIT__]: () => void;\n [__VFS_REVERT__]: () => void;\n\n /**\n * The underlying builtin module Ids.\n */\n builtinIdMap: Map<string, string>;\n\n /**\n * Checks if a path or ID corresponds to a builtin file.\n *\n * @param id - The id of the builtin file to check against.\n * @param pathOrId - The path or id of the file to check.\n * @returns Whether the path or ID corresponds to a builtin file.\n */\n isMatchingBuiltinId: (id: string, pathOrId: string) => boolean;\n\n /**\n * Checks if a provided string is a valid builtin ID (does not need to already be created in the file system).\n *\n * @param id - The ID to check.\n * @returns Whether the ID is a valid builtin ID.\n */\n isValidBuiltinId: (id: string) => boolean;\n\n /**\n * Check if a path or ID corresponds to a virtual file.\n *\n * @param pathOrId - The path or ID to check.\n * @param options - Optional parameters for resolving the path.\n * @returns Whether the path or ID corresponds to a virtual file.\n */\n isVirtualFile: (pathOrId: string, options?: ResolvePathOptions) => boolean;\n\n /**\n * Check if a path exists within one of the directories specified in the tsconfig.json's `path` field.\n *\n * @see https://www.typescriptlang.org/tsconfig#paths\n *\n * @param pathOrId - The path or ID to check.\n * @returns Whether the path or ID corresponds to a virtual file.\n */\n isTsconfigPath: (pathOrId: string) => boolean;\n\n /**\n * Checks if a given path or ID corresponds to a builtin module file.\n */\n isBuiltinFile: (pathOrID: string, options?: ResolvePathOptions) => boolean;\n\n /**\n * Returns a list of builtin module files in the virtual file system.\n */\n listBuiltinFiles: () => Promise<VirtualBuiltinFile[]>;\n\n /**\n * Checks if a file exists in the virtual file system (VFS).\n */\n existsSync: (pathOrId: string) => boolean;\n\n /**\n * Checks if a file exists in the virtual file system (VFS).\n *\n * @param path - The path of the file to check.\n * @returns `true` if the file exists, otherwise `false`.\n */\n fileExistsSync: (path: string) => boolean;\n\n /**\n * Checks if a directory exists in the virtual file system (VFS).\n *\n * @param path - The path of the directory to check.\n * @returns `true` if the directory exists, otherwise `false`.\n */\n directoryExistsSync: (path: string) => boolean;\n\n /**\n * Checks if a path exists in the virtual file system (VFS).\n *\n * @param path - The path to check.\n * @returns `true` if the path exists, otherwise `false`.\n */\n pathExistsSync: (path: string) => boolean;\n\n /**\n * Gets the stats of a file in the virtual file system (VFS).\n *\n * @param pathOrId - The path or id of the file.\n * @param options - Optional parameters for getting the stats.\n * @returns The stats of the file if it exists, otherwise undefined.\n */\n lstat: (\n pathOrId: string,\n options?: StatSyncOptions & {\n bigint?: false | undefined;\n throwIfNoEntry: false;\n }\n ) => Promise<Stats>;\n\n /**\n * Gets the stats of a file in the virtual file system (VFS).\n *\n * @param pathOrId - The path or id of the file.\n * @param options - Optional parameters for getting the stats.\n * @returns The stats of the file if it exists, otherwise undefined.\n */\n lstatSync: (\n pathOrId: string,\n options?: StatSyncOptions & {\n bigint?: false | undefined;\n throwIfNoEntry: false;\n }\n ) => Stats | undefined;\n\n /**\n * Gets the stats of a file in the virtual file system (VFS).\n *\n * @param pathOrId - The path or id of the file.\n * @returns The stats of the file if it exists, otherwise false.\n */\n stat: (\n pathOrId: string,\n options?: StatSyncOptions & {\n bigint?: false | undefined;\n throwIfNoEntry: false;\n }\n ) => Promise<Stats>;\n\n /**\n * Gets the stats of a file in the virtual file system (VFS).\n *\n * @param pathOrId - The path or id of the file.\n * @returns The stats of the file if it exists, otherwise false.\n */\n statSync: (\n pathOrId: string,\n options?: StatSyncOptions & {\n bigint?: false | undefined;\n throwIfNoEntry: false;\n }\n ) => Stats | undefined;\n\n /**\n * Lists files in a given path.\n *\n * @param path - The path to list files from.\n * @param options - Options for listing files, such as encoding and recursion.\n * @returns An array of file names in the specified path.\n */\n readdirSync: (\n path: string,\n options?:\n | {\n encoding: BufferEncoding | null;\n withFileTypes?: false | undefined;\n recursive?: boolean | undefined;\n }\n | BufferEncoding\n ) => string[];\n\n /**\n * Lists files in a given path.\n *\n * @param path - The path to list files from.\n * @param options - Options for listing files, such as encoding and recursion.\n * @returns An array of file names in the specified path.\n */\n readdir: (\n path: string,\n options?:\n | {\n encoding: BufferEncoding | null;\n withFileTypes?: false | undefined;\n recursive?: boolean | undefined;\n }\n | BufferEncoding\n ) => Promise<string[]>;\n\n /**\n * Removes a file or symbolic link in the virtual file system (VFS).\n *\n * @param path - The path to the file to remove.\n * @returns A promise that resolves when the file is removed.\n */\n unlinkSync: (path: PathLike, options?: ResolveFSOptions) => void;\n\n /**\n * Asynchronously removes a file or symbolic link in the virtual file system (VFS).\n *\n * @param path - The path to the file to remove.\n * @returns A promise that resolves when the file is removed.\n */\n unlink: (path: string, options?: ResolveFSOptions) => Promise<void>;\n\n /**\n * Removes a directory in the virtual file system (VFS).\n *\n * @param path - The path to create the directory at.\n * @param options - Options for creating the directory.\n */\n rmdirSync: (path: PathLike, options?: RmDirOptions & ResolveFSOptions) => any;\n\n /**\n * Removes a directory in the virtual file system (VFS).\n *\n * @param path - The path to create the directory at.\n * @param options - Options for creating the directory.\n * @returns A promise that resolves to the path of the created directory, or undefined if the directory could not be created.\n */\n rmdir: (\n path: PathLike,\n options?: RmDirOptions & ResolveFSOptions\n ) => Promise<void>;\n\n /**\n * Removes a file in the virtual file system (VFS).\n *\n * @param path - The path to the file to remove.\n * @param options - Options for removing the file.\n * @returns A promise that resolves when the file is removed.\n */\n rm: (path: PathLike, options?: RmOptions & ResolveFSOptions) => Promise<void>;\n\n /**\n * Creates a directory in the virtual file system (VFS).\n *\n * @param path - The path to create the directory at.\n * @param options - Options for creating the directory.\n * @returns A promise that resolves to the path of the created directory, or undefined if the directory could not be created.\n */\n mkdirSync: (\n path: PathLike,\n options?: MakeDirectoryOptions\n ) => string | undefined;\n\n /**\n * Creates a directory in the virtual file system (VFS).\n *\n * @param path - The path to create the directory at.\n * @param options - Options for creating the directory.\n * @returns A promise that resolves to the path of the created directory, or undefined if the directory could not be created.\n */\n mkdir: (\n path: PathLike,\n options?: MakeDirectoryOptions\n ) => Promise<string | undefined>;\n\n /**\n * Reads a file from the virtual file system (VFS).\n *\n * @param pathOrId - The path or id of the file.\n * @returns The contents of the file if it exists, otherwise undefined.\n */\n readFile: (pathOrId: string) => Promise<string | undefined>;\n\n /**\n * Reads a file from the virtual file system (VFS).\n *\n * @param pathOrId - The path or id of the file.\n */\n readFileSync: (pathOrId: string) => string | undefined;\n\n /**\n * Writes a file to the virtual file system (VFS).\n *\n * @param file - The path to the file.\n * @param data - The contents of the file.\n * @param options - Optional parameters for writing the file.\n * @returns A promise that resolves when the file is written.\n */\n writeFile: (\n file: PathOrFileDescriptor,\n data: string | NodeJS.ArrayBufferView,\n options?: WriteFileOptions\n ) => Promise<void>;\n\n /**\n * Writes a file to the virtual file system (VFS).\n *\n * @param file - The path to the file.\n * @param data - The contents of the file.\n * @param options - Optional parameters for writing the file.\n */\n writeFileSync: (\n file: PathOrFileDescriptor,\n data: string | NodeJS.ArrayBufferView,\n options?: WriteFileOptions\n ) => void;\n\n /**\n * Adds a builtin module file to the virtual file system.\n *\n * @param id - The unique identifier for the builtin module file.\n * @param path - The path to the builtin module file.\n * @param contents - The contents of the builtin module file.\n * @param options - Optional parameters for writing the builtin module file.\n */\n writeBuiltinFile: (\n id: string,\n path: string,\n contents: string,\n options?: WriteBuiltinFileOptions\n ) => Promise<void>;\n\n /**\n * Adds an entry file to the virtual file system.\n *\n * @param name - The unique identifier for the entry file.\n * @param contents - The contents of the entry file.\n * @param options - Optional parameters for writing the entry file.\n */\n writeEntryFile: (\n name: string,\n contents: string,\n options?: WriteBuiltinFileOptions\n ) => Promise<void>;\n\n /**\n * Writes a file to disk from the physical file system (on disk).\n *\n * @param path - The path to the file to write.\n * @param contents - The contents of the file to write.\n * @param options - Optional parameters for writing the file.\n * @returns A promise that resolves when the file is written.\n */\n writeFileToDisk: (\n path: string,\n contents: string,\n options?: { skipFormat?: boolean }\n ) => Promise<void>;\n\n /**\n * Resolves a path or ID to a file path in the virtual file system.\n *\n * @param pathOrId - The path or id of the file to resolve.\n * @param options - Optional parameters for resolving the path.\n * @returns The resolved path of the file if it exists, otherwise false.\n */\n resolvePath: (\n pathOrId: string,\n options?: ResolvePathOptions\n ) => string | false;\n\n /**\n * Resolves a path or ID to a file path in the virtual file system.\n *\n * @param pathOrId - The path or id of the file to resolve.\n * @returns The resolved path of the file if it exists, otherwise false.\n */\n realpathSync: (pathOrId: string) => string;\n\n /**\n * Resolves a path or ID to a builtin module file id in the virtual file system.\n *\n * @param pathOrId - The path or id of the file to resolve.\n * @param paths - Optional array of paths to search for the file.\n * @returns The resolved id of the builtin module file if it exists, otherwise false.\n */\n resolveId: (pathOrId: string) => string | false;\n\n /**\n * Resolves a path based on TypeScript's `tsconfig.json` paths.\n *\n * @see https://www.typescriptlang.org/tsconfig#paths\n *\n * @param path - The path to check.\n * @returns The resolved file path if it exists, otherwise undefined.\n */\n resolveTsconfigPath: (path: string) => string | false;\n\n /**\n * Resolves a package name based on TypeScript's `tsconfig.json` paths.\n *\n * @see https://www.typescriptlang.org/tsconfig#paths\n *\n * @param path - The path to check.\n * @returns The resolved package name if it exists, otherwise undefined.\n */\n resolveTsconfigPathPackage: (path: string) => string | false;\n\n /**\n * A map of cached file paths to their underlying file content.\n */\n [__VFS_CACHE__]: Map<string, string>;\n\n /**\n * A reference to the underlying virtual file system.\n */\n [__VFS_VIRTUAL__]: Volume;\n\n /**\n * A reference to the underlying unified file system.\n */\n [__VFS_UNIFIED__]: IUnionFs;\n}\n","/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { parseTypeDefinition } from \"@stryke/convert/parse-type-definition\";\nimport { toArray } from \"@stryke/convert/to-array\";\nimport { listFiles, listFilesSync } from \"@stryke/fs/list-files\";\nimport { murmurhash } from \"@stryke/hash/murmurhash\";\nimport { getUniqueBy } from \"@stryke/helpers/get-unique\";\nimport { appendPath } from \"@stryke/path/append\";\nimport { findFileExtensionSafe } from \"@stryke/path/file-path-fns\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport { replacePath } from \"@stryke/path/replace\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport type {\n TypeDefinition,\n TypeDefinitionParameter\n} from \"@stryke/types/configuration\";\nimport type { Context } from \"../types/context\";\nimport { ResolvedEntryTypeDefinition } from \"../types/resolved\";\n\nexport function resolveEntryInputFile(\n context: Context,\n typeDefinition: TypeDefinition\n): string {\n return replacePath(\n typeDefinition.file,\n joinPaths(context.workspaceConfig.workspaceRoot, context.config.projectRoot)\n );\n}\n\nexport function resolveEntryInput(\n context: Context,\n typeDefinition: TypeDefinition\n): TypeDefinition {\n return {\n file: resolveEntryInputFile(context, typeDefinition),\n name: typeDefinition.name\n };\n}\n\nexport function resolveEntryOutput(\n context: Context,\n typeDefinition: TypeDefinition\n): string {\n return joinPaths(\n replacePath(\n replacePath(\n replacePath(\n replacePath(\n typeDefinition.file,\n joinPaths(\n context.workspaceConfig.workspaceRoot,\n context.config.sourceRoot\n )\n ),\n joinPaths(\n context.workspaceConfig.workspaceRoot,\n context.config.projectRoot\n )\n ),\n context.config.sourceRoot\n ),\n context.config.projectRoot\n )\n ).replace(`.${findFileExtensionSafe(typeDefinition.file)}`, \"\");\n}\n\nexport function resolveEntry(\n context: Context,\n typeDefinition: TypeDefinition\n): ResolvedEntryTypeDefinition {\n const input = resolveEntryInput(context, typeDefinition);\n\n return {\n ...input,\n input,\n output: resolveEntryOutput(context, typeDefinition)\n };\n}\n\n/**\n * Resolves multiple type definitions into their corresponding resolved entry type definitions.\n *\n * @param context - The current context\n * @param typeDefinitions - The type definitions to resolve.\n * @returns A promise that resolves to an array of resolved entry type definitions.\n */\nexport async function resolveEntries(\n context: Context,\n typeDefinitions: TypeDefinitionParameter[]\n): Promise<ResolvedEntryTypeDefinition[]> {\n return (\n await Promise.all(\n typeDefinitions.map(async typeDefinition => {\n const parsed = parseTypeDefinition(typeDefinition)!;\n\n return (\n await listFiles(appendPath(parsed.file, context.config.projectRoot))\n ).map(file =>\n resolveEntry(context, {\n file,\n name: parsed.name\n })\n );\n })\n )\n )\n .flat()\n .filter(Boolean);\n}\n\n/**\n * Resolves multiple type definitions into their corresponding resolved entry type definitions.\n *\n * @param context - The current context\n * @param typeDefinitions - The type definitions to resolve.\n * @returns A promise that resolves to an array of resolved entry type definitions.\n */\nexport function resolveEntriesSync(\n context: Context,\n typeDefinitions: TypeDefinitionParameter[]\n): ResolvedEntryTypeDefinition[] {\n return typeDefinitions\n .map(typeDefinition => {\n const parsed = parseTypeDefinition(typeDefinition)!;\n\n return listFilesSync(\n appendPath(parsed.file, context.config.projectRoot)\n ).map(file =>\n resolveEntry(context, {\n file,\n name: parsed.name\n })\n );\n })\n .flat()\n .filter(Boolean);\n}\n\n/** Resolve a virtual entry point by generating a unique file path in the artifacts directory.\n *\n * @param context - The current context\n * @param typeDefinition - The type definition to resolve.\n * @returns The resolved entry type definition with a unique virtual file path.\n */\nexport function resolveVirtualEntry(\n context: Context,\n typeDefinition: TypeDefinitionParameter\n): ResolvedEntryTypeDefinition {\n const parsed = parseTypeDefinition(typeDefinition)!;\n const resolved = resolveEntry(context, parsed);\n const file = joinPaths(\n context.artifactsPath,\n `entry-${murmurhash(\n { file: resolved.file, name: resolved.name },\n { maxLength: 24 }\n )\n .replaceAll(\"-\", \"0\")\n .replaceAll(\"_\", \"1\")}.ts`\n );\n\n return {\n file,\n name: resolved.name,\n input: {\n file,\n name: resolved.name\n },\n output: file\n };\n}\n\n/**\n * Get unique entries from the provided list.\n *\n * @param entries - The entries to process.\n * @returns An array of unique entries (by file path or content hash).\n */\nexport function getUniqueEntries(\n entries: TypeDefinitionParameter | TypeDefinitionParameter[] = []\n): TypeDefinitionParameter[] {\n return getUniqueBy(toArray(entries), (item: TypeDefinitionParameter) =>\n isSetString(item) ? item : murmurhash(item ?? {}, { maxLength: 24 })\n );\n}\n","/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { getLogFn, getLogLevel } from \"@storm-software/config-tools/logger\";\nimport { LogLevelLabel } from \"@storm-software/config-tools/types\";\nimport { getColor } from \"@storm-software/config-tools/utilities/colors\";\nimport { noop } from \"@stryke/helpers/noop\";\nimport { titleCase } from \"@stryke/string-format/title-case\";\nimport chalk from \"chalk\";\nimport type { LogFn, WorkspaceConfig } from \"../types\";\n\nexport interface CreateLogOptions {\n name?: string;\n logLevel?: LogLevelLabel | null;\n customLogger?: LogFn;\n colors?: WorkspaceConfig[\"colors\"];\n}\n\n/**\n * Create a logging function with a specific name and options.\n *\n * @param name - The name of the logging function.\n * @param options - The options to configure the logging function.\n * @returns A logging function.\n */\nexport const createLog = (\n name: string | null,\n options: CreateLogOptions = {}\n): LogFn => {\n const logLevel =\n options.logLevel === null\n ? LogLevelLabel.SILENT\n : options.logLevel || LogLevelLabel.INFO;\n if (logLevel === LogLevelLabel.SILENT) {\n return noop;\n }\n\n if (options.customLogger) {\n return options.customLogger;\n }\n\n return (type: LogLevelLabel, ...args: string[]) =>\n getLogFn(getLogLevel(type), {\n ...options,\n logLevel\n })(\n `${chalk.bold.hex(\n getColor(\"brand\", options as Parameters<typeof getColor>[1])\n )(\n `powerlines${name ? `:${name}` : \"\"}${\n options.name ? ` ${chalk.gray(\"> \")}${options.name}` : \"\"\n } ${chalk.gray(\"> \")}`\n )}${args.join(\" \")} `.trim()\n );\n};\n\nconst BADGE_COLORS = [\n \"#00A0DD\",\n \"#6FCE4E\",\n \"#FBBF24\",\n \"#F43F5E\",\n \"#3B82F6\",\n \"#A855F7\",\n \"#469592\",\n \"#288EDF\",\n \"#10B981\",\n \"#EF4444\",\n \"#F0EC56\",\n \"#F472B6\",\n \"#22D3EE\",\n \"#EAB308\",\n \"#84CC16\",\n \"#F87171\",\n \"#0EA5E9\",\n \"#D946EF\",\n \"#FACC15\",\n \"#34D399\"\n] as const;\n\nexport const extendLog = (logFn: LogFn, name: string): LogFn => {\n return (type: LogLevelLabel, ...args: string[]) =>\n logFn(\n type,\n ` ${chalk.inverse.hex(\n BADGE_COLORS[\n name\n .split(\"\")\n .map(char => char.charCodeAt(0))\n .reduce((ret, charCode) => ret + charCode, 0) % BADGE_COLORS.length\n ] || BADGE_COLORS[0]\n )(` ${titleCase(name)} `)} ${args.join(\" \")} `\n );\n};\n","/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\n/* eslint-disable ts/no-unsafe-call */\n\nimport { LogLevelLabel } from \"@storm-software/config-tools/types\";\nimport { bufferToString } from \"@stryke/convert/buffer-to-string\";\nimport { toArray } from \"@stryke/convert/to-array\";\nimport { murmurhash } from \"@stryke/hash/murmurhash\";\nimport { omit } from \"@stryke/helpers/omit\";\nimport { findFilePath } from \"@stryke/path/file-path-fns\";\nimport { isParentPath } from \"@stryke/path/is-parent-path\";\nimport { isAbsolutePath } from \"@stryke/path/is-type\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport { prettyBytes } from \"@stryke/string-format/pretty-bytes\";\nimport { isBuffer } from \"@stryke/type-checks/is-buffer\";\nimport { isFunction } from \"@stryke/type-checks/is-function\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport defu from \"defu\";\nimport { Volume } from \"memfs\";\nimport { Blob } from \"node:buffer\";\nimport fs, {\n ObjectEncodingOptions,\n PathLike,\n PathOrFileDescriptor,\n Stats,\n StatSyncOptions\n} from \"node:fs\";\nimport { format, resolveConfig } from \"prettier\";\nimport { IFS, IUnionFs, Union } from \"unionfs\";\nimport { extendLog } from \"../../lib/logger\";\nimport { LogFn } from \"../../types/config\";\nimport { Context, SerializedVirtualFileSystem } from \"../../types/context\";\nimport {\n __VFS_CACHE__,\n __VFS_INIT__,\n __VFS_RESOLVER__,\n __VFS_REVERT__,\n __VFS_UNIFIED__,\n __VFS_VIRTUAL__,\n MakeDirectoryOptions,\n OutputModeType,\n ResolveFSOptions,\n ResolvePathOptions,\n VirtualBuiltinFile,\n VirtualFileSystemInterface,\n WriteBuiltinFileOptions,\n WriteFileOptions\n} from \"../../types/vfs\";\n\n/**\n * Remove byte order marker. This catches EF BB BF (the UTF-8 BOM)\n * because the buffer-to-string conversion in `fs.readFileSync()`\n * translates it to FEFF, the UTF-16 BOM.\n */\n// function stripBOM(content: string) {\n// if (content.charCodeAt(0) === 0xfeff) {\n// content = content.slice(1);\n// }\n// return content;\n// }\n\n// type ModuleBuiltIn = typeof _Module & {\n// _extensions: Record<\n// string,\n// (\n// module: {\n// _compile: (content: string, fileName: string) => void;\n// exports: any;\n// },\n// fileName: string\n// ) => void\n// >;\n// _findPath: (\n// request: string,\n// paths: string[],\n// isMain: boolean\n// ) => false | string;\n// _resolveFilename: (request: string, parent: string) => string;\n// _pathCache: Record<string, string>;\n// };\n\n// const Module: ModuleBuiltIn = _Module as ModuleBuiltIn;\n\n/**\n * Represents a virtual file system (VFS) that stores files and their associated metadata in virtual memory.\n *\n * @remarks\n * This class provides methods to manage virtual files, check their existence, retrieve their content, and manipulate the virtual file system. It allows for efficient file management and retrieval without relying on the actual file system.\n */\nexport class VirtualFileSystem implements VirtualFileSystemInterface {\n /**\n * The internal map of virtual files.\n */\n #builtinIdMap: Map<string, string> = new Map<string, string>();\n\n /**\n * A map of virtual file paths to their underlying file content.\n */\n #cachedFS: Map<string, string> = new Map<string, string>();\n\n /**\n * A map of virtual file paths to their underlying file content.\n */\n #cachedResolver: Map<string, string | false> = new Map<\n string,\n string | false\n >();\n\n /**\n * The internal map of virtual files.\n */\n #virtualFS: Volume = new Volume();\n\n /**\n * The physical file system.\n */\n #fs: typeof fs = cloneFS(fs);\n\n /**\n * The unified volume that combines the virtual file system with the real file system.\n *\n * @remarks\n * This volume allows for seamless access to both virtual and real files.\n */\n #unifiedFS = new Union();\n\n /**\n * Indicator specifying if the file system module is patched\n */\n #isPatched = false;\n\n /**\n * Function to revert require patch\n */\n #revert: (() => void) | undefined;\n\n /**\n * The context of the virtual file system.\n */\n #context: Context;\n\n /**\n * The file system's logging function.\n */\n #log: LogFn;\n\n /**\n * Exposes the internal VFS map for advanced usage.\n */\n public get [__VFS_CACHE__](): Map<string, string> {\n return this.#cachedFS;\n }\n\n /**\n * Exposes the internal VFS resolver cache for advanced usage.\n */\n public get [__VFS_RESOLVER__](): Map<string, string | false> {\n return this.#cachedResolver;\n }\n\n /**\n * Exposes the internal VFS map for advanced usage.\n */\n public get [__VFS_VIRTUAL__](): Volume {\n return this.#virtualFS;\n }\n\n /**\n * Exposes the internal UFS map for advanced usage.\n */\n public get [__VFS_UNIFIED__](): IUnionFs {\n return this.#unifiedFS;\n }\n\n /**\n * Creates a new instance of the VirtualFileSystem.\n *\n * @param context - The context of the virtual file system, typically containing options and logging functions.\n * @param serialized - A map of files/file contents to populate in cache\n */\n constructor(context: Context, serialized?: SerializedVirtualFileSystem) {\n this.#context = context;\n this.#cachedFS = new Map();\n this.#builtinIdMap = new Map(\n Object.entries(serialized?.builtinIdMap ?? {})\n );\n\n if (!this.#fs.existsSync(this.#context.dataPath)) {\n this.#fs.mkdirSync(this.#context.dataPath, {\n recursive: true\n });\n }\n\n if (!this.#fs.existsSync(this.#context.cachePath)) {\n this.#fs.mkdirSync(this.#context.cachePath, {\n recursive: true\n });\n }\n\n if (\n !this.#fs.existsSync(\n joinPaths(\n this.#context.workspaceConfig.workspaceRoot,\n this.#context.config.output.outputPath\n )\n )\n ) {\n this.#fs.mkdirSync(\n joinPaths(\n this.#context.workspaceConfig.workspaceRoot,\n this.#context.config.output.outputPath\n ),\n {\n recursive: true\n }\n );\n }\n\n this.#unifiedFS = this.#unifiedFS.use(this.#fs);\n\n if (this.#context.config.output.mode !== \"fs\") {\n if (\n serialized?.virtualFiles &&\n Object.keys(serialized.virtualFiles).length > 0\n ) {\n this.#virtualFS = Volume.fromJSON(serialized.virtualFiles);\n }\n\n if (!this.#virtualFS.existsSync(this.#context.artifactsPath)) {\n this.#virtualFS.mkdirSync(this.#context.artifactsPath, {\n recursive: true\n });\n }\n\n if (!this.#virtualFS.existsSync(this.#context.builtinsPath)) {\n this.#virtualFS.mkdirSync(this.#context.builtinsPath, {\n recursive: true\n });\n }\n\n if (!this.#virtualFS.existsSync(this.#context.entryPath)) {\n this.#virtualFS.mkdirSync(this.#context.entryPath, {\n recursive: true\n });\n }\n\n if (!this.#virtualFS.existsSync(this.#context.dtsPath)) {\n this.#virtualFS.mkdirSync(this.#context.dtsPath, {\n recursive: true\n });\n }\n\n this.#unifiedFS = this.#unifiedFS.use(this.#virtualFS as any);\n } else if (this.#context.config.projectType === \"application\") {\n if (!this.#fs.existsSync(this.#context.artifactsPath)) {\n this.#fs.mkdirSync(this.#context.artifactsPath, {\n recursive: true\n });\n }\n\n if (!this.#fs.existsSync(this.#context.builtinsPath)) {\n this.#fs.mkdirSync(this.#context.builtinsPath, {\n recursive: true\n });\n }\n\n if (!this.#fs.existsSync(this.#context.entryPath)) {\n this.#fs.mkdirSync(this.#context.entryPath, {\n recursive: true\n });\n }\n\n if (!this.#fs.existsSync(this.#context.dtsPath)) {\n this.#fs.mkdirSync(this.#context.dtsPath, {\n recursive: true\n });\n }\n }\n\n this.#log = extendLog(this.#context.log, \"virtual-file-system\");\n }\n\n public [__VFS_INIT__]() {\n if (!this.#isPatched && this.#context.config.output.mode !== \"fs\") {\n this.#revert = patchFS(fs, this);\n this.#isPatched = true;\n }\n }\n\n public [__VFS_REVERT__]() {\n if (this.#isPatched && this.#context.config.output.mode !== \"fs\") {\n if (!this.#revert) {\n throw new Error(\n \"Attempting to revert File System patch prior to calling `__init__` function\"\n );\n }\n\n this.#revert?.();\n this.#isPatched = false;\n }\n }\n\n /**\n * Returns a Map of all runtime file IDs and their corresponding paths in the virtual file system.\n *\n * @returns A Map where the keys are runtime file IDs (strings) and the values are their corresponding paths (strings).\n */\n public get builtinIdMap(): Map<string, string> {\n return this.#builtinIdMap;\n }\n\n /**\n * Lists all runtime IDs in the virtual file system.\n *\n * @returns An array of formatted runtime IDs.\n */\n public get runtimeIds(): string[] {\n return Array.from(this.builtinIdMap.keys()).map(id =>\n this.formatRuntimeId(id)\n );\n }\n\n /**\n * Checks if a given path or ID corresponds to a runtime file.\n *\n * @param pathOrId - The path or ID to check.\n * @param options - Options for resolving the path, such as paths to check.\n * @returns `true` if the path or ID corresponds to a runtime file, otherwise `false`.\n */\n public isBuiltinFile(\n pathOrId: string,\n options?: ResolvePathOptions\n ): boolean {\n return !!this.builtinIdMap\n .values()\n .find(\n path =>\n path === this.resolvePath(pathOrId, { ...options, type: \"file\" })\n );\n }\n\n /**\n * Checks if a provided string is a valid runtime ID (does not need to already be created in the file system).\n *\n * @param id - The ID to check.\n * @returns Whether the ID is a valid runtime ID.\n */\n public isValidBuiltinId(id: string): boolean {\n return id.startsWith(`${this.#context.config.output.builtinPrefix}:`);\n }\n\n /**\n * Check if a path or ID corresponds to a virtual file.\n *\n * @param pathOrId - The path or ID to check.\n * @param options - Options for resolving the path, such as paths to check.\n * @returns Whether the path or ID corresponds to a virtual file.\n */\n public isVirtualFile(\n pathOrId: string,\n options: ResolvePathOptions = {}\n ): boolean {\n if (!pathOrId) {\n return false;\n }\n\n const resolvedPath = this.resolvePath(pathOrId, {\n ...options,\n type: \"file\"\n });\n if (!resolvedPath) {\n return false;\n }\n\n // Check if the resolved path is a runtime file\n if (this.builtinIdMap.values().find(path => path === resolvedPath)) {\n return true;\n }\n\n return this.#virtualFS.existsSync(resolvedPath);\n }\n\n /**\n * Check if a path exists within one of the directories specified in the tsconfig.json's `path` field.\n *\n * @see https://www.typescriptlang.org/tsconfig#paths\n *\n * @param pathOrId - The path or ID to check.\n * @returns Whether the path or ID corresponds to a virtual file.\n */\n public isTsconfigPath(pathOrId: string): boolean {\n return (\n !!this.#context.tsconfig.options.paths &&\n Object.keys(this.#context.tsconfig.options.paths).some(path =>\n pathOrId.startsWith(path.replaceAll(\"*\", \"\"))\n )\n );\n }\n\n /**\n * Checks if a given ID corresponds to a runtime file path.\n *\n * @param id - The unique identifier for the runtime file.\n * @param pathOrId - The path or ID to check.\n * @returns `true` if the ID corresponds to the path or ID of a runtime file, otherwise `false`.\n */\n public isMatchingBuiltinId(id: string, pathOrId: string): boolean {\n const resolvedPath = this.resolvePath(pathOrId);\n const resolvedId = this.resolveId(pathOrId);\n\n return !!(\n this.isBuiltinFile(pathOrId) &&\n ((resolvedPath &&\n (resolvedPath === this.builtinIdMap.get(id) ||\n resolvedPath === this.builtinIdMap.get(this.formatRuntimeId(id)))) ||\n (resolvedId &&\n (resolvedId === this.builtinIdMap.get(id) ||\n resolvedId === this.builtinIdMap.get(this.formatRuntimeId(id)))))\n );\n }\n\n /**\n * Lists all runtime files in the virtual file system.\n *\n * @returns A promise that resolves to an array of runtime files.\n */\n public async listBuiltinFiles(): Promise<VirtualBuiltinFile[]> {\n const runtimeFiles: VirtualBuiltinFile[] = [];\n for (const [id, path] of this.builtinIdMap.entries()) {\n const contents = await this.readFile(path);\n if (contents) {\n runtimeFiles.push({\n id: this.formatRuntimeId(id),\n path,\n contents\n });\n }\n }\n\n return runtimeFiles;\n }\n\n /**\n * Lists files in a given path.\n *\n * @param path - The path to list files from.\n * @param options - Options for listing files, such as encoding and recursion.\n * @returns An array of file names in the specified path.\n */\n public readdirSync(\n path: fs.PathLike,\n options:\n | {\n encoding: BufferEncoding | null;\n withFileTypes?: false | undefined;\n recursive?: boolean | undefined;\n }\n | BufferEncoding = \"utf8\"\n ): string[] {\n return this.resolveFS(path).readdirSync(toFilePath(path), options);\n }\n\n /**\n * Removes a file in the virtual file system (VFS).\n *\n * @param path - The path to create the directory at.\n */\n public unlinkSync(path: fs.PathLike, options?: ResolveFSOptions) {\n const formattedPath = toFilePath(path);\n if (!this.fileExistsSync(path)) {\n return;\n }\n\n this.#log(\n LogLevelLabel.TRACE,\n `Synchronously removing file: ${formattedPath}`\n );\n\n this.resolveFS(path, options).unlinkSync(formattedPath);\n\n this.#cachedFS.delete(formattedPath);\n this.clearResolverCache(formattedPath);\n }\n\n /**\n * Removes a file in the virtual file system (VFS).\n *\n * @param path - The path to create the directory at.\n */\n public async unlink(\n path: fs.PathLike,\n options?: ResolveFSOptions\n ): Promise<void> {\n const formattedPath = toFilePath(path);\n if (!this.fileExistsSync(path)) {\n return;\n }\n\n this.#log(LogLevelLabel.TRACE, `Removing file: ${formattedPath}`);\n\n if (isFunction(this.resolveFS(path, options).promises.unlink)) {\n await this.resolveFS(path, options).promises.unlink(formattedPath);\n\n this.#cachedFS.delete(formattedPath);\n this.clearResolverCache(formattedPath);\n } else {\n this.unlinkSync(formattedPath, options);\n }\n }\n\n /**\n * Removes a directory in the virtual file system (VFS).\n *\n * @param path - The path to create the directory at.\n * @param options - Options for creating the directory.\n */\n public rmdirSync(\n path: fs.PathLike,\n options: fs.RmDirOptions & ResolveFSOptions = {}\n ) {\n const formattedPath = toFilePath(path);\n if (!this.directoryExistsSync(path)) {\n return;\n }\n\n this.#log(\n LogLevelLabel.TRACE,\n `Synchronously removing directory: ${formattedPath}`\n );\n\n this.resolveFS(path, options).rmdirSync(\n formattedPath,\n defu(options, {\n recursive: true\n })\n );\n\n this.#cachedFS.delete(formattedPath);\n this.clearResolverCache(formattedPath);\n }\n\n /**\n * Removes a directory in the virtual file system (VFS).\n *\n * @param path - The path to create the directory at.\n * @param options - Options for creating the directory.\n * @returns A promise that resolves to the path of the created directory, or undefined if the directory could not be created.\n */\n public async rmdir(\n path: fs.PathLike,\n options: fs.RmDirOptions & ResolveFSOptions = {}\n ): Promise<void> {\n const formattedPath = toFilePath(path);\n if (!this.directoryExistsSync(path)) {\n return;\n }\n\n this.#log(LogLevelLabel.TRACE, `Removing directory: ${formattedPath}`);\n\n if (isFunction(this.resolveFS(path, options).promises.rm)) {\n await this.resolveFS(path, options).promises.rm(\n formattedPath,\n defu(options, {\n force: true,\n recursive: true\n })\n );\n\n this.#cachedFS.delete(formattedPath);\n this.clearResolverCache(formattedPath);\n } else {\n this.rmdirSync(\n formattedPath,\n defu(options ?? {}, {\n force: true,\n recursive: true\n })\n );\n }\n }\n\n /**\n * Removes a file in the virtual file system (VFS).\n *\n * @param path - The path to the file to remove.\n * @param options - Options for removing the file.\n * @returns A promise that resolves when the file is removed.\n */\n public async rm(\n path: fs.PathLike,\n options: fs.RmOptions & ResolveFSOptions = {}\n ): Promise<void> {\n this.#log(LogLevelLabel.TRACE, `Removing: ${toFilePath(path)}`);\n\n if (this.directoryExistsSync(path)) {\n return this.rmdir(path, options);\n }\n\n return this.unlink(path, options);\n }\n\n /**\n * Creates a directory in the virtual file system (VFS).\n *\n * @param path - The path to create the directory at.\n * @param options - Options for creating the directory.\n * @returns A promise that resolves to the path of the created directory, or undefined if the directory could not be created.\n */\n public mkdirSync(\n path: fs.PathLike,\n options: MakeDirectoryOptions = {}\n ): string | undefined {\n const filePath = toFilePath(path);\n\n this.clearResolverCache(filePath);\n return this.resolveFS(filePath, options).mkdirSync(\n filePath,\n defu(options ?? {}, {\n recursive: true\n })\n );\n }\n\n /**\n * Creates a directory in the virtual file system (VFS).\n *\n * @param path - The path to create the directory at.\n * @param options - Options for creating the directory.\n * @returns A promise that resolves to the path of the created directory, or undefined if the directory could not be created.\n */\n public async mkdir(\n path: fs.PathLike,\n options: MakeDirectoryOptions = {}\n ): Promise<string | undefined> {\n let result: string | undefined;\n\n const filePath = toFilePath(path);\n\n if (isFunction(this.resolveFS(filePath, options).promises.mkdir)) {\n result = await this.resolveFS(filePath, options).promises.mkdir(\n filePath,\n defu(options ?? {}, {\n recursive: true\n })\n );\n } else {\n result = this.resolveFS(filePath, options).mkdirSync(\n filePath,\n defu(options ?? {}, {\n recursive: true\n })\n );\n }\n\n this.clearResolverCache(filePath);\n return result;\n }\n\n /**\n * Lists files in a given path.\n *\n * @param path - The path to list files from.\n * @param options - Options for listing files, such as encoding and recursion.\n * @returns An array of file names in the specified path.\n */\n public async readdir(\n path: PathLike,\n options:\n | {\n encoding: BufferEncoding | null;\n withFileTypes?: false | undefined;\n recursive?: boolean | undefined;\n }\n | BufferEncoding = \"utf8\"\n ): Promise<string[]> {\n return this.resolveFS(path).promises.readdir(toFilePath(path), options);\n }\n\n /**\n * Asynchronously reads a file from the virtual file system (VFS).\n *\n * @param pathOrId - The path or ID of the file to read.\n * @returns A promise that resolves to the contents of the file as a string, or undefined if the file does not exist.\n */\n public async readFile(\n pathOrId: PathLike,\n options:\n | (ObjectEncodingOptions & {\n flag?: string | undefined;\n })\n | BufferEncoding = \"utf8\"\n ): Promise<string | undefined> {\n if (!pathOrId) {\n return undefined;\n }\n\n const filePath = this.resolvePath(toFilePath(pathOrId), {\n type: \"file\"\n });\n if (filePath) {\n if (this.#cachedFS.has(filePath)) {\n return this.#cachedFS.get(filePath);\n }\n\n let result: string | NonSharedBuffer;\n if (isFunction(this.resolveFS(filePath).promises.readFile)) {\n result = (\n await this.resolveFS(filePath).promises.readFile(filePath, options)\n )?.toString(\"utf8\");\n } else {\n result = this.resolveFS(filePath).readFileSync(filePath, options);\n }\n\n const content = isBuffer(result) ? bufferToString(result) : result;\n this.#cachedFS.set(filePath, content);\n\n return content;\n }\n\n return undefined;\n }\n\n /**\n * Synchronously reads a file from the virtual file system (VFS).\n *\n * @param pathOrId - The path or ID of the file to read.\n * @returns The contents of the file as a string, or undefined if the file does not exist.\n */\n public readFileSync(\n pathOrId: PathLike,\n options:\n | (fs.ObjectEncodingOptions & {\n flag?: string | undefined;\n })\n | BufferEncoding\n | null = \"utf8\"\n ): string | undefined {\n if (!pathOrId) {\n return undefined;\n }\n\n const filePath = this.resolvePath(toFilePath(pathOrId), {\n type: \"file\"\n });\n if (filePath) {\n if (this.#cachedFS.has(filePath)) {\n return this.#cachedFS.get(filePath);\n }\n\n const result = this.resolveFS(filePath).readFileSync(filePath, options);\n\n const content = isBuffer(result) ? bufferToString(result) : result;\n this.#cachedFS.set(filePath, content);\n\n return content;\n }\n\n return undefined;\n }\n\n /**\n * Writes a file to the virtual file system (VFS).\n *\n * @param file - The path to the file.\n * @param data - The contents of the file.\n * @param options - Optional parameters for writing the file.\n * @returns A promise that resolves when the file is written.\n */\n public async writeFile(\n file: PathOrFileDescriptor,\n data: string | NodeJS.ArrayBufferView = \"\",\n options: WriteFileOptions = \"utf8\"\n ): Promise<void> {\n const absolutePath = this.formatAbsoluteFilePath(toFilePath(file));\n if (!this.directoryExistsSync(findFilePath(absolutePath))) {\n await this.mkdir(findFilePath(absolutePath), options);\n }\n\n this.#log(\n LogLevelLabel.TRACE,\n `Writing ${absolutePath} file to the ${\n this.resolveOutputMode(absolutePath, options) === \"fs\" ? \"\" : \"virtual \"\n }file system (size: ${prettyBytes(new Blob(toArray(data)).size)})`\n );\n\n this.#cachedFS.set(absolutePath, data.toString());\n this.clearResolverCache(absolutePath);\n\n const ifs: IFS = this.resolveFS(absolutePath, options);\n\n if (isFunction(ifs.promises.writeFile)) {\n return ifs.promises.writeFile(\n absolutePath,\n data,\n omit(options, [\"mode\"])\n );\n }\n\n return ifs.writeFileSync(absolutePath, data, omit(options, [\"mode\"]));\n }\n\n /**\n * Synchronously writes a file to the virtual file system (VFS).\n *\n * @param file - The file to write.\n * @param data - The contents of the file.\n * @param options - Optional parameters for writing the file.\n */\n public writeFileSync(\n file: PathOrFileDescriptor,\n data: string | NodeJS.ArrayBufferView = \"\",\n options: WriteFileOptions = \"utf8\"\n ): void {\n const absolutePath = this.formatAbsoluteFilePath(toFilePath(file));\n if (!this.directoryExistsSync(findFilePath(absolutePath))) {\n this.mkdirSync(findFilePath(absolutePath));\n }\n\n this.#log(\n LogLevelLabel.TRACE,\n `Writing ${absolutePath} file to the ${\n this.resolveOutputMode(absolutePath, options) === \"fs\" ? \"\" : \"virtual \"\n } (size: ${prettyBytes(new Blob(toArray(data)).size)})`\n );\n\n this.#cachedFS.set(absolutePath, data.toString());\n this.clearResolverCache(absolutePath);\n\n const writeStream = this.resolveFS(\n absolutePath,\n omit(options, [\"mode\"])\n ).createWriteStream(absolutePath);\n try {\n writeStream.write(data);\n } finally {\n writeStream.close();\n }\n }\n\n /**\n * Writes a runtime file to the virtual file system (VFS).\n *\n * @param id - The unique identifier for the runtime file.\n * @param path - The path to the runtime file.\n * @param contents - The contents of the runtime file.\n * @param options - Optional parameters for writing the runtime file.\n * @returns A promise that resolves when the file is written.\n */\n public async writeBuiltinFile(\n id: string,\n path: PathLike,\n contents: string,\n options: WriteBuiltinFileOptions = {}\n ): Promise<void> {\n const formattedId = this.formatRuntimeId(id);\n const absolutePath = this.formatAbsoluteFilePath(toFilePath(path));\n\n this.builtinIdMap.set(formattedId, absolutePath);\n\n let data = contents;\n if (!options.skipFormat) {\n data = await format(contents, {\n absolutePath,\n ...(await resolveConfig(absolutePath))\n });\n }\n\n const _options = defu(isSetString(options) ? {} : (options ?? {}), {\n encoding: isSetString(options) ? options : \"utf8\",\n mode: \"virtual\"\n }) as WriteFileOptions;\n\n this.#log(\n LogLevelLabel.DEBUG,\n `Writing runtime file ${absolutePath} (size: ${prettyBytes(\n new Blob(toArray(data)).size\n )}) to ${\n this.resolveOutputMode(absolutePath, _options) === \"fs\"\n ? \"disk\"\n : \"memory\"\n }`\n );\n\n return this.writeFile(absolutePath, data, _options);\n }\n\n /**\n * Adds an entry file to the virtual file system.\n *\n * @param name - The file name or absolute path of the entry module.\n * @param contents - The contents of the entry file.\n * @param options - Optional parameters for writing the entry file.\n */\n public async writeEntryFile(\n name: string,\n contents: string,\n options: WriteBuiltinFileOptions = {}\n ): Promise<void> {\n const absolutePath = this.formatAbsoluteFilePath(\n isAbsolutePath(toFilePath(name))\n ? toFilePath(name)\n : toFilePath(joinPaths(this.#context.entryPath, name))\n );\n\n let data = contents;\n if (!options.skipFormat) {\n data = await format(contents, {\n absolutePath,\n ...(await resolveConfig(absolutePath))\n });\n }\n\n const _options = defu(isSetString(options) ? {} : (options ?? {}), {\n encoding: isSetString(options) ? options : \"utf8\",\n mode: \"virtual\"\n }) as WriteFileOptions;\n\n this.#log(\n LogLevelLabel.DEBUG,\n `Writing entry file ${absolutePath} (size: ${prettyBytes(\n new Blob(toArray(data)).size\n )}) to ${\n this.resolveOutputMode(absolutePath, _options) === \"fs\"\n ? \"disk\"\n : \"virtual memory\"\n }`\n );\n\n return this.writeFile(absolutePath, data, _options);\n }\n\n /**\n * Writes a file to disk from the physical file system (on disk).\n *\n * @param path - The path to the file to write.\n * @param contents - The contents of the file to write.\n * @param options - Optional parameters for writing the file.\n * @returns A promise that resolves when the file is written.\n */\n public async writeFileToDisk(\n path: PathLike,\n contents: string,\n options: WriteBuiltinFileOptions = {}\n ): Promise<void> {\n const absolutePath = this.formatAbsoluteFilePath(toFilePath(path));\n\n let data = contents;\n if (!options.skipFormat) {\n const resolvedConfig = await resolveConfig(absolutePath);\n if (resolvedConfig) {\n data = await format(contents, {\n absolutePath,\n ...resolvedConfig\n });\n }\n }\n\n return this.writeFile(\n absolutePath,\n data,\n defu(\n {\n mode: \"fs\"\n },\n isSetString(options) ? {} : (options ?? {}),\n {\n encoding: isSetString(options) ? options : \"utf8\"\n }\n ) as WriteFileOptions\n );\n }\n\n /**\n * Synchronously checks if a file exists in the virtual file system (VFS).\n *\n * @param pathOrId - The path or ID of the file to check.\n * @returns `true` if the file exists, otherwise `false`.\n */\n public existsSync(pathOrId: PathLike): boolean {\n return this.pathExistsSync(\n this.resolvePath(toFilePath(pathOrId)) || toFilePath(pathOrId)\n );\n }\n\n /**\n * Checks if a file exists in the virtual file system (VFS).\n *\n * @remarks\n * This is a base method used by {@link existsSync} - it does not try to resolve the path prior to checking if it exists or not.\n *\n * @param path - The path of the file to check.\n * @returns `true` if the file exists, otherwise `false`.\n */\n public fileExistsSync(path: PathLike): boolean {\n const formattedPath = this.formatAbsoluteFilePath(toFilePath(path));\n\n return (\n this.isValidBuiltinId(formattedPath) ||\n (this.#virtualFS.existsSync(formattedPath) &&\n this.#virtualFS.lstatSync(formattedPath).isFile()) ||\n (this.#fs.existsSync(formattedPath) &&\n this.#fs.lstatSync(formattedPath).isFile()) ||\n (this.resolveFS(path).existsSync(formattedPath) &&\n this.resolveFS(path).lstatSync(formattedPath).isFile())\n );\n }\n\n /**\n * Checks if a directory exists in the virtual file system (VFS).\n *\n * @param path - The path of the directory to check.\n * @returns `true` if the directory exists, otherwise `false`.\n */\n public directoryExistsSync(path: PathLike): boolean {\n const formattedPath = this.formatAbsoluteFilePath(toFilePath(path));\n\n return (\n (this.#virtualFS.existsSync(formattedPath) &&\n this.#virtualFS.lstatSync(formattedPath).isDirectory()) ||\n (this.#fs.existsSync(formattedPath) &&\n this.#fs.lstatSync(formattedPath).isDirectory()) ||\n (this.resolveFS(path).existsSync(formattedPath) &&\n this.resolveFS(path).lstatSync(formattedPath).isDirectory())\n );\n }\n\n /**\n * Checks if a path exists in the virtual file system (VFS).\n *\n * @param path - The path to check.\n * @returns `true` if the path exists, otherwise `false`.\n */\n public pathExistsSync(path: PathLike): boolean {\n const formattedPath = this.formatAbsoluteFilePath(toFilePath(path));\n\n return (\n this.isValidBuiltinId(formattedPath) ||\n this.#virtualFS.existsSync(formattedPath) ||\n this.#fs.existsSync(formattedPath) ||\n this.resolveFS(path).existsSync(formattedPath)\n );\n }\n\n /**\n * Retrieves the status of a file in the virtual file system (VFS).\n *\n * @param pathOrId - The path or ID of the file to retrieve status for.\n * @returns A promise that resolves to the file's status information, or false if the file does not exist.\n */\n public async stat(\n pathOrId: PathLike,\n options?: fs.StatOptions & {\n bigint?: false | undefined;\n }\n ): Promise<Stats> {\n return this.resolveFS(pathOrId).promises.stat(\n this.resolvePath(toFilePath(pathOrId)) || toFilePath(pathOrId),\n options\n );\n }\n\n /**\n * Synchronously retrieves the status of a file in the virtual file system (VFS).\n *\n * @param pathOrId - The path or ID of the file to retrieve status for.\n * @returns The file's status information, or false if the file does not exist.\n */\n public statSync(pathOrId: PathLike): Stats {\n return this.resolveFS(pathOrId).statSync(\n this.resolvePath(toFilePath(pathOrId)) || toFilePath(pathOrId)\n );\n }\n\n /**\n * Retrieves the status of a symbolic link in the virtual file system (VFS).\n *\n * @param pathOrId - The path or ID of the symbolic link to retrieve status for.\n * @returns A promise that resolves to the symbolic link's status information, or false if the link does not exist.\n */\n public async lstat(\n pathOrId: PathLike,\n options?: fs.StatOptions & {\n bigint?: false | undefined;\n }\n ): Promise<Stats> {\n return this.resolveFS(pathOrId).promises.lstat(\n this.resolvePath(toFilePath(pathOrId)) || toFilePath(pathOrId),\n options\n );\n }\n\n /**\n * Synchronously retrieves the status of a symbolic link in the virtual file system (VFS).\n *\n * @param pathOrId - The path or ID of the symbolic link to retrieve status for.\n * @returns The symbolic link's status information, or false if the link does not exist.\n */\n public lstatSync(\n pathOrId: PathLike,\n options?: StatSyncOptions & {\n bigint?: false | undefined;\n throwIfNoEntry: false;\n }\n ): Stats | undefined {\n return this.resolveFS(pathOrId).lstatSync(\n this.resolvePath(toFilePath(pathOrId)) || toFilePath(pathOrId),\n options\n );\n }\n\n /**\n * Resolves a path or ID to a runtime file id in the virtual file system.\n *\n * @param pathOrId - The path or id of the file to resolve.\n * @returns The resolved id of the runtime file if it exists, otherwise false.\n */\n public resolveId(pathOrId: PathLike): string | false {\n if (this.builtinIdMap.has(this.formatRuntimeId(toFilePath(pathOrId)))) {\n return this.formatRuntimeId(toFilePath(pathOrId));\n }\n\n const filePath = this.resolvePath(toFilePath(pathOrId));\n if (filePath) {\n return (\n this.builtinIdMap\n .keys()\n .find(id => this.builtinIdMap.get(id) === filePath) || false\n );\n }\n\n return false;\n }\n\n /**\n * Resolves a path based on TypeScript's `tsconfig.json` paths.\n *\n * @see https://www.typescriptlang.org/tsconfig#paths\n *\n * @param path - The path to check.\n * @returns The resolved file path if it exists, otherwise undefined.\n */\n public resolveTsconfigPath(path: string): string | false {\n if (this.#context.tsconfig.options.paths) {\n for (const tsconfigPathKey of Object.keys(\n this.#context.tsconfig.options.paths\n ).filter(tsconfigPath =>\n path.startsWith(tsconfigPath.replaceAll(\"*\", \"\"))\n )) {\n const resolvedPath = this.#context.tsconfig.options.paths[\n tsconfigPathKey\n ]?.find(\n tsconfigPath =>\n this.resolvePathName(\n joinPaths(\n this.#context.workspaceConfig.workspaceRoot,\n tsconfigPath.replaceAll(\"*\", \"\"),\n path.replace(tsconfigPathKey.replaceAll(\"*\", \"\"), \"\")\n )\n ) ||\n this.formatAbsoluteFilePath(tsconfigPath) ===\n this.formatAbsoluteFilePath(path)\n );\n if (resolvedPath) {\n return this.formatAbsoluteFilePath(resolvedPath) ===\n this.formatAbsoluteFilePath(path)\n ? this.formatAbsoluteFilePath(resolvedPath)\n : this.resolvePathName(\n joinPaths(\n this.#context.workspaceConfig.workspaceRoot,\n resolvedPath.replaceAll(\"*\", \"\"),\n path.replace(tsconfigPathKey.replaceAll(\"*\", \"\"), \"\")\n )\n );\n }\n }\n }\n\n return false;\n }\n\n /**\n * Resolves a path based on TypeScript's `tsconfig.json` paths.\n *\n * @see https://www.typescriptlang.org/tsconfig#paths\n *\n * @param path - The path to check.\n * @returns The resolved file path if it exists, otherwise undefined.\n */\n public resolveTsconfigPathPackage(path: string): string | false {\n if (this.#context.tsconfig.options.paths) {\n const tsconfigPathKeys = Object.keys(\n this.#context.tsconfig.options.paths\n ).filter(tsconfigPath =>\n path.startsWith(tsconfigPath.replaceAll(\"*\", \"\"))\n );\n if (tsconfigPathKeys.length > 0 && tsconfigPathKeys[0]) {\n return tsconfigPathKeys[0].replace(/\\/\\*$/, \"\");\n }\n }\n\n return false;\n }\n\n /**\n * Resolves a path or ID to its real path in the virtual file system (VFS).\n *\n * @param pathOrId - The path or ID to resolve.\n * @returns The resolved real path if it exists, otherwise undefined.\n */\n public realpathSync(pathOrId: PathLike): string {\n const filePath = this.resolvePath(toFilePath(pathOrId));\n if (!filePath) {\n throw new Error(`File not found: ${toFilePath(pathOrId)}`);\n }\n\n return filePath;\n }\n\n /**\n * Resolves a path or ID parameter to a corresponding virtual file path in the virtual file system (VFS).\n *\n * @param pathOrId - The path or ID to resolve.\n * @param options - Optional parameters for resolving the path, such as whether to include the file extension.\n * @returns The resolved file path if it exists, otherwise undefined.\n */\n public resolvePath(\n pathOrId: PathLike,\n options: ResolvePathOptions = {}\n ): string | false {\n const formattedPath = toFilePath(pathOrId);\n\n const resolverKey = `${formattedPath}${\n options.withExtension ? \"-ext\" : \"\"\n }${options.paths ? `-${murmurhash(options.paths)}` : \"\"}${\n options.type ? `-${options.type}` : \"\"\n }`;\n if (this.#cachedResolver.has(resolverKey)) {\n return this.#cachedResolver.get(resolverKey)!;\n } else if (this.#cachedFS.has(formattedPath)) {\n return formattedPath;\n }\n\n let result: string | undefined | false = false;\n if (this.isValidBuiltinId(formattedPath)) {\n result = this.builtinIdMap.get(this.formatRuntimeId(formattedPath));\n } else {\n result = this.resolvePathName(formattedPath, options);\n }\n\n if (!result) {\n result = false;\n } else {\n result = toFilePath(result);\n }\n\n if (result && options.withExtension === false) {\n return result.replace(/\\.[m|c]?[t|j]sx?$/, \"\");\n }\n\n this.#cachedResolver.set(resolverKey, result);\n\n return result;\n }\n\n /**\n * Formats a file path by removing the runtime prefix and leading null character.\n *\n * @param path - The file path to format.\n * @returns The formatted file path.\n */\n public formatFilePath(path: string): string {\n if (!isSetString(path)) {\n throw new Error(\n `Invalid path provided. Expected a string or a valid file path.`\n );\n }\n\n return path\n .replace(new RegExp(`^${this.#context.config.output.builtinPrefix}:`), \"\")\n .replace(/^\\\\0/, \"\");\n }\n\n /**\n * Converts a relative path to an absolute path based on the workspace and project root.\n *\n * @param path - The relative path to convert.\n * @returns The absolute path.\n */\n public formatAbsoluteFilePath = (path: string): string => {\n const formattedPath = this.formatFilePath(path);\n if (\n isAbsolutePath(formattedPath) ||\n formattedPath.startsWith(this.#context.workspaceConfig.workspaceRoot)\n ) {\n return formattedPath;\n } else if (formattedPath.startsWith(this.#context.config.projectRoot)) {\n return joinPaths(\n this.#context.workspaceConfig.workspaceRoot,\n formattedPath\n );\n }\n\n return formattedPath;\n };\n\n /**\n * Formats a runtime ID by removing the file extension and prepending the runtime prefix.\n *\n * @param id - The runtime ID to format.\n * @returns The formatted runtime ID.\n */\n public formatRuntimeId(id: string): string {\n return `${this.#context.config.output.builtinPrefix}:${this.formatFilePath(\n id\n ).replace(/\\.[m|c]?[t|j]sx?$/, \"\")}`;\n }\n\n /**\n * Resolves a path or ID parameter to a corresponding virtual file path in the virtual file system (VFS).\n *\n * @param pathOrId - The path or ID to resolve.\n * @returns The resolved file path if it exists, otherwise undefined.\n */\n private resolvePathName(\n pathOrId: string,\n options: ResolvePathOptions = {}\n ): string | false {\n if (pathOrId.startsWith(`${this.#context.config.output.builtinPrefix}:`)) {\n return false;\n }\n\n // if (pathOrId.startsWith(\"@\")) {\n // const resolveOptions = {\n // paths: [\n // joinPaths(\n // this.#context.options.workspaceRoot,\n // this.#context.options.projectRoot\n // ),\n // this.#context.options.workspaceRoot\n // ]\n // };\n\n // let result = resolveSafeSync(\n // joinPaths(pathOrId, \"package.json\"),\n // resolveOptions\n // );\n // if (!result) {\n // result = resolveSafeSync(\n // joinPaths(pathOrId, \"index.js\"),\n // resolveOptions\n // );\n // if (!result) {\n // result = resolveSafeSync(pathOrId, resolveOptions);\n // }\n // }\n\n // if (result) {\n // return findFilePath(result);\n // }\n // }\n\n // let result = checkAbsolute(\n // this.#context,\n // this.formatAbsoluteFilePath(pathOrId),\n // this,\n // options\n // );\n // if (result) {\n // return result;\n // }\n\n if (isAbsolutePath(pathOrId)) {\n if (\n options.type === \"file\"\n ? this.fileExistsSync(pathOrId)\n : this.pathExistsSync(pathOrId)\n ) {\n return pathOrId;\n }\n\n const result = checkVariants(pathOrId, this);\n if (result) {\n return result;\n }\n }\n\n for (const path of this.resolveParentPaths(pathOrId, options.paths)) {\n const request = joinPaths(path, pathOrId);\n if (\n options.type === \"file\"\n ? this.fileExistsSync(pathOrId)\n : this.pathExistsSync(pathOrId)\n ) {\n return request;\n }\n\n const result = checkVariants(request, this);\n if (result) {\n return result;\n }\n }\n\n return false;\n }\n\n private resolveParentPaths(request: string, current: string[] = []) {\n let paths = [\n this.#context.workspaceConfig.workspaceRoot,\n joinPaths(\n this.#context.workspaceConfig.workspaceRoot,\n this.#context.config.projectRoot\n )\n ];\n\n if (this.#context.tsconfig.options.paths) {\n paths = this.#context.tsconfig.options.paths\n ? Object.keys(this.#context.tsconfig.options.paths)\n .filter(tsconfigPath =>\n request.startsWith(tsconfigPath.replaceAll(\"*\", \"\"))\n )\n .map(\n tsconfigPath =>\n this.#context.tsconfig.options.paths?.[tsconfigPath]\n )\n .flat()\n .reduce((ret, path) => {\n if (\n path &&\n !ret.includes(\n joinPaths(this.#context.workspaceConfig.workspaceRoot, path)\n )\n ) {\n ret.push(\n joinPaths(this.#context.workspaceConfig.workspaceRoot, path)\n );\n }\n\n return ret;\n }, paths)\n : paths;\n }\n\n return paths.reduce(\n (ret, path) => {\n if (!ret.includes(path)) {\n ret.push(path);\n }\n\n return ret;\n },\n current\n .filter(Boolean)\n .map(p => this.formatAbsoluteFilePath(toFilePath(p)))\n );\n }\n\n /**\n * Select the file system module to use for the operation based on the path or URL.\n *\n * @param pathOrUrl - The path to perform the file system operation on.\n * @param options - Options for the operation, such as output mode.\n * @returns The file system module used for the operation.\n */\n private resolveFS(\n pathOrUrl: fs.PathOrFileDescriptor,\n options: ResolveFSOptions = {}\n ): IFS {\n const mode = this.resolveOutputMode(pathOrUrl, options);\n if (mode === \"virtual\") {\n return this.#virtualFS as any;\n } else if (mode === \"fs\") {\n return this.#fs;\n }\n\n return this.#unifiedFS;\n }\n\n /**\n * Select the file system module to use for the operation based on the path or URL.\n *\n * @param pathOrUrl - The path to perform the file system operation on.\n * @param options - Options for the operation, such as output mode.\n * @returns The file system module used for the operation.\n */\n private resolveOutputMode(\n pathOrUrl: fs.PathOrFileDescriptor,\n options: ResolveFSOptions = {}\n ): OutputModeType | null {\n if (\n options.mode === \"virtual\" &&\n this.#context.config.output.mode !== \"fs\" &&\n isParentPath(toFilePath(pathOrUrl), this.#context.artifactsPath)\n ) {\n return \"virtual\";\n } else if (\n options.mode === \"fs\" ||\n this.#context.config.output.mode === \"fs\" ||\n isParentPath(toFilePath(pathOrUrl), this.#context.dataPath) ||\n isParentPath(toFilePath(pathOrUrl), this.#context.cachePath) ||\n isParentPath(\n toFilePath(pathOrUrl),\n joinPaths(\n this.#context.workspaceConfig.workspaceRoot,\n this.#context.config.output.outputPath\n )\n )\n ) {\n return \"fs\";\n }\n\n return null;\n }\n\n /**\n * Clears the resolver cache for a given path.\n *\n * @param path - The path to clear the resolver cache for.\n */\n private clearResolverCache(path: fs.PathLike) {\n this.#cachedResolver\n .keys()\n .filter(key => key.startsWith(toFilePath(path)))\n .forEach(key => this.#cachedResolver.delete(key));\n }\n}\n\nconst FILE_PREFIX = \"file://\";\n\nfunction toFilePath(pathOrUrl: PathOrFileDescriptor): string {\n if (!pathOrUrl) {\n throw new Error(\"No Path or URL provided to Virtual File System\");\n }\n let result = pathOrUrl.toString();\n if (result.startsWith(FILE_PREFIX)) {\n result = result.slice(FILE_PREFIX.length);\n }\n return result;\n}\n\nconst FS_METHODS = [\n \"mkdir\",\n \"mkdirSync\",\n \"rmdir\",\n \"rmdirSync\",\n \"unlink\",\n \"unlinkSync\",\n \"existsSync\",\n \"realpathSync\",\n \"writeFileSync\",\n \"readFileSync\",\n \"readdirSync\",\n \"createWriteStream\",\n \"WriteStream\",\n \"createReadStream\",\n \"ReadStream\"\n];\n\nconst FS_PROMISE_METHODS = [\n \"mkdir\",\n \"rm\",\n \"rmdir\",\n \"unlink\",\n \"writeFile\",\n \"readFile\",\n \"readdir\",\n \"stat\",\n \"lstat\"\n];\n\nfunction cloneFS(originalFS: typeof fs) {\n const clonedFS: typeof fs = {\n ...originalFS,\n promises: {\n ...(originalFS.promises ?? {})\n }\n };\n\n for (const method of FS_METHODS) {\n if ((originalFS as any)[method]) {\n (clonedFS as any)[method] = (originalFS as any)[method];\n }\n }\n\n originalFS.promises ??= {} as (typeof fs)[\"promises\"];\n for (const method of FS_PROMISE_METHODS) {\n if ((originalFS.promises as any)[method]) {\n clonedFS.promises ??= {} as (typeof fs)[\"promises\"];\n (clonedFS.promises as any)[method] = (originalFS.promises as any)[method];\n (clonedFS as any)[method] = (originalFS.promises as any)[method];\n }\n }\n\n for (const prop in clonedFS) {\n if (isFunction((clonedFS as any)[prop])) {\n (clonedFS as any)[prop] = (clonedFS as any)[prop].bind(originalFS);\n if (isFunction((clonedFS.promises as any)[prop])) {\n (clonedFS.promises as any)[prop] = (clonedFS.promises as any)[\n prop\n ].bind(originalFS);\n }\n }\n }\n\n for (const prop in clonedFS.promises) {\n if (isFunction((clonedFS.promises as any)[prop])) {\n (clonedFS.promises as any)[prop] = (clonedFS.promises as any)[prop].bind(\n originalFS\n );\n }\n }\n\n return clonedFS;\n}\n\n/**\n * Patches the original file system module to use the virtual file system (VFS) methods.\n *\n * @param originalFS - The original file system module to patch.\n * @param vfs - The virtual file system interface to use for file operations.\n * @returns A function to restore the original file system methods.\n */\nfunction patchFS(\n originalFS: typeof fs,\n vfs: VirtualFileSystemInterface\n): () => void {\n const clonedFS = cloneFS(originalFS);\n\n (originalFS as any).mkdirSync = (file: PathOrFileDescriptor, options?: any) =>\n (vfs.mkdirSync as any)(toFilePath(file), options);\n (originalFS as any).mkdir = (\n file: PathOrFileDescriptor,\n options?: any,\n callback?: any\n ) => (vfs.mkdir as any)(toFilePath(file), options, callback);\n (originalFS.promises as any).mkdir = async (\n file: PathOrFileDescriptor,\n options?: any\n ) => (vfs.mkdir as any)(toFilePath(file), options);\n\n // originalFS.rmdirSync = vfs.rmdirSync.bind(vfs);\n originalFS.unlinkSync = (file: PathOrFileDescriptor) =>\n (vfs.unlinkSync as any)(toFilePath(file));\n // originalFS.rmdir = vfs.rmdir.bind(vfs);\n // originalFS.promises.rmdir = vfs.rmdir.bind(vfs);\n // Wrap promise methods to accept PathLike and forward string to VFS implementation\n originalFS.promises.rm = (async (file: PathOrFileDescriptor, options?: any) =>\n vfs.rm(toFilePath(file), options)) as unknown as (\n file: PathOrFileDescriptor,\n options?: any\n ) => Promise<void>;\n originalFS.promises.unlink = (async (file: PathOrFileDescriptor) =>\n vfs.unlink(toFilePath(file))) as unknown as (\n file: PathOrFileDescriptor\n ) => Promise<void>;\n\n originalFS.existsSync = (file: PathOrFileDescriptor) =>\n vfs.existsSync(toFilePath(file));\n Object.defineProperty(originalFS, \"realpathSync\", {\n value: (file: PathOrFileDescriptor, options?: fs.EncodingOption) =>\n (vfs.realpathSync as any)(toFilePath(file), options)\n });\n\n originalFS.writeFileSync = (\n file: PathOrFileDescriptor,\n data: any,\n options?: any\n ) => (vfs.writeFileSync as any)(toFilePath(file), data, options);\n originalFS.promises.writeFile = (async (\n file: PathOrFileDescriptor,\n data: any,\n options?: any\n ) =>\n (vfs.writeFile as any)(\n toFilePath(file as any),\n data,\n options\n )) as unknown as typeof originalFS.promises.writeFile;\n originalFS.readFileSync = (file: PathOrFileDescriptor, options?: any) =>\n (vfs.readFileSync as any)(toFilePath(file), options);\n originalFS.promises.readFile = ((file: PathOrFileDescriptor, options?: any) =>\n (vfs.readFile as any)(\n toFilePath(file),\n options\n )) as unknown as typeof originalFS.promises.readFile;\n\n originalFS.readdirSync = (file: PathOrFileDescriptor, options?: any) =>\n (vfs.readdirSync as any)(toFilePath(file), options);\n originalFS.promises.readdir = (file: PathOrFileDescriptor, options?: any) =>\n (vfs.readdir as any)(toFilePath(file), options);\n\n Object.defineProperty(originalFS, \"statSync\", {\n value: (file: PathOrFileDescriptor, options?: any) =>\n (vfs.statSync as any)(toFilePath(file), options)\n });\n (originalFS as any).stat = (file: PathOrFileDescriptor, options?: any) =>\n (vfs.statSync as any)(toFilePath(file), options);\n originalFS.promises.stat = (file: PathOrFileDescriptor, options?: any) =>\n (vfs.stat as any)(toFilePath(file), options);\n\n Object.defineProperty(originalFS, \"lstatSync\", {\n value: (file: PathOrFileDescriptor, options?: any) =>\n (vfs.lstatSync as any)(toFilePath(file), options)\n });\n (originalFS as any).lstat = (file: PathOrFileDescriptor, options?: any) =>\n (vfs.lstatSync as any)(toFilePath(file), options);\n originalFS.promises.lstat = (file: PathOrFileDescriptor, options?: any) =>\n (vfs.lstat as any)(toFilePath(file), options);\n\n return () => {\n originalFS.mkdirSync = clonedFS.mkdirSync;\n originalFS.mkdir = clonedFS.mkdir;\n originalFS.promises.mkdir = clonedFS.promises.mkdir;\n\n // originalFS.rmdirSync = clonedFS.rmdirSync;\n originalFS.unlinkSync = clonedFS.unlinkSync;\n // originalFS.rmdir = clonedFS.rmdir;\n // originalFS.promises.rmdir = clonedFS.promises.rmdir;\n originalFS.promises.rm = clonedFS.promises.rm;\n originalFS.promises.unlink = clonedFS.promises.unlink;\n\n originalFS.existsSync = clonedFS.existsSync;\n originalFS.realpathSync = clonedFS.realpathSync;\n\n originalFS.writeFileSync = clonedFS.writeFileSync;\n originalFS.promises.writeFile = clonedFS.promises.writeFile;\n originalFS.readFileSync = clonedFS.readFileSync;\n originalFS.promises.readFile = clonedFS.promises.readFile;\n\n originalFS.readdirSync = clonedFS.readdirSync;\n originalFS.promises.readdir = clonedFS.promises.readdir;\n\n Object.defineProperty(originalFS, \"statSync\", {\n value: clonedFS.statSync\n });\n (originalFS as any).stat = clonedFS.stat;\n originalFS.promises.stat = clonedFS.promises.stat;\n\n Object.defineProperty(originalFS, \"lstatSync\", {\n value: clonedFS.lstatSync\n });\n (originalFS as any).lstat = clonedFS.lstat;\n originalFS.promises.lstat = clonedFS.promises.lstat;\n };\n}\n\n/**\n * Check if the file exists with different variants (index, extensions).\n *\n * @param request - The request path to check.\n * @param vfs - The file system module to use for checking file existence.\n * @returns The file path if it exists, otherwise false.\n */\nfunction checkVariants(\n request: string,\n vfs: VirtualFileSystemInterface,\n parentPath?: string\n): string | false {\n const path = parentPath ? joinPaths(parentPath, request) : request;\n\n let file = checkExtensions(path, vfs);\n if (file) {\n return file;\n }\n\n file = checkIndex(path, vfs);\n if (file) {\n return file;\n }\n\n return false;\n}\n\n/**\n * Check if the index file exists in the given request path.\n *\n * @param request - The request path to check.\n * @param vfs - The file system module to use for checking file existence.\n * @returns The index file path if it exists, otherwise false.\n */\nfunction checkIndex(\n request: string,\n vfs: VirtualFileSystemInterface\n): string | false {\n let file: string | false = joinPaths(request, \"index\");\n if (vfs.fileExistsSync(file)) {\n return file;\n }\n\n file = checkExtensions(file, vfs);\n if (file) {\n return file;\n }\n\n return false;\n}\n\n/**\n * Check if the file exists with different extensions.\n *\n * @param request - The request path to check.\n * @param vfs - The file system module to use for checking file existence.\n * @returns The file path if it exists with any of the checked extensions, otherwise false.\n */\nfunction checkExtensions(\n request: string,\n vfs: VirtualFileSystemInterface\n): string | false {\n let file = `${request}.ts`;\n if (vfs.fileExistsSync(file)) {\n return file;\n }\n\n file = `${request}.mts`;\n if (vfs.fileExistsSync(file)) {\n return file;\n }\n\n file = `${request}.cts`;\n if (vfs.fileExistsSync(file)) {\n return file;\n }\n\n file = `${request}.tsx`;\n if (vfs.fileExistsSync(file)) {\n return file;\n }\n\n file = `${request}.js`;\n if (vfs.fileExistsSync(file)) {\n return file;\n }\n\n file = `${request}.mjs`;\n if (vfs.fileExistsSync(file)) {\n return file;\n }\n\n file = `${request}.cjs`;\n if (vfs.fileExistsSync(file)) {\n return file;\n }\n\n file = `${request}.jsx`;\n if (vfs.fileExistsSync(file)) {\n return file;\n }\n\n file = `${request}.json`;\n if (vfs.fileExistsSync(file)) {\n return file;\n }\n\n file = `${request}.d.ts`;\n if (vfs.fileExistsSync(file)) {\n return file;\n }\n\n return false;\n}\n\n/**\n * Creates a new virtual file system (VFS) using a Map to store {@link Vinyl} instances.\n *\n * @returns A virtual file-system containing a map where the keys are file paths and the values are {@link Vinyl} instances.\n */\nexport function createVfs(context: Context): VirtualFileSystem {\n const vfs = new VirtualFileSystem(context);\n\n return vfs;\n}\n\n/**\n * Creates a new virtual file system (VFS) using a Map to store {@link Vinyl} instances.\n *\n * @returns A virtual file-system containing a map where the keys are file paths and the values are {@link Vinyl} instances.\n */\nexport function restoreVfs(\n context: Context,\n serialized: SerializedVirtualFileSystem\n): VirtualFileSystem {\n const vfs = new VirtualFileSystem(context, serialized);\n\n return vfs;\n}\n","/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { LogLevelLabel } from \"@storm-software/config-tools/types\";\nimport { isDirectory } from \"@stryke/fs/is-file\";\nimport { isPackageExists } from \"@stryke/fs/package-fns\";\nimport { readFile } from \"@stryke/fs/read-file\";\nimport { parseVersion } from \"@stryke/fs/semver-fns\";\nimport { findFileName } from \"@stryke/path/file-path-fns\";\nimport { getParentPath } from \"@stryke/path/get-parent-path\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport { isError } from \"@stryke/type-checks/is-error\";\nimport type { ESLint as FlatESLint } from \"eslint\";\nimport type { LegacyESLint } from \"eslint/use-at-your-own-risk\";\nimport path from \"node:path\";\nimport { writeFile } from \"../../lib/utilities/write-file\";\nimport { ESLintConfig, LogFn } from \"../../types/config\";\nimport type { Context } from \"../../types/context\";\nimport { installPackages } from \"./install\";\n\nexport enum MessageSeverity {\n Warning = 1,\n Error = 2\n}\n\ninterface LintMessage {\n ruleId: string | null;\n severity: 1 | 2;\n message: string;\n line: number;\n column: number;\n}\n\nexport interface LintResult {\n filePath: string;\n messages: LintMessage[];\n errorCount: number;\n warningCount: number;\n output?: string;\n source?: string;\n}\n\nfunction pluginCount(messages: LintMessage[]): {\n nextPluginErrorCount: number;\n nextPluginWarningCount: number;\n} {\n let nextPluginWarningCount = 0;\n let nextPluginErrorCount = 0;\n\n for (let i = 0; i < messages.length; i++) {\n const { severity, ruleId } = messages[i]!;\n\n if (ruleId?.includes(\"powerlines\")) {\n if (severity === MessageSeverity.Warning) {\n nextPluginWarningCount += 1;\n } else {\n nextPluginErrorCount += 1;\n }\n }\n }\n\n return {\n nextPluginErrorCount,\n nextPluginWarningCount\n };\n}\n\nfunction formatMessage(\n dir: string,\n messages: LintMessage[],\n filePath: string\n): string {\n let fileName = path.posix.normalize(\n path.relative(dir, filePath).replace(/\\\\/g, \"/\")\n );\n\n if (!fileName.startsWith(\".\")) {\n fileName = `./${fileName}`;\n }\n\n let output = `\\n${fileName}`;\n\n for (let i = 0; i < messages.length; i++) {\n const { message, severity, line, column, ruleId } = messages[i]!;\n\n output += \"\\n\";\n\n if (line && column) {\n output = `${output + line.toString()}:${column.toString()} `;\n }\n\n if (severity === MessageSeverity.Warning) {\n output += `Warning: `;\n } else {\n output += `Error: `;\n }\n\n output += message;\n\n if (ruleId) {\n output += ` ${ruleId}`;\n }\n }\n\n return output;\n}\n\nexport async function formatResults(\n baseDir: string,\n results: LintResult[],\n format?: (\n results: LintResult[],\n resultsMeta?: FlatESLint.ResultsMeta\n ) => string | Promise<string>\n): Promise<{\n output: string;\n outputWithMessages: string;\n totalPluginErrorCount: number;\n totalPluginWarningCount: number;\n}> {\n let totalPluginErrorCount = 0;\n let totalPluginWarningCount = 0;\n const resultsWithMessages = results.filter(\n ({ messages }) => messages?.length\n );\n\n // Track number of Powerlines plugin errors and warnings\n resultsWithMessages.forEach(({ messages }) => {\n const res = pluginCount(messages);\n totalPluginErrorCount += res.nextPluginErrorCount;\n totalPluginWarningCount += res.nextPluginWarningCount;\n });\n\n // Use user defined formatter or built-in custom formatter\n const output = format\n ? await format(resultsWithMessages)\n : resultsWithMessages\n .map(({ messages, filePath }) =>\n formatMessage(baseDir, messages, filePath)\n )\n .join(\"\\n\");\n\n return {\n output,\n outputWithMessages:\n resultsWithMessages.length > 0\n ? `${output}\\n\\nInfo - Need to disable some ESLint rules? Learn more here: https://nextjs.org/docs/app/api-reference/config/eslint#disabling-rules`\n : \"\",\n totalPluginErrorCount,\n totalPluginWarningCount\n };\n}\n\nasync function writeDefaultEslintConfig(\n log: LogFn,\n context: Context,\n type: \"base\" | \"recommended\" | \"strict\" = \"recommended\"\n) {\n const eslintConfigFile = joinPaths(\n context.workspaceConfig.workspaceRoot,\n \"eslint.config.js\"\n );\n const eslintConfig = `\nimport { getConfig } from \"eslint-config-powerlines\";\n\nError.stackTraceLimit = Number.POSITIVE_INFINITY;\n\nexport default getConfig({\n repositoryName: \"${context.workspaceConfig.name || context.config.name || \"powerlines\"}\",\n \"powerlines\": \"${type}\",\n});\n`;\n\n log(\n LogLevelLabel.INFO,\n `Writing a default ESLint config file to ${eslintConfigFile}`\n );\n return writeFile(log, eslintConfigFile, eslintConfig);\n}\ninterface Config {\n plugins: string[];\n rules: { [key: string]: Array<number | string> };\n}\n\n// 0 is off, 1 is warn, 2 is error. See https://eslint.org/docs/user-guide/configuring/rules#configuring-rules\nconst VALID_SEVERITY = [\"off\", \"warn\", \"error\"] as const;\ntype Severity = (typeof VALID_SEVERITY)[number];\n\nfunction isValidSeverity(severity: string): severity is Severity {\n return VALID_SEVERITY.includes(severity as Severity);\n}\n\ninterface ConfigAvailable {\n exists: boolean;\n emptyEslint?: boolean;\n emptyPkgJsonConfig?: boolean;\n firstTimeSetup?: true;\n}\n\nexport interface EventLintCheckCompleted {\n durationInSeconds: number;\n eslintVersion: string | null;\n lintedFilesCount?: number;\n lintFix?: boolean;\n buildLint?: boolean;\n eslintPluginErrorsCount?: number;\n eslintPluginWarningsCount?: number;\n stormStackRulesEnabled: {\n [ruleName: `powerlines/${string}`]: \"off\" | \"warn\" | \"error\";\n };\n}\n\n/**\n * Create a file with eslint output data\n */\nasync function writeOutputFile(\n log: LogFn,\n /** The name file that needs to be created */\n outputFile: string,\n /** The data that needs to be inserted into the file */\n outputData: string\n): Promise<void> {\n const filePath = path.resolve(process.cwd(), outputFile);\n\n if (isDirectory(filePath)) {\n log(\n LogLevelLabel.ERROR,\n `Cannot write to output file path, it is a directory: ${filePath}`\n );\n } else {\n try {\n await writeFile(log, filePath, outputData);\n\n log(LogLevelLabel.INFO, `The output file has been created: ${filePath}`);\n } catch (err) {\n log(\n LogLevelLabel.ERROR,\n `There was a problem writing the output file: ${filePath}`\n );\n // eslint-disable-next-line no-console\n console.error(err);\n }\n }\n}\n\nasync function hasEslintConfiguration(\n eslintFile: string | null,\n packageJsonConfig: { eslintConfig?: any } | null\n): Promise<ConfigAvailable> {\n const configObject = {\n exists: false,\n emptyEslint: false,\n emptyPkgJsonConfig: false\n };\n\n if (eslintFile) {\n const content = await readFile(eslintFile).then(\n txt => txt.trim().replace(/\\n/g, \"\"),\n () => null\n );\n\n if (\n content === \"\" ||\n content === \"{}\" ||\n content === \"---\" ||\n content === \"module.exports = {}\"\n ) {\n configObject.emptyEslint = true;\n } else {\n configObject.exists = true;\n }\n } else if (packageJsonConfig?.eslintConfig) {\n if (Object.keys(packageJsonConfig.eslintConfig).length) {\n configObject.exists = true;\n } else {\n configObject.emptyPkgJsonConfig = true;\n }\n }\n return configObject;\n}\n\nconst lint = async (\n log: LogFn,\n context: Context,\n eslintConfigPath: string | null,\n {\n lintDuringBuild = false,\n eslintOptions = null,\n reportErrorsOnly = false,\n maxWarnings = -1,\n formatter = null,\n outputFile = null\n }: {\n lintDuringBuild: boolean;\n eslintOptions: any;\n reportErrorsOnly: boolean;\n maxWarnings: number;\n formatter: string | null;\n outputFile: string | null;\n }\n): Promise<\n | string\n | null\n | {\n output: string | null;\n isError: boolean;\n eventInfo: EventLintCheckCompleted;\n }\n> => {\n try {\n // Load ESLint after we're sure it exists:\n await installPackages(context, [\n { name: \"eslint\", dev: true },\n { name: \"eslint-config-powerlines\", dev: true }\n ]);\n\n const isInstalled = isPackageExists(\"eslint\", {\n paths: [context.workspaceConfig.workspaceRoot, context.config.projectRoot]\n });\n if (!isInstalled) {\n log(\n LogLevelLabel.ERROR,\n `ESLint must be installed${\n lintDuringBuild ? \" in order to run during builds:\" : \":\"\n } npm install --save-dev eslint`\n );\n\n return null;\n }\n\n const module = await context.resolver.import<typeof import(\"eslint\")>(\n context.resolver.esmResolve(\"eslint\")\n );\n\n // If V9 config was found, use flat config, or else use legacy.\n const useFlatConfig = eslintConfigPath\n ? // eslintConfigPath is absolute path\n findFileName(eslintConfigPath).startsWith(\"eslint.config.\")\n : false;\n\n let ESLint!: typeof FlatESLint | typeof LegacyESLint;\n // loadESLint is >= 8.57.0\n // PR https://github.com/eslint/eslint/pull/18098\n // Release https://github.com/eslint/eslint/releases/tag/v8.57.0\n if (\"loadESLint\" in module) {\n // By default, configType is `flat`. If `useFlatConfig` is false, the return value is `LegacyESLint`.\n // https://github.com/eslint/eslint/blob/1def4cdfab1f067c5089df8b36242cdf912b0eb6/lib/types/index.d.ts#L1609-L1613\n ESLint = await module.loadESLint({\n useFlatConfig\n });\n }\n\n const eslintVersion = parseVersion(ESLint?.version);\n\n if (!eslintVersion || eslintVersion.compare(\"8.57.0\") < 0) {\n return `Error - Your project has an older version of ESLint installed${\n eslintVersion\n ? ` (${eslintVersion.major}.${eslintVersion.minor}.${eslintVersion.patch})`\n : \"\"\n }. Please upgrade to ESLint version 8.57.0 or above`;\n }\n\n const options: any = {\n useEslintrc: true,\n baseConfig: {},\n errorOnUnmatchedPattern: false,\n extensions: [\".js\", \".jsx\", \".ts\", \".tsx\"],\n cache: true,\n ...eslintOptions\n };\n\n if (eslintVersion?.compare(\"9.0.0\") && useFlatConfig) {\n for (const option of [\n \"useEslintrc\",\n \"extensions\",\n \"ignorePath\",\n \"reportUnusedDisableDirectives\",\n \"resolvePluginsRelativeTo\",\n \"rulePaths\",\n \"inlineConfig\",\n \"maxWarnings\"\n ]) {\n if (option in options) {\n delete options[option];\n }\n }\n }\n\n let eslint = new ESLint(options);\n\n let stormStackEslintPluginIsEnabled = false;\n const stormStackRulesEnabled = new Map<string, Severity>();\n\n for (const configFile of [\n eslintConfigPath,\n joinPaths(context.config.projectRoot, \"package.json\")\n ]) {\n if (!configFile) continue;\n\n const completeConfig: Config | undefined =\n await eslint.calculateConfigForFile(configFile);\n if (!completeConfig) continue;\n\n const plugins = completeConfig.plugins;\n\n const hasStormStackPlugin =\n // in ESLint < 9, `plugins` value is string[]\n Array.isArray(plugins)\n ? plugins.includes(\"powerlines\")\n : // in ESLint >= 9, `plugins` value is Record<string, unknown>\n \"powerlines\" in plugins;\n\n if (hasStormStackPlugin) {\n stormStackEslintPluginIsEnabled = true;\n for (const [name, [severity]] of Object.entries(completeConfig.rules)) {\n if (!name.startsWith(\"powerlines/\")) {\n continue;\n }\n if (\n typeof severity === \"number\" &&\n severity >= 0 &&\n severity < VALID_SEVERITY.length\n ) {\n stormStackRulesEnabled.set(name, VALID_SEVERITY[severity]!);\n } else if (\n typeof severity === \"string\" &&\n isValidSeverity(severity)\n ) {\n stormStackRulesEnabled.set(name, severity);\n }\n }\n break;\n }\n }\n\n if (stormStackEslintPluginIsEnabled) {\n eslint = new ESLint(options);\n } else {\n log(\n LogLevelLabel.WARN,\n \"The Powerlines plugin was not detected in your ESLint configuration. See https://nextjs.org/docs/app/api-reference/config/eslint#migrating-existing-config\"\n );\n }\n\n const lintStart = process.hrtime();\n\n let results = await eslint.lintFiles(\n context.tsconfig.fileNames.filter(\n fileName =>\n !fileName.includes(context.artifactsPath) &&\n !fileName.includes(\"node_modules\")\n )\n );\n\n let selectedFormatter = null as FlatESLint.Formatter | null;\n if (options.fix) {\n await ESLint.outputFixes(results);\n }\n if (reportErrorsOnly) {\n results = ESLint.getErrorResults(results);\n }\n\n if (formatter) {\n selectedFormatter = await eslint.loadFormatter(formatter);\n }\n\n const formattedResult = await formatResults(\n context.config.projectRoot,\n results,\n selectedFormatter?.format?.bind(selectedFormatter) as Parameters<\n typeof formatResults\n >[2]\n );\n const lintEnd = process.hrtime(lintStart);\n const totalWarnings = results.reduce(\n (sum: number, file: LintResult) => sum + file.warningCount,\n 0\n );\n\n if (outputFile) {\n await writeOutputFile(log, outputFile, formattedResult.output);\n }\n\n return {\n output: formattedResult.outputWithMessages,\n isError:\n ESLint.getErrorResults(results)?.length > 0 ||\n (maxWarnings >= 0 && totalWarnings > maxWarnings),\n eventInfo: {\n durationInSeconds: lintEnd[0],\n eslintVersion: eslintVersion.version,\n lintedFilesCount: results.length,\n lintFix: !!options.fix,\n eslintPluginErrorsCount: formattedResult.totalPluginErrorCount,\n eslintPluginWarningsCount: formattedResult.totalPluginWarningCount,\n stormStackRulesEnabled: Object.fromEntries(stormStackRulesEnabled)\n }\n };\n } catch (err) {\n if (lintDuringBuild) {\n log(\n LogLevelLabel.ERROR,\n `ESLint: ${\n isError(err) && err.message\n ? err.message.replace(/\\n/g, \" \")\n : String(err)\n }`\n );\n return null;\n } else {\n throw err;\n }\n }\n};\n\nexport async function eslint(\n context: Context,\n lintDuringBuild = false,\n opts: ESLintConfig = {}\n): ReturnType<typeof lint> {\n const {\n eslintOptions = null,\n reportErrorsOnly = false,\n maxWarnings = -1,\n formatter = null,\n outputFile = null,\n type = \"recommended\"\n } = opts;\n\n // Find user's .eslintrc file\n // See: https://eslint.org/docs/user-guide/configuring/configuration-files#configuration-file-formats\n const eslintFile =\n getParentPath(\n [\n // eslint v9\n \"eslint.config.js\",\n \"eslint.config.mjs\",\n \"eslint.config.cjs\",\n // TS extensions require to install a separate package `jiti`.\n // https://eslint.org/docs/latest/use/configure/configuration-files#typescript-configuration-files\n \"eslint.config.ts\",\n \"eslint.config.mts\",\n \"eslint.config.cts\",\n // eslint <= v8\n \".eslintrc.js\",\n \".eslintrc.cjs\",\n \".eslintrc.yaml\",\n \".eslintrc.yml\",\n \".eslintrc.json\",\n \".eslintrc\"\n ],\n context.config.projectRoot\n ) ?? null;\n\n const config = await hasEslintConfiguration(\n eslintFile,\n context.packageJson as { eslintConfig?: any }\n );\n\n if (config.exists) {\n // Run if ESLint config exists\n return lint(context.log, context, eslintFile, {\n lintDuringBuild,\n eslintOptions,\n reportErrorsOnly,\n maxWarnings,\n formatter,\n outputFile\n });\n }\n\n // Display warning if no ESLint configuration is present inside\n // config file during \"storm build\", no warning is shown when\n // no eslintrc file is present\n if (lintDuringBuild) {\n if (config.emptyPkgJsonConfig || config.emptyEslint) {\n context.log(\n LogLevelLabel.WARN,\n `No ESLint configuration detected. Run \"storm lint\" to begin setup`\n );\n }\n\n return null;\n } else {\n // Check if necessary deps installed, and install any that are missing\n const isEslintInstalled = isPackageExists(\"eslint\", {\n paths: [context.workspaceConfig.workspaceRoot, context.config.projectRoot]\n });\n const isEslintPluginInstalled = isPackageExists(\n \"eslint-config-powerlines\",\n {\n paths: [\n context.workspaceConfig.workspaceRoot,\n context.config.projectRoot\n ]\n }\n );\n\n if (!isEslintInstalled || !isEslintPluginInstalled) {\n await installPackages(context, [\n { name: \"eslint\", dev: true },\n { name: \"eslint-config-powerlines\", dev: true }\n ]);\n }\n\n // Write default ESLint config.\n await writeDefaultEslintConfig(context.log, context, type);\n }\n\n context.log(\n LogLevelLabel.SUCCESS,\n `ESLint has successfully been configured. Run \"storm lint\" again to view warnings and errors.`\n );\n\n return null;\n}\n","/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { readFileIfExistingSync } from \"@stryke/fs/read-file\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { isString } from \"@stryke/type-checks/is-string\";\nimport MagicString from \"magic-string\";\nimport { TransformResult } from \"unplugin\";\nimport { SourceFile } from \"../../types/compiler\";\n\n/**\n * Get the string from the source.\n *\n * @param code - The source string or magic string.\n * @returns The source string.\n */\nexport function getString(\n code: string | MagicString | TransformResult\n): string {\n if (!code) {\n return \"\";\n }\n\n if (isString(code)) {\n return code;\n }\n\n if (isSetObject(code) && \"code\" in code) {\n return code.code;\n }\n\n return code.toString();\n}\n\n/**\n * Get the magic string.\n *\n * @param code - The source string or magic string.\n * @returns The magic string.\n */\nexport function getMagicString(code: string | MagicString): MagicString {\n if (isString(code)) {\n return new MagicString(code);\n }\n\n return code;\n}\n\n/**\n * Get the source file.\n *\n * @param code - The source code.\n * @param id - The name of the file.\n * @returns The source file.\n */\nexport function getSourceFile(\n code: string | MagicString,\n id: string\n): SourceFile {\n const content = code ?? readFileIfExistingSync(id);\n\n return {\n id,\n code: getMagicString(content),\n env: []\n };\n}\n","/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { match } from \"bundle-require\";\nimport type { ExternalIdResult } from \"unplugin\";\nimport type { Context } from \"../../types/context\";\n\n// Must not start with \"/\" or \"./\" or \"../\" or \"C:\\\" or be the exact strings \"..\" or \".\"\nconst NON_NODE_MODULE_REGEX = /^[A-Z]:[/\\\\]|^\\.{0,2}\\/|^\\.{1,2}$/;\n\nexport interface ResolveIdArgs {\n id: string;\n importer: string | undefined;\n options: {\n isEntry: boolean;\n };\n}\n\nexport interface ResolveIdOptions {\n skipResolve?: boolean;\n skipNodeModulesBundle?: boolean;\n external: (string | RegExp)[];\n noExternal: (string | RegExp)[];\n resolvePatterns: (string | RegExp)[];\n}\n\n/**\n * Handle the resolveId hook for the unplugin.\n *\n * @param context - The plugin context.\n * @param args - The arguments for the hook.\n * @param options - The options for the hook.\n * @returns The resolved id or null if not found.\n */\nexport async function handleResolveId(\n context: Context,\n args: ResolveIdArgs,\n options: Partial<ResolveIdOptions> = {}\n): Promise<ExternalIdResult | null | undefined> {\n if (args.id) {\n if (\n context.fs.isVirtualFile(args.id) ||\n (args.importer &&\n context.fs.isVirtualFile(args.id, {\n paths: [args.importer]\n }))\n ) {\n const resolvedPath = args.importer\n ? context.fs.resolvePath(args.id, {\n paths: [args.importer]\n })\n : context.fs.resolvePath(args.id);\n if (resolvedPath) {\n return {\n id: resolvedPath,\n external: context.config.projectType !== \"application\"\n };\n }\n }\n\n if (context.fs.isTsconfigPath(args.id)) {\n const tsconfigPath = context.fs.resolveTsconfigPath(args.id);\n const tsconfigPathPackage = context.fs.resolveTsconfigPathPackage(\n args.id\n );\n if (tsconfigPath && tsconfigPathPackage) {\n return {\n id: tsconfigPath,\n external: Boolean(\n !options.noExternal?.includes(tsconfigPathPackage) &&\n (options.external?.includes(tsconfigPathPackage) ??\n context.config.projectType !== \"application\")\n )\n };\n }\n }\n\n if (options.skipResolve) {\n return undefined;\n }\n\n if (options.skipNodeModulesBundle) {\n if (\n match(args.id, options.resolvePatterns) ||\n match(args.id, options.noExternal) ||\n args.id.startsWith(\"internal:\") ||\n args.id.startsWith(\"virtual:\")\n ) {\n return undefined;\n }\n\n if (match(args.id, options.external) || args.id.startsWith(\"node:\")) {\n return { id: args.id, external: true };\n }\n\n // Exclude any other import that looks like a Node module\n if (!NON_NODE_MODULE_REGEX.test(args.id)) {\n return {\n id: args.id,\n external: true\n };\n }\n } else {\n if (\n match(args.id, options.noExternal) ||\n context.fs.isBuiltinFile(args.id) ||\n (args.importer &&\n context.fs.isBuiltinFile(args.id, {\n paths: [args.importer]\n }))\n ) {\n return undefined;\n }\n\n if (match(args.id, options.external) || args.id.startsWith(\"node:\")) {\n return { id: args.id, external: true };\n }\n }\n }\n\n return undefined;\n}\n","/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { LogLevelLabel } from \"@storm-software/config-tools/types\";\nimport defu from \"defu\";\nimport type {\n ExternalIdResult,\n TransformResult,\n UnpluginBuildContext,\n UnpluginContext,\n UnpluginFactory\n} from \"unplugin\";\n// eslint-disable-next-line camelcase\nimport { Internal_PluginContext, PluginContext } from \"../../types/context\";\nimport { extendLog } from \"../logger\";\nimport { getString } from \"../utilities/source-file\";\nimport { handleResolveId } from \"./resolve-id\";\n\nexport interface CreateUnpluginOptions {\n /**\n * If true, skips the plugin resolution step.\n *\n * @remarks\n * This value should be set to `true` when using a build tool that handles `external` and `noExternal` options itself (for example `tsup`).\n *\n * @defaultValue false\n */\n skipResolve?: boolean;\n}\n\n/**\n * Creates a Powerlines unplugin instance.\n *\n * @param context - The plugin context.\n * @param options - Options for creating the unplugin.\n * @returns The unplugin instance.\n */\nexport function createUnplugin<TContext extends PluginContext = PluginContext>(\n context: TContext,\n options: CreateUnpluginOptions = {}\n): UnpluginFactory<object> {\n // eslint-disable-next-line camelcase\n const ctx = context as unknown as Internal_PluginContext;\n\n return () => {\n const log = extendLog(ctx.log, \"unplugin\");\n log(LogLevelLabel.DEBUG, \"Initializing Unplugin\");\n\n try {\n async function buildStart(this: UnpluginBuildContext) {\n log(LogLevelLabel.DEBUG, \"Powerlines build plugin starting...\");\n\n await ctx.$$internal.callHook(\"buildStart\", {\n sequential: true\n });\n }\n\n async function resolveId(\n this: UnpluginBuildContext & UnpluginContext,\n id: string,\n importer?: string,\n opts: {\n isEntry: boolean;\n } = { isEntry: false }\n ): Promise<string | ExternalIdResult | null | undefined> {\n let result = await ctx.$$internal.callHook(\n \"resolveId\",\n {\n sequential: true,\n result: \"first\",\n order: \"pre\"\n },\n id,\n importer,\n opts\n );\n if (result) {\n return result;\n }\n\n result = await ctx.$$internal.callHook(\n \"resolveId\",\n {\n sequential: true,\n result: \"first\",\n order: \"normal\"\n },\n id,\n importer,\n opts\n );\n if (result) {\n return result;\n }\n\n result = await handleResolveId(\n ctx,\n {\n id,\n importer,\n options: opts\n },\n {\n skipResolve: options.skipResolve,\n skipNodeModulesBundle: ctx.config.build.skipNodeModulesBundle,\n external: ctx.config.build.external,\n noExternal: ctx.config.build.noExternal\n }\n );\n if (result) {\n return result;\n }\n\n return ctx.$$internal.callHook(\n \"resolveId\",\n {\n sequential: true,\n result: \"first\",\n order: \"post\"\n },\n id,\n importer,\n opts\n );\n }\n\n async function load(\n this: UnpluginBuildContext & UnpluginContext,\n id: string\n ): Promise<TransformResult | null | undefined> {\n let result = await ctx.$$internal.callHook(\n \"load\",\n {\n sequential: true,\n result: \"first\",\n order: \"pre\"\n },\n id\n );\n if (result) {\n return result;\n }\n\n result = await ctx.$$internal.callHook(\n \"load\",\n {\n sequential: true,\n result: \"first\",\n order: \"normal\"\n },\n id\n );\n if (result) {\n return result;\n }\n\n if (id) {\n const resolvedPath = ctx.fs.resolvePath(id, {\n type: \"file\"\n });\n if (resolvedPath) {\n return ctx.fs.readFile(resolvedPath);\n }\n }\n\n return ctx.$$internal.callHook(\n \"load\",\n {\n sequential: true,\n result: \"first\",\n order: \"post\"\n },\n id\n );\n }\n\n async function transform(\n this: UnpluginBuildContext & UnpluginContext,\n code: string,\n id: string\n ): Promise<TransformResult | null | undefined> {\n let transformed: TransformResult | string = code;\n\n for (const handler of ctx.$$internal.environment.selectHooks(\n \"transform\"\n )) {\n const result: TransformResult | string | undefined =\n await handler.apply(defu(ctx, this), [getString(transformed), id]);\n if (result) {\n transformed = result;\n }\n }\n\n return transformed;\n }\n\n async function buildEnd(this: UnpluginBuildContext): Promise<void> {\n log(LogLevelLabel.DEBUG, \"Powerlines build plugin finishing...\");\n\n return ctx.$$internal.callHook(\"buildEnd\", {\n sequential: true\n });\n }\n\n async function writeBundle(): Promise<void> {\n log(LogLevelLabel.DEBUG, \"Finalizing Powerlines project output...\");\n\n return ctx.$$internal.callHook(\"writeBundle\", {\n sequential: true\n });\n }\n\n return {\n name: \"powerlines\",\n resolveId: {\n filter: {\n id: {\n include: [/.*/]\n }\n },\n handler: resolveId\n },\n load: {\n filter: {\n id: {\n include: [/.*/, /^storm:/]\n }\n },\n handler: load\n },\n transform,\n buildStart,\n buildFinish: buildEnd,\n writeBundle,\n vite: {\n sharedDuringBuild: true\n }\n };\n } catch (error) {\n log(LogLevelLabel.FATAL, (error as Error)?.message);\n\n throw error;\n }\n };\n}\n","/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { createUnplugin } from \"powerlines/lib/unplugin\";\nimport { createEsbuildPlugin } from \"unplugin\";\nimport { ESBuildPluginContext } from \"../types/plugin\";\n\nexport function createESBuildPlugin(context: ESBuildPluginContext) {\n return createEsbuildPlugin(\n createUnplugin(context, {\n skipResolve: true\n })\n )({});\n}\n"]}
@@ -1,3 +0,0 @@
1
-
2
- //# sourceMappingURL=chunk-DXDH2OBY.js.map
3
- //# sourceMappingURL=chunk-DXDH2OBY.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"chunk-DXDH2OBY.js"}
@@ -1,3 +0,0 @@
1
-
2
- //# sourceMappingURL=chunk-EWDQEFTW.js.map
3
- //# sourceMappingURL=chunk-EWDQEFTW.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"chunk-EWDQEFTW.js"}