From dbb8e61d454f2e7bd6dea41e3092426a1ccea2a1 Mon Sep 17 00:00:00 2001 From: xHyroM Date: Thu, 28 Jul 2022 08:42:43 +0200 Subject: [PATCH] chore: debug --- bun.lockb | Bin 18665 -> 19006 bytes dist/utils/getGithubRelease.js | 3 +- dist/utils/install.js | 2 + node_modules/.bin/nanoid | 1 + node_modules/nanoid/LICENSE | 20 +++++ node_modules/nanoid/README.md | 39 +++++++++ node_modules/nanoid/async/index.browser.js | 33 ++++++++ node_modules/nanoid/async/index.d.ts | 56 +++++++++++++ node_modules/nanoid/async/index.js | 34 ++++++++ node_modules/nanoid/async/index.native.js | 25 ++++++ node_modules/nanoid/bin/nanoid.js | 46 +++++++++++ node_modules/nanoid/index.browser.js | 33 ++++++++ node_modules/nanoid/index.d.ts | 91 +++++++++++++++++++++ node_modules/nanoid/index.js | 45 ++++++++++ node_modules/nanoid/nanoid.js | 1 + node_modules/nanoid/non-secure/index.d.ts | 33 ++++++++ node_modules/nanoid/non-secure/index.js | 20 +++++ node_modules/nanoid/package.json | 41 ++++++++++ node_modules/nanoid/url-alphabet/index.js | 2 + package.json | 3 +- src/utils/getGithubRelease.ts | 3 +- src/utils/install.ts | 2 + 22 files changed, 530 insertions(+), 3 deletions(-) create mode 120000 node_modules/.bin/nanoid create mode 100644 node_modules/nanoid/LICENSE create mode 100644 node_modules/nanoid/README.md create mode 100644 node_modules/nanoid/async/index.browser.js create mode 100644 node_modules/nanoid/async/index.d.ts create mode 100644 node_modules/nanoid/async/index.js create mode 100644 node_modules/nanoid/async/index.native.js create mode 100755 node_modules/nanoid/bin/nanoid.js create mode 100644 node_modules/nanoid/index.browser.js create mode 100644 node_modules/nanoid/index.d.ts create mode 100644 node_modules/nanoid/index.js create mode 100644 node_modules/nanoid/nanoid.js create mode 100644 node_modules/nanoid/non-secure/index.d.ts create mode 100644 node_modules/nanoid/non-secure/index.js create mode 100644 node_modules/nanoid/package.json create mode 100644 node_modules/nanoid/url-alphabet/index.js diff --git a/bun.lock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2;f21Q{B~>0TWTWX@*|GR+BNdi)o;x_eCsbg{{g?JUJd{N diff --git a/dist/utils/getGithubRelease.js b/dist/utils/getGithubRelease.js index b030ad6..4ac58ae 100644 --- a/dist/utils/getGithubRelease.js +++ b/dist/utils/getGithubRelease.js @@ -1,3 +1,4 @@ +import { nanoid } from 'nanoid'; import fetch from 'node-fetch'; import { getArchitecture } from './getAsset.js'; export default async (version, token, fullRepository, customDownloadUrl, miscTestBuilds) => { @@ -12,7 +13,7 @@ export default async (version, token, fullRepository, customDownloadUrl, miscTes if (customDownloadUrl) { return { name: 'custom', - version: version + Math.random().toString(36).slice(-8), + version: `${version}-${nanoid(10)}`, html_url: customDownloadUrl, tag_name: 'custom', assets: [ diff --git a/dist/utils/install.js b/dist/utils/install.js index fed4c08..dbaefad 100644 --- a/dist/utils/install.js +++ b/dist/utils/install.js @@ -18,7 +18,9 @@ export default async (release, token) => { 'Authorization': new URL(asset.asset.browser_download_url).host.includes('github.com') ? `token ${token}` : '' }); const extracted = await extractZip(zipPath, join(homedir(), '.bun', 'bin')); + console.log(extracted); const newCache = await cacheDir(extracted, 'bun', release.version); + console.log(newCache, join(extracted, asset.name)); await saveCache([ join(extracted, asset.name) ], `bun-${process.platform}-${asset.name}-${release.version}`); diff --git a/node_modules/.bin/nanoid b/node_modules/.bin/nanoid new file mode 120000 index 0000000..714c2f2 --- /dev/null +++ b/node_modules/.bin/nanoid @@ -0,0 +1 @@ +../nanoid/bin/nanoid.js \ No newline at end of file diff --git a/node_modules/nanoid/LICENSE b/node_modules/nanoid/LICENSE new file mode 100644 index 0000000..37f56aa --- /dev/null +++ b/node_modules/nanoid/LICENSE @@ -0,0 +1,20 @@ +The MIT License (MIT) + +Copyright 2017 Andrey Sitnik + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/node_modules/nanoid/README.md b/node_modules/nanoid/README.md new file mode 100644 index 0000000..a4abd92 --- /dev/null +++ b/node_modules/nanoid/README.md @@ -0,0 +1,39 @@ +# Nano ID + +Nano ID logo by Anton Lovchikov + +**English** | [Русский](./README.ru.md) | [简体中文](./README.zh-CN.md) | [Bahasa Indonesia](./README.id-ID.md) + +A tiny, secure, URL-friendly, unique string ID generator for JavaScript. + +> “An amazing level of senseless perfectionism, +> which is simply impossible not to respect.” + +* **Small.** 130 bytes (minified and gzipped). No dependencies. + [Size Limit] controls the size. +* **Fast.** It is 2 times faster than UUID. +* **Safe.** It uses hardware random generator. Can be used in clusters. +* **Short IDs.** It uses a larger alphabet than UUID (`A-Za-z0-9_-`). + So ID size was reduced from 36 to 21 symbols. +* **Portable.** Nano ID was ported + to [20 programming languages](#other-programming-languages). + +```js +import { nanoid } from 'nanoid' +model.id = nanoid() //=> "V1StGXR8_Z5jdHi6B-myT" +``` + +Supports modern browsers, IE [with Babel], Node.js and React Native. + +[online tool]: https://gitpod.io/#https://github.com/ai/nanoid/ +[with Babel]: https://developer.epages.com/blog/coding/how-to-transpile-node-modules-with-babel-and-webpack-in-a-monorepo/ +[Size Limit]: https://github.com/ai/size-limit + + + Sponsored by Evil Martians + + +## Docs +Read **[full docs](https://github.com/ai/nanoid#readme)** on GitHub. diff --git a/node_modules/nanoid/async/index.browser.js b/node_modules/nanoid/async/index.browser.js new file mode 100644 index 0000000..6998a79 --- /dev/null +++ b/node_modules/nanoid/async/index.browser.js @@ -0,0 +1,33 @@ +export let random = async bytes => crypto.getRandomValues(new Uint8Array(bytes)) +export let customAlphabet = (alphabet, defaultSize = 21) => { + let mask = (2 << (Math.log(alphabet.length - 1) / Math.LN2)) - 1 + let step = -~((1.6 * mask * defaultSize) / alphabet.length) + return async (size = defaultSize) => { + let id = '' + while (true) { + let bytes = crypto.getRandomValues(new Uint8Array(step)) + let i = step + while (i--) { + id += alphabet[bytes[i] & mask] || '' + if (id.length === size) return id + } + } + } +} +export let nanoid = async (size = 21) => { + let id = '' + let bytes = crypto.getRandomValues(new Uint8Array(size)) + while (size--) { + let byte = bytes[size] & 63 + if (byte < 36) { + id += byte.toString(36) + } else if (byte < 62) { + id += (byte - 26).toString(36).toUpperCase() + } else if (byte < 63) { + id += '_' + } else { + id += '-' + } + } + return id +} diff --git a/node_modules/nanoid/async/index.d.ts b/node_modules/nanoid/async/index.d.ts new file mode 100644 index 0000000..9e91965 --- /dev/null +++ b/node_modules/nanoid/async/index.d.ts @@ -0,0 +1,56 @@ +/** + * Generate secure URL-friendly unique ID. The non-blocking version. + * + * By default, the ID will have 21 symbols to have a collision probability + * similar to UUID v4. + * + * ```js + * import { nanoid } from 'nanoid/async' + * nanoid().then(id => { + * model.id = id + * }) + * ``` + * + * @param size Size of the ID. The default size is 21. + * @returns A promise with a random string. + */ +export function nanoid(size?: number): Promise + +/** + * A low-level function. + * Generate secure unique ID with custom alphabet. The non-blocking version. + * + * Alphabet must contain 256 symbols or less. Otherwise, the generator + * will not be secure. + * + * @param alphabet Alphabet used to generate the ID. + * @param defaultSize Size of the ID. The default size is 21. + * @returns A function that returns a promise with a random string. + * + * ```js + * import { customAlphabet } from 'nanoid/async' + * const nanoid = customAlphabet('0123456789абвгдеё', 5) + * nanoid().then(id => { + * model.id = id //=> "8ё56а" + * }) + * ``` + */ +export function customAlphabet( + alphabet: string, + defaultSize?: number +): (size?: number) => Promise + +/** + * Generate an array of random bytes collected from hardware noise. + * + * ```js + * import { random } from 'nanoid/async' + * random(5).then(bytes => { + * bytes //=> [10, 67, 212, 67, 89] + * }) + * ``` + * + * @param bytes Size of the array. + * @returns A promise with a random bytes array. + */ +export function random(bytes: number): Promise diff --git a/node_modules/nanoid/async/index.js b/node_modules/nanoid/async/index.js new file mode 100644 index 0000000..bdd464c --- /dev/null +++ b/node_modules/nanoid/async/index.js @@ -0,0 +1,34 @@ +import { randomFill } from 'crypto' +import { urlAlphabet } from '../url-alphabet/index.js' +export let random = bytes => + new Promise((resolve, reject) => { + randomFill(Buffer.allocUnsafe(bytes), (err, buf) => { + if (err) { + reject(err) + } else { + resolve(buf) + } + }) + }) +export let customAlphabet = (alphabet, defaultSize = 21) => { + let mask = (2 << (31 - Math.clz32((alphabet.length - 1) | 1))) - 1 + let step = Math.ceil((1.6 * mask * defaultSize) / alphabet.length) + let tick = (id, size = defaultSize) => + random(step).then(bytes => { + let i = step + while (i--) { + id += alphabet[bytes[i] & mask] || '' + if (id.length === size) return id + } + return tick(id, size) + }) + return size => tick('', size) +} +export let nanoid = (size = 21) => + random(size).then(bytes => { + let id = '' + while (size--) { + id += urlAlphabet[bytes[size] & 63] + } + return id + }) diff --git a/node_modules/nanoid/async/index.native.js b/node_modules/nanoid/async/index.native.js new file mode 100644 index 0000000..ed5533a --- /dev/null +++ b/node_modules/nanoid/async/index.native.js @@ -0,0 +1,25 @@ +import { getRandomBytesAsync } from 'expo-random' +import { urlAlphabet } from '../url-alphabet/index.js' +export let random = getRandomBytesAsync +export let customAlphabet = (alphabet, defaultSize = 21) => { + let mask = (2 << (31 - Math.clz32((alphabet.length - 1) | 1))) - 1 + let step = Math.ceil((1.6 * mask * defaultSize) / alphabet.length) + let tick = (id, size = defaultSize) => + random(step).then(bytes => { + let i = step + while (i--) { + id += alphabet[bytes[i] & mask] || '' + if (id.length === size) return id + } + return tick(id, size) + }) + return size => tick('', size) +} +export let nanoid = (size = 21) => + random(size).then(bytes => { + let id = '' + while (size--) { + id += urlAlphabet[bytes[size] & 63] + } + return id + }) diff --git a/node_modules/nanoid/bin/nanoid.js b/node_modules/nanoid/bin/nanoid.js new file mode 100755 index 0000000..13c9939 --- /dev/null +++ b/node_modules/nanoid/bin/nanoid.js @@ -0,0 +1,46 @@ +#!/usr/bin/env node +import { nanoid, customAlphabet } from '../index.js' +function print(msg) { + process.stdout.write(msg + '\n') +} +function error(msg) { + process.stderr.write(msg + '\n') + process.exit(1) +} +if (process.argv.includes('--help') || process.argv.includes('-h')) { + print(` + Usage + $ nanoid [options] + Options + -s, --size Generated ID size + -a, --alphabet Alphabet to use + -h, --help Show this help + Examples + $ nanoid --s 15 + S9sBF77U6sDB8Yg + $ nanoid --size 10 --alphabet abc + bcabababca`) + process.exit() +} +let alphabet, size +for (let i = 2; i < process.argv.length; i++) { + let arg = process.argv[i] + if (arg === '--size' || arg === '-s') { + size = Number(process.argv[i + 1]) + i += 1 + if (Number.isNaN(size) || size <= 0) { + error('Size must be positive integer') + } + } else if (arg === '--alphabet' || arg === '-a') { + alphabet = process.argv[i + 1] + i += 1 + } else { + error('Unknown argument ' + arg) + } +} +if (alphabet) { + let customNanoid = customAlphabet(alphabet, size) + print(customNanoid()) +} else { + print(nanoid(size)) +} diff --git a/node_modules/nanoid/index.browser.js b/node_modules/nanoid/index.browser.js new file mode 100644 index 0000000..f5bd92d --- /dev/null +++ b/node_modules/nanoid/index.browser.js @@ -0,0 +1,33 @@ +export { urlAlphabet } from './url-alphabet/index.js' +export let random = bytes => crypto.getRandomValues(new Uint8Array(bytes)) +export let customRandom = (alphabet, defaultSize, getRandom) => { + let mask = (2 << (Math.log(alphabet.length - 1) / Math.LN2)) - 1 + let step = -~((1.6 * mask * defaultSize) / alphabet.length) + return (size = defaultSize) => { + let id = '' + while (true) { + let bytes = getRandom(step) + let j = step + while (j--) { + id += alphabet[bytes[j] & mask] || '' + if (id.length === size) return id + } + } + } +} +export let customAlphabet = (alphabet, size = 21) => + customRandom(alphabet, size, random) +export let nanoid = (size = 21) => + crypto.getRandomValues(new Uint8Array(size)).reduce((id, byte) => { + byte &= 63 + if (byte < 36) { + id += byte.toString(36) + } else if (byte < 62) { + id += (byte - 26).toString(36).toUpperCase() + } else if (byte > 62) { + id += '-' + } else { + id += '_' + } + return id + }, '') diff --git a/node_modules/nanoid/index.d.ts b/node_modules/nanoid/index.d.ts new file mode 100644 index 0000000..3e111a3 --- /dev/null +++ b/node_modules/nanoid/index.d.ts @@ -0,0 +1,91 @@ +/** + * Generate secure URL-friendly unique ID. + * + * By default, the ID will have 21 symbols to have a collision probability + * similar to UUID v4. + * + * ```js + * import { nanoid } from 'nanoid' + * model.id = nanoid() //=> "Uakgb_J5m9g-0JDMbcJqL" + * ``` + * + * @param size Size of the ID. The default size is 21. + * @returns A random string. + */ +export function nanoid(size?: number): string + +/** + * Generate secure unique ID with custom alphabet. + * + * Alphabet must contain 256 symbols or less. Otherwise, the generator + * will not be secure. + * + * @param alphabet Alphabet used to generate the ID. + * @param defaultSize Size of the ID. The default size is 21. + * @returns A random string generator. + * + * ```js + * const { customAlphabet } = require('nanoid') + * const nanoid = customAlphabet('0123456789абвгдеё', 5) + * nanoid() //=> "8ё56а" + * ``` + */ +export function customAlphabet( + alphabet: string, + defaultSize?: number +): (size?: number) => string + +/** + * Generate unique ID with custom random generator and alphabet. + * + * Alphabet must contain 256 symbols or less. Otherwise, the generator + * will not be secure. + * + * ```js + * import { customRandom } from 'nanoid/format' + * + * const nanoid = customRandom('abcdef', 5, size => { + * const random = [] + * for (let i = 0; i < size; i++) { + * random.push(randomByte()) + * } + * return random + * }) + * + * nanoid() //=> "fbaef" + * ``` + * + * @param alphabet Alphabet used to generate a random string. + * @param size Size of the random string. + * @param random A random bytes generator. + * @returns A random string generator. + */ +export function customRandom( + alphabet: string, + size: number, + random: (bytes: number) => Uint8Array +): () => string + +/** + * URL safe symbols. + * + * ```js + * import { urlAlphabet } from 'nanoid' + * const nanoid = customAlphabet(urlAlphabet, 10) + * nanoid() //=> "Uakgb_J5m9" + * ``` + */ +export const urlAlphabet: string + +/** + * Generate an array of random bytes collected from hardware noise. + * + * ```js + * import { customRandom, random } from 'nanoid' + * const nanoid = customRandom("abcdef", 5, random) + * ``` + * + * @param bytes Size of the array. + * @returns An array of random bytes. + */ +export function random(bytes: number): Uint8Array diff --git a/node_modules/nanoid/index.js b/node_modules/nanoid/index.js new file mode 100644 index 0000000..7b2e502 --- /dev/null +++ b/node_modules/nanoid/index.js @@ -0,0 +1,45 @@ +import { randomFillSync } from 'crypto' +import { urlAlphabet } from './url-alphabet/index.js' +export { urlAlphabet } +const POOL_SIZE_MULTIPLIER = 128 +let pool, poolOffset +let fillPool = bytes => { + if (!pool || pool.length < bytes) { + pool = Buffer.allocUnsafe(bytes * POOL_SIZE_MULTIPLIER) + randomFillSync(pool) + poolOffset = 0 + } else if (poolOffset + bytes > pool.length) { + randomFillSync(pool) + poolOffset = 0 + } + poolOffset += bytes +} +export let random = bytes => { + fillPool((bytes -= 0)) + return pool.subarray(poolOffset - bytes, poolOffset) +} +export let customRandom = (alphabet, defaultSize, getRandom) => { + let mask = (2 << (31 - Math.clz32((alphabet.length - 1) | 1))) - 1 + let step = Math.ceil((1.6 * mask * defaultSize) / alphabet.length) + return (size = defaultSize) => { + let id = '' + while (true) { + let bytes = getRandom(step) + let i = step + while (i--) { + id += alphabet[bytes[i] & mask] || '' + if (id.length === size) return id + } + } + } +} +export let customAlphabet = (alphabet, size = 21) => + customRandom(alphabet, size, random) +export let nanoid = (size = 21) => { + fillPool((size -= 0)) + let id = '' + for (let i = poolOffset - size; i < poolOffset; i++) { + id += urlAlphabet[pool[i] & 63] + } + return id +} diff --git a/node_modules/nanoid/nanoid.js b/node_modules/nanoid/nanoid.js new file mode 100644 index 0000000..493f9a2 --- /dev/null +++ b/node_modules/nanoid/nanoid.js @@ -0,0 +1 @@ +export let nanoid=(t=21)=>crypto.getRandomValues(new Uint8Array(t)).reduce(((t,e)=>t+=(e&=63)<36?e.toString(36):e<62?(e-26).toString(36).toUpperCase():e>62?"-":"_"),""); \ No newline at end of file diff --git a/node_modules/nanoid/non-secure/index.d.ts b/node_modules/nanoid/non-secure/index.d.ts new file mode 100644 index 0000000..4965322 --- /dev/null +++ b/node_modules/nanoid/non-secure/index.d.ts @@ -0,0 +1,33 @@ +/** + * Generate URL-friendly unique ID. This method uses the non-secure + * predictable random generator with bigger collision probability. + * + * ```js + * import { nanoid } from 'nanoid/non-secure' + * model.id = nanoid() //=> "Uakgb_J5m9g-0JDMbcJqL" + * ``` + * + * @param size Size of the ID. The default size is 21. + * @returns A random string. + */ +export function nanoid(size?: number): string + +/** + * Generate a unique ID based on a custom alphabet. + * This method uses the non-secure predictable random generator + * with bigger collision probability. + * + * @param alphabet Alphabet used to generate the ID. + * @param defaultSize Size of the ID. The default size is 21. + * @returns A random string generator. + * + * ```js + * import { customAlphabet } from 'nanoid/non-secure' + * const nanoid = customAlphabet('0123456789абвгдеё', 5) + * model.id = //=> "8ё56а" + * ``` + */ +export function customAlphabet( + alphabet: string, + defaultSize?: number +): (size?: number) => string diff --git a/node_modules/nanoid/non-secure/index.js b/node_modules/nanoid/non-secure/index.js new file mode 100644 index 0000000..c07a2b1 --- /dev/null +++ b/node_modules/nanoid/non-secure/index.js @@ -0,0 +1,20 @@ +let urlAlphabet = + 'useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict' +export let customAlphabet = (alphabet, defaultSize = 21) => { + return (size = defaultSize) => { + let id = '' + let i = size + while (i--) { + id += alphabet[(Math.random() * alphabet.length) | 0] + } + return id + } +} +export let nanoid = (size = 21) => { + let id = '' + let i = size + while (i--) { + id += urlAlphabet[(Math.random() * 64) | 0] + } + return id +} diff --git a/node_modules/nanoid/package.json b/node_modules/nanoid/package.json new file mode 100644 index 0000000..112cd79 --- /dev/null +++ b/node_modules/nanoid/package.json @@ -0,0 +1,41 @@ +{ + "name": "nanoid", + "version": "4.0.0", + "description": "A tiny (116 bytes), secure URL-friendly unique string ID generator", + "keywords": [ + "uuid", + "random", + "id", + "url" + ], + "type": "module", + "engines": { + "node": "^14 || ^16 || >=18" + }, + "author": "Andrey Sitnik ", + "license": "MIT", + "repository": "ai/nanoid", + "exports": { + ".": { + "browser": "./index.browser.js", + "default": "./index.js" + }, + "./async": { + "browser": "./async/index.browser.js", + "default": "./async/index.js" + }, + "./non-secure": "./non-secure/index.js", + "./package.json": "./package.json" + }, + "browser": { + "./index.js": "./index.browser.js", + "./async/index.js": "./async/index.browser.js", + "./async/index.cjs": "./async/index.browser.cjs" + }, + "react-native": { + "./async/index.js": "./async/index.native.js" + }, + "bin": "./bin/nanoid.js", + "sideEffects": false, + "types": "./index.d.ts" +} diff --git a/node_modules/nanoid/url-alphabet/index.js b/node_modules/nanoid/url-alphabet/index.js new file mode 100644 index 0000000..cfec9b2 --- /dev/null +++ b/node_modules/nanoid/url-alphabet/index.js @@ -0,0 +1,2 @@ +export const urlAlphabet = + 'useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict' diff --git a/package.json b/package.json index e90bfc4..b725b13 100644 --- a/package.json +++ b/package.json @@ -28,10 +28,11 @@ "@actions/cache": "^3.0.0", "@actions/core": "^1.9.0", "@actions/tool-cache": "^2.0.1", + "nanoid": "^4.0.0", "node-fetch": "^3.2.6" }, "devDependencies": { "bun-types": "^0.0.83", "typescript": "^4.7.4" } -} +} \ No newline at end of file diff --git a/src/utils/getGithubRelease.ts b/src/utils/getGithubRelease.ts index 5aa3c02..6e33535 100644 --- a/src/utils/getGithubRelease.ts +++ b/src/utils/getGithubRelease.ts @@ -1,3 +1,4 @@ +import { nanoid } from 'nanoid'; import fetch from 'node-fetch'; import { getArchitecture } from './getAsset.js'; @@ -26,7 +27,7 @@ export default async(version: string, token: string, fullRepository: string, cus if (customDownloadUrl) { return { name: 'custom', - version: version + Math.random().toString(36).slice(-8), + version: `${version}-${nanoid(10)}`, html_url: customDownloadUrl, tag_name: 'custom', assets: [ diff --git a/src/utils/install.ts b/src/utils/install.ts index 1aa16fd..f14365a 100644 --- a/src/utils/install.ts +++ b/src/utils/install.ts @@ -28,11 +28,13 @@ export default async(release: Release, token: string) => { ); const extracted = await extractZip(zipPath, join(homedir(), '.bun', 'bin')); + console.log(extracted) const newCache = await cacheDir( extracted, 'bun', release.version ); + console.log(newCache, join(extracted, asset.name)); await saveCache([ join(extracted, asset.name) ], `bun-${process.platform}-${asset.name}-${release.version}`);