@schemavaults/dbh 0.8.2 → 0.8.3
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 +1 -1
- package/dist-cli/cli.js +1 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -20,7 +20,7 @@ Ensure that you have both `postgres` and a `postgres-ws-proxy` containers runnin
|
|
|
20
20
|
|
|
21
21
|
You'll likely want to replace the `build:` sections for the services in the e2e test example `.yml` file with `image:`. For example, use `image: postgres:17.7` for the `postgres` service. For the proxy, you can pull the docker image from `ghcr.io/schemavaults/dbh/postgres-ws-proxy`; use the version number equal to your `@schemavaults/dbh` npm package installation:
|
|
22
22
|
```md
|
|
23
|
-
# NPM Package: @schemavaults/dbh@0.8.
|
|
23
|
+
# NPM Package: @schemavaults/dbh@0.8.3 => ghcr.io/schemavaults/dbh/postgres-ws-proxy:0.8.3
|
|
24
24
|
```
|
|
25
25
|
|
|
26
26
|
### In your application server code
|
package/dist-cli/cli.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
1
2
|
import{createRequire as o7}from"node:module";var t7=Object.create;var{getPrototypeOf:s7,defineProperty:H9,getOwnPropertyNames:a7}=Object;var d7=Object.prototype.hasOwnProperty;var n7=(W,$,k)=>{k=W!=null?t7(s7(W)):{};let J=$||!W||!W.__esModule?H9(k,"default",{value:W,enumerable:!0}):k;for(let Z of a7(W))if(!d7.call(J,Z))H9(J,Z,{get:()=>W[Z],enumerable:!0});return J};var X0=(W,$)=>()=>($||W(($={exports:{}}).exports,$),$.exports);var $8=o7(import.meta.url);var k8=X0((r7)=>{class I4 extends Error{constructor(W,$,k){super(k);Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=$,this.exitCode=W,this.nestedError=void 0}}class z9 extends I4{constructor(W){super(1,"commander.invalidArgument",W);Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}}r7.CommanderError=I4;r7.InvalidArgumentError=z9});var y8=X0((J$)=>{var{InvalidArgumentError:$$}=k8();class G9{constructor(W,$){switch(this.description=$||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,W[0]){case"<":this.required=!0,this._name=W.slice(1,-1);break;case"[":this.required=!1,this._name=W.slice(1,-1);break;default:this.required=!0,this._name=W;break}if(this._name.endsWith("..."))this.variadic=!0,this._name=this._name.slice(0,-3)}name(){return this._name}_collectValue(W,$){if($===this.defaultValue||!Array.isArray($))return[W];return $.push(W),$}default(W,$){return this.defaultValue=W,this.defaultValueDescription=$,this}argParser(W){return this.parseArg=W,this}choices(W){return this.argChoices=W.slice(),this.parseArg=($,k)=>{if(!this.argChoices.includes($))throw new $$(`Allowed choices are ${this.argChoices.join(", ")}.`);if(this.variadic)return this._collectValue($,k);return $},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}}function k$(W){let $=W.name()+(W.variadic===!0?"...":"");return W.required?"<"+$+">":"["+$+"]"}J$.Argument=G9;J$.humanReadableArgName=k$});var y4=X0((H$)=>{var{humanReadableArgName:Y$}=y8();class M9{constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(W){this.helpWidth=this.helpWidth??W.helpWidth??80}visibleCommands(W){let $=W.commands.filter((J)=>!J._hidden),k=W._getHelpCommand();if(k&&!k._hidden)$.push(k);if(this.sortSubcommands)$.sort((J,Z)=>{return J.name().localeCompare(Z.name())});return $}compareOptions(W,$){let k=(J)=>{return J.short?J.short.replace(/^-/,""):J.long.replace(/^--/,"")};return k(W).localeCompare(k($))}visibleOptions(W){let $=W.options.filter((J)=>!J.hidden),k=W._getHelpOption();if(k&&!k.hidden){let J=k.short&&W._findOption(k.short),Z=k.long&&W._findOption(k.long);if(!J&&!Z)$.push(k);else if(k.long&&!Z)$.push(W.createOption(k.long,k.description));else if(k.short&&!J)$.push(W.createOption(k.short,k.description))}if(this.sortOptions)$.sort(this.compareOptions);return $}visibleGlobalOptions(W){if(!this.showGlobalOptions)return[];let $=[];for(let k=W.parent;k;k=k.parent){let J=k.options.filter((Z)=>!Z.hidden);$.push(...J)}if(this.sortOptions)$.sort(this.compareOptions);return $}visibleArguments(W){if(W._argsDescription)W.registeredArguments.forEach(($)=>{$.description=$.description||W._argsDescription[$.name()]||""});if(W.registeredArguments.find(($)=>$.description))return W.registeredArguments;return[]}subcommandTerm(W){let $=W.registeredArguments.map((k)=>Y$(k)).join(" ");return W._name+(W._aliases[0]?"|"+W._aliases[0]:"")+(W.options.length?" [options]":"")+($?" "+$:"")}optionTerm(W){return W.flags}argumentTerm(W){return W.name()}longestSubcommandTermLength(W,$){return $.visibleCommands(W).reduce((k,J)=>{return Math.max(k,this.displayWidth($.styleSubcommandTerm($.subcommandTerm(J))))},0)}longestOptionTermLength(W,$){return $.visibleOptions(W).reduce((k,J)=>{return Math.max(k,this.displayWidth($.styleOptionTerm($.optionTerm(J))))},0)}longestGlobalOptionTermLength(W,$){return $.visibleGlobalOptions(W).reduce((k,J)=>{return Math.max(k,this.displayWidth($.styleOptionTerm($.optionTerm(J))))},0)}longestArgumentTermLength(W,$){return $.visibleArguments(W).reduce((k,J)=>{return Math.max(k,this.displayWidth($.styleArgumentTerm($.argumentTerm(J))))},0)}commandUsage(W){let $=W._name;if(W._aliases[0])$=$+"|"+W._aliases[0];let k="";for(let J=W.parent;J;J=J.parent)k=J.name()+" "+k;return k+$+" "+W.usage()}commandDescription(W){return W.description()}subcommandDescription(W){return W.summary()||W.description()}optionDescription(W){let $=[];if(W.argChoices)$.push(`choices: ${W.argChoices.map((k)=>JSON.stringify(k)).join(", ")}`);if(W.defaultValue!==void 0){if(W.required||W.optional||W.isBoolean()&&typeof W.defaultValue==="boolean")$.push(`default: ${W.defaultValueDescription||JSON.stringify(W.defaultValue)}`)}if(W.presetArg!==void 0&&W.optional)$.push(`preset: ${JSON.stringify(W.presetArg)}`);if(W.envVar!==void 0)$.push(`env: ${W.envVar}`);if($.length>0){let k=`(${$.join(", ")})`;if(W.description)return`${W.description} ${k}`;return k}return W.description}argumentDescription(W){let $=[];if(W.argChoices)$.push(`choices: ${W.argChoices.map((k)=>JSON.stringify(k)).join(", ")}`);if(W.defaultValue!==void 0)$.push(`default: ${W.defaultValueDescription||JSON.stringify(W.defaultValue)}`);if($.length>0){let k=`(${$.join(", ")})`;if(W.description)return`${W.description} ${k}`;return k}return W.description}formatItemList(W,$,k){if($.length===0)return[];return[k.styleTitle(W),...$,""]}groupItems(W,$,k){let J=new Map;return W.forEach((Z)=>{let X=k(Z);if(!J.has(X))J.set(X,[])}),$.forEach((Z)=>{let X=k(Z);if(!J.has(X))J.set(X,[]);J.get(X).push(Z)}),J}formatHelp(W,$){let k=$.padWidth(W,$),J=$.helpWidth??80;function Z(R,h){return $.formatItem(R,k,h,$)}let X=[`${$.styleTitle("Usage:")} ${$.styleUsage($.commandUsage(W))}`,""],G=$.commandDescription(W);if(G.length>0)X=X.concat([$.boxWrap($.styleCommandDescription(G),J),""]);let z=$.visibleArguments(W).map((R)=>{return Z($.styleArgumentTerm($.argumentTerm(R)),$.styleArgumentDescription($.argumentDescription(R)))});if(X=X.concat(this.formatItemList("Arguments:",z,$)),this.groupItems(W.options,$.visibleOptions(W),(R)=>R.helpGroupHeading??"Options:").forEach((R,h)=>{let _=R.map((D)=>{return Z($.styleOptionTerm($.optionTerm(D)),$.styleOptionDescription($.optionDescription(D)))});X=X.concat(this.formatItemList(h,_,$))}),$.showGlobalOptions){let R=$.visibleGlobalOptions(W).map((h)=>{return Z($.styleOptionTerm($.optionTerm(h)),$.styleOptionDescription($.optionDescription(h)))});X=X.concat(this.formatItemList("Global Options:",R,$))}return this.groupItems(W.commands,$.visibleCommands(W),(R)=>R.helpGroup()||"Commands:").forEach((R,h)=>{let _=R.map((D)=>{return Z($.styleSubcommandTerm($.subcommandTerm(D)),$.styleSubcommandDescription($.subcommandDescription(D)))});X=X.concat(this.formatItemList(h,_,$))}),X.join(`
|
|
2
3
|
`)}displayWidth(W){return L9(W).length}styleTitle(W){return W}styleUsage(W){return W.split(" ").map(($)=>{if($==="[options]")return this.styleOptionText($);if($==="[command]")return this.styleSubcommandText($);if($[0]==="["||$[0]==="<")return this.styleArgumentText($);return this.styleCommandText($)}).join(" ")}styleCommandDescription(W){return this.styleDescriptionText(W)}styleOptionDescription(W){return this.styleDescriptionText(W)}styleSubcommandDescription(W){return this.styleDescriptionText(W)}styleArgumentDescription(W){return this.styleDescriptionText(W)}styleDescriptionText(W){return W}styleOptionTerm(W){return this.styleOptionText(W)}styleSubcommandTerm(W){return W.split(" ").map(($)=>{if($==="[options]")return this.styleOptionText($);if($[0]==="["||$[0]==="<")return this.styleArgumentText($);return this.styleSubcommandText($)}).join(" ")}styleArgumentTerm(W){return this.styleArgumentText(W)}styleOptionText(W){return W}styleArgumentText(W){return W}styleSubcommandText(W){return W}styleCommandText(W){return W}padWidth(W,$){return Math.max($.longestOptionTermLength(W,$),$.longestGlobalOptionTermLength(W,$),$.longestSubcommandTermLength(W,$),$.longestArgumentTermLength(W,$))}preformatted(W){return/\n[^\S\r\n]/.test(W)}formatItem(W,$,k,J){let X=" ".repeat(2);if(!k)return X+W;let G=W.padEnd($+W.length-J.displayWidth(W)),z=2,w=(this.helpWidth??80)-$-z-2,R;if(w<this.minWidthToWrap||J.preformatted(k))R=k;else R=J.boxWrap(k,w).replace(/\n/g,`
|
|
3
4
|
`+" ".repeat($+z));return X+G+" ".repeat(z)+R.replace(/\n/g,`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@schemavaults/dbh",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.3",
|
|
4
4
|
"description": "Easily connect to PostgresDB from serverless environment",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"private": false,
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"build": "bun run build:pkg && bun run build:build-db-migrations && bun run build:cli",
|
|
32
32
|
"postbuild": "bun run cleanup",
|
|
33
33
|
"build:pkg": "tsc --project tsconfig.json && tsc-alias --project tsconfig.json",
|
|
34
|
-
"build:cli": "bun build ./src/cli.ts --outdir dist-cli --format esm --target node --minify",
|
|
34
|
+
"build:cli": "bun build ./src/cli.ts --outdir dist-cli --format esm --target node --minify && echo '#!/usr/bin/env node' | cat - dist-cli/cli.js > dist-cli/cli.tmp && mv dist-cli/cli.tmp dist-cli/cli.js",
|
|
35
35
|
"build:build-db-migrations": "bun build ./src/build-db-migrations.ts --outdir dist-cli --format esm --target bun --minify",
|
|
36
36
|
"test:unit": "bun test --test-name-pattern 'DBH Init'",
|
|
37
37
|
"test": "bun run test:unit",
|