From 21dd5858b83230290679ba2916970a839f36bffe Mon Sep 17 00:00:00 2001 From: hustcer Date: Thu, 27 Jun 2024 21:19:07 +0800 Subject: [PATCH] fix plugins --- dist/index.js | 2 +- src/plugins.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/dist/index.js b/dist/index.js index 95907e4..36f37a5 100644 --- a/dist/index.js +++ b/dist/index.js @@ -59,4 +59,4 @@ e.exports=runParallel;const s=r(1504);function runParallel(e,t){let r,n,o;let i= register-plugins print $'(char nl)Plugins registered successfully for Nu ($version).' } -`;function registerPlugins(e,t){return s(this,void 0,void 0,(function*(){if(e===""||e==="false"){return}const r="0.92.3";const s=!t.includes("nightly")&&a.default.lte(t,r);o.default.writeFileSync("register-plugins.nu",u);if(s){i.default.exec(`nu register-plugins.nu ${e} ${t} --is-legacy`)}else{i.default.exec(`nu register-plugins.nu ${e} ${t}"`)}}))}},5837:function(e,t,r){"use strict";var s=this&&this.__createBinding||(Object.create?function(e,t,r,s){if(s===undefined)s=r;var n=Object.getOwnPropertyDescriptor(t,r);if(!n||("get"in n?!t.__esModule:n.writable||n.configurable)){n={enumerable:true,get:function(){return t[r]}}}Object.defineProperty(e,s,n)}:function(e,t,r,s){if(s===undefined)s=r;e[s]=t[r]});var n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:true,value:t})}:function(e,t){e["default"]=t});var o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r in e)if(r!=="default"&&Object.prototype.hasOwnProperty.call(e,r))s(t,e,r);n(t,e);return t};var i=this&&this.__awaiter||function(e,t,r,s){function adopt(e){return e instanceof r?e:new r((function(t){t(e)}))}return new(r||(r=Promise))((function(r,n){function fulfilled(e){try{step(s.next(e))}catch(e){n(e)}}function rejected(e){try{step(s["throw"](e))}catch(e){n(e)}}function step(e){e.done?r(e.value):adopt(e.value).then(fulfilled,rejected)}step((s=s.apply(e,t||[])).next())}))};var a=this&&this.__asyncValues||function(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=e[Symbol.asyncIterator],r;return t?t.call(e):(e=typeof __values==="function"?__values(e):e[Symbol.iterator](),r={},verb("next"),verb("throw"),verb("return"),r[Symbol.asyncIterator]=function(){return this},r);function verb(t){r[t]=e[t]&&function(r){return new Promise((function(s,n){r=e[t](r),settle(s,n,r.done,r.value)}))}}function settle(e,t,r,s){Promise.resolve(s).then((function(t){e({value:t,done:r})}),t)}};Object.defineProperty(t,"__esModule",{value:true});t.checkOrInstallTool=checkOrInstallTool;const c=o(r(1017));const u=r(9945);const l=o(r(7705));const p=o(r(9093));const d=o(r(5561));const h=r(4296);const m=r(7147);const g={darwin_x64:["x86_64-apple-darwin","macOS.zip"],darwin_arm64:["aarch64-apple-darwin","macOS.zip"],win32_x64:["x86_64-pc-windows-msvc.zip","windows.zip"],linux_x64:["x86_64-unknown-linux-musl","x86_64-unknown-linux-gnu","linux.tar.gz"]};const E={darwin_x64:["x86_64-darwin-full"],darwin_arm64:["aarch64-darwin-full"],win32_x64:["x86_64-windows-msvc-full.zip"],linux_x64:["x86_64-linux-musl-full","x86_64-linux-gnu-full"]};function getTargets(e){const{arch:t,platform:r}=process;const s=`${r}_${t}`;if(e==="default"){return g[s]}if(e==="full"){return E[s]}throw new Error(`Failed to determine any valid targets: arch = ${t}, platform = ${r}, feature = ${e}`)}function filterMatch(e,t,r){const s=getTargets(r);return e.data.map((e=>{const t=e.assets.find((e=>s.some((t=>e.name.includes(t)))));if(t){return{version:e.tag_name.replace(/^v/,""),downloadUrl:t.browser_download_url}}})).filter((e=>e&&t?l.satisfies(e.version,t):true))}function filterLatest(e,t){const r=getTargets(t);const s=e.data.map((e=>e.tag_name));const n=l.rsort(s)[0];return e.data.filter((e=>e&&e.tag_name===n)).map((e=>{const t=e.assets.find((e=>r.some((t=>e.name.includes(t)))));if(t){return{version:e.tag_name.replace(/^v/,""),downloadUrl:t.browser_download_url}}}))}function filterLatestNightly(e,t){const r=getTargets(t);const s=e.data.map((e=>e.published_at));const n=s.sort(((e,t)=>new Date(t).getTime()-new Date(e).getTime()));const o=n[0];p.info(`Try to get latest nightly version published at: ${o}`);return e.data.filter((e=>e&&e.published_at===o)).map((e=>{const t=e.assets.find((e=>r.some((t=>e.name.includes(t)))));if(t){return{version:e.tag_name.replace(/^v/,""),downloadUrl:t.browser_download_url}}}))}function getRelease(e){return i(this,void 0,void 0,(function*(){const{owner:t,name:r,versionSpec:s,checkLatest:n=false,features:o="default"}=e;const i=s==="nightly";const a=new h.Octokit({auth:e.githubToken});return a.paginate(a.repos.listReleases,{owner:t,repo:r},((e,t)=>{const r=i?filterLatestNightly(e,o):[];const a=n?filterLatest(e,o):filterMatch(e,s,o);const c=i?r:a;if(c){t()}return c})).then((e=>{const t=e.find((e=>e!=null));if(t===undefined){if(o==="full"){p.warning('The "full" feature was removed for Nu after v0.93.1, try to use "default" feature instead.')}throw new Error(`No release for Nusehll matching version specifier ${s} of ${o} feature.`)}return t}))}))}function handleBadBinaryPermissions(e,t){return i(this,void 0,void 0,(function*(){const{name:r,bin:s}=e;if(process.platform!=="win32"){const findBin=()=>i(this,void 0,void 0,(function*(){var e,s,n,o;const i=yield m.promises.readdir(t);try{for(var c=true,u=a(i),l;l=yield u.next(),e=l.done,!e;c=true){o=l.value;c=false;const e=o;if(e.toLowerCase()===r.toLowerCase()){return e}}}catch(e){s={error:e}}finally{try{if(!c&&!e&&(n=u.return))yield n.call(u)}finally{if(s)throw s.error}}return r}));const e=c.join(t,s?s:yield findBin());try{yield m.promises.access(e,m.constants.X_OK)}catch(t){yield m.promises.chmod(e,"755");p.debug(`Fixed file permissions (-> 0o755) for ${e}`)}}}))}function checkOrInstallTool(e){return i(this,void 0,void 0,(function*(){const{name:t,versionSpec:r}=e;let s=d.find(t,r||"*");if(!s){const{version:r,downloadUrl:n}=yield getRelease(e);const o=yield d.downloadTool(n);p.debug(`Successfully downloaded ${t} v${r}`);let i;if(n.endsWith(".zip")){i=yield d.extractZip(o)}else{i=yield d.extractTar(o)}p.debug(`Successfully extracted archive for ${t} v${r}`);const a=yield(0,u.globby)([`${i}/**/nu_plugin_*`,c.join(i,"**","nu_plugin_*").replace(/\\/g,"/")],{unique:true,absolute:true});s=yield d.cacheDir(c.dirname(a[0]),t,r);yield handleBadBinaryPermissions(e,s)}const n=c.basename(c.dirname(s));return Object.assign({version:n,dir:s},e)}))}},9491:e=>{"use strict";e.exports=require("assert")},2081:e=>{"use strict";e.exports=require("child_process")},6113:e=>{"use strict";e.exports=require("crypto")},2361:e=>{"use strict";e.exports=require("events")},7147:e=>{"use strict";e.exports=require("fs")},3685:e=>{"use strict";e.exports=require("http")},5687:e=>{"use strict";e.exports=require("https")},1808:e=>{"use strict";e.exports=require("net")},2037:e=>{"use strict";e.exports=require("os")},1017:e=>{"use strict";e.exports=require("path")},2781:e=>{"use strict";e.exports=require("stream")},1576:e=>{"use strict";e.exports=require("string_decoder")},9512:e=>{"use strict";e.exports=require("timers")},4404:e=>{"use strict";e.exports=require("tls")},3837:e=>{"use strict";e.exports=require("util")},9945:(e,t,r)=>{"use strict";r.r(t);r.d(t,{convertPathToPattern:()=>L,generateGlobTasks:()=>x,generateGlobTasksSync:()=>G,globby:()=>P,globbyStream:()=>A,globbySync:()=>k,isDynamicPattern:()=>C,isGitIgnored:()=>isGitIgnored,isGitIgnoredSync:()=>isGitIgnoredSync});const s=require("node:process");const n=require("node:fs");const o=require("node:path");const i=require("node:events");const a=require("node:stream");const c=require("node:stream/promises");function mergeStreams(e){if(!Array.isArray(e)){throw new TypeError(`Expected an array, got \`${typeof e}\`.`)}for(const t of e){validateStream(t)}const t=e.some((({readableObjectMode:e})=>e));const r=getHighWaterMark(e,t);const s=new MergedStream({objectMode:t,writableHighWaterMark:r,readableHighWaterMark:r});for(const t of e){s.add(t)}if(e.length===0){s.end()}return s}const getHighWaterMark=(e,t)=>{if(e.length===0){return 16384}const r=e.filter((({readableObjectMode:e})=>e===t)).map((({readableHighWaterMark:e})=>e));return Math.max(...r)};class MergedStream extends a.PassThrough{#e=new Set([]);#t=new Set([]);#r;constructor(...e){super(...e);this.#r=onMergedStreamFinished(this,this.#e)}add(e){if(this.#e.has(e)){return}validateStream(e);if(!this.writable){throw new TypeError("The merged stream has already ended.")}this.#e.add(e);endWhenStreamsDone({passThroughStream:this,stream:e,streams:this.#e,ended:this.#t,onFinished:this.#r});updateMaxListeners(this,p);e.pipe(this,{end:false})}remove(e){if(!this.#e.has(e)){throw new TypeError("Stream cannot be removed because it was not piped.")}e.unpipe(this)}}const onMergedStreamFinished=async(e,t)=>{updateMaxListeners(e,l);const r=new AbortController;try{await Promise.race([onMergedStreamEnd(e,r),onInputStreamsUnpipe(e,t,r)])}finally{r.abort();updateMaxListeners(e,-l)}};const onMergedStreamEnd=async(e,{signal:t})=>{try{await(0,c.finished)(e,{signal:t,cleanup:true})}catch{}};const onInputStreamsUnpipe=async(e,t,{signal:r})=>{for await(const[s]of(0,i.on)(e,"unpipe",{signal:r})){if(t.has(s)){s.emit(u)}}};const validateStream=e=>{if(typeof e?.pipe!=="function"){throw new TypeError(`Expected a readable stream, got: \`${typeof e}\`.`)}};const endWhenStreamsDone=async({passThroughStream:e,stream:t,streams:r,ended:s,onFinished:n})=>{try{const o=new AbortController;try{await Promise.race([n,onInputStreamEnd({stream:t,streams:r,ended:s,abortController:o}),onInputStreamUnpipe({passThroughStream:e,stream:t,streams:r,ended:s,abortController:o})])}finally{o.abort()}if(r.size===s.size&&e.writable){e.end()}}catch(t){if(t?.code==="ERR_STREAM_PREMATURE_CLOSE"){e.destroy()}else{e.destroy(t)}}};const onInputStreamEnd=async({stream:e,streams:t,ended:r,abortController:{signal:s}})=>{await(0,c.finished)(e,{signal:s,cleanup:true,readable:true,writable:false});if(t.has(e)){r.add(e)}};const onInputStreamUnpipe=async({passThroughStream:e,stream:t,streams:r,ended:s,abortController:{signal:n}})=>{await(0,i.once)(t,u,{signal:n});r.delete(t);s.delete(t);updateMaxListeners(e,-p)};const u=Symbol("unpipe");const updateMaxListeners=(e,t)=>{e.setMaxListeners(e.getMaxListeners()+t)};const l=2;const p=1;var d=r(6581);var h=r(7147);async function isType(e,t,r){if(typeof r!=="string"){throw new TypeError(`Expected a string, got ${typeof r}`)}try{const s=await h.promises[e](r);return s[t]()}catch(e){if(e.code==="ENOENT"){return false}throw e}}function isTypeSync(e,t,r){if(typeof r!=="string"){throw new TypeError(`Expected a string, got ${typeof r}`)}try{return h[e](r)[t]()}catch(e){if(e.code==="ENOENT"){return false}throw e}}const m=isType.bind(null,"stat","isFile");const g=isType.bind(null,"stat","isDirectory");const E=isType.bind(null,"lstat","isSymbolicLink");const v=isTypeSync.bind(null,"statSync","isFile");const y=isTypeSync.bind(null,"statSync","isDirectory");const _=isTypeSync.bind(null,"lstatSync","isSymbolicLink");const b=require("node:url");function toPath(e){return e instanceof URL?(0,b.fileURLToPath)(e):e}const w=require("node:fs/promises");var T=r(8829);function slash(e){const t=e.startsWith("\\\\?\\");if(t){return e}return e.replace(/\\/g,"/")}const isNegativePattern=e=>e[0]==="!";const S=["**/node_modules","**/flow-typed","**/coverage","**/.git"];const O={absolute:true,dot:true};const R="**/.gitignore";const applyBaseToPattern=(e,t)=>isNegativePattern(e)?"!"+o.posix.join(t,e.slice(1)):o.posix.join(t,e);const parseIgnoreFile=(e,t)=>{const r=slash(o.relative(t,o.dirname(e.filePath)));return e.content.split(/\r?\n/).filter((e=>e&&!e.startsWith("#"))).map((e=>applyBaseToPattern(e,r)))};const toRelativePath=(e,t)=>{t=slash(t);if(o.isAbsolute(e)){if(slash(e).startsWith(t)){return o.relative(t,e)}throw new Error(`Path ${e} is not in cwd ${t}`)}return e};const getIsIgnoredPredicate=(e,t)=>{const r=e.flatMap((e=>parseIgnoreFile(e,t)));const s=T().add(r);return e=>{e=toPath(e);e=toRelativePath(e,t);return e?s.ignores(slash(e)):false}};const normalizeOptions=(e={})=>({cwd:toPath(e.cwd)??s.cwd(),suppressErrors:Boolean(e.suppressErrors),deep:typeof e.deep==="number"?e.deep:Number.POSITIVE_INFINITY,ignore:[...e.ignore??[],...S]});const isIgnoredByIgnoreFiles=async(e,t)=>{const{cwd:r,suppressErrors:s,deep:n,ignore:o}=normalizeOptions(t);const i=await d(e,{cwd:r,suppressErrors:s,deep:n,ignore:o,...O});const a=await Promise.all(i.map((async e=>({filePath:e,content:await w.readFile(e,"utf8")}))));return getIsIgnoredPredicate(a,r)};const isIgnoredByIgnoreFilesSync=(e,t)=>{const{cwd:r,suppressErrors:s,deep:o,ignore:i}=normalizeOptions(t);const a=d.sync(e,{cwd:r,suppressErrors:s,deep:o,ignore:i,...O});const c=a.map((e=>({filePath:e,content:n.readFileSync(e,"utf8")})));return getIsIgnoredPredicate(c,r)};const isGitIgnored=e=>isIgnoredByIgnoreFiles(R,e);const isGitIgnoredSync=e=>isIgnoredByIgnoreFilesSync(R,e);const assertPatternsInput=e=>{if(e.some((e=>typeof e!=="string"))){throw new TypeError("Patterns must be a string or an array of strings")}};const normalizePathForDirectoryGlob=(e,t)=>{const r=isNegativePattern(e)?e.slice(1):e;return o.isAbsolute(r)?r:o.join(t,r)};const getDirectoryGlob=({directoryPath:e,files:t,extensions:r})=>{const s=r?.length>0?`.${r.length>1?`{${r.join(",")}}`:r[0]}`:"";return t?t.map((t=>o.posix.join(e,`**/${o.extname(t)?t:`${t}${s}`}`))):[o.posix.join(e,`**${s?`/*${s}`:""}`)]};const directoryToGlob=async(e,{cwd:t=s.cwd(),files:r,extensions:n}={})=>{const o=await Promise.all(e.map((async e=>await g(normalizePathForDirectoryGlob(e,t))?getDirectoryGlob({directoryPath:e,files:r,extensions:n}):e)));return o.flat()};const directoryToGlobSync=(e,{cwd:t=s.cwd(),files:r,extensions:n}={})=>e.flatMap((e=>y(normalizePathForDirectoryGlob(e,t))?getDirectoryGlob({directoryPath:e,files:r,extensions:n}):e));const toPatternsArray=e=>{e=[...new Set([e].flat())];assertPatternsInput(e);return e};const checkCwdOption=e=>{if(!e){return}let t;try{t=n.statSync(e)}catch{return}if(!t.isDirectory()){throw new Error("The `cwd` option must be a path to a directory")}};const globby_normalizeOptions=(e={})=>{e={...e,ignore:e.ignore??[],expandDirectories:e.expandDirectories??true,cwd:toPath(e.cwd)};checkCwdOption(e.cwd);return e};const normalizeArguments=e=>async(t,r)=>e(toPatternsArray(t),globby_normalizeOptions(r));const normalizeArgumentsSync=e=>(t,r)=>e(toPatternsArray(t),globby_normalizeOptions(r));const getIgnoreFilesPatterns=e=>{const{ignoreFiles:t,gitignore:r}=e;const s=t?toPatternsArray(t):[];if(r){s.push(R)}return s};const getFilter=async e=>{const t=getIgnoreFilesPatterns(e);return createFilterFunction(t.length>0&&await isIgnoredByIgnoreFiles(t,e))};const getFilterSync=e=>{const t=getIgnoreFilesPatterns(e);return createFilterFunction(t.length>0&&isIgnoredByIgnoreFilesSync(t,e))};const createFilterFunction=e=>{const t=new Set;return r=>{const s=o.normalize(r.path??r);if(t.has(s)||e&&e(s)){return false}t.add(s);return true}};const unionFastGlobResults=(e,t)=>e.flat().filter((e=>t(e)));const convertNegativePatterns=(e,t)=>{const r=[];while(e.length>0){const s=e.findIndex((e=>isNegativePattern(e)));if(s===-1){r.push({patterns:e,options:t});break}const n=e[s].slice(1);for(const e of r){e.options.ignore.push(n)}if(s!==0){r.push({patterns:e.slice(0,s),options:{...t,ignore:[...t.ignore,n]}})}e=e.slice(s+1)}return r};const normalizeExpandDirectoriesOption=(e,t)=>({...t?{cwd:t}:{},...Array.isArray(e)?{files:e}:e});const generateTasks=async(e,t)=>{const r=convertNegativePatterns(e,t);const{cwd:s,expandDirectories:n}=t;if(!n){return r}const o=normalizeExpandDirectoriesOption(n,s);return Promise.all(r.map((async e=>{let{patterns:t,options:r}=e;[t,r.ignore]=await Promise.all([directoryToGlob(t,o),directoryToGlob(r.ignore,{cwd:s})]);return{patterns:t,options:r}})))};const generateTasksSync=(e,t)=>{const r=convertNegativePatterns(e,t);const{cwd:s,expandDirectories:n}=t;if(!n){return r}const o=normalizeExpandDirectoriesOption(n,s);return r.map((e=>{let{patterns:t,options:r}=e;t=directoryToGlobSync(t,o);r.ignore=directoryToGlobSync(r.ignore,{cwd:s});return{patterns:t,options:r}}))};const P=normalizeArguments((async(e,t)=>{const[r,s]=await Promise.all([generateTasks(e,t),getFilter(t)]);const n=await Promise.all(r.map((e=>d(e.patterns,e.options))));return unionFastGlobResults(n,s)}));const k=normalizeArgumentsSync(((e,t)=>{const r=generateTasksSync(e,t);const s=getFilterSync(t);const n=r.map((e=>d.sync(e.patterns,e.options)));return unionFastGlobResults(n,s)}));const A=normalizeArgumentsSync(((e,t)=>{const r=generateTasksSync(e,t);const s=getFilterSync(t);const n=r.map((e=>d.stream(e.patterns,e.options)));const o=mergeStreams(n).filter((e=>s(e)));return o}));const C=normalizeArgumentsSync(((e,t)=>e.some((e=>d.isDynamicPattern(e,t)))));const x=normalizeArguments(generateTasks);const G=normalizeArgumentsSync(generateTasksSync);const{convertPathToPattern:L}=d}};var t={};function __nccwpck_require__(r){var s=t[r];if(s!==undefined){return s.exports}var n=t[r]={id:r,loaded:false,exports:{}};var o=true;try{e[r].call(n.exports,n,n.exports,__nccwpck_require__);o=false}finally{if(o)delete t[r]}n.loaded=true;return n.exports}(()=>{__nccwpck_require__.d=(e,t)=>{for(var r in t){if(__nccwpck_require__.o(t,r)&&!__nccwpck_require__.o(e,r)){Object.defineProperty(e,r,{enumerable:true,get:t[r]})}}}})();(()=>{__nccwpck_require__.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t)})();(()=>{__nccwpck_require__.r=e=>{if(typeof Symbol!=="undefined"&&Symbol.toStringTag){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})}Object.defineProperty(e,"__esModule",{value:true})}})();(()=>{__nccwpck_require__.nmd=e=>{e.paths=[];if(!e.children)e.children=[];return e}})();if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var r=__nccwpck_require__(2694);module.exports=r})(); \ No newline at end of file +`;function registerPlugins(e,t){return s(this,void 0,void 0,(function*(){if(e===""||e==="false"){return}const r="0.92.3";const s=!t.includes("nightly")&&a.default.lte(t,r);o.default.writeFileSync("register-plugins.nu",u);if(s){i.default.exec(`nu register-plugins.nu '${e}' ${t} --is-legacy`)}else{i.default.exec(`nu register-plugins.nu '${e}' ${t}"`)}}))}},5837:function(e,t,r){"use strict";var s=this&&this.__createBinding||(Object.create?function(e,t,r,s){if(s===undefined)s=r;var n=Object.getOwnPropertyDescriptor(t,r);if(!n||("get"in n?!t.__esModule:n.writable||n.configurable)){n={enumerable:true,get:function(){return t[r]}}}Object.defineProperty(e,s,n)}:function(e,t,r,s){if(s===undefined)s=r;e[s]=t[r]});var n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:true,value:t})}:function(e,t){e["default"]=t});var o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r in e)if(r!=="default"&&Object.prototype.hasOwnProperty.call(e,r))s(t,e,r);n(t,e);return t};var i=this&&this.__awaiter||function(e,t,r,s){function adopt(e){return e instanceof r?e:new r((function(t){t(e)}))}return new(r||(r=Promise))((function(r,n){function fulfilled(e){try{step(s.next(e))}catch(e){n(e)}}function rejected(e){try{step(s["throw"](e))}catch(e){n(e)}}function step(e){e.done?r(e.value):adopt(e.value).then(fulfilled,rejected)}step((s=s.apply(e,t||[])).next())}))};var a=this&&this.__asyncValues||function(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=e[Symbol.asyncIterator],r;return t?t.call(e):(e=typeof __values==="function"?__values(e):e[Symbol.iterator](),r={},verb("next"),verb("throw"),verb("return"),r[Symbol.asyncIterator]=function(){return this},r);function verb(t){r[t]=e[t]&&function(r){return new Promise((function(s,n){r=e[t](r),settle(s,n,r.done,r.value)}))}}function settle(e,t,r,s){Promise.resolve(s).then((function(t){e({value:t,done:r})}),t)}};Object.defineProperty(t,"__esModule",{value:true});t.checkOrInstallTool=checkOrInstallTool;const c=o(r(1017));const u=r(9945);const l=o(r(7705));const p=o(r(9093));const d=o(r(5561));const h=r(4296);const m=r(7147);const g={darwin_x64:["x86_64-apple-darwin","macOS.zip"],darwin_arm64:["aarch64-apple-darwin","macOS.zip"],win32_x64:["x86_64-pc-windows-msvc.zip","windows.zip"],linux_x64:["x86_64-unknown-linux-musl","x86_64-unknown-linux-gnu","linux.tar.gz"]};const E={darwin_x64:["x86_64-darwin-full"],darwin_arm64:["aarch64-darwin-full"],win32_x64:["x86_64-windows-msvc-full.zip"],linux_x64:["x86_64-linux-musl-full","x86_64-linux-gnu-full"]};function getTargets(e){const{arch:t,platform:r}=process;const s=`${r}_${t}`;if(e==="default"){return g[s]}if(e==="full"){return E[s]}throw new Error(`Failed to determine any valid targets: arch = ${t}, platform = ${r}, feature = ${e}`)}function filterMatch(e,t,r){const s=getTargets(r);return e.data.map((e=>{const t=e.assets.find((e=>s.some((t=>e.name.includes(t)))));if(t){return{version:e.tag_name.replace(/^v/,""),downloadUrl:t.browser_download_url}}})).filter((e=>e&&t?l.satisfies(e.version,t):true))}function filterLatest(e,t){const r=getTargets(t);const s=e.data.map((e=>e.tag_name));const n=l.rsort(s)[0];return e.data.filter((e=>e&&e.tag_name===n)).map((e=>{const t=e.assets.find((e=>r.some((t=>e.name.includes(t)))));if(t){return{version:e.tag_name.replace(/^v/,""),downloadUrl:t.browser_download_url}}}))}function filterLatestNightly(e,t){const r=getTargets(t);const s=e.data.map((e=>e.published_at));const n=s.sort(((e,t)=>new Date(t).getTime()-new Date(e).getTime()));const o=n[0];p.info(`Try to get latest nightly version published at: ${o}`);return e.data.filter((e=>e&&e.published_at===o)).map((e=>{const t=e.assets.find((e=>r.some((t=>e.name.includes(t)))));if(t){return{version:e.tag_name.replace(/^v/,""),downloadUrl:t.browser_download_url}}}))}function getRelease(e){return i(this,void 0,void 0,(function*(){const{owner:t,name:r,versionSpec:s,checkLatest:n=false,features:o="default"}=e;const i=s==="nightly";const a=new h.Octokit({auth:e.githubToken});return a.paginate(a.repos.listReleases,{owner:t,repo:r},((e,t)=>{const r=i?filterLatestNightly(e,o):[];const a=n?filterLatest(e,o):filterMatch(e,s,o);const c=i?r:a;if(c){t()}return c})).then((e=>{const t=e.find((e=>e!=null));if(t===undefined){if(o==="full"){p.warning('The "full" feature was removed for Nu after v0.93.1, try to use "default" feature instead.')}throw new Error(`No release for Nusehll matching version specifier ${s} of ${o} feature.`)}return t}))}))}function handleBadBinaryPermissions(e,t){return i(this,void 0,void 0,(function*(){const{name:r,bin:s}=e;if(process.platform!=="win32"){const findBin=()=>i(this,void 0,void 0,(function*(){var e,s,n,o;const i=yield m.promises.readdir(t);try{for(var c=true,u=a(i),l;l=yield u.next(),e=l.done,!e;c=true){o=l.value;c=false;const e=o;if(e.toLowerCase()===r.toLowerCase()){return e}}}catch(e){s={error:e}}finally{try{if(!c&&!e&&(n=u.return))yield n.call(u)}finally{if(s)throw s.error}}return r}));const e=c.join(t,s?s:yield findBin());try{yield m.promises.access(e,m.constants.X_OK)}catch(t){yield m.promises.chmod(e,"755");p.debug(`Fixed file permissions (-> 0o755) for ${e}`)}}}))}function checkOrInstallTool(e){return i(this,void 0,void 0,(function*(){const{name:t,versionSpec:r}=e;let s=d.find(t,r||"*");if(!s){const{version:r,downloadUrl:n}=yield getRelease(e);const o=yield d.downloadTool(n);p.debug(`Successfully downloaded ${t} v${r}`);let i;if(n.endsWith(".zip")){i=yield d.extractZip(o)}else{i=yield d.extractTar(o)}p.debug(`Successfully extracted archive for ${t} v${r}`);const a=yield(0,u.globby)([`${i}/**/nu_plugin_*`,c.join(i,"**","nu_plugin_*").replace(/\\/g,"/")],{unique:true,absolute:true});s=yield d.cacheDir(c.dirname(a[0]),t,r);yield handleBadBinaryPermissions(e,s)}const n=c.basename(c.dirname(s));return Object.assign({version:n,dir:s},e)}))}},9491:e=>{"use strict";e.exports=require("assert")},2081:e=>{"use strict";e.exports=require("child_process")},6113:e=>{"use strict";e.exports=require("crypto")},2361:e=>{"use strict";e.exports=require("events")},7147:e=>{"use strict";e.exports=require("fs")},3685:e=>{"use strict";e.exports=require("http")},5687:e=>{"use strict";e.exports=require("https")},1808:e=>{"use strict";e.exports=require("net")},2037:e=>{"use strict";e.exports=require("os")},1017:e=>{"use strict";e.exports=require("path")},2781:e=>{"use strict";e.exports=require("stream")},1576:e=>{"use strict";e.exports=require("string_decoder")},9512:e=>{"use strict";e.exports=require("timers")},4404:e=>{"use strict";e.exports=require("tls")},3837:e=>{"use strict";e.exports=require("util")},9945:(e,t,r)=>{"use strict";r.r(t);r.d(t,{convertPathToPattern:()=>L,generateGlobTasks:()=>x,generateGlobTasksSync:()=>G,globby:()=>P,globbyStream:()=>A,globbySync:()=>k,isDynamicPattern:()=>C,isGitIgnored:()=>isGitIgnored,isGitIgnoredSync:()=>isGitIgnoredSync});const s=require("node:process");const n=require("node:fs");const o=require("node:path");const i=require("node:events");const a=require("node:stream");const c=require("node:stream/promises");function mergeStreams(e){if(!Array.isArray(e)){throw new TypeError(`Expected an array, got \`${typeof e}\`.`)}for(const t of e){validateStream(t)}const t=e.some((({readableObjectMode:e})=>e));const r=getHighWaterMark(e,t);const s=new MergedStream({objectMode:t,writableHighWaterMark:r,readableHighWaterMark:r});for(const t of e){s.add(t)}if(e.length===0){s.end()}return s}const getHighWaterMark=(e,t)=>{if(e.length===0){return 16384}const r=e.filter((({readableObjectMode:e})=>e===t)).map((({readableHighWaterMark:e})=>e));return Math.max(...r)};class MergedStream extends a.PassThrough{#e=new Set([]);#t=new Set([]);#r;constructor(...e){super(...e);this.#r=onMergedStreamFinished(this,this.#e)}add(e){if(this.#e.has(e)){return}validateStream(e);if(!this.writable){throw new TypeError("The merged stream has already ended.")}this.#e.add(e);endWhenStreamsDone({passThroughStream:this,stream:e,streams:this.#e,ended:this.#t,onFinished:this.#r});updateMaxListeners(this,p);e.pipe(this,{end:false})}remove(e){if(!this.#e.has(e)){throw new TypeError("Stream cannot be removed because it was not piped.")}e.unpipe(this)}}const onMergedStreamFinished=async(e,t)=>{updateMaxListeners(e,l);const r=new AbortController;try{await Promise.race([onMergedStreamEnd(e,r),onInputStreamsUnpipe(e,t,r)])}finally{r.abort();updateMaxListeners(e,-l)}};const onMergedStreamEnd=async(e,{signal:t})=>{try{await(0,c.finished)(e,{signal:t,cleanup:true})}catch{}};const onInputStreamsUnpipe=async(e,t,{signal:r})=>{for await(const[s]of(0,i.on)(e,"unpipe",{signal:r})){if(t.has(s)){s.emit(u)}}};const validateStream=e=>{if(typeof e?.pipe!=="function"){throw new TypeError(`Expected a readable stream, got: \`${typeof e}\`.`)}};const endWhenStreamsDone=async({passThroughStream:e,stream:t,streams:r,ended:s,onFinished:n})=>{try{const o=new AbortController;try{await Promise.race([n,onInputStreamEnd({stream:t,streams:r,ended:s,abortController:o}),onInputStreamUnpipe({passThroughStream:e,stream:t,streams:r,ended:s,abortController:o})])}finally{o.abort()}if(r.size===s.size&&e.writable){e.end()}}catch(t){if(t?.code==="ERR_STREAM_PREMATURE_CLOSE"){e.destroy()}else{e.destroy(t)}}};const onInputStreamEnd=async({stream:e,streams:t,ended:r,abortController:{signal:s}})=>{await(0,c.finished)(e,{signal:s,cleanup:true,readable:true,writable:false});if(t.has(e)){r.add(e)}};const onInputStreamUnpipe=async({passThroughStream:e,stream:t,streams:r,ended:s,abortController:{signal:n}})=>{await(0,i.once)(t,u,{signal:n});r.delete(t);s.delete(t);updateMaxListeners(e,-p)};const u=Symbol("unpipe");const updateMaxListeners=(e,t)=>{e.setMaxListeners(e.getMaxListeners()+t)};const l=2;const p=1;var d=r(6581);var h=r(7147);async function isType(e,t,r){if(typeof r!=="string"){throw new TypeError(`Expected a string, got ${typeof r}`)}try{const s=await h.promises[e](r);return s[t]()}catch(e){if(e.code==="ENOENT"){return false}throw e}}function isTypeSync(e,t,r){if(typeof r!=="string"){throw new TypeError(`Expected a string, got ${typeof r}`)}try{return h[e](r)[t]()}catch(e){if(e.code==="ENOENT"){return false}throw e}}const m=isType.bind(null,"stat","isFile");const g=isType.bind(null,"stat","isDirectory");const E=isType.bind(null,"lstat","isSymbolicLink");const v=isTypeSync.bind(null,"statSync","isFile");const y=isTypeSync.bind(null,"statSync","isDirectory");const _=isTypeSync.bind(null,"lstatSync","isSymbolicLink");const b=require("node:url");function toPath(e){return e instanceof URL?(0,b.fileURLToPath)(e):e}const w=require("node:fs/promises");var T=r(8829);function slash(e){const t=e.startsWith("\\\\?\\");if(t){return e}return e.replace(/\\/g,"/")}const isNegativePattern=e=>e[0]==="!";const S=["**/node_modules","**/flow-typed","**/coverage","**/.git"];const O={absolute:true,dot:true};const R="**/.gitignore";const applyBaseToPattern=(e,t)=>isNegativePattern(e)?"!"+o.posix.join(t,e.slice(1)):o.posix.join(t,e);const parseIgnoreFile=(e,t)=>{const r=slash(o.relative(t,o.dirname(e.filePath)));return e.content.split(/\r?\n/).filter((e=>e&&!e.startsWith("#"))).map((e=>applyBaseToPattern(e,r)))};const toRelativePath=(e,t)=>{t=slash(t);if(o.isAbsolute(e)){if(slash(e).startsWith(t)){return o.relative(t,e)}throw new Error(`Path ${e} is not in cwd ${t}`)}return e};const getIsIgnoredPredicate=(e,t)=>{const r=e.flatMap((e=>parseIgnoreFile(e,t)));const s=T().add(r);return e=>{e=toPath(e);e=toRelativePath(e,t);return e?s.ignores(slash(e)):false}};const normalizeOptions=(e={})=>({cwd:toPath(e.cwd)??s.cwd(),suppressErrors:Boolean(e.suppressErrors),deep:typeof e.deep==="number"?e.deep:Number.POSITIVE_INFINITY,ignore:[...e.ignore??[],...S]});const isIgnoredByIgnoreFiles=async(e,t)=>{const{cwd:r,suppressErrors:s,deep:n,ignore:o}=normalizeOptions(t);const i=await d(e,{cwd:r,suppressErrors:s,deep:n,ignore:o,...O});const a=await Promise.all(i.map((async e=>({filePath:e,content:await w.readFile(e,"utf8")}))));return getIsIgnoredPredicate(a,r)};const isIgnoredByIgnoreFilesSync=(e,t)=>{const{cwd:r,suppressErrors:s,deep:o,ignore:i}=normalizeOptions(t);const a=d.sync(e,{cwd:r,suppressErrors:s,deep:o,ignore:i,...O});const c=a.map((e=>({filePath:e,content:n.readFileSync(e,"utf8")})));return getIsIgnoredPredicate(c,r)};const isGitIgnored=e=>isIgnoredByIgnoreFiles(R,e);const isGitIgnoredSync=e=>isIgnoredByIgnoreFilesSync(R,e);const assertPatternsInput=e=>{if(e.some((e=>typeof e!=="string"))){throw new TypeError("Patterns must be a string or an array of strings")}};const normalizePathForDirectoryGlob=(e,t)=>{const r=isNegativePattern(e)?e.slice(1):e;return o.isAbsolute(r)?r:o.join(t,r)};const getDirectoryGlob=({directoryPath:e,files:t,extensions:r})=>{const s=r?.length>0?`.${r.length>1?`{${r.join(",")}}`:r[0]}`:"";return t?t.map((t=>o.posix.join(e,`**/${o.extname(t)?t:`${t}${s}`}`))):[o.posix.join(e,`**${s?`/*${s}`:""}`)]};const directoryToGlob=async(e,{cwd:t=s.cwd(),files:r,extensions:n}={})=>{const o=await Promise.all(e.map((async e=>await g(normalizePathForDirectoryGlob(e,t))?getDirectoryGlob({directoryPath:e,files:r,extensions:n}):e)));return o.flat()};const directoryToGlobSync=(e,{cwd:t=s.cwd(),files:r,extensions:n}={})=>e.flatMap((e=>y(normalizePathForDirectoryGlob(e,t))?getDirectoryGlob({directoryPath:e,files:r,extensions:n}):e));const toPatternsArray=e=>{e=[...new Set([e].flat())];assertPatternsInput(e);return e};const checkCwdOption=e=>{if(!e){return}let t;try{t=n.statSync(e)}catch{return}if(!t.isDirectory()){throw new Error("The `cwd` option must be a path to a directory")}};const globby_normalizeOptions=(e={})=>{e={...e,ignore:e.ignore??[],expandDirectories:e.expandDirectories??true,cwd:toPath(e.cwd)};checkCwdOption(e.cwd);return e};const normalizeArguments=e=>async(t,r)=>e(toPatternsArray(t),globby_normalizeOptions(r));const normalizeArgumentsSync=e=>(t,r)=>e(toPatternsArray(t),globby_normalizeOptions(r));const getIgnoreFilesPatterns=e=>{const{ignoreFiles:t,gitignore:r}=e;const s=t?toPatternsArray(t):[];if(r){s.push(R)}return s};const getFilter=async e=>{const t=getIgnoreFilesPatterns(e);return createFilterFunction(t.length>0&&await isIgnoredByIgnoreFiles(t,e))};const getFilterSync=e=>{const t=getIgnoreFilesPatterns(e);return createFilterFunction(t.length>0&&isIgnoredByIgnoreFilesSync(t,e))};const createFilterFunction=e=>{const t=new Set;return r=>{const s=o.normalize(r.path??r);if(t.has(s)||e&&e(s)){return false}t.add(s);return true}};const unionFastGlobResults=(e,t)=>e.flat().filter((e=>t(e)));const convertNegativePatterns=(e,t)=>{const r=[];while(e.length>0){const s=e.findIndex((e=>isNegativePattern(e)));if(s===-1){r.push({patterns:e,options:t});break}const n=e[s].slice(1);for(const e of r){e.options.ignore.push(n)}if(s!==0){r.push({patterns:e.slice(0,s),options:{...t,ignore:[...t.ignore,n]}})}e=e.slice(s+1)}return r};const normalizeExpandDirectoriesOption=(e,t)=>({...t?{cwd:t}:{},...Array.isArray(e)?{files:e}:e});const generateTasks=async(e,t)=>{const r=convertNegativePatterns(e,t);const{cwd:s,expandDirectories:n}=t;if(!n){return r}const o=normalizeExpandDirectoriesOption(n,s);return Promise.all(r.map((async e=>{let{patterns:t,options:r}=e;[t,r.ignore]=await Promise.all([directoryToGlob(t,o),directoryToGlob(r.ignore,{cwd:s})]);return{patterns:t,options:r}})))};const generateTasksSync=(e,t)=>{const r=convertNegativePatterns(e,t);const{cwd:s,expandDirectories:n}=t;if(!n){return r}const o=normalizeExpandDirectoriesOption(n,s);return r.map((e=>{let{patterns:t,options:r}=e;t=directoryToGlobSync(t,o);r.ignore=directoryToGlobSync(r.ignore,{cwd:s});return{patterns:t,options:r}}))};const P=normalizeArguments((async(e,t)=>{const[r,s]=await Promise.all([generateTasks(e,t),getFilter(t)]);const n=await Promise.all(r.map((e=>d(e.patterns,e.options))));return unionFastGlobResults(n,s)}));const k=normalizeArgumentsSync(((e,t)=>{const r=generateTasksSync(e,t);const s=getFilterSync(t);const n=r.map((e=>d.sync(e.patterns,e.options)));return unionFastGlobResults(n,s)}));const A=normalizeArgumentsSync(((e,t)=>{const r=generateTasksSync(e,t);const s=getFilterSync(t);const n=r.map((e=>d.stream(e.patterns,e.options)));const o=mergeStreams(n).filter((e=>s(e)));return o}));const C=normalizeArgumentsSync(((e,t)=>e.some((e=>d.isDynamicPattern(e,t)))));const x=normalizeArguments(generateTasks);const G=normalizeArgumentsSync(generateTasksSync);const{convertPathToPattern:L}=d}};var t={};function __nccwpck_require__(r){var s=t[r];if(s!==undefined){return s.exports}var n=t[r]={id:r,loaded:false,exports:{}};var o=true;try{e[r].call(n.exports,n,n.exports,__nccwpck_require__);o=false}finally{if(o)delete t[r]}n.loaded=true;return n.exports}(()=>{__nccwpck_require__.d=(e,t)=>{for(var r in t){if(__nccwpck_require__.o(t,r)&&!__nccwpck_require__.o(e,r)){Object.defineProperty(e,r,{enumerable:true,get:t[r]})}}}})();(()=>{__nccwpck_require__.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t)})();(()=>{__nccwpck_require__.r=e=>{if(typeof Symbol!=="undefined"&&Symbol.toStringTag){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})}Object.defineProperty(e,"__esModule",{value:true})}})();(()=>{__nccwpck_require__.nmd=e=>{e.paths=[];if(!e.children)e.children=[];return e}})();if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var r=__nccwpck_require__(2694);module.exports=r})(); \ No newline at end of file diff --git a/src/plugins.ts b/src/plugins.ts index db04a2e..43f213e 100644 --- a/src/plugins.ts +++ b/src/plugins.ts @@ -39,8 +39,8 @@ export async function registerPlugins(enablePlugins: string, version: string) { const isLegacyVersion = !version.includes('nightly') && semver.lte(version, LEGACY_VERSION); fs.writeFileSync('register-plugins.nu', pluginRegisterScript); if (isLegacyVersion) { - shell.exec(`nu register-plugins.nu ${enablePlugins} ${version} --is-legacy`); + shell.exec(`nu register-plugins.nu '${enablePlugins}' ${version} --is-legacy`); } else { - shell.exec(`nu register-plugins.nu ${enablePlugins} ${version}"`); + shell.exec(`nu register-plugins.nu '${enablePlugins}' ${version}"`); } }