build-ts 3.1.3 → 3.2.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/README.md CHANGED
@@ -4,3 +4,9 @@
4
4
  [![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)
5
5
 
6
6
  An opinionated tool for building a Node.js app and library written in TypeScript.
7
+
8
+ ## Node.js Application
9
+
10
+ ## Firebase Functions
11
+
12
+ ## Node.js Library
package/bin/index.mjs CHANGED
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- import '../dist/index.min.mjs';
3
+ import '../dist/index.mjs';
package/dist/index.mjs ADDED
@@ -0,0 +1,2 @@
1
+ import e from"yargs";import{hideBin as o}from"yargs/helpers";import r from"node:fs";import t from"node:path";import{rollup as n}from"rollup";import i from"node:url";import{babel as s}from"@rollup/plugin-babel";import a from"@rollup/plugin-commonjs";import p from"@rollup/plugin-json";import l from"@rollup/plugin-node-resolve";import c from"@rollup/plugin-replace";import m from"@rollup/plugin-terser";import d from"rollup-plugin-analyzer";import{externals as u}from"rollup-plugin-node-externals";import{string as f}from"rollup-plugin-string";import g from"rollup-plugin-ts";import h from"dotenv";import*as b from"node:child_process";async function y(e){try{const o=await r.promises.readFile(t.join(e,"package.json"),"utf8");return JSON.parse(o)}catch{}}function j(e){const o={};for(const r of(e.env??[]).map((e=>e.toString())))void 0!==process.env[r]&&(o[`process.env.${r}`]=JSON.stringify(process.env[r]));for(const r of e.dotenv??[]){const e=h.config({path:r.toString()}).parsed||{};for(const[r,t]of Object.entries(e))void 0!==t&&(o[`process.env.${r}`]=JSON.stringify(t))}return o}function v(e,o,r){const n=[...e.external??[]].map((e=>e.toString()));o?.dependencies?.["@prisma/client"]&&n.push("prisma-client");const h=[".cjs",".mjs",".js",".jsx",".json",".cts",".mts",".ts",".tsx"],b=t.join(i.fileURLToPath(t.dirname(t.dirname(import.meta.url))),"babel.config.mjs"),y=[c({delimiters:["",""],preventAssignment:!0,values:j(e)}),p(),u({deps:!0,devDeps:!1,include:n,exclude:r&&new RegExp(`${r}\\/.+`)}),l({extensions:h}),a()];return"app"===e.target?y.push(s({configFile:b,extensions:h,babelHelpers:"bundled",exclude:"node_modules/**"})):y.push(g({transpiler:"babel",babelConfig:b})),y.push(f({include:["**/*.csv","**/*.txt"]})),e.minify&&y.push(m()),y.push(d({summaryOnly:!0})),y}const x={command:"build [package]",describe:"Build a package",builder:{target:{description:"A target format: app, lib or functions",type:"string",require:!0,alias:"t"},input:{description:'A file path of main source code. Default value is "src/index.ts" from package directory.',type:"string",alias:"i"},"core-js":{description:"Whether or not core-js is employed.",type:"boolean",default:!1},minify:{description:"Whether or not minification is enabled.",type:"boolean",default:!0},sourcemap:{description:"Whether or not sourcemap is enabled.",type:"boolean",default:!0},external:{description:"Additional external dependencies.",type:"array"},verbose:{description:"Whether or not verbose mode is enabled.",type:"boolean",alias:"v"},env:{description:"Environment variables to be inlined.",type:"array",alias:"e"},dotenv:{description:".env files to be inlined.",type:"array"}},async handler(e){"app"!==e.target&&"lib"!==e.target&&"functions"!==e.target&&(console.error('target option must be "app", "lib" or "functions'),process.exit(1));const o=t.resolve(e.package?.toString()??"."),i=await y(o);i||(console.error("Failed to parse package.json"),process.exit(1)),e.coreJs&&(process.env.BUILD_TS_COREJS="1"),e.verbose&&(process.env.BUILD_TS_VERBOSE="1"),process.env.BUILD_TS_TARGET=e.target;const[s]=function(e){const o=e.name?.toString()||"",r=/@([^/]+)\/(.+)/.exec(o),[,t,n]=r||[];return[t,n]}(i),a=v(e,i,s),p="module"===i.type;let l,c;await r.promises.rm(t.join(o,"dist"),{recursive:!0,force:!0}),"app"===e.target||"functions"===e.target?(i.main=p?"index.mjs":"index.cjs",l=[{file:t.join(o,"dist",i.main),format:p?"module":"commonjs",sourcemap:e.sourcemap}]):l=[{file:t.join(o,"dist","cjs","index.cjs"),format:"commonjs",sourcemap:e.sourcemap},{dir:t.join(o,"dist","esm"),entryFileNames:"[name].mjs",format:"module",preserveModules:!0,sourcemap:e.sourcemap}],0===l.length&&(console.error("Failed to detect output files."),process.exit(1));let m=!1;try{const s=await n({input:t.join(o,e.input||t.join("src","index.ts")),plugins:a});c=s,await Promise.all(l.map((e=>s.write(e)))),"functions"===e.target&&(i.name+="-dist",delete i.devDependencies,await r.promises.writeFile(t.join(o,"dist","package.json"),JSON.stringify(i)))}catch(e){m=!0,console.error("Filed to index due to:",e)}await(c?.close()),m&&process.exit(1)}},w={command:"run <file>",describe:"Run script",builder:{module:{description:"A module type: cjs or esm",type:"string",alias:"m"},watch:{description:"Whether watch mode is enabled or not",type:"boolean",alias:"w"}},async handler(e){const o=e.file?.toString()||"",r=await async function(e,o){if("cjs"===o||e.endsWith(".cts"))return"cjs";if("esm"===o||e.endsWith(".mts"))return"esm";let r=t.dirname(e);for(;;){const e=await y(r);if(e){if("module"===e.type)return"esm";break}const o=t.dirname(r);if(!o||o===r)break;r=o}return"cjs"}(o,e.module),n=["--no-warnings"];e.watch&&n.push("--watch"),"cjs"===r?n.push("--require","ts-node/register"):n.push("--loader","ts-node/esm"),n.push(o);const[,...i]=e._;b.spawnSync("node",[...n,...i.map((e=>e.toString()))],{shell:!0,stdio:"inherit",env:{...process.env,TS_NODE_TRANSPILE_ONLY:"1"}})}};await e(o(process.argv)).command(x).command(w).demandCommand().help().argv;
2
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
package/package.json CHANGED
@@ -1,11 +1,10 @@
1
1
  {
2
2
  "name": "build-ts",
3
- "version": "3.1.3",
3
+ "version": "3.2.0",
4
4
  "repository": "github:WillBooster/build-ts",
5
5
  "license": "UNLICENSED",
6
6
  "author": "WillBooster Inc.",
7
7
  "type": "module",
8
- "main": "dist/index.min.mjs",
9
8
  "bin": "bin/index.mjs",
10
9
  "files": [
11
10
  "bin/",
@@ -31,7 +30,7 @@
31
30
  "npm/chalk": "^4.1.2"
32
31
  },
33
32
  "dependencies": {
34
- "@babel/core": "7.20.7",
33
+ "@babel/core": "7.20.12",
35
34
  "@babel/plugin-proposal-class-properties": "7.18.6",
36
35
  "@babel/plugin-proposal-numeric-separator": "7.18.6",
37
36
  "@babel/plugin-transform-runtime": "7.19.6",
@@ -49,7 +48,7 @@
49
48
  "core-js": "3.27.1",
50
49
  "core-js-pure": "3.27.1",
51
50
  "dotenv": "16.0.3",
52
- "rollup": "3.9.0",
51
+ "rollup": "3.9.1",
53
52
  "rollup-plugin-analyzer": "4.0.0",
54
53
  "rollup-plugin-node-externals": "5.0.3",
55
54
  "rollup-plugin-string": "3.0.0",
@@ -59,34 +58,37 @@
59
58
  },
60
59
  "devDependencies": {
61
60
  "@types/babel__core": "7.1.20",
62
- "@types/babel__plugin-transform-runtime": "^7",
61
+ "@types/babel__plugin-transform-runtime": "7.9.2",
63
62
  "@types/babel__preset-env": "7.9.2",
64
- "@types/eslint": "^8",
63
+ "@types/eslint": "8.4.10",
65
64
  "@types/node": "18.11.18",
66
- "@types/yargs": "17.0.18",
67
- "@typescript-eslint/eslint-plugin": "5.47.1",
68
- "@typescript-eslint/parser": "5.47.1",
65
+ "@types/yargs": "17.0.19",
66
+ "@typescript-eslint/eslint-plugin": "5.48.0",
67
+ "@typescript-eslint/parser": "5.48.0",
69
68
  "@willbooster/babel-configs": "1.3.0",
70
69
  "@willbooster/eslint-config-ts": "10.0.8",
71
70
  "@willbooster/prettier-config": "9.1.1",
72
- "@willbooster/renovate-config": "9.4.2",
71
+ "@willbooster/renovate-config": "9.5.0",
73
72
  "conventional-changelog-conventionalcommits": "5.0.0",
74
- "eslint": "8.30.0",
75
- "eslint-config-prettier": "8.5.0",
73
+ "eslint": "8.31.0",
74
+ "eslint-config-prettier": "8.6.0",
76
75
  "eslint-import-resolver-typescript": "3.5.2",
77
76
  "eslint-plugin-import": "2.26.0",
78
77
  "eslint-plugin-sort-class-members": "1.16.0",
79
78
  "eslint-plugin-sort-destructure-keys": "1.4.0",
80
79
  "eslint-plugin-unicorn": "45.0.2",
81
- "husky": "8.0.2",
80
+ "husky": "8.0.3",
82
81
  "lint-staged": "13.1.0",
83
82
  "micromatch": "4.0.5",
84
83
  "pinst": "3.0.0",
85
84
  "prettier": "2.8.1",
86
85
  "semantic-release": "19.0.5",
87
86
  "sort-package-json": "2.1.0",
88
- "type-fest": "3.5.0",
87
+ "type-fest": "3.5.1",
89
88
  "typescript": "4.9.4"
90
89
  },
91
- "packageManager": "yarn@4.0.0-rc.34"
90
+ "packageManager": "yarn@4.0.0-rc.34",
91
+ "engines": {
92
+ "node": ">=16.19.0"
93
+ }
92
94
  }
@@ -1,2 +0,0 @@
1
- import e from"yargs";import{hideBin as r}from"yargs/helpers";import o from"node:fs";import s from"node:path";import{babel as i}from"@rollup/plugin-babel";import n from"@rollup/plugin-commonjs";import t from"@rollup/plugin-json";import a from"@rollup/plugin-node-resolve";import p from"@rollup/plugin-replace";import c from"@rollup/plugin-terser";import l from"dotenv";import{rollup as m}from"rollup";import d from"rollup-plugin-analyzer";import{externals as u}from"rollup-plugin-node-externals";import{string as f}from"rollup-plugin-string";import g from"rollup-plugin-ts";import b from"node:url";import*as h from"node:child_process";const v={command:"build [package]",describe:"Build a package",builder:{target:{description:"A target format: app or lib",type:"string",require:!0,alias:"t"},input:{description:'A file path of main source code. Default value is "src/index.ts" from package directory.',type:"string",alias:"i"},firebase:{description:"A file path of firebase.json.",type:"string"},"core-js":{description:"Whether or not core-js is employed.",type:"boolean",default:!1},minify:{description:"Whether or not minification is enabled.",type:"boolean",default:!0},sourcemap:{description:"Whether or not sourcemap is enabled.",type:"boolean",default:!0},external:{description:"Additional external dependencies.",type:"array"},verbose:{description:"Whether or not verbose mode is enabled.",type:"boolean",alias:"v"},env:{description:"Environment variables to be inlined.",type:"array",alias:"e"},dotenv:{description:".env files to be inlined.",type:"array"}},async handler(e){"app"!==e.target&&"lib"!==e.target&&(console.error('target option must be "app" or "lib"'),process.exit(1));let r=e.package?.toString()??".";r.endsWith("package.json")||(r=s.resolve(r,"package.json"));const l=await o.promises.readFile(r,"utf8"),h=JSON.parse(l);h&&h.main||(console.error('Please add "main" property in package.json.'),process.exit(1));const v=h.main,x=s.dirname(r),S=e.input||s.join(x,"src","index.ts");let w=s.join(x,v);e.coreJs&&(process.env.BUILD_TS_COREJS="1"),e.verbose&&(process.env.BUILD_TS_VERBOSE="1"),process.env.BUILD_TS_TARGET=e.target;const[O,k]=function(e){const r=e.name?.toString()||"",o=/@([^/]+)\/(.+)/.exec(r),[,s,i]=o||[];return[s,i]}(h),_=function(e,r,o){const l=[...e.external??[]].map((e=>e.toString()));r?.dependencies?.["@prisma/client"]&&l.push("prisma-client");const m=[".cjs",".mjs",".js",".jsx",".json",".cts",".mts",".ts",".tsx"],h=s.join(b.fileURLToPath(s.dirname(s.dirname(import.meta.url))),"babel.config.mjs"),v=[p({delimiters:["",""],preventAssignment:!0,values:y(e)}),t(),u({deps:!0,devDeps:!1,include:l,exclude:o&&new RegExp(`${o}\\/.+`)}),a({extensions:m}),n()];"app"===e.target?v.push(i({configFile:h,extensions:m,babelHelpers:"bundled",exclude:"node_modules/**"})):v.push(g({transpiler:"babel",babelConfig:h}));v.push(f({include:["**/*.csv","**/*.txt"]})),e.minify&&v.push(c());return v.push(d({summaryOnly:!0})),v}(e,h,O),N="app"===e.target&&e.firebase&&o.existsSync(e.firebase);N&&(w=await async function(e,r,i,n){const t=await o.promises.readFile(e,"utf8"),a=JSON.parse(t),p=s.resolve(s.dirname(e),a.functions.source);return r=s.join(p,s.basename(n)),await o.promises.rm(p,{recursive:!0,force:!0}),await o.promises.mkdir(p,{recursive:!0}),i.name+="-dist",i.main=s.relative(p,r),delete i.devDependencies,await o.promises.writeFile(s.join(p,"package.json"),JSON.stringify(i)),r}(e.firebase,w,h,v));const A=function(e,r,o,i){const n=[];if("app"===e.target)n.push({file:r,format:".mjs"===s.extname(r)?"module":"commonjs",sourcemap:e.sourcemap});else{const r=[[o.main,".mjs"===s.extname(o.main??"")?"module":"commonjs"],[o.module,"module"]];for(const[o,t]of r)o&&n.push({dir:j(s.dirname(o),i),format:t,preserveModules:!0,sourcemap:e.sourcemap})}return n}(e,w,h,k);let E;process.chdir(x);let J=!1;try{const[e]=await Promise.all([m({input:S,plugins:_}),!N&&o.promises.rm(s.dirname(w),{recursive:!0,force:!0})]);await Promise.all(A.map((r=>e.write(r)))),E=e}catch(e){J=!0,console.error("Filed to build due to:",e)}await(E?.close()),J&&process.exit(1)}};function y(e){const r={};for(const o of(e.env??[]).map((e=>e.toString())))void 0!==process.env[o]&&(r[`process.env.${o}`]=JSON.stringify(process.env[o]));for(const o of e.dotenv??[]){const e=l.config({path:o.toString()}).parsed||{};for(const[o,s]of Object.entries(e))void 0!==s&&(r[`process.env.${o}`]=JSON.stringify(s))}return r}function j(e,r){if(!r)return e;const o=e.indexOf(r);return o<0?e:e.slice(0,o)}const x={command:"run <file>",describe:"Run script",builder:{module:{description:"A module type: cjs or esm",type:"string",alias:"m"},watch:{description:"Whether watch mode is enabled or not",type:"boolean",alias:"w"}},async handler(e){const r=e.file?.toString()||"",i=await async function(e,r){if("cjs"===r||e.endsWith(".cts"))return"cjs";if("esm"===r||e.endsWith(".mts"))return"esm";let i=s.dirname(e);for(;;){const e=s.join(i,"package.json");if(o.existsSync(e)){try{const r=await o.promises.readFile(e,"utf8");if("module"===JSON.parse(r).type)return"esm"}catch{}break}const r=s.dirname(i);if(!r||r===i)break;i=r}return"cjs"}(r,e.module),n=["--no-warnings"];e.watch&&n.push("--watch"),"cjs"===i?n.push("--require","ts-node/register"):n.push("--loader","ts-node/esm"),n.push(r);const[,...t]=e._;h.spawnSync("node",[...n,...t.map((e=>e.toString()))],{shell:!0,stdio:"inherit",env:{...process.env,TS_NODE_TRANSPILE_ONLY:"1"}})}};await e(r(process.argv)).command(v).command(x).demandCommand().help().argv;
2
- //# sourceMappingURL=index.min.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.min.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}