jiek 1.1.1 → 1.1.2

Sign up to get free protection for your applications and to get access to all the features.
package/dist/cli.cjs CHANGED
@@ -141,7 +141,7 @@ async function getSelectedProjectsGraph() {
141
141
 
142
142
  var name = "jiek";
143
143
  var type = "module";
144
- var version = "1.1.0";
144
+ var version = "1.1.1";
145
145
  var description$1 = "YiJie's personal kits.";
146
146
  var bin = {
147
147
  jiek: "bin/jiek.js",
@@ -391,7 +391,7 @@ commander.program.command("build").description(description).option("-s, --silent
391
391
  if (tsRegisterName) {
392
392
  prefix = `node -r ${tsRegisterName} `;
393
393
  }
394
- const command = `${prefix}${rollupBinaryPath} -c ${configFile}`;
394
+ const command = `${prefix}${rollupBinaryPath} --silent -c ${configFile}`;
395
395
  const child = execa.execaCommand(command, {
396
396
  ipc: true,
397
397
  cwd: dir,
package/dist/cli.js CHANGED
@@ -110,7 +110,7 @@ async function getSelectedProjectsGraph() {
110
110
 
111
111
  var name = "jiek";
112
112
  var type = "module";
113
- var version = "1.1.0";
113
+ var version = "1.1.1";
114
114
  var description$1 = "YiJie's personal kits.";
115
115
  var bin = {
116
116
  jiek: "bin/jiek.js",
@@ -360,7 +360,7 @@ program.command("build").description(description).option("-s, --silent", "Don't
360
360
  if (tsRegisterName) {
361
361
  prefix = `node -r ${tsRegisterName} `;
362
362
  }
363
- const command = `${prefix}${rollupBinaryPath} -c ${configFile}`;
363
+ const command = `${prefix}${rollupBinaryPath} --silent -c ${configFile}`;
364
364
  const child = execaCommand(command, {
365
365
  ipc: true,
366
366
  cwd: dir,
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 E=R(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?_.default.isAbsolute(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(){let e=o.program.getOptionValue("filter");const t=H(),{wd:n,notWorkspace:s}=O();if(!s&&"pnpm"===T){const o=_.default.resolve(n,"pnpm-workspace.yaml"),s=E.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(t!==n&&!e){if(!E.default.existsSync(_.default.resolve(t,"package.json")))throw new Error("root path is not workspace root, please provide a filter");const n=JSON.parse(E.default.readFileSync(_.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)),{})}}return{wd:n,root:t,value:{[n]:JSON.parse(E.default.readFileSync(_.default.resolve(n,"package.json"),"utf-8"))}}}""!==T&&o.program.option("-f, --filter <filter>","filter packages");var N="1.1.0",I="YiJie's personal kits.";let j;function M(){j()}function B(){new Promise((e=>j=e))}o.program.version(N).description(I).option("--root <root>","root path").option("-c, --config-path <configPath>","config path");const P=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 P.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(!E.default.existsSync(r))throw new Error(`config file not found: ${r}`);_.default.isAbsolute(r)||(r=_.default.resolve(n,r))}else r=function(e,t){const n=!!U;function r(n){const r=[_.default.resolve(process.cwd(),`${K}.${n}`),_.default.resolve(process.cwd(),`.${K}.${n}`),_.default.resolve(e,`${K}.${n}`),_.default.resolve(e,`.${K}.${n}`)];t&&r.unshift(_.default.resolve(t,`${K}.${n}`),_.default.resolve(t,`.${K}.${n}`));for(const e of r)if(E.default.existsSync(e)&&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),_.default.resolve(e,K)}(n,t);const s=_.default.extname(r);let i;switch(s){case".js":i=F(r);break;case".json":return F(r);case".yaml":return a.load(E.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 Q=t.createRequire("undefined"==typeof document?require("url").pathToFileURL(__filename).href:A&&A.src||new URL("cli.min.cjs",document.baseURI).href),W="\nBuild the package according to the 'exports' field in the package.json.\n".trim();o.program.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("-v, --verbose","Display debug logs.").action((async({silent:e,entries:t,verbose:n})=>{B();const{build:r}=q();e=e??r?.silent??!1;const{wd:o,value:a={}}=await L()??{};if(0===Object.keys(a).length)throw new Error("no package found");const s=_.default.resolve(o,"node_modules");E.default.existsSync(s)||E.default.mkdirSync(s);const l=(...e)=>_.default.resolve(s,".jiek",...e);E.default.existsSync(l())||E.default.mkdirSync(l());const p=Q.resolve("rollup").replace(/dist\/rollup.js$/,"dist/bin/rollup"),c=new i.MultiBar({clearOnComplete:!1,hideCursor:!0,format:"- {bar} | {status} | {input} | {message}"},i.Presets.shades_classic);let f=0;await Promise.all(Object.entries(a).map((async([r,a])=>{const s=a.name?.replace(/^@/g,"").replace(/\//g,"+"),i=l(`${s??"anonymous-"+f++}.rollup.config.js`);E.default.writeFileSync(i,(e=>`\nmodule.exports = require('jiek/rollup').template(${JSON.stringify(e,null,2)})\n`.trimStart())(a));let d="";U&&(d=`node -r ${U} `);const g=`${d}${p} -c ${i}`,h=u.execaCommand(g,{ipc:!0,cwd:r,env:{...process.env,JIEK_ROOT:o,JIEK_ENTRIES:t}}),y={};let A=10;h.on("message",(e=>{"debug"===e.type&&console.log(...Array.isArray(e.data)?e.data:[e.data])})),!e&&h.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 '${a.name}' has ${n} targets to build`),r.forEach((({input:e})=>{A=Math.max(A,e.length)})),r.forEach((({input:e,path:t})=>{const n=`${e}:${t}`;y[n]||(y[n]=c.create(50,0,{input:e.padEnd(A),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=y[`${r}:${t}`];if(!s)return;s.update({start:0,resolve:20,end:50}[o??"start"]??0,{input:r.padEnd(A),status:o?.padEnd(10),message:`${n?.join(", ")}: ${a}`})}})),await new Promise(((e,t)=>{let r="";h.stderr?.on("data",(e=>{r+=e})),h.once("exit",(n=>0===n?e():t(new Error(`rollup build failed:\n${r}`)))),n&&h.stdout?.pipe(process.stdout)}))}))).finally((()=>{c.stop()})),M()}));var X,Z,J,z,Y,V,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(J)return Z;J=1;const e=ge();return Z=(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 E=R(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?_.default.isAbsolute(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(){let e=o.program.getOptionValue("filter");const t=H(),{wd:n,notWorkspace:s}=O();if(!s&&"pnpm"===T){const o=_.default.resolve(n,"pnpm-workspace.yaml"),s=E.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(t!==n&&!e){if(!E.default.existsSync(_.default.resolve(t,"package.json")))throw new Error("root path is not workspace root, please provide a filter");const n=JSON.parse(E.default.readFileSync(_.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)),{})}}return{wd:n,root:t,value:{[n]:JSON.parse(E.default.readFileSync(_.default.resolve(n,"package.json"),"utf-8"))}}}""!==T&&o.program.option("-f, --filter <filter>","filter packages");var N="1.1.1",I="YiJie's personal kits.";let j;function M(){j()}function B(){new Promise((e=>j=e))}o.program.version(N).description(I).option("--root <root>","root path").option("-c, --config-path <configPath>","config path");const P=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 P.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(!E.default.existsSync(r))throw new Error(`config file not found: ${r}`);_.default.isAbsolute(r)||(r=_.default.resolve(n,r))}else r=function(e,t){const n=!!U;function r(n){const r=[_.default.resolve(process.cwd(),`${K}.${n}`),_.default.resolve(process.cwd(),`.${K}.${n}`),_.default.resolve(e,`${K}.${n}`),_.default.resolve(e,`.${K}.${n}`)];t&&r.unshift(_.default.resolve(t,`${K}.${n}`),_.default.resolve(t,`.${K}.${n}`));for(const e of r)if(E.default.existsSync(e)&&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),_.default.resolve(e,K)}(n,t);const s=_.default.extname(r);let i;switch(s){case".js":i=F(r);break;case".json":return F(r);case".yaml":return a.load(E.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 Q=t.createRequire("undefined"==typeof document?require("url").pathToFileURL(__filename).href:A&&A.src||new URL("cli.min.cjs",document.baseURI).href),W="\nBuild the package according to the 'exports' field in the package.json.\n".trim();o.program.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("-v, --verbose","Display debug logs.").action((async({silent:e,entries:t,verbose:n})=>{B();const{build:r}=q();e=e??r?.silent??!1;const{wd:o,value:a={}}=await L()??{};if(0===Object.keys(a).length)throw new Error("no package found");const s=_.default.resolve(o,"node_modules");E.default.existsSync(s)||E.default.mkdirSync(s);const l=(...e)=>_.default.resolve(s,".jiek",...e);E.default.existsSync(l())||E.default.mkdirSync(l());const p=Q.resolve("rollup").replace(/dist\/rollup.js$/,"dist/bin/rollup"),c=new i.MultiBar({clearOnComplete:!1,hideCursor:!0,format:"- {bar} | {status} | {input} | {message}"},i.Presets.shades_classic);let f=0;await Promise.all(Object.entries(a).map((async([r,a])=>{const s=a.name?.replace(/^@/g,"").replace(/\//g,"+"),i=l(`${s??"anonymous-"+f++}.rollup.config.js`);E.default.writeFileSync(i,(e=>`\nmodule.exports = require('jiek/rollup').template(${JSON.stringify(e,null,2)})\n`.trimStart())(a));let d="";U&&(d=`node -r ${U} `);const g=`${d}${p} --silent -c ${i}`,h=u.execaCommand(g,{ipc:!0,cwd:r,env:{...process.env,JIEK_ROOT:o,JIEK_ENTRIES:t}}),y={};let A=10;h.on("message",(e=>{"debug"===e.type&&console.log(...Array.isArray(e.data)?e.data:[e.data])})),!e&&h.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 '${a.name}' has ${n} targets to build`),r.forEach((({input:e})=>{A=Math.max(A,e.length)})),r.forEach((({input:e,path:t})=>{const n=`${e}:${t}`;y[n]||(y[n]=c.create(50,0,{input:e.padEnd(A),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=y[`${r}:${t}`];if(!s)return;s.update({start:0,resolve:20,end:50}[o??"start"]??0,{input:r.padEnd(A),status:o?.padEnd(10),message:`${n?.join(", ")}: ${a}`})}})),await new Promise(((e,t)=>{let r="";h.stderr?.on("data",(e=>{r+=e})),h.once("exit",(n=>0===n?e():t(new Error(`rollup build failed:\n${r}`)))),n&&h.stdout?.pipe(process.stdout)}))}))).finally((()=>{c.stop()})),M()}));var X,Z,J,z,Y,V,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(J)return Z;J=1;const e=ge();return Z=(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 R from"util";import y from"path";import*as m from"node:child_process";import{bump as _}from"@jiek/utils/bumper";import{resolveEntrypoints as E,filterLeafs as b,DEFAULT_SKIP_VALUES as S,entrypoints2Exports as C}from"@jiek/pkger/entrypoints";let v,$;function x(){if(v)return v;const e=a.getOptionValue("root");return v=e?n.isAbsolute(e)?e:n.resolve(process.cwd(),e):void 0,v}let w=!1;function H(){if($)return{wd:$,notWorkspace:w};const e=x();if(void 0!==e){const t=u(e,k);return w=!t,$=e,{wd:$,notWorkspace:w}}try{$=p(k)}catch(t){if(!("message"in t)||"workspace root not found"!==t.message)throw t;$=e,w=!0}return{wd:$,notWorkspace:w}}let k="";try{t(import.meta.url).resolve("@pnpm/filter-workspace-packages"),k="pnpm"}catch{}async function O(){let t=a.getOptionValue("filter");const r=x(),{wd:o,notWorkspace:u}=H();if(!u&&"pnpm"===k){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(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)),{})}}return{wd:o,root:r,value:{[o]:JSON.parse(e.readFileSync(n.resolve(o,"package.json"),"utf-8"))}}}""!==k&&a.option("-f, --filter <filter>","filter packages");var T="1.1.0",L="YiJie's personal kits.";let N;function I(){N()}function M(){new Promise((e=>N=e))}a.version(T).description(L).option("--root <root>","root path").option("-c, --config-path <configPath>","config path");const j=t(import.meta.url);function B(e){try{return j.resolve(e),!0}catch(e){return!1}}let P;const D=[process.env.JIEK_TS_REGISTER,"esbuild-register","@swc-node/register","ts-node/register"].filter(Boolean);for(const e of D)if(B(e)){P=e;break}const G=t(import.meta.url);let K="jiek.config";function U(t){let r,o;"object"==typeof t?(r=t.dir,o=t.root??H().wd):(r=t,o=H().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=!!P;function s(o){const s=[n.resolve(process.cwd(),`${K}.${o}`),n.resolve(process.cwd(),`.${K}.${o}`),n.resolve(t,`${K}.${o}`),n.resolve(t,`.${K}.${o}`)];r&&s.unshift(n.resolve(r,`${K}.${o}`),n.resolve(r,`.${K}.${o}`));for(const t of s)if(e.existsSync(t)&&e.lstatSync(t).isFile())return t}return K=s("js")??K,K=s("json")??K,K=s("yaml")??K,o&&(K=s("ts")??K),n.resolve(t,K)}(o,r);const u=n.extname(s);let p;switch(u){case".js":p=G(s);break;case".json":return G(s);case".yaml":return i(e.readFileSync(s,"utf-8"));case".ts":if(P){G(P),p=G(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 F=t(import.meta.url),Q="\nBuild the package according to the 'exports' field in the package.json.\n".trim();a.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("-v, --verbose","Display debug logs.").action((async({silent:t,entries:r,verbose:o})=>{M();const{build:s}=U();t=t??s?.silent??!1;const{wd:a,value:i={}}=await O()??{};if(0===Object.keys(i).length)throw new Error("no package found");const u=n.resolve(a,"node_modules");e.existsSync(u)||e.mkdirSync(u);const p=(...e)=>n.resolve(u,".jiek",...e);e.existsSync(p())||e.mkdirSync(p());const g=F.resolve("rollup").replace(/dist\/rollup.js$/,"dist/bin/rollup"),d=new l({clearOnComplete:!1,hideCursor:!0,format:"- {bar} | {status} | {input} | {message}"},c.shades_classic);let h=0;await Promise.all(Object.entries(i).map((async([n,s])=>{const i=s.name?.replace(/^@/g,"").replace(/\//g,"+"),u=p(`${i??"anonymous-"+h++}.rollup.config.js`);e.writeFileSync(u,(e=>`\nmodule.exports = require('jiek/rollup').template(${JSON.stringify(e,null,2)})\n`.trimStart())(s));let l="";P&&(l=`node -r ${P} `);const c=f(`${l}${g} -c ${u}`,{ipc:!0,cwd:n,env:{...process.env,JIEK_ROOT:a,JIEK_ENTRIES:r}}),A={};let R=10;c.on("message",(e=>{"debug"===e.type&&console.log(...Array.isArray(e.data)?e.data:[e.data])})),!t&&c.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 '${s.name}' has ${n} targets to build`),r.forEach((({input:e})=>{R=Math.max(R,e.length)})),r.forEach((({input:e,path:t})=>{const n=`${e}:${t}`;A[n]||(A[n]=d.create(50,0,{input:e.padEnd(R),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=A[`${r}:${t}`];if(!a)return;a.update({start:0,resolve:20,end:50}[o??"start"]??0,{input:r.padEnd(R),status:o?.padEnd(10),message:`${n?.join(", ")}: ${s}`})}})),await new Promise(((e,t)=>{let n="";c.stderr?.on("data",(e=>{n+=e})),c.once("exit",(r=>0===r?e():t(new Error(`rollup build failed:\n${n}`)))),o&&c.stdout?.pipe(process.stdout)}))}))).finally((()=>{d.stop()})),I()}));var W,X,q,Z,J,Y,z,V,ee,te,ne,re,oe,se,ae,ie,ue,pe,le,ce={};function fe(){return W||(W=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}}(ce)),ce}function ge(){if(q)return X;q=1;const e=fe();return X=(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 R from"util";import y from"path";import*as m from"node:child_process";import{bump as _}from"@jiek/utils/bumper";import{resolveEntrypoints as E,filterLeafs as b,DEFAULT_SKIP_VALUES as S,entrypoints2Exports as C}from"@jiek/pkger/entrypoints";let v,$;function x(){if(v)return v;const e=a.getOptionValue("root");return v=e?n.isAbsolute(e)?e:n.resolve(process.cwd(),e):void 0,v}let w=!1;function H(){if($)return{wd:$,notWorkspace:w};const e=x();if(void 0!==e){const t=u(e,k);return w=!t,$=e,{wd:$,notWorkspace:w}}try{$=p(k)}catch(t){if(!("message"in t)||"workspace root not found"!==t.message)throw t;$=e,w=!0}return{wd:$,notWorkspace:w}}let k="";try{t(import.meta.url).resolve("@pnpm/filter-workspace-packages"),k="pnpm"}catch{}async function O(){let t=a.getOptionValue("filter");const r=x(),{wd:o,notWorkspace:u}=H();if(!u&&"pnpm"===k){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(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)),{})}}return{wd:o,root:r,value:{[o]:JSON.parse(e.readFileSync(n.resolve(o,"package.json"),"utf-8"))}}}""!==k&&a.option("-f, --filter <filter>","filter packages");var T="1.1.1",L="YiJie's personal kits.";let N;function I(){N()}function M(){new Promise((e=>N=e))}a.version(T).description(L).option("--root <root>","root path").option("-c, --config-path <configPath>","config path");const j=t(import.meta.url);function B(e){try{return j.resolve(e),!0}catch(e){return!1}}let P;const D=[process.env.JIEK_TS_REGISTER,"esbuild-register","@swc-node/register","ts-node/register"].filter(Boolean);for(const e of D)if(B(e)){P=e;break}const G=t(import.meta.url);let K="jiek.config";function U(t){let r,o;"object"==typeof t?(r=t.dir,o=t.root??H().wd):(r=t,o=H().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=!!P;function s(o){const s=[n.resolve(process.cwd(),`${K}.${o}`),n.resolve(process.cwd(),`.${K}.${o}`),n.resolve(t,`${K}.${o}`),n.resolve(t,`.${K}.${o}`)];r&&s.unshift(n.resolve(r,`${K}.${o}`),n.resolve(r,`.${K}.${o}`));for(const t of s)if(e.existsSync(t)&&e.lstatSync(t).isFile())return t}return K=s("js")??K,K=s("json")??K,K=s("yaml")??K,o&&(K=s("ts")??K),n.resolve(t,K)}(o,r);const u=n.extname(s);let p;switch(u){case".js":p=G(s);break;case".json":return G(s);case".yaml":return i(e.readFileSync(s,"utf-8"));case".ts":if(P){G(P),p=G(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 F=t(import.meta.url),Q="\nBuild the package according to the 'exports' field in the package.json.\n".trim();a.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("-v, --verbose","Display debug logs.").action((async({silent:t,entries:r,verbose:o})=>{M();const{build:s}=U();t=t??s?.silent??!1;const{wd:a,value:i={}}=await O()??{};if(0===Object.keys(i).length)throw new Error("no package found");const u=n.resolve(a,"node_modules");e.existsSync(u)||e.mkdirSync(u);const p=(...e)=>n.resolve(u,".jiek",...e);e.existsSync(p())||e.mkdirSync(p());const g=F.resolve("rollup").replace(/dist\/rollup.js$/,"dist/bin/rollup"),d=new l({clearOnComplete:!1,hideCursor:!0,format:"- {bar} | {status} | {input} | {message}"},c.shades_classic);let h=0;await Promise.all(Object.entries(i).map((async([n,s])=>{const i=s.name?.replace(/^@/g,"").replace(/\//g,"+"),u=p(`${i??"anonymous-"+h++}.rollup.config.js`);e.writeFileSync(u,(e=>`\nmodule.exports = require('jiek/rollup').template(${JSON.stringify(e,null,2)})\n`.trimStart())(s));let l="";P&&(l=`node -r ${P} `);const c=f(`${l}${g} --silent -c ${u}`,{ipc:!0,cwd:n,env:{...process.env,JIEK_ROOT:a,JIEK_ENTRIES:r}}),A={};let R=10;c.on("message",(e=>{"debug"===e.type&&console.log(...Array.isArray(e.data)?e.data:[e.data])})),!t&&c.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 '${s.name}' has ${n} targets to build`),r.forEach((({input:e})=>{R=Math.max(R,e.length)})),r.forEach((({input:e,path:t})=>{const n=`${e}:${t}`;A[n]||(A[n]=d.create(50,0,{input:e.padEnd(R),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=A[`${r}:${t}`];if(!a)return;a.update({start:0,resolve:20,end:50}[o??"start"]??0,{input:r.padEnd(R),status:o?.padEnd(10),message:`${n?.join(", ")}: ${s}`})}})),await new Promise(((e,t)=>{let n="";c.stderr?.on("data",(e=>{n+=e})),c.once("exit",(r=>0===r?e():t(new Error(`rollup build failed:\n${n}`)))),o&&c.stdout?.pipe(process.stdout)}))}))).finally((()=>{d.stop()})),I()}));var W,X,q,Z,J,Y,z,V,ee,te,ne,re,oe,se,ae,ie,ue,pe,le,ce={};function fe(){return W||(W=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}}(ce)),ce}function ge(){if(q)return X;q=1;const e=fe();return X=(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.1",
4
+ "version": "1.1.2",
5
5
  "description": "YiJie's personal kits.",
6
6
  "bin": {
7
7
  "jiek": "bin/jiek.js",
@@ -90,7 +90,7 @@ program
90
90
  if (tsRegisterName) {
91
91
  prefix = `node -r ${tsRegisterName} `
92
92
  }
93
- const command = `${prefix}${rollupBinaryPath} -c ${configFile}`
93
+ const command = `${prefix}${rollupBinaryPath} --silent -c ${configFile}`
94
94
  const child = execaCommand(command, {
95
95
  ipc: true,
96
96
  cwd: dir,