UNPKG

gitly

Version:

An API to download and/or extract git repositories

1 lines 25.9 kB
{"version":3,"sources":["../src/main.ts","../src/utils/clone.ts","../src/utils/archive.ts","../src/utils/error.ts","../src/utils/execute.ts","../src/utils/exists.ts","../src/utils/parse.ts","../src/utils/offline.ts","../src/utils/download.ts","../src/utils/fetch.ts","../src/utils/write.ts","../src/utils/extract.ts","../src/utils/gitly.ts"],"sourcesContent":["export { default } from './utils/gitly'\r\nexport { default as download } from './utils/download'\r\nexport { default as extract } from './utils/extract'\r\nexport { default as parse } from './utils/parse'\r\nexport { default as clone } from './utils/clone'\r\n","import spawn from 'cross-spawn'\r\nimport { rm } from 'node:fs/promises'\r\nimport path from 'node:path'\r\nimport * as tar from 'tar'\r\nimport type GitlyOptions from '../interfaces/options'\r\nimport { getArchivePath } from './archive'\r\nimport { GitlyCloneError } from './error'\r\nimport execute from './execute'\r\nimport exists from './exists'\r\nimport { isOffline } from './offline'\r\nimport parse from './parse'\r\n/**\r\n * Uses local git installation to clone a repository to the destination.\r\n * @param repository The repository to clone\r\n * @param options The options to use\r\n * @returns The path to the cloned repository\r\n * @throws {GitlyCloneError} When the repository fails to clone\r\n * @note This method requires a local git installation\r\n * @note This method caches the repository by default\r\n * @example\r\n * ```js\r\n * // ...\r\n * const path = await clone('iwatakeshi/git-copy')\r\n * // ...\r\n * ```\r\n */\r\nexport default async function clone(\r\n repository: string,\r\n options: GitlyOptions = {}\r\n): Promise<string> {\r\n const info = parse(repository, options)\r\n const archivePath = getArchivePath(info, options)\r\n const directory = archivePath.replace(/\\.tar\\.gz$/, '')\r\n let order: (() => Promise<boolean | string>)[] = []\r\n\r\n const local = async () => exists(`${archivePath}.tar.gz`)\r\n const remote = async () => {\r\n // If the repository is cached, remove the old cache\r\n if (await exists(archivePath)) {\r\n /* istanbul ignore next */\r\n await rm(archivePath)\r\n }\r\n\r\n // Prevent second order command injection\r\n\r\n const depth = options?.git?.depth || 1\r\n\r\n if (\r\n repository.includes('--upload-pack') ||\r\n directory.includes('--upload-pack')\r\n ) {\r\n throw new GitlyCloneError('Invalid argument')\r\n }\r\n\r\n /* istanbul ignore if */\r\n if (typeof depth !== 'number') {\r\n throw new GitlyCloneError('Invalid depth option')\r\n }\r\n\r\n /* istanbul ignore if */\r\n if (info.href.includes('--upload-pack')) {\r\n throw new GitlyCloneError('Invalid argument')\r\n }\r\n\r\n const child = spawn('git', [\r\n 'clone',\r\n '--depth',\r\n depth.toString(),\r\n info.href,\r\n directory,\r\n ])\r\n\r\n await new Promise((resolve, reject) => {\r\n child.on('error', (reason) => reject(new GitlyCloneError(reason.message)))\r\n child.on('close', (code) => {\r\n /* istanbul ignore next */\r\n if (code === 0) {\r\n // delete the .git directory to make the archive smaller\r\n rm(path.resolve(directory, '.git'), { recursive: true })\r\n .then(() =>\r\n // Create the archive after cloning\r\n tar.create(\r\n {\r\n gzip: true,\r\n file: archivePath,\r\n // Go one level up to include the repository name in the archive\r\n cwd: path.resolve(archivePath, '..'),\r\n portable: true,\r\n },\r\n [info.type]\r\n )\r\n )\r\n .then(() =>\r\n rm(path.resolve(directory), {\r\n recursive: true,\r\n })\r\n )\r\n .then(resolve)\r\n .catch((error) => reject(new GitlyCloneError(error.message)))\r\n } /* istanbul ignore next */ else {\r\n reject(new GitlyCloneError('Failed to clone the repository'))\r\n }\r\n })\r\n })\r\n return archivePath\r\n }\r\n /* istanbul ignore next */\r\n if ((await isOffline()) || options.cache) {\r\n order = [local]\r\n } else if (options.force || ['master', 'main'].includes(info.type)) {\r\n order = [remote, local]\r\n }\r\n\r\n try {\r\n const result = await execute(order)\r\n if (typeof result === 'boolean') {\r\n return archivePath\r\n }\r\n return result\r\n } catch (error) {\r\n if (options.throw) {\r\n throw error\r\n }\r\n }\r\n return ''\r\n}\r\n","import os from 'node:os'\r\nimport { join } from 'node:path'\r\nimport * as tar from 'tar'\r\n\r\nimport type GitlyOptions from '../interfaces/options'\r\nimport type URLInfo from '../interfaces/url'\r\n\r\nexport function getArchiveUrl(\r\n info: URLInfo,\r\n options: GitlyOptions = {}\r\n): string {\r\n const { path: repo, type } = info\r\n\r\n if (options.url?.filter) {\r\n return options.url.filter(info)\r\n }\r\n\r\n switch (info.hostname) {\r\n case 'bitbucket':\r\n return `https://bitbucket.org${repo}/get/${type}.tar.gz`\r\n case 'gitlab':\r\n return `https://gitlab.com${repo}/-/archive/${type}/${\r\n repo.split('/')[2]\r\n }-${type}.tar.gz`\r\n default:\r\n return `https://github.com${repo}/archive/${type}.tar.gz`\r\n }\r\n}\r\n\r\nexport function getArchivePath(\r\n info: URLInfo,\r\n options: GitlyOptions = {}\r\n): string {\r\n const { path, type, hostname: site } = info\r\n\r\n return join(\r\n options.temp || join(os.homedir(), '.gitly'),\r\n site,\r\n path,\r\n `${type}.tar.gz`\r\n )\r\n}\r\n\r\nexport const extract = tar.extract\r\n","export enum GitlyErrorType {\r\n Fetch = 'fetch',\r\n Clone = 'clone',\r\n Extract = 'extract',\r\n Download = 'download',\r\n Unknown = 'unknown',\r\n}\r\n\r\nexport default abstract class GitlyAbstractError extends Error {\r\n static type: GitlyErrorType\r\n type: GitlyErrorType\r\n rawMessage: string\r\n constructor(\r\n readonly message: string,\r\n readonly code: number = -1\r\n ) {\r\n super(message)\r\n this.rawMessage = message\r\n // biome-ignore lint/suspicious/noAssignInExpressions: <explanation>\r\n const type = (this.type = this.ctor.type)\r\n this.message = `[${type ? `gitly:${type}` : 'gitly'}]: ${message}`\r\n Object.setPrototypeOf(this, new.target.prototype)\r\n }\r\n\r\n get ctor(): typeof GitlyAbstractError {\r\n return this.constructor as typeof GitlyAbstractError\r\n }\r\n}\r\n\r\n// biome-ignore lint/complexity/noStaticOnlyClass: <explanation>\r\nexport const GitlyUnknownError = class extends GitlyAbstractError {\r\n static type = GitlyErrorType.Unknown\r\n}\r\n\r\n// biome-ignore lint/complexity/noStaticOnlyClass: <explanation>\r\nexport const GitlyFetchError = class extends GitlyAbstractError {\r\n static type = GitlyErrorType.Fetch\r\n}\r\n\r\n// biome-ignore lint/complexity/noStaticOnlyClass: <explanation>\r\nexport const GitlyExtractError = class extends GitlyAbstractError {\r\n static type = GitlyErrorType.Extract\r\n}\r\n\r\n// biome-ignore lint/complexity/noStaticOnlyClass: <explanation>\r\nexport const GitlyDownloadError = class extends GitlyAbstractError {\r\n static type = GitlyErrorType.Download\r\n}\r\n\r\n// biome-ignore lint/complexity/noStaticOnlyClass: <explanation>\r\nexport const GitlyCloneError = class extends GitlyAbstractError {\r\n static type = GitlyErrorType.Clone\r\n}\r\n","export type Task = () => Promise<string | boolean>\r\n\r\nexport default async function execute(\r\n tasks: Task[]\r\n): Promise<string | boolean> {\r\n return new Promise((resolve, reject) => {\r\n const next = () => execute(tasks.slice(1)).then(resolve)\r\n return tasks[0]()\r\n .then((t) => (t ? resolve(t) : next()))\r\n .catch(reject)\r\n })\r\n}\r\n","import { constants, promises as fs } from 'node:fs'\r\nimport { isAbsolute } from 'node:path'\r\n\r\nimport type GitlyOptions from '../interfaces/options'\r\n\r\nimport parse from './parse'\r\nimport { getArchivePath } from './archive'\r\n\r\nexport default async function exists(\r\n path: string,\r\n options: GitlyOptions = {}\r\n): Promise<boolean> {\r\n let _path = path\r\n if (!isAbsolute(path)) {\r\n _path = getArchivePath(parse(path), options)\r\n }\r\n try {\r\n await fs.access(_path, constants.F_OK)\r\n return true\r\n // eslint-disable-next-line no-empty\r\n } catch (_) {}\r\n return false\r\n}\r\n","import { URL } from 'node:url'\r\n\r\nimport type GitlyOptions from '../interfaces/options'\r\nimport type URLInfo from '../interfaces/url'\r\n\r\n/**\r\n * Parses a url and returns the metadata\r\n *\r\n * @example\r\n * ```markdown\r\n * 1. owner/repo\r\n * 2. owner/repo#tag\r\n * 3. https://host.com/owner/repo\r\n * 4. host.com/owner/repo\r\n * 5. host.com/owner/repo#tag\r\n * 6. host:owner/repo\r\n * 7. host:owner/repo#tag\r\n * ```\r\n */\r\nexport default function parse(\r\n url: string,\r\n options: GitlyOptions = {}\r\n): URLInfo {\r\n const { url: normalized, host } = normalizeURL(url, options)\r\n const result = new URL(normalized)\r\n const paths = (result.pathname || '').split('/').filter(Boolean)\r\n const owner = paths.shift() || ''\r\n const repository = paths.shift() || ''\r\n return {\r\n protocol: (result.protocol || 'https').replace(/:/g, ''),\r\n host: result.host || host || 'github.com',\r\n hostname: (result.hostname || host || 'github').replace(/\\.(\\S+)/, ''),\r\n hash: result.hash || '',\r\n href: result.href || '',\r\n path: result.pathname || '',\r\n repository,\r\n owner,\r\n type: (result.hash || '#master').substring(1),\r\n }\r\n}\r\n\r\nfunction normalizeURL(url: string, options: GitlyOptions) {\r\n const { host } = options\r\n\r\n /* istanbul ignore if */\r\n if (url.includes('0') && Array.from(url.matchAll(/0/g)).length > 25) {\r\n throw new Error('Invalid argument')\r\n }\r\n /* istanbul ignore if */\r\n if (host?.includes('0') && Array.from(host.matchAll(/0/g)).length > 25) {\r\n throw new Error('Invalid argument')\r\n }\r\n\r\n const isNotProtocol = !/http(s)?:\\/\\//.test(url)\r\n const hasHost = /([\\S]+):.+/.test(url)\r\n const hasTLD = /[\\S]+\\.([\\D]+)/.test(url)\r\n\r\n let normalizedURL = url.replace('www.', '').replace('.git', '')\r\n let updatedHost = host || ''\r\n\r\n if (isNotProtocol && hasHost) {\r\n // Matches host:owner/repo\r\n const hostMatch = url.match(/([\\S]+):.+/)\r\n updatedHost = hostMatch ? hostMatch[1] : ''\r\n normalizedURL = `https://${updatedHost}.com/${normalizedURL.replace(`${updatedHost}:`, '')}`\r\n } else if (isNotProtocol && hasTLD) {\r\n // Matches host.com/...\r\n normalizedURL = `https://${normalizedURL}`\r\n } else if (isNotProtocol) {\r\n // Matches owner/repo\r\n const tldMatch = (host || '').match(/[\\S]+\\.([\\D]+)/)\r\n const domain = (host || 'github').replace(\r\n `.${tldMatch ? tldMatch[1] : 'com'}`,\r\n ''\r\n )\r\n const tld = tldMatch ? tldMatch[1] : 'com'\r\n normalizedURL = `https://${domain}.${tld}/${normalizedURL}`\r\n }\r\n\r\n return { url: normalizedURL, host: updatedHost }\r\n}\r\n","import { promises as dns } from 'node:dns'\r\nconst { lookup } = dns\r\nexport async function isOffline(): Promise<boolean> {\r\n try {\r\n await lookup('google.com')\r\n return false\r\n // eslint-disable-next-line no-empty\r\n } catch (_) {}\r\n return true\r\n}\r\n","import type GitlyOptions from '../interfaces/options'\r\n\r\nimport shelljs from 'shelljs'\r\nimport { getArchivePath, getArchiveUrl } from './archive'\r\nimport execute from './execute'\r\nimport exists from './exists'\r\nimport fetch from './fetch'\r\nimport { isOffline } from './offline'\r\nimport parse from './parse'\r\n\r\nconst { rm } = shelljs\r\n\r\n/**\r\n * Download the tar file from the repository\r\n * and store it in a temporary directory\r\n * @param repository The repository to download\r\n *\r\n * @example\r\n * ```js\r\n * // ..\r\n * const path = await download('iwatakeshi/git-copy')\r\n * // ...\r\n * ```\r\n */\r\nexport default async function download(\r\n repository: string,\r\n options: GitlyOptions = {}\r\n): Promise<string> {\r\n const info = parse(repository, options)\r\n const archivePath = getArchivePath(info, options)\r\n const url = getArchiveUrl(info, options)\r\n const local = async () => exists(archivePath)\r\n const remote = async () => {\r\n // If the repository is cached, remove the old cache\r\n if (await exists(archivePath)) {\r\n /* istanbul ignore next */\r\n rm(archivePath)\r\n }\r\n\r\n return fetch(url, archivePath, options)\r\n }\r\n let order = [local, remote]\r\n if ((await isOffline()) || options.cache) {\r\n order = [local]\r\n } else if (options.force || ['master', 'main'].includes(info.type)) {\r\n order = [remote, local]\r\n }\r\n\r\n try {\r\n const result = await execute(order)\r\n if (typeof result === 'boolean') {\r\n return archivePath\r\n }\r\n return result\r\n } catch (error) {\r\n if (options.throw) {\r\n throw error\r\n }\r\n }\r\n return ''\r\n}\r\n","import axios, { AxiosProxyConfig } from 'axios'\r\nimport * as stream from 'node:stream'\r\nimport { promisify } from 'node:util'\r\n\r\nimport { GitlyDownloadError } from './error'\r\nimport write from './write'\r\nimport type GitlyOptions from '../interfaces/options'\r\nimport { URL } from 'node:url'\r\n\r\nconst pipeline = promisify(stream.pipeline)\r\n\r\nexport default async function fetch(\r\n url: string,\r\n file: string,\r\n options: GitlyOptions = {}\r\n): Promise<string> {\r\n const response = await axios.get(url, {\r\n headers: options.headers,\r\n proxy: getProxy(options.proxy),\r\n responseType: 'stream',\r\n validateStatus: (status) => status >= 200 && status < 500,\r\n })\r\n\r\n const { statusText: message, status: code } = response\r\n if (code >= 400) throw new GitlyDownloadError(message, code)\r\n if (code >= 300 && code < 400 && response.headers.location) {\r\n return fetch(response.headers.location, file)\r\n }\r\n await pipeline(response.data, await write(file))\r\n return file\r\n}\r\n\r\nfunction getProxy(proxy: GitlyOptions['proxy']): AxiosProxyConfig | false {\r\n if (typeof proxy?.host === 'string' && typeof proxy?.port === 'number') {\r\n return proxy\r\n }\r\n\r\n const proxyUrl = process.env.https_proxy || process.env.http_proxy\r\n if (typeof proxyUrl === 'string') {\r\n try {\r\n const url = new URL(proxyUrl)\r\n const { protocol, hostname, port } = url\r\n \r\n // Port is required by AxiosProxyConfig, so only return proxy if port is present\r\n if (!port) {\r\n return false\r\n }\r\n \r\n return {\r\n protocol: protocol.replace(':', ''),\r\n host: hostname,\r\n port: Number.parseInt(port),\r\n }\r\n } catch {\r\n return false;\r\n }\r\n }\r\n\r\n return false\r\n}","import type { WriteStream } from 'node:fs'\r\nimport { createWriteStream, promises as fs } from 'node:fs'\r\nimport { dirname, normalize } from 'node:path'\r\n\r\nconst { mkdir } = fs\r\n/**\r\n * Create a folder and return a writable stream.\r\n * @param path The path to write a file\r\n */\r\nexport default async function write(path: string): Promise<WriteStream> {\r\n const _path = normalize(path)\r\n await mkdir(dirname(_path), { recursive: true })\r\n return createWriteStream(_path)\r\n}\r\n","import { promises as fs } from 'node:fs'\r\nimport { resolve } from 'node:path'\r\n\r\nimport type GitlyOptions from '../interfaces/options'\r\n\r\nimport exists from './exists'\r\nimport { extract } from './archive'\r\n\r\nconst { mkdir } = fs\r\n\r\n/**\r\n * Extract a zipped file to the specified destination\r\n * @param source The source zipped file\r\n * @param destination The path to extract the zipped file\r\n * @param options\r\n *\r\n */\r\nexport default async (\r\n source: string,\r\n destination: string,\r\n options: GitlyOptions = {}\r\n): Promise<string> => {\r\n const _destination = resolve(destination)\r\n if (await exists(source, options)) {\r\n try {\r\n const filter = options.extract?.filter\r\n ? options.extract.filter\r\n : () => true\r\n await mkdir(destination, { recursive: true })\r\n await extract({ strip: 1, filter, file: source, cwd: _destination })\r\n return _destination\r\n // eslint-disable-next-line no-empty\r\n } catch (_) {}\r\n }\r\n return ''\r\n}\r\n","import type GitlyOptions from '../interfaces/options'\r\nimport clone from './clone'\r\nimport download from './download'\r\nimport extract from './extract'\r\n\r\n/**\r\n * Downloads and extracts the repository\r\n * @param repository The repository to download\r\n * @param destination The destination to extract\r\n * @returns A tuple with the source and destination respectively\r\n */\r\nexport default async function gitly(\r\n repository: string,\r\n destination: string,\r\n options: GitlyOptions\r\n): Promise<[string, string]> {\r\n let source = ''\r\n switch (options?.backend) {\r\n case 'git':\r\n source = await clone(repository, options)\r\n break\r\n default:\r\n source = await download(repository, options)\r\n break\r\n }\r\n\r\n return [source, await extract(source, destination, options)]\r\n}\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,yBAAkB;AAClB,sBAAmB;AACnB,IAAAA,oBAAiB;AACjB,IAAAC,OAAqB;;;ACHrB,qBAAe;AACf,uBAAqB;AACrB,UAAqB;AAKd,SAAS,cACd,MACA,UAAwB,CAAC,GACjB;AAVV,MAAAC;AAWE,QAAM,EAAE,MAAM,MAAM,KAAK,IAAI;AAE7B,OAAIA,MAAA,QAAQ,QAAR,gBAAAA,IAAa,QAAQ;AACvB,WAAO,QAAQ,IAAI,OAAO,IAAI;AAAA,EAChC;AAEA,UAAQ,KAAK,UAAU;AAAA,IACrB,KAAK;AACH,aAAO,wBAAwB,IAAI,QAAQ,IAAI;AAAA,IACjD,KAAK;AACH,aAAO,qBAAqB,IAA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S,SAAS;AAAA,IACxB,KAAK;AACH,eAAS,MAAM,MAAM,YAAY,OAAO;AACxC;AAAA,IACF;AACE,eAAS,MAAM,SAAS,YAAY,OAAO;AAC3C;AAAA,EACJ;AAEA,SAAO,CAAC,QAAQ,MAAM,gBAAQ,QAAQ,aAAa,OAAO,CAAC;AAC7D;","names":["import_node_path","tar","_a","path","os","extract","_a","resolve","import_node_path","path","fs","dns","_a","spawn","resolve","path","import_node_fs","import_node_path","fs","path","import_node_url","pipeline","axios","rm","shelljs","import_node_fs","import_node_path","mkdir","fs","_a","extract"]}