@shopify/cli-kit 3.86.1 → 3.87.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.
- package/README.md +2 -1
- package/dist/cli/api/graphql/admin/generated/theme_files_upsert.d.ts +1 -0
- package/dist/cli/api/graphql/admin/generated/theme_files_upsert.js +1 -0
- package/dist/cli/api/graphql/admin/generated/theme_files_upsert.js.map +1 -1
- package/dist/private/node/analytics.d.ts +1 -0
- package/dist/private/node/analytics.js +4 -0
- package/dist/private/node/analytics.js.map +1 -1
- package/dist/private/node/api.d.ts +24 -0
- package/dist/private/node/api.js +42 -4
- package/dist/private/node/api.js.map +1 -1
- package/dist/private/node/session/device-authorization.js +47 -8
- package/dist/private/node/session/device-authorization.js.map +1 -1
- package/dist/private/node/session/exchange.js +1 -1
- package/dist/private/node/session/exchange.js.map +1 -1
- package/dist/public/common/json.d.ts +17 -0
- package/dist/public/common/json.js +28 -0
- package/dist/public/common/json.js.map +1 -0
- package/dist/public/common/version.d.ts +1 -1
- package/dist/public/common/version.js +1 -1
- package/dist/public/common/version.js.map +1 -1
- package/dist/public/node/api/admin.js +8 -2
- package/dist/public/node/api/admin.js.map +1 -1
- package/dist/public/node/archiver.js +34 -14
- package/dist/public/node/archiver.js.map +1 -1
- package/dist/public/node/base-command.js +18 -0
- package/dist/public/node/base-command.js.map +1 -1
- package/dist/public/node/custom-oclif-loader.js +24 -19
- package/dist/public/node/custom-oclif-loader.js.map +1 -1
- package/dist/public/node/fs.d.ts +15 -0
- package/dist/public/node/fs.js +25 -0
- package/dist/public/node/fs.js.map +1 -1
- package/dist/public/node/git.js +56 -49
- package/dist/public/node/git.js.map +1 -1
- package/dist/public/node/hooks/postrun.d.ts +6 -0
- package/dist/public/node/hooks/postrun.js +10 -0
- package/dist/public/node/hooks/postrun.js.map +1 -1
- package/dist/public/node/import-extractor.d.ts +27 -0
- package/dist/public/node/import-extractor.js +178 -0
- package/dist/public/node/import-extractor.js.map +1 -0
- package/dist/public/node/metadata.d.ts +3 -0
- package/dist/public/node/monorail.d.ts +2 -1
- package/dist/public/node/monorail.js +1 -1
- package/dist/public/node/monorail.js.map +1 -1
- package/dist/public/node/node-package-manager.js +3 -2
- package/dist/public/node/node-package-manager.js.map +1 -1
- package/dist/public/node/themes/api.js +4 -0
- package/dist/public/node/themes/api.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fs.js","sourceRoot":"","sources":["../../../src/public/node/fs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAE,aAAa,EAAC,MAAM,WAAW,CAAA;AACjD,OAAO,EAAC,aAAa,EAAE,WAAW,EAAE,WAAW,EAAC,MAAM,6BAA6B,CAAA;AACnF,OAAO,EAAC,aAAa,EAAmB,MAAM,qBAAqB,CAAA;AAEnE,OAAO,EACL,IAAI,IAAI,MAAM,EACd,UAAU,IAAI,YAAY,EAC1B,cAAc,IAAI,gBAAgB,EAClC,MAAM,IAAI,QAAQ,EAClB,UAAU,IAAI,YAAY,EAC1B,IAAI,IAAI,MAAM;AACd,6DAA6D;AAC7D,aAAa;EACd,MAAM,cAAc,CAAA;AAErB,OAAO,EAAC,kBAAkB,EAAE,sBAAsB,EAAC,MAAM,OAAO,CAAA;AAChE,OAAO,EAAC,GAAG,EAAE,IAAI,EAAC,MAAM,OAAO,CAAA;AAC/B,OAAO,EAAC,MAAM,IAAI,cAAc,EAAC,MAAM,SAAS,CAAA;AAChD,OAAO,EAAC,SAAS,EAAC,MAAM,WAAW,CAAA;AACnC,OAAO,EACL,SAAS,IAAI,WAAW,EACxB,YAAY,IAAI,cAAc,EAC9B,aAAa,IAAI,eAAe,EAChC,cAAc,IAAI,gBAAgB,EAClC,QAAQ,IAAI,UAAU,EACtB,gBAAgB,IAAI,kBAAkB,EACtC,iBAAiB,IAAI,mBAAmB,EACxC,SAAS,IAAI,WAAW,EACxB,UAAU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,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAA;QACnE,MAAM,QAAQ,GAAG,QAAQ,CAAC,OAAO,EAAE,YAAY,CAAC,CAAA;QAEhD,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAA;IAC5C,CAAC;IAED,MAAM,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,CAAA;AAChC,CAAC","sourcesContent":["import {joinPath, normalizePath} from './path.js'\nimport {outputContent, outputToken, outputDebug} from '../../public/node/output.js'\nimport {getRandomName, RandomNameFamily} from '../common/string.js'\nimport {OverloadParameters} from '../../private/common/ts/overloaded-parameters.js'\nimport {\n copy as fsCopy,\n ensureFile as fsEnsureFile,\n ensureFileSync as fsEnsureFileSync,\n remove as fsRemove,\n removeSync as fsRemoveSync,\n move as fsMove,\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n} from 'fs-extra/esm'\n\nimport {temporaryDirectory, temporaryDirectoryTask} from 'tempy'\nimport {sep, join} from 'pathe'\nimport {findUp as internalFindUp} from 'find-up'\nimport {minimatch} from 'minimatch'\nimport {\n mkdirSync as fsMkdirSync,\n readFileSync as fsReadFileSync,\n writeFileSync as fsWriteFileSync,\n appendFileSync as fsAppendFileSync,\n statSync as fsStatSync,\n createReadStream as fsCreateReadStream,\n createWriteStream as fsCreateWriteStream,\n constants as fsConstants,\n existsSync as fsFileExistsSync,\n unlinkSync as fsUnlinkSync,\n accessSync,\n ReadStream,\n WriteStream,\n statSync,\n} from 'fs'\nimport {\n mkdir as fsMkdir,\n writeFile as fsWriteFile,\n readFile as fsReadFile,\n realpath as fsRealPath,\n appendFile as fsAppendFile,\n mkdtemp as fsMkdtemp,\n stat as fsStat,\n lstat as fsLstat,\n chmod as fsChmod,\n access as fsAccess,\n rename as fsRename,\n unlink as fsUnlink,\n readdir as fsReaddir,\n} from 'fs/promises'\nimport {pathToFileURL as pathToFile} from 'url'\nimport * as os from 'os'\nimport type {Pattern, Options as GlobOptions} from 'fast-glob'\n\n/**\n * Strip the first `strip` parts of the path.\n *\n * @param path - Path to strip.\n * @param strip - Number of parts to strip.\n * @returns The stripped path.\n */\nexport function stripUpPath(path: string, strip: number): string {\n const parts = path.split(sep)\n return join(...parts.slice(strip))\n}\n\n/**\n * Creates a temporary directory and ties its lifecycle to the lifecycle of the callback.\n *\n * @param callback - The callback that receives the temporary directory.\n */\nexport async function inTemporaryDirectory<T>(callback: (tmpDir: string) => T | Promise<T>): Promise<T> {\n return temporaryDirectoryTask(callback)\n}\n\n/**\n * Return a temporary directory\n * @returns - The path to the temporary directory.\n */\nexport function tempDirectory(): string {\n return temporaryDirectory()\n}\n\n/**\n * It reads a file and returns its content as a string using the\n * utf-8 encoding.\n *\n * @param path - Path to the file to read.\n * @returns A promise that resolves with the content of the file.\n */\n\nexport type ReadOptions =\n | undefined\n | {flag?: string | undefined}\n | {\n encoding: string\n flag?: string | undefined\n }\nexport async function readFile(path: string, options?: ReadOptions): Promise<string>\nexport async function readFile(path: string, options?: ReadOptions): Promise<Buffer>\n\n/**\n * It reads a file and returns its content as a string.\n * Uses utf-8 encoding by default.\n *\n * @param path - Path to the file to read.\n * @param options - Options to read the file with (defaults to utf-8 encoding).\n * @returns A promise that resolves with the content of the file.\n */\nexport async function readFile(path: string, options: ReadOptions = {encoding: 'utf8'}): Promise<string | Buffer> {\n outputDebug(outputContent`Reading the content of file at ${outputToken.path(path)}...`)\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n return fsReadFile(path, options)\n}\n\n/**\n * Synchronously reads a file and returns its content as a buffer.\n *\n * @param path - Path to the file to read.\n * @returns The content of the file.\n */\nexport function readFileSync(path: string): Buffer {\n outputDebug(outputContent`Sync-reading the content of file at ${outputToken.path(path)}...`)\n return fsReadFileSync(path)\n}\n\n/**\n * Given a path, it determines the actual path. This is useful when working\n * with paths that represent symlinks.\n *\n * @param path - Path whose real path will be returned.\n */\nexport async function fileRealPath(path: string): Promise<string> {\n return fsRealPath(path)\n}\n\n/**\n * Copies a file.\n *\n * @param from - Path to the directory or file to be copied.\n * @param to - Destination path.\n */\nexport async function copyFile(from: string, to: string): Promise<void> {\n outputDebug(outputContent`Copying file from ${outputToken.path(from)} to ${outputToken.path(to)}...`)\n await fsCopy(from, to)\n}\n\n/**\n * Creates a file at the given path.\n *\n * @param path - Path to the file to be created.\n */\nexport async function touchFile(path: string): Promise<void> {\n outputDebug(outputContent`Creating an empty file at ${outputToken.path(path)}...`)\n await fsEnsureFile(path)\n}\n\n/**\n * Synchronously creates a file at the given path.\n *\n * @param path - Path to the file to be created.\n */\nexport function touchFileSync(path: string): void {\n outputDebug(outputContent`Creating an empty file at ${outputToken.path(path)}...`)\n fsEnsureFileSync(path)\n}\n\n/**\n * Appnds content to file at path.\n *\n * @param path - Path to the file to be appended.\n * @param content - Content to be appended.\n */\nexport async function appendFile(path: string, content: string): Promise<void> {\n outputDebug(outputContent`Appending the following content to ${outputToken.path(path)}:\n ${content\n .split('\\n')\n .map((line) => ` ${line}`)\n .join('\\n')}\n `)\n await fsAppendFile(path, content)\n}\n\n/**\n * Synchronously appends content to file at path.\n *\n * @param path - Path to the file to be appended.\n * @param data - Content to be appended.\n */\nexport function appendFileSync(path: string, data: string): void {\n fsAppendFileSync(path, data)\n}\n\nexport interface WriteOptions {\n encoding: BufferEncoding\n}\n\n/**\n * Writes content to file at path.\n *\n * @param path - Path to the file to be written.\n * @param data - Content to be written.\n * @param options - Options to write the file with (defaults to utf-8 encoding).\n */\nexport async function writeFile(\n path: string,\n data: string | Buffer,\n options: WriteOptions = {encoding: 'utf8'},\n): Promise<void> {\n outputDebug(outputContent`Writing some content to file at ${outputToken.path(path)}...`)\n await fsWriteFile(path, data, options)\n}\n\n/**\n * Synchronously writes content to file at path.\n *\n * @param path - Path to the file to be written.\n * @param data - Content to be written.\n */\nexport function writeFileSync(path: string, data: string): void {\n outputDebug(outputContent`File-writing some content to file at ${outputToken.path(path)}...`)\n fsWriteFileSync(path, data)\n}\n\n/**\n * Creates a directory at the given path.\n *\n * @param path - Path to the directory to be created.\n */\nexport async function mkdir(path: string): Promise<void> {\n outputDebug(outputContent`Creating directory at ${outputToken.path(path)}...`)\n await fsMkdir(path, {recursive: true})\n}\n\n/**\n * Synchronously creates a directory at the given path.\n *\n * @param path - Path to the directory to be created.\n */\nexport function mkdirSync(path: string): void {\n outputDebug(outputContent`Sync-creating directory at ${outputToken.path(path)}...`)\n fsMkdirSync(path, {recursive: true})\n}\n\n/**\n * Removes a file at the given path.\n *\n * @param path - Path to the file to be removed.\n */\nexport async function removeFile(path: string): Promise<void> {\n outputDebug(outputContent`Removing file at ${outputToken.path(path)}...`)\n await fsRemove(path)\n}\n\n/**\n * Renames a file.\n * @param from - Path to the file to be renamed.\n * @param to - New path for the file.\n */\nexport async function renameFile(from: string, to: string): Promise<void> {\n outputDebug(outputContent`Renaming file from ${outputToken.path(from)} to ${outputToken.path(to)}...`)\n await fsRename(from, to)\n}\n\n/**\n * Synchronously removes a file at the given path.\n *\n * @param path - Path to the file to be removed.\n */\nexport function removeFileSync(path: string): void {\n outputDebug(outputContent`Sync-removing file at ${outputToken.path(path)}...`)\n fsRemoveSync(path)\n}\n\ninterface RmDirOptions {\n force?: boolean\n}\n/**\n * Removes a directory at the given path.\n *\n * @param path - Path to the directory to be removed.\n * @param options - Options to remove the directory with.\n */\nexport async function rmdir(path: string, options: RmDirOptions = {}): Promise<void> {\n const {default: del} = await import('del')\n outputDebug(outputContent`Removing directory at ${outputToken.path(path)}...`)\n await del(path, {force: options.force})\n}\n\n/**\n * Create a temporary directory within the OS provided location for temp directories\n *\n * @returns Path to the temporary directory.\n */\nexport async function mkTmpDir(): Promise<string> {\n outputDebug(outputContent`Creating a temporary directory...`)\n const directory = await fsMkdtemp(joinPath(os.tmpdir(), 'tmp-'))\n return directory\n}\n\n/**\n * Check whether a path is a directory.\n *\n * @param path - Path to check.\n * @returns True if the path is a directory, false otherwise.\n */\nexport async function isDirectory(path: string): Promise<boolean> {\n outputDebug(outputContent`Checking if ${outputToken.path(path)} is a directory...`)\n return (await fsLstat(path)).isDirectory()\n}\n\n/**\n * Get the size of a file.\n *\n * @param path - Path to the file.\n * @returns The size of the file in bytes.\n */\nexport async function fileSize(path: string): Promise<number> {\n outputDebug(outputContent`Getting the size of file file at ${outputToken.path(path)}...`)\n return (await fsStat(path)).size\n}\n\n/**\n * Synchronously get the size of a file.\n *\n * @param path - Path to the file.\n * @returns The size of the file in bytes.\n */\nexport function fileSizeSync(path: string): number {\n outputDebug(outputContent`Sync-getting the size of file file at ${outputToken.path(path)}...`)\n return fsStatSync(path).size\n}\n\n/**\n * Synchronously unlink a file at the given path.\n *\n * @param path - Path to the file.\n */\nexport function unlinkFileSync(path: string): void {\n fsUnlinkSync(path)\n}\n\n/**\n * Unlink a file at the given path.\n *\n * @param path - Path to the file.\n * @returns A promise that resolves when the file is unlinked.\n */\nexport function unlinkFile(path: string): Promise<void> {\n return fsUnlink(path)\n}\n\n/**\n * Create a read stream for a file with optional options.\n *\n * @param path - Path to the file.\n * @param options - Options for the read stream.\n * @returns A read stream for the file.\n */\nexport function createFileReadStream(\n path: string,\n options?: {encoding?: BufferEncoding; start?: number; end?: number},\n): ReadStream {\n return fsCreateReadStream(path, options)\n}\n\n/**\n * Create a write stream for a file.\n *\n * @param path - Path to the file.\n * @returns A write stream for the file.\n */\nexport function createFileWriteStream(path: string): WriteStream {\n return fsCreateWriteStream(path)\n}\n\n/**\n * Returns the Date object for the last modification of a file.\n *\n * @param path - Path to the directory or file.\n * @returns A unix timestamp.\n */\nexport async function fileLastUpdated(path: string): Promise<Date> {\n outputDebug(outputContent`Getting last updated timestamp for file at ${outputToken.path(path)}...`)\n return (await fsStat(path)).ctime\n}\n\n/**\n * Returns the unix timestamp of the last modification of a file.\n *\n * @param path - Path to the directory or file.\n * @returns A unix timestamp.\n */\nexport async function fileLastUpdatedTimestamp(path: string): Promise<number | undefined> {\n try {\n const lastUpdatedDateTime = await fileLastUpdated(path)\n return lastUpdatedDateTime.getTime()\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch {\n return undefined\n }\n}\n\ninterface MoveFileOptions {\n overwrite?: boolean\n}\n\n/**\n * Moves a file.\n *\n * @param src - File to be moved.\n * @param dest - Path to be moved to.\n * @param options - Moving options.\n */\nexport async function moveFile(src: string, dest: string, options: MoveFileOptions = {}): Promise<void> {\n await fsMove(src, dest, options)\n}\n\n/**\n * Changes the permissions of a directory or file.\n *\n * @param path - Path to the file or directory whose permissions will be modified.\n * @param mode - Permissions to set to the file or directory.\n */\nexport async function chmod(path: string, mode: number | string): Promise<void> {\n await fsChmod(path, mode)\n}\n\n/**\n * Checks if a file has executable permissions.\n *\n * @param path - Path to the file whose permissions will be checked.\n */\nexport async function fileHasExecutablePermissions(path: string): Promise<boolean> {\n try {\n await fsAccess(path, fsConstants.X_OK)\n return true\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch {\n return false\n }\n}\n\nexport function fileHasWritePermissions(path: string): boolean {\n try {\n accessSync(path, fsConstants.W_OK)\n return true\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch {\n return false\n }\n}\n\nexport function unixFileIsOwnedByCurrentUser(path: string): boolean | undefined {\n // process.getuid() is only available on Unix-like systems\n if (process.platform === 'win32' || typeof process.getuid !== 'function') return undefined\n if (!fileExistsSync(path)) return false\n\n try {\n const stats = statSync(path)\n const currentUid = process.getuid()\n\n return stats.uid === currentUid\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch {\n return false\n }\n}\n\n/**\n * Returns true if a file or directory exists.\n *\n * @param path - Path to the directory or file.\n * @returns True if it exists.\n */\nexport async function fileExists(path: string): Promise<boolean> {\n try {\n await fsAccess(path)\n return true\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch {\n return false\n }\n}\n\nexport function fileExistsSync(path: string): boolean {\n return fsFileExistsSync(path)\n}\n\ninterface GenerateRandomDirectoryOptions {\n /** Suffix to include in the randomly generated directory name. */\n suffix: string\n\n /** Absolute path to the directory where the random directory will be created. */\n directory: string\n\n /** Type of word to use for random name. */\n family?: RandomNameFamily\n}\n\n/**\n * It generates a random directory directory name for a sub-directory.\n * It ensures that the returned directory name doesn't exist.\n *\n * @param options - Options to generate the random directory name.\n * @returns It returns the name of the directory.\n */\nexport async function generateRandomNameForSubdirectory(options: GenerateRandomDirectoryOptions): Promise<string> {\n const generated = `${getRandomName(options.family ?? 'business')}-${options.suffix}`\n const randomDirectoryPath = joinPath(options.directory, generated)\n const isAppDirectoryTaken = await fileExists(randomDirectoryPath)\n\n if (isAppDirectoryTaken) {\n return generateRandomNameForSubdirectory(options)\n } else {\n return generated\n }\n}\n\n/**\n * Traverse the file system and return pathnames that match the given pattern.\n *\n * @param pattern - A glob pattern or an array of glob patterns.\n * @param options - Options for the glob.\n * @returns A promise that resolves to an array of pathnames that match the given pattern.\n */\nexport async function glob(pattern: Pattern | Pattern[], options?: GlobOptions): Promise<string[]> {\n const {default: fastGlob} = await import('fast-glob')\n let overridenOptions = options\n if (options?.dot == null) {\n overridenOptions = {...options, dot: true}\n }\n return fastGlob(pattern, overridenOptions)\n}\n\n/**\n * Convert a path to a File URL.\n *\n * @param path - Path to convert.\n * @returns The File URL.\n */\nexport function pathToFileURL(path: string): URL {\n return pathToFile(path)\n}\n\n/**\n * The operating system-specific end-of-line marker:\n * - `\\n` on POSIX\n * - `\\r\\n` on Windows\n */\nexport type EOL = '\\r\\n' | '\\n'\n\n/**\n * Detects the end-of-line marker used in a string.\n *\n * @param content - file contents to analyze\n *\n * @returns The detected end-of-line marker\n */\nexport function detectEOL(content: string): EOL {\n const match = content.match(/\\r\\n|\\n/g)\n\n if (!match) {\n return defaultEOL()\n }\n\n const crlf = match.filter((eol) => eol === '\\r\\n').length\n const lf = match.filter((eol) => eol === '\\n').length\n\n return crlf > lf ? '\\r\\n' : '\\n'\n}\n\n/**\n * Returns the operating system's end-of-line marker.\n *\n * @returns The OS-specific end-of-line marker\n */\nexport function defaultEOL(): EOL {\n return os.EOL as EOL\n}\n\n/**\n * Find a file by walking parent directories.\n *\n * @param matcher - A pattern or an array of patterns to match a file name.\n * @param options - Options for the search.\n * @returns The first path found that matches or `undefined` if none could be found.\n */\nexport async function findPathUp(\n matcher: OverloadParameters<typeof internalFindUp>[0],\n options: OverloadParameters<typeof internalFindUp>[1],\n): ReturnType<typeof internalFindUp> {\n // findUp has odd typing\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const got = await internalFindUp(matcher as any, options)\n return got ? normalizePath(got) : undefined\n}\n\nexport interface MatchGlobOptions {\n matchBase: boolean\n noglobstar: boolean\n}\n\n/**\n * Matches a key against a glob pattern.\n * @param key - The key to match.\n * @param pattern - The glob pattern to match against.\n * @param options - The options to refine the matching approach.\n * @returns true if the key matches the pattern, false otherwise.\n */\nexport function matchGlob(key: string, pattern: string, options?: MatchGlobOptions): boolean {\n return minimatch(key, pattern, options)\n}\n\n/**\n * Read a directory.\n * @param path - The path to read.\n * @returns A promise that resolves to an array of file names.\n */\nexport function readdir(path: string): Promise<string[]> {\n return fsReaddir(path)\n}\n\n/**\n * Copies the contents of a directory to another directory.\n *\n * @param srcDir - Source directory path.\n * @param destDir - Destination directory path.\n */\nexport async function copyDirectoryContents(srcDir: string, destDir: string): Promise<void> {\n if (!(await fileExists(srcDir))) {\n throw new Error(`Source directory ${srcDir} does not exist`)\n }\n\n if (!(await fileExists(destDir))) {\n await mkdir(destDir)\n }\n\n // Get all files and directories in the source directory\n const items = await glob(joinPath(srcDir, '**/*'))\n\n const filesToCopy = []\n\n for (const item of items) {\n const relativePath = item.replace(srcDir, '').replace(/^[/\\\\]/, '')\n const destPath = joinPath(destDir, relativePath)\n\n filesToCopy.push(copyFile(item, destPath))\n }\n\n await Promise.all(filesToCopy)\n}\n"]}
|
|
1
|
+
{"version":3,"file":"fs.js","sourceRoot":"","sources":["../../../src/public/node/fs.ts"],"names":[],"mappings":"A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AwD;IACxD,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAA;IAElD,MAAM,WAAW,GAAG,EAAE,CAAA;IAEtB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAA;QACnE,MAAM,QAAQ,GAAG,QAAQ,CAAC,OAAO,EAAE,YAAY,CAAC,CAAA;QAEhD,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAA;IAC5C,CAAC;IAED,MAAM,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,CAAA;AAChC,CAAC","sourcesContent":["import {joinPath, normalizePath} from './path.js'\nimport {outputContent, outputToken, outputDebug} from '../../public/node/output.js'\nimport {getRandomName, RandomNameFamily} from '../common/string.js'\nimport {OverloadParameters} from '../../private/common/ts/overloaded-parameters.js'\nimport {\n copy as fsCopy,\n ensureFile as fsEnsureFile,\n ensureFileSync as fsEnsureFileSync,\n remove as fsRemove,\n removeSync as fsRemoveSync,\n move as fsMove,\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n} from 'fs-extra/esm'\n\nimport {temporaryDirectory, temporaryDirectoryTask} from 'tempy'\nimport {sep, join} from 'pathe'\nimport {findUp as internalFindUp} from 'find-up'\nimport {minimatch} from 'minimatch'\nimport fastGlobLib from 'fast-glob'\nimport {\n mkdirSync as fsMkdirSync,\n readFileSync as fsReadFileSync,\n writeFileSync as fsWriteFileSync,\n appendFileSync as fsAppendFileSync,\n statSync as fsStatSync,\n createReadStream as fsCreateReadStream,\n createWriteStream as fsCreateWriteStream,\n constants as fsConstants,\n existsSync as fsFileExistsSync,\n unlinkSync as fsUnlinkSync,\n accessSync,\n ReadStream,\n WriteStream,\n statSync,\n} from 'fs'\nimport {\n mkdir as fsMkdir,\n writeFile as fsWriteFile,\n readFile as fsReadFile,\n realpath as fsRealPath,\n appendFile as fsAppendFile,\n mkdtemp as fsMkdtemp,\n stat as fsStat,\n lstat as fsLstat,\n chmod as fsChmod,\n access as fsAccess,\n rename as fsRename,\n unlink as fsUnlink,\n readdir as fsReaddir,\n} from 'fs/promises'\nimport {pathToFileURL as pathToFile} from 'url'\nimport * as os from 'os'\nimport type {Pattern, Options as GlobOptions} from 'fast-glob'\n\n/**\n * Strip the first `strip` parts of the path.\n *\n * @param path - Path to strip.\n * @param strip - Number of parts to strip.\n * @returns The stripped path.\n */\nexport function stripUpPath(path: string, strip: number): string {\n const parts = path.split(sep)\n return join(...parts.slice(strip))\n}\n\n/**\n * Creates a temporary directory and ties its lifecycle to the lifecycle of the callback.\n *\n * @param callback - The callback that receives the temporary directory.\n */\nexport async function inTemporaryDirectory<T>(callback: (tmpDir: string) => T | Promise<T>): Promise<T> {\n return temporaryDirectoryTask(callback)\n}\n\n/**\n * Return a temporary directory\n * @returns - The path to the temporary directory.\n */\nexport function tempDirectory(): string {\n return temporaryDirectory()\n}\n\n/**\n * It reads a file and returns its content as a string using the\n * utf-8 encoding.\n *\n * @param path - Path to the file to read.\n * @returns A promise that resolves with the content of the file.\n */\n\nexport type ReadOptions =\n | undefined\n | {flag?: string | undefined}\n | {\n encoding: string\n flag?: string | undefined\n }\nexport async function readFile(path: string, options?: ReadOptions): Promise<string>\nexport async function readFile(path: string, options?: ReadOptions): Promise<Buffer>\n\n/**\n * It reads a file and returns its content as a string.\n * Uses utf-8 encoding by default.\n *\n * @param path - Path to the file to read.\n * @param options - Options to read the file with (defaults to utf-8 encoding).\n * @returns A promise that resolves with the content of the file.\n */\nexport async function readFile(path: string, options: ReadOptions = {encoding: 'utf8'}): Promise<string | Buffer> {\n outputDebug(outputContent`Reading the content of file at ${outputToken.path(path)}...`)\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n return fsReadFile(path, options)\n}\n\n/**\n * Synchronously reads a file and returns its content as a buffer.\n *\n * @param path - Path to the file to read.\n * @returns The content of the file.\n */\nexport function readFileSync(path: string): Buffer {\n outputDebug(outputContent`Sync-reading the content of file at ${outputToken.path(path)}...`)\n return fsReadFileSync(path)\n}\n\n/**\n * Given a path, it determines the actual path. This is useful when working\n * with paths that represent symlinks.\n *\n * @param path - Path whose real path will be returned.\n */\nexport async function fileRealPath(path: string): Promise<string> {\n return fsRealPath(path)\n}\n\n/**\n * Copies a file.\n *\n * @param from - Path to the directory or file to be copied.\n * @param to - Destination path.\n */\nexport async function copyFile(from: string, to: string): Promise<void> {\n outputDebug(outputContent`Copying file from ${outputToken.path(from)} to ${outputToken.path(to)}...`)\n await fsCopy(from, to)\n}\n\n/**\n * Creates a file at the given path.\n *\n * @param path - Path to the file to be created.\n */\nexport async function touchFile(path: string): Promise<void> {\n outputDebug(outputContent`Creating an empty file at ${outputToken.path(path)}...`)\n await fsEnsureFile(path)\n}\n\n/**\n * Synchronously creates a file at the given path.\n *\n * @param path - Path to the file to be created.\n */\nexport function touchFileSync(path: string): void {\n outputDebug(outputContent`Creating an empty file at ${outputToken.path(path)}...`)\n fsEnsureFileSync(path)\n}\n\n/**\n * Appnds content to file at path.\n *\n * @param path - Path to the file to be appended.\n * @param content - Content to be appended.\n */\nexport async function appendFile(path: string, content: string): Promise<void> {\n outputDebug(outputContent`Appending the following content to ${outputToken.path(path)}:\n ${content\n .split('\\n')\n .map((line) => ` ${line}`)\n .join('\\n')}\n `)\n await fsAppendFile(path, content)\n}\n\n/**\n * Synchronously appends content to file at path.\n *\n * @param path - Path to the file to be appended.\n * @param data - Content to be appended.\n */\nexport function appendFileSync(path: string, data: string): void {\n fsAppendFileSync(path, data)\n}\n\nexport interface WriteOptions {\n encoding: BufferEncoding\n}\n\n/**\n * Writes content to file at path.\n *\n * @param path - Path to the file to be written.\n * @param data - Content to be written.\n * @param options - Options to write the file with (defaults to utf-8 encoding).\n */\nexport async function writeFile(\n path: string,\n data: string | Buffer,\n options: WriteOptions = {encoding: 'utf8'},\n): Promise<void> {\n outputDebug(outputContent`Writing some content to file at ${outputToken.path(path)}...`)\n await fsWriteFile(path, data, options)\n}\n\n/**\n * Synchronously writes content to file at path.\n *\n * @param path - Path to the file to be written.\n * @param data - Content to be written.\n */\nexport function writeFileSync(path: string, data: string): void {\n outputDebug(outputContent`File-writing some content to file at ${outputToken.path(path)}...`)\n fsWriteFileSync(path, data)\n}\n\n/**\n * Creates a directory at the given path.\n *\n * @param path - Path to the directory to be created.\n */\nexport async function mkdir(path: string): Promise<void> {\n outputDebug(outputContent`Creating directory at ${outputToken.path(path)}...`)\n await fsMkdir(path, {recursive: true})\n}\n\n/**\n * Synchronously creates a directory at the given path.\n *\n * @param path - Path to the directory to be created.\n */\nexport function mkdirSync(path: string): void {\n outputDebug(outputContent`Sync-creating directory at ${outputToken.path(path)}...`)\n fsMkdirSync(path, {recursive: true})\n}\n\n/**\n * Removes a file at the given path.\n *\n * @param path - Path to the file to be removed.\n */\nexport async function removeFile(path: string): Promise<void> {\n outputDebug(outputContent`Removing file at ${outputToken.path(path)}...`)\n await fsRemove(path)\n}\n\n/**\n * Renames a file.\n * @param from - Path to the file to be renamed.\n * @param to - New path for the file.\n */\nexport async function renameFile(from: string, to: string): Promise<void> {\n outputDebug(outputContent`Renaming file from ${outputToken.path(from)} to ${outputToken.path(to)}...`)\n await fsRename(from, to)\n}\n\n/**\n * Synchronously removes a file at the given path.\n *\n * @param path - Path to the file to be removed.\n */\nexport function removeFileSync(path: string): void {\n outputDebug(outputContent`Sync-removing file at ${outputToken.path(path)}...`)\n fsRemoveSync(path)\n}\n\ninterface RmDirOptions {\n force?: boolean\n}\n/**\n * Removes a directory at the given path.\n *\n * @param path - Path to the directory to be removed.\n * @param options - Options to remove the directory with.\n */\nexport async function rmdir(path: string, options: RmDirOptions = {}): Promise<void> {\n const {default: del} = await import('del')\n outputDebug(outputContent`Removing directory at ${outputToken.path(path)}...`)\n await del(path, {force: options.force})\n}\n\n/**\n * Create a temporary directory within the OS provided location for temp directories\n *\n * @returns Path to the temporary directory.\n */\nexport async function mkTmpDir(): Promise<string> {\n outputDebug(outputContent`Creating a temporary directory...`)\n const directory = await fsMkdtemp(joinPath(os.tmpdir(), 'tmp-'))\n return directory\n}\n\n/**\n * Check whether a path is a directory.\n *\n * @param path - Path to check.\n * @returns True if the path is a directory, false otherwise.\n */\nexport async function isDirectory(path: string): Promise<boolean> {\n outputDebug(outputContent`Checking if ${outputToken.path(path)} is a directory...`)\n return (await fsLstat(path)).isDirectory()\n}\n\n/**\n * Check whether a path is a directory.\n *\n * @param path - Path to check.\n * @returns True if the path is a directory, false otherwise.\n */\nexport function isDirectorySync(path: string): boolean {\n outputDebug(outputContent`Checking if ${outputToken.path(path)} is a directory...`)\n return fsStatSync(path).isDirectory()\n}\n\n/**\n * Get the size of a file.\n *\n * @param path - Path to the file.\n * @returns The size of the file in bytes.\n */\nexport async function fileSize(path: string): Promise<number> {\n outputDebug(outputContent`Getting the size of file file at ${outputToken.path(path)}...`)\n return (await fsStat(path)).size\n}\n\n/**\n * Synchronously get the size of a file.\n *\n * @param path - Path to the file.\n * @returns The size of the file in bytes.\n */\nexport function fileSizeSync(path: string): number {\n outputDebug(outputContent`Sync-getting the size of file file at ${outputToken.path(path)}...`)\n return fsStatSync(path).size\n}\n\n/**\n * Synchronously unlink a file at the given path.\n *\n * @param path - Path to the file.\n */\nexport function unlinkFileSync(path: string): void {\n fsUnlinkSync(path)\n}\n\n/**\n * Unlink a file at the given path.\n *\n * @param path - Path to the file.\n * @returns A promise that resolves when the file is unlinked.\n */\nexport function unlinkFile(path: string): Promise<void> {\n return fsUnlink(path)\n}\n\n/**\n * Create a read stream for a file with optional options.\n *\n * @param path - Path to the file.\n * @param options - Options for the read stream.\n * @returns A read stream for the file.\n */\nexport function createFileReadStream(\n path: string,\n options?: {encoding?: BufferEncoding; start?: number; end?: number},\n): ReadStream {\n return fsCreateReadStream(path, options)\n}\n\n/**\n * Create a write stream for a file.\n *\n * @param path - Path to the file.\n * @returns A write stream for the file.\n */\nexport function createFileWriteStream(path: string): WriteStream {\n return fsCreateWriteStream(path)\n}\n\n/**\n * Returns the Date object for the last modification of a file.\n *\n * @param path - Path to the directory or file.\n * @returns A unix timestamp.\n */\nexport async function fileLastUpdated(path: string): Promise<Date> {\n outputDebug(outputContent`Getting last updated timestamp for file at ${outputToken.path(path)}...`)\n return (await fsStat(path)).ctime\n}\n\n/**\n * Returns the unix timestamp of the last modification of a file.\n *\n * @param path - Path to the directory or file.\n * @returns A unix timestamp.\n */\nexport async function fileLastUpdatedTimestamp(path: string): Promise<number | undefined> {\n try {\n const lastUpdatedDateTime = await fileLastUpdated(path)\n return lastUpdatedDateTime.getTime()\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch {\n return undefined\n }\n}\n\ninterface MoveFileOptions {\n overwrite?: boolean\n}\n\n/**\n * Moves a file.\n *\n * @param src - File to be moved.\n * @param dest - Path to be moved to.\n * @param options - Moving options.\n */\nexport async function moveFile(src: string, dest: string, options: MoveFileOptions = {}): Promise<void> {\n await fsMove(src, dest, options)\n}\n\n/**\n * Changes the permissions of a directory or file.\n *\n * @param path - Path to the file or directory whose permissions will be modified.\n * @param mode - Permissions to set to the file or directory.\n */\nexport async function chmod(path: string, mode: number | string): Promise<void> {\n await fsChmod(path, mode)\n}\n\n/**\n * Checks if a file has executable permissions.\n *\n * @param path - Path to the file whose permissions will be checked.\n */\nexport async function fileHasExecutablePermissions(path: string): Promise<boolean> {\n try {\n await fsAccess(path, fsConstants.X_OK)\n return true\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch {\n return false\n }\n}\n\nexport function fileHasWritePermissions(path: string): boolean {\n try {\n accessSync(path, fsConstants.W_OK)\n return true\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch {\n return false\n }\n}\n\nexport function unixFileIsOwnedByCurrentUser(path: string): boolean | undefined {\n // process.getuid() is only available on Unix-like systems\n if (process.platform === 'win32' || typeof process.getuid !== 'function') return undefined\n if (!fileExistsSync(path)) return false\n\n try {\n const stats = statSync(path)\n const currentUid = process.getuid()\n\n return stats.uid === currentUid\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch {\n return false\n }\n}\n\n/**\n * Returns true if a file or directory exists.\n *\n * @param path - Path to the directory or file.\n * @returns True if it exists.\n */\nexport async function fileExists(path: string): Promise<boolean> {\n try {\n await fsAccess(path)\n return true\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch {\n return false\n }\n}\n\nexport function fileExistsSync(path: string): boolean {\n return fsFileExistsSync(path)\n}\n\ninterface GenerateRandomDirectoryOptions {\n /** Suffix to include in the randomly generated directory name. */\n suffix: string\n\n /** Absolute path to the directory where the random directory will be created. */\n directory: string\n\n /** Type of word to use for random name. */\n family?: RandomNameFamily\n}\n\n/**\n * It generates a random directory directory name for a sub-directory.\n * It ensures that the returned directory name doesn't exist.\n *\n * @param options - Options to generate the random directory name.\n * @returns It returns the name of the directory.\n */\nexport async function generateRandomNameForSubdirectory(options: GenerateRandomDirectoryOptions): Promise<string> {\n const generated = `${getRandomName(options.family ?? 'business')}-${options.suffix}`\n const randomDirectoryPath = joinPath(options.directory, generated)\n const isAppDirectoryTaken = await fileExists(randomDirectoryPath)\n\n if (isAppDirectoryTaken) {\n return generateRandomNameForSubdirectory(options)\n } else {\n return generated\n }\n}\n\n/**\n * Traverse the file system and return pathnames that match the given pattern.\n *\n * @param pattern - A glob pattern or an array of glob patterns.\n * @param options - Options for the glob.\n * @returns A promise that resolves to an array of pathnames that match the given pattern.\n */\nexport async function glob(pattern: Pattern | Pattern[], options?: GlobOptions): Promise<string[]> {\n const {default: fastGlob} = await import('fast-glob')\n let overridenOptions = options\n if (options?.dot == null) {\n overridenOptions = {...options, dot: true}\n }\n return fastGlob(pattern, overridenOptions)\n}\n\n/**\n * Synchronously traverse the file system and return pathnames that match the given pattern.\n *\n * @param pattern - A glob pattern or an array of glob patterns.\n * @param options - Options for the glob.\n * @returns An array of pathnames that match the given pattern.\n */\nexport function globSync(pattern: Pattern | Pattern[], options?: GlobOptions): string[] {\n let overridenOptions = options\n if (options?.dot == null) {\n overridenOptions = {...options, dot: true}\n }\n return fastGlobLib.sync(pattern, overridenOptions)\n}\n\n/**\n * Convert a path to a File URL.\n *\n * @param path - Path to convert.\n * @returns The File URL.\n */\nexport function pathToFileURL(path: string): URL {\n return pathToFile(path)\n}\n\n/**\n * The operating system-specific end-of-line marker:\n * - `\\n` on POSIX\n * - `\\r\\n` on Windows\n */\nexport type EOL = '\\r\\n' | '\\n'\n\n/**\n * Detects the end-of-line marker used in a string.\n *\n * @param content - file contents to analyze\n *\n * @returns The detected end-of-line marker\n */\nexport function detectEOL(content: string): EOL {\n const match = content.match(/\\r\\n|\\n/g)\n\n if (!match) {\n return defaultEOL()\n }\n\n const crlf = match.filter((eol) => eol === '\\r\\n').length\n const lf = match.filter((eol) => eol === '\\n').length\n\n return crlf > lf ? '\\r\\n' : '\\n'\n}\n\n/**\n * Returns the operating system's end-of-line marker.\n *\n * @returns The OS-specific end-of-line marker\n */\nexport function defaultEOL(): EOL {\n return os.EOL as EOL\n}\n\n/**\n * Find a file by walking parent directories.\n *\n * @param matcher - A pattern or an array of patterns to match a file name.\n * @param options - Options for the search.\n * @returns The first path found that matches or `undefined` if none could be found.\n */\nexport async function findPathUp(\n matcher: OverloadParameters<typeof internalFindUp>[0],\n options: OverloadParameters<typeof internalFindUp>[1],\n): ReturnType<typeof internalFindUp> {\n // findUp has odd typing\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const got = await internalFindUp(matcher as any, options)\n return got ? normalizePath(got) : undefined\n}\n\nexport interface MatchGlobOptions {\n matchBase: boolean\n noglobstar: boolean\n}\n\n/**\n * Matches a key against a glob pattern.\n * @param key - The key to match.\n * @param pattern - The glob pattern to match against.\n * @param options - The options to refine the matching approach.\n * @returns true if the key matches the pattern, false otherwise.\n */\nexport function matchGlob(key: string, pattern: string, options?: MatchGlobOptions): boolean {\n return minimatch(key, pattern, options)\n}\n\n/**\n * Read a directory.\n * @param path - The path to read.\n * @returns A promise that resolves to an array of file names.\n */\nexport function readdir(path: string): Promise<string[]> {\n return fsReaddir(path)\n}\n\n/**\n * Copies the contents of a directory to another directory.\n *\n * @param srcDir - Source directory path.\n * @param destDir - Destination directory path.\n */\nexport async function copyDirectoryContents(srcDir: string, destDir: string): Promise<void> {\n if (!(await fileExists(srcDir))) {\n throw new Error(`Source directory ${srcDir} does not exist`)\n }\n\n if (!(await fileExists(destDir))) {\n await mkdir(destDir)\n }\n\n // Get all files and directories in the source directory\n const items = await glob(joinPath(srcDir, '**/*'))\n\n const filesToCopy = []\n\n for (const item of items) {\n const relativePath = item.replace(srcDir, '').replace(/^[/\\\\]/, '')\n const destPath = joinPath(destDir, relativePath)\n\n filesToCopy.push(copyFile(item, destPath))\n }\n\n await Promise.all(filesToCopy)\n}\n"]}
|
package/dist/public/node/git.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-base-to-string */
|
|
2
2
|
import { hasGit, isTerminalInteractive } from './context/local.js';
|
|
3
|
-
import { appendFileSync, detectEOL, fileExistsSync, readFileSync, writeFileSync } from './fs.js';
|
|
3
|
+
import { appendFileSync, detectEOL, fileExists, fileExistsSync, glob, isDirectory, readFileSync, writeFileSync, } from './fs.js';
|
|
4
4
|
import { AbortError } from './error.js';
|
|
5
5
|
import { cwd, joinPath } from './path.js';
|
|
6
6
|
import { runWithTimer } from './metadata.js';
|
|
@@ -17,11 +17,10 @@ export async function initializeGitRepository(directory, initialBranch = 'main')
|
|
|
17
17
|
outputDebug(outputContent `Initializing git repository at ${outputToken.path(directory)}...`);
|
|
18
18
|
await ensureGitIsPresentOrAbort();
|
|
19
19
|
// We use init and checkout instead of `init --initial-branch` because the latter is only supported in git 2.28+
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
await repo.checkoutLocalBranch(initialBranch);
|
|
20
|
+
await withGit({ directory }, async (repo) => {
|
|
21
|
+
await repo.init();
|
|
22
|
+
await repo.checkoutLocalBranch(initialBranch);
|
|
23
|
+
});
|
|
25
24
|
}
|
|
26
25
|
/**
|
|
27
26
|
* Given a Git repository and a list of absolute paths to files contained
|
|
@@ -33,11 +32,7 @@ export async function initializeGitRepository(directory, initialBranch = 'main')
|
|
|
33
32
|
* @returns Files ignored by the lockfile.
|
|
34
33
|
*/
|
|
35
34
|
export async function checkIfIgnoredInGitRepository(directory, files) {
|
|
36
|
-
|
|
37
|
-
// @ts-ignore
|
|
38
|
-
const repo = git(directory);
|
|
39
|
-
const ignoredLockfile = await repo.checkIgnore(files);
|
|
40
|
-
return ignoredLockfile;
|
|
35
|
+
return withGit({ directory }, (repo) => repo.checkIgnore(files));
|
|
41
36
|
}
|
|
42
37
|
/**
|
|
43
38
|
* Create a .gitignore file in the given directory.
|
|
@@ -99,6 +94,22 @@ export async function downloadGitRepository(cloneOptions) {
|
|
|
99
94
|
const { repoUrl, destination, progressUpdater, shallow, latestTag } = cloneOptions;
|
|
100
95
|
outputDebug(outputContent `Git-cloning repository ${repoUrl} into ${outputToken.path(destination)}...`);
|
|
101
96
|
await ensureGitIsPresentOrAbort();
|
|
97
|
+
// Validate destination directory before attempting to clone
|
|
98
|
+
if (await fileExists(destination)) {
|
|
99
|
+
// Check if it's a directory
|
|
100
|
+
if (!(await isDirectory(destination))) {
|
|
101
|
+
throw new AbortError(outputContent `Can't clone to ${outputToken.path(destination)}`, "The path exists but isn't a directory.");
|
|
102
|
+
}
|
|
103
|
+
// Check if directory is empty
|
|
104
|
+
const entries = await glob(['*', '.*'], {
|
|
105
|
+
cwd: destination,
|
|
106
|
+
deep: 1,
|
|
107
|
+
onlyFiles: false,
|
|
108
|
+
});
|
|
109
|
+
if (entries.length > 0) {
|
|
110
|
+
throw new AbortError(outputContent `Directory ${outputToken.path(destination)} already exists and is not empty`, outputContent `Choose a different name or remove the existing directory first.`);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
102
113
|
const [repository, branch] = repoUrl.split('#');
|
|
103
114
|
const options = { '--recurse-submodules': null };
|
|
104
115
|
if (branch && latestTag) {
|
|
@@ -128,11 +139,10 @@ export async function downloadGitRepository(cloneOptions) {
|
|
|
128
139
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
129
140
|
await git(simpleGitOptions).clone(repository, destination, options);
|
|
130
141
|
if (latestTag) {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
await localGitRepository.checkout(latestTag);
|
|
142
|
+
await withGit({ directory: destination }, async (localGitRepository) => {
|
|
143
|
+
const latestTag = await getLocalLatestTag(localGitRepository, repoUrl);
|
|
144
|
+
await localGitRepository.checkout(latestTag);
|
|
145
|
+
});
|
|
136
146
|
}
|
|
137
147
|
}
|
|
138
148
|
catch (err) {
|
|
@@ -166,11 +176,7 @@ async function getLocalLatestTag(repository, repoUrl) {
|
|
|
166
176
|
* @returns The latest commit of the repository.
|
|
167
177
|
*/
|
|
168
178
|
export async function getLatestGitCommit(directory) {
|
|
169
|
-
|
|
170
|
-
// @ts-ignore
|
|
171
|
-
const logs = await git({ baseDir: directory }).log({
|
|
172
|
-
maxCount: 1,
|
|
173
|
-
});
|
|
179
|
+
const logs = await withGit({ directory }, (repo) => repo.log({ maxCount: 1 }));
|
|
174
180
|
if (!logs.latest) {
|
|
175
181
|
throw new AbortError('Must have at least one commit to run command', outputContent `Run ${outputToken.genericShellCommand("git commit -m 'Initial commit'")} to create your first commit.`);
|
|
176
182
|
}
|
|
@@ -183,10 +189,7 @@ export async function getLatestGitCommit(directory) {
|
|
|
183
189
|
* @returns A promise that resolves when the files are added to the index.
|
|
184
190
|
*/
|
|
185
191
|
export async function addAllToGitFromDirectory(directory) {
|
|
186
|
-
|
|
187
|
-
// @ts-ignore
|
|
188
|
-
const simpleGit = git({ baseDir: directory });
|
|
189
|
-
await simpleGit.raw('add', '--all');
|
|
192
|
+
await withGit({ directory }, (repo) => repo.raw('add', '--all'));
|
|
190
193
|
}
|
|
191
194
|
/**
|
|
192
195
|
* Create a git commit.
|
|
@@ -196,11 +199,8 @@ export async function addAllToGitFromDirectory(directory) {
|
|
|
196
199
|
* @returns The hash of the created commit.
|
|
197
200
|
*/
|
|
198
201
|
export async function createGitCommit(message, options) {
|
|
199
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
200
|
-
// @ts-ignore
|
|
201
|
-
const simpleGit = git({ baseDir: options?.directory });
|
|
202
202
|
const commitOptions = options?.author ? { '--author': options.author } : undefined;
|
|
203
|
-
const result = await
|
|
203
|
+
const result = await withGit({ directory: options?.directory }, (repo) => repo.commit(message, commitOptions));
|
|
204
204
|
return result.commit;
|
|
205
205
|
}
|
|
206
206
|
/**
|
|
@@ -210,9 +210,7 @@ export async function createGitCommit(message, options) {
|
|
|
210
210
|
* @returns The HEAD symbolic reference of the repository.
|
|
211
211
|
*/
|
|
212
212
|
export async function getHeadSymbolicRef(directory) {
|
|
213
|
-
|
|
214
|
-
// @ts-ignore
|
|
215
|
-
const ref = await git({ baseDir: directory }).raw('symbolic-ref', '-q', 'HEAD');
|
|
213
|
+
const ref = await withGit({ directory }, (repo) => repo.raw('symbolic-ref', '-q', 'HEAD'));
|
|
216
214
|
if (!ref) {
|
|
217
215
|
throw new AbortError("Git HEAD can't be detached to run command", outputContent `Run ${outputToken.genericShellCommand('git checkout [branchName]')} to reattach HEAD or see git ${outputToken.link('documentation', 'https://git-scm.com/book/en/v2/Git-Internals-Git-References')} for more details`);
|
|
218
216
|
}
|
|
@@ -249,9 +247,7 @@ export async function ensureInsideGitDirectory(directory) {
|
|
|
249
247
|
* @returns True if the directory is inside a .git directory tree.
|
|
250
248
|
*/
|
|
251
249
|
export async function insideGitDirectory(directory) {
|
|
252
|
-
|
|
253
|
-
// @ts-ignore
|
|
254
|
-
return git({ baseDir: directory }).checkIsRepo();
|
|
250
|
+
return withGit({ directory }, (repo) => repo.checkIsRepo());
|
|
255
251
|
}
|
|
256
252
|
export class GitDirectoryNotCleanError extends AbortError {
|
|
257
253
|
}
|
|
@@ -273,9 +269,7 @@ export async function ensureIsClean(directory) {
|
|
|
273
269
|
* @returns True is the .git directory is clean.
|
|
274
270
|
*/
|
|
275
271
|
export async function isClean(directory) {
|
|
276
|
-
|
|
277
|
-
// @ts-ignore
|
|
278
|
-
return (await git({ baseDir: directory }).status()).isClean();
|
|
272
|
+
return (await withGit({ directory }, (git) => git.status())).isClean();
|
|
279
273
|
}
|
|
280
274
|
/**
|
|
281
275
|
* Returns the latest tag of a git repository.
|
|
@@ -284,9 +278,7 @@ export async function isClean(directory) {
|
|
|
284
278
|
* @returns String with the latest tag or undefined if no tags are found.
|
|
285
279
|
*/
|
|
286
280
|
export async function getLatestTag(directory) {
|
|
287
|
-
|
|
288
|
-
// @ts-ignore
|
|
289
|
-
const tags = await git({ baseDir: directory }).tags();
|
|
281
|
+
const tags = await withGit({ directory }, (repo) => repo.tags());
|
|
290
282
|
return tags.latest;
|
|
291
283
|
}
|
|
292
284
|
/**
|
|
@@ -299,16 +291,31 @@ export async function getLatestTag(directory) {
|
|
|
299
291
|
export async function removeGitRemote(directory, remoteName = 'origin') {
|
|
300
292
|
outputDebug(outputContent `Removing git remote ${remoteName} from ${outputToken.path(directory)}...`);
|
|
301
293
|
await ensureGitIsPresentOrAbort();
|
|
294
|
+
await withGit({ directory }, async (repo) => {
|
|
295
|
+
// Check if remote exists first
|
|
296
|
+
const remotes = await repo.getRemotes();
|
|
297
|
+
const remoteExists = remotes.some((remote) => remote.name === remoteName);
|
|
298
|
+
if (!remoteExists) {
|
|
299
|
+
outputDebug(outputContent `Remote ${remoteName} does not exist, no action needed`);
|
|
300
|
+
return;
|
|
301
|
+
}
|
|
302
|
+
await repo.removeRemote(remoteName);
|
|
303
|
+
});
|
|
304
|
+
}
|
|
305
|
+
async function withGit({ directory, }, callback) {
|
|
302
306
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
303
307
|
// @ts-ignore
|
|
304
|
-
const repo = git(directory);
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
308
|
+
const repo = git({ baseDir: directory });
|
|
309
|
+
try {
|
|
310
|
+
return await callback(repo);
|
|
311
|
+
}
|
|
312
|
+
catch (err) {
|
|
313
|
+
if (err instanceof Error) {
|
|
314
|
+
const abortError = new AbortError(err.message);
|
|
315
|
+
abortError.stack = err.stack;
|
|
316
|
+
throw abortError;
|
|
317
|
+
}
|
|
318
|
+
throw err;
|
|
311
319
|
}
|
|
312
|
-
await repo.removeRemote(remoteName);
|
|
313
320
|
}
|
|
314
321
|
//# sourceMappingURL=git.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"git.js","sourceRoot":"","sources":["../../../src/public/node/git.ts"],"names":[],"mappings":"AAAA,yDAAyD;AACzD,OAAO,EAAC,MAAM,EAAE,qBAAqB,EAAC,MAAM,oBAAoB,CAAA;AAChE,OAAO,EAAC,cAAc,EAAE,SAAS,EAAE,cAAc,EAAE,YAAY,EAAE,aAAa,EAAC,MAAM,SAAS,CAAA;AAC9F,OAAO,EAAC,UAAU,EAAC,MAAM,YAAY,CAAA;AACrC,OAAO,EAAC,GAAG,EAAE,QAAQ,EAAC,MAAM,WAAW,CAAA;AACvC,OAAO,EAAC,YAAY,EAAC,MAAM,eAAe,CAAA;AAC1C,OAAO,EAAC,aAAa,EAAE,WAAW,EAAE,WAAW,EAAC,MAAM,6BAA6B,CAAA;AACnF,OAAO,GAAoF,MAAM,YAAY,CAAA;AAC7G,OAAO,MAAM,MAAM,QAAQ,CAAA;AAE3B;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAAC,SAAiB,EAAE,aAAa,GAAG,MAAM;IACrF,WAAW,CAAC,aAAa,CAAA,kCAAkC,WAAW,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAA;I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Content":["/* eslint-disable @typescript-eslint/no-base-to-string */\nimport {hasGit, isTerminalInteractive} from './context/local.js'\nimport {appendFileSync, detectEOL, fileExistsSync, readFileSync, writeFileSync} from './fs.js'\nimport {AbortError} from './error.js'\nimport {cwd, joinPath} from './path.js'\nimport {runWithTimer} from './metadata.js'\nimport {outputContent, outputToken, outputDebug} from '../../public/node/output.js'\nimport git, {TaskOptions, SimpleGitProgressEvent, DefaultLogFields, ListLogLine, SimpleGit} from 'simple-git'\nimport ignore from 'ignore'\n\n/**\n * Initialize a git repository at the given directory.\n *\n * @param directory - The directory where the git repository will be initialized.\n * @param initialBranch - The name of the initial branch.\n */\nexport async function initializeGitRepository(directory: string, initialBranch = 'main'): Promise<void> {\n outputDebug(outputContent`Initializing git repository at ${outputToken.path(directory)}...`)\n await ensureGitIsPresentOrAbort()\n // We use init and checkout instead of `init --initial-branch` because the latter is only supported in git 2.28+\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n const repo = git(directory)\n await repo.init()\n await repo.checkoutLocalBranch(initialBranch)\n}\n\n/**\n * Given a Git repository and a list of absolute paths to files contained\n * in the repository, it filters and returns the files that are ignored\n * by the .gitignore.\n *\n * @param directory - The absolute path to the directory containing the files.\n * @param files - The list of files to check against.\n * @returns Files ignored by the lockfile.\n */\nexport async function checkIfIgnoredInGitRepository(directory: string, files: string[]): Promise<string[]> {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n const repo = git(directory)\n const ignoredLockfile = await repo.checkIgnore(files)\n return ignoredLockfile\n}\n\nexport interface GitIgnoreTemplate {\n [section: string]: string[]\n}\n/**\n * Create a .gitignore file in the given directory.\n *\n * @param directory - The directory where the .gitignore file will be created.\n * @param template - The template to use to create the .gitignore file.\n */\nexport function createGitIgnore(directory: string, template: GitIgnoreTemplate): void {\n outputDebug(outputContent`Creating .gitignore at ${outputToken.path(directory)}...`)\n const filePath = `${directory}/.gitignore`\n\n let fileContent = ''\n for (const [section, lines] of Object.entries(template)) {\n fileContent += `# ${section}\\n`\n fileContent += `${lines.join('\\n')}\\n\\n`\n }\n\n appendFileSync(filePath, fileContent)\n}\n\n/**\n * Add an entry to an existing .gitignore file.\n *\n * If the .gitignore file doesn't exist, or if the entry is already present,\n * no changes will be made.\n *\n * @param root - The directory containing the .gitignore file.\n * @param entry - The entry to add to the .gitignore file.\n */\nexport function addToGitIgnore(root: string, entry: string): void {\n const gitIgnorePath = joinPath(root, '.gitignore')\n\n if (!fileExistsSync(gitIgnorePath)) {\n // When the .gitignore file does not exist, the CLI should not be opinionated about creating it\n return\n }\n\n const gitIgnoreContent = readFileSync(gitIgnorePath).toString()\n const eol = detectEOL(gitIgnoreContent)\n\n const lines = gitIgnoreContent.split(eol).map((line) => line.trim())\n const ignoreManager = ignore.default({allowRelativePaths: true}).add(lines)\n\n const isIgnoredEntry = ignoreManager.ignores(joinPath(entry))\n const isIgnoredEntryAsDir = ignoreManager.ignores(joinPath(entry, 'ignored.txt'))\n const isAlreadyIgnored = isIgnoredEntry || isIgnoredEntryAsDir\n if (isAlreadyIgnored) {\n // The file is already ignored by an existing pattern\n return\n }\n\n if (gitIgnoreContent.endsWith(eol)) {\n writeFileSync(gitIgnorePath, `${gitIgnoreContent}${entry}${eol}`)\n } else {\n writeFileSync(gitIgnorePath, `${gitIgnoreContent}${eol}${entry}${eol}`)\n }\n}\n\n/**\n * Options to use when cloning a git repository.\n *\n * @param repoUrl - The URL of the repository to clone.\n * @param destination - The directory where the repository will be cloned.\n * @param progressUpdater - A function that will be called with the progress of the clone.\n * @param shallow - Whether to clone the repository shallowly.\n * @param latestTag - Whether to clone the latest tag instead of the default branch.\n */\nexport interface GitCloneOptions {\n repoUrl: string\n destination: string\n progressUpdater?: (statusString: string) => void\n shallow?: boolean\n latestTag?: boolean\n}\n/**\n * Clone a git repository.\n *\n * @param cloneOptions - The options to use to clone the repository.\n * @returns A promise that resolves when the clone is complete.\n */\nexport async function downloadGitRepository(cloneOptions: GitCloneOptions): Promise<void> {\n return runWithTimer('cmd_all_timing_network_ms')(async () => {\n const {repoUrl, destination, progressUpdater, shallow, latestTag} = cloneOptions\n outputDebug(outputContent`Git-cloning repository ${repoUrl} into ${outputToken.path(destination)}...`)\n await ensureGitIsPresentOrAbort()\n const [repository, branch] = repoUrl.split('#')\n const options: TaskOptions = {'--recurse-submodules': null}\n\n if (branch && latestTag) {\n throw new AbortError(\"Error cloning the repository. Git can't clone the latest release with a 'branch'.\")\n }\n if (branch) {\n options['--branch'] = branch\n }\n\n if (shallow && latestTag) {\n throw new AbortError(\n \"Error cloning the repository. Git can't clone the latest release with the 'shallow' property.\",\n )\n }\n if (shallow) {\n options['--depth'] = 1\n }\n\n const progress = ({stage, progress, processed, total}: SimpleGitProgressEvent) => {\n const updateString = `${stage}, ${processed}/${total} objects (${progress}% complete)`\n if (progressUpdater) progressUpdater(updateString)\n }\n\n const simpleGitOptions = {\n progress,\n ...(!isTerminalInteractive() && {config: ['core.askpass=true']}),\n }\n try {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n await git(simpleGitOptions).clone(repository!, destination, options)\n\n if (latestTag) {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n const localGitRepository = git(destination)\n const latestTag = await getLocalLatestTag(localGitRepository, repoUrl)\n await localGitRepository.checkout(latestTag)\n }\n } catch (err) {\n if (err instanceof Error) {\n const abortError = new AbortError(err.message)\n abortError.stack = err.stack\n throw abortError\n }\n throw err\n }\n })\n}\n\n/**\n * Get the most recent tag of a local git repository.\n *\n * @param repository - The local git repository.\n * @param repoUrl - The URL of the repository.\n * @returns The most recent tag of the repository.\n */\nasync function getLocalLatestTag(repository: SimpleGit, repoUrl: string): Promise<string> {\n const latest = (await repository.tags()).latest\n\n if (!latest) {\n throw new AbortError(`Couldn't obtain the most recent tag of the repository ${repoUrl}`)\n }\n\n return latest\n}\n\n/**\n * Get the latest commit of a git repository.\n *\n * @param directory - The directory of the git repository.\n * @returns The latest commit of the repository.\n */\nexport async function getLatestGitCommit(directory?: string): Promise<DefaultLogFields & ListLogLine> {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n const logs = await git({baseDir: directory}).log({\n maxCount: 1,\n })\n if (!logs.latest) {\n throw new AbortError(\n 'Must have at least one commit to run command',\n outputContent`Run ${outputToken.genericShellCommand(\n \"git commit -m 'Initial commit'\",\n )} to create your first commit.`,\n )\n }\n return logs.latest\n}\n\n/**\n * Add all files to the git index from the given directory.\n *\n * @param directory - The directory where the git repository is located.\n * @returns A promise that resolves when the files are added to the index.\n */\nexport async function addAllToGitFromDirectory(directory?: string): Promise<void> {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n const simpleGit = git({baseDir: directory})\n await simpleGit.raw('add', '--all')\n}\n\nexport interface CreateGitCommitOptions {\n directory?: string\n author?: string\n}\n\n/**\n * Create a git commit.\n *\n * @param message - The message of the commit.\n * @param options - The options to use to create the commit.\n * @returns The hash of the created commit.\n */\nexport async function createGitCommit(message: string, options?: CreateGitCommitOptions): Promise<string> {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n const simpleGit = git({baseDir: options?.directory})\n\n const commitOptions = options?.author ? {'--author': options.author} : undefined\n const result = await simpleGit.commit(message, commitOptions)\n\n return result.commit\n}\n\n/**\n * Get the HEAD symbolic reference of a git repository.\n *\n * @param directory - The directory of the git repository.\n * @returns The HEAD symbolic reference of the repository.\n */\nexport async function getHeadSymbolicRef(directory?: string): Promise<string> {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n const ref = await git({baseDir: directory}).raw('symbolic-ref', '-q', 'HEAD')\n if (!ref) {\n throw new AbortError(\n \"Git HEAD can't be detached to run command\",\n outputContent`Run ${outputToken.genericShellCommand(\n 'git checkout [branchName]',\n )} to reattach HEAD or see git ${outputToken.link(\n 'documentation',\n 'https://git-scm.com/book/en/v2/Git-Internals-Git-References',\n )} for more details`,\n )\n }\n return ref.trim()\n}\n\n/**\n * If \"git\" is not present in the environment it throws\n * an abort error.\n */\nexport async function ensureGitIsPresentOrAbort(): Promise<void> {\n if (!(await hasGit())) {\n throw new AbortError(\n `Git is necessary in the environment to continue`,\n outputContent`Install ${outputToken.link(\n 'git',\n 'https://git-scm.com/book/en/v2/Getting-Started-Installing-Git',\n )}`,\n )\n }\n}\n\nexport class OutsideGitDirectoryError extends AbortError {}\n/**\n * If command run from outside a .git directory tree\n * it throws an abort error.\n *\n * @param directory - The directory to check.\n */\nexport async function ensureInsideGitDirectory(directory?: string): Promise<void> {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n if (!(await insideGitDirectory(directory))) {\n throw new OutsideGitDirectoryError(`${outputToken.path(directory || cwd())} is not a Git directory`)\n }\n}\n\n/**\n * Returns true if the given directory is inside a .git directory tree.\n *\n * @param directory - The directory to check.\n * @returns True if the directory is inside a .git directory tree.\n */\nexport async function insideGitDirectory(directory?: string): Promise<boolean> {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n return git({baseDir: directory}).checkIsRepo()\n}\n\nexport class GitDirectoryNotCleanError extends AbortError {}\n/**\n * If the .git directory tree is not clean (has uncommitted changes)\n * it throws an abort error.\n *\n * @param directory - The directory to check.\n */\nexport async function ensureIsClean(directory?: string): Promise<void> {\n if (!(await isClean(directory))) {\n throw new GitDirectoryNotCleanError(`${outputToken.path(directory || cwd())} is not a clean Git directory`)\n }\n}\n\n/**\n * Returns true if the .git directory tree is clean (no uncommitted changes).\n *\n * @param directory - The directory to check.\n * @returns True is the .git directory is clean.\n */\nexport async function isClean(directory?: string): Promise<boolean> {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n return (await git({baseDir: directory}).status()).isClean()\n}\n\n/**\n * Returns the latest tag of a git repository.\n *\n * @param directory - The directory to check.\n * @returns String with the latest tag or undefined if no tags are found.\n */\nexport async function getLatestTag(directory?: string): Promise<string | undefined> {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n const tags = await git({baseDir: directory}).tags()\n return tags.latest\n}\n\n/**\n * Remove a git remote from the given directory.\n *\n * @param directory - The directory where the git repository is located.\n * @param remoteName - The name of the remote to remove (defaults to 'origin').\n * @returns A promise that resolves when the remote is removed.\n */\nexport async function removeGitRemote(directory: string, remoteName = 'origin'): Promise<void> {\n outputDebug(outputContent`Removing git remote ${remoteName} from ${outputToken.path(directory)}...`)\n await ensureGitIsPresentOrAbort()\n\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n const repo = git(directory)\n\n // Check if remote exists first\n const remotes = await repo.getRemotes()\n const remoteExists = remotes.some((remote: {name: string}) => remote.name === remoteName)\n\n if (!remoteExists) {\n outputDebug(outputContent`Remote ${remoteName} does not exist, no action needed`)\n return\n }\n\n await repo.removeRemote(remoteName)\n}\n"]}
|
|
1
|
+
{"version":3,"file":"git.js","sourceRoot":"","sources":["../../../src/public/node/git.ts"],"names":[],"mappings":"AAAA,yDAAyD;AACzD,OAAO,EAAC,MAAM,EAAE,qBAAqB,EAAC,MAAM,oBAAoB,CAAA;AAChE,OAAO,EACL,cAAc,EACd,SAAS,EACT,UAAU,EACV,cAAc,EACd,IAAI,EACJ,WAAW,EACX,YAAY,EACZ,aAAa,GACd,MAAM,SAAS,CAAA;AAChB,OAAO,EAAC,UAAU,EAAC,MAAM,YAAY,CAAA;AACrC,OAAO,EAAC,GAAG,EAAE,QAAQ,EAAC,MAAM,WAAW,CAAA;AACvC,OAAO,EAAC,YAAY,EAAC,MAAM,eAAe,CAAA;AAC1C,OAAO,EAAC,aAAa,EAAE,WAAW,EAAE,WAAW,EAAC,MAAM,6BAA6B,CAAA;AACnF,OAAO,GAAoF,MAAM,YAAY,CAAA;AAC7G,OAAO,MAAM,MAAM,QAAQ,CAAA;AAE3B;;;;;GAKG;AACH,MAAM,CAAC,K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AAG,CAAC,KAAK,CAAA;YAC5B,MAAM,UAAU,CAAA;QAClB,CAAC;QACD,MAAM,GAAG,CAAA;IACX,CAAC;AACH,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/no-base-to-string */\nimport {hasGit, isTerminalInteractive} from './context/local.js'\nimport {\n appendFileSync,\n detectEOL,\n fileExists,\n fileExistsSync,\n glob,\n isDirectory,\n readFileSync,\n writeFileSync,\n} from './fs.js'\nimport {AbortError} from './error.js'\nimport {cwd, joinPath} from './path.js'\nimport {runWithTimer} from './metadata.js'\nimport {outputContent, outputToken, outputDebug} from '../../public/node/output.js'\nimport git, {TaskOptions, SimpleGitProgressEvent, DefaultLogFields, ListLogLine, SimpleGit} from 'simple-git'\nimport ignore from 'ignore'\n\n/**\n * Initialize a git repository at the given directory.\n *\n * @param directory - The directory where the git repository will be initialized.\n * @param initialBranch - The name of the initial branch.\n */\nexport async function initializeGitRepository(directory: string, initialBranch = 'main'): Promise<void> {\n outputDebug(outputContent`Initializing git repository at ${outputToken.path(directory)}...`)\n await ensureGitIsPresentOrAbort()\n // We use init and checkout instead of `init --initial-branch` because the latter is only supported in git 2.28+\n await withGit({directory}, async (repo) => {\n await repo.init()\n await repo.checkoutLocalBranch(initialBranch)\n })\n}\n\n/**\n * Given a Git repository and a list of absolute paths to files contained\n * in the repository, it filters and returns the files that are ignored\n * by the .gitignore.\n *\n * @param directory - The absolute path to the directory containing the files.\n * @param files - The list of files to check against.\n * @returns Files ignored by the lockfile.\n */\nexport async function checkIfIgnoredInGitRepository(directory: string, files: string[]): Promise<string[]> {\n return withGit({directory}, (repo) => repo.checkIgnore(files))\n}\n\nexport interface GitIgnoreTemplate {\n [section: string]: string[]\n}\n/**\n * Create a .gitignore file in the given directory.\n *\n * @param directory - The directory where the .gitignore file will be created.\n * @param template - The template to use to create the .gitignore file.\n */\nexport function createGitIgnore(directory: string, template: GitIgnoreTemplate): void {\n outputDebug(outputContent`Creating .gitignore at ${outputToken.path(directory)}...`)\n const filePath = `${directory}/.gitignore`\n\n let fileContent = ''\n for (const [section, lines] of Object.entries(template)) {\n fileContent += `# ${section}\\n`\n fileContent += `${lines.join('\\n')}\\n\\n`\n }\n\n appendFileSync(filePath, fileContent)\n}\n\n/**\n * Add an entry to an existing .gitignore file.\n *\n * If the .gitignore file doesn't exist, or if the entry is already present,\n * no changes will be made.\n *\n * @param root - The directory containing the .gitignore file.\n * @param entry - The entry to add to the .gitignore file.\n */\nexport function addToGitIgnore(root: string, entry: string): void {\n const gitIgnorePath = joinPath(root, '.gitignore')\n\n if (!fileExistsSync(gitIgnorePath)) {\n // When the .gitignore file does not exist, the CLI should not be opinionated about creating it\n return\n }\n\n const gitIgnoreContent = readFileSync(gitIgnorePath).toString()\n const eol = detectEOL(gitIgnoreContent)\n\n const lines = gitIgnoreContent.split(eol).map((line) => line.trim())\n const ignoreManager = ignore.default({allowRelativePaths: true}).add(lines)\n\n const isIgnoredEntry = ignoreManager.ignores(joinPath(entry))\n const isIgnoredEntryAsDir = ignoreManager.ignores(joinPath(entry, 'ignored.txt'))\n const isAlreadyIgnored = isIgnoredEntry || isIgnoredEntryAsDir\n if (isAlreadyIgnored) {\n // The file is already ignored by an existing pattern\n return\n }\n\n if (gitIgnoreContent.endsWith(eol)) {\n writeFileSync(gitIgnorePath, `${gitIgnoreContent}${entry}${eol}`)\n } else {\n writeFileSync(gitIgnorePath, `${gitIgnoreContent}${eol}${entry}${eol}`)\n }\n}\n\n/**\n * Options to use when cloning a git repository.\n *\n * @param repoUrl - The URL of the repository to clone.\n * @param destination - The directory where the repository will be cloned.\n * @param progressUpdater - A function that will be called with the progress of the clone.\n * @param shallow - Whether to clone the repository shallowly.\n * @param latestTag - Whether to clone the latest tag instead of the default branch.\n */\nexport interface GitCloneOptions {\n repoUrl: string\n destination: string\n progressUpdater?: (statusString: string) => void\n shallow?: boolean\n latestTag?: boolean\n}\n/**\n * Clone a git repository.\n *\n * @param cloneOptions - The options to use to clone the repository.\n * @returns A promise that resolves when the clone is complete.\n */\nexport async function downloadGitRepository(cloneOptions: GitCloneOptions): Promise<void> {\n return runWithTimer('cmd_all_timing_network_ms')(async () => {\n const {repoUrl, destination, progressUpdater, shallow, latestTag} = cloneOptions\n outputDebug(outputContent`Git-cloning repository ${repoUrl} into ${outputToken.path(destination)}...`)\n await ensureGitIsPresentOrAbort()\n\n // Validate destination directory before attempting to clone\n if (await fileExists(destination)) {\n // Check if it's a directory\n if (!(await isDirectory(destination))) {\n throw new AbortError(\n outputContent`Can't clone to ${outputToken.path(destination)}`,\n \"The path exists but isn't a directory.\",\n )\n }\n\n // Check if directory is empty\n const entries = await glob(['*', '.*'], {\n cwd: destination,\n deep: 1,\n onlyFiles: false,\n })\n\n if (entries.length > 0) {\n throw new AbortError(\n outputContent`Directory ${outputToken.path(destination)} already exists and is not empty`,\n outputContent`Choose a different name or remove the existing directory first.`,\n )\n }\n }\n\n const [repository, branch] = repoUrl.split('#')\n const options: TaskOptions = {'--recurse-submodules': null}\n\n if (branch && latestTag) {\n throw new AbortError(\"Error cloning the repository. Git can't clone the latest release with a 'branch'.\")\n }\n if (branch) {\n options['--branch'] = branch\n }\n\n if (shallow && latestTag) {\n throw new AbortError(\n \"Error cloning the repository. Git can't clone the latest release with the 'shallow' property.\",\n )\n }\n if (shallow) {\n options['--depth'] = 1\n }\n\n const progress = ({stage, progress, processed, total}: SimpleGitProgressEvent) => {\n const updateString = `${stage}, ${processed}/${total} objects (${progress}% complete)`\n if (progressUpdater) progressUpdater(updateString)\n }\n\n const simpleGitOptions = {\n progress,\n ...(!isTerminalInteractive() && {config: ['core.askpass=true']}),\n }\n try {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n await git(simpleGitOptions).clone(repository!, destination, options)\n\n if (latestTag) {\n await withGit({directory: destination}, async (localGitRepository) => {\n const latestTag = await getLocalLatestTag(localGitRepository, repoUrl)\n await localGitRepository.checkout(latestTag)\n })\n }\n } catch (err) {\n if (err instanceof Error) {\n const abortError = new AbortError(err.message)\n abortError.stack = err.stack\n throw abortError\n }\n throw err\n }\n })\n}\n\n/**\n * Get the most recent tag of a local git repository.\n *\n * @param repository - The local git repository.\n * @param repoUrl - The URL of the repository.\n * @returns The most recent tag of the repository.\n */\nasync function getLocalLatestTag(repository: SimpleGit, repoUrl: string): Promise<string> {\n const latest = (await repository.tags()).latest\n\n if (!latest) {\n throw new AbortError(`Couldn't obtain the most recent tag of the repository ${repoUrl}`)\n }\n\n return latest\n}\n\n/**\n * Get the latest commit of a git repository.\n *\n * @param directory - The directory of the git repository.\n * @returns The latest commit of the repository.\n */\nexport async function getLatestGitCommit(directory?: string): Promise<DefaultLogFields & ListLogLine> {\n const logs = await withGit({directory}, (repo) => repo.log({maxCount: 1}))\n if (!logs.latest) {\n throw new AbortError(\n 'Must have at least one commit to run command',\n outputContent`Run ${outputToken.genericShellCommand(\n \"git commit -m 'Initial commit'\",\n )} to create your first commit.`,\n )\n }\n return logs.latest\n}\n\n/**\n * Add all files to the git index from the given directory.\n *\n * @param directory - The directory where the git repository is located.\n * @returns A promise that resolves when the files are added to the index.\n */\nexport async function addAllToGitFromDirectory(directory?: string): Promise<void> {\n await withGit({directory}, (repo) => repo.raw('add', '--all'))\n}\n\nexport interface CreateGitCommitOptions {\n directory?: string\n author?: string\n}\n\n/**\n * Create a git commit.\n *\n * @param message - The message of the commit.\n * @param options - The options to use to create the commit.\n * @returns The hash of the created commit.\n */\nexport async function createGitCommit(message: string, options?: CreateGitCommitOptions): Promise<string> {\n const commitOptions = options?.author ? {'--author': options.author} : undefined\n const result = await withGit({directory: options?.directory}, (repo) => repo.commit(message, commitOptions))\n return result.commit\n}\n\n/**\n * Get the HEAD symbolic reference of a git repository.\n *\n * @param directory - The directory of the git repository.\n * @returns The HEAD symbolic reference of the repository.\n */\nexport async function getHeadSymbolicRef(directory?: string): Promise<string> {\n const ref = await withGit({directory}, (repo) => repo.raw('symbolic-ref', '-q', 'HEAD'))\n if (!ref) {\n throw new AbortError(\n \"Git HEAD can't be detached to run command\",\n outputContent`Run ${outputToken.genericShellCommand(\n 'git checkout [branchName]',\n )} to reattach HEAD or see git ${outputToken.link(\n 'documentation',\n 'https://git-scm.com/book/en/v2/Git-Internals-Git-References',\n )} for more details`,\n )\n }\n return ref.trim()\n}\n\n/**\n * If \"git\" is not present in the environment it throws\n * an abort error.\n */\nexport async function ensureGitIsPresentOrAbort(): Promise<void> {\n if (!(await hasGit())) {\n throw new AbortError(\n `Git is necessary in the environment to continue`,\n outputContent`Install ${outputToken.link(\n 'git',\n 'https://git-scm.com/book/en/v2/Getting-Started-Installing-Git',\n )}`,\n )\n }\n}\n\nexport class OutsideGitDirectoryError extends AbortError {}\n/**\n * If command run from outside a .git directory tree\n * it throws an abort error.\n *\n * @param directory - The directory to check.\n */\nexport async function ensureInsideGitDirectory(directory?: string): Promise<void> {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n if (!(await insideGitDirectory(directory))) {\n throw new OutsideGitDirectoryError(`${outputToken.path(directory || cwd())} is not a Git directory`)\n }\n}\n\n/**\n * Returns true if the given directory is inside a .git directory tree.\n *\n * @param directory - The directory to check.\n * @returns True if the directory is inside a .git directory tree.\n */\nexport async function insideGitDirectory(directory?: string): Promise<boolean> {\n return withGit({directory}, (repo) => repo.checkIsRepo())\n}\n\nexport class GitDirectoryNotCleanError extends AbortError {}\n/**\n * If the .git directory tree is not clean (has uncommitted changes)\n * it throws an abort error.\n *\n * @param directory - The directory to check.\n */\nexport async function ensureIsClean(directory?: string): Promise<void> {\n if (!(await isClean(directory))) {\n throw new GitDirectoryNotCleanError(`${outputToken.path(directory || cwd())} is not a clean Git directory`)\n }\n}\n\n/**\n * Returns true if the .git directory tree is clean (no uncommitted changes).\n *\n * @param directory - The directory to check.\n * @returns True is the .git directory is clean.\n */\nexport async function isClean(directory?: string): Promise<boolean> {\n return (await withGit({directory}, (git: SimpleGit) => git.status())).isClean()\n}\n\n/**\n * Returns the latest tag of a git repository.\n *\n * @param directory - The directory to check.\n * @returns String with the latest tag or undefined if no tags are found.\n */\nexport async function getLatestTag(directory?: string): Promise<string | undefined> {\n const tags = await withGit({directory}, (repo) => repo.tags())\n return tags.latest\n}\n\n/**\n * Remove a git remote from the given directory.\n *\n * @param directory - The directory where the git repository is located.\n * @param remoteName - The name of the remote to remove (defaults to 'origin').\n * @returns A promise that resolves when the remote is removed.\n */\nexport async function removeGitRemote(directory: string, remoteName = 'origin'): Promise<void> {\n outputDebug(outputContent`Removing git remote ${remoteName} from ${outputToken.path(directory)}...`)\n await ensureGitIsPresentOrAbort()\n\n await withGit({directory}, async (repo) => {\n // Check if remote exists first\n const remotes = await repo.getRemotes()\n const remoteExists = remotes.some((remote: {name: string}) => remote.name === remoteName)\n\n if (!remoteExists) {\n outputDebug(outputContent`Remote ${remoteName} does not exist, no action needed`)\n return\n }\n\n await repo.removeRemote(remoteName)\n })\n}\n\nasync function withGit<T>(\n {\n directory,\n }: {\n directory?: string\n },\n callback: (git: SimpleGit) => Promise<T>,\n): Promise<T> {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n const repo = git({baseDir: directory})\n try {\n return await callback(repo)\n } catch (err) {\n if (err instanceof Error) {\n const abortError = new AbortError(err.message)\n abortError.stack = err.stack\n throw abortError\n }\n throw err\n }\n}\n"]}
|
|
@@ -2,6 +2,15 @@ import { postrun as deprecationsHook } from './deprecations.js';
|
|
|
2
2
|
import { reportAnalyticsEvent } from '../analytics.js';
|
|
3
3
|
import { outputDebug } from '../../../public/node/output.js';
|
|
4
4
|
import * as metadata from '../../../public/node/metadata.js';
|
|
5
|
+
let postRunHookCompleted = false;
|
|
6
|
+
/**
|
|
7
|
+
* Check if post run hook has completed.
|
|
8
|
+
*
|
|
9
|
+
* @returns Whether post run hook has completed.
|
|
10
|
+
*/
|
|
11
|
+
export function postRunHookHasCompleted() {
|
|
12
|
+
return postRunHookCompleted;
|
|
13
|
+
}
|
|
5
14
|
// This hook is called after each successful command run. More info: https://oclif.io/docs/hooks
|
|
6
15
|
export const hook = async ({ config, Command }) => {
|
|
7
16
|
await detectStopCommand(Command);
|
|
@@ -9,6 +18,7 @@ export const hook = async ({ config, Command }) => {
|
|
|
9
18
|
deprecationsHook(Command);
|
|
10
19
|
const command = Command.id.replace(/:/g, ' ');
|
|
11
20
|
outputDebug(`Completed command ${command}`);
|
|
21
|
+
postRunHookCompleted = true;
|
|
12
22
|
};
|
|
13
23
|
/**
|
|
14
24
|
* Override the command name with the stop one for analytics purposes.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"postrun.js","sourceRoot":"","sources":["../../../../src/public/node/hooks/postrun.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,IAAI,gBAAgB,EAAC,MAAM,mBAAmB,CAAA;AAC7D,OAAO,EAAC,oBAAoB,EAAC,MAAM,iBAAiB,CAAA;AACpD,OAAO,EAAC,WAAW,EAAC,MAAM,gCAAgC,CAAA;AAE1D,OAAO,KAAK,QAAQ,MAAM,kCAAkC,CAAA;AAG5D,gGAAgG;AAChG,MAAM,CAAC,MAAM,IAAI,GAAiB,KAAK,EAAE,EAAC,MAAM,EAAE,OAAO,EAAC,EAAE,EAAE;IAC5D,MAAM,iBAAiB,CAAC,OAAoC,CAAC,CAAA;IAC7D,MAAM,oBAAoB,CAAC,EAAC,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAC,CAAC,CAAA;IACpD,gBAAgB,CAAC,OAAO,CAAC,CAAA;IAEzB,MAAM,OAAO,GAAG,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAA;IAC7C,WAAW,CAAC,qBAAqB,OAAO,EAAE,CAAC,CAAA;
|
|
1
|
+
{"version":3,"file":"postrun.js","sourceRoot":"","sources":["../../../../src/public/node/hooks/postrun.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,IAAI,gBAAgB,EAAC,MAAM,mBAA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AAE,CAAC,CAAC;gBACzC,mBAAmB,EAAE;oBACnB,GAAG,mBAAmB;oBACtB,SAAS,EAAE,WAAW;oBACtB,YAAY,EAAE,WAAW;iBAC1B;aACF,CAAC,CAAC,CAAA;QACL,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["import {postrun as deprecationsHook} from './deprecations.js'\nimport {reportAnalyticsEvent} from '../analytics.js'\nimport {outputDebug} from '../../../public/node/output.js'\nimport BaseCommand from '../base-command.js'\nimport * as metadata from '../../../public/node/metadata.js'\nimport {Command, Hook} from '@oclif/core'\n\nlet postRunHookCompleted = false\n\n/**\n * Check if post run hook has completed.\n *\n * @returns Whether post run hook has completed.\n */\nexport function postRunHookHasCompleted(): boolean {\n return postRunHookCompleted\n}\n\n// This hook is called after each successful command run. More info: https://oclif.io/docs/hooks\nexport const hook: Hook.Postrun = async ({config, Command}) => {\n await detectStopCommand(Command as unknown as typeof Command)\n await reportAnalyticsEvent({config, exitMode: 'ok'})\n deprecationsHook(Command)\n\n const command = Command.id.replace(/:/g, ' ')\n outputDebug(`Completed command ${command}`)\n postRunHookCompleted = true\n}\n\n/**\n * Override the command name with the stop one for analytics purposes.\n *\n * @param commandClass - Oclif command class.\n */\nasync function detectStopCommand(commandClass: Command.Class | typeof BaseCommand): Promise<void> {\n const currentTime = new Date().getTime()\n if (commandClass && Object.prototype.hasOwnProperty.call(commandClass, 'analyticsStopCommand')) {\n const stopCommand = (commandClass as typeof BaseCommand).analyticsStopCommand()\n if (stopCommand) {\n const {commandStartOptions} = metadata.getAllSensitiveMetadata()\n if (!commandStartOptions) return\n await metadata.addSensitiveMetadata(() => ({\n commandStartOptions: {\n ...commandStartOptions,\n startTime: currentTime,\n startCommand: stopCommand,\n },\n }))\n }\n }\n}\n"]}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Extracts import paths from a source file.
|
|
3
|
+
* Supports JavaScript, TypeScript, and Rust files.
|
|
4
|
+
*
|
|
5
|
+
* @param filePath - Path to the file to analyze.
|
|
6
|
+
* @returns Array of absolute paths to imported files.
|
|
7
|
+
*/
|
|
8
|
+
export declare function extractImportPaths(filePath: string): string[];
|
|
9
|
+
/**
|
|
10
|
+
* Recursively extracts import paths from a source file and all its dependencies.
|
|
11
|
+
* Supports JavaScript, TypeScript, and Rust files.
|
|
12
|
+
* Handles circular dependencies by tracking visited files.
|
|
13
|
+
*
|
|
14
|
+
* @param filePath - Path to the file to analyze.
|
|
15
|
+
* @param visited - Set of already visited files to prevent infinite recursion.
|
|
16
|
+
* @returns Array of absolute paths to the provided file and all imported files there (including nested imports).
|
|
17
|
+
* @throws If an unexpected error occurs while processing files (not including ENOENT file not found errors).
|
|
18
|
+
*/
|
|
19
|
+
export declare function extractImportPathsRecursively(filePath: string, visited?: Set<string>): string[];
|
|
20
|
+
/**
|
|
21
|
+
* Extracts import paths from a JavaScript content.
|
|
22
|
+
*
|
|
23
|
+
* @param content - The content to extract imports from.
|
|
24
|
+
* @param filePath - The path to the file to extract imports from.
|
|
25
|
+
* @returns Array of absolute paths to imported files.
|
|
26
|
+
*/
|
|
27
|
+
export declare function extractJSImports(content: string, filePath: string): string[];
|