@ripple-ts/cli 0.3.8 → 0.3.9
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/index.js +3 -13
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -132,19 +132,8 @@ Filtered results for: ${this.inputValue?this.inputValue:n.gray(`Enter something
|
|
|
132
132
|
`)}this.#f(()=>this.#a.write(n))===!1&&this.#a.isTTY&&(this.#l=()=>{this.#l=void 0,this.#p()},this.#a.once(`drain`,this.#l)),this.#e=this.#S(n,r)}finally{t&&this.#f(()=>this.#a.write(`\x1B[?2026l`))}return this}start(e){if(e&&(this.text=e),this.isSilent)return this;if(!this.isEnabled){let e=this.text?`-`:``,t=` `.repeat(this.#r.indent)+this.#v(e,this.text,this.#r.prefixText,this.#r.suffixText);return t.trim()!==``&&this.#f(()=>this.#a.write(t+`
|
|
133
133
|
`)),this}return this.isSpinning?this:(this.#r.hideCursor&&U.hide(this.#a),this.#r.discardStdin&&h.stdin.isTTY&&(Yr.start(),this.#d=!0),this.#w(),this.render(),this.#o=setInterval(this.render.bind(this),this.interval),this)}stop(){return clearInterval(this.#o),this.#o=void 0,this.#t=-1,this.#n=0,this.#_(),this.#T(),this.#l&&=(this.#a.removeListener(`drain`,this.#l),void 0),this.isEnabled&&(this.clear(),this.#r.hideCursor&&U.show(this.#a)),this.#d&&(this.#d=!1,Yr.stop()),this}succeed(e){return this.stopAndPersist({symbol:ur,text:e})}fail(e){return this.stopAndPersist({symbol:dr,text:e})}warn(e){return this.stopAndPersist({symbol:K,text:e})}info(e){return this.stopAndPersist({symbol:lr,text:e})}stopAndPersist(e={}){if(this.isSilent)return this;let t=e.symbol??` `,n=e.text??this.text,r=e.prefixText??this.#r.prefixText,i=e.suffixText??this.#r.suffixText,a=this.#v(t,n,r,i)+`
|
|
134
134
|
`;return this.stop(),this.#f(()=>this.#a.write(a)),this}};function Qr(e){return new Zr(e)}async function $r({projectName:e,projectPath:n,templateName:r,packageManager:i=`npm`,gitInit:a=!1,stylingFramework:o=`vanilla`}){console.log(Ee(`Creating project: ${e}`)),console.log(Ee(`Template: ${r}`)),console.log(Ee(`Package manager: ${i}`)),console.log();let l,d=!1,f=Qr(`Preparing template...`).start();try{if(Re()){if(l=Le(r),!c(l))throw Error(`Local template "${r}" not found at ${l}`);f.succeed(`Local template located`)}else f.text=`Downloading template from GitHub...`,l=await Ie(r),d=!0,f.succeed(`Template downloaded`)}catch(e){throw f.fail(`Failed to prepare template`),e}let m=Qr(`Creating project directory...`).start();try{u(n,{recursive:!0}),m.succeed(`Project directory created`)}catch(e){throw m.fail(`Failed to create project directory`),d&&p(l,{recursive:!0,force:!0}),e}let h=Qr(`Copying template files...`).start();try{s(l,n,{recursive:!0,filter:e=>{let t=e.replace(l,``);return!t.includes(`node_modules`)&&!t.includes(`package-lock.json`)&&!t.includes(`yarn.lock`)&&!t.includes(`pnpm-lock.yaml`)&&!t.includes(`bun.lock`)}}),h.succeed(`Template files copied`)}catch(e){throw h.fail(`Failed to copy template files`),d&&p(l,{recursive:!0,force:!0}),e}let g=Qr(`Configuring package.json...`).start();try{ei(n,e,i,o),g.succeed(`Package.json configured`)}catch(e){throw g.fail(`Failed to configure package.json`),d&&p(l,{recursive:!0,force:!0}),e}let _=Qr(`Configuring styling framework...`).start();try{ti(n,o),_.succeed(`Styling framework configured`)}catch(e){throw _.fail(`Failed to configure styling framework`),d&&p(l,{recursive:!0,force:!0}),e}if(a){let e=Qr(`Initializing Git repository...`).start();try{t(`git init`,{cwd:n,stdio:`ignore`}),e.succeed(`Git repository initialized`)}catch{e.warn(`Git initialization failed (optional)`)}}if(d)try{p(l,{recursive:!0,force:!0})}catch{}console.log(),console.log(Oe(`✓ Project created successfully!`))}function ei(e,t,r,a){let o=i(e,`package.json`);if(!c(o))throw Error(`package.json not found in template`);let s=JSON.parse(d(o,`utf-8`));s.name=n(t),s.version===`0.0.0`&&(s.version=`1.0.0`),s.description=`A Ripple application created with create-ripple`,r!==`npm`&&(s.packageManager=ii(r)),a===`tailwind`?s.devDependencies={...s.devDependencies,tailwindcss:`^4.1.12`,"@tailwindcss/vite":`^4.1.12`}:a===`bootstrap`&&(s.dependencies={...s.dependencies,bootstrap:`^5.3.0`}),ni(s),ri(s),m(o,JSON.stringify(s,null,2)+`
|
|
135
|
-
`)}function ti(e,t){if(t===`tailwind`){m(i(e,`
|
|
136
|
-
|
|
137
|
-
content: [
|
|
138
|
-
"./index.html",
|
|
139
|
-
"./src/**/*.{ts,ripple}",
|
|
140
|
-
],
|
|
141
|
-
theme: {
|
|
142
|
-
extend: {},
|
|
143
|
-
},
|
|
144
|
-
plugins: []
|
|
145
|
-
} satisfies Config
|
|
146
|
-
`),m(i(e,`src`,`index.css`),`@import "tailwindcss";
|
|
147
|
-
@config "../tailwind.config.ts";`);let t=`import './index.css';
|
|
135
|
+
`)}function ti(e,t){if(t===`tailwind`){m(i(e,`src`,`index.css`),`@import "tailwindcss";
|
|
136
|
+
`);let t=`import './index.css';
|
|
148
137
|
`+d(i(e,`src`,`index.ts`),`utf-8`);m(i(e,`src`,`index.ts`),t),c(i(e,`vite.config.js`))&&p(i(e,`vite.config.js`)),m(i(e,`vite.config.js`),`import { defineConfig } from 'vite';
|
|
149
138
|
import { ripple } from '@ripple-ts/vite-plugin';
|
|
150
139
|
import tailwindcss from '@tailwindcss/vite';
|
|
@@ -155,5 +144,6 @@ export default defineConfig({
|
|
|
155
144
|
port: 3000
|
|
156
145
|
}
|
|
157
146
|
});
|
|
147
|
+
`);let n=i(e,`.vscode`);u(n,{recursive:!0});let r=JSON.stringify({"tailwindCSS.includeLanguages":{ripple:`html`},"tailwindCSS.classAttributes":[`class`,`className`],"files.associations":{"*.ripple":`ripple`},"editor.quickSuggestions":{strings:!0}},null,` `);m(i(n,`settings.json`),r+`
|
|
158
148
|
`)}else if(t===`bootstrap`){let t=`import 'bootstrap/dist/css/bootstrap.min.css';
|
|
159
149
|
`+d(i(e,`src`,`index.ts`),`utf-8`);m(i(e,`src`,`index.ts`),t)}}function ni(e){let t={ripple:`latest`,"@ripple-ts/vite-plugin":`latest`,"@ripple-ts/prettier-plugin":`latest`,"@ripple-ts/eslint-plugin":`latest`,"@ripple-ts/eslint-parser":`latest`,"@ripple-ts/typescript-plugin":`latest`};if(e.dependencies)for(let[n,r]of Object.entries(t))e.dependencies[n]&&(e.dependencies[n]=r);if(e.devDependencies)for(let[n,r]of Object.entries(t))e.devDependencies[n]&&(e.devDependencies[n]=r)}function ri(e){e.scripts&&(e.scripts.format&&(e.scripts.format=`prettier --write .`),e.scripts[`format:check`]&&(e.scripts[`format:check`]=`prettier --check .`))}function ii(e){return{yarn:`yarn@4.0.0`,pnpm:`pnpm@9.0.0`,bun:`bun@1.3.0`}[e]||e}function ai(e,t){let n=[`.DS_Store`,`.git`,`.gitattributes`,`.gitignore`,`.gitlab-ci.yml`,`.hg`,`.hgcheck`,`.hgignore`,`.idea`,`.npmignore`,`.travis.yml`,`LICENSE`,`Thumbs.db`,`docs`,`mkdocs.yml`,`npm-debug.log`,`yarn-debug.log`,`yarn-error.log`,`yarnrc.yml`,`.yarn`],r=f(e).filter(e=>!n.includes(e)&&!/\.iml$/.test(e));if(r.length>0){console.log(`The directory ${Oe(t)} contains files that could conflict:`),console.log();for(let t of r)try{l(i(e,t)).isDirectory()?console.log(` ${A(t)}/`):console.log(` ${t}`)}catch{console.log(` ${t}`)}return console.log(),console.log(`Either try using a new directory name, or remove the files listed above.`),console.log(),!1}return!0}function oi(){let e=process.env.npm_config_user_agent;if(e){if(e.startsWith(`pnpm/`))return`pnpm`;if(e.startsWith(`yarn/`))return`yarn`;if(e.startsWith(`bun/`))return`bun`;if(e.startsWith(`npm/`))return`npm`}let t=process.env.npm_execpath;if(t){let e=t.toLowerCase().replace(/\\/g,`/`);if(e.includes(`pnpm`))return`pnpm`;if(e.includes(`yarn`))return`yarn`;if(e.includes(`bun`))return`bun`}return process.env.PNPM_HOME||process.env.PNPM_SCRIPT_SRC_DIR?`pnpm`:process.env.YARN_WRAP_OUTPUT||process.env.npm_config_yarn?`yarn`:process.env.BUN_INSTALL?`bun`:`npm`}async function si(e,t){if(console.log(),console.log(ke(`🌊 Welcome to Create Ripple App!`)),console.log(Ee(`Let's create a new Ripple application`)),console.log(),!e)e=await Jt();else{let t=Ae(e);t.valid||(console.error(De(`✖ ${t.message}`)),process.exit(1))}let r=o(process.cwd(),e);c(r)&&!ai(r,n(r))&&process.exit(1);let i=t.template;i?Fe(i)||(console.error(De(`✖ Template "${i}" not found`)),console.error(`Available templates: ${M().join(`, `)}`),process.exit(1)):i=await Yt();let a,s=oi();a=!t.packageManager&&!t.yes?await Xt(s):t.packageManager||s;let l;l=t.git===!1?!1:t.yes?!0:await Zt();let u=`vanilla`;t.yes||(u=await Qt()),console.log(),console.log(`Creating Ripple app in ${Oe(r)}...`),console.log();try{await $r({projectName:e,projectPath:r,templateName:i,packageManager:a,gitInit:l,stylingFramework:u}),ci(r,a),process.exit(0)}catch(e){let t=e;console.error(De(`✖ Failed to create project:`)),console.error(t.message),process.exit(1)}}function ci(e,t){let n=li(t),r=ui(t),i=a(process.cwd(),e);console.log(),console.log(Oe(`🎉 Success! Your Ripple app is ready to go.`)),console.log(),console.log(Te(`Next steps:`)),console.log(),console.log(` ${Oe(`1.`)} ${Ee(`cd`)} ${i}`),console.log(` ${Oe(`2.`)} ${Ee(n)}`),console.log(` ${Oe(`3.`)} ${Ee(r)}`),console.log(` ${Oe(`4.`)} visit: ${ke(`http://localhost:3000`)}`),console.log(` ${Oe(`5.`)} make changes in the: ${ke(`src/`)} directory`),console.log(),console.log(Te(`Need help? Check out:`)),console.log(` ${Ee(`•`)} README.md in your project folder`),console.log(` ${Ee(`•`)} Documentation: ${ke(`https://www.ripple-ts.com/docs/introduction`)}`),console.log(),console.log(`Happy coding! 🌊`),console.log()}function li(e){return{npm:`npm install`,yarn:`yarn install`,pnpm:`pnpm install`,bun:`bun install`}[e]||`npm install`}function ui(e){return{npm:`npm run dev`,yarn:`yarn dev`,pnpm:`pnpm dev`,bun:`bun dev`}[e]||`npm run dev`}const di=r(g(import.meta.url)),fi=JSON.parse(d(i(di,`../package.json`),`utf-8`)),pi=new ge;pi.name(`create-ripple`).description(`Interactive CLI tool for creating Ripple applications`).version(fi.version).helpOption(`-h, --help`,`Display help for command`),pi.argument(`[project-name]`,`Name of the project to create`).option(`-t, --template <template>`,`Template to use (default: basic)`).option(`-p, --package-manager <pm>`,`Package manager to use (npm, yarn, pnpm, bun)`).option(`--no-git`,`Skip Git repository initialization`).option(`-y, --yes`,`Skip all prompts and use defaults`).action(async(e,t)=>{try{await si(e,t)}catch(e){let t=e;console.error(De(`✖ Unexpected error:`)),console.error(t.message),process.exit(1)}}),process.on(`unhandledRejection`,e=>{console.error(De(`✖ Unhandled error:`)),console.error(e),process.exit(1)}),process.on(`SIGINT`,()=>{console.log(),console.log(De(`✖ Operation cancelled`)),process.exit(1)}),pi.parse();export{};
|