You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

@alessiofrittoli/node-scripts

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@alessiofrittoli/node-scripts - npm Package Compare versions

Comparing version

to
3.0.0-alpha.2

73

dist/index.d.ts

@@ -0,5 +1,71 @@

import { ErrorCode as ErrorCode$1 } from '@alessiofrittoli/exception/code';
import { ParsedPath } from 'path';
import { Stats } from 'fs';
import { AbortSignal } from '@alessiofrittoli/abort-controller';
import { Git, NodeJS, Package } from './types.js';
export { Release } from './types.js';
declare enum FileSystem {
ENOENT = "ERR:ENOENT"
}
declare const ErrorCode: {
ENOENT: FileSystem.ENOENT;
UNKNOWN: ErrorCode$1.UNKNOWN;
ABORT: ErrorCode$1.ABORT;
EMPTY_VALUE: ErrorCode$1.EMPTY_VALUE;
WRONG_VALUE: ErrorCode$1.WRONG_VALUE;
EXPIRED: ErrorCode$1.EXPIRED;
TOO_EARLY: ErrorCode$1.TOO_EARLY;
TOO_MANY: ErrorCode$1.TOO_MANY;
QUOTA_REACHED: ErrorCode$1.QUOTA_REACHED;
NOT_FOUND: ErrorCode$1.NOT_FOUND;
OFFLINE: ErrorCode$1.OFFLINE;
};
type ErrorCode = MergedEnumValue<typeof ErrorCode>;
interface DirectoryTreeEntry {
path: string;
parsedPath: ParsedPath;
stats: Stats;
}
type OnIterationOptions = DirectoryTreeEntry;
type OnIteration<T = unknown> = (options: OnIterationOptions, index: number, total: number) => T | Promise<T>;
interface ForEachDirectoryEntryOptions<T = unknown, TCode = ErrorCode> {
/** The root directory path to start traversal. */
path: string;
/** Excluded paths. */
exclude?: string[];
/** An AbortSignal to cancel the iteration early. */
signal?: AbortSignal<TCode>;
/** Callback function invoked for each directory entry. */
onIteration: OnIteration<T>;
}
/**
* Recursively retrieves the directory tree starting from the specified path.
*
* @param path The root directory path to start traversing.
* @param exclude Optional array of directory paths to exclude from the traversal.
*
* @returns An array of {@linkcode DirectoryTreeEntry} objects representing files and directories found.
* @throws A new Exception if the specified `path` does not exist.
*
* @remarks
* - If `path` is in the `exclude` list, an empty array is returned.
* - If `path` is a file, returns an array containing only that file's entry.
* - If `path` is a directory, recursively traverses its contents, excluding any paths listed in `exclude`.
*/
declare const getDirectoryTree: (path: string, exclude?: string[]) => DirectoryTreeEntry[];
/**
* Asynchronously iterates over each entry in a directory tree, applying a callback function to each entry.
*
* @template T The type of the result returned by the iteration callback.
* @template TCode The type representing error codes.
*
* @param options Configuration options for the iteration. See {@linkcode ForEachDirectoryEntryOptions} for more info.
*
* @returns A new Promise that resolves to an array of results returned by the callback for each entry.
*/
declare const forEachDirectoryEntry: <T = unknown, TCode = ErrorCode>(options: ForEachDirectoryEntryOptions<T, TCode>) => Promise<T[]>;
/**
* Retrieves the list of Git remotes and their URLs.

@@ -128,2 +194,5 @@ *

type PackageJson = (Record<string, string | Record<string, string>> & {
name: string;
});
/**

@@ -136,3 +205,3 @@ * Reads and parses the `package.json` file from the specified root directory.

*/
declare const getPackageJson: (root: Package["root"]) => any;
declare const getPackageJson: (root: Package["root"]) => PackageJson;
/**

@@ -181,2 +250,2 @@ * Determines if the script is running in an external project.

export { Git, NodeJS, Package, formatStash, formatStashList, getDefaultRemote, getDefaultRemoteAndBranch, getPackage, getPackageJson, getPreReleaseTag, getProcessOptions, getProcessRoot, getRemotes, getStashBy, getStashList, isExternalPackage, isPackageInstalled, popStashByIndex };
export { type DirectoryTreeEntry, ErrorCode, FileSystem, type ForEachDirectoryEntryOptions, Git, NodeJS, type OnIteration, type OnIterationOptions, Package, type PackageJson, forEachDirectoryEntry, formatStash, formatStashList, getDefaultRemote, getDefaultRemoteAndBranch, getDirectoryTree, getPackage, getPackageJson, getPreReleaseTag, getProcessOptions, getProcessRoot, getRemotes, getStashBy, getStashList, isExternalPackage, isPackageInstalled, popStashByIndex };

8

dist/index.js

@@ -1,4 +0,4 @@

'use strict';var child_process=require('child_process'),P=require('fs'),N=require('path');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var P__default=/*#__PURE__*/_interopDefault(P);var N__default=/*#__PURE__*/_interopDefault(N);var g=()=>{let e=child_process.execSync("git remote -v",{encoding:"buffer"}).toString().split(`
`),r=new Map;return e.map(s=>{var m;let[n,o]=s.split(" ");if(!n||!o)return null;let a=r.get(n)||new Map,p=a.get("urls")||new Map,c=o.split(" "),i=((m=c.at(1))==null?void 0:m.replace(/\(|\)/g,""))||"fetch",x=p.has(i)?i==="fetch"?"push":"fetch":i,u=c.at(0);if(!u)return null;p.set(x,u),a.set("name",n),a.set("urls",p),r.has(n)||r.set(n,a);}),r},h=()=>{var t,e,r;return ((r=(e=(t=child_process.execSync("git branch -rl '*/HEAD'"))==null?void 0:t.toString().split(`
`).filter(Boolean).at(0))==null?void 0:e.split(" -> ").at(1))==null?void 0:r.split("/"))||[null,null]},w=()=>{var e;let[t]=h();return t?g().get(t):(e=g().entries().next().value)==null?void 0:e[1]},S=()=>child_process.execSync("git stash list").toString().split(`
`).map(f).filter(Boolean),f=t=>{var o;if(!t)return null;let e=t.split(": "),r=Number(e.at(0).split("@{").pop().split("}").at(0)||"invalid");if(isNaN(r))return null;let s=(e.at(2)?e.at(1).split(" ").pop():null)||"main",n=e.at(2)||((o=e.at(1))==null?void 0:o.split(" ").pop())||null;return {index:r,branch:s,name:n}},M=t=>t.map(f),R=t=>S().find(e=>"name"in t?e.name===t.name:e.index===t.index),b=t=>child_process.execFileSync("git",["stash","pop","--index",t.toString()],{stdio:"inherit"});var v=t=>JSON.parse(child_process.execSync(`npm list --json${t?" -g":""}`).toString()),T=(t,e)=>t in(v(e).dependencies||{});var k=t=>JSON.parse(P__default.default.readFileSync(N__default.default.resolve(t,"package.json")).toString()),O=({root:t,name:e})=>{try{return !k(t).name.endsWith(e)}catch(r){throw new Error("Couldn't check if script is running in an external project.",{cause:r})}},I=t=>{let e=t.match(/-(\w+)\.\d+/);return e?e[1]:null};var E=()=>process.env.INIT_CWD||process.cwd(),K=()=>new Map(process.argv.map(t=>({value:t,isValue:!t.startsWith("-")})).map((t,e,r)=>{switch(e){case 0:return ["--executable",t.value];case 1:return ["--scriptPath",t.value];default:{let s=r[e+1];if(!t.isValue)return s!=null&&s.isValue?[t.value,s.value]:[t.value,"true"]}}}).filter(Boolean));exports.formatStash=f;exports.formatStashList=M;exports.getDefaultRemote=w;exports.getDefaultRemoteAndBranch=h;exports.getPackage=v;exports.getPackageJson=k;exports.getPreReleaseTag=I;exports.getProcessOptions=K;exports.getProcessRoot=E;exports.getRemotes=g;exports.getStashBy=R;exports.getStashList=S;exports.isExternalPackage=O;exports.isPackageInstalled=T;exports.popStashByIndex=b;
'use strict';var code=require('@alessiofrittoli/exception/code'),F=require('path'),A=require('fs'),exception=require('@alessiofrittoli/exception'),child_process=require('child_process');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var F__default=/*#__PURE__*/_interopDefault(F);var A__default=/*#__PURE__*/_interopDefault(A);var b=Object.defineProperty;var f=Object.getOwnPropertySymbols;var k=Object.prototype.hasOwnProperty,w=Object.prototype.propertyIsEnumerable;var d=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t);var y=(t,e,r)=>e in t?b(t,e,{enumerable:true,configurable:true,writable:true,value:r}):t[e]=r,m=(t,e)=>{for(var r in e||(e={}))k.call(e,r)&&y(t,r,e[r]);if(f)for(var r of f(e))w.call(e,r)&&y(t,r,e[r]);return t};var x=(t,e,r)=>(e=t[d("asyncIterator")])?e.call(t):(t=t[d("iterator")](),e={},r=(o,s)=>(s=t[o])&&(e[o]=n=>new Promise((a,i,p)=>(n=s.call(t,n),p=n.done,Promise.resolve(n.value).then(c=>a({value:c,done:p}),i)))),r("next"),r("return"),e);var h=(e=>(e.ENOENT="ERR:ENOENT",e))(h||{}),S=m(m({},code.ErrorCode),h);var E=(t,e)=>{if(e!=null&&e.includes(t))return [];if(!A.existsSync(t))throw new exception.Exception(`No such file or directory, '${t}'`,{code:S.ENOENT});let r=A.lstatSync(t),o=F.parse(t),s=r.isFile(),n={path:t,parsedPath:o,stats:r};return s?[n]:[...A.readdirSync(t).map(a=>E(F.join(o.dir,o.base,a),e)).flat(),n]},Q=async t=>{let{path:e,exclude:r,signal:o,onIteration:s}=t,n=E(e,r),a=[];try{for(var i=x(n),p,c,N;p=!(c=await i.next()).done;p=!1){let l=c.value;if(o!=null&&o.aborted)break;a.push(await s(l,a.length,n.length));}}catch(c){N=[c];}finally{try{p&&(c=i.return)&&await c.call(i);}finally{if(N)throw N[0]}}return a};var T=()=>{let e=child_process.execSync("git remote -v",{encoding:"buffer"}).toString().split(`
`),r=new Map;return e.map(o=>{var g;let[s,n]=o.split(" ");if(!s||!n)return null;let a=r.get(s)||new Map,i=a.get("urls")||new Map,p=n.split(" "),c=((g=p.at(1))==null?void 0:g.replace(/\(|\)/g,""))||"fetch",N=i.has(c)?c==="fetch"?"push":"fetch":c,l=p.at(0);if(!l)return null;i.set(N,l),a.set("name",s),a.set("urls",i),r.has(s)||r.set(s,a);}),r},M=()=>{var t,e,r;return ((r=(e=(t=child_process.execSync("git branch -rl '*/HEAD'"))==null?void 0:t.toString().split(`
`).filter(Boolean).at(0))==null?void 0:e.split(" -> ").at(1))==null?void 0:r.split("/"))||[null,null]},tt=()=>{var e;let[t]=M();return t?T().get(t):(e=T().entries().next().value)==null?void 0:e[1]},V=()=>child_process.execSync("git stash list").toString().split(`
`).map(P).filter(Boolean),P=t=>{var n;if(!t)return null;let e=t.split(": "),r=Number(e.at(0).split("@{").pop().split("}").at(0)||"invalid");if(isNaN(r))return null;let o=(e.at(2)?e.at(1).split(" ").pop():null)||"main",s=e.at(2)||((n=e.at(1))==null?void 0:n.split(" ").pop())||null;return {index:r,branch:o,name:s}},et=t=>t.map(P),rt=t=>V().find(e=>"name"in t?e.name===t.name:e.index===t.index),ot=t=>child_process.execFileSync("git",["stash","pop","--index",t.toString()],{stdio:"inherit"});var j=t=>JSON.parse(child_process.execSync(`npm list --json${t?" -g":""}`).toString()),at=(t,e)=>t in(j(e).dependencies||{});var K=t=>JSON.parse(A__default.default.readFileSync(F__default.default.resolve(t,"package.json")).toString()),lt=({root:t,name:e})=>{try{return !K(t).name.endsWith(e)}catch(r){throw new Error("Couldn't check if script is running in an external project.",{cause:r})}},mt=t=>{let e=t.match(/-(\w+)\.\d+/);return e?e[1]:null};var gt=()=>process.env.INIT_CWD||process.cwd(),ft=()=>new Map(process.argv.map(t=>({value:t,isValue:!t.startsWith("-")})).map((t,e,r)=>{switch(e){case 0:return ["--executable",t.value];case 1:return ["--scriptPath",t.value];default:{let o=r[e+1];if(!t.isValue)return o!=null&&o.isValue?[t.value,o.value]:[t.value,"true"]}}}).filter(Boolean));exports.ErrorCode=S;exports.FileSystem=h;exports.forEachDirectoryEntry=Q;exports.formatStash=P;exports.formatStashList=et;exports.getDefaultRemote=tt;exports.getDefaultRemoteAndBranch=M;exports.getDirectoryTree=E;exports.getPackage=j;exports.getPackageJson=K;exports.getPreReleaseTag=mt;exports.getProcessOptions=ft;exports.getProcessRoot=gt;exports.getRemotes=T;exports.getStashBy=rt;exports.getStashList=V;exports.isExternalPackage=lt;exports.isPackageInstalled=at;exports.popStashByIndex=ot;

@@ -1,4 +0,4 @@

'use strict';var i=require('fs'),f=require('path');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var i__default=/*#__PURE__*/_interopDefault(i);var f__default=/*#__PURE__*/_interopDefault(f);var u=()=>process.env.INIT_CWD||process.cwd();var h=r=>JSON.parse(i__default.default.readFileSync(f__default.default.resolve(r,"package.json")).toString()),p=({root:r,name:n})=>{try{return !h(r).name.endsWith(n)}catch(e){throw new Error("Couldn't check if script is running in an external project.",{cause:e})}};var w=r=>{let{root:n}=r,{name:e}=r,{outputFile:t}=r,o=`/// <reference types="${e}" />
'use strict';var i=require('fs'),f=require('path');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var i__default=/*#__PURE__*/_interopDefault(i);var f__default=/*#__PURE__*/_interopDefault(f);var p=()=>process.env.INIT_CWD||process.cwd();var h=r=>JSON.parse(i__default.default.readFileSync(f__default.default.resolve(r,"package.json")).toString()),u=({root:r,name:n})=>{try{return !h(r).name.endsWith(n)}catch(e){throw new Error("Couldn't check if script is running in an external project.",{cause:e})}};var w=r=>{let{root:n}=r,{name:e}=r,{outputFile:t}=r,o=`/// <reference types="${e}" />
`,c="// NOTE: This file should not be edited",s=f__default.default.resolve(n,t);if(i__default.default.existsSync(s)){let a=i__default.default.readFileSync(s);if(a.toString().split(`
`).includes(o.replace(/\n/g,""))){console.log({package:e,message:`The "${t}" file already exists and it includes the needed type references.`});return}let d=Buffer.concat([Buffer.from(o),a]);try{i__default.default.writeFileSync(s,d),console.log({package:e,message:`The "${t}" file already exists and it has been edited with new type references.`});return}catch(m){throw new Error(`An error occured while editing "${t}" in your project. Some global types may not work as expected.`,{cause:m})}}let l=[o,c].join(`
`);try{return i__default.default.writeFileSync(s,Buffer.from(l)),console.log({package:e,message:`"${t}" has been created at the root of your project.`}),!0}catch(a){throw new Error(`An error occurred while creating "${t}" at the root of your project. Some global types may not work as expected.`,{cause:a})}},x=r=>{let{root:n}=r,{name:e}=r,{outputFile:t}=r,o="tsconfig.json";try{let c=f__default.default.resolve(n,o),s=JSON.parse(i__default.default.readFileSync(c).toString());s.include||(s.include=[]);let{include:l}=s;if(Array.isArray(l)&&!l.includes(t)){l.push(t);try{i__default.default.writeFileSync(c,Buffer.from(JSON.stringify(s,void 0," "))),console.log({package:e,message:`"${t}" added to \`include\` property of your "${o}" file.`});}catch(a){throw new Error(`Couldn't update your "${o}" file. You should manually update it by adding ${t} in the \`include\` array.`,{cause:a})}}}catch(c){throw new Error(`An error occured while updating your "${o}" file.`,{cause:c})}},A=r=>{let{outputFile:n="alessiofrittoli-env.d.ts"}=r,{name:e}=r,t=u();try{if(!p({name:e,root:t})){console.log({package:e,message:`Skip "postinstall" script. Running in ${e}`});return}w({name:e,root:t,outputFile:n}),x({root:t,name:e,outputFile:n});}catch(o){console.error(o),process.exit(1);}};exports.addTypesReference=A;exports.createReferenceFile=w;exports.updateTsConfig=x;
`).includes(o.replace(/\n/g,""))){console.log({package:e,message:`The "${t}" file already exists and it includes the needed type references.`});return}let d=Buffer.concat([Buffer.from(o),a]);try{i__default.default.writeFileSync(s,d),console.log({package:e,message:`The "${t}" file already exists and it has been edited with new type references.`});return}catch(g){throw new Error(`An error occured while editing "${t}" in your project. Some global types may not work as expected.`,{cause:g})}}let l=[o,c].join(`
`);try{return i__default.default.writeFileSync(s,Buffer.from(l)),console.log({package:e,message:`"${t}" has been created at the root of your project.`}),!0}catch(a){throw new Error(`An error occurred while creating "${t}" at the root of your project. Some global types may not work as expected.`,{cause:a})}},x=r=>{let{root:n}=r,{name:e}=r,{outputFile:t}=r,o="tsconfig.json";try{let c=f__default.default.resolve(n,o),s=JSON.parse(i__default.default.readFileSync(c).toString());s.include||(s.include=[]);let{include:l}=s;if(Array.isArray(l)&&!l.includes(t)){l.push(t);try{i__default.default.writeFileSync(c,Buffer.from(JSON.stringify(s,void 0," "))),console.log({package:e,message:`"${t}" added to \`include\` property of your "${o}" file.`});}catch(a){throw new Error(`Couldn't update your "${o}" file. You should manually update it by adding ${t} in the \`include\` array.`,{cause:a})}}}catch(c){throw new Error(`An error occured while updating your "${o}" file.`,{cause:c})}},O=r=>{let{outputFile:n="alessiofrittoli-env.d.ts"}=r,{name:e}=r,t=p();try{if(!u({name:e,root:t})){console.log({package:e,message:`Skip "postinstall" script. Running in ${e}`});return}w({name:e,root:t,outputFile:n}),x({root:t,name:e,outputFile:n});}catch(o){console.error(o),process.exit(1);}};exports.addTypesReference=O;exports.createReferenceFile=w;exports.updateTsConfig=x;
'use strict';var child_process=require('child_process'),R=require('fs'),N=require('path');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var R__default=/*#__PURE__*/_interopDefault(R);var N__default=/*#__PURE__*/_interopDefault(N);var f=()=>process.env.INIT_CWD||process.cwd(),h=()=>new Map(process.argv.map(e=>({value:e,isValue:!e.startsWith("-")})).map((e,t,r)=>{switch(t){case 0:return ["--executable",e.value];case 1:return ["--scriptPath",e.value];default:{let o=r[t+1];if(!e.isValue)return o!=null&&o.isValue?[e.value,o.value]:[e.value,"true"]}}}).filter(Boolean));var x=e=>JSON.parse(R__default.default.readFileSync(N__default.default.resolve(e,"package.json")).toString());var y=e=>{let t=e.match(/-(\w+)\.\d+/);return t?t[1]:null};var S=()=>{let t=child_process.execSync("git remote -v",{encoding:"buffer"}).toString().split(`
`),r=new Map;return t.map(o=>{var u;let[s,a]=o.split(" ");if(!s||!a)return null;let i=r.get(s)||new Map,p=i.get("urls")||new Map,g=a.split(" "),l=((u=g.at(1))==null?void 0:u.replace(/\(|\)/g,""))||"fetch",n=p.has(l)?l==="fetch"?"push":"fetch":l,c=g.at(0);if(!c)return null;p.set(n,c),i.set("name",s),i.set("urls",p),r.has(s)||r.set(s,i);}),r},w=()=>{var e,t,r;return ((r=(t=(e=child_process.execSync("git branch -rl '*/HEAD'"))==null?void 0:e.toString().split(`
`).filter(Boolean).at(0))==null?void 0:t.split(" -> ").at(1))==null?void 0:r.split("/"))||[null,null]},v=()=>{var t;let[e]=w();return e?S().get(e):(t=S().entries().next().value)==null?void 0:t[1]},B=()=>child_process.execSync("git stash list").toString().split(`
`).map(G).filter(Boolean),G=e=>{var a;if(!e)return null;let t=e.split(": "),r=Number(t.at(0).split("@{").pop().split("}").at(0)||"invalid");if(isNaN(r))return null;let o=(t.at(2)?t.at(1).split(" ").pop():null)||"main",s=t.at(2)||((a=t.at(1))==null?void 0:a.split(" ").pop())||null;return {index:r,branch:o,name:s}};var b=e=>B().find(t=>"name"in e?t.name===e.name:t.index===e.index),k=e=>child_process.execFileSync("git",["stash","pop","--index",e.toString()],{stdio:"inherit"});var T=e=>JSON.parse(child_process.execSync(`npm list --json${" -g"}`).toString()),P=(e,t)=>e in(T().dependencies||{});var F=()=>{let e=null;try{e=x(f());}catch(n){}let t=h(),r=t.has("--verbose"),o=t.get("--build")||"build",s=t.get("--version")||(e==null?void 0:e.version),a=t.get("--origin")||t.get("--o"),i=t.has("--npm"),p=t.get("--access")||"public",g="pre-release",l="npm run";try{l=P("pnpm",!0)?"pnpm":"npm run";}catch(n){let c=n;console.log({package:e==null?void 0:e.name,message:"Couldn't check if `pnpm` is installed. Using `npm` instead.",error:c.message});}if((!s||typeof s!="string")&&(console.error("No `version` found in `package.json`"),process.exit(1)),i)switch(p){case "public":break;case "restricted":break;default:console.error("Invalid `--access` option. `public` or `restricted` accepted."),process.exit(1);}if(!a){let n=v();a=(n==null?void 0:n.get("name"))||"origin";}try{let n=y(s);if(child_process.execSync(`git stash save -u -m "${g}"`,{stdio:"inherit"}),child_process.execSync(`${l} ${o}`,{stdio:"inherit"}),child_process.execSync(`git tag v${s}`,{stdio:"inherit"}),child_process.execSync(`git push ${a} tag v${s}`,{stdio:"inherit"}),i){let u=[`--access ${p}`,n&&`--tag ${n}`].filter(Boolean).join(" ");child_process.execSync(`npm publish ${u}`,{stdio:"inherit"});}let c=b({name:g});c&&k(c.index),r&&console.log({package:e==null?void 0:e.name,message:`Released version ${s}`,origin:a,tag:`v${s}`,npmPublish:i});}catch(n){console.error("Error during release process:",n),process.exit(1);}};exports.release=F;
`),r=new Map;return t.map(o=>{var u;let[s,a]=o.split(" ");if(!s||!a)return null;let i=r.get(s)||new Map,p=i.get("urls")||new Map,g=a.split(" "),l=((u=g.at(1))==null?void 0:u.replace(/\(|\)/g,""))||"fetch",n=p.has(l)?l==="fetch"?"push":"fetch":l,c=g.at(0);if(!c)return null;p.set(n,c),i.set("name",s),i.set("urls",p),r.has(s)||r.set(s,i);}),r},$=()=>{var e,t,r;return ((r=(t=(e=child_process.execSync("git branch -rl '*/HEAD'"))==null?void 0:e.toString().split(`
`).filter(Boolean).at(0))==null?void 0:t.split(" -> ").at(1))==null?void 0:r.split("/"))||[null,null]},v=()=>{var t;let[e]=$();return e?S().get(e):(t=S().entries().next().value)==null?void 0:t[1]},w=()=>child_process.execSync("git stash list").toString().split(`
`).map(B).filter(Boolean),B=e=>{var a;if(!e)return null;let t=e.split(": "),r=Number(t.at(0).split("@{").pop().split("}").at(0)||"invalid");if(isNaN(r))return null;let o=(t.at(2)?t.at(1).split(" ").pop():null)||"main",s=t.at(2)||((a=t.at(1))==null?void 0:a.split(" ").pop())||null;return {index:r,branch:o,name:s}};var k=e=>w().find(t=>"name"in e?t.name===e.name:t.index===e.index),P=e=>child_process.execFileSync("git",["stash","pop","--index",e.toString()],{stdio:"inherit"});var M=e=>JSON.parse(child_process.execSync(`npm list --json${" -g"}`).toString()),b=(e,t)=>e in(M().dependencies||{});var H=()=>{let e=null;try{e=x(f());}catch(n){}let t=h(),r=t.has("--verbose"),o=t.get("--build")||"build",s=t.get("--version")||(e==null?void 0:e.version),a=t.get("--origin")||t.get("--o"),i=t.has("--npm"),p=t.get("--access")||"public",g="pre-release",l="npm run";try{l=b("pnpm",!0)?"pnpm":"npm run";}catch(n){let c=n;console.log({package:e==null?void 0:e.name,message:"Couldn't check if `pnpm` is installed. Using `npm` instead.",error:c.message});}if((!s||typeof s!="string")&&(console.error("No `version` found in `package.json`"),process.exit(1)),i)switch(p){case "public":break;case "restricted":break;default:console.error("Invalid `--access` option. `public` or `restricted` accepted."),process.exit(1);}if(!a){let n=v();a=(n==null?void 0:n.get("name"))||"origin";}try{let n=y(s);if(child_process.execSync(`git stash save -u -m "${g}"`,{stdio:"inherit"}),child_process.execSync(`${l} ${o}`,{stdio:"inherit"}),child_process.execSync(`git tag v${s}`,{stdio:"inherit"}),child_process.execSync(`git push ${a} tag v${s}`,{stdio:"inherit"}),i){let u=[`--access ${p}`,n&&`--tag ${n}`].filter(Boolean).join(" ");child_process.execSync(`npm publish ${u}`,{stdio:"inherit"});}let c=k({name:g});c&&P(c.index),r&&console.log({package:e==null?void 0:e.name,message:`Released version ${s}`,origin:a,tag:`v${s}`,npmPublish:i});}catch(n){console.error("Error during release process:",n),process.exit(1);}};exports.release=H;
{
"name": "@alessiofrittoli/node-scripts",
"version": "3.0.0-alpha.1",
"version": "3.0.0-alpha.2",
"description": "Utility library with common Node.js scripts",

@@ -84,2 +84,3 @@ "author": {

"test:release": "pnpm test:watch release/*",
"test:fs": "pnpm test:watch fs.test.ts",
"test:git": "pnpm test:watch git.test.ts",

@@ -91,9 +92,9 @@ "test:npm": "pnpm test:watch npm.test.ts",

"devDependencies": {
"@eslint/js": "^9.30.1",
"@eslint/js": "^9.31.0",
"@jest/globals": "^30.0.4",
"@types/jest": "^30.0.0",
"@types/node": "^24.0.13",
"@types/node": "^24.0.14",
"concurrently": "^9.2.0",
"dotenv": "^17.2.0",
"eslint": "^9.30.1",
"eslint": "^9.31.0",
"globals": "^16.3.0",

@@ -106,4 +107,10 @@ "http-server": "^14.1.1",

"typescript": "^5.8.3",
"typescript-eslint": "^8.36.0"
"typescript-eslint": "^8.37.0"
},
"dependencies": {
"@alessiofrittoli/abort-controller": "^0.1.0",
"@alessiofrittoli/event-emitter": "^1.5.0",
"@alessiofrittoli/exception": "^3.2.0",
"@alessiofrittoli/type-utils": "^1.8.0"
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet