cache-cmd 0.3.0 → 0.4.0-dev.9ebf4bb66905066a9094a49f834742ec7c0fc624
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/dist/cli.js +1 -1
- package/dist/cli.js.map +1 -1
- package/package.json +9 -2
package/dist/cli.js
CHANGED
package/dist/cli.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/cli.ts", "../package.json", "../src/cache-clear.ts", "../src/utils/get-cache-dir.ts", "../src/cache-dir.ts", "../src/run.ts", "../src/utils/get-cache-key.ts", "../src/utils/get-duration.ts", "../src/utils/get-file-hashes.ts", "../src/utils/get-file-paths.ts"],
|
|
4
|
-
"sourcesContent": ["#!/usr/bin/env node\n\nimport hardRejection from 'hard-rejection'\nimport sade from 'sade'\n\nimport { version } from '../package.json'\n\nimport { clearCacheDirectory } from './cache-clear'\nimport { showCacheDirectory } from './cache-dir'\nimport { runCommand } from './run'\n\nhardRejection()\n\nconst program = sade('cache-cmd')\n\nprogram\n .version(version)\n .describe('Run and cache a command based on various factors')\n .option(\n '-c, --cache-dir',\n 'Cache directory to use (default: .cache/cache-cmd in nearest node_modules)'\n )\n\nprogram\n .command(\n 'run <command>',\n 'Run cached command (if no <command> provided, this is the default)',\n { default: true }\n )\n .option('-f, --file', 'Run command only when file content changes')\n .option('-t, --time', 'Run command only after specified time (unit with s,m,h,d,w,mo,y)')\n .option('--cache-on-error', 'Cache command run even when command exits with non-zero exit code')\n .example('run \"echo ran this command\" --time 20s')\n .example('run \"./may-fail\" --time 20s --cache-on-error')\n .example('run \"yarn install\" --file yarn.lock')\n .example('run \"yarn install\" --file yarn.lock --cache-dir .config/cache')\n .example('run \"yarn install\" --time 1mo --file yarn.lock --file package.json')\n .action((command: unknown, options: Record<string, unknown>) => {\n const cacheDirectory = options['cache-dir']\n const time = options.time\n const file = options.file\n const shouldCacheOnError = options['cache-on-error']\n const files: unknown[] = file === undefined ? [] : Array.isArray(file) ? file : [file]\n\n if (typeof command !== 'string') {\n throw Error('Invalid <command> supplied')\n }\n\n if (cacheDirectory !== undefined && typeof cacheDirectory !== 'string') {\n throw Error('Invalid --cache-dir supplied')\n }\n\n if (time !== undefined && typeof time !== 'string') {\n throw Error('Invalid --time supplied')\n }\n\n if (files.some((file) => typeof file !== 'string')) {\n throw Error('Invalid --file supplied')\n }\n\n if (shouldCacheOnError !== undefined && typeof shouldCacheOnError !== 'boolean') {\n throw Error('Invalid --cache-on-error supplied')\n }\n\n runCommand({\n relativeCacheDirectory: cacheDirectory,\n command,\n cacheByTime: time,\n cacheByFiles: files as string[],\n shouldCacheOnError,\n })\n })\n\nprogram\n .command('cache dir', 'Show cache directory path used by cache-cmd')\n .action((options: Record<string, unknown>) => {\n const cacheDirectory = options['cache-dir']\n\n if (cacheDirectory !== undefined && typeof cacheDirectory !== 'string') {\n throw Error('Invalid --cache-dir supplied')\n }\n\n showCacheDirectory(cacheDirectory)\n })\n\nprogram\n .command('cache clear', 'Clear cache used by cache-cmd')\n .action((options: Record<string, unknown>) => {\n const cacheDirectory = options['cache-dir']\n\n if (cacheDirectory !== undefined && typeof cacheDirectory !== 'string') {\n throw Error('Invalid --cache-dir supplied')\n }\n\n clearCacheDirectory(cacheDirectory)\n })\n\nprogram.parse(process.argv)\n", "{\n \"name\": \"cache-cmd\",\n \"version\": \"0.3.0\",\n \"description\": \"Run and cache a command based on various factors\",\n \"keywords\": [\n \"cache\",\n \"debounce\",\n \"cli\",\n \"conditional\",\n \"run\",\n \"cmd\",\n \"command\",\n \"time\",\n \"hash\"\n ],\n \"homepage\": \"https://github.com/dcastil/cache-cmd\",\n \"bugs\": {\n \"url\": \"https://github.com/dcastil/cache-cmd/issues\"\n },\n \"license\": \"MIT\",\n \"author\": \"Dany Castillo\",\n \"files\": [\n \"dist\",\n \"src\"\n ],\n \"bin\": \"dist/cli.js\",\n \"type\": \"module\",\n \"source\": \"src/cli.ts\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/dcastil/cache-cmd.git\"\n },\n \"scripts\": {\n \"cache-cmd\": \"node ./dist/cli.js\",\n \"build\": \"rm -rf dist/* && esbuild src/cli.ts --bundle --platform=node --target=node20 --packages=external --format=esm --sourcemap --outfile=dist/cli.js\",\n \"type-check\": \"tsc --build\",\n \"preversion\": \"if [ -n \\\"$DANYS_MACHINE\\\" ]; then git checkout main && git pull; fi\",\n \"postversion\": \"if [ -n \\\"$DANYS_MACHINE\\\" ]; then git push --follow-tags && open https://github.com/dcastil/cache-cmd/releases; fi\"\n },\n \"dependencies\": {\n \"date-fns\": \"^4.1.0\",\n \"del\": \"^8.0.0\",\n \"exec-sh\": \"^0.4.0\",\n \"find-cache-dir\": \"^5.0.0\",\n \"flat-cache\": \"^6.1.3\",\n \"hard-rejection\": \"^2.1.0\",\n \"hasha\": \"^6.0.0\",\n \"lodash-es\": \"^4.17.21\",\n \"sade\": \"^1.8.1\"\n },\n \"devDependencies\": {\n \"@types/find-cache-dir\": \"^5.0.2\",\n \"@types/flat-cache\": \"^2.0.2\",\n \"@types/lodash-es\": \"^4.17.12\",\n \"@types/node\": \"^22.10.1\",\n \"@types/sade\": \"^1.8.0\",\n \"esbuild\": \"^0.24.0\",\n \"prettier\": \"^3.4.2\",\n \"typescript\": \"^5.7.2\"\n }\n}\n", "import { deleteSync } from 'del'\n\nimport { getCacheDirectoryPath } from './utils/get-cache-dir'\n\nexport function clearCacheDirectory(relativeCacheDirectory: string | undefined) {\n const deletedPaths = deleteSync(getCacheDirectoryPath(relativeCacheDirectory))\n\n if (deletedPaths.length === 0) {\n console.log('No cache to clear')\n } else if (deletedPaths.length === 1) {\n console.log(`Deleted: ${deletedPaths[0]}`)\n } else {\n console.log('Deleted:\\n', deletedPaths.join('\\n'))\n }\n}\n", "import path from 'path'\n\nimport findCacheDir from 'find-cache-dir'\n\nimport { name } from '../../package.json'\n\nexport function getCacheDirectoryPath(relativeCacheDirectoryPath: string | undefined) {\n if (relativeCacheDirectoryPath) {\n return path.resolve(process.cwd(), relativeCacheDirectoryPath)\n }\n\n const resolvedCacheDirectory = findCacheDir({ name })\n\n if (!resolvedCacheDirectory) {\n throw Error('Could not find cache directory. Please provide a cache directory manually.')\n }\n\n return resolvedCacheDirectory\n}\n", "import { getCacheDirectoryPath } from './utils/get-cache-dir'\n\nexport function showCacheDirectory(relativeCacheDirectory: string | undefined) {\n console.log(getCacheDirectoryPath(relativeCacheDirectory))\n}\n", "import { add, isAfter } from 'date-fns'\nimport execSh from 'exec-sh'\nimport { create } from 'flat-cache'\nimport { isEqual } from 'lodash-es'\n\nimport { getCacheDirectoryPath } from './utils/get-cache-dir'\nimport { getCacheKey } from './utils/get-cache-key'\nimport { getDuration } from './utils/get-duration'\nimport { getFileHashes } from './utils/get-file-hashes'\nimport { getFilePaths } from './utils/get-file-paths'\n\ninterface RunCommandProps {\n relativeCacheDirectory: string | undefined\n command: string\n cacheByTime: string | undefined\n cacheByFiles: string[]\n shouldCacheOnError: boolean | undefined\n}\n\nexport async function runCommand({\n relativeCacheDirectory,\n command,\n cacheByTime: cacheByTime,\n cacheByFiles: cacheByFiles,\n shouldCacheOnError,\n}: RunCommandProps) {\n if (!cacheByTime && cacheByFiles.length === 0) {\n console.log(`Executing command \"${command}\" due to no caching options provided`)\n await execSh.promise(command)\n return\n }\n\n const cache = create({\n cacheId: 'commands-cache.json',\n cacheDir: getCacheDirectoryPath(relativeCacheDirectory),\n lruSize: 10_000,\n })\n const filePaths = getFilePaths(cacheByFiles)\n const duration = cacheByTime ? getDuration(cacheByTime) : undefined\n\n const cacheKey = getCacheKey({ duration, filePaths, command })\n\n const cacheData: unknown = cache.getKey(cacheKey)\n\n const fileHashes = filePaths.length === 0 ? undefined : await getFileHashes(filePaths)\n const currentDate = new Date()\n\n const areFileHashesEqual = isEqual((cacheData as any)?.fileHashes, fileHashes)\n const isWithinCacheTime = (() => {\n if (!duration) {\n return true\n }\n\n const lastRun = (cacheData as any)?.lastRun\n\n if (!lastRun) {\n return false\n }\n\n return isAfter(add(new Date(lastRun), duration), currentDate)\n })()\n\n if (areFileHashesEqual && isWithinCacheTime) {\n console.log(\n [\n `Skipping command \"${command}\" due to`,\n [fileHashes && 'unchanged files', duration && 'being within cache time']\n .filter(Boolean)\n .join(' and '),\n ].join(' '),\n )\n return\n }\n\n console.log(\n [\n `Executing command \"${command}\" due to`,\n [fileHashes && 'changed files', duration && 'cache time passing']\n .filter(Boolean)\n .join(' and '),\n ].join(' '),\n )\n let execPromise = execSh.promise(command)\n\n function setCache() {\n cache.setKey(cacheKey, {\n lastRun: currentDate,\n fileHashes,\n })\n cache.save(true)\n console.log(`Cache saved for command \"${command}\"`)\n }\n\n if (shouldCacheOnError) {\n execPromise = execPromise.catch((error: unknown) => {\n setCache()\n\n throw error\n })\n }\n\n await execPromise\n\n setCache()\n}\n", "interface GetCacheKeyProps {\n duration: Duration | undefined\n filePaths: string[]\n command: string\n}\n\ninterface Duration {\n years: number | undefined\n months: number | undefined\n weeks: number | undefined\n days: number | undefined\n hours: number | undefined\n minutes: number | undefined\n seconds: number | undefined\n}\n\nexport function getCacheKey({ duration, filePaths, command }: GetCacheKeyProps) {\n return [\n 'cwd:' + process.cwd(),\n 'cmd:' + command,\n duration && 'time:' + JSON.stringify(duration),\n filePaths.length !== 0 && 'files:' + filePaths.join(','),\n ]\n .filter(Boolean)\n .join(' ---')\n}\n", "export function getDuration(durationString: string) {\n if (!/^(\\d+[a-z]+)+$/gi.test(durationString)) {\n throw Error(`Invalid duration: ${durationString}`)\n }\n\n const duration = {\n years: undefined as undefined | number,\n months: undefined as undefined | number,\n weeks: undefined as undefined | number,\n days: undefined as undefined | number,\n hours: undefined as undefined | number,\n minutes: undefined as undefined | number,\n seconds: undefined as undefined | number,\n }\n\n durationString.match(/\\d+[a-z]+/gi)!.forEach((durationPart) => {\n const [, stringQuantity, unitShort] = /(\\d+)([a-z]+)/gi.exec(durationPart)!\n const quantity = Number(stringQuantity)\n\n const unitLong = (\n {\n y: 'years',\n mo: 'months',\n w: 'weeks',\n d: 'days',\n h: 'hours',\n m: 'minutes',\n s: 'seconds',\n } as const\n )[unitShort!]\n\n if (Number.isNaN(quantity) || !unitLong) {\n throw Error(`Invalid duration part: ${durationPart}`)\n }\n\n if (duration[unitLong] !== undefined) {\n throw Error(`Duration with unit ${unitLong} was supplied multiple times`)\n }\n\n duration[unitLong] = quantity\n })\n\n return duration\n}\n", "import { hashFile } from 'hasha'\n\nexport async function getFileHashes(filePaths: string[]) {\n return Object.fromEntries(\n await Promise.all(\n filePaths.map((filePath) =>\n hashFile(filePath, { algorithm: 'md5' }).then((hash) => [filePath, hash] as const),\n ),\n ),\n )\n}\n", "import path from 'path'\n\nexport function getFilePaths(relativeFilePaths: string[]) {\n const cwd = process.cwd()\n\n return relativeFilePaths.map((file) => path.resolve(cwd, file)).sort()\n}\n"],
|
|
4
|
+
"sourcesContent": ["#!/usr/bin/env node\n\nimport hardRejection from 'hard-rejection'\nimport sade from 'sade'\n\nimport { version } from '../package.json'\n\nimport { clearCacheDirectory } from './cache-clear'\nimport { showCacheDirectory } from './cache-dir'\nimport { runCommand } from './run'\n\nhardRejection()\n\nconst program = sade('cache-cmd')\n\nprogram\n .version(version)\n .describe('Run and cache a command based on various factors')\n .option(\n '-c, --cache-dir',\n 'Cache directory to use (default: .cache/cache-cmd in nearest node_modules)'\n )\n\nprogram\n .command(\n 'run <command>',\n 'Run cached command (if no <command> provided, this is the default)',\n { default: true }\n )\n .option('-f, --file', 'Run command only when file content changes')\n .option('-t, --time', 'Run command only after specified time (unit with s,m,h,d,w,mo,y)')\n .option('--cache-on-error', 'Cache command run even when command exits with non-zero exit code')\n .example('run \"echo ran this command\" --time 20s')\n .example('run \"./may-fail\" --time 20s --cache-on-error')\n .example('run \"yarn install\" --file yarn.lock')\n .example('run \"yarn install\" --file yarn.lock --cache-dir .config/cache')\n .example('run \"yarn install\" --time 1mo --file yarn.lock --file package.json')\n .action((command: unknown, options: Record<string, unknown>) => {\n const cacheDirectory = options['cache-dir']\n const time = options.time\n const file = options.file\n const shouldCacheOnError = options['cache-on-error']\n const files: unknown[] = file === undefined ? [] : Array.isArray(file) ? file : [file]\n\n if (typeof command !== 'string') {\n throw Error('Invalid <command> supplied')\n }\n\n if (cacheDirectory !== undefined && typeof cacheDirectory !== 'string') {\n throw Error('Invalid --cache-dir supplied')\n }\n\n if (time !== undefined && typeof time !== 'string') {\n throw Error('Invalid --time supplied')\n }\n\n if (files.some((file) => typeof file !== 'string')) {\n throw Error('Invalid --file supplied')\n }\n\n if (shouldCacheOnError !== undefined && typeof shouldCacheOnError !== 'boolean') {\n throw Error('Invalid --cache-on-error supplied')\n }\n\n runCommand({\n relativeCacheDirectory: cacheDirectory,\n command,\n cacheByTime: time,\n cacheByFiles: files as string[],\n shouldCacheOnError,\n })\n })\n\nprogram\n .command('cache dir', 'Show cache directory path used by cache-cmd')\n .action((options: Record<string, unknown>) => {\n const cacheDirectory = options['cache-dir']\n\n if (cacheDirectory !== undefined && typeof cacheDirectory !== 'string') {\n throw Error('Invalid --cache-dir supplied')\n }\n\n showCacheDirectory(cacheDirectory)\n })\n\nprogram\n .command('cache clear', 'Clear cache used by cache-cmd')\n .action((options: Record<string, unknown>) => {\n const cacheDirectory = options['cache-dir']\n\n if (cacheDirectory !== undefined && typeof cacheDirectory !== 'string') {\n throw Error('Invalid --cache-dir supplied')\n }\n\n clearCacheDirectory(cacheDirectory)\n })\n\nprogram.parse(process.argv)\n", "{\n \"name\": \"cache-cmd\",\n \"version\": \"0.4.0\",\n \"description\": \"Run and cache a command based on various factors\",\n \"keywords\": [\n \"cache\",\n \"debounce\",\n \"cli\",\n \"conditional\",\n \"run\",\n \"cmd\",\n \"command\",\n \"time\",\n \"hash\"\n ],\n \"homepage\": \"https://github.com/dcastil/cache-cmd\",\n \"bugs\": {\n \"url\": \"https://github.com/dcastil/cache-cmd/issues\"\n },\n \"funding\": {\n \"type\": \"github\",\n \"url\": \"https://github.com/sponsors/dcastil\"\n },\n \"license\": \"MIT\",\n \"author\": \"Dany Castillo\",\n \"files\": [\n \"dist\",\n \"src\"\n ],\n \"bin\": \"dist/cli.js\",\n \"type\": \"module\",\n \"source\": \"src/cli.ts\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git+https://github.com/dcastil/cache-cmd.git\"\n },\n \"scripts\": {\n \"cache-cmd\": \"node ./dist/cli.js\",\n \"build\": \"rm -rf dist/* && esbuild src/cli.ts --bundle --platform=node --target=node20 --packages=external --format=esm --sourcemap --outfile=dist/cli.js\",\n \"type-check\": \"tsc --build\",\n \"preversion\": \"if [ -n \\\"$DANYS_MACHINE\\\" ]; then git checkout main && git pull; fi\",\n \"postversion\": \"if [ -n \\\"$DANYS_MACHINE\\\" ]; then git push --follow-tags && open https://github.com/dcastil/cache-cmd/releases; fi\"\n },\n \"dependencies\": {\n \"date-fns\": \"^4.1.0\",\n \"del\": \"^8.0.0\",\n \"exec-sh\": \"^0.4.0\",\n \"find-cache-dir\": \"^5.0.0\",\n \"flat-cache\": \"^6.1.3\",\n \"hard-rejection\": \"^2.1.0\",\n \"hasha\": \"^6.0.0\",\n \"lodash-es\": \"^4.17.21\",\n \"sade\": \"^1.8.1\"\n },\n \"devDependencies\": {\n \"@types/find-cache-dir\": \"^5.0.2\",\n \"@types/flat-cache\": \"^2.0.2\",\n \"@types/lodash-es\": \"^4.17.12\",\n \"@types/node\": \"^22.10.1\",\n \"@types/sade\": \"^1.8.0\",\n \"esbuild\": \"^0.24.0\",\n \"prettier\": \"^3.4.2\",\n \"typescript\": \"^5.7.2\"\n },\n \"publishConfig\": {\n \"provenance\": true\n }\n}\n", "import { deleteSync } from 'del'\n\nimport { getCacheDirectoryPath } from './utils/get-cache-dir'\n\nexport function clearCacheDirectory(relativeCacheDirectory: string | undefined) {\n const deletedPaths = deleteSync(getCacheDirectoryPath(relativeCacheDirectory))\n\n if (deletedPaths.length === 0) {\n console.log('No cache to clear')\n } else if (deletedPaths.length === 1) {\n console.log(`Deleted: ${deletedPaths[0]}`)\n } else {\n console.log('Deleted:\\n', deletedPaths.join('\\n'))\n }\n}\n", "import path from 'path'\n\nimport findCacheDir from 'find-cache-dir'\n\nimport { name } from '../../package.json'\n\nexport function getCacheDirectoryPath(relativeCacheDirectoryPath: string | undefined) {\n if (relativeCacheDirectoryPath) {\n return path.resolve(process.cwd(), relativeCacheDirectoryPath)\n }\n\n const resolvedCacheDirectory = findCacheDir({ name })\n\n if (!resolvedCacheDirectory) {\n throw Error('Could not find cache directory. Please provide a cache directory manually.')\n }\n\n return resolvedCacheDirectory\n}\n", "import { getCacheDirectoryPath } from './utils/get-cache-dir'\n\nexport function showCacheDirectory(relativeCacheDirectory: string | undefined) {\n console.log(getCacheDirectoryPath(relativeCacheDirectory))\n}\n", "import { add, isAfter } from 'date-fns'\nimport execSh from 'exec-sh'\nimport { create } from 'flat-cache'\nimport { isEqual } from 'lodash-es'\n\nimport { getCacheDirectoryPath } from './utils/get-cache-dir'\nimport { getCacheKey } from './utils/get-cache-key'\nimport { getDuration } from './utils/get-duration'\nimport { getFileHashes } from './utils/get-file-hashes'\nimport { getFilePaths } from './utils/get-file-paths'\n\ninterface RunCommandProps {\n relativeCacheDirectory: string | undefined\n command: string\n cacheByTime: string | undefined\n cacheByFiles: string[]\n shouldCacheOnError: boolean | undefined\n}\n\nexport async function runCommand({\n relativeCacheDirectory,\n command,\n cacheByTime: cacheByTime,\n cacheByFiles: cacheByFiles,\n shouldCacheOnError,\n}: RunCommandProps) {\n if (!cacheByTime && cacheByFiles.length === 0) {\n console.log(`Executing command \"${command}\" due to no caching options provided`)\n await execSh.promise(command)\n return\n }\n\n const cache = create({\n cacheId: 'commands-cache.json',\n cacheDir: getCacheDirectoryPath(relativeCacheDirectory),\n lruSize: 10_000,\n })\n const filePaths = getFilePaths(cacheByFiles)\n const duration = cacheByTime ? getDuration(cacheByTime) : undefined\n\n const cacheKey = getCacheKey({ duration, filePaths, command })\n\n const cacheData: unknown = cache.getKey(cacheKey)\n\n const fileHashes = filePaths.length === 0 ? undefined : await getFileHashes(filePaths)\n const currentDate = new Date()\n\n const areFileHashesEqual = isEqual((cacheData as any)?.fileHashes, fileHashes)\n const isWithinCacheTime = (() => {\n if (!duration) {\n return true\n }\n\n const lastRun = (cacheData as any)?.lastRun\n\n if (!lastRun) {\n return false\n }\n\n return isAfter(add(new Date(lastRun), duration), currentDate)\n })()\n\n if (areFileHashesEqual && isWithinCacheTime) {\n console.log(\n [\n `Skipping command \"${command}\" due to`,\n [fileHashes && 'unchanged files', duration && 'being within cache time']\n .filter(Boolean)\n .join(' and '),\n ].join(' '),\n )\n return\n }\n\n console.log(\n [\n `Executing command \"${command}\" due to`,\n [fileHashes && 'changed files', duration && 'cache time passing']\n .filter(Boolean)\n .join(' and '),\n ].join(' '),\n )\n let execPromise = execSh.promise(command)\n\n function setCache() {\n cache.setKey(cacheKey, {\n lastRun: currentDate,\n fileHashes,\n })\n cache.save(true)\n console.log(`Cache saved for command \"${command}\"`)\n }\n\n if (shouldCacheOnError) {\n execPromise = execPromise.catch((error: unknown) => {\n setCache()\n\n throw error\n })\n }\n\n await execPromise\n\n setCache()\n}\n", "interface GetCacheKeyProps {\n duration: Duration | undefined\n filePaths: string[]\n command: string\n}\n\ninterface Duration {\n years: number | undefined\n months: number | undefined\n weeks: number | undefined\n days: number | undefined\n hours: number | undefined\n minutes: number | undefined\n seconds: number | undefined\n}\n\nexport function getCacheKey({ duration, filePaths, command }: GetCacheKeyProps) {\n return [\n 'cwd:' + process.cwd(),\n 'cmd:' + command,\n duration && 'time:' + JSON.stringify(duration),\n filePaths.length !== 0 && 'files:' + filePaths.join(','),\n ]\n .filter(Boolean)\n .join(' ---')\n}\n", "export function getDuration(durationString: string) {\n if (!/^(\\d+[a-z]+)+$/gi.test(durationString)) {\n throw Error(`Invalid duration: ${durationString}`)\n }\n\n const duration = {\n years: undefined as undefined | number,\n months: undefined as undefined | number,\n weeks: undefined as undefined | number,\n days: undefined as undefined | number,\n hours: undefined as undefined | number,\n minutes: undefined as undefined | number,\n seconds: undefined as undefined | number,\n }\n\n durationString.match(/\\d+[a-z]+/gi)!.forEach((durationPart) => {\n const [, stringQuantity, unitShort] = /(\\d+)([a-z]+)/gi.exec(durationPart)!\n const quantity = Number(stringQuantity)\n\n const unitLong = (\n {\n y: 'years',\n mo: 'months',\n w: 'weeks',\n d: 'days',\n h: 'hours',\n m: 'minutes',\n s: 'seconds',\n } as const\n )[unitShort!]\n\n if (Number.isNaN(quantity) || !unitLong) {\n throw Error(`Invalid duration part: ${durationPart}`)\n }\n\n if (duration[unitLong] !== undefined) {\n throw Error(`Duration with unit ${unitLong} was supplied multiple times`)\n }\n\n duration[unitLong] = quantity\n })\n\n return duration\n}\n", "import { hashFile } from 'hasha'\n\nexport async function getFileHashes(filePaths: string[]) {\n return Object.fromEntries(\n await Promise.all(\n filePaths.map((filePath) =>\n hashFile(filePath, { algorithm: 'md5' }).then((hash) => [filePath, hash] as const),\n ),\n ),\n )\n}\n", "import path from 'path'\n\nexport function getFilePaths(relativeFilePaths: string[]) {\n const cwd = process.cwd()\n\n return relativeFilePaths.map((file) => path.resolve(cwd, file)).sort()\n}\n"],
|
|
5
5
|
"mappings": ";;;AAEA,OAAO,mBAAmB;AAC1B,OAAO,UAAU;;;ACFb,WAAQ;AACR,cAAW;;;ACFf,SAAS,kBAAkB;;;ACA3B,OAAO,UAAU;AAEjB,OAAO,kBAAkB;AAIlB,SAAS,sBAAsB,4BAAgD;AAClF,MAAI,4BAA4B;AAC5B,WAAO,KAAK,QAAQ,QAAQ,IAAI,GAAG,0BAA0B;AAAA,EACjE;AAEA,QAAM,yBAAyB,aAAa,EAAE,KAAK,CAAC;AAEpD,MAAI,CAAC,wBAAwB;AACzB,UAAM,MAAM,4EAA4E;AAAA,EAC5F;AAEA,SAAO;AACX;;;ADdO,SAAS,oBAAoB,wBAA4C;AAC5E,QAAM,eAAe,WAAW,sBAAsB,sBAAsB,CAAC;AAE7E,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,eAAe,+BAA+B,EACtD,OAAO,CAAC,YAAqC;AAC1C,QAAM,iBAAiB,QAAQ,WAAW;AAE1C,MAAI,mBAAmB,UAAa,OAAO,mBAAmB,UAAU;AACpE,UAAM,MAAM,8BAA8B;AAAA,EAC9C;AAEA,sBAAoB,cAAc;AACtC,CAAC;AAEL,QAAQ,MAAM,QAAQ,IAAI;",
|
|
6
6
|
"names": ["path", "file"]
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cache-cmd",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0-dev.9ebf4bb66905066a9094a49f834742ec7c0fc624",
|
|
4
4
|
"description": "Run and cache a command based on various factors",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cache",
|
|
@@ -17,6 +17,10 @@
|
|
|
17
17
|
"bugs": {
|
|
18
18
|
"url": "https://github.com/dcastil/cache-cmd/issues"
|
|
19
19
|
},
|
|
20
|
+
"funding": {
|
|
21
|
+
"type": "github",
|
|
22
|
+
"url": "https://github.com/sponsors/dcastil"
|
|
23
|
+
},
|
|
20
24
|
"license": "MIT",
|
|
21
25
|
"author": "Dany Castillo",
|
|
22
26
|
"files": [
|
|
@@ -28,7 +32,7 @@
|
|
|
28
32
|
"source": "src/cli.ts",
|
|
29
33
|
"repository": {
|
|
30
34
|
"type": "git",
|
|
31
|
-
"url": "https://github.com/dcastil/cache-cmd.git"
|
|
35
|
+
"url": "git+https://github.com/dcastil/cache-cmd.git"
|
|
32
36
|
},
|
|
33
37
|
"scripts": {
|
|
34
38
|
"cache-cmd": "node ./dist/cli.js",
|
|
@@ -57,5 +61,8 @@
|
|
|
57
61
|
"esbuild": "^0.24.0",
|
|
58
62
|
"prettier": "^3.4.2",
|
|
59
63
|
"typescript": "^5.7.2"
|
|
64
|
+
},
|
|
65
|
+
"publishConfig": {
|
|
66
|
+
"provenance": true
|
|
60
67
|
}
|
|
61
68
|
}
|