jiek 1.1.7-alpha.2 → 1.1.8

Sign up to get free protection for your applications and to get access to all the features.
package/dist/cli.cjs CHANGED
@@ -149,7 +149,7 @@ async function getSelectedProjectsGraph(filter = commander.program.getOptionValu
149
149
 
150
150
  var name = "jiek";
151
151
  var type = "module";
152
- var version = "1.1.7-alpha.2";
152
+ var version = "1.1.8";
153
153
  var description$1 = "YiJie's personal kits.";
154
154
  var bin = {
155
155
  jiek: "bin/jiek.js",
package/dist/cli.js CHANGED
@@ -118,7 +118,7 @@ async function getSelectedProjectsGraph(filter = program.getOptionValue("filter"
118
118
 
119
119
  var name = "jiek";
120
120
  var type = "module";
121
- var version = "1.1.7-alpha.2";
121
+ var version = "1.1.8";
122
122
  var description$1 = "YiJie's personal kits.";
123
123
  var bin = {
124
124
  jiek: "bin/jiek.js",
package/dist/cli.min.cjs CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var e=require("node:fs"),t=require("node:module"),n=require("node:path"),r=require("@pnpm/filter-workspace-packages"),o=require("commander"),a=require("js-yaml"),s=require("@jiek/utils/getWorkspaceDir"),i=require("cli-progress"),u=require("execa"),l=require("detect-indent"),p=require("inquirer"),c=require("jsonc-parser"),f=require("util"),d=require("path"),g=require("node:child_process"),h=require("@jiek/utils/bumper"),y=require("@jiek/pkger/entrypoints"),A="undefined"!=typeof document?document.currentScript:null;function R(e){return e&&e.__esModule?e:{default:e}}function m(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(n){if("default"!==n){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})}})),t.default=e,Object.freeze(t)}var _=R(e),E=R(n),b=R(l),S=R(p),C=R(f),v=R(d),$=m(g);let x,w;function H(){if(x)return x;const e=o.program.getOptionValue("root");return x=e?E.default.isAbsolute(e)?e:E.default.resolve(process.cwd(),e):void 0,x}let k=!1;function O(){if(w)return{wd:w,notWorkspace:k};const e=H();if(void 0!==e){const t=s.isWorkspaceDir(e,T);return k=!t,w=e,{wd:w,notWorkspace:k}}try{w=s.getWorkspaceDir(T)}catch(t){if(!("message"in t)||"workspace root not found"!==t.message)throw t;w=e,k=!0}return{wd:w,notWorkspace:k}}let T="";try{t.createRequire("undefined"==typeof document?require("url").pathToFileURL(__filename).href:A&&A.src||new URL("cli.min.cjs",document.baseURI).href).resolve("@pnpm/filter-workspace-packages"),T="pnpm"}catch{}async function L(e=o.program.getOptionValue("filter")){let t=H();const{wd:n,notWorkspace:s}=O();if(s)return{wd:n,root:t,value:{[n]:JSON.parse(_.default.readFileSync(E.default.resolve(n,"package.json"),"utf-8"))}};if("pnpm"===T){const o=E.default.resolve(n,"pnpm-workspace.yaml"),s=_.default.readFileSync(o,"utf-8"),i=a.load(s);if(t===n&&!e)throw new Error("root path is workspace root, please provide a filter");if(void 0===t&&(t=process.cwd()),t!==n&&!e){if(!_.default.existsSync(E.default.resolve(t,"package.json")))throw new Error("root path is not workspace root, please provide a filter");const n=JSON.parse(_.default.readFileSync(E.default.resolve(t,"package.json"),"utf-8"));if(!n.name)throw new Error("root path is not workspace root, please provide a filter");e=n.name}const{selectedProjectsGraph:u}=await r.filterPackagesFromDir(n,[{filter:e??"",followProdDepsOnly:!0}],{prefix:t,workspaceDir:n,patterns:i.packages});return{wd:n,root:t,value:Object.entries(u).reduce(((e,[t,n])=>(e[t]=n.package.manifest,e)),{})}}throw new Error(`not supported package manager ${T}`)}""!==T&&o.program.option("-f, --filter <filter>","filter packages, support fuzzy match and array. e.g. -f core,utils");var N="1.1.7-alpha.2",I="YiJie's personal kits.";let j;function M(){j()}function P(){new Promise((e=>j=e))}o.program.version(N).description(I).option("--root <root>","root path").option("-c, --config-path <configPath>","config path");const B=t.createRequire("undefined"==typeof document?require("url").pathToFileURL(__filename).href:A&&A.src||new URL("cli.min.cjs",document.baseURI).href);function D(e){try{return B.resolve(e),!0}catch(e){return!1}}let U;const G=[process.env.JIEK_TS_REGISTER,"esbuild-register","@swc-node/register","ts-node/register"].filter(Boolean);for(const e of G)if(D(e)){U=e;break}const F=t.createRequire("undefined"==typeof document?require("url").pathToFileURL(__filename).href:A&&A.src||new URL("cli.min.cjs",document.baseURI).href);let K="jiek.config";function q(e){let t,n;"object"==typeof e?(t=e.dir,n=e.root??O().wd):(t=e,n=O().wd);let r=o.program.getOptionValue("configPath");if(r){if(!_.default.existsSync(r))throw new Error(`config file not found: ${r}`);E.default.isAbsolute(r)||(r=E.default.resolve(n,r))}else r=function(e,t){const n=!!U;function r(n){const r=[E.default.resolve(process.cwd(),`${K}.${n}`),E.default.resolve(process.cwd(),`.${K}.${n}`),E.default.resolve(e,`${K}.${n}`),E.default.resolve(e,`.${K}.${n}`)];t&&r.unshift(E.default.resolve(t,`${K}.${n}`),E.default.resolve(t,`.${K}.${n}`));for(const e of r)if(_.default.existsSync(e)&&_.default.lstatSync(e).isFile())return e}return K=r("js")??K,K=r("json")??K,K=r("yaml")??K,n&&(K=r("ts")??K),E.default.resolve(e,K)}(n,t);const s=E.default.extname(r);let i;switch(s){case".js":i=F(r);break;case".json":return F(r);case".yaml":return a.load(_.default.readFileSync(r,"utf-8"));case".ts":if(U){F(U),i=F(r);break}throw new Error("ts config file is not supported without ts register, please install esbuild-register or set JIEK_TS_REGISTER env for custom ts register");case".config":i={};break;default:throw new Error(`unsupported config file type: ${s}`)}if(!i)throw new Error("config file is empty");return i.default??i}const W=t.createRequire("undefined"==typeof document?require("url").pathToFileURL(__filename).href:A&&A.src||new URL("cli.min.cjs",document.baseURI).href),Q="\nBuild the package according to the 'exports' field in the package.json.\n".trim();o.program.command("build").description(Q).option("-s, --silent","Don't display logs.").option("-e, --entries <ENTRIES>","Specify the entries of the package.json's 'exports' field.(support glob)").option("--without-js","Do not output js files.").option("--without-dts","Do not output dts files.").option("-v, --verbose","Display debug logs.").action((async({silent:e,entries:t,verbose:n,withoutJs:r,withoutDts:a})=>{P();const{build:s}=q();e=e??s?.silent??!1;const l=new i.MultiBar({clearOnComplete:!1,hideCursor:!0,format:"- {bar} | {status} | {pkgName} | {input} | {message}"},i.Presets.shades_classic),p=async({wd:o,value:s={}})=>{if(0===Object.keys(s).length)throw new Error("no package found");const i=E.default.resolve(o,"node_modules");_.default.existsSync(i)||_.default.mkdirSync(i);const p=(...e)=>E.default.resolve(i,".jiek",...e);_.default.existsSync(p())||_.default.mkdirSync(p());const c=W.resolve("rollup").replace(/dist\/rollup.js$/,"dist/bin/rollup");let f=0;await Promise.all(Object.entries(s).map((async([s,i])=>{const d=i.name?.replace(/^@/g,"").replace(/\//g,"+"),g=p(`${d??"anonymous-"+f++}.rollup.config.js`);_.default.writeFileSync(g,(e=>`\nmodule.exports = require('jiek/rollup').template(${JSON.stringify(e,null,2)})\n`.trimStart())(i));let h="";U&&(h=`node -r ${U} `);const y=`${h}${c} --silent -c ${g}`,A=u.execaCommand(y,{ipc:!0,cwd:s,env:{...process.env,JIEK_ROOT:o,JIEK_ENTRIES:t,JIEK_WITHOUT_JS:String(r),JIEK_WITHOUT_DTS:String(a)}}),R={};let m=10;A.on("message",(e=>{"debug"===e.type&&console.log(...Array.isArray(e.data)?e.data:[e.data])})),!e&&A.on("message",(e=>{if("init"===e.type){const{leafMap:t,targetsLength:n}=e.data,r=Array.from(t.entries()).flatMap((([e,t])=>t.map((([t,...n])=>({input:e,path:t,conditions:n})))));console.log(`Package '${i.name}' has ${n} targets to build`),r.forEach((({input:e})=>{m=Math.max(m,e.length)})),r.forEach((({input:e,path:t})=>{const n=`${e}:${t}`;R[n]||(R[n]=l.create(50,0,{pkgName:i.name,input:e.padEnd(m),status:"waiting".padEnd(10)},{barsize:20,linewrap:!0}))}))}if("progress"===e.type){const{path:t,tags:n,input:r,event:o,message:a}=e.data,s=R[`${r}:${t}`];if(!s)return;s.update({start:0,resolve:20,end:50}[o??"start"]??0,{input:r.padEnd(m),status:o?.padEnd(10),message:`${n?.join(", ")}: ${a}`})}})),await new Promise(((e,t)=>{let r="";A.stderr?.on("data",(e=>{r+=e})),A.once("exit",(n=>0===n?e():t(new Error(`rollup build failed:\n${r}`)))),n&&A.stdout?.pipe(process.stdout)}))})))},c=o.program.getOptionValue("filter")?.split(",");try{if(c){const e=await function(e){return Promise.all(e.map((async e=>L(e))))}(c);await Promise.all(e.map(p))}else await p(await L())}finally{l.stop()}M()}));var X,J,Z,z,V,Y,ee,te,ne,re,oe,ae,se,ie,ue,le,pe,ce,fe,de={};function ge(){return X||(X=1,(e=de).isInteger=e=>"number"==typeof e?Number.isInteger(e):"string"==typeof e&&""!==e.trim()&&Number.isInteger(Number(e)),e.find=(e,t)=>e.nodes.find((e=>e.type===t)),e.exceedsLimit=(t,n,r=1,o)=>!1!==o&&!(!e.isInteger(t)||!e.isInteger(n))&&(Number(n)-Number(t))/Number(r)>=o,e.escapeNode=(e,t=0,n)=>{let r=e.nodes[t];r&&(n&&r.type===n||"open"===r.type||"close"===r.type)&&!0!==r.escaped&&(r.value="\\"+r.value,r.escaped=!0)},e.encloseBrace=e=>!("brace"!==e.type||e.commas>>0+e.ranges||(e.invalid=!0,0)),e.isInvalidBrace=e=>!("brace"!==e.type||!0!==e.invalid&&!e.dollar&&(e.commas>>0+e.ranges&&!0===e.open&&!0===e.close||(e.invalid=!0,0))),e.isOpenOrClose=e=>"open"===e.type||"close"===e.type||!0===e.open||!0===e.close,e.reduce=e=>e.reduce(((e,t)=>("text"===t.type&&e.push(t.value),"range"===t.type&&(t.type="text"),e)),[]),e.flatten=(...e)=>{const t=[],n=e=>{for(let r=0;r<e.length;r++){let o=e[r];Array.isArray(o)?n(o):void 0!==o&&t.push(o)}return t};return n(e),t}),de;var e}function he(){if(Z)return J;Z=1;const e=ge();return J=(t,n={})=>{let r=(t,o={})=>{let a=n.escapeInvalid&&e.isInvalidBrace(o),s=!0===t.invalid&&!0===n.escapeInvalid,i="";if(t.value)return(a||s)&&e.isOpenOrClose(t)?"\\"+t.value:t.value;if(t.value)return t.value;if(t.nodes)for(let e of t.nodes)i+=r(e);return i};return r(t)}}
1
+ "use strict";var e=require("node:fs"),t=require("node:module"),n=require("node:path"),r=require("@pnpm/filter-workspace-packages"),o=require("commander"),a=require("js-yaml"),s=require("@jiek/utils/getWorkspaceDir"),i=require("cli-progress"),u=require("execa"),l=require("detect-indent"),p=require("inquirer"),c=require("jsonc-parser"),f=require("util"),d=require("path"),g=require("node:child_process"),h=require("@jiek/utils/bumper"),y=require("@jiek/pkger/entrypoints"),A="undefined"!=typeof document?document.currentScript:null;function R(e){return e&&e.__esModule?e:{default:e}}function m(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(n){if("default"!==n){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})}})),t.default=e,Object.freeze(t)}var _=R(e),E=R(n),b=R(l),S=R(p),C=R(f),v=R(d),$=m(g);let x,w;function H(){if(x)return x;const e=o.program.getOptionValue("root");return x=e?E.default.isAbsolute(e)?e:E.default.resolve(process.cwd(),e):void 0,x}let k=!1;function O(){if(w)return{wd:w,notWorkspace:k};const e=H();if(void 0!==e){const t=s.isWorkspaceDir(e,T);return k=!t,w=e,{wd:w,notWorkspace:k}}try{w=s.getWorkspaceDir(T)}catch(t){if(!("message"in t)||"workspace root not found"!==t.message)throw t;w=e,k=!0}return{wd:w,notWorkspace:k}}let T="";try{t.createRequire("undefined"==typeof document?require("url").pathToFileURL(__filename).href:A&&A.src||new URL("cli.min.cjs",document.baseURI).href).resolve("@pnpm/filter-workspace-packages"),T="pnpm"}catch{}async function L(e=o.program.getOptionValue("filter")){let t=H();const{wd:n,notWorkspace:s}=O();if(s)return{wd:n,root:t,value:{[n]:JSON.parse(_.default.readFileSync(E.default.resolve(n,"package.json"),"utf-8"))}};if("pnpm"===T){const o=E.default.resolve(n,"pnpm-workspace.yaml"),s=_.default.readFileSync(o,"utf-8"),i=a.load(s);if(t===n&&!e)throw new Error("root path is workspace root, please provide a filter");if(void 0===t&&(t=process.cwd()),t!==n&&!e){if(!_.default.existsSync(E.default.resolve(t,"package.json")))throw new Error("root path is not workspace root, please provide a filter");const n=JSON.parse(_.default.readFileSync(E.default.resolve(t,"package.json"),"utf-8"));if(!n.name)throw new Error("root path is not workspace root, please provide a filter");e=n.name}const{selectedProjectsGraph:u}=await r.filterPackagesFromDir(n,[{filter:e??"",followProdDepsOnly:!0}],{prefix:t,workspaceDir:n,patterns:i.packages});return{wd:n,root:t,value:Object.entries(u).reduce(((e,[t,n])=>(e[t]=n.package.manifest,e)),{})}}throw new Error(`not supported package manager ${T}`)}""!==T&&o.program.option("-f, --filter <filter>","filter packages, support fuzzy match and array. e.g. -f core,utils");var N="1.1.8",I="YiJie's personal kits.";let j;function M(){j()}function P(){new Promise((e=>j=e))}o.program.version(N).description(I).option("--root <root>","root path").option("-c, --config-path <configPath>","config path");const B=t.createRequire("undefined"==typeof document?require("url").pathToFileURL(__filename).href:A&&A.src||new URL("cli.min.cjs",document.baseURI).href);function D(e){try{return B.resolve(e),!0}catch(e){return!1}}let U;const G=[process.env.JIEK_TS_REGISTER,"esbuild-register","@swc-node/register","ts-node/register"].filter(Boolean);for(const e of G)if(D(e)){U=e;break}const F=t.createRequire("undefined"==typeof document?require("url").pathToFileURL(__filename).href:A&&A.src||new URL("cli.min.cjs",document.baseURI).href);let K="jiek.config";function q(e){let t,n;"object"==typeof e?(t=e.dir,n=e.root??O().wd):(t=e,n=O().wd);let r=o.program.getOptionValue("configPath");if(r){if(!_.default.existsSync(r))throw new Error(`config file not found: ${r}`);E.default.isAbsolute(r)||(r=E.default.resolve(n,r))}else r=function(e,t){const n=!!U;function r(n){const r=[E.default.resolve(process.cwd(),`${K}.${n}`),E.default.resolve(process.cwd(),`.${K}.${n}`),E.default.resolve(e,`${K}.${n}`),E.default.resolve(e,`.${K}.${n}`)];t&&r.unshift(E.default.resolve(t,`${K}.${n}`),E.default.resolve(t,`.${K}.${n}`));for(const e of r)if(_.default.existsSync(e)&&_.default.lstatSync(e).isFile())return e}return K=r("js")??K,K=r("json")??K,K=r("yaml")??K,n&&(K=r("ts")??K),E.default.resolve(e,K)}(n,t);const s=E.default.extname(r);let i;switch(s){case".js":i=F(r);break;case".json":return F(r);case".yaml":return a.load(_.default.readFileSync(r,"utf-8"));case".ts":if(U){F(U),i=F(r);break}throw new Error("ts config file is not supported without ts register, please install esbuild-register or set JIEK_TS_REGISTER env for custom ts register");case".config":i={};break;default:throw new Error(`unsupported config file type: ${s}`)}if(!i)throw new Error("config file is empty");return i.default??i}const W=t.createRequire("undefined"==typeof document?require("url").pathToFileURL(__filename).href:A&&A.src||new URL("cli.min.cjs",document.baseURI).href),Q="\nBuild the package according to the 'exports' field in the package.json.\n".trim();o.program.command("build").description(Q).option("-s, --silent","Don't display logs.").option("-e, --entries <ENTRIES>","Specify the entries of the package.json's 'exports' field.(support glob)").option("--without-js","Do not output js files.").option("--without-dts","Do not output dts files.").option("-v, --verbose","Display debug logs.").action((async({silent:e,entries:t,verbose:n,withoutJs:r,withoutDts:a})=>{P();const{build:s}=q();e=e??s?.silent??!1;const l=new i.MultiBar({clearOnComplete:!1,hideCursor:!0,format:"- {bar} | {status} | {pkgName} | {input} | {message}"},i.Presets.shades_classic),p=async({wd:o,value:s={}})=>{if(0===Object.keys(s).length)throw new Error("no package found");const i=E.default.resolve(o,"node_modules");_.default.existsSync(i)||_.default.mkdirSync(i);const p=(...e)=>E.default.resolve(i,".jiek",...e);_.default.existsSync(p())||_.default.mkdirSync(p());const c=W.resolve("rollup").replace(/dist\/rollup.js$/,"dist/bin/rollup");let f=0;await Promise.all(Object.entries(s).map((async([s,i])=>{const d=i.name?.replace(/^@/g,"").replace(/\//g,"+"),g=p(`${d??"anonymous-"+f++}.rollup.config.js`);_.default.writeFileSync(g,(e=>`\nmodule.exports = require('jiek/rollup').template(${JSON.stringify(e,null,2)})\n`.trimStart())(i));let h="";U&&(h=`node -r ${U} `);const y=`${h}${c} --silent -c ${g}`,A=u.execaCommand(y,{ipc:!0,cwd:s,env:{...process.env,JIEK_ROOT:o,JIEK_ENTRIES:t,JIEK_WITHOUT_JS:String(r),JIEK_WITHOUT_DTS:String(a)}}),R={};let m=10;A.on("message",(e=>{"debug"===e.type&&console.log(...Array.isArray(e.data)?e.data:[e.data])})),!e&&A.on("message",(e=>{if("init"===e.type){const{leafMap:t,targetsLength:n}=e.data,r=Array.from(t.entries()).flatMap((([e,t])=>t.map((([t,...n])=>({input:e,path:t,conditions:n})))));console.log(`Package '${i.name}' has ${n} targets to build`),r.forEach((({input:e})=>{m=Math.max(m,e.length)})),r.forEach((({input:e,path:t})=>{const n=`${e}:${t}`;R[n]||(R[n]=l.create(50,0,{pkgName:i.name,input:e.padEnd(m),status:"waiting".padEnd(10)},{barsize:20,linewrap:!0}))}))}if("progress"===e.type){const{path:t,tags:n,input:r,event:o,message:a}=e.data,s=R[`${r}:${t}`];if(!s)return;s.update({start:0,resolve:20,end:50}[o??"start"]??0,{input:r.padEnd(m),status:o?.padEnd(10),message:`${n?.join(", ")}: ${a}`})}})),await new Promise(((e,t)=>{let r="";A.stderr?.on("data",(e=>{r+=e})),A.once("exit",(n=>0===n?e():t(new Error(`rollup build failed:\n${r}`)))),n&&A.stdout?.pipe(process.stdout)}))})))},c=o.program.getOptionValue("filter")?.split(",");try{if(c){const e=await function(e){return Promise.all(e.map((async e=>L(e))))}(c);await Promise.all(e.map(p))}else await p(await L())}finally{l.stop()}M()}));var X,J,Z,z,V,Y,ee,te,ne,re,oe,ae,se,ie,ue,le,pe,ce,fe,de={};function ge(){return X||(X=1,(e=de).isInteger=e=>"number"==typeof e?Number.isInteger(e):"string"==typeof e&&""!==e.trim()&&Number.isInteger(Number(e)),e.find=(e,t)=>e.nodes.find((e=>e.type===t)),e.exceedsLimit=(t,n,r=1,o)=>!1!==o&&!(!e.isInteger(t)||!e.isInteger(n))&&(Number(n)-Number(t))/Number(r)>=o,e.escapeNode=(e,t=0,n)=>{let r=e.nodes[t];r&&(n&&r.type===n||"open"===r.type||"close"===r.type)&&!0!==r.escaped&&(r.value="\\"+r.value,r.escaped=!0)},e.encloseBrace=e=>!("brace"!==e.type||e.commas>>0+e.ranges||(e.invalid=!0,0)),e.isInvalidBrace=e=>!("brace"!==e.type||!0!==e.invalid&&!e.dollar&&(e.commas>>0+e.ranges&&!0===e.open&&!0===e.close||(e.invalid=!0,0))),e.isOpenOrClose=e=>"open"===e.type||"close"===e.type||!0===e.open||!0===e.close,e.reduce=e=>e.reduce(((e,t)=>("text"===t.type&&e.push(t.value),"range"===t.type&&(t.type="text"),e)),[]),e.flatten=(...e)=>{const t=[],n=e=>{for(let r=0;r<e.length;r++){let o=e[r];Array.isArray(o)?n(o):void 0!==o&&t.push(o)}return t};return n(e),t}),de;var e}function he(){if(Z)return J;Z=1;const e=ge();return J=(t,n={})=>{let r=(t,o={})=>{let a=n.escapeInvalid&&e.isInvalidBrace(o),s=!0===t.invalid&&!0===n.escapeInvalid,i="";if(t.value)return(a||s)&&e.isOpenOrClose(t)?"\\"+t.value:t.value;if(t.value)return t.value;if(t.nodes)for(let e of t.nodes)i+=r(e);return i};return r(t)}}
2
2
  /*!
3
3
  * is-number <https://github.com/jonschlinkert/is-number>
4
4
  *
package/dist/cli.min.js CHANGED
@@ -1,4 +1,4 @@
1
- import e from"node:fs";import{createRequire as t}from"node:module";import n,{resolve as r,relative as o}from"node:path";import{filterPackagesFromDir as s}from"@pnpm/filter-workspace-packages";import{program as a}from"commander";import{load as i}from"js-yaml";import{isWorkspaceDir as u,getWorkspaceDir as p}from"@jiek/utils/getWorkspaceDir";import{MultiBar as l,Presets as c}from"cli-progress";import{execaCommand as f}from"execa";import g from"detect-indent";import d from"inquirer";import{applyEdits as h,modify as A}from"jsonc-parser";import m from"util";import R from"path";import*as y from"node:child_process";import{bump as _,TAGS as E}from"@jiek/utils/bumper";import{resolveEntrypoints as b,filterLeafs as S,DEFAULT_SKIP_VALUES as C,entrypoints2Exports as v}from"@jiek/pkger/entrypoints";let $,x;function w(){if($)return $;const e=a.getOptionValue("root");return $=e?n.isAbsolute(e)?e:n.resolve(process.cwd(),e):void 0,$}let H=!1;function k(){if(x)return{wd:x,notWorkspace:H};const e=w();if(void 0!==e){const t=u(e,O);return H=!t,x=e,{wd:x,notWorkspace:H}}try{x=p(O)}catch(t){if(!("message"in t)||"workspace root not found"!==t.message)throw t;x=e,H=!0}return{wd:x,notWorkspace:H}}let O="";try{t(import.meta.url).resolve("@pnpm/filter-workspace-packages"),O="pnpm"}catch{}async function T(t=a.getOptionValue("filter")){let r=w();const{wd:o,notWorkspace:u}=k();if(u)return{wd:o,root:r,value:{[o]:JSON.parse(e.readFileSync(n.resolve(o,"package.json"),"utf-8"))}};if("pnpm"===O){const a=n.resolve(o,"pnpm-workspace.yaml"),u=e.readFileSync(a,"utf-8"),p=i(u);if(r===o&&!t)throw new Error("root path is workspace root, please provide a filter");if(void 0===r&&(r=process.cwd()),r!==o&&!t){if(!e.existsSync(n.resolve(r,"package.json")))throw new Error("root path is not workspace root, please provide a filter");const o=JSON.parse(e.readFileSync(n.resolve(r,"package.json"),"utf-8"));if(!o.name)throw new Error("root path is not workspace root, please provide a filter");t=o.name}const{selectedProjectsGraph:l}=await s(o,[{filter:t??"",followProdDepsOnly:!0}],{prefix:r,workspaceDir:o,patterns:p.packages});return{wd:o,root:r,value:Object.entries(l).reduce(((e,[t,n])=>(e[t]=n.package.manifest,e)),{})}}throw new Error(`not supported package manager ${O}`)}""!==O&&a.option("-f, --filter <filter>","filter packages, support fuzzy match and array. e.g. -f core,utils");var L="1.1.7-alpha.2",N="YiJie's personal kits.";let I;function M(){I()}function j(){new Promise((e=>I=e))}a.version(L).description(N).option("--root <root>","root path").option("-c, --config-path <configPath>","config path");const B=t(import.meta.url);function P(e){try{return B.resolve(e),!0}catch(e){return!1}}let D;const G=[process.env.JIEK_TS_REGISTER,"esbuild-register","@swc-node/register","ts-node/register"].filter(Boolean);for(const e of G)if(P(e)){D=e;break}const K=t(import.meta.url);let U="jiek.config";function F(t){let r,o;"object"==typeof t?(r=t.dir,o=t.root??k().wd):(r=t,o=k().wd);let s=a.getOptionValue("configPath");if(s){if(!e.existsSync(s))throw new Error(`config file not found: ${s}`);n.isAbsolute(s)||(s=n.resolve(o,s))}else s=function(t,r){const o=!!D;function s(o){const s=[n.resolve(process.cwd(),`${U}.${o}`),n.resolve(process.cwd(),`.${U}.${o}`),n.resolve(t,`${U}.${o}`),n.resolve(t,`.${U}.${o}`)];r&&s.unshift(n.resolve(r,`${U}.${o}`),n.resolve(r,`.${U}.${o}`));for(const t of s)if(e.existsSync(t)&&e.lstatSync(t).isFile())return t}return U=s("js")??U,U=s("json")??U,U=s("yaml")??U,o&&(U=s("ts")??U),n.resolve(t,U)}(o,r);const u=n.extname(s);let p;switch(u){case".js":p=K(s);break;case".json":return K(s);case".yaml":return i(e.readFileSync(s,"utf-8"));case".ts":if(D){K(D),p=K(s);break}throw new Error("ts config file is not supported without ts register, please install esbuild-register or set JIEK_TS_REGISTER env for custom ts register");case".config":p={};break;default:throw new Error(`unsupported config file type: ${u}`)}if(!p)throw new Error("config file is empty");return p.default??p}const Q=t(import.meta.url),W="\nBuild the package according to the 'exports' field in the package.json.\n".trim();a.command("build").description(W).option("-s, --silent","Don't display logs.").option("-e, --entries <ENTRIES>","Specify the entries of the package.json's 'exports' field.(support glob)").option("--without-js","Do not output js files.").option("--without-dts","Do not output dts files.").option("-v, --verbose","Display debug logs.").action((async({silent:t,entries:r,verbose:o,withoutJs:s,withoutDts:i})=>{j();const{build:u}=F();t=t??u?.silent??!1;const p=new l({clearOnComplete:!1,hideCursor:!0,format:"- {bar} | {status} | {pkgName} | {input} | {message}"},c.shades_classic),g=async({wd:a,value:u={}})=>{if(0===Object.keys(u).length)throw new Error("no package found");const l=n.resolve(a,"node_modules");e.existsSync(l)||e.mkdirSync(l);const c=(...e)=>n.resolve(l,".jiek",...e);e.existsSync(c())||e.mkdirSync(c());const g=Q.resolve("rollup").replace(/dist\/rollup.js$/,"dist/bin/rollup");let d=0;await Promise.all(Object.entries(u).map((async([n,u])=>{const l=u.name?.replace(/^@/g,"").replace(/\//g,"+"),h=c(`${l??"anonymous-"+d++}.rollup.config.js`);e.writeFileSync(h,(e=>`\nmodule.exports = require('jiek/rollup').template(${JSON.stringify(e,null,2)})\n`.trimStart())(u));let A="";D&&(A=`node -r ${D} `);const m=f(`${A}${g} --silent -c ${h}`,{ipc:!0,cwd:n,env:{...process.env,JIEK_ROOT:a,JIEK_ENTRIES:r,JIEK_WITHOUT_JS:String(s),JIEK_WITHOUT_DTS:String(i)}}),R={};let y=10;m.on("message",(e=>{"debug"===e.type&&console.log(...Array.isArray(e.data)?e.data:[e.data])})),!t&&m.on("message",(e=>{if("init"===e.type){const{leafMap:t,targetsLength:n}=e.data,r=Array.from(t.entries()).flatMap((([e,t])=>t.map((([t,...n])=>({input:e,path:t,conditions:n})))));console.log(`Package '${u.name}' has ${n} targets to build`),r.forEach((({input:e})=>{y=Math.max(y,e.length)})),r.forEach((({input:e,path:t})=>{const n=`${e}:${t}`;R[n]||(R[n]=p.create(50,0,{pkgName:u.name,input:e.padEnd(y),status:"waiting".padEnd(10)},{barsize:20,linewrap:!0}))}))}if("progress"===e.type){const{path:t,tags:n,input:r,event:o,message:s}=e.data,a=R[`${r}:${t}`];if(!a)return;a.update({start:0,resolve:20,end:50}[o??"start"]??0,{input:r.padEnd(y),status:o?.padEnd(10),message:`${n?.join(", ")}: ${s}`})}})),await new Promise(((e,t)=>{let n="";m.stderr?.on("data",(e=>{n+=e})),m.once("exit",(r=>0===r?e():t(new Error(`rollup build failed:\n${n}`)))),o&&m.stdout?.pipe(process.stdout)}))})))},d=a.getOptionValue("filter")?.split(",");try{if(d){const e=await function(e){return Promise.all(e.map((async e=>T(e))))}(d);await Promise.all(e.map(g))}else await g(await T())}finally{p.stop()}M()}));var X,q,J,Z,z,Y,V,ee,te,ne,re,oe,se,ae,ie,ue,pe,le,ce,fe={};function ge(){return X||(X=1,function(e){e.isInteger=e=>"number"==typeof e?Number.isInteger(e):"string"==typeof e&&""!==e.trim()&&Number.isInteger(Number(e)),e.find=(e,t)=>e.nodes.find((e=>e.type===t)),e.exceedsLimit=(t,n,r=1,o)=>!1!==o&&(!(!e.isInteger(t)||!e.isInteger(n))&&(Number(n)-Number(t))/Number(r)>=o),e.escapeNode=(e,t=0,n)=>{let r=e.nodes[t];r&&(n&&r.type===n||"open"===r.type||"close"===r.type)&&!0!==r.escaped&&(r.value="\\"+r.value,r.escaped=!0)},e.encloseBrace=e=>"brace"===e.type&&(!(e.commas>>0+e.ranges)&&(e.invalid=!0,!0)),e.isInvalidBrace=e=>"brace"===e.type&&(!(!0!==e.invalid&&!e.dollar)||(e.commas>>0+e.ranges?(!0!==e.open||!0!==e.close)&&(e.invalid=!0,!0):(e.invalid=!0,!0))),e.isOpenOrClose=e=>"open"===e.type||"close"===e.type||(!0===e.open||!0===e.close),e.reduce=e=>e.reduce(((e,t)=>("text"===t.type&&e.push(t.value),"range"===t.type&&(t.type="text"),e)),[]),e.flatten=(...e)=>{const t=[],n=e=>{for(let r=0;r<e.length;r++){let o=e[r];Array.isArray(o)?n(o):void 0!==o&&t.push(o)}return t};return n(e),t}}(fe)),fe}function de(){if(J)return q;J=1;const e=ge();return q=(t,n={})=>{let r=(t,o={})=>{let s=n.escapeInvalid&&e.isInvalidBrace(o),a=!0===t.invalid&&!0===n.escapeInvalid,i="";if(t.value)return(s||a)&&e.isOpenOrClose(t)?"\\"+t.value:t.value;if(t.value)return t.value;if(t.nodes)for(let e of t.nodes)i+=r(e);return i};return r(t)}}
1
+ import e from"node:fs";import{createRequire as t}from"node:module";import n,{resolve as r,relative as o}from"node:path";import{filterPackagesFromDir as s}from"@pnpm/filter-workspace-packages";import{program as a}from"commander";import{load as i}from"js-yaml";import{isWorkspaceDir as u,getWorkspaceDir as p}from"@jiek/utils/getWorkspaceDir";import{MultiBar as l,Presets as c}from"cli-progress";import{execaCommand as f}from"execa";import g from"detect-indent";import d from"inquirer";import{applyEdits as h,modify as A}from"jsonc-parser";import m from"util";import R from"path";import*as y from"node:child_process";import{bump as _,TAGS as E}from"@jiek/utils/bumper";import{resolveEntrypoints as b,filterLeafs as S,DEFAULT_SKIP_VALUES as C,entrypoints2Exports as v}from"@jiek/pkger/entrypoints";let $,x;function w(){if($)return $;const e=a.getOptionValue("root");return $=e?n.isAbsolute(e)?e:n.resolve(process.cwd(),e):void 0,$}let H=!1;function k(){if(x)return{wd:x,notWorkspace:H};const e=w();if(void 0!==e){const t=u(e,O);return H=!t,x=e,{wd:x,notWorkspace:H}}try{x=p(O)}catch(t){if(!("message"in t)||"workspace root not found"!==t.message)throw t;x=e,H=!0}return{wd:x,notWorkspace:H}}let O="";try{t(import.meta.url).resolve("@pnpm/filter-workspace-packages"),O="pnpm"}catch{}async function T(t=a.getOptionValue("filter")){let r=w();const{wd:o,notWorkspace:u}=k();if(u)return{wd:o,root:r,value:{[o]:JSON.parse(e.readFileSync(n.resolve(o,"package.json"),"utf-8"))}};if("pnpm"===O){const a=n.resolve(o,"pnpm-workspace.yaml"),u=e.readFileSync(a,"utf-8"),p=i(u);if(r===o&&!t)throw new Error("root path is workspace root, please provide a filter");if(void 0===r&&(r=process.cwd()),r!==o&&!t){if(!e.existsSync(n.resolve(r,"package.json")))throw new Error("root path is not workspace root, please provide a filter");const o=JSON.parse(e.readFileSync(n.resolve(r,"package.json"),"utf-8"));if(!o.name)throw new Error("root path is not workspace root, please provide a filter");t=o.name}const{selectedProjectsGraph:l}=await s(o,[{filter:t??"",followProdDepsOnly:!0}],{prefix:r,workspaceDir:o,patterns:p.packages});return{wd:o,root:r,value:Object.entries(l).reduce(((e,[t,n])=>(e[t]=n.package.manifest,e)),{})}}throw new Error(`not supported package manager ${O}`)}""!==O&&a.option("-f, --filter <filter>","filter packages, support fuzzy match and array. e.g. -f core,utils");var L="1.1.8",N="YiJie's personal kits.";let I;function M(){I()}function j(){new Promise((e=>I=e))}a.version(L).description(N).option("--root <root>","root path").option("-c, --config-path <configPath>","config path");const B=t(import.meta.url);function P(e){try{return B.resolve(e),!0}catch(e){return!1}}let D;const G=[process.env.JIEK_TS_REGISTER,"esbuild-register","@swc-node/register","ts-node/register"].filter(Boolean);for(const e of G)if(P(e)){D=e;break}const K=t(import.meta.url);let U="jiek.config";function F(t){let r,o;"object"==typeof t?(r=t.dir,o=t.root??k().wd):(r=t,o=k().wd);let s=a.getOptionValue("configPath");if(s){if(!e.existsSync(s))throw new Error(`config file not found: ${s}`);n.isAbsolute(s)||(s=n.resolve(o,s))}else s=function(t,r){const o=!!D;function s(o){const s=[n.resolve(process.cwd(),`${U}.${o}`),n.resolve(process.cwd(),`.${U}.${o}`),n.resolve(t,`${U}.${o}`),n.resolve(t,`.${U}.${o}`)];r&&s.unshift(n.resolve(r,`${U}.${o}`),n.resolve(r,`.${U}.${o}`));for(const t of s)if(e.existsSync(t)&&e.lstatSync(t).isFile())return t}return U=s("js")??U,U=s("json")??U,U=s("yaml")??U,o&&(U=s("ts")??U),n.resolve(t,U)}(o,r);const u=n.extname(s);let p;switch(u){case".js":p=K(s);break;case".json":return K(s);case".yaml":return i(e.readFileSync(s,"utf-8"));case".ts":if(D){K(D),p=K(s);break}throw new Error("ts config file is not supported without ts register, please install esbuild-register or set JIEK_TS_REGISTER env for custom ts register");case".config":p={};break;default:throw new Error(`unsupported config file type: ${u}`)}if(!p)throw new Error("config file is empty");return p.default??p}const Q=t(import.meta.url),W="\nBuild the package according to the 'exports' field in the package.json.\n".trim();a.command("build").description(W).option("-s, --silent","Don't display logs.").option("-e, --entries <ENTRIES>","Specify the entries of the package.json's 'exports' field.(support glob)").option("--without-js","Do not output js files.").option("--without-dts","Do not output dts files.").option("-v, --verbose","Display debug logs.").action((async({silent:t,entries:r,verbose:o,withoutJs:s,withoutDts:i})=>{j();const{build:u}=F();t=t??u?.silent??!1;const p=new l({clearOnComplete:!1,hideCursor:!0,format:"- {bar} | {status} | {pkgName} | {input} | {message}"},c.shades_classic),g=async({wd:a,value:u={}})=>{if(0===Object.keys(u).length)throw new Error("no package found");const l=n.resolve(a,"node_modules");e.existsSync(l)||e.mkdirSync(l);const c=(...e)=>n.resolve(l,".jiek",...e);e.existsSync(c())||e.mkdirSync(c());const g=Q.resolve("rollup").replace(/dist\/rollup.js$/,"dist/bin/rollup");let d=0;await Promise.all(Object.entries(u).map((async([n,u])=>{const l=u.name?.replace(/^@/g,"").replace(/\//g,"+"),h=c(`${l??"anonymous-"+d++}.rollup.config.js`);e.writeFileSync(h,(e=>`\nmodule.exports = require('jiek/rollup').template(${JSON.stringify(e,null,2)})\n`.trimStart())(u));let A="";D&&(A=`node -r ${D} `);const m=f(`${A}${g} --silent -c ${h}`,{ipc:!0,cwd:n,env:{...process.env,JIEK_ROOT:a,JIEK_ENTRIES:r,JIEK_WITHOUT_JS:String(s),JIEK_WITHOUT_DTS:String(i)}}),R={};let y=10;m.on("message",(e=>{"debug"===e.type&&console.log(...Array.isArray(e.data)?e.data:[e.data])})),!t&&m.on("message",(e=>{if("init"===e.type){const{leafMap:t,targetsLength:n}=e.data,r=Array.from(t.entries()).flatMap((([e,t])=>t.map((([t,...n])=>({input:e,path:t,conditions:n})))));console.log(`Package '${u.name}' has ${n} targets to build`),r.forEach((({input:e})=>{y=Math.max(y,e.length)})),r.forEach((({input:e,path:t})=>{const n=`${e}:${t}`;R[n]||(R[n]=p.create(50,0,{pkgName:u.name,input:e.padEnd(y),status:"waiting".padEnd(10)},{barsize:20,linewrap:!0}))}))}if("progress"===e.type){const{path:t,tags:n,input:r,event:o,message:s}=e.data,a=R[`${r}:${t}`];if(!a)return;a.update({start:0,resolve:20,end:50}[o??"start"]??0,{input:r.padEnd(y),status:o?.padEnd(10),message:`${n?.join(", ")}: ${s}`})}})),await new Promise(((e,t)=>{let n="";m.stderr?.on("data",(e=>{n+=e})),m.once("exit",(r=>0===r?e():t(new Error(`rollup build failed:\n${n}`)))),o&&m.stdout?.pipe(process.stdout)}))})))},d=a.getOptionValue("filter")?.split(",");try{if(d){const e=await function(e){return Promise.all(e.map((async e=>T(e))))}(d);await Promise.all(e.map(g))}else await g(await T())}finally{p.stop()}M()}));var X,q,J,Z,z,Y,V,ee,te,ne,re,oe,se,ae,ie,ue,pe,le,ce,fe={};function ge(){return X||(X=1,function(e){e.isInteger=e=>"number"==typeof e?Number.isInteger(e):"string"==typeof e&&""!==e.trim()&&Number.isInteger(Number(e)),e.find=(e,t)=>e.nodes.find((e=>e.type===t)),e.exceedsLimit=(t,n,r=1,o)=>!1!==o&&(!(!e.isInteger(t)||!e.isInteger(n))&&(Number(n)-Number(t))/Number(r)>=o),e.escapeNode=(e,t=0,n)=>{let r=e.nodes[t];r&&(n&&r.type===n||"open"===r.type||"close"===r.type)&&!0!==r.escaped&&(r.value="\\"+r.value,r.escaped=!0)},e.encloseBrace=e=>"brace"===e.type&&(!(e.commas>>0+e.ranges)&&(e.invalid=!0,!0)),e.isInvalidBrace=e=>"brace"===e.type&&(!(!0!==e.invalid&&!e.dollar)||(e.commas>>0+e.ranges?(!0!==e.open||!0!==e.close)&&(e.invalid=!0,!0):(e.invalid=!0,!0))),e.isOpenOrClose=e=>"open"===e.type||"close"===e.type||(!0===e.open||!0===e.close),e.reduce=e=>e.reduce(((e,t)=>("text"===t.type&&e.push(t.value),"range"===t.type&&(t.type="text"),e)),[]),e.flatten=(...e)=>{const t=[],n=e=>{for(let r=0;r<e.length;r++){let o=e[r];Array.isArray(o)?n(o):void 0!==o&&t.push(o)}return t};return n(e),t}}(fe)),fe}function de(){if(J)return q;J=1;const e=ge();return q=(t,n={})=>{let r=(t,o={})=>{let s=n.escapeInvalid&&e.isInvalidBrace(o),a=!0===t.invalid&&!0===n.escapeInvalid,i="";if(t.value)return(s||a)&&e.isOpenOrClose(t)?"\\"+t.value:t.value;if(t.value)return t.value;if(t.nodes)for(let e of t.nodes)i+=r(e);return i};return r(t)}}
2
2
  /*!
3
3
  * is-number <https://github.com/jonschlinkert/is-number>
4
4
  *
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "jiek",
3
3
  "type": "module",
4
- "version": "1.1.7-alpha.2",
4
+ "version": "1.1.8",
5
5
  "description": "YiJie's personal kits.",
6
6
  "bin": {
7
7
  "jiek": "bin/jiek.js",
@@ -61,8 +61,8 @@
61
61
  "rollup": "4.13.2",
62
62
  "rollup-plugin-esbuild": "^6.1.0",
63
63
  "typescript": "^5.0.0",
64
- "@jiek/utils": "^0.2.2",
65
- "@jiek/pkger": "^0.2.0"
64
+ "@jiek/pkger": "^0.2.0",
65
+ "@jiek/utils": "^0.2.2"
66
66
  },
67
67
  "optionalDependencies": {
68
68
  "@pnpm/filter-workspace-packages": "^7.2.13",