create-pluto 0.2.0 → 0.3.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/index.mjs +2 -2
- package/package.json +7 -7
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import e from"node:fs";import t from"node:path";import{cancel as n,confirm as r,isCancel as i,log as a,select as o,spinner as s,text as c}from"@clack/prompts";import{downloadTemplate as l}from"giget";
|
|
2
|
-
`,Object.entries(
|
|
1
|
+
import e from"node:fs";import t from"node:path";import{cancel as n,confirm as r,isCancel as i,log as a,select as o,spinner as s,text as c}from"@clack/prompts";import{downloadTemplate as l}from"giget";const u=/^postgres(?:ql)?:\/\//i;function d(e){return URL.canParse(e)}function f(e){return u.test(e)}async function p(){let e,t,r;for(;!e;){let t=await c({message:`Type/Paste your Supabase URL:`});if(i(t)&&(n(`Operation cancelled.`),process.exit(0)),!t||!d(t)){a.error(`Enter a valid Supabase URL, like https://xxxxx.supabase.co.`);continue}e=t}for(;!t;){let e=await c({message:`Type/Paste your Supabase Key:`});if(i(e)&&(n(`Operation cancelled.`),process.exit(0)),!e){a.error(`Supabase Key is required.`);continue}t=e}for(a.info(`Now find your database connection string: open your Supabase project, go to Project Settings > Database > Connection string, and copy the URI (the pooler connection works too).`);!r;){let e=await c({message:`Type/Paste your Supabase database connection string:`});if(i(e)&&(n(`Operation cancelled.`),process.exit(0)),!e||!f(e)){a.error(`Enter a valid Postgres connection string, starting with postgres:// or postgresql://.`);continue}r=e}return{supabaseUrl:e,supabaseKey:t,databaseUrl:r}}function m(e,t,n){let r={};return r.SUPABASE_URL=e?.toString()??``,r.SUPABASE_KEY=t?.toString()??``,r.DATABASE_URL=n?.toString()??``,{envVars:r}}const h=process.cwd(),g={blue:e=>`\x1B[34m${e}\x1B[0m`,green:e=>`\x1B[32m${e}\x1B[0m`},_={databases:[{value:`supabase`,label:`Supabase`,hint:`Hosted Postgres Database`}],templates:[{value:`shop`,label:`Shop (e-commerce)`,hint:`A full-featured online store template`},{value:`blog`,label:`Blog`,hint:`A simple blog template with a rich text editor`}]};function v(e){let t={};for(let n=0;n<e.length;n+=1){let r=e[n];if(r===`-t`||r===`--template`){t.templateShortcut=e[n+1],n+=1;continue}if(r?.startsWith(`--template=`)){t.templateShortcut=r.split(`=`)[1];continue}!r?.startsWith(`-`)&&!t.projectDir&&(t.projectDir=r)}return t}function y(e){let[t,n]=e.split(`-`,2),r=_.databases.some(e=>e.value===t),i=_.templates.some(e=>e.value===n);if(!r||!i){let t=_.databases.flatMap(e=>_.templates.map(t=>`${e.value}-${t.value}`));a.error(`Unknown template \"${e}\". Available options: ${t.join(`, `)}`),process.exit(1)}return{databaseProvider:t,templateChoice:n}}const b=v(process.argv.slice(2)),x=b.templateShortcut?y(b.templateShortcut):void 0,S=b.projectDir?b.projectDir:await c({message:`Where do you want to create your Pluto project?`,placeholder:`./my-pluto-project`,defaultValue:`my-pluto-project`});i(S)&&(n(`Operation cancelled.`),process.exit(0));const C=t.resolve(h,S);e.existsSync(C)||e.mkdirSync(C,{recursive:!0});const w=await c({message:`Website title:`,placeholder:`My Awesome Website`,defaultValue:`My Awesome Website`});i(w)&&(n(`Operation cancelled.`),process.exit(0));const T=x?x.databaseProvider:await o({message:`Pick a database provider.`,options:_.databases});i(T)&&(n(`Operation cancelled.`),process.exit(0));let E,D,O;if(T===`supabase`){a.warn(`You must have a Supabase project set up. If you do not have one, please create it at:\n${g.blue(`https://database.new/`)}.`);let{supabaseUrl:e,supabaseKey:t,databaseUrl:n}=await p();(!e||!t||!n)&&(a.error(`Supabase setup failed.`),process.exit(1)),E=e,D=t,O=n}const k=s();e.existsSync(`${h}/nuxt.config.ts`)&&(await r({message:`Nuxt project detected. Do you want to add Pluto environment variables?`})||process.exit(0));const A=x?x.templateChoice:await o({message:`Select a template to use. You can add more layers as needed.`,options:_.templates});i(A)&&(n(`Operation cancelled.`),process.exit(0)),e.readdirSync(C).length>0&&(await r({message:`The folder ${g.green(S)} is not empty. Do you want to continue and potentially overwrite existing files?`})||(n(`Operation cancelled.`),process.exit(0))),k.start(`Downloading Pluto template...`);const{source:j}=await l(`gh:plutocms/pluto-${T}-${A}-template`,{dir:C,force:!0});a.info(`Template downloaded from ${g.green(j)}`);const M=t.resolve(C,`.env`),N={WEBSITE_NAME:w?.toString()??``};if(T===`supabase`){let{envVars:e}=m(E,D,O);Object.assign(N,e)}try{let t=``;e.existsSync(M)?(t=e.readFileSync(M,`utf-8`),Object.entries(N).forEach(([e,n])=>{let r=RegExp(`^${e}=.*$`,`m`);r.test(t)?t=t.replace(r,`${e}="${n}"`):t+=`\n${e}="${n}"`})):(t=`# Pluto Configurations
|
|
2
|
+
`,Object.entries(N).forEach(([e,n])=>{t+=`${e}="${n}"\n`})),e.writeFileSync(M,`${t.trim()}\n`)}catch(e){a.error(`Failed to write to .env file: ${e}`),process.exit(1)}k.stop(`All done!`),a.success(`Setup complete! 🎉`),a.info(`Nuxt project created in: ${g.green(S)}`);export{};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-pluto",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.3.1",
|
|
5
5
|
"description": "CLI Wizard for creating a Pluto App",
|
|
6
6
|
"author": "https://github.com/ojvribeiro",
|
|
7
7
|
"license": "MIT",
|
|
@@ -41,14 +41,14 @@
|
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
43
|
"@clack/prompts": "^0.11.0",
|
|
44
|
-
"giget": "^3.
|
|
44
|
+
"giget": "^3.3.1"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@antfu/eslint-config": "^7.
|
|
48
|
-
"@types/node": "^25.
|
|
49
|
-
"eslint": "^10.
|
|
50
|
-
"prettier": "^3.
|
|
51
|
-
"tsdown": "^0.20.
|
|
47
|
+
"@antfu/eslint-config": "^7.7.3",
|
|
48
|
+
"@types/node": "^25.9.9",
|
|
49
|
+
"eslint": "^10.12.0",
|
|
50
|
+
"prettier": "^3.9.10",
|
|
51
|
+
"tsdown": "^0.20.3",
|
|
52
52
|
"typescript": "^5.9.3"
|
|
53
53
|
},
|
|
54
54
|
"publishConfig": {
|