@tsmodule/tsmodule 40.0.1 → 40.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commands/build/index.js +1 -1
- package/dist/commands/create/index.js +1 -1
- package/dist/commands/create/lib/copyTemplate.js +2 -2
- package/dist/commands/dev/index.js +2 -2
- package/dist/commands/index.js +3 -3
- package/dist/constants.js +1 -1
- package/dist/index.js +3 -3
- package/dist/types/index.js +3 -3
- package/package.json +1 -1
@@ -27,7 +27,7 @@ import ReactDOM from "react-dom";
|
|
27
27
|
\rTried running: ${l}.
|
28
28
|
\rError: ${u+h}`)},W0=`
|
29
29
|
typeof document>"u"&&await(async()=>{let{dirname:e}=await import("path"),{fileURLToPath:i}=await import("url");if(typeof globalThis.__filename>"u"&&(globalThis.__filename=i(import.meta.url)),typeof globalThis.__dirname>"u"&&(globalThis.__dirname=e(globalThis.__filename)),typeof globalThis.require>"u"){let{default:a}=await import("module");globalThis.require=a.createRequire(import.meta.url)}})();
|
30
|
-
`,V0=async({input:e="src/**/*",styles:t="src/components/index.css",target:r="esnext",dev:n=!1,bundle:i=!1,runtimeOnly:s
|
30
|
+
`,V0=async({input:e="src/**/*",styles:t="src/components/index.css",target:r="esnext",dev:n=!1,bundle:i=!1,runtimeOnly:s=!1,jsOnly:o=!1,noWrite:a=!1,stdin:l=void 0,stdinFile:f=void 0})=>{sc.NODE_ENV=n?"development":"production";let u=ye(V0);n&&(s=!0);let{cwd:h,srcDir:A,outDir:C}=Zs(),E=await tc(),_=JSON.parse(E),B={treeShaking:i,target:r,minify:!n,jsx:"transform",jsxFactory:"React.createElement",format:"esm",charset:"utf8",logLevel:n?"warning":"error",define:{"process.env.NODE_ENV":n?JSON.stringify("development"):JSON.stringify("production")}},b=["esbuild","*.png"],O={...B,bundle:i,absWorkingDir:h,outbase:"src",outdir:"dist",assetNames:"[name].js",format:"esm",target:"esnext",platform:_?.platform??"node",write:!a,external:i?b:void 0,banner:i?{js:W0}:void 0},k="";if(l){u.log("Building file from stdin",{stdin:l,stdinFile:f,noWrite:a}),f||(Pe(F.red("ERROR: --stdin-file must be specified to emulate a file location when using stdin.")),process.exit(1)),typeof l=="string"&&l.length?k=l:k=await oo();let c={...B,sourcefile:f,loader:"tsx",banner:void 0,footer:void 0};if(a)return(await K0(k,c)).code;{let D=ac(k,f,"tsx");await ao({...O,...D}),Pe(F.green("Successfully built stdin file to dist/.")),Pe(F.grey("Use --no-write to print to stdout instead."));return}}u.log("Building",{files:e,dev:n,runtimeOnly:s}),oc(`${F.bold("TS Module")} [${sc.NODE_ENV}]`);let G=lo.default.sync(e,{cwd:h}).filter(c=>$0(c)!==".d.ts").map(c=>sr(c));if(G0(e)){G.length||G.push(e);let c=e.replace(A,C).replace(kt,".js").replace(ct,".js");u.log("Cleaning emitted file:",{outfile:c}),await ic(c,{force:!0})}else u.log("Cleaning old output:",{outDir:C}),await ic(C,{force:!0,recursive:!0});let x=G.filter(c=>ct.test(c));u.log("Compiling TSX files:",{tsxJsxInput:x});let q=x.filter(c=>!c.endsWith(".d.ts"));await Promise.all(q.map(async c=>{let D=await uc(c,"utf-8"),M=J0+D,ae=ac(M,c,"tsx");await ao({...O,...ae})})),Ye("Built TSX files.").succeed();let w=G.filter(c=>kt.test(c)).filter(c=>!ct.test(c));u.log("Compiling TS files:",{tsJsInput:w}),await ao({...O,entryPoints:w.filter(c=>!c.endsWith(".d.ts"))}),Ye("Built TS files.").succeed();let S=G.filter(c=>!ec.test(c));u.log("Copying non-JS/TS files.",{allFiles:G,nonTsJsInput:S});for(let c of S){let D=zs(c);u.log("Copying non-source file:",{file:c,emittedFile:D}),await H0(fc(D),{recursive:!0}),await q0(c,D,F0.COPYFILE_FICLONE)}if(!process.env.NO_REWRITES){let c=e.replace(A,C).replace(/^(\.\/)?src\//,"dist/").replace(kt,".js").replace(ct,".js");u.log("Normalizing import specifiers in emitted JS.",{emittedJs:c}),await so(c.endsWith(".js")?c:`${c}.js`),Ye("Normalized import specifiers.").succeed()}if(await Y0()&&Ye('Forced "type": "module" in output.').succeed(),s)return;if(!o)if(uo(U0(t))){u.log("Building styles for production.");let{style:c="./dist/bundle.css"}=_;if(u.log("Building style bundle.",{bundleInput:t,bundleOutput:c,dev:n}),await lc(t,c,n),i){u.log("Bundling all styles.");let D=lo.default.sync("dist/**/*.css"),M=Ye("Bundling emitted styles.").start();await Promise.all(D.map(async ae=>await lc(ae,ae,n))),M.succeed(`Bundled all styles to ${F.bold(c)}.`)}}else Pe(F.grey(`Bundle styles not found for this project.
|
31
31
|
\rChecked: `+F.bold(t)));oc("Running post-build setup.");let Z=Ye("Generating type declarations.").start();await eo(),Z.succeed(`Generated delcarations for ${G.length} files.`),Pe(F.green("Build complete."))};export{oc as bannerLog,V0 as build};
|
32
32
|
/*!
|
33
33
|
* fill-range <https://github.com/jonschlinkert/fill-range>
|
@@ -14,5 +14,5 @@ $ ${s} ${l.join(" ")}
|
|
14
14
|
`)),await new Promise((a,f)=>{n=Un(s,l,i);let c="",d="";if(!n)throw new Error("Child process was not set.");let y=m=>{n=null;let S={code:m,stdout:c,stderr:d};m===0||m===1&&!wt?a(S):f(S)};n.stdout?.on("data",m=>{c+=m.toString()}),n.stderr?.on("data",m=>{d+=m.toString()}),n.on("close",y),n.on("exit",y),n.on("error",y),n.stdout?.pipe(process.stdout),n.stderr?.pipe(process.stderr)})},kill(o="SIGKILL"){if(n?.pid)if(wt)Gn(`taskkill /t /f /pid ${n.pid}`);else return process.kill(-n.pid,o);return!0}}};import ht from"node:process";import Kr from"node:process";var Yr=pe(jr(),1),Hr=pe($r(),1);import po from"node:process";var _o=(0,Yr.default)(()=>{(0,Hr.default)(()=>{po.stderr.write("\x1B[?25h")},{alwaysLast:!0})}),Vr=_o;var Ye=!1,ae={};ae.show=(e=Kr.stderr)=>{!e.isTTY||(Ye=!1,e.write("\x1B[?25h"))};ae.hide=(e=Kr.stderr)=>{!e.isTTY||(Vr(),Ye=!0,e.write("\x1B[?25l"))};ae.toggle=(e,t)=>{e!==void 0&&(Ye=e),Ye?ae.show(t):ae.hide(t)};var Ot=ae;var De=pe(Xr(),1);import q from"node:process";function me(){return q.platform!=="win32"?q.env.TERM!=="linux":Boolean(q.env.CI)||Boolean(q.env.WT_SESSION)||q.env.ConEmuTask==="{cmd::Cmder}"||q.env.TERM_PROGRAM==="vscode"||q.env.TERM==="xterm-256color"||q.env.TERM==="alacritty"||q.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var bo={info:A.blue("ℹ"),success:A.green("✔"),warning:A.yellow("⚠"),error:A.red("✖")},yo={info:A.blue("i"),success:A.green("√"),warning:A.yellow("‼"),error:A.red("×")},xo=me()?bo:yo,ve=xo;function At({onlyFirst:e=!1}={}){let t=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))"].join("|");return new RegExp(t,e?void 0:"g")}function Ct(e){if(typeof e!="string")throw new TypeError(`Expected a \`string\`, got \`${typeof e}\``);return e.replace(At(),"")}var bn=pe(li(),1);function Mt({stream:e=process.stdout}={}){return Boolean(e&&e.isTTY&&process.env.TERM!=="dumb"&&!("CI"in process.env))}var gn=pe(_n(),1);import N from"node:process";import Tl from"node:readline";var Ol=3,ut=class{#r=0;#u=new gn.BufferListStream;#n;#i;constructor(){this.#u.pipe(N.stdout);let t=this;this.#n=function(r,i,...n){let{stdin:o}=N;if(t.#r>0||o.emit===t.#n){if(r==="keypress")return;r==="data"&&i.includes(Ol)&&N.emit("SIGINT"),Reflect.apply(t.#n,this,[r,i,...n])}else Reflect.apply(N.stdin.emit,this,[r,i,...n])}}start(){this.#r++,this.#r===1&&this._realStart()}stop(){if(this.#r<=0)throw new Error("`stop` called more times than `start`");this.#r--,this.#r===0&&this._realStop()}_realStart(){N.platform!=="win32"&&(this.#i=Tl.createInterface({input:N.stdin,output:this.#u}),this.#i.on("SIGINT",()=>{N.listenerCount("SIGINT")===0?N.emit("SIGINT"):(this.#i.close(),N.kill(N.pid,"SIGINT"))}))}_realStop(){N.platform!=="win32"&&(this.#i.close(),this.#i=void 0)}};var ct,fr=class{#r=0;#u=!1;#n=0;#i=0;#e;#s;#t;#h;#c;#l;#a;#f;#d;#o;color;constructor(t){ct||(ct=new ut),typeof t=="string"&&(t={text:t}),this.#e={color:"cyan",stream:ht.stderr,discardStdin:!0,hideCursor:!0,...t},this.color=this.#e.color,this.spinner=this.#e.spinner,this.#c=this.#e.interval,this.#t=this.#e.stream,this.#l=typeof this.#e.isEnabled=="boolean"?this.#e.isEnabled:Mt({stream:this.#t}),this.#a=typeof this.#e.isSilent=="boolean"?this.#e.isSilent:!1,this.text=this.#e.text,this.prefixText=this.#e.prefixText,this.indent=this.#e.indent,ht.env.NODE_ENV==="test"&&(this._stream=this.#t,this._isEnabled=this.#l,Object.defineProperty(this,"_linesToClear",{get(){return this.#r},set(r){this.#r=r}}),Object.defineProperty(this,"_frameIndex",{get(){return this.#i}}),Object.defineProperty(this,"_lineCount",{get(){return this.#n}}))}get indent(){return this.#f}set indent(t=0){if(!(t>=0&&Number.isInteger(t)))throw new Error("The `indent` option must be an integer from 0 and up");this.#f=t,this.updateLineCount()}get interval(){return this.#c||this.#s.interval||100}get spinner(){return this.#s}set spinner(t){if(this.#i=0,this.#c=void 0,typeof t=="object"){if(t.frames===void 0)throw new Error("The given spinner must have a `frames` property");this.#s=t}else if(!me())this.#s=De.default.line;else if(t===void 0)this.#s=De.default.dots;else if(t!=="default"&&De.default[t])this.#s=De.default[t];else throw new Error(`There is no built-in spinner named '${t}'. See https://github.com/sindresorhus/cli-spinners/blob/main/spinners.json for a full list.`)}get text(){return this.#d}set text(t){this.#d=t||"",this.updateLineCount()}get prefixText(){return this.#o}set prefixText(t){this.#o=t||"",this.updateLineCount()}get isSpinning(){return this.#h!==void 0}getFullPrefixText(t=this.#o,r=" "){return typeof t=="string"&&t!==""?t+r:typeof t=="function"?t()+r:""}updateLineCount(){let t=this.#t.columns||80,r=this.getFullPrefixText(this.#o,"-");this.#n=0;for(let i of Ct(" ".repeat(this.#f)+r+"--"+this.#d).split(`
|
15
15
|
`))this.#n+=Math.max(1,Math.ceil((0,bn.default)(i)/t))}get isEnabled(){return this.#l&&!this.#a}set isEnabled(t){if(typeof t!="boolean")throw new TypeError("The `isEnabled` option must be a boolean");this.#l=t}get isSilent(){return this.#a}set isSilent(t){if(typeof t!="boolean")throw new TypeError("The `isSilent` option must be a boolean");this.#a=t}frame(){let{frames:t}=this.#s,r=t[this.#i];this.color&&(r=A[this.color](r)),this.#i=++this.#i%t.length;let i=typeof this.#o=="string"&&this.#o!==""?this.#o+" ":"",n=typeof this.text=="string"?" "+this.text:"";return i+r+n}clear(){if(!this.#l||!this.#t.isTTY)return this;this.#t.cursorTo(0);for(let t=0;t<this.#r;t++)t>0&&this.#t.moveCursor(0,-1),this.#t.clearLine(1);return(this.#f||this.lastIndent!==this.#f)&&this.#t.cursorTo(this.#f),this.lastIndent=this.#f,this.#r=0,this}render(){return this.#a?this:(this.clear(),this.#t.write(this.frame()),this.#r=this.#n,this)}start(t){return t&&(this.text=t),this.#a?this:this.#l?this.isSpinning?this:(this.#e.hideCursor&&Ot.hide(this.#t),this.#e.discardStdin&&ht.stdin.isTTY&&(this.#u=!0,ct.start()),this.render(),this.#h=setInterval(this.render.bind(this),this.interval),this):(this.text&&this.#t.write(`- ${this.text}
|
16
16
|
`),this)}stop(){return this.#l?(clearInterval(this.#h),this.#h=void 0,this.#i=0,this.clear(),this.#e.hideCursor&&Ot.show(this.#t),this.#e.discardStdin&&ht.stdin.isTTY&&this.#u&&(ct.stop(),this.#u=!1),this):this}succeed(t){return this.stopAndPersist({symbol:ve.success,text:t})}fail(t){return this.stopAndPersist({symbol:ve.error,text:t})}warn(t){return this.stopAndPersist({symbol:ve.warning,text:t})}info(t){return this.stopAndPersist({symbol:ve.info,text:t})}stopAndPersist(t={}){if(this.#a)return this;let r=t.prefixText||this.#o,i=t.text||this.text,n=typeof i=="string"?" "+i:"";return this.stop(),this.#t.write(`${this.getFullPrefixText(r," ")}${t.symbol||" "}${n}
|
17
|
-
`),this}};function ur(e){return new fr(e)}import{dirname as Al,resolve as Cl}from"path";import{fileURLToPath as Bl}from"url";var hr={default:[],react:["
|
17
|
+
`),this}};function ur(e){return new fr(e)}import{dirname as Al,resolve as Cl}from"path";import{fileURLToPath as Bl}from"url";var hr={default:[],react:["react@^17.0.2","react-dom@^17.0.2"]},cr={default:["@types/node","@tsmodule/tsmodule","@typescript-eslint/eslint-plugin","@typescript-eslint/parser","ava","eslint","typescript"],react:["next","@types/react@^17.0.39","@types/react-dom@^17.0.11","@tsmodule/react","eslint","eslint-config-next","tailwindcss","autoprefixer","cssnano","postcss","postcss-import"]},yn=Cl(Al(Bl(import.meta.url)),"..");import{mkdir as Ml}from"fs/promises";import{resolve as xn}from"path";var dr=async(e,t)=>{let r=je(),i=xn(yn,`./templates/${e}`),n=xn(t);await Ml(n,{recursive:!0}),await r.run({posix:`cp -rf ${i}/. ${n}`,win32:`xcopy /E /I /Q /Y ${i}\\ ${n}\\`})};import mn from"fs/promises";import{resolve as Il}from"path";var vn=async e=>{let t=Il(process.cwd(),e,"package.json"),r=await mn.readFile(t,"utf-8"),i=JSON.parse(r);i.name=e,await mn.writeFile(t,JSON.stringify(i,null,2))};globalThis.SHELL_OPTIONS={stdio:["ignore","ignore","inherit"]};var yf=async(e,{react:t=!1})=>{let r=je(),i=ur(`Creating new module ${A.blueBright(e)}.`).start();await dr("default",e),t&&await dr("react",e),await vn(e),i.succeed("Project created."),process.chdir(e);let n=[...hr.default],o=[...cr.default];t&&(n.push(...hr.react),o.push(...cr.react)),n.length&&await r.run(`yarn add ${n.join(" ")}`),o.length&&await r.run(`yarn add -D ${o.join(" ")}`),i.succeed("Dependencies installed."),await r.run("git init"),i.succeed("Set up as Git repository.")};export{yf as create};
|
18
18
|
/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
@@ -5,6 +5,6 @@ import{dirname as Y,resolve as F}from"path";import{fileURLToPath as U}from"url";
|
|
5
5
|
`:`
|
6
6
|
`)+t,l=o+1,o=r.indexOf(`
|
7
7
|
`,l)}while(o!==-1);return i+=r.slice(l),i}var{stdout:k,stderr:S}=X,x=Symbol("GENERATOR"),b=Symbol("STYLER"),v=Symbol("IS_EMPTY"),N=["ansi","ansi","ansi256","ansi16m"],T=Object.create(null),re=(r,e={})=>{if(e.level&&!(Number.isInteger(e.level)&&e.level>=0&&e.level<=3))throw new Error("The `level` option should be an integer from 0 to 3");let t=k?k.level:0;r.level=e.level===void 0?t:e.level},te=r=>{let e=(...t)=>t.join(" ");return re(e,r),Object.setPrototypeOf(e,O.prototype),e};function O(r){return te(r)}Object.setPrototypeOf(O.prototype,Function.prototype);for(let[r,e]of Object.entries(m))T[r]={get(){let t=R(this,B(e.open,e.close,this[b]),this[v]);return Object.defineProperty(this,r,{value:t}),t}};T.visible={get(){let r=R(this,this[b],!0);return Object.defineProperty(this,"visible",{value:r}),r}};var w=(r,e,t,...o)=>r==="rgb"?e==="ansi16m"?m[t].ansi16m(...o):e==="ansi256"?m[t].ansi256(m.rgbToAnsi256(...o)):m[t].ansi(m.rgbToAnsi(...o)):r==="hex"?w("rgb",e,t,...m.hexToRgb(...o)):m[t][r](...o),oe=["rgb","hex","ansi256"];for(let r of oe){T[r]={get(){let{level:t}=this;return function(...o){let l=B(w(r,N[t],"color",...o),m.color.close,this[b]);return R(this,l,this[v])}}};let e="bg"+r[0].toUpperCase()+r.slice(1);T[e]={get(){let{level:t}=this;return function(...o){let l=B(w(r,N[t],"bgColor",...o),m.bgColor.close,this[b]);return R(this,l,this[v])}}}}var le=Object.defineProperties(()=>{},{...T,level:{enumerable:!0,get(){return this[x].level},set(r){this[x].level=r}}}),B=(r,e,t)=>{let o,l;return t===void 0?(o=r,l=e):(o=t.openAll+r,l=e+t.closeAll),{open:r,close:e,openAll:o,closeAll:l,parent:t}},R=(r,e,t)=>{let o=(...l)=>ie(o,l.length===1?""+l[0]:l.join(" "));return Object.setPrototypeOf(o,le),o[x]=r,o[b]=e,o[v]=t,o},ie=(r,e)=>{if(r.level<=0||!e)return r[v]?"":e;let t=r[b];if(t===void 0)return e;let{openAll:o,closeAll:l}=t;if(e.includes("\x1B"))for(;t!==void 0;)e=Z(e,t.close,t.open),t=t.parent;let i=e.indexOf(`
|
8
|
-
`);return i!==-1&&(e=ee(e,l,o,i)),o+e+l};Object.defineProperties(O.prototype,T);var ne=O(),Re=O({level:S?S.level:0}),se=ne,ae={win32:r=>({cmd:"cmd.exe",args:["/d","/s","/c",r]})},ce={"cp -rf":{win32:r=>{let e="xcopy /E /S /G /Q /Y",t=r.map(o=>o.endsWith("\\")?o:`${o}\\`).map(o=>o.replace(/\*\\$/,""));return`${e} ${t.join(" ")}`}},ln:{win32:r=>`mklink /D ${r.join(" ")}`},pkill:{win32:r=>`taskkill /T /F /pid ${r.join(" ")}`}},ue=(r,e,t)=>{let o={...ae,...e},l={...ce,...t},i=a=>{let u=process.platform,p=o[u];if(p)return p(a);let[g,...
|
8
|
+
`);return i!==-1&&(e=ee(e,l,o,i)),o+e+l};Object.defineProperties(O.prototype,T);var ne=O(),Re=O({level:S?S.level:0}),se=ne,ae={win32:r=>({cmd:"cmd.exe",args:["/d","/s","/c",r]})},ce={"cp -rf":{win32:r=>{let e="xcopy /E /S /G /Q /Y",t=r.map(o=>o.endsWith("\\")?o:`${o}\\`).map(o=>o.replace(/\*\\$/,""));return`${e} ${t.join(" ")}`}},ln:{win32:r=>`mklink /D ${r.join(" ")}`},pkill:{win32:r=>`taskkill /T /F /pid ${r.join(" ")}`}},ue=(r,e,t)=>{let o={...ae,...e},l={...ce,...t},i=a=>{let u=process.platform,p=o[u];if(p)return p(a);let[g,...d]=a.split(" ");return{cmd:g,args:d}},n=(a=>{let u=Object.entries(l);for(let[p,g]of u)if(a.startsWith(p)){let d=process.platform,h=g[d];if(!h)break;let f=a.slice(p.length).trim().split(" ");return h(f)}return a})(r);return i(n)},pe=process.platform==="linux"||process.platform==="darwin",C=process.platform==="win32",me={stdio:"pipe",shell:!0,detached:!C,env:process.env},fe={log:!0,commandTranslations:{},shellTranslations:{},...me},L=({log:r=!0,commandTranslations:e={},shellTranslations:t={},...o}=fe)=>{let l=null;return{childProcess:l,async run(i){if(l)throw new Error("Only one command per shell.");if(typeof i=="object"){let u=process.platform;i.posix&&pe&&(u="posix");let p=i[u];if(!p)throw new Error("No command found for platform: "+JSON.stringify({platform:process.platform,command:i}));i=p}let{cmd:n,args:a}=ue(i,t,e);return r&&console.log(se.dim(`
|
9
9
|
$ ${n} ${a.join(" ")}
|
10
|
-
`)),await new Promise((u,p)=>{l=D(n,a,o);let g="",
|
10
|
+
`)),await new Promise((u,p)=>{l=D(n,a,o);let g="",d="";if(!l)throw new Error("Child process was not set.");let h=f=>{l=null;let A={code:f,stdout:g,stderr:d};f===0||f===1&&!C?u(A):p(A)};l.stdout?.on("data",f=>{g+=f.toString()}),l.stderr?.on("data",f=>{d+=f.toString()}),l.on("close",h),l.on("exit",h),l.on("error",h),l.stdout?.pipe(process.stdout),l.stderr?.pipe(process.stderr)})},kill(i="SIGKILL"){if(l?.pid)if(C)V(`taskkill /t /f /pid ${l.pid}`);else return process.kill(-l.pid,i);return!0}}};import{mkdir as ge}from"fs/promises";import{resolve as G}from"path";var Ae=async(r,e)=>{let t=L(),o=G(M,`./templates/${r}`),l=G(e);await ge(l,{recursive:!0}),await t.run({posix:`cp -rf ${o}/. ${l}`,win32:`xcopy /E /I /Q /Y ${o}\\ ${l}\\`})};export{Ae as copyTemplate};
|
@@ -27,10 +27,10 @@ import ReactDOM from "react-dom";
|
|
27
27
|
\rTried running: ${u}.
|
28
28
|
\rError: ${l+h}`)},JE=`
|
29
29
|
typeof document>"u"&&await(async()=>{let{dirname:e}=await import("path"),{fileURLToPath:i}=await import("url");if(typeof globalThis.__filename>"u"&&(globalThis.__filename=i(import.meta.url)),typeof globalThis.__dirname>"u"&&(globalThis.__dirname=e(globalThis.__filename)),typeof globalThis.require>"u"){let{default:a}=await import("module");globalThis.require=a.createRequire(import.meta.url)}})();
|
30
|
-
`,xn=async({input:e="src/**/*",styles:t="src/components/index.css",target:r="esnext",dev:n=!1,bundle:i=!1,runtimeOnly:s
|
30
|
+
`,xn=async({input:e="src/**/*",styles:t="src/components/index.css",target:r="esnext",dev:n=!1,bundle:i=!1,runtimeOnly:s=!1,jsOnly:o=!1,noWrite:a=!1,stdin:u=void 0,stdinFile:f=void 0})=>{qc.NODE_ENV=n?"development":"production";let l=me(xn);n&&(s=!0);let{cwd:h,srcDir:A,outDir:C}=go(),E=await Pc(),_=JSON.parse(E),v={treeShaking:i,target:r,minify:!n,jsx:"transform",jsxFactory:"React.createElement",format:"esm",charset:"utf8",logLevel:n?"warning":"error",define:{"process.env.NODE_ENV":n?JSON.stringify("development"):JSON.stringify("production")}},b=["esbuild","*.png"],O={...v,bundle:i,absWorkingDir:h,outbase:"src",outdir:"dist",assetNames:"[name].js",format:"esm",target:"esnext",platform:_?.platform??"node",write:!a,external:i?b:void 0,banner:i?{js:JE}:void 0},P="";if(u){l.log("Building file from stdin",{stdin:u,stdinFile:f,noWrite:a}),f||(ye(k.red("ERROR: --stdin-file must be specified to emulate a file location when using stdin.")),process.exit(1)),typeof u=="string"&&u.length?P=u:P=await So();let c={...v,sourcefile:f,loader:"tsx",banner:void 0,footer:void 0};if(a)return(await GE(P,c)).code;{let D=jc(P,f,"tsx");await Bo({...O,...D}),ye(k.green("Successfully built stdin file to dist/.")),ye(k.grey("Use --no-write to print to stdout instead."));return}}l.log("Building",{files:e,dev:n,runtimeOnly:s}),Hc(`${k.bold("TS Module")} [${qc.NODE_ENV}]`);let U=xo.default.sync(e,{cwd:h}).filter(c=>HE(c)!==".d.ts").map(c=>cr(c));if(jE(e)){U.length||U.push(e);let c=e.replace(A,C).replace(Mt,".js").replace(ht,".js");l.log("Cleaning emitted file:",{outfile:c}),await Fc(c,{force:!0})}else l.log("Cleaning old output:",{outDir:C}),await Fc(C,{force:!0,recursive:!0});let x=U.filter(c=>ht.test(c));l.log("Compiling TSX files:",{tsxJsxInput:x});let H=x.filter(c=>!c.endsWith(".d.ts"));await Promise.all(H.map(async c=>{let D=await Gc(c,"utf-8"),F=UE+D,ue=jc(F,c,"tsx");await Bo({...O,...ue})})),Re("Built TSX files.").succeed();let R=U.filter(c=>Mt.test(c)).filter(c=>!ht.test(c));l.log("Compiling TS files:",{tsJsInput:R}),await Bo({...O,entryPoints:R.filter(c=>!c.endsWith(".d.ts"))}),Re("Built TS files.").succeed();let S=U.filter(c=>!Lc.test(c));l.log("Copying non-JS/TS files.",{allFiles:U,nonTsJsInput:S});for(let c of S){let D=_o(c);l.log("Copying non-source file:",{file:c,emittedFile:D}),await FE(Uc(D),{recursive:!0}),await ME(c,D,NE.COPYFILE_FICLONE)}if(!process.env.NO_REWRITES){let c=e.replace(A,C).replace(/^(\.\/)?src\//,"dist/").replace(Mt,".js").replace(ht,".js");l.log("Normalizing import specifiers in emitted JS.",{emittedJs:c}),await vo(c.endsWith(".js")?c:`${c}.js`),Re("Normalized import specifiers.").succeed()}if(await KE()&&Re('Forced "type": "module" in output.').succeed(),s)return;if(!o)if(wo($E(t))){l.log("Building styles for production.");let{style:c="./dist/bundle.css"}=_;if(l.log("Building style bundle.",{bundleInput:t,bundleOutput:c,dev:n}),await $c(t,c,n),i){l.log("Bundling all styles.");let D=xo.default.sync("dist/**/*.css"),F=Re("Bundling emitted styles.").start();await Promise.all(D.map(async ue=>await $c(ue,ue,n))),F.succeed(`Bundled all styles to ${k.bold(c)}.`)}}else ye(k.grey(`Bundle styles not found for this project.
|
31
31
|
\rChecked: `+k.bold(t)));Hc("Running post-build setup.");let z=Re("Generating type declarations.").start();await Eo(),z.succeed(`Generated delcarations for ${U.length} files.`),ye(k.green("Build complete."))};var Kc=()=>{console.clear()},Jc=e=>{ye(`
|
32
32
|
`,k.gray(`Built ${k.bold(e)}.`),`
|
33
|
-
`,k.blue(new Date().toLocaleString()))},ev=async()=>{let e=process.cwd(),t=Et();process.platform!=="win32"&&await t.run("clear"),Kc(),await xn({dev:!0}),Jc("src/**/*"),(0,Yc.default)(WE(e,"src"),{recursive:!0}).on("change",async(r,n)=>{if(!VE(n)||(await XE(n)).isDirectory())return;Kc();let a=Date.now();await xn({dev:!0,input:n});let u=Date.now()-a;Re(k.blueBright(`Dev refresh finished in ${k.bold(`${u}ms`)}.`)).succeed(),Jc(YE(e,n))})};export{ev as dev};
|
33
|
+
`,k.blue(new Date().toLocaleString()))},ev=async()=>{let e=process.cwd(),t=Et();process.platform!=="win32"&&await t.run("clear"),Kc(),await xn({dev:!0}),Jc("src/**/*"),(0,Yc.default)(WE(e,"src"),{recursive:!0}).on("change",async(r,n)=>{if(!VE(n)||(await XE(n)).isDirectory())return;Kc();let a=Date.now();await xn({dev:!0,runtimeOnly:!0,input:n});let u=Date.now()-a;Re(k.blueBright(`Dev refresh finished in ${k.bold(`${u}ms`)}.`)).succeed(),Jc(YE(e,n))})};export{ev as dev};
|
34
34
|
/*!
|
35
35
|
* fill-range <https://github.com/jonschlinkert/fill-range>
|
36
36
|
*
|
package/dist/commands/index.js
CHANGED
@@ -27,10 +27,10 @@ import ReactDOM from "react-dom";
|
|
27
27
|
\rTried running: ${l}.
|
28
28
|
\rError: ${u+h}`)},qE=`
|
29
29
|
typeof document>"u"&&await(async()=>{let{dirname:e}=await import("path"),{fileURLToPath:i}=await import("url");if(typeof globalThis.__filename>"u"&&(globalThis.__filename=i(import.meta.url)),typeof globalThis.__dirname>"u"&&(globalThis.__dirname=e(globalThis.__filename)),typeof globalThis.require>"u"){let{default:a}=await import("module");globalThis.require=a.createRequire(import.meta.url)}})();
|
30
|
-
`,vn=async({input:e="src/**/*",styles:t="src/components/index.css",target:r="esnext",dev:n=!1,bundle:i=!1,runtimeOnly:s
|
31
|
-
\rChecked: `+T.bold(t)));wc("Running post-build setup.");let z=_e("Generating type declarations.").start();await fo(),z.succeed(`Generated delcarations for ${U.length} files.`),Se(T.green("Build complete."))};import{dirname as HE,resolve as jE}from"path";import{fileURLToPath as $E}from"url";var Co={default:[],react:["
|
30
|
+
`,vn=async({input:e="src/**/*",styles:t="src/components/index.css",target:r="esnext",dev:n=!1,bundle:i=!1,runtimeOnly:s=!1,jsOnly:o=!1,noWrite:a=!1,stdin:l=void 0,stdinFile:f=void 0})=>{Bc.NODE_ENV=n?"development":"production";let u=ve(vn);n&&(s=!0);let{cwd:h,srcDir:A,outDir:C}=lo(),E=await bc(),_=JSON.parse(E),v={treeShaking:i,target:r,minify:!n,jsx:"transform",jsxFactory:"React.createElement",format:"esm",charset:"utf8",logLevel:n?"warning":"error",define:{"process.env.NODE_ENV":n?JSON.stringify("development"):JSON.stringify("production")}},b=["esbuild","*.png"],D={...v,bundle:i,absWorkingDir:h,outbase:"src",outdir:"dist",assetNames:"[name].js",format:"esm",target:"esnext",platform:_?.platform??"node",write:!a,external:i?b:void 0,banner:i?{js:qE}:void 0},P="";if(l){u.log("Building file from stdin",{stdin:l,stdinFile:f,noWrite:a}),f||(Se(T.red("ERROR: --stdin-file must be specified to emulate a file location when using stdin.")),process.exit(1)),typeof l=="string"&&l.length?P=l:P=await _o();let c={...v,sourcefile:f,loader:"tsx",banner:void 0,footer:void 0};if(a)return(await NE(P,c)).code;{let k=Rc(P,f,"tsx");await Eo({...D,...k}),Se(T.green("Successfully built stdin file to dist/.")),Se(T.grey("Use --no-write to print to stdout instead."));return}}u.log("Building",{files:e,dev:n,runtimeOnly:s}),wc(`${T.bold("TS Module")} [${Bc.NODE_ENV}]`);let U=mo.default.sync(e,{cwd:h}).filter(c=>kE(c)!==".d.ts").map(c=>lr(c));if(LE(e)){U.length||U.push(e);let c=e.replace(A,C).replace(Mt,".js").replace(pt,".js");u.log("Cleaning emitted file:",{outfile:c}),await xc(c,{force:!0})}else u.log("Cleaning old output:",{outDir:C}),await xc(C,{force:!0,recursive:!0});let B=U.filter(c=>pt.test(c));u.log("Compiling TSX files:",{tsxJsxInput:B});let H=B.filter(c=>!c.endsWith(".d.ts"));await Promise.all(H.map(async c=>{let k=await Ic(c,"utf-8"),F=ME+k,le=Rc(F,c,"tsx");await Eo({...D,...le})})),_e("Built TSX files.").succeed();let R=U.filter(c=>Mt.test(c)).filter(c=>!pt.test(c));u.log("Compiling TS files:",{tsJsInput:R}),await Eo({...D,entryPoints:R.filter(c=>!c.endsWith(".d.ts"))}),_e("Built TS files.").succeed();let S=U.filter(c=>!Cc.test(c));u.log("Copying non-JS/TS files.",{allFiles:U,nonTsJsInput:S});for(let c of S){let k=uo(c);u.log("Copying non-source file:",{file:c,emittedFile:k}),await OE(Tc(k),{recursive:!0}),await TE(c,k,IE.COPYFILE_FICLONE)}if(!process.env.NO_REWRITES){let c=e.replace(A,C).replace(/^(\.\/)?src\//,"dist/").replace(Mt,".js").replace(pt,".js");u.log("Normalizing import specifiers in emitted JS.",{emittedJs:c}),await go(c.endsWith(".js")?c:`${c}.js`),_e("Normalized import specifiers.").succeed()}if(await FE()&&_e('Forced "type": "module" in output.').succeed(),s)return;if(!o)if(yo(PE(t))){u.log("Building styles for production.");let{style:c="./dist/bundle.css"}=_;if(u.log("Building style bundle.",{bundleInput:t,bundleOutput:c,dev:n}),await Qc(t,c,n),i){u.log("Bundling all styles.");let k=mo.default.sync("dist/**/*.css"),F=_e("Bundling emitted styles.").start();await Promise.all(k.map(async le=>await Qc(le,le,n))),F.succeed(`Bundled all styles to ${T.bold(c)}.`)}}else Se(T.grey(`Bundle styles not found for this project.
|
31
|
+
\rChecked: `+T.bold(t)));wc("Running post-build setup.");let z=_e("Generating type declarations.").start();await fo(),z.succeed(`Generated delcarations for ${U.length} files.`),Se(T.green("Build complete."))};import{dirname as HE,resolve as jE}from"path";import{fileURLToPath as $E}from"url";var Co={default:[],react:["react@^17.0.2","react-dom@^17.0.2"]},bo={default:["@types/node","@tsmodule/tsmodule","@typescript-eslint/eslint-plugin","@typescript-eslint/parser","ava","eslint","typescript"],react:["next","@types/react@^17.0.39","@types/react-dom@^17.0.11","@tsmodule/react","eslint","eslint-config-next","tailwindcss","autoprefixer","cssnano","postcss","postcss-import"]},Sn=jE(HE($E(import.meta.url)),"..");import{mkdir as GE}from"fs/promises";import{resolve as Oc}from"path";var vo=async(e,t)=>{let r=me(),n=Oc(Sn,`./templates/${e}`),i=Oc(t);await GE(i,{recursive:!0}),await r.run({posix:`cp -rf ${n}/. ${i}`,win32:`xcopy /E /I /Q /Y ${n}\\ ${i}\\`})};import Dc from"fs/promises";import{resolve as UE}from"path";var kc=async e=>{let t=UE(process.cwd(),e,"package.json"),r=await Dc.readFile(t,"utf-8"),n=JSON.parse(r);n.name=e,await Dc.writeFile(t,JSON.stringify(n,null,2))};globalThis.SHELL_OPTIONS={stdio:["ignore","ignore","inherit"]};var yv=async(e,{react:t=!1})=>{let r=me(),n=_e(`Creating new module ${T.blueBright(e)}.`).start();await vo("default",e),t&&await vo("react",e),await kc(e),n.succeed("Project created."),process.chdir(e);let i=[...Co.default],s=[...bo.default];t&&(i.push(...Co.react),s.push(...bo.react)),i.length&&await r.run(`yarn add ${i.join(" ")}`),s.length&&await r.run(`yarn add -D ${s.join(" ")}`),n.succeed("Dependencies installed."),await r.run("git init"),n.succeed("Set up as Git repository.")};import{relative as om,resolve as am}from"path";import{existsSync as lm}from"fs";import{lstat as um}from"fs/promises";var tA=He(Zc(),1);var zc=()=>{console.clear()},eA=e=>{Se(`
|
32
32
|
`,T.gray(`Built ${T.bold(e)}.`),`
|
33
|
-
`,T.blue(new Date().toLocaleString()))},Dv=async()=>{let e=process.cwd(),t=me();process.platform!=="win32"&&await t.run("clear"),zc(),await vn({dev:!0}),eA("src/**/*"),(0,tA.default)(am(e,"src"),{recursive:!0}).on("change",async(r,n)=>{if(!lm(n)||(await um(n)).isDirectory())return;zc();let a=Date.now();await vn({dev:!0,input:n});let l=Date.now()-a;_e(T.blueBright(`Dev refresh finished in ${T.bold(`${l}ms`)}.`)).succeed(),eA(om(e,n))})};import{pathToFileURL as fm}from"url";import{resolve as cm}from"path";var Fv=async()=>{let e=cm(Sn,"dist/loader/index.js"),t=["--no-warnings","--loader",fm(e).href,...process.argv.slice(2)];await me().run(`node ${t.join(" ")}`)};export{wc as bannerLog,vn as build,yv as create,Dv as dev,Fv as execute,go as normalizeImportSpecifiers};
|
33
|
+
`,T.blue(new Date().toLocaleString()))},Dv=async()=>{let e=process.cwd(),t=me();process.platform!=="win32"&&await t.run("clear"),zc(),await vn({dev:!0}),eA("src/**/*"),(0,tA.default)(am(e,"src"),{recursive:!0}).on("change",async(r,n)=>{if(!lm(n)||(await um(n)).isDirectory())return;zc();let a=Date.now();await vn({dev:!0,runtimeOnly:!0,input:n});let l=Date.now()-a;_e(T.blueBright(`Dev refresh finished in ${T.bold(`${l}ms`)}.`)).succeed(),eA(om(e,n))})};import{pathToFileURL as fm}from"url";import{resolve as cm}from"path";var Fv=async()=>{let e=cm(Sn,"dist/loader/index.js"),t=["--no-warnings","--loader",fm(e).href,...process.argv.slice(2)];await me().run(`node ${t.join(" ")}`)};export{wc as bannerLog,vn as build,yv as create,Dv as dev,Fv as execute,go as normalizeImportSpecifiers};
|
34
34
|
/*!
|
35
35
|
* fill-range <https://github.com/jonschlinkert/fill-range>
|
36
36
|
*
|
package/dist/constants.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
1
|
|
2
2
|
typeof document>"u"&&await(async()=>{let{dirname:e}=await import("path"),{fileURLToPath:i}=await import("url");if(typeof globalThis.__filename>"u"&&(globalThis.__filename=i(import.meta.url)),typeof globalThis.__dirname>"u"&&(globalThis.__dirname=e(globalThis.__filename)),typeof globalThis.require>"u"){let{default:a}=await import("module");globalThis.require=a.createRequire(import.meta.url)}})();
|
3
3
|
|
4
|
-
import{readFile as s}from"fs/promises";import{dirname as
|
4
|
+
import{readFile as s}from"fs/promises";import{dirname as o,resolve as e}from"path";import{fileURLToPath as r}from"url";var i={default:[],react:["react@^17.0.2","react-dom@^17.0.2"]},l={default:["@types/node","@tsmodule/tsmodule","@typescript-eslint/eslint-plugin","@typescript-eslint/parser","ava","eslint","typescript"],react:["next","@types/react@^17.0.39","@types/react-dom@^17.0.11","@tsmodule/react","eslint","eslint-config-next","tailwindcss","autoprefixer","cssnano","postcss","postcss-import"]},n=e(o(r(import.meta.url)),".."),d=async()=>{let t=await s(e(n,"package.json"),"utf-8");return JSON.parse(t)};export{n as PACKAGE_ROOT,i as dependencies,l as devDependencies,d as localPackageJson};
|
package/dist/index.js
CHANGED
@@ -45,10 +45,10 @@ import ReactDOM from "react-dom";
|
|
45
45
|
\rTried running: ${l}.
|
46
46
|
\rError: ${u+f}`)},G0=`
|
47
47
|
typeof document>"u"&&await(async()=>{let{dirname:e}=await import("path"),{fileURLToPath:i}=await import("url");if(typeof globalThis.__filename>"u"&&(globalThis.__filename=i(import.meta.url)),typeof globalThis.__dirname>"u"&&(globalThis.__dirname=e(globalThis.__filename)),typeof globalThis.require>"u"){let{default:a}=await import("module");globalThis.require=a.createRequire(import.meta.url)}})();
|
48
|
-
`,jt=async({input:t="src/**/*",styles:e="src/components/index.css",target:r="esnext",dev:i=!1,bundle:n=!1,runtimeOnly:s
|
49
|
-
\rChecked: `+w.bold(e)));ch("Running post-build setup.");let ee=me("Generating type declarations.").start();await Do(),ee.succeed(`Generated delcarations for ${U.length} files.`),we(w.green("Build complete."))};import{readFile as U0}from"fs/promises";import{dirname as K0,resolve as Ah}from"path";import{fileURLToPath as J0}from"url";var $o={default:[],react:["
|
48
|
+
`,jt=async({input:t="src/**/*",styles:e="src/components/index.css",target:r="esnext",dev:i=!1,bundle:n=!1,runtimeOnly:s=!1,jsOnly:o=!1,noWrite:a=!1,stdin:l=void 0,stdinFile:c=void 0})=>{uh.NODE_ENV=i?"development":"production";let u=Se(jt);i&&(s=!0);let{cwd:f,srcDir:h,outDir:y}=Oo(),_=await sh(),m=JSON.parse(_),v={treeShaking:n,target:r,minify:!i,jsx:"transform",jsxFactory:"React.createElement",format:"esm",charset:"utf8",logLevel:i?"warning":"error",define:{"process.env.NODE_ENV":i?JSON.stringify("development"):JSON.stringify("production")}},b=["esbuild","*.png"],D={...v,bundle:n,absWorkingDir:f,outbase:"src",outdir:"dist",assetNames:"[name].js",format:"esm",target:"esnext",platform:m?.platform??"node",write:!a,external:n?b:void 0,banner:n?{js:G0}:void 0},P="";if(l){u.log("Building file from stdin",{stdin:l,stdinFile:c,noWrite:a}),c||(we(w.red("ERROR: --stdin-file must be specified to emulate a file location when using stdin.")),process.exit(1)),typeof l=="string"&&l.length?P=l:P=await Mo();let p={...v,sourcefile:c,loader:"tsx",banner:void 0,footer:void 0};if(a)return(await q0(P,p)).code;{let k=fh(P,c,"tsx");await Fo({...D,...k}),we(w.green("Successfully built stdin file to dist/.")),we(w.grey("Use --no-write to print to stdout instead."));return}}u.log("Building",{files:t,dev:i,runtimeOnly:s}),ch(`${w.bold("TS Module")} [${uh.NODE_ENV}]`);let U=Ho.default.sync(t,{cwd:f}).filter(p=>M0(p)!==".d.ts").map(p=>gr(p));if(F0(t)){U.length||U.push(t);let p=t.replace(h,y).replace($t,".js").replace(_t,".js");u.log("Cleaning emitted file:",{outfile:p}),await lh(p,{force:!0})}else u.log("Cleaning old output:",{outDir:y}),await lh(y,{force:!0,recursive:!0});let B=U.filter(p=>_t.test(p));u.log("Compiling TSX files:",{tsxJsxInput:B});let q=B.filter(p=>!p.endsWith(".d.ts"));await Promise.all(q.map(async p=>{let k=await ph(p,"utf-8"),F=$0+k,ue=fh(F,p,"tsx");await Fo({...D,...ue})})),me("Built TSX files.").succeed();let Q=U.filter(p=>$t.test(p)).filter(p=>!_t.test(p));u.log("Compiling TS files:",{tsJsInput:Q}),await Fo({...D,entryPoints:Q.filter(p=>!p.endsWith(".d.ts"))}),me("Built TS files.").succeed();let S=U.filter(p=>!nh.test(p));u.log("Copying non-JS/TS files.",{allFiles:U,nonTsJsInput:S});for(let p of S){let k=To(p);u.log("Copying non-source file:",{file:p,emittedFile:k}),await P0(dh(k),{recursive:!0}),await L0(p,k,k0.COPYFILE_FICLONE)}if(!process.env.NO_REWRITES){let p=t.replace(h,y).replace(/^(\.\/)?src\//,"dist/").replace($t,".js").replace(_t,".js");u.log("Normalizing import specifiers in emitted JS.",{emittedJs:p}),await Ar(p.endsWith(".js")?p:`${p}.js`),me("Normalized import specifiers.").succeed()}if(await j0()&&me('Forced "type": "module" in output.').succeed(),s)return;if(!o)if(qo(H0(e))){u.log("Building styles for production.");let{style:p="./dist/bundle.css"}=m;if(u.log("Building style bundle.",{bundleInput:e,bundleOutput:p,dev:i}),await hh(e,p,i),n){u.log("Bundling all styles.");let k=Ho.default.sync("dist/**/*.css"),F=me("Bundling emitted styles.").start();await Promise.all(k.map(async ue=>await hh(ue,ue,i))),F.succeed(`Bundled all styles to ${w.bold(p)}.`)}}else we(w.grey(`Bundle styles not found for this project.
|
49
|
+
\rChecked: `+w.bold(e)));ch("Running post-build setup.");let ee=me("Generating type declarations.").start();await Do(),ee.succeed(`Generated delcarations for ${U.length} files.`),we(w.green("Build complete."))};import{readFile as U0}from"fs/promises";import{dirname as K0,resolve as Ah}from"path";import{fileURLToPath as J0}from"url";var $o={default:[],react:["react@^17.0.2","react-dom@^17.0.2"]},jo={default:["@types/node","@tsmodule/tsmodule","@typescript-eslint/eslint-plugin","@typescript-eslint/parser","ava","eslint","typescript"],react:["next","@types/react@^17.0.39","@types/react-dom@^17.0.11","@tsmodule/react","eslint","eslint-config-next","tailwindcss","autoprefixer","cssnano","postcss","postcss-import"]},_r=Ah(K0(J0(import.meta.url)),".."),gh=async()=>{let t=await U0(Ah(_r,"package.json"),"utf-8");return JSON.parse(t)};import{mkdir as V0}from"fs/promises";import{resolve as _h}from"path";var Go=async(t,e)=>{let r=ye(),i=_h(_r,`./templates/${t}`),n=_h(e);await V0(n,{recursive:!0}),await r.run({posix:`cp -rf ${i}/. ${n}`,win32:`xcopy /E /I /Q /Y ${i}\\ ${n}\\`})};import mh from"fs/promises";import{resolve as Y0}from"path";var Eh=async t=>{let e=Y0(process.cwd(),t,"package.json"),r=await mh.readFile(e,"utf-8"),i=JSON.parse(r);i.name=t,await mh.writeFile(e,JSON.stringify(i,null,2))};globalThis.SHELL_OPTIONS={stdio:["ignore","ignore","inherit"]};var yh=async(t,{react:e=!1})=>{let r=ye(),i=me(`Creating new module ${w.blueBright(t)}.`).start();await Go("default",t),e&&await Go("react",t),await Eh(t),i.succeed("Project created."),process.chdir(t);let n=[...$o.default],s=[...jo.default];e&&(n.push(...$o.react),s.push(...jo.react)),n.length&&await r.run(`yarn add ${n.join(" ")}`),s.length&&await r.run(`yarn add -D ${s.join(" ")}`),i.succeed("Dependencies installed."),await r.run("git init"),i.succeed("Set up as Git repository.")};import{relative as cy,resolve as fy}from"path";import{existsSync as hy}from"fs";import{lstat as py}from"fs/promises";var qh=Me(Mh(),1);var Fh=()=>{console.clear()},Hh=t=>{we(`
|
50
50
|
`,w.gray(`Built ${w.bold(t)}.`),`
|
51
|
-
`,w.blue(new Date().toLocaleString()))},$h=async()=>{let t=process.cwd(),e=ye();process.platform!=="win32"&&await e.run("clear"),Fh(),await jt({dev:!0}),Hh("src/**/*"),(0,qh.default)(fy(t,"src"),{recursive:!0}).on("change",async(r,i)=>{if(!hy(i)||(await py(i)).isDirectory())return;Fh();let a=Date.now();await jt({dev:!0,input:i});let l=Date.now()-a;me(w.blueBright(`Dev refresh finished in ${w.bold(`${l}ms`)}.`)).succeed(),Hh(cy(t,i))})};import{pathToFileURL as dy}from"url";import{resolve as Ay}from"path";var jh=async()=>{let t=Ay(_r,"dist/loader/index.js"),e=["--no-warnings","--loader",dy(t).href,...process.argv.slice(2)];await ye().run(`node ${e.join(" ")}`)};var{version:gy}=await gh(),mt=new wa;mt.name(w.white(w.bold("tsmodule"))).usage(w.white(w.bold("<file | command> [options]"))).description(w.blueBright(`A tool for building TypeScript modules.
|
51
|
+
`,w.blue(new Date().toLocaleString()))},$h=async()=>{let t=process.cwd(),e=ye();process.platform!=="win32"&&await e.run("clear"),Fh(),await jt({dev:!0}),Hh("src/**/*"),(0,qh.default)(fy(t,"src"),{recursive:!0}).on("change",async(r,i)=>{if(!hy(i)||(await py(i)).isDirectory())return;Fh();let a=Date.now();await jt({dev:!0,runtimeOnly:!0,input:i});let l=Date.now()-a;me(w.blueBright(`Dev refresh finished in ${w.bold(`${l}ms`)}.`)).succeed(),Hh(cy(t,i))})};import{pathToFileURL as dy}from"url";import{resolve as Ay}from"path";var jh=async()=>{let t=Ay(_r,"dist/loader/index.js"),e=["--no-warnings","--loader",dy(t).href,...process.argv.slice(2)];await ye().run(`node ${e.join(" ")}`)};var{version:gy}=await gh(),mt=new wa;mt.name(w.white(w.bold("tsmodule"))).usage(w.white(w.bold("<file | command> [options]"))).description(w.blueBright(`A tool for building TypeScript modules.
|
52
52
|
|
53
53
|
Run TS directly: ${w.bold("tsmodule src/index.ts")}
|
54
54
|
Use a command: ${w.bold("tsmodule build")}`)).version(String(gy));mt.command("dev").description("Build and watch for changes.").action($h);mt.command("build").description("Builds TS files to output in dist/.").option("-i, --input <files>","Entrypoints to compile.").option("-j, --js-only","Do not build styles").option("-s, --styles <styles>","Specify stylesheet entrypoint.").option("-t, --target <target>","ECMAScript featureset to target.").option("-b, --bundle","Bundle dependencies into entrypoints.").option("-d, --dev","Build development runtime.").option("-r, --runtime-only","Do not emit type declarations, only build JS runtime.").option("--stdin [source]","Read from a string or stdin.").option("--stdin-file [file]","File path to mock for stdin.").option("--no-write",`Return code from build() rather than write to disk.
|
package/dist/types/index.js
CHANGED
@@ -27,10 +27,10 @@ import ReactDOM from "react-dom";
|
|
27
27
|
\rTried running: ${l}.
|
28
28
|
\rError: ${u+h}`)},qE=`
|
29
29
|
typeof document>"u"&&await(async()=>{let{dirname:e}=await import("path"),{fileURLToPath:i}=await import("url");if(typeof globalThis.__filename>"u"&&(globalThis.__filename=i(import.meta.url)),typeof globalThis.__dirname>"u"&&(globalThis.__dirname=e(globalThis.__filename)),typeof globalThis.require>"u"){let{default:a}=await import("module");globalThis.require=a.createRequire(import.meta.url)}})();
|
30
|
-
`,vn=async({input:e="src/**/*",styles:t="src/components/index.css",target:r="esnext",dev:n=!1,bundle:i=!1,runtimeOnly:s
|
31
|
-
\rChecked: `+T.bold(t)));wc("Running post-build setup.");let z=_e("Generating type declarations.").start();await fo(),z.succeed(`Generated delcarations for ${U.length} files.`),xe(T.green("Build complete."))};import{dirname as HE,resolve as jE}from"path";import{fileURLToPath as $E}from"url";var Co={default:[],react:["
|
30
|
+
`,vn=async({input:e="src/**/*",styles:t="src/components/index.css",target:r="esnext",dev:n=!1,bundle:i=!1,runtimeOnly:s=!1,jsOnly:o=!1,noWrite:a=!1,stdin:l=void 0,stdinFile:f=void 0})=>{Bc.NODE_ENV=n?"development":"production";let u=ve(vn);n&&(s=!0);let{cwd:h,srcDir:A,outDir:C}=lo(),E=await bc(),_=JSON.parse(E),v={treeShaking:i,target:r,minify:!n,jsx:"transform",jsxFactory:"React.createElement",format:"esm",charset:"utf8",logLevel:n?"warning":"error",define:{"process.env.NODE_ENV":n?JSON.stringify("development"):JSON.stringify("production")}},b=["esbuild","*.png"],D={...v,bundle:i,absWorkingDir:h,outbase:"src",outdir:"dist",assetNames:"[name].js",format:"esm",target:"esnext",platform:_?.platform??"node",write:!a,external:i?b:void 0,banner:i?{js:qE}:void 0},P="";if(l){u.log("Building file from stdin",{stdin:l,stdinFile:f,noWrite:a}),f||(xe(T.red("ERROR: --stdin-file must be specified to emulate a file location when using stdin.")),process.exit(1)),typeof l=="string"&&l.length?P=l:P=await _o();let c={...v,sourcefile:f,loader:"tsx",banner:void 0,footer:void 0};if(a)return(await NE(P,c)).code;{let k=Rc(P,f,"tsx");await Eo({...D,...k}),xe(T.green("Successfully built stdin file to dist/.")),xe(T.grey("Use --no-write to print to stdout instead."));return}}u.log("Building",{files:e,dev:n,runtimeOnly:s}),wc(`${T.bold("TS Module")} [${Bc.NODE_ENV}]`);let U=mo.default.sync(e,{cwd:h}).filter(c=>kE(c)!==".d.ts").map(c=>lr(c));if(LE(e)){U.length||U.push(e);let c=e.replace(A,C).replace(Mt,".js").replace(pt,".js");u.log("Cleaning emitted file:",{outfile:c}),await Sc(c,{force:!0})}else u.log("Cleaning old output:",{outDir:C}),await Sc(C,{force:!0,recursive:!0});let B=U.filter(c=>pt.test(c));u.log("Compiling TSX files:",{tsxJsxInput:B});let H=B.filter(c=>!c.endsWith(".d.ts"));await Promise.all(H.map(async c=>{let k=await Ic(c,"utf-8"),F=ME+k,le=Rc(F,c,"tsx");await Eo({...D,...le})})),_e("Built TSX files.").succeed();let R=U.filter(c=>Mt.test(c)).filter(c=>!pt.test(c));u.log("Compiling TS files:",{tsJsInput:R}),await Eo({...D,entryPoints:R.filter(c=>!c.endsWith(".d.ts"))}),_e("Built TS files.").succeed();let x=U.filter(c=>!Cc.test(c));u.log("Copying non-JS/TS files.",{allFiles:U,nonTsJsInput:x});for(let c of x){let k=uo(c);u.log("Copying non-source file:",{file:c,emittedFile:k}),await OE(Tc(k),{recursive:!0}),await TE(c,k,IE.COPYFILE_FICLONE)}if(!process.env.NO_REWRITES){let c=e.replace(A,C).replace(/^(\.\/)?src\//,"dist/").replace(Mt,".js").replace(pt,".js");u.log("Normalizing import specifiers in emitted JS.",{emittedJs:c}),await go(c.endsWith(".js")?c:`${c}.js`),_e("Normalized import specifiers.").succeed()}if(await FE()&&_e('Forced "type": "module" in output.').succeed(),s)return;if(!o)if(yo(PE(t))){u.log("Building styles for production.");let{style:c="./dist/bundle.css"}=_;if(u.log("Building style bundle.",{bundleInput:t,bundleOutput:c,dev:n}),await Qc(t,c,n),i){u.log("Bundling all styles.");let k=mo.default.sync("dist/**/*.css"),F=_e("Bundling emitted styles.").start();await Promise.all(k.map(async le=>await Qc(le,le,n))),F.succeed(`Bundled all styles to ${T.bold(c)}.`)}}else xe(T.grey(`Bundle styles not found for this project.
|
31
|
+
\rChecked: `+T.bold(t)));wc("Running post-build setup.");let z=_e("Generating type declarations.").start();await fo(),z.succeed(`Generated delcarations for ${U.length} files.`),xe(T.green("Build complete."))};import{dirname as HE,resolve as jE}from"path";import{fileURLToPath as $E}from"url";var Co={default:[],react:["react@^17.0.2","react-dom@^17.0.2"]},bo={default:["@types/node","@tsmodule/tsmodule","@typescript-eslint/eslint-plugin","@typescript-eslint/parser","ava","eslint","typescript"],react:["next","@types/react@^17.0.39","@types/react-dom@^17.0.11","@tsmodule/react","eslint","eslint-config-next","tailwindcss","autoprefixer","cssnano","postcss","postcss-import"]},xn=jE(HE($E(import.meta.url)),"..");import{mkdir as GE}from"fs/promises";import{resolve as Oc}from"path";var vo=async(e,t)=>{let r=me(),n=Oc(xn,`./templates/${e}`),i=Oc(t);await GE(i,{recursive:!0}),await r.run({posix:`cp -rf ${n}/. ${i}`,win32:`xcopy /E /I /Q /Y ${n}\\ ${i}\\`})};import Dc from"fs/promises";import{resolve as UE}from"path";var kc=async e=>{let t=UE(process.cwd(),e,"package.json"),r=await Dc.readFile(t,"utf-8"),n=JSON.parse(r);n.name=e,await Dc.writeFile(t,JSON.stringify(n,null,2))};globalThis.SHELL_OPTIONS={stdio:["ignore","ignore","inherit"]};var yv=async(e,{react:t=!1})=>{let r=me(),n=_e(`Creating new module ${T.blueBright(e)}.`).start();await vo("default",e),t&&await vo("react",e),await kc(e),n.succeed("Project created."),process.chdir(e);let i=[...Co.default],s=[...bo.default];t&&(i.push(...Co.react),s.push(...bo.react)),i.length&&await r.run(`yarn add ${i.join(" ")}`),s.length&&await r.run(`yarn add -D ${s.join(" ")}`),n.succeed("Dependencies installed."),await r.run("git init"),n.succeed("Set up as Git repository.")};import{relative as om,resolve as am}from"path";import{existsSync as lm}from"fs";import{lstat as um}from"fs/promises";var tA=He(Zc(),1);var zc=()=>{console.clear()},eA=e=>{xe(`
|
32
32
|
`,T.gray(`Built ${T.bold(e)}.`),`
|
33
|
-
`,T.blue(new Date().toLocaleString()))},Dv=async()=>{let e=process.cwd(),t=me();process.platform!=="win32"&&await t.run("clear"),zc(),await vn({dev:!0}),eA("src/**/*"),(0,tA.default)(am(e,"src"),{recursive:!0}).on("change",async(r,n)=>{if(!lm(n)||(await um(n)).isDirectory())return;zc();let a=Date.now();await vn({dev:!0,input:n});let l=Date.now()-a;_e(T.blueBright(`Dev refresh finished in ${T.bold(`${l}ms`)}.`)).succeed(),eA(om(e,n))})};import{pathToFileURL as fm}from"url";import{resolve as cm}from"path";var Fv=async()=>{let e=cm(xn,"dist/loader/index.js"),t=["--no-warnings","--loader",fm(e).href,...process.argv.slice(2)];await me().run(`node ${t.join(" ")}`)};export{wc as bannerLog,vn as build,yv as create,Dv as dev,Fv as execute,go as normalizeImportSpecifiers};
|
33
|
+
`,T.blue(new Date().toLocaleString()))},Dv=async()=>{let e=process.cwd(),t=me();process.platform!=="win32"&&await t.run("clear"),zc(),await vn({dev:!0}),eA("src/**/*"),(0,tA.default)(am(e,"src"),{recursive:!0}).on("change",async(r,n)=>{if(!lm(n)||(await um(n)).isDirectory())return;zc();let a=Date.now();await vn({dev:!0,runtimeOnly:!0,input:n});let l=Date.now()-a;_e(T.blueBright(`Dev refresh finished in ${T.bold(`${l}ms`)}.`)).succeed(),eA(om(e,n))})};import{pathToFileURL as fm}from"url";import{resolve as cm}from"path";var Fv=async()=>{let e=cm(xn,"dist/loader/index.js"),t=["--no-warnings","--loader",fm(e).href,...process.argv.slice(2)];await me().run(`node ${t.join(" ")}`)};export{wc as bannerLog,vn as build,yv as create,Dv as dev,Fv as execute,go as normalizeImportSpecifiers};
|
34
34
|
/*!
|
35
35
|
* fill-range <https://github.com/jonschlinkert/fill-range>
|
36
36
|
*
|