Skip to content

Commit e38f8b0

Browse files
committed
update actions
1 parent 01a6eb8 commit e38f8b0

File tree

5 files changed

+32
-32
lines changed

5 files changed

+32
-32
lines changed

dist/index.mjs

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,39 @@
11
#!/usr/bin/env node
2-
import{readdirSync as lt,writeFileSync as mt}from"fs";import{homedir as ut}from"os";import{join as dt,resolve as N}from"path";import gt from"readline";var G=(...t)=>process.stdout.hasColors()?"\x1B[92m"+t[0]+"\x1B[39m":t[0];var D=(...t)=>process.stdout.hasColors()?"\x1B[104m"+t[0]+"\x1B[49m":t[0];var F=(...t)=>process.stdout.hasColors()?"\x1B[97m"+t[0]+"\x1B[39m":t[0];var x=(...t)=>process.stdout.hasColors()?"\x1B[1m"+t[0]+"\x1B[22m":t[0],l=(...t)=>process.stdout.hasColors()?"\x1B[2m"+t[0]+"\x1B[22m":t[0];var J=(...t)=>process.stdout.hasColors()?"\x1B[4m"+t[0]+"\x1B[24m":t[0],U=(...t)=>process.stdout.hasColors()?"\x1B[7m"+t[0]+"\x1B[27m":t[0];async function H(t){let s=process.stdout,n=process.stdin,o=gt.createInterface({input:n,output:s,completer:a=>{let d=a.lastIndexOf("/"),B=a.indexOf("/")?a.substring(0,d+1):"",ct=a.substr(d+1),pt=N(B),I=lt(pt),y=I.filter(at=>at.indexOf(ct)===0),S=[];return y.length===1&&S.push(B+y[0]+"/"),S.length?[S,a]:[y.length?y:I,a]}});o.write(`
3-
`+(t?l("[GLOBAL] "):l("[LOCAL] "))+`sveltegen Configuration -- Leave path blank if unneeded.
2+
import{readdirSync as lt,writeFileSync as mt}from"fs";import{homedir as ut}from"os";import{join as dt,resolve as O}from"path";import gt from"readline";var F=(...t)=>process.stdout.hasColors()?"\x1B[92m"+t[0]+"\x1B[39m":t[0];var J=(...t)=>process.stdout.hasColors()?"\x1B[104m"+t[0]+"\x1B[49m":t[0];var U=(...t)=>process.stdout.hasColors()?"\x1B[97m"+t[0]+"\x1B[39m":t[0];var x=(...t)=>process.stdout.hasColors()?"\x1B[1m"+t[0]+"\x1B[22m":t[0],m=(...t)=>process.stdout.hasColors()?"\x1B[2m"+t[0]+"\x1B[22m":t[0];var W=(...t)=>process.stdout.hasColors()?"\x1B[4m"+t[0]+"\x1B[24m":t[0],H=(...t)=>process.stdout.hasColors()?"\x1B[7m"+t[0]+"\x1B[27m":t[0];async function V(t){let o=process.stdout,n=process.stdin,s=gt.createInterface({input:n,output:o,completer:l=>{let d=l.lastIndexOf("/"),G=l.indexOf("/")?l.substring(0,d+1):"",ct=l.substr(d+1),at=O(G),D=lt(at),y=D.filter(pt=>pt.indexOf(ct)===0),A=[];return y.length===1&&A.push(G+y[0]+"/"),A.length?[A,l]:[y.length?y:D,l]}});s.write(`
3+
`+(t?m("[GLOBAL] "):m("[LOCAL] "))+`sveltegen Configuration -- Leave path blank if unneeded.
44
5-
`);function e(a){return new Promise((d,it)=>{o.question(a,d)})}let p=a=>typeof a>"u"?null:N(a),c={},i=await e("Path to actions directory? "),r=await e("Path to components directory? "),m=await e("Path to routes directory? ");c.actions=p(i),c.components=p(r),c.routes=p(m);let T=JSON.stringify(c);o.close(),mt(N(t?dt(ut(),".sveltegen.json"):"./.sveltegen.json"),T,{encoding:"utf-8"})}var C=(t,s,n)=>`${U(G("Finished"))+` generating ${n} \`${t}\`!`}
5+
`);function e(l){return new Promise((d,it)=>{s.question(l,d)})}let a=l=>typeof l>"u"?null:O(l),c={},i=await e("Path to actions directory? "),r=await e("Path to components directory? "),p=await e("Path to routes directory? ");c.actions=a(i),c.components=a(r),c.routes=a(p);let S=JSON.stringify(c);s.close(),mt(O(t?dt(ut(),".sveltegen.json"):"./.sveltegen.json"),S,{encoding:"utf-8"})}var C=(t,o,n)=>`${H(F("Finished"))+` generating ${n} \`${t}\`!`}
66
7-
Output Path: ${J(s)}`,ht=/[\t\s\n]*\/{2,3}@?.*|import\s(type\s)?\{.*}\s.*;|\slang="ts"|(?:\:\s.[a-zA-Z\.<>]+)/gm;function _(t){return t.replace(ht,"")}var M=t=>t.replace(/[\t\s\n]*?\/{2,3}?@?.+$/gm,""),u={log(...t){if(!!t.length)for(let s=-1;++s<t.length;)console.log(t[s])},err(...t){if(!!t.length)for(let s=-1;++s<t.length;)console.error(t[s])},warn(...t){if(!!t.length)for(let s=-1;++s<t.length;)console.warn(t[s])},info(...t){if(!!t.length)for(let s=-1;++s<t.length;)console.info(t[s])}};var ft=/^-[a-z]$/i,bt=/^--[a-z]{2,}/i;function yt(t){return ft.test(t)}function xt(t){return bt.test(t)}function O(t){return t.replace(/([[\]<>]+)/g,"")}function V(t){let s={name:"",longNotation:"",shortNotation:"",type:0,allNames:[],allNotations:[],rawArgs:[],args:[],longName:"",shortName:""},n=t.split(/[\s\t,]+/).reduce((o,e)=>(xt(e)&&(o.longNotation=e,o.longName=O(e.slice(2)),o.allNames.push(o.longName),o.allNotations.push(e)),yt(e)&&(o.shortNotation=e,o.shortName=e.slice(1),o.allNames.push(o.shortName),o.allNotations.push(e)),e[0]==="["?(o.type=0,o.rawArgs.push(O(e))):e[0]==="<"?(o.type=1,o.rawArgs.push(O(e))):o.type=2,o),s);return n.name=n.longName||n.shortName,Object.assign({},{...n})}var g=class{constructor(s,n,o){this.name=s;this.args=n;this.opts=o;this._options={},this.option("-?, --help","Gets help for this option")}_value;_flags=[];_description="";_action;_example="";_options={};_helpText="";_examples=[];get flags(){return this._flags}get value(){return this._value}get description(){return this._description}get options(){return this._options}option(s,n,o){let e=V(s);return this._options[e.name]={...e,description:n,defaultValue:o},this._helpText+=`${s.padEnd(48," ")} ${n||""}
8-
`,this}action(s){return this._action=s,this}describe(s){if(typeof s!="string")throw new TypeError("Provided description is not a valid string!");return this._description=s,this}example(s,n=""){if(!s||typeof s!="string")throw new Error(s?"Argument `snippet` must be a valid string.":"Argument `snippet` not found. `snippet` must be a valid string.");return this._example+=" "+s.padEnd(48," ")+n+`
9-
`,this}getHelp(){let s=`${this.name+" "+this.args[0]} [options]
7+
Output Path: ${W(o)}`,ht=/[\t\s\n]*\/{2,3}@?.*|import\s(type\s)?\{.*}\s.*;|\slang="ts"|(?:\:\s.[a-zA-Z\.<>]+)/gm;function _(t){return t.replace(ht,"")}var Y=t=>t.replace(/[\t\s\n]*?\/{2,3}?@?.+$/gm,""),u={log(...t){if(!!t.length)for(let o=-1;++o<t.length;)console.log(t[o])},err(...t){if(!!t.length)for(let o=-1;++o<t.length;)console.error(t[o])},warn(...t){if(!!t.length)for(let o=-1;++o<t.length;)console.warn(t[o])},info(...t){if(!!t.length)for(let o=-1;++o<t.length;)console.info(t[o])}};var ft=/^-[a-z]$/i,bt=/^--[a-z]{2,}/i;function yt(t){return ft.test(t)}function xt(t){return bt.test(t)}function E(t){return t.replace(/([[\]<>]+)/g,"")}function q(t){let o={name:"",longNotation:"",shortNotation:"",type:0,allNames:[],allNotations:[],rawArgs:[],args:[],longName:"",shortName:""},n=t.split(/[\s\t,]+/).reduce((s,e)=>(xt(e)&&(s.longNotation=e,s.longName=E(e.slice(2)),s.allNames.push(s.longName),s.allNotations.push(e)),yt(e)&&(s.shortNotation=e,s.shortName=e.slice(1),s.allNames.push(s.shortName),s.allNotations.push(e)),e[0]==="["?(s.type=0,s.rawArgs.push(E(e))):e[0]==="<"?(s.type=1,s.rawArgs.push(E(e))):s.type=2,s),o);return n.name=n.longName||n.shortName,Object.assign({},{...n})}var g=class{constructor(o,n,s){this.name=o;this.args=n;this.opts=s;this._options={},this.option("-?, --help","Gets help for this option")}_value;_flags=[];_description="";_action;_example="";_options={};_helpText="";_examples=[];get flags(){return this._flags}get value(){return this._value}get description(){return this._description}get options(){return this._options}option(o,n,s){let e=q(o);return this._options[e.name]={...e,description:n,defaultValue:s},this._helpText+=`${o.padEnd(48," ")} ${n||""}
8+
`,this}action(o){return this._action=o,this}describe(o){if(typeof o!="string")throw new TypeError("Provided description is not a valid string!");return this._description=o,this}example(o,n=""){if(!o||typeof o!="string")throw new Error(o?"Argument `snippet` must be a valid string.":"Argument `snippet` not found. `snippet` must be a valid string.");return this._example+=" "+o.padEnd(48," ")+n+`
9+
`,this}getHelp(){let o=`${this.name+" "+this.args[0]} [options]
1010
11-
`,n=this._helpText,o=this._example;return{header:s,options:n,examples:o}}run(s){let n={},o=s[0],e;for(;e=s.shift();)for(let p in this._options){let c=this._options[p],i=e===c.longNotation,r=e===c.shortNotation;(i||r)&&(n[p]=!0)}if(n.help){let p=`${this.name+" "+this.args[0]} [options]
11+
`,n=this._helpText,s=this._example;return{header:o,options:n,examples:s}}run(o){let n={},s=o[0],e;for(;e=o.shift();)for(let a in this._options){let c=this._options[a],i=e===c.longNotation,r=e===c.shortNotation;(i||r)&&(n[a]=!0)}if(n.help){let a=`${this.name+" "+this.args[0]} [options]
1212
13-
`,c=this._helpText;return{header:p,options:c,examples:this._example}}try{this._action(o,n,{})}catch(p){u.err(p)}}};var v=class{constructor(s,n){this.name=s;this.version=n;this._commands.help=new g("help",["<cmd>"],{alias:"h"}).action((o,e)=>{if(!o)return this.help();let c=Object.assign({},this._commands,this._aliases)[o].getHelp(),i=`
14-
${x(l(this.name+" "+(this.version?`v${this.version}`:" ")))}
13+
`,c=this._helpText;return{header:a,options:c,examples:this._example}}try{this._action(s,n,{})}catch(a){u.err(a)}}};var v=class{constructor(o,n){this.name=o;this.version=n;this._commands.help=new g("help",["<cmd>"],{alias:"h"}).action((s,e)=>{if(!s)return this.help();let c=Object.assign({},this._commands,this._aliases)[s].getHelp(),i=`
14+
${x(m(this.name+" "+(this.version?`v${this.version}`:" ")))}
1515
16-
`;console.log(i+` ${"Usage: "+this.name} `+c.header,l(`Options:
16+
`;console.log(i+` ${"Usage: "+this.name} `+c.header,m(`Options:
1717
`),c.options+`
1818
19-
`)}),this._commands.help.describe("Provides help for a specific command")}_commands={};_aliases={};_defaultCmd;help(){let s=`
20-
${x(l(this.name+" "+(this.version?`v${this.version}`:" ")))}
19+
`)}),this._commands.help.describe("Provides help for a specific command")}_commands={};_aliases={};_defaultCmd;help(){let o=`
20+
${x(m(this.name+" "+(this.version?`v${this.version}`:" ")))}
2121
22-
`,n=`s${this.name} `,o="",p=Object.keys(this._commands).forEach(r=>this._commands[r]&&(o+=` ${this._commands[r]?.name?.padEnd(16," ")}${this._commands[r]?.args[0]?.padEnd(8," ")}${this._commands[r]?.description}
23-
`)),c=` ${l`Commands:`}
22+
`,n=`s${this.name} `,s="",a=Object.keys(this._commands).forEach(r=>this._commands[r]&&(s+=` ${this._commands[r]?.name?.padEnd(16," ")}${this._commands[r]?.args[0]?.padEnd(8," ")}${this._commands[r]?.description}
23+
`)),c=` ${m`Commands:`}
2424
`,i=`
2525
Need help? To get help for a command run:
2626
${this.name} [command] --help
27-
`;process.stdout.write(s+c+o+i+`
28-
`)}command(s,n=[],o){return this._commands[s]=new g(s,n,o),o?.alias&&(this._aliases[o.alias]=this._commands[s]),o?.isDefault&&(this._defaultCmd=this._commands[s]),this._commands[s]}parse(s){let n=Object.assign({},this._commands,this._aliases),o=new Set(Object.keys(n)),e=s.sort((m,T)=>{let a=m.startsWith("-"),d=T.startsWith("-");if(a<d)return-1;if(d<a)return 1;if(a===d)return 0}),p=e.findIndex(m=>o.has(m)),c=s[p],i=n[c];if(p<0){this.help();return}let r=i.run(e.slice(1));if(r){let m=`
29-
${x(l(this.name+" "+(this.version?`v${this.version}`:" ")))}
27+
`;process.stdout.write(o+c+s+i+`
28+
`)}command(o,n=[],s){return this._commands[o]=new g(o,n,s),s?.alias&&(this._aliases[s.alias]=this._commands[o]),s?.isDefault&&(this._defaultCmd=this._commands[o]),this._commands[o]}parse(o){let n=Object.assign({},this._commands,this._aliases),s=new Set(Object.keys(n)),e=o.sort((p,S)=>{let l=p.startsWith("-"),d=S.startsWith("-");if(l<d)return-1;if(d<l)return 1;if(l===d)return 0}),a=e.findIndex(p=>s.has(p)),c=o[a],i=n[c];if(a<0){this.help();return}let r=i.run(e.slice(1));if(r){let p=`
29+
${x(m(this.name+" "+(this.version?`v${this.version}`:" ")))}
3030
31-
`;console.log(m+` ${"Usage: "+this.name} `+r.header,l(`Options:
31+
`;console.log(p+` ${"Usage: "+this.name} `+r.header,m(`Options:
3232
`),r.options+`
33-
`+(r.examples?l(`
33+
`+(r.examples?m(`
3434
Examples:
3535
`)+r.examples:"")+`
36-
`)}}usage(){}};import{readdirSync as Q,readFileSync as $,writeFileSync as R}from"fs";import{join as P,resolve as k,sep as tt}from"path";import{copyFileSync as Ct,existsSync as q,mkdirSync as _t,readdirSync as vt,readFileSync as At,rmdirSync as wt,rmSync as Tt,statSync as St}from"fs";import{dirname as Nt,join as Y,resolve as z}from"path";function h(t){try{_t(t,{recursive:!0})}catch(s){if(s.code==="EEXIST")return;throw s}}function K(t){(Tt||wt)(t,{recursive:!0,force:!0})}function Ot(t){return t}function E(t,s,n=Ot){if(!q(t))return;St(t).isDirectory()?vt(t).forEach(e=>{E(Y(t,e),Y(s,n(e)))}):(h(Nt(s)),Ct(t,s))}var A=t=>z("./templates/"+t),Z=z("./.sveltegen.json"),f=()=>q(Z),w=()=>{if(f())return JSON.parse(At(Z))};function X(t,s){let n=t.length,o=-1;for(;++o<n;)s(t[o],o,t);o=null}var L=(t,s,n,o)=>E(`${t}`,s,e=>(e=e.replaceAll("_name",n),o.typescript||(e=e.replace(".ts",".js")),o?.scss||(e=e.replace(".scss",".css")),e));function st(t,s={scss:!1,typescript:!1}){if(!f())return;let o=t.split(/\\\\|\//gm).pop(),e=k(w().components+tt+t);if(e===null)return u.err('`components` directory is not defined. Please run "sveltegen config" to specify a path.');h(e);let p=A("components");L(p,e,o,s),X(Q(e),c=>{let i=P(e,c),r=$(i,{encoding:"utf-8"});s.typescript||(r=_(r)),s.scss||(r=r.replace(/scss/gm,"css")),r=r.replaceAll("_name",t),R(i,r,{encoding:"utf-8"})}),u.log(C(o,e,"component"))}function ot(t,s={endpoint:!1,page:!1,scss:!1,typescript:!1}){if(!f())return;let o=t.split(/\\\\|\//gm).pop(),e=k(w().routes+tt+t);if(e===null)return u.err('`routes` directory is not defined. Please run "sveltegen config" to specify a path.');h(e);let p=A("routes");L(p,e,o,s),Q(e).forEach(c=>{let i=P(e,c),r=$(i,{encoding:"utf-8"});if(i.includes(".json")&&!s.endpoint||i.endsWith(".svelte")&&!s.page){K(i);return}s.typescript?s.typescript&&(r=M(r)):(r=_(r),r=r.replace(/\t\n+|(?<=>)|\n$/gm,"")),s.scss||(i.replace(".scss",".css"),r=r.replace(/scss/gm,"css")),r=r.replaceAll("_name",t),R(i,r,{encoding:"utf-8"})}),u.log(C(o,e,"component"))}function et(t,s){if(!f())return;let o=t.split(/\\\\|\//gm).pop(),e=k(w().actions);if(e===null)return u.err('`actions` directory is not defined. Please run "sveltegen config" to specify a path.');h(e);let p=A("actions");L(p,e,o,s);let c=P(e,o+(s.typescript?".ts":".js"));setImmediate(()=>{let i=$(c,{encoding:"utf-8"});s.typescript||(i=_(i)),i=i.replaceAll("_name",t),R(c,i,{encoding:"utf-8"})}),u.log(C(o,c,"action"))}import{readFileSync as Pt}from"fs";import{get as Et}from"https";async function j(t,s,n={method:"GET"}){let o=new URL(t);return new Promise((e,p)=>{let c="";Et(o,i=>{let r=i.statusCode;r>=400?p({code:r,message:i.statusMessage}):r>=300?j(i.headers.location).then(e,p):(i.setEncoding("utf-8"),i.on("data",m=>{c+=m}).on("end",()=>{e(JSON.parse(c))}))})})}var $t=(t,s)=>l`> `+`Installed: ${t}
37-
`+l`> `+`Latest: ${s}
38-
`,Rt=(t,s,n)=>l`\n> `+F(D`UPDATE AVAILABLE!`+` Run \`npm i -g ${t}@latest\` to install ${t} ${n}
39-
`+s);async function nt(t,s){let o=(await j(`https://registry.npmjs.org/${t}/latest`,"json",{method:"GET"}))?.version||null;if(o===null)throw new Error("An error has occured when checking for the latest package version.");let e=()=>console.log(Rt(t,$t(s,o),o));s<o&&(process.on("SIGINT",()=>e()),process.on("exit",()=>e()),process.on("uncaughtException",()=>e()))}var kt=Pt(new URL("../package.json",import.meta.url),{encoding:"utf-8"}),{version:rt,name:Lt}=JSON.parse(kt);nt(Lt,rt);var b=new v("sveltegen",rt);b.command("component",["<name>"],{alias:"c"}).describe("Creates a new component").option("-s, --scss","Creates a new component using SCSS for styles").option("-t, --typescript","Creates a new component using Typescript").example("sveltegen c Button -t","creates a `Button` component with TS/CSS").example("sveltegen component Article","creates an `Article` component with JS/CSS").action(st);b.command("action",["<name>"],{alias:"a"}).describe("Creates a new action").option("-t, --typescript","Creates a new component using Typescript").action(et);b.command("route",["<name>"],{alias:"r"}).describe("Creates a new route").option("-t, --typescript","Creates a new route using TypeScript").option("-p, --page","Creates a page-only route").option("-e, --endpoint","Creates an endpoint-only route").option("-s, --scss","Adds SCSS for styles").action(ot);b.command("config",["<action>"],{isDefault:!0}).action((t,s)=>{H(!!s?.global)}).option("-g, --global","Configures Sveltegen globally").example;b.parse(process.argv.slice(2));
36+
`)}}usage(){}};import{readdirSync as P,readFileSync as k,writeFileSync as L}from"fs";import{join as N,resolve as B,sep as tt}from"path";import{copyFileSync as Ct,existsSync as K,mkdirSync as _t,readdirSync as vt,readFileSync as wt,rmdirSync as Tt,rmSync as Nt,statSync as St}from"fs";import{dirname as At,join as z,resolve as Z}from"path";function h(t){try{_t(t,{recursive:!0})}catch(o){if(o.code==="EEXIST")return;throw o}}function X(t){(Nt||Tt)(t,{recursive:!0,force:!0})}function Ot(t){return t}function $(t,o,n=Ot){if(!K(t))return;St(t).isDirectory()?vt(t).forEach(e=>{$(z(t,e),z(o,n(e)))}):(h(At(o)),Ct(t,o))}var w=t=>Z("./templates/"+t),Q=Z("./.sveltegen.json"),f=()=>K(Q),T=()=>{if(f())return JSON.parse(wt(Q))};function R(t,o){let n=t.length,s=-1;for(;++s<n;)o(t[s],s,t);s=null}var j=(t,o,n,s)=>$(`${t}`,o,e=>(e=e.replaceAll("_name",n),s.typescript||(e=e.replace(".ts",".js")),s?.scss||(e=e.replace(".scss",".css")),e));function ot(t,o={scss:!1,typescript:!1}){if(!f())return;let s=t.split(/\\\\|\//gm).pop(),e=B(T().components+tt+t);if(e===null)return u.err('`components` directory is not defined. Please run "sveltegen config" to specify a path.');h(e);let a=w("components");j(a,e,s,o),R(P(e),c=>{let i=N(e,c),r=k(i,{encoding:"utf-8"});o.typescript||(r=_(r)),o.scss||(r=r.replace(/scss/gm,"css")),r=r.replaceAll("_name",t),L(i,r,{encoding:"utf-8"})}),u.log(C(s,e,"component"))}function st(t,o={endpoint:!1,page:!1,scss:!1,typescript:!1}){if(!f())return;let s=t.split(/\\\\|\//gm).pop(),e=B(T().routes+tt+t);if(e===null)return u.err('`routes` directory is not defined. Please run "sveltegen config" to specify a path.');h(e);let a=w("routes");j(a,e,s,o),P(e).forEach(c=>{let i=N(e,c),r=k(i,{encoding:"utf-8"});if(i.includes(".json")&&!o.endpoint||i.endsWith(".svelte")&&!o.page){X(i);return}o.typescript?o.typescript&&(r=Y(r)):(r=_(r),r=r.replace(/\t\n+|(?<=>)|\n$/gm,"")),o.scss||(i.replace(".scss",".css"),r=r.replace(/scss/gm,"css")),r=r.replaceAll("_name",t),L(i,r,{encoding:"utf-8"})}),u.log(C(s,e,"component"))}function et(t,o){if(!f())return;let s=t.split(/\\\\|\//gm).pop(),e=B(T().actions);if(e===null)return u.err('`actions` directory is not defined. Please run "sveltegen config" to specify a path.');h(e);let a=w("actions");j(a,e,s,o);let c=N(e,s);R(P(e),i=>{let r=N(e,i),p=k(r,{encoding:"utf-8"});o.typescript||(p=_(p)),p=p.replaceAll("_name",t),L(r,p,{encoding:"utf-8"})}),u.log(C(s,c,"action"))}import{readFileSync as Pt}from"fs";import{get as Et}from"https";async function I(t,o,n={method:"GET"}){let s=new URL(t);return new Promise((e,a)=>{let c="";Et(s,i=>{let r=i.statusCode;r>=400?a({code:r,message:i.statusMessage}):r>=300?I(i.headers.location).then(e,a):(i.setEncoding("utf-8"),i.on("data",p=>{c+=p}).on("end",()=>{e(JSON.parse(c))}))})})}var $t=(t,o)=>m`> `+`Installed: ${t}
37+
`+m`> `+`Latest: ${o}
38+
`,Rt=(t,o,n)=>m`\n> `+U(J`UPDATE AVAILABLE!`+` Run \`npm i -g ${t}@latest\` to install ${t} ${n}
39+
`+o);async function nt(t,o){let s=(await I(`https://registry.npmjs.org/${t}/latest`,"json",{method:"GET"}))?.version||null;if(s===null)throw new Error("An error has occured when checking for the latest package version.");let e=()=>console.log(Rt(t,$t(o,s),s));o<s&&(process.on("SIGINT",()=>e()),process.on("exit",()=>e()),process.on("uncaughtException",()=>e()))}var kt=Pt(new URL("../package.json",import.meta.url),{encoding:"utf-8"}),{version:rt,name:Lt}=JSON.parse(kt);nt(Lt,rt);var b=new v("sveltegen",rt);b.command("component",["<name>"],{alias:"c"}).describe("Creates a new component").option("-s, --scss","Creates a new component using SCSS for styles").option("-t, --typescript","Creates a new component using Typescript").example("sveltegen c Button -t","creates a `Button` component with TS/CSS").example("sveltegen component Article","creates an `Article` component with JS/CSS").action(ot);b.command("action",["<name>"],{alias:"a"}).describe("Creates a new action").option("-t, --typescript","Creates a new component using Typescript").action(et);b.command("route",["<name>"],{alias:"r"}).describe("Creates a new route").option("-t, --typescript","Creates a new route using TypeScript").option("-p, --page","Creates a page-only route").option("-e, --endpoint","Creates an endpoint-only route").option("-s, --scss","Adds SCSS for styles").action(st);b.command("config",["<action>"],{isDefault:!0}).action((t,o)=>{V(!!o?.global)}).option("-g, --global","Configures Sveltegen globally").example;b.parse(process.argv.slice(2));

examples/actions/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
### Breakdown of Actions
22

33
```
4-
Click // TypeScript
4+
Click
55
6-
Tooltip // JS
6+
Tooltip
77
```
88

0 commit comments

Comments
 (0)