@tixyel/cli 3.1.0 → 3.1.1
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/api.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./workspace-
|
|
1
|
+
import{t as e}from"./workspace-CsM91FG0.mjs";function t(t){return e.Service.mergeConfig(t)}export{t as default,t as defineConfig};
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{n as e,t}from"./workspace-
|
|
2
|
+
import{n as e,t}from"./workspace-CsM91FG0.mjs";import{Command as n}from"commander";import{createRequire as r}from"module";import{existsSync as i,readFileSync as a,readdirSync as o,unlink as s}from"fs";import c,{basename as l,join as u,relative as d,resolve as f}from"path";import{writeFile as p}from"fs/promises";import m from"inquirer";import{exec as h}from"child_process";import g from"ora";import _ from"cli-spinners";const v=new n;v.name(`tixyel cli`).description(`CLI tool for streamelements widgets made by Tixyel`).version((()=>{try{let{version:e}=r(import.meta.url)(`../package.json`);return e??`dev`}catch{return`dev`}})());const y=[`@tixyel/cli`,`@tixyel/streamelements`,`comfy.js`,`motion`,`typescript`,`@types/node`,`@types/jquery`,`lottie-web`],b={npm:(e,t)=>`npm install ${e.join(` `)}${t?` --no-cache`:``}`,yarn:(e,t)=>`yarn add ${e.join(` `)}${t?` --no-cache`:``}`,pnpm:(e,t)=>`pnpm add ${e.join(` `)}${t?` --no-cache`:``}`,bun:(e,t)=>`bun add ${e.join(` `)}${t?` --no-cache`:``}`};function x(){let e=process.env.npm_config_user_agent;if(e){if(e.includes(`yarn`))return`yarn`;if(e.includes(`pnpm`))return`pnpm`;if(e.includes(`bun`))return`bun`}return`npm`}v.command(`init`).aliases([`initialize`,`start`,`i`,`setup`]).description(`Initialize a new workspace for widget development`).option(`-f --force`,`Force initialization by overwriting existing configuration without confirmation`).action(async(e={})=>{let n=g({color:`magenta`,text:`Checking for existing workspace configuration...`,spinner:_.dotsCircle}).start(),r=await new t.Service({path:process.cwd(),spinner:n}).loadConfig().catch(e=>{n.fail(`Failed to load workspace configuration`),process.exit(1)});if(r&&!e.force){n.stop();let{force:t}=await m.prompt({type:`confirm`,name:`force`,message:`A workspace configuration already exists. Do you want to overwrite it?`,default:!1});if(!t){console.log(`Existing workspace configuration found. Initialization aborted.`);return}e.force=!0,n.start()}if(!r||r&&e.force){let t=f(process.cwd(),`tixyel.config.ts`),a=`import { defineConfig } from '@tixyel/cli/api';
|
|
3
3
|
|
|
4
4
|
export default defineConfig({
|
|
5
5
|
search: {
|
|
@@ -12,7 +12,7 @@ import{existsSync as e,mkdirSync as t,readFileSync as n,readdirSync as r,unlinkS
|
|
|
12
12
|
`}for(let e of Object.keys(a))s.add(e);c.has(`html`)?r=r+=`<style>${l.trim()}</style>`:r+=l.trim(),c.add(`css`)}}if(o([`typescript`,`ts`],[`.ts`,`.tsx`,`.cts`,`.mts`])){let n=a.filter(e=>e.endsWith(`.ts`)&&!s.has(e));if(n.length){i&&console.log(` - Processing TypeScript for ${this.config.name} [${t}, ${n.join(`, `)}]...`);let a=v(e,n),o=``;for await(let[e,t]of Object.entries(a))try{let e=g(t,{loader:`ts`,target:`es2020`,format:`cjs`});o+=e.code+`
|
|
13
13
|
`}catch(e){throw console.warn(` ⚠️ Failed to compile TypeScript: ${e}`),e}finally{s.add(e)}let l=E.obfuscate(o.trim(),this.workspace.config.data.build?.obfuscation?.javascript);c.has(`html`)?r=r+=`<script>${l.getObfuscatedCode()}<\/script>\n`:r+=l.getObfuscatedCode()+`
|
|
14
14
|
`,c.add(`typescript`)}}if(o([`script`,`js`,`javascript`],[`.js`,`.mjs`,`.cjs`,`.jsx`])){let n=a.filter(e=>e.endsWith(`.js`)&&!s.has(e));if(n.length){i&&console.log(` - Processing JavaScript for ${this.config.name} [${t}, ${n.join(`, `)}]...`);let a=v(e,n),o=``;for await(let[e,t]of Object.entries(a)){let n=E.obfuscate(t,this.workspace.config.data.build?.obfuscation?.javascript);o+=n.getObfuscatedCode()+`
|
|
15
|
-
`,s.add(e)}c.has(`html`)?r=r+=`<script>${o.trim()}<\/script>`:r+=o.trim(),c.add(`script`)}}if(o([`fields`,`fielddata`,`fieldData`,`cf`,`customfields`],[`.json`,`.jsonc`])){let n=a.filter(e=>(e.endsWith(`.json`)||e.endsWith(`.jsonc`))&&!s.has(e));if(n.length){i&&console.log(` - Processing JSON for ${this.config.name} [${t}, ${n.join(`, `)}]...`);let a=v(e,n),o={};for await(let[e,t]of Object.entries(a)){try{let e=y(t),n=JSON.parse(JSON.stringify(e));Object.assign(o,n)}catch(e){throw console.warn(` ⚠️ Failed to parse fields JSON: ${e}`),e}s.add(e)}
|
|
15
|
+
`,s.add(e)}c.has(`html`)?r=r+=`<script>${o.trim()}<\/script>`:r+=o.trim(),c.add(`script`)}}if(o([`fields`,`fielddata`,`fieldData`,`cf`,`customfields`],[`.json`,`.jsonc`])){let n=a.filter(e=>(e.endsWith(`.json`)||e.endsWith(`.jsonc`))&&!s.has(e));if(n.length){i&&console.log(` - Processing JSON for ${this.config.name} [${t}, ${n.join(`, `)}]...`);let a=v(e,n),o={};for await(let[e,t]of Object.entries(a)){try{let e=y(t),n=JSON.parse(JSON.stringify(e));Object.assign(o,n)}catch(e){throw console.warn(` ⚠️ Failed to parse fields JSON: ${e}`),e}s.add(e)}c.has(`fields`)||(r+=JSON.stringify(o,null,2)),c.add(`fields`)}}return r.length||(i&&console.log(` - Unknown build key: ${t}, the available keys are html, css, script and fields.`),r+=``),[t,r]})));for await(let[e,t]of Object.entries(m)){let r=``,s=Array.isArray(t)?t:[t];if(s.some(e=>e.includes(`script`))?(o.has(`script`)||(r+=P.script(this)+`
|
|
16
16
|
`),o.add(`script`)):s.some(e=>e.includes(`css`))?(o.has(`css`)||(r+=P.css(this)+`
|
|
17
17
|
`),o.add(`css`)):s.some(e=>e.includes(`html`))&&(o.has(`html`)||(r+=P.html(this)+`
|
|
18
18
|
`),o.add(`html`)),typeof t==`string`)r=c[t];else if(Array.isArray(t))for await(let e of t){let t=c[e];if(t&&t.trim().length){if([`fields`,`customfields`,`cf`,`fielddata`,`fieldData`,`data`].some(t=>e.toLowerCase().includes(t.toLowerCase()))){let e=JSON.parse(r||`{}`),n=JSON.parse(t);r=JSON.stringify({...e,...n},null,2)}else r+=`
|