@alessiofrittoli/node-scripts
Advanced tools
+1
-1
@@ -175,3 +175,3 @@ import { ErrorCode as ErrorCode$1 } from '@alessiofrittoli/exception/code'; | ||
| */ | ||
| declare const popStashByIndex: (index: number) => Buffer<ArrayBufferLike>; | ||
| declare const popStashByIndex: (index: number) => NonSharedBuffer; | ||
@@ -178,0 +178,0 @@ /** |
+1
-1
@@ -175,3 +175,3 @@ import { ErrorCode as ErrorCode$1 } from '@alessiofrittoli/exception/code'; | ||
| */ | ||
| declare const popStashByIndex: (index: number) => Buffer<ArrayBufferLike>; | ||
| declare const popStashByIndex: (index: number) => NonSharedBuffer; | ||
@@ -178,0 +178,0 @@ /** |
@@ -0,1 +1,3 @@ | ||
| import { Release } from '../types.mjs'; | ||
| /** | ||
@@ -14,4 +16,4 @@ * Executes the release process for a project. | ||
| */ | ||
| declare const release: () => void; | ||
| declare const release: (options?: Release.Options) => void; | ||
| export { release }; |
@@ -0,1 +1,3 @@ | ||
| import { Release } from '../types.js'; | ||
| /** | ||
@@ -14,4 +16,4 @@ * Executes the release process for a project. | ||
| */ | ||
| declare const release: () => void; | ||
| declare const release: (options?: Release.Options) => void; | ||
| export { release }; |
@@ -1,4 +0,4 @@ | ||
| '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},$=()=>{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; | ||
| 'use strict';var child_process=require('child_process'),T=require('fs'),O=require('path');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var T__default=/*#__PURE__*/_interopDefault(T);var O__default=/*#__PURE__*/_interopDefault(O);var k=()=>process.env.INIT_CWD||process.cwd(),P=()=>new Map(process.argv.map(e=>({value:e,isValue:!e.startsWith("-")})).map((e,t,s)=>{switch(t){case 0:return ["--executable",e.value];case 1:return ["--scriptPath",e.value];default:{let a=s[t+1];if(!e.isValue)return a!=null&&a.isValue?[e.value,a.value]:[e.value,"true"]}}}).filter(Boolean));var R=e=>JSON.parse(T__default.default.readFileSync(O__default.default.resolve(e,"package.json")).toString());var N=e=>{let t=e.match(/-(\w+)\.\d+/);return t?t[1]:null};var J=()=>{let t=child_process.execSync("git remote -v",{encoding:"buffer"}).toString().split(` | ||
| `),s=new Map;return t.map(a=>{var m;let[n,r]=a.split(" ");if(!n||!r)return null;let o=s.get(n)||new Map,c=o.get("urls")||new Map,p=r.split(" "),l=((m=p.at(1))==null?void 0:m.replace(/\(|\)/g,""))||"fetch",d=c.has(l)?l==="fetch"?"push":"fetch":l,g=p.at(0);if(!g)return null;c.set(d,g),o.set("name",n),o.set("urls",c),s.has(n)||s.set(n,o);}),s},I=()=>{var e,t,s;return ((s=(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:s.split("/"))||[null,null]},$=()=>{var t;let[e]=I();return e?J().get(e):(t=J().entries().next().value)==null?void 0:t[1]},V=()=>child_process.execSync("git stash list").toString().split(` | ||
| `).map(E).filter(Boolean),E=e=>{var r;if(!e)return null;let t=e.split(": "),s=Number(t.at(0).split("@{").pop().split("}").at(0)||"invalid");if(isNaN(s))return null;let a=(t.at(2)?t.at(1).split(" ").pop():null)||"main",n=t.at(2)||((r=t.at(1))==null?void 0:r.split(" ").pop())||null;return {index:s,branch:a,name:n}};var w=e=>V().find(t=>"name"in e?t.name===e.name:t.index===e.index),B=e=>child_process.execFileSync("git",["stash","pop","--index",e.toString()],{stdio:"inherit"});var A=e=>JSON.parse(child_process.execSync(`npm list --json${" -g"}`).toString()),G=(e,t)=>e in(A().dependencies||{});var ee=e=>{var g,m,x,y,S,v,b;let t=null;try{t=R(k());}catch(i){}let s=P(),a=(g=e==null?void 0:e.verbose)!=null?g:s.has("--verbose"),n=(m=e==null?void 0:e.build)!=null?m:s.get("--build")||"build",r=(x=e==null?void 0:e.version)!=null?x:s.get("--version")||(t==null?void 0:t.version),o=(S=e==null?void 0:e.origin)!=null?S:s.get("--origin")||s.get("--o")||((y=$())==null?void 0:y.get("name"))||"origin",c=(v=e==null?void 0:e.npm)!=null?v:s.has("--npm"),p=(b=e==null?void 0:e.access)!=null?b:s.get("--access")||"public",l="pre-release",d="npm run";try{d=G("pnpm",!0)?"pnpm":"npm run";}catch(i){let f=i;console.log({package:t==null?void 0:t.name,message:"Couldn't check if `pnpm` is installed. Using `npm` instead.",error:f.message});}if((!r||typeof r!="string")&&(console.error("No `version` found in `package.json`"),process.exit(1)),c)switch(p){case "public":break;case "restricted":break;default:console.error("Invalid `--access` option. `public` or `restricted` accepted."),process.exit(1);}try{let i=N(r);if(child_process.execSync(`git stash save -u -m "${l}"`,{stdio:"inherit"}),child_process.execSync(`${d} ${n}`,{stdio:"inherit"}),child_process.execSync(`git tag v${r}`,{stdio:"inherit"}),child_process.execSync(`git push ${o} tag v${r}`,{stdio:"inherit"}),c){let M=[`--access ${p}`,i&&`--tag ${i}`].filter(Boolean).join(" ");child_process.execSync(`npm publish ${M}`,{stdio:"inherit"});}let f=w({name:l});f&&B(f.index),a&&console.log({package:t==null?void 0:t.name,message:`Released version ${r}`,origin:o,tag:`v${r}`,npmPublish:c});}catch(i){console.error("Error during release process:",i),process.exit(1);}};exports.release=ee; |
@@ -1,4 +0,4 @@ | ||
| import {execSync,execFileSync}from'child_process';import R from'fs';import N from'path';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.readFileSync(N.resolve(e,"package.json")).toString());var y=e=>{let t=e.match(/-(\w+)\.\d+/);return t?t[1]:null};var S=()=>{let t=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},$=()=>{var e,t,r;return ((r=(t=(e=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=()=>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=>execFileSync("git",["stash","pop","--index",e.toString()],{stdio:"inherit"});var M=e=>JSON.parse(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(execSync(`git stash save -u -m "${g}"`,{stdio:"inherit"}),execSync(`${l} ${o}`,{stdio:"inherit"}),execSync(`git tag v${s}`,{stdio:"inherit"}),execSync(`git push ${a} tag v${s}`,{stdio:"inherit"}),i){let u=[`--access ${p}`,n&&`--tag ${n}`].filter(Boolean).join(" ");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);}};export{H as release}; | ||
| import {execSync,execFileSync}from'child_process';import T from'fs';import O from'path';var k=()=>process.env.INIT_CWD||process.cwd(),P=()=>new Map(process.argv.map(e=>({value:e,isValue:!e.startsWith("-")})).map((e,t,s)=>{switch(t){case 0:return ["--executable",e.value];case 1:return ["--scriptPath",e.value];default:{let a=s[t+1];if(!e.isValue)return a!=null&&a.isValue?[e.value,a.value]:[e.value,"true"]}}}).filter(Boolean));var R=e=>JSON.parse(T.readFileSync(O.resolve(e,"package.json")).toString());var N=e=>{let t=e.match(/-(\w+)\.\d+/);return t?t[1]:null};var J=()=>{let t=execSync("git remote -v",{encoding:"buffer"}).toString().split(` | ||
| `),s=new Map;return t.map(a=>{var m;let[n,r]=a.split(" ");if(!n||!r)return null;let o=s.get(n)||new Map,c=o.get("urls")||new Map,p=r.split(" "),l=((m=p.at(1))==null?void 0:m.replace(/\(|\)/g,""))||"fetch",d=c.has(l)?l==="fetch"?"push":"fetch":l,g=p.at(0);if(!g)return null;c.set(d,g),o.set("name",n),o.set("urls",c),s.has(n)||s.set(n,o);}),s},I=()=>{var e,t,s;return ((s=(t=(e=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:s.split("/"))||[null,null]},$=()=>{var t;let[e]=I();return e?J().get(e):(t=J().entries().next().value)==null?void 0:t[1]},V=()=>execSync("git stash list").toString().split(` | ||
| `).map(E).filter(Boolean),E=e=>{var r;if(!e)return null;let t=e.split(": "),s=Number(t.at(0).split("@{").pop().split("}").at(0)||"invalid");if(isNaN(s))return null;let a=(t.at(2)?t.at(1).split(" ").pop():null)||"main",n=t.at(2)||((r=t.at(1))==null?void 0:r.split(" ").pop())||null;return {index:s,branch:a,name:n}};var w=e=>V().find(t=>"name"in e?t.name===e.name:t.index===e.index),B=e=>execFileSync("git",["stash","pop","--index",e.toString()],{stdio:"inherit"});var A=e=>JSON.parse(execSync(`npm list --json${" -g"}`).toString()),G=(e,t)=>e in(A().dependencies||{});var ee=e=>{var g,m,x,y,S,v,b;let t=null;try{t=R(k());}catch(i){}let s=P(),a=(g=e==null?void 0:e.verbose)!=null?g:s.has("--verbose"),n=(m=e==null?void 0:e.build)!=null?m:s.get("--build")||"build",r=(x=e==null?void 0:e.version)!=null?x:s.get("--version")||(t==null?void 0:t.version),o=(S=e==null?void 0:e.origin)!=null?S:s.get("--origin")||s.get("--o")||((y=$())==null?void 0:y.get("name"))||"origin",c=(v=e==null?void 0:e.npm)!=null?v:s.has("--npm"),p=(b=e==null?void 0:e.access)!=null?b:s.get("--access")||"public",l="pre-release",d="npm run";try{d=G("pnpm",!0)?"pnpm":"npm run";}catch(i){let f=i;console.log({package:t==null?void 0:t.name,message:"Couldn't check if `pnpm` is installed. Using `npm` instead.",error:f.message});}if((!r||typeof r!="string")&&(console.error("No `version` found in `package.json`"),process.exit(1)),c)switch(p){case "public":break;case "restricted":break;default:console.error("Invalid `--access` option. `public` or `restricted` accepted."),process.exit(1);}try{let i=N(r);if(execSync(`git stash save -u -m "${l}"`,{stdio:"inherit"}),execSync(`${d} ${n}`,{stdio:"inherit"}),execSync(`git tag v${r}`,{stdio:"inherit"}),execSync(`git push ${o} tag v${r}`,{stdio:"inherit"}),c){let M=[`--access ${p}`,i&&`--tag ${i}`].filter(Boolean).join(" ");execSync(`npm publish ${M}`,{stdio:"inherit"});}let f=w({name:l});f&&B(f.index),a&&console.log({package:t==null?void 0:t.name,message:`Released version ${r}`,origin:o,tag:`v${r}`,npmPublish:c});}catch(i){console.error("Error during release process:",i),process.exit(1);}};export{ee as release}; |
+54
-0
@@ -26,2 +26,3 @@ /** | ||
| * Interface representing a map of release options to their values. | ||
| * | ||
| */ | ||
@@ -52,2 +53,55 @@ interface OptionsMap extends Map<Option, OptionValue<Option>> { | ||
| } | ||
| /** | ||
| * Interface representing release accepted options. | ||
| * | ||
| */ | ||
| interface Options { | ||
| /** | ||
| * The version to release. | ||
| * | ||
| * Retrieved from `--version` process option or package.json if omitted. | ||
| * | ||
| */ | ||
| version?: string; | ||
| /** | ||
| * A custom build command that will build your project before publish. | ||
| * | ||
| * Retrieved from `--build` process option or fallback to `build` if omitted. | ||
| * | ||
| * @default 'build' | ||
| */ | ||
| build?: string; | ||
| /** | ||
| * Enables detailed logging. | ||
| * | ||
| * Retrieved from `--verbose` process option or fallback to `false` if omitted. | ||
| * | ||
| * @default false | ||
| */ | ||
| verbose?: boolean; | ||
| /** | ||
| * The Git origin name used for pushing version tags. | ||
| * | ||
| * Retrieved from `--origin` or `--o` process option or fallback to `origin` if omitted. | ||
| * | ||
| * @default 'origin' | ||
| */ | ||
| origin?: string; | ||
| /** | ||
| * Indicates whether to publish the package to npm. | ||
| * | ||
| * Retrieved from `--npm` process option or fallback to `false` if omitted. | ||
| * | ||
| * @default false | ||
| */ | ||
| npm?: boolean; | ||
| /** | ||
| * Sets npm package access level. | ||
| * | ||
| * Retrieved from `--access` process option or fallback to `public` if omitted. | ||
| * | ||
| * @default 'public' | ||
| */ | ||
| access?: 'public' | 'restricted'; | ||
| } | ||
| } | ||
@@ -54,0 +108,0 @@ /** |
+54
-0
@@ -26,2 +26,3 @@ /** | ||
| * Interface representing a map of release options to their values. | ||
| * | ||
| */ | ||
@@ -52,2 +53,55 @@ interface OptionsMap extends Map<Option, OptionValue<Option>> { | ||
| } | ||
| /** | ||
| * Interface representing release accepted options. | ||
| * | ||
| */ | ||
| interface Options { | ||
| /** | ||
| * The version to release. | ||
| * | ||
| * Retrieved from `--version` process option or package.json if omitted. | ||
| * | ||
| */ | ||
| version?: string; | ||
| /** | ||
| * A custom build command that will build your project before publish. | ||
| * | ||
| * Retrieved from `--build` process option or fallback to `build` if omitted. | ||
| * | ||
| * @default 'build' | ||
| */ | ||
| build?: string; | ||
| /** | ||
| * Enables detailed logging. | ||
| * | ||
| * Retrieved from `--verbose` process option or fallback to `false` if omitted. | ||
| * | ||
| * @default false | ||
| */ | ||
| verbose?: boolean; | ||
| /** | ||
| * The Git origin name used for pushing version tags. | ||
| * | ||
| * Retrieved from `--origin` or `--o` process option or fallback to `origin` if omitted. | ||
| * | ||
| * @default 'origin' | ||
| */ | ||
| origin?: string; | ||
| /** | ||
| * Indicates whether to publish the package to npm. | ||
| * | ||
| * Retrieved from `--npm` process option or fallback to `false` if omitted. | ||
| * | ||
| * @default false | ||
| */ | ||
| npm?: boolean; | ||
| /** | ||
| * Sets npm package access level. | ||
| * | ||
| * Retrieved from `--access` process option or fallback to `public` if omitted. | ||
| * | ||
| * @default 'public' | ||
| */ | ||
| access?: 'public' | 'restricted'; | ||
| } | ||
| } | ||
@@ -54,0 +108,0 @@ /** |
+14
-14
| { | ||
| "name": "@alessiofrittoli/node-scripts", | ||
| "version": "3.1.0", | ||
| "version": "3.2.0", | ||
| "description": "Utility library with common Node.js scripts", | ||
@@ -113,18 +113,18 @@ "author": { | ||
| "devDependencies": { | ||
| "@eslint/js": "^9.31.0", | ||
| "@jest/globals": "^30.0.4", | ||
| "@eslint/js": "^9.39.1", | ||
| "@jest/globals": "^30.2.0", | ||
| "@types/jest": "^30.0.0", | ||
| "@types/node": "^24.0.15", | ||
| "concurrently": "^9.2.0", | ||
| "cross-env": "^7.0.3", | ||
| "dotenv": "^17.2.0", | ||
| "eslint": "^9.31.0", | ||
| "globals": "^16.3.0", | ||
| "@types/node": "^24.10.1", | ||
| "concurrently": "^9.2.1", | ||
| "cross-env": "^10.1.0", | ||
| "dotenv": "^17.2.3", | ||
| "eslint": "^9.39.1", | ||
| "globals": "^16.5.0", | ||
| "http-server": "^14.1.1", | ||
| "jest": "^30.0.4", | ||
| "ts-jest": "^29.4.0", | ||
| "jest": "^30.2.0", | ||
| "ts-jest": "^29.4.6", | ||
| "ts-node": "^10.9.2", | ||
| "tsup": "^8.5.0", | ||
| "typescript": "^5.8.3", | ||
| "typescript-eslint": "^8.37.0" | ||
| "tsup": "^8.5.1", | ||
| "typescript": "^5.9.3", | ||
| "typescript-eslint": "^8.48.1" | ||
| }, | ||
@@ -131,0 +131,0 @@ "dependencies": { |
+136
-77
@@ -16,3 +16,2 @@ # Node.js Scripts 🫧 | ||
| [deps-url]: https://libraries.io/npm/%40alessiofrittoli%2Fnode-scripts | ||
| [sponsor-badge]: https://img.shields.io/static/v1?label=Fund%20this%20package&message=%E2%9D%A4&logo=GitHub&color=%23DB61A2 | ||
@@ -25,24 +24,24 @@ [sponsor-url]: https://github.com/sponsors/alessiofrittoli | ||
| - [Getting started](#getting-started) | ||
| - [API Reference](#api-reference) | ||
| - [Post-Install scripts](#post-install-scripts) | ||
| - [TypeScript Type Reference Management](#typescript-type-reference-management) | ||
| - [Type Reference Interfaces](#type-reference-interfaces) | ||
| - [`CommonOptions`](#commonoptions) | ||
| - [`AddTypesReferenceOptions`](#addtypesreferenceoptions) | ||
| - [Type Reference Functions](#type-reference-functions) | ||
| - [`createReferenceFile`](#createreferencefile) | ||
| - [`updateTsConfig`](#updatetsconfig) | ||
| - [`addTypesReference`](#addtypesreference) | ||
| - [Add Types Reference Example usage](#add-types-reference-example-usage) | ||
| - [Release Scripts](#release-scripts) | ||
| - [Release](#release) | ||
| - [Development](#development) | ||
| - [Install depenendencies](#install-depenendencies) | ||
| - [Build the source code](#build-the-source-code) | ||
| - [ESLint](#eslint) | ||
| - [Jest](#jest) | ||
| - [Contributing](#contributing) | ||
| - [Security](#security) | ||
| - [Credits](#made-with-) | ||
| - [Getting started](#getting-started) | ||
| - [API Reference](#api-reference) | ||
| - [Post-Install scripts](#post-install-scripts) | ||
| - [TypeScript Type Reference Management](#typescript-type-reference-management) | ||
| - [Type Reference Interfaces](#type-reference-interfaces) | ||
| - [`CommonOptions`](#commonoptions) | ||
| - [`AddTypesReferenceOptions`](#addtypesreferenceoptions) | ||
| - [Type Reference Functions](#type-reference-functions) | ||
| - [`createReferenceFile`](#createreferencefile) | ||
| - [`updateTsConfig`](#updatetsconfig) | ||
| - [`addTypesReference`](#addtypesreference) | ||
| - [Add Types Reference Example usage](#add-types-reference-example-usage) | ||
| - [Release Scripts](#release-scripts) | ||
| - [Release](#release) | ||
| - [Development](#development) | ||
| - [Install depenendencies](#install-depenendencies) | ||
| - [Build the source code](#build-the-source-code) | ||
| - [ESLint](#eslint) | ||
| - [Jest](#jest) | ||
| - [Contributing](#contributing) | ||
| - [Security](#security) | ||
| - [Credits](#made-with-) | ||
@@ -85,7 +84,7 @@ --- | ||
| | Property | Type | Description | | ||
| |--------------|----------|-------------| | ||
| | Property | Type | Description | | ||
| | ------------ | -------- | ----------------------------------------------------------------------- | | ||
| | `root` | `string` | The root directory of the project which is installing your node module. | | ||
| | `name` | `string` | The name of your node module. | | ||
| | `outputFile` | `string` | The output file name. | | ||
| | `name` | `string` | The name of your node module. | | ||
| | `outputFile` | `string` | The output file name. | | ||
@@ -102,6 +101,6 @@ </details> | ||
| | Property | Type | Default | Description | | ||
| |--------------|----------|---------|-------------| | ||
| | `name` | `string` | - | The project name currently executing the script. | | ||
| | `outputFile` | `string` | 'alessiofrittoli-env.d.ts' | The *.d.ts output file name. | | ||
| | Property | Type | Default | Description | | ||
| | ------------ | -------- | -------------------------- | ------------------------------------------------ | | ||
| | `name` | `string` | - | The project name currently executing the script. | | ||
| | `outputFile` | `string` | 'alessiofrittoli-env.d.ts' | The \*.d.ts output file name. | | ||
@@ -122,7 +121,7 @@ </details> | ||
| | Parameter | Type | Description | | ||
| |--------------|-----------------|-------------| | ||
| | `options` | `CommonOptions` | Common options for the reference file creation. | | ||
| | Parameter | Type | Description | | ||
| | --------- | --------------- | ----------------------------------------------- | | ||
| | `options` | `CommonOptions` | Common options for the reference file creation. | | ||
| - See [CommonOptions](#commonoptions) interface. | ||
| - See [CommonOptions](#commonoptions) interface. | ||
@@ -147,7 +146,7 @@ **Returns** | ||
| | Parameter | Type | Description | | ||
| |--------------|-----------------|-------------| | ||
| | `options` | `CommonOptions` | Common options for the reference file creation. | | ||
| | Parameter | Type | Description | | ||
| | --------- | --------------- | ----------------------------------------------- | | ||
| | `options` | `CommonOptions` | Common options for the reference file creation. | | ||
| - See [CommonOptions](#commonoptions) interface. | ||
| - See [CommonOptions](#commonoptions) interface. | ||
@@ -174,7 +173,7 @@ **Returns** | ||
| | Parameter | Type | Description | | ||
| |--------------|-----------------|-------------| | ||
| | `options` | `AddTypesReferenceOptions` | The options for adding the types reference. | | ||
| | Parameter | Type | Description | | ||
| | --------- | -------------------------- | ------------------------------------------- | | ||
| | `options` | `AddTypesReferenceOptions` | The options for adding the types reference. | | ||
| - See [AddTypesReferenceOptions](#addtypesreferenceoptions) interface. | ||
| - See [AddTypesReferenceOptions](#addtypesreferenceoptions) interface. | ||
@@ -217,9 +216,11 @@ **Returns** | ||
| // path-to-my-scripts/ts-setup.js | ||
| const { addTypesReference } = require( '@alessiofrittoli/node-scripts/postinstall' ) | ||
| const project = require( '../../package.json' ) | ||
| const { | ||
| addTypesReference, | ||
| } = require("@alessiofrittoli/node-scripts/postinstall"); | ||
| const project = require("../../package.json"); | ||
| addTypesReference( { | ||
| addTypesReference({ | ||
| name: project.name, | ||
| outputFile: `${ project.name }.d.ts`, // optional | ||
| } ) | ||
| outputFile: `${project.name}.d.ts`, // optional | ||
| }); | ||
| ``` | ||
@@ -231,9 +232,11 @@ | ||
| // path-to-my-scripts/ts-setup.js | ||
| const { addTypesReference } = require( '@alessiofrittoli/node-scripts/postinstall' ) | ||
| const project = require( '../../package.json' ) | ||
| const { | ||
| addTypesReference, | ||
| } = require("@alessiofrittoli/node-scripts/postinstall"); | ||
| const project = require("../../package.json"); | ||
| addTypesReference( { | ||
| addTypesReference({ | ||
| name: project.name, | ||
| outputFile: 'my-package-scope-env.d.ts', | ||
| } ) | ||
| outputFile: "my-package-scope-env.d.ts", | ||
| }); | ||
| ``` | ||
@@ -251,14 +254,22 @@ | ||
| This function either works with process options (passed via CLI) or function arguments (function arguments takes precedence over process options). | ||
| <details> | ||
| <summary>Process Options</summary> | ||
| <summary>Arguments</summary> | ||
| | Option | Type | Default | Description | | ||
| |------------------|------------------------|-------------------------|-------------| | ||
| | `--version` | `string` | Value from package.json | The version to release. Retrieved from package.json if omitted. | | ||
| | `--build` | `string` | `build` | A custom build command that will build your project before publish. | | ||
| | `--verbose` | `boolean \| undefined` | `false` | Enables detailed logging. | | ||
| | `--origin`, `-o` | `string` | 'origin' | The Git origin for pushing tags. | | ||
| | `--npm` | `boolean \| undefined` | `false` | Indicates whether to publish the package to npm. | | ||
| | `--access` | `public \| restricted` | 'public' | Sets npm access level (public or restricted). | | ||
| | Argument | Type | Default | Description | | ||
| | --------- | -------------------- | ------------------------------------------- | ------------------------------------------------------------------------------------- | | ||
| | `version` | `string` | `--version` process option or package.json. | The version to release. | | ||
| | | | | Retrieved from `--version` process option or package.json if omitted. | | ||
| | `build` | `string` | 'build' | A custom build command that will build your project before publish. | | ||
| | | | | Retrieved from `--build` process option or fallback to `build` if omitted. | | ||
| | `verbose` | `boolean` | false | Enables detailed logging. | | ||
| | | | | Retrieved from `--verbose` process option or fallback to `false` if omitted. | | ||
| | `origin` | `string` | 'origin' | The Git origin name used for pushing version tags. | | ||
| | | | | Retrieved from `--origin` or `--o` process option or fallback to `origin` if omitted. | | ||
| | `npm` | `boolean` | false | Indicates whether to publish the package to npm. | | ||
| | | | | Retrieved from `--npm` process option or fallback to `false` if omitted. | | ||
| | `access` | `public\|restricted` | 'public' | Sets npm package access level. | | ||
| | | | | Retrieved from `--access` process option or fallback to `public` if omitted. | | ||
@@ -271,2 +282,20 @@ </details> | ||
| <summary>Process Options - CLI</summary> | ||
| | Option | Type | Default | Description | | ||
| | ---------------- | -------------------- | ----------------------- | ------------------------------------------------------------------- | | ||
| | `--version` | `string` | Value from package.json | The version to release. Retrieved from package.json if omitted. | | ||
| | | | | Retrieved from package.json if omitted. | | ||
| | `--build` | `string` | `build` | A custom build command that will build your project before publish. | | ||
| | `--verbose` | `boolean` | `false` | Enables detailed logging. | | ||
| | `--origin`, `-o` | `string` | 'origin' | The Git origin name used for pushing version tags. | | ||
| | `--npm` | `boolean` | `false` | Indicates whether to publish the package to npm. | | ||
| | `--access` | `public\|restricted` | 'public' | Sets npm package access level. | | ||
| </details> | ||
| --- | ||
| <details> | ||
| <summary>Performed steps</summary> | ||
@@ -278,5 +307,5 @@ | ||
| - Attempts to load and parse the `package.json` file. | ||
| - Exits the process with code "1" if the file is unavailable or invalid. | ||
| - Retrieve the version to use as fallback if no `--version` option has been provided. | ||
| - Attempts to load and parse the `package.json` file. | ||
| - Exits the process with code "1" if the file is unavailable or invalid. | ||
| - Retrieve the version to use as fallback if no `--version` option has been provided. | ||
@@ -287,4 +316,4 @@ </li> | ||
| - Retrieves CLI options using `getProcessOptions()`. | ||
| - Validates critical parameters such as `version` and `access`. | ||
| - Retrieves CLI options using `getProcessOptions()`. | ||
| - Validates critical parameters such as `version` and `access`. | ||
@@ -295,6 +324,6 @@ </li> | ||
| - Stashes any uncommitted changes with a stash name (`pre-release`). | ||
| - Executes the `npm run build` or `pnpm build` command (if `pnpm` is globally installed). | ||
| - Create the Git Tag as `v{version}` | ||
| - Push the Git Tag the the specified `origin` or to the default Git Repository Remote. | ||
| - Stashes any uncommitted changes with a stash name (`pre-release`). | ||
| - Executes the `npm run build` or `pnpm build` command (if `pnpm` is globally installed). | ||
| - Create the Git Tag as `v{version}` | ||
| - Push the Git Tag the the specified `origin` or to the default Git Repository Remote. | ||
@@ -305,3 +334,3 @@ </li> | ||
| - Publishes the package using `npm publish` if the `--npm` flag is set. | ||
| - Publishes the package using `npm publish` if the `--npm` flag is set. | ||
@@ -312,3 +341,3 @@ </li> | ||
| - Restores the stashed changes if any were saved during the process. | ||
| - Restores the stashed changes if any were saved during the process. | ||
@@ -319,3 +348,3 @@ </li> | ||
| - Logs details of the release process if the `--verbose` flag is set. | ||
| - Logs details of the release process if the `--verbose` flag is set. | ||
@@ -333,2 +362,4 @@ </li> | ||
| ###### Using function arguments | ||
| Add the `release` script in your `package.json` file so you can easly run from your terminal. | ||
@@ -341,2 +372,31 @@ | ||
| // ... | ||
| "release": "node path-to-my-scripts/release.js" | ||
| } | ||
| } | ||
| ``` | ||
| Then in your `release.js` file simply import the script and execute it. | ||
| ⚠️ Remember to add this file to `.npmignore` so it won't be published within you package. | ||
| ```ts | ||
| // path-to-my-scripts/release.js | ||
| require("@alessiofrittoli/node-scripts/release").release({ | ||
| verbose: true, | ||
| npm: true, | ||
| access: "restricted", | ||
| }); | ||
| ``` | ||
| --- | ||
| ###### Using CLI options | ||
| Add the `release` script in your `package.json` file so you can easly run from your terminal. | ||
| ```json | ||
| { | ||
| // ... | ||
| "scripts": { | ||
| // ... | ||
| "release": "node path-to-my-scripts/release.js --verbose --npm --access restricted" | ||
@@ -353,4 +413,3 @@ } | ||
| // path-to-my-scripts/release.js | ||
| require( '@alessiofrittoli/node-scripts/release' ) | ||
| .release() | ||
| require("@alessiofrittoli/node-scripts/release").release(); | ||
| ``` | ||
@@ -404,3 +463,3 @@ | ||
| - See [`package.json`](./package.json) file scripts for more info. | ||
| - See [`package.json`](./package.json) file scripts for more info. | ||
@@ -407,0 +466,0 @@ Run tests with coverage. |
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
85657
10.2%576
10.56%503
13.29%