litedbmodel-gen 0.6.2 → 0.6.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.
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
- import { createRequire } from 'module';
3
- const require = createRequire(import.meta.url);
2
+ import { createRequire as __bundleRequire } from 'module';
3
+ const require = __bundleRequire(import.meta.url);
4
4
  var zY=Object.create;var iy=Object.defineProperty;var qY=Object.getOwnPropertyDescriptor;var UY=Object.getOwnPropertyNames;var VY=Object.getPrototypeOf,BY=Object.prototype.hasOwnProperty;var Kn=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,r)=>(typeof require<"u"?require:t)[r]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var rt=(e,t)=>()=>(e&&(t=e(e=0)),t);var we=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Sn=(e,t)=>{for(var r in t)iy(e,r,{get:t[r],enumerable:!0})},GY=(e,t,r,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of UY(t))!BY.call(e,n)&&n!==r&&iy(e,n,{get:()=>t[n],enumerable:!(i=qY(t,n))||i.enumerable});return e};var Pi=(e,t,r)=>(r=e!=null?zY(VY(e)):{},GY(t||!e||!e.__esModule?iy(r,"default",{value:e,enumerable:!0}):r,e));var rd=we(by=>{var Nm=class extends Error{constructor(t,r,i){super(i),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=r,this.exitCode=t,this.nestedError=void 0}},_y=class extends Nm{constructor(t){super(1,"commander.invalidArgument",t),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};by.CommanderError=Nm;by.InvalidArgumentError=_y});var Dm=we(Sy=>{var{InvalidArgumentError:dee}=rd(),wy=class{constructor(t,r){switch(this.description=r||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,t[0]){case"<":this.required=!0,this._name=t.slice(1,-1);break;case"[":this.required=!1,this._name=t.slice(1,-1);break;default:this.required=!0,this._name=t;break}this._name.endsWith("...")&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_collectValue(t,r){return r===this.defaultValue||!Array.isArray(r)?[t]:(r.push(t),r)}default(t,r){return this.defaultValue=t,this.defaultValueDescription=r,this}argParser(t){return this.parseArg=t,this}choices(t){return this.argChoices=t.slice(),this.parseArg=(r,i)=>{if(!this.argChoices.includes(r))throw new dee(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._collectValue(r,i):r},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function pee(e){let t=e.name()+(e.variadic===!0?"...":"");return e.required?"<"+t+">":"["+t+"]"}Sy.Argument=wy;Sy.humanReadableArgName=pee});var Ey=we($y=>{var{humanReadableArgName:fee}=Dm(),xy=class{constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(t){this.helpWidth=this.helpWidth??t.helpWidth??80}visibleCommands(t){let r=t.commands.filter(n=>!n._hidden),i=t._getHelpCommand();return i&&!i._hidden&&r.push(i),this.sortSubcommands&&r.sort((n,a)=>n.name().localeCompare(a.name())),r}compareOptions(t,r){let i=n=>n.short?n.short.replace(/^-/,""):n.long.replace(/^--/,"");return i(t).localeCompare(i(r))}visibleOptions(t){let r=t.options.filter(n=>!n.hidden),i=t._getHelpOption();if(i&&!i.hidden){let n=i.short&&t._findOption(i.short),a=i.long&&t._findOption(i.long);!n&&!a?r.push(i):i.long&&!a?r.push(t.createOption(i.long,i.description)):i.short&&!n&&r.push(t.createOption(i.short,i.description))}return this.sortOptions&&r.sort(this.compareOptions),r}visibleGlobalOptions(t){if(!this.showGlobalOptions)return[];let r=[];for(let i=t.parent;i;i=i.parent){let n=i.options.filter(a=>!a.hidden);r.push(...n)}return this.sortOptions&&r.sort(this.compareOptions),r}visibleArguments(t){return t._argsDescription&&t.registeredArguments.forEach(r=>{r.description=r.description||t._argsDescription[r.name()]||""}),t.registeredArguments.find(r=>r.description)?t.registeredArguments:[]}subcommandTerm(t){let r=t.registeredArguments.map(i=>fee(i)).join(" ");return t._name+(t._aliases[0]?"|"+t._aliases[0]:"")+(t.options.length?" [options]":"")+(r?" "+r:"")}optionTerm(t){return t.flags}argumentTerm(t){return t.name()}longestSubcommandTermLength(t,r){return r.visibleCommands(t).reduce((i,n)=>Math.max(i,this.displayWidth(r.styleSubcommandTerm(r.subcommandTerm(n)))),0)}longestOptionTermLength(t,r){return r.visibleOptions(t).reduce((i,n)=>Math.max(i,this.displayWidth(r.styleOptionTerm(r.optionTerm(n)))),0)}longestGlobalOptionTermLength(t,r){return r.visibleGlobalOptions(t).reduce((i,n)=>Math.max(i,this.displayWidth(r.styleOptionTerm(r.optionTerm(n)))),0)}longestArgumentTermLength(t,r){return r.visibleArguments(t).reduce((i,n)=>Math.max(i,this.displayWidth(r.styleArgumentTerm(r.argumentTerm(n)))),0)}commandUsage(t){let r=t._name;t._aliases[0]&&(r=r+"|"+t._aliases[0]);let i="";for(let n=t.parent;n;n=n.parent)i=n.name()+" "+i;return i+r+" "+t.usage()}commandDescription(t){return t.description()}subcommandDescription(t){return t.summary()||t.description()}optionDescription(t){let r=[];if(t.argChoices&&r.push(`choices: ${t.argChoices.map(i=>JSON.stringify(i)).join(", ")}`),t.defaultValue!==void 0&&(t.required||t.optional||t.isBoolean()&&typeof t.defaultValue=="boolean")&&r.push(`default: ${t.defaultValueDescription||JSON.stringify(t.defaultValue)}`),t.presetArg!==void 0&&t.optional&&r.push(`preset: ${JSON.stringify(t.presetArg)}`),t.envVar!==void 0&&r.push(`env: ${t.envVar}`),r.length>0){let i=`(${r.join(", ")})`;return t.description?`${t.description} ${i}`:i}return t.description}argumentDescription(t){let r=[];if(t.argChoices&&r.push(`choices: ${t.argChoices.map(i=>JSON.stringify(i)).join(", ")}`),t.defaultValue!==void 0&&r.push(`default: ${t.defaultValueDescription||JSON.stringify(t.defaultValue)}`),r.length>0){let i=`(${r.join(", ")})`;return t.description?`${t.description} ${i}`:i}return t.description}formatItemList(t,r,i){return r.length===0?[]:[i.styleTitle(t),...r,""]}groupItems(t,r,i){let n=new Map;return t.forEach(a=>{let o=i(a);n.has(o)||n.set(o,[])}),r.forEach(a=>{let o=i(a);n.has(o)||n.set(o,[]),n.get(o).push(a)}),n}formatHelp(t,r){let i=r.padWidth(t,r),n=r.helpWidth??80;function a(c,f){return r.formatItem(c,i,f,r)}let o=[`${r.styleTitle("Usage:")} ${r.styleUsage(r.commandUsage(t))}`,""],s=r.commandDescription(t);s.length>0&&(o=o.concat([r.boxWrap(r.styleCommandDescription(s),n),""]));let l=r.visibleArguments(t).map(c=>a(r.styleArgumentTerm(r.argumentTerm(c)),r.styleArgumentDescription(r.argumentDescription(c))));if(o=o.concat(this.formatItemList("Arguments:",l,r)),this.groupItems(t.options,r.visibleOptions(t),c=>c.helpGroupHeading??"Options:").forEach((c,f)=>{let h=c.map(g=>a(r.styleOptionTerm(r.optionTerm(g)),r.styleOptionDescription(r.optionDescription(g))));o=o.concat(this.formatItemList(f,h,r))}),r.showGlobalOptions){let c=r.visibleGlobalOptions(t).map(f=>a(r.styleOptionTerm(r.optionTerm(f)),r.styleOptionDescription(r.optionDescription(f))));o=o.concat(this.formatItemList("Global Options:",c,r))}return this.groupItems(t.commands,r.visibleCommands(t),c=>c.helpGroup()||"Commands:").forEach((c,f)=>{let h=c.map(g=>a(r.styleSubcommandTerm(r.subcommandTerm(g)),r.styleSubcommandDescription(r.subcommandDescription(g))));o=o.concat(this.formatItemList(f,h,r))}),o.join(`
5
5
  `)}displayWidth(t){return jk(t).length}styleTitle(t){return t}styleUsage(t){return t.split(" ").map(r=>r==="[options]"?this.styleOptionText(r):r==="[command]"?this.styleSubcommandText(r):r[0]==="["||r[0]==="<"?this.styleArgumentText(r):this.styleCommandText(r)).join(" ")}styleCommandDescription(t){return this.styleDescriptionText(t)}styleOptionDescription(t){return this.styleDescriptionText(t)}styleSubcommandDescription(t){return this.styleDescriptionText(t)}styleArgumentDescription(t){return this.styleDescriptionText(t)}styleDescriptionText(t){return t}styleOptionTerm(t){return this.styleOptionText(t)}styleSubcommandTerm(t){return t.split(" ").map(r=>r==="[options]"?this.styleOptionText(r):r[0]==="["||r[0]==="<"?this.styleArgumentText(r):this.styleSubcommandText(r)).join(" ")}styleArgumentTerm(t){return this.styleArgumentText(t)}styleOptionText(t){return t}styleArgumentText(t){return t}styleSubcommandText(t){return t}styleCommandText(t){return t}padWidth(t,r){return Math.max(r.longestOptionTermLength(t,r),r.longestGlobalOptionTermLength(t,r),r.longestSubcommandTermLength(t,r),r.longestArgumentTermLength(t,r))}preformatted(t){return/\n[^\S\r\n]/.test(t)}formatItem(t,r,i,n){let o=" ".repeat(2);if(!i)return o+t;let s=t.padEnd(r+t.length-n.displayWidth(t)),l=2,d=(this.helpWidth??80)-r-l-2,c;return d<this.minWidthToWrap||n.preformatted(i)?c=i:c=n.boxWrap(i,d).replace(/\n/g,`
6
6
  `+" ".repeat(r+l)),o+s+" ".repeat(l)+c.replace(/\n/g,`
@@ -1988,7 +1988,7 @@ Generated at ${i.generatedAt??"\u2014"} by ${i.tool??"litedbmodel-gen"} (adapter
1988
1988
  `),process.exit(1)}let l=t.reportFormat??"json",u;if(l==="text"?u=K2(s):l==="yaml"?u=H2(s):u=W2(s),t.output){let d=N8e(t.output);j8e(d,u+`
1989
1989
  `,"utf-8"),process.stderr.write(`Report written to: ${d}
1990
1990
  `)}else process.stdout.write(u+`
1991
- `);process.exit(G2(s,o))}X3();var L8e={version:"0.6.2"},F8e=M8e(import.meta.url),UB=VB(F8e);function z8e(e){let t=VB(e),r=Z2(e,"utf-8"),i=td.load(r)??{},n=jc(t,i.renderers_dir??".embedoc/renderers"),a=jc(t,i.datasources_dir??".embedoc/datasources"),o=jc(t,i.templates_dir??".embedoc/templates");return{renderersDir:n,datasourcesDir:a,templatesDir:o}}var q8e={audit:async(e,t)=>{await zB(e,{adapter:t.adapter,model:t.model,dryRun:t.dryRun,failOn:t.failOn,output:t.output,reportFormat:t.reportFormat})},implement:async(e,t)=>{await qB(e,{target:t.target,models:t.models,adapter:t.adapter,model:t.model,dryRun:t.dryRun,failOn:t.failOn,output:t.output,reportFormat:t.reportFormat})},agents:async e=>{let t=await Promise.resolve().then(()=>Pi(mo(),1)),r=e.format??"yaml";try{console.log(r==="json"?JSON.stringify(qd,null,2):t.stringify(qd,{lineWidth:120}))}catch(i){console.error(`Failed to output DSL: ${i.message}`),process.exit(1)}},init:async e=>{let t=e??"embedoc.config.yaml",r=jc(t);Uf(r)||(process.stderr.write(JSON.stringify({error:"config_not_found",message:`${t} not found. Run "npx embedoc init" first.`},null,2)+`
1991
+ `);process.exit(G2(s,o))}X3();var L8e={version:"0.6.3"},F8e=M8e(import.meta.url),UB=VB(F8e);function z8e(e){let t=VB(e),r=Z2(e,"utf-8"),i=td.load(r)??{},n=jc(t,i.renderers_dir??".embedoc/renderers"),a=jc(t,i.datasources_dir??".embedoc/datasources"),o=jc(t,i.templates_dir??".embedoc/templates");return{renderersDir:n,datasourcesDir:a,templatesDir:o}}var q8e={audit:async(e,t)=>{await zB(e,{adapter:t.adapter,model:t.model,dryRun:t.dryRun,failOn:t.failOn,output:t.output,reportFormat:t.reportFormat})},implement:async(e,t)=>{await qB(e,{target:t.target,models:t.models,adapter:t.adapter,model:t.model,dryRun:t.dryRun,failOn:t.failOn,output:t.output,reportFormat:t.reportFormat})},agents:async e=>{let t=await Promise.resolve().then(()=>Pi(mo(),1)),r=e.format??"yaml";try{console.log(r==="json"?JSON.stringify(qd,null,2):t.stringify(qd,{lineWidth:120}))}catch(i){console.error(`Failed to output DSL: ${i.message}`),process.exit(1)}},init:async e=>{let t=e??"embedoc.config.yaml",r=jc(t);Uf(r)||(process.stderr.write(JSON.stringify({error:"config_not_found",message:`${t} not found. Run "npx embedoc init" first.`},null,2)+`
1992
1992
  `),process.exit(3));let i=z8e(r);console.log(`Setting up litedbmodel-gen...
1993
1993
  `),U8e(i.templatesDir),B8e(i.renderersDir),G8e(i.datasourcesDir),K8e(r),console.log(`
1994
1994
  Done! Next steps:`),console.log(" 1. Edit embedoc.config.yaml \u2014 set path/database in the schema datasource"),console.log(" 2. npx embedoc generate --datasource schema (create model files)"),console.log(" 3. npx embedoc build (fill in column definitions)")}};function U8e(e){D8e(e,{recursive:!0});let t=_x(e,"model.hbs");if(Uf(t)){console.log(` skip ${t} (already exists)`);return}let r=V8e();R8e(r,t),console.log(` create ${t}`)}function V8e(){let e=[jc(UB,"..","templates","model.hbs"),jc(UB,"templates","model.hbs")];for(let t of e)if(Uf(t))return t;throw new Error("Could not find model.hbs template in package")}function B8e(e){let t=_x(e,"index.ts");if(!Uf(t)){console.error(` warn ${t} not found, skipping renderers setup`);return}let r=Z2(t,"utf-8");if(r.includes("litedbmodel-gen")){console.log(` skip ${t} (already configured)`);return}let i="import { litedbmodelColumns } from 'litedbmodel-gen';",n=` litedbmodel_columns: {