@xaendar/cli 0.8.0 → 0.9.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.js +3 -3
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -36,7 +36,7 @@ Reserved names are:
|
|
|
36
36
|
- not contain uppercase letters.
|
|
37
37
|
- not be a native HTML tag name.
|
|
38
38
|
- not contain the following chars: '@', '#', '$', '%', '&', '*', '!', '?', '/', '\\', '|', "'", '"', '<', '>', '='
|
|
39
|
-
`),!1)}function et(o){return V.includes(o)}import{existsSync as it,mkdirSync as nt,rmSync as st,writeFileSync as rt}from"fs";import{join as
|
|
39
|
+
`),!1)}function et(o){return V.includes(o)}import{existsSync as it,mkdirSync as nt,rmSync as st,writeFileSync as rt}from"fs";import{join as N}from"path";function w(o){return o.replace(/[-_](.)/g,(t,e)=>e.toUpperCase()).replace(/^(.)/,(t,e)=>e.toUpperCase())}function S(o,t,e,i){F(o)||process.exit(1);let n=N(t,o);i??="css",it(n)&&(e?(console.log(`Deleting "${o}"...`),st(n,{recursive:!0,force:!0}),console.log("\u2714 Component Deleted.")):(console.error(`\u2716 Directory "${o}" already exists.`),process.exit(1))),nt(n,{recursive:!0});let s=[[`${o}.xd.component.ts`,ot(o,i)],[`${o}.xd.component.html`,at(o)],[`${o}.xd.component.${i}`,lt(o)],[`${o}.xd.component.spec.ts`,ut(o)]];for(let[r,a]of s)rt(N(n,r),a,"utf8");console.log(),console.log(`\u2714 Component "${o}" generated:`);for(let[r]of s)console.log(`${o}/${r}`)}function ot(o,t){let e=w(o);return`import { BaseWebComponent, WebComponent } from '@xaendar/core';
|
|
40
40
|
|
|
41
41
|
@WebComponent({
|
|
42
42
|
selector: '${o}',
|
|
@@ -56,7 +56,7 @@ describe('${t}Component', () => {
|
|
|
56
56
|
expect(component).toBeTruthy();
|
|
57
57
|
});
|
|
58
58
|
});
|
|
59
|
-
`}function
|
|
59
|
+
`}function G(){let o=new g("generate").alias("g").description("Generate Xaendar building blocks");return o.command("component <name>").alias("c").option("-p, --path <path>","Custom path for the generated component (default: current directory)").option("-f, --force","Force generation deleting current component if already exists").description("Generate a new component (creates <name>/ folder with .ts, .html, .css, .spec.ts)").action((t,e)=>{let i=e.path||process.cwd();S(t,i,!!e.force)}),o}import{existsSync as mt,mkdirSync as J,readdirSync as dt,writeFileSync as ft}from"fs";import{resolve as k}from"path/win32";import{readFileSync as ht}from"fs";import{resolve as ct}from"path";function I(o){return`<!DOCTYPE html>
|
|
60
60
|
<html lang="en">
|
|
61
61
|
<head>
|
|
62
62
|
<meta charset="UTF-8" />
|
|
@@ -169,4 +169,4 @@ export default defineConfig({
|
|
|
169
169
|
"style": "${t}"
|
|
170
170
|
}
|
|
171
171
|
}
|
|
172
|
-
}`}function pt(){try{let o=JSON.parse(ht(ct(import.meta.filename,"..","../package.json"),"utf8"));if(!o.version)throw new Error("Unable to determine Xaendar CLI version.");return o.version}catch(o){console.error("Error reading Xaendar CLI version:",o),process.exit(1)}}function B(o){let t=pt(),e=o.name,i=`${e}-root`;return[{type:"file",name:"package.json",content:M(e,t)},{type:"file",name:"xaendar.json",content:R(e,o.style)},{type:"file",name:"vite.config.ts",content:q()},{type:"file",name:"tsconfig.json",content:U()},{type:"directory",name:"src",children:[{type:"file",name:"index.html",content:I(i)},{type:"file",name:"signals.ts",content:L()},{type:"file",name:"main.ts",content:j(i)},{type:"generateComponent",name:i}]}]}import{execSync as gt}from"child_process";function K(){return new g("new").description("Scaffold a new Xaendar project").argument("<name>","Name of the project to create").option("-p, --path <path>","Custom path for the generated project (default: current directory)").option("-s, --style <style>","CSS preprocessor to use (css, scss, less, styl)","css").action((o,t)=>{let e=_t(t.style),i=t.path||process.cwd(),n=k(i,o);Ct(n),X(B({name:o,style:e}),n,e),gt("npm i",{stdio:"inherit",cwd:n})})}function _t(o){let t=["css","scss","less","styl"];return o?(t.includes(o)||(console.error(`\u2716 Invalid style option: ${o}`),process.exit(1)),o):"css"}function Ct(o){let t=mt(o);t&&dt(o).length&&(console.error(`\u2716 Cannot create project: target directory is not empty: ${o}`),process.exit(1)),t||J(o)}function X(o,t,e){o.forEach(i=>{switch(i.type){case"file":case void 0:let n=i.content;ft(k(t,i.name),n,"utf8");break;case"directory":let s=k(t,i.name);J(s),i.children&&X(i.children,s,e);break;case"generateComponent":S(i.name,t,!1,e);break}})}var xt=JSON.parse(Ot(bt(import.meta.filename,"..","../package.json"),"utf-8")).version;A.name("xd").description("Xaendar CLI").version(xt);A.addCommand(
|
|
172
|
+
}`}function pt(){try{let o=JSON.parse(ht(ct(import.meta.filename,"..","../package.json"),"utf8"));if(!o.version)throw new Error("Unable to determine Xaendar CLI version.");return o.version}catch(o){console.error("Error reading Xaendar CLI version:",o),process.exit(1)}}function B(o){let t=pt(),e=o.name,i=`${e}-root`;return[{type:"file",name:"package.json",content:M(e,t)},{type:"file",name:"xaendar.json",content:R(e,o.style)},{type:"file",name:"vite.config.ts",content:q()},{type:"file",name:"tsconfig.json",content:U()},{type:"directory",name:"src",children:[{type:"file",name:"index.html",content:I(i)},{type:"file",name:"signals.ts",content:L()},{type:"file",name:"main.ts",content:j(i)},{type:"generateComponent",name:i}]}]}import{execSync as gt}from"child_process";function K(){return new g("new").description("Scaffold a new Xaendar project").argument("<name>","Name of the project to create").option("-p, --path <path>","Custom path for the generated project (default: current directory)").option("-s, --style <style>","CSS preprocessor to use (css, scss, less, styl)","css").action((o,t)=>{let e=_t(t.style),i=t.path||process.cwd(),n=k(i,o);Ct(n),X(B({name:o,style:e}),n,e),gt("npm i",{stdio:"inherit",cwd:n})})}function _t(o){let t=["css","scss","less","styl"];return o?(t.includes(o)||(console.error(`\u2716 Invalid style option: ${o}`),process.exit(1)),o):"css"}function Ct(o){let t=mt(o);t&&dt(o).length&&(console.error(`\u2716 Cannot create project: target directory is not empty: ${o}`),process.exit(1)),t||J(o)}function X(o,t,e){o.forEach(i=>{switch(i.type){case"file":case void 0:let n=i.content;ft(k(t,i.name),n,"utf8");break;case"directory":let s=k(t,i.name);J(s),i.children&&X(i.children,s,e);break;case"generateComponent":S(i.name,t,!1,e);break}})}var xt=JSON.parse(Ot(bt(import.meta.filename,"..","../package.json"),"utf-8")).version;A.name("xd").description("Xaendar CLI").version(xt);A.addCommand(G());A.addCommand(K());A.parse();
|