@tochii/build 1.0.0

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/cli.d.mts ADDED
@@ -0,0 +1 @@
1
+ #!/usr/bin/env node
package/dist/cli.mjs ADDED
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env node
2
+ import s from"chalk";import f from"fs";import m from"path";import{Command as h}from"commander";import{spawn as b}from"child_process";var a={name:"@tochii/build",version:"1.0.0",description:"Tools for bundling your projects in Node.js",repository:"https://github.com/tochiResources/project/packages/build.git",license:"MIT",bin:{tochibuild:"./dist/cli.mjs"},scripts:{build:"tsup-node",dev:"tsx cli.ts"},dependencies:{chalk:"^5.4.1",commander:"^13.1.0"},devDependencies:{"@types/node":"^22.15.17",tsup:"^8.4.0",tsx:"^4.19.4",typescript:"^5.8.3"},engines:{node:">=18.17.0"},files:["dist"]};var u={node:"tsup-node"},d=s.cyan("tochibuild"),p=new h("tochibuild").name("tochibuild <command>").description("Tools for bundling your projects in Node.js").allowUnknownOption(!0).version(a.version);p.command("node").description("bundle a Node.js project using tsup (https://tsup.egoist.dev)").allowUnknownOption(!0).argument("[...args]","arguments to pass to tsup").action(async e=>y("node",e));p.command("config").description("generate config files for the selected bundler").argument("<bundler>","bundler to generate config for").option("--ext <string>","the file extension to use (defaults to the common one for the bundler)","").option("-f, --file <string>","the file name to use (defaults to the common one for the bundler)","").option("-o, --overwrite","whether to overwrite the config file if it already exists (defaults to false)",!1).action((e,n)=>w(e,n));p.parseAsync(process.argv);async function y(e,n){return new Promise((r,i)=>{try{console.log(d,`running ${s.magenta(e)}...`),setTimeout(()=>{let o=b(u[e],n,{stdio:"inherit",shell:!0,cwd:process.cwd(),env:process.env});o.on("exit",c=>{process.exit(c??1)}),process.on("SIGINT",()=>{i(),o.kill("SIGINT")}),process.on("SIGTERM",()=>{i(),o.kill("SIGTERM")}),r()},3e3)}catch(o){i(o)}})}function w(e,n){switch(u[e]){case"tsup-node":x(n);break}}function x(e){let n=process.cwd(),r=e.ext||".ts",i=e.file||"tsup.config",o=m.join(n,`${i}${r}`),c=f.existsSync(o);!e?.overwrite&&c&&(console.warn(d,s.yellow("the tsup config file already exists for this project.")),process.exit(1));let l=" ",t="";t+=`import build from '@tochii/build/node';
3
+
4
+ `,t+=`export default build.defineConfig({
5
+ `,t+=`${l}entry: ['index.ts'],
6
+ `,t+=`${l}clean: false,
7
+ `,t+=`${l}splitting: false,
8
+ `,t+=`});
9
+ `,f.writeFileSync(o,t),console.log(s.green(d,"the tsup config file has been created at:"),s.gray(o))}
@@ -0,0 +1,65 @@
1
+ import { Options } from 'tsup';
2
+
3
+ declare class NodeBundlerUtils {
4
+ /**
5
+ * Array of commonly ignored entries
6
+ *
7
+ * @static
8
+ * @memberof NodeBundlerUtils
9
+ */
10
+ static ignoredEntries: string[];
11
+ /**
12
+ * Aray of commonly used entries
13
+ *
14
+ * @static
15
+ * @memberof NodeBundlerUtils
16
+ */
17
+ static entriesCommon: string[];
18
+ /**
19
+ * Array of index entries
20
+ *
21
+ * @static
22
+ * @memberof NodeBundlerUtils
23
+ */
24
+ static entriesIndex: string[];
25
+ /**
26
+ * Array of default entries including index files and commonly ignored entries
27
+ *
28
+ * @static
29
+ * @memberof NodeBundlerUtils
30
+ */
31
+ static defaultEntriesIndex: string[];
32
+ /**
33
+ * Array of default entries including any .ts files and commonly ignored entries
34
+ *
35
+ * @static
36
+ * @memberof NodeBundlerUtils
37
+ */
38
+ static defaultEntriesCommon: string[];
39
+ /**
40
+ * Default options
41
+ *
42
+ * @default '{ tsconfig: "tsconfig.json", dts: true, format: ["esm"], minify: true, ...options }'
43
+ * @param options configuration for tsup with clean and splitting as required to avoid unintended behaviour
44
+ * @returns tsup `Options`
45
+ */
46
+ static defaultOptions: (options: WithRequired<Options, "clean" | "entry" | "splitting">) => Options;
47
+ /**
48
+ * Default options for index files as entry
49
+ *
50
+ * @default '{ entry: NodeBundlerUtils.defaultEntriesCommon, tsconfig: "tsconfig.json", dts: true, format: ["esm"], minify: true, ...options }'
51
+ * @param options configuration for tsup with clean and splitting as required to avoid unintended behaviour
52
+ * @returns tsup `Options`
53
+ */
54
+ static defaultOptionsIndexEntries: (options: WithRequired<Options, "clean" | "splitting">) => Options;
55
+ /**
56
+ * Default options for common files as entry
57
+ *
58
+ * @default '{ entry: NodeBundlerUtils.defaultEntriesCommon, tsconfig: "tsconfig.json", dts: true, format: ["esm"], minify: true, ...options }'
59
+ * @param options configuration for tsup with clean and splitting as required to avoid unintended behaviour
60
+ * @returns tsup `Options`
61
+ */
62
+ static defaultOptionsCommonEntries: (options: WithRequired<Options, "clean" | "splitting">) => Options;
63
+ }
64
+
65
+ export { NodeBundlerUtils, NodeBundlerUtils as default };
@@ -0,0 +1 @@
1
+ var t=class t{};t.ignoredEntries=["!node_modules","!**/*/node_modules","!*.d.ts","!**/*/*.d.ts","!tsup.config*","!**/*/tsup.config*"],t.entriesCommon=["*.ts","**/*/*.ts"],t.entriesIndex=["index.ts","**/*/index.ts"],t.defaultEntriesIndex=[...t.entriesIndex,...t.ignoredEntries],t.defaultEntriesCommon=[...t.entriesCommon,...t.ignoredEntries],t.defaultOptions=n=>({tsconfig:"tsconfig.json",dts:!0,format:["esm"],minify:!0,...n,entry:s(n.entry,"ignoredEntries")}),t.defaultOptionsIndexEntries=n=>({entry:s(n.entry,"defaultEntriesIndex"),tsconfig:"tsconfig.json",dts:!0,format:["esm"],minify:!0,...n}),t.defaultOptionsCommonEntries=n=>({entry:s(n.entry,"defaultEntriesCommon"),tsconfig:"tsconfig.json",dts:!0,format:["esm"],minify:!0,...n});var e=t,a=e;function s(i,n){if(Array.isArray(i))return[...i,...e[n]];let r={};return e[n].forEach(o=>r[o]=o),{...i,...r}}export{e as NodeBundlerUtils,a as default};
package/package.json ADDED
@@ -0,0 +1,30 @@
1
+ {
2
+ "name": "@tochii/build",
3
+ "version": "1.0.0",
4
+ "description": "Tools for bundling your projects in Node.js",
5
+ "repository": "https://github.com/tochiResources/project/packages/build.git",
6
+ "license": "MIT",
7
+ "bin": {
8
+ "tochibuild": "./dist/cli.mjs"
9
+ },
10
+ "scripts": {
11
+ "build": "tsup-node",
12
+ "dev": "tsx cli.ts"
13
+ },
14
+ "dependencies": {
15
+ "chalk": "^5.4.1",
16
+ "commander": "^13.1.0"
17
+ },
18
+ "devDependencies": {
19
+ "@types/node": "^22.15.17",
20
+ "tsup": "^8.4.0",
21
+ "tsx": "^4.19.4",
22
+ "typescript": "^5.8.3"
23
+ },
24
+ "engines": {
25
+ "node": ">=18.17.0"
26
+ },
27
+ "files": [
28
+ "dist"
29
+ ]
30
+ }