create-arkstack 0.17.16 → 0.17.18
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/bin/run.js +3 -3
- package/package.json +5 -5
package/bin/run.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{AbortPromptError as e,ExitPromptError as t}from"@inquirer/core";import n,{basename as r,dirname as i,join as a,relative as o}from"node:path";import{copyFile as s,cp as c,mkdir as l,readFile as u,readdir as d,rename as f,rm as p,unlink as m,writeFile as h}from"node:fs/promises";import{Logger as g,Resolver as _}from"@h3ravel/shared";import{Str as v}from"@h3ravel/support";import{chdir as y}from"node:process";import{detectPackageManager as b}from"@antfu/install-pkg";import{downloadTemplate as x}from"giget";import{existsSync as S}from"node:fs";import{spawnSync as C}from"node:child_process";import{tmpdir as w}from"node:os";import{Command as T,Kernel as E}from"@h3ravel/musket";import D from"inquirer";async function O(e){let t=n.join(e,`templates`),r=await d(e);await c(t,e,{recursive:!0}),await Promise.all(r.filter(e=>e!==`templates`).map(t=>p(n.join(e,t),{recursive:!0,force:!0}))),await p(t,{recursive:!0,force:!0})}async function k(e,t){let r=await d(e);for(let i of r)i
|
|
2
|
+
import{AbortPromptError as e,ExitPromptError as t}from"@inquirer/core";import n,{basename as r,dirname as i,join as a,relative as o}from"node:path";import{copyFile as s,cp as c,mkdir as l,readFile as u,readdir as d,rename as f,rm as p,unlink as m,writeFile as h}from"node:fs/promises";import{Logger as g,Resolver as _}from"@h3ravel/shared";import{Str as v}from"@h3ravel/support";import{chdir as y}from"node:process";import{detectPackageManager as b}from"@antfu/install-pkg";import{downloadTemplate as x}from"giget";import{existsSync as S}from"node:fs";import{spawnSync as C}from"node:child_process";import{tmpdir as w}from"node:os";import{Command as T,Kernel as E}from"@h3ravel/musket";import D from"inquirer";async function O(e){let t=n.join(e,`templates`),r=await d(e);await c(t,e,{recursive:!0}),await Promise.all(r.filter(e=>e!==`templates`).map(t=>p(n.join(e,t),{recursive:!0,force:!0}))),await p(t,{recursive:!0,force:!0})}async function k(e,t){let r=await d(e);for(let i of r){if(i===t)continue;let r=n.join(e,i);await p(r,{recursive:!0,force:!0})}}async function A(e,t){let r=n.isAbsolute(t)?t:n.join(process.cwd(),t),i=n.isAbsolute(e)?e:n.join(process.cwd(),e);if(!r.startsWith(i))throw Error(`Source must be inside the parent directory`);let a=await d(r);for(let e of a){let t=n.join(r,e),a=n.join(i,e);await f(t,a)}await p(r,{recursive:!0})}const j=[{name:`Express`,alias:`express`,hint:`Arkstack application running on Express`,source:`github:arkstack-hq/arkstack`},{name:`H3`,alias:`h3`,hint:`Arkstack application running on H3`,source:`github:arkstack-hq/arkstack`}],M=[{name:`Lean`,hint:`A minimal Arkstack application running on {template}`,lean:!0},{name:`Full`,hint:`Full Arkstack experience on {template}`,lean:!1}],N={"@h3ravel/musket":`^2.2.13`,"@h3ravel/shared":`^2.2.7`,"@h3ravel/support":`^2.2.7`,"@h3ravel/collect.js":`^5.4.0`,"@faker-js/faker":`^10.4.0`,"@arkormx/plugin-clear-router":`^0.1.57`,"@resora/plugin-clear-router":`^1.0.72`,"@kanun-hq/plugin-file":`^0.1.12`,"@kanun-hq/plugin-phone":`^0.1.8`,arkormx:`^2.12.8`,"clear-router":`^2.9.3`,dotenv:`^17.4.2`,express:`^5.2.1`,h3:`^2.0.1-rc.22`,kysely:`^0.29.2`,kanun:`^1.2.0`,parasito:`^0.2.6`,pg:`^8.22.0`,resora:`^1.3.34`,tsdown:`^0.22.14`},P={},F=[`src/app`,`src/app/http/controllers`,`src/app/http/resources`,`src/models`,`src/app/models`,`database`,`src/routes/api.ts`,`src/database`,`src/core/database.ts`,`src/config/filesystem.ts`,`src/config/notifications.ts`,`src/config/database.ts`,`src/config/resources.ts`,`src/config/cache.ts`,`src/config/queue.ts`,`prisma`,`prisma.config.ts`,`arkorm.config.ts`,`arkormx.config.ts`,`arkorm.config.js`,`arkormx.config.js`,`arkorm.config.mjs`,`arkormx.config.mjs`],I=[`@types/pg`,`@prisma/client`,`@prisma/adapter-pg`,`@arkstack/auth`,`@arkstack/cache`,`@arkstack/database`,`@arkstack/filesystem`,`@arkstack/jobs`,`@arkstack/notifications`,`@arkstack/queue`,`pg`,`kysely`,`prisma`,`arkormx`],L=[],R={"@arkstack/auth":`^0.17.18`,"@arkstack/cache":`^0.17.18`,"@arkstack/common":`^0.17.18`,"@arkstack/console":`^0.17.18`,"@arkstack/foundry":`^0.17.18`,"@arkstack/jobs":`^0.17.18`,"@arkstack/contract":`^0.17.18`,"@arkstack/database":`^0.17.18`,"@arkstack/driver-express":`^0.17.18`,"@arkstack/driver-h3":`^0.17.18`,"@arkstack/filesystem":`^0.17.18`,"@arkstack/http":`^0.17.18`,"@arkstack/view":`^0.17.18`,"@arkstack/queue":`^0.17.18`,"@arkstack/scheduler":`^0.17.18`,"@arkstack/notifications":`^0.17.18`,"@h3ravel/musket":`^2.2.13`,"@h3ravel/support":`^2.2.7`},z={min:[`PORT`,`HOST`,`APP_URL`,`APP_KEY`,`APP_ENV`,`APP_HOST`,`APP_PORT`,`APP_NAME`,`APP_DEBUG`,`APP_LOCALE`,`APP_TIMEZONE`,`NODE_ENV`,`FRONTEND_URL`,`NGROK_DOMAIN`,`NGROK_AUTHTOKEN`,`APP_FAKER_LOCALE`,`APP_FALLBACK_LOCALE`],max:`FILESYSTEM_DISK.CACHE_STORE.QUEUE_CONNECTION.REDIS_HOST.REDIS_PORT.REDIS_PASSWORD.JWT_EXPIRES_IN.DATABASE_URL.DB_CONNECTION.DB_HOST.DB_PORT.DB_DATABASE.DB_USERNAME.DB_PASSWORD.MAIL_HOST.MAIL_PORT.MAIL_SECURE.MAIL_USERNAME.MAIL_PASSWORD.MAIL_FROM_ADDRESS.MAIL_TEST_ADDRESS.AWS_ACCESS_KEY_ID.AWS_SECRET_ACCESS_KEY.AWS_DEFAULT_REGION.AWS_BUCKET.AWS_URL.AWS_ENDPOINT`.split(`.`)},B=R[`@arkstack/common`],V=[{from:`config/inertia.ts.stub`,to:`src/config/inertia.ts`},{from:`config/app.css.stub`,to:`resources/css/app.css`},{from:`views/app.edge.stub`,to:`src/resources/views/app.edge`},{from:`shared/resources/js/vite-env.d.ts.stub`,to:`resources/js/vite-env.d.ts`}],H={"@arkstack/inertia":B,"@arkstack/view":B,vite:`^8.1.0`},U=[{name:`React`,value:`react`,ext:`tsx`,reactRefresh:!0,deps:{react:`^19.2.7`,"react-dom":`^19.2.7`,"@inertiajs/react":`^3.5.0`},devDeps:{"@types/react":`^19.2.3`,"@types/react-dom":`^19.2.3`,"@vitejs/plugin-react":`^6.0.3`},files:[{from:`react/resources/js/app.tsx.stub`,to:`resources/js/app.tsx`},{from:`react/vite.config.ts.stub`,to:`vite.config.ts`},{from:`react/resources/js/Pages/Index.tsx.stub`,to:`resources/js/Pages/Index.tsx`}]},{name:`Vue`,value:`vue`,ext:`ts`,reactRefresh:!1,deps:{vue:`^3.5.0`,"@inertiajs/vue3":`^3.5.0`},devDeps:{"@vitejs/plugin-vue":`^6.0.0`},files:[{from:`vue/resources/js/app.ts.stub`,to:`resources/js/app.ts`},{from:`vue/vite.config.ts.stub`,to:`vite.config.ts`},{from:`vue/resources/js/Pages/Index.vue.stub`,to:`resources/js/Pages/Index.vue`}]},{name:`Svelte`,value:`svelte`,ext:`ts`,reactRefresh:!1,deps:{svelte:`^5.0.0`,"@inertiajs/svelte":`^3.5.0`},devDeps:{"@sveltejs/vite-plugin-svelte":`^6.0.0`},files:[{from:`svelte/resources/js/app.ts.stub`,to:`resources/js/app.ts`},{from:`svelte/vite.config.ts.stub`,to:`vite.config.ts`},{from:`svelte/resources/js/Pages/Index.svelte.stub`,to:`resources/js/Pages/Index.svelte`}]}],W=e=>U.find(t=>t.value===e),G=(e,t)=>e.replaceAll(`{{ext}}`,t.ext).replaceAll(`{{reactRefresh}}`,t.reactRefresh?`@viteReactRefresh
|
|
3
3
|
`:``);var K=class{location;appName;description;skipInstallation;packageJson={};pkgPath;inertiaStubsDir;constructor(e,t,n){this.location=e,this.appName=t,this.description=n,this.location||=a(process.cwd(),`.temp`)}async pm(){return await b()??`npm`}async runCmd(e=!1){if(e)return`npx`;let t=await this.pm();return t===`npm`?`npm run`:t}async download(e,t=!1,n,r=!1){return this.location?.includes(`.temp`)||r&&S(this.location)?await p(this.location,{force:!0,recursive:!0}):S(this.location)&&(await d(this.location??`./`))?.length>0&&(console.log(`
|
|
4
4
|
`),g.parse([[` ERROR `,`bgRed`],[this.location,[`gray`,`italic`]],[`is not empty.`,`white`]],` `),console.log(``),process.exit(0)),this.skipInstallation=!t,this.removeLockFile(),await x(e,{dir:this.location,auth:n,provider:`github`,registry:await this.pm(),forceClean:!1})}async installPackage(e,t=[]){let n=await _.getPakageInstallCommand()+(e?` ${e}`:``),r=n?.split(` `)[0];n.includes(` `)&&t.unshift(...n.split(` `).slice(1));let i=C(r,t,{cwd:this.location??process.cwd(),stdio:`ignore`});return i.error?i.status:0}async complete(e=!1){let t=!1;e&&(t=await this.installPackage()===0),console.log(``);let r=`./`+o(process.cwd(),this.location);try{y(n.join(process.cwd(),r))}catch{}g.success(`Your Arkstack project has been created successfully`),g.parse([[`cd`,`cyan`],[r,`yellow`],r===process.cwd()?[`✔`,`green`]:[``,`green`]],` `),t||g.parse([[await _.getPakageInstallCommand(),`cyan`]]),g.parse([[await this.runCmd(),`cyan`],[`dev`,`yellow`]],` `),g.parse([[`Open`,`cyan`],[`http://localhost:3000`,`yellow`]]),console.log(``),g.parse([[`Have any questions`,`white`]]),g.parse([[`Join our Discord server -`,`white`],[`https://discord.gg/jmQybxKQ7R`,`yellow`]]),g.parse([[`Checkout our other projects -`,`white`],[`https://toneflix.net/open-source`,`yellow`]])}async removeLockFile(){this.skipInstallation&&await Promise.allSettled([m(a(this.location,`package-lock.json`)),m(a(this.location,`yarn.lock`)),m(a(this.location,`pnpm-lock.yaml`))])}async getBanner(){return await u(a(process.cwd(),`./logo.txt`),`utf-8`)}async createDotEnv(e=`max`){let t=a(this.location,`.env`),n=a(this.location,`.env.example`),r=e===`max`?[...z.max,...z.min]:z.min;if(S(n)){let e=await u(n,`utf-8`),i=[];for(let t of e.split(/\r?\n/)){let e=t.trim(),n=e===``,a=e.startsWith(`#`);if(!n&&!a){let e=t.split(`=`).at(0)?.trim()??``;if(!r.includes(e))continue}n&&i.at(-1)?.trim()===``||i.push(t)}for(;i.length&&i[0].trim()===``;)i.shift();for(;i.length&&i.at(-1).trim()===``;)i.pop();await h(n,i.join(`
|
|
5
5
|
`)+`
|
|
@@ -19,7 +19,7 @@ import{AbortPromptError as e,ExitPromptError as t}from"@inquirer/core";import n,
|
|
|
19
19
|
`),await h(t,n,`utf-8`)}}async captureInertiaStubs(e){let t=a(e,`packages`,`inertia`,`stubs`);if(!S(t))return!1;let n=a(w(),`create-arkstack-inertia-${process.pid}`);return await p(n,{force:!0,recursive:!0}),await c(t,n,{recursive:!0}),this.inertiaStubsDir=n,!0}async applyInertia(e,t){let n=W(t);if(n){if(!this.inertiaStubsDir||!S(this.inertiaStubsDir)){g.parse([[` WARN `,`bgYellow`],[`Inertia stubs were not found; skipping Inertia setup.`,`white`]],` `);return}this.pkgPath||await this.makeProfile(),await this.writeInertiaFiles(n),await this.patchInertiaView(n),this.addInertiaDependencies(n),await this.patchInertiaMiddleware(e),await this.patchInertiaWeb(),await this.patchInertiaTsConfig(n),await this.saveProfile()}}async writeInertiaFiles(e){for(let t of[...V,...e.files]){let n=a(this.inertiaStubsDir,t.from);if(!S(n))continue;let r=G(await u(n,`utf-8`),e),o=a(this.location,t.to);await l(i(o),{recursive:!0}),await h(o,r,`utf-8`)}}async patchInertiaView(e){let t=a(this.location,`src/resources/views/app.edge`);if(!S(t))return;let n=await u(t,`utf-8`);n=n.replaceAll(`{{ext}}`,e.ext).replaceAll(`{{reactRefresh}}`,e.reactRefresh?`@viteReactRefresh
|
|
20
20
|
`:``),n=n.replace(/resources\/js\/app\.[jt]sx?/g,`resources/js/app.${e.ext}`),e.reactRefresh&&!n.includes(`@viteReactRefresh`)&&(n=n.replace(/^([ \t]*)@vite\(/m,`$1@viteReactRefresh
|
|
21
21
|
$1@vite(`)),await h(t,n,`utf-8`)}addInertiaDependencies(e){this.packageJson.dependencies={...this.packageJson.dependencies??{},...H,...e.deps},this.packageJson.devDependencies={...this.packageJson.devDependencies??{},...e.devDeps},this.packageJson.scripts={...this.packageJson.scripts??{},"dev:client":`vite`,"build:client":`vite build`}}async patchInertiaMiddleware(e){let t=a(this.location,`src/config/middleware.ts`);if(!S(t))return;let n=await u(t,`utf-8`);n.includes(`inertia(`)||(n=n.replace(`requestLogger, resora }`,`inertia, requestLogger, resora }`).replace(/(\n(\s*)resora\(\),)/,`$1
|
|
22
|
-
$2inertia(),`)),await h(t,n,`utf-8`)}async patchInertiaWeb(){let e=a(this.location,`src/routes/web.ts`);S(e)
|
|
22
|
+
$2inertia(),`)),await h(t,n,`utf-8`)}async patchInertiaWeb(){let e=a(this.location,`src/routes/web.ts`);if(!S(e))return;let t=(await u(e,`utf-8`)).replace(`import { view } from '@arkstack/view'`,`import { inertia } from '@arkstack/inertia'`).replace(/await view\(\s*'welcome'/,`await inertia('Index'`);await h(e,t,`utf-8`)}async patchInertiaTsConfig(e){let t=a(this.location,`tsconfig.json`);if(!S(t))return;let n=JSON.parse(await u(t,`utf-8`));n.compilerOptions=n.compilerOptions??{},e.reactRefresh&&(n.compilerOptions.jsx=`react-jsx`),n.include=[`.arkstack/*.d.ts`,`src`,`tests`,`resources`],await h(t,JSON.stringify(n,null,2)+`
|
|
23
23
|
`,`utf-8`)}async cleanup(e){let t=this.packageJson;delete t.packageManager,delete t.scripts.predev,delete t.scripts.prebuild,delete t.scripts.precmd,delete t.scripts.cmd,t.scripts.dev=`ark dev`,t.scripts.build=`ark build`,t.scripts.postinstall=`prepare`,t.name=v.slugify(this.appName??r(this.location).replace(`.`,``),`-`),this.description&&(t.description=this.description);for(let n of Object.keys(t.dependencies))n.includes(`@arkstack/driver`)&&n!==`@arkstack/driver-`+e&&delete t.dependencies[n];this.packageJson=t,await Promise.allSettled([this.saveProfile(),this.removeLockFile(),p(a(this.location,`pnpm-workspace.yaml`),{force:!0}),p(a(this.location,`.github`),{force:!0,recursive:!0})])}};const q=String.raw`%c
|
|
24
24
|
_ __ _ _
|
|
25
25
|
/_\ _ __ ___/ _\ |_ __ _ ___| | __
|
|
@@ -39,4 +39,4 @@ $2inertia(),`)),await h(t,n,`utf-8`)}async patchInertiaWeb(){let e=a(this.locati
|
|
|
39
39
|
{--f|full: Make a full project (Ignored if lean is defined).}
|
|
40
40
|
{--p|pre: Download prerelease version if available.}
|
|
41
41
|
{--o|overwrite: Overwrite the installation directory if it is not empty.}
|
|
42
|
-
`;description=`Display a personalized greeting.`;async handle(){let n=this.options(),i=this.argument(`location`);console.log(q,`font-family: monospace`);let{template:o}=await D.prompt([{type:`list`,name:`template`,message:`Choose Runtime:`,choices:j.map(e=>({name:`${e.name} - ${e.hint}`,value:e.alias,disabled
|
|
42
|
+
`;description=`Display a personalized greeting.`;async handle(){let n=this.options(),i=this.argument(`location`);console.log(q,`font-family: monospace`);let{template:o}=await D.prompt([{type:`list`,name:`template`,message:`Choose Runtime:`,choices:j.map(e=>({name:`${e.name} - ${e.hint}`,value:e.alias,disabled:!e.source&&`(Unavailable at this time)`})),default:`full`,when:()=>!n.kit}]).catch(n=>((n instanceof e||n instanceof t)&&(this.info(`Thanks for trying out Arkstack.`),process.exit(0)),n)),{lean:s,appName:c,description:l}=await D.prompt([{type:`list`,name:`lean`,message:`Project Scope:`,choices:M.map(e=>({name:`${e.name} - ${e.hint.replace(`{template}`,v.title(n.kit||o))}`,value:e.lean})),default:`full`,when:()=>!n.lean&&!n.full},{type:`input`,name:`appName`,message:`What is the name of your project:`,default:`arkstack-${n.kit||o}`,when:()=>!n.name},{type:`input`,name:`description`,message:`Project Description:`,default:`Simple ${v.of(n.kit||o).ucfirst()}.js project created with Arkstack.`,when:()=>!n.desc}]).catch(n=>((n instanceof e||n instanceof t)&&(this.info(`Thanks for trying out Arkstack.`),process.exit(0)),n)),{location:u,stack:d}=await D.prompt([{type:`input`,name:`location`,message:`Installation location relative to the current dir:`,default:v.slugify(n.name??c??r(process.cwd()),`-`),when:()=>!i},{type:`list`,name:`stack`,message:`Add an Inertia front-end? (server-side adapter + client scaffolding):`,choices:[{name:`None - plain server-rendered views`,value:`none`},...U.map(e=>({name:`${e.name} - Inertia + ${e.name}`,value:e.value}))],default:`none`,when:()=>!n.stack}]).catch(n=>((n instanceof e||n instanceof t)&&(this.info(`Thanks for trying out Arkstack.`),process.exit(0)),n)),f=j.find(e=>e.alias===(n.kit||o));f.lean=n.full===!1||n.lean||!!s||!1;let{install:p,token:m,pre:h}=await D.prompt([{type:`confirm`,name:`pre`,message:`An alpha version of the ${f.name.replace(/\s*template$/i,``).trim()} template is available. Would you like to use it instead?`,default:!1,when:()=>f.prereleaseSource&&!n.pre},{type:`input`,name:`token`,message:`Authentication token:`,when:()=>f.locked&&!n.token},{type:`confirm`,name:`install`,message:`Would you like to install node_modules right away?:`,default:!0,when:()=>!n.install}]).catch(n=>((n instanceof e||n instanceof t)&&(this.info(`Thanks for trying out Arkstack.`),process.exit(0)),n));h=n.pre??h,m=n.token??m,c=n.name??c,p=n.install??p,o=n.kit??o,u=i??u,l=n.description??l,d=n.stack??d??`none`,f&&!f.source&&(this.error(`ERROR: The ${f.name} kit is not currently available`),process.exit(1));let _=(f.baseAlias??f.alias).replace(/-lean$/i,``),y=h&&f.prereleaseSource?f.prereleaseSource:f.source,b=new K(a(process.cwd(),u),c,l),x=this.spinner(`Loading Template...`).start(),S=await b.download(y,p,m,n.overwrite),C=d&&d!==`none`;S.dir&&_&&(C&&await b.captureInertiaStubs(S.dir),await O(S.dir),await k(S.dir,_),await A(S.dir,a(S.dir,_))),f.lean?(x.info(g.parse([[`Applying lean profile...`,`green`]],``,!1)).start(),await b.makeLeanProfile(_)):await b.makeFullProfile(_),C&&(x.info(g.parse([[`Adding Inertia (${v.title(d)})...`,`green`]],``,!1)).start(),await b.applyInertia(_,d)),x.info(g.parse([[`Cleaning Up...`,`green`]],``,!1)).start(),await b.cleanup(_),x.info(g.parse([[`Initializing Project...`,`green`]],``,!1)).start(),await b.createDotEnv(f.lean?`min`:`max`),await b.complete(p),x.succeed(g.parse([[`Project initialization complete!`,`green`]],``,!1))}},Y=class{};E.init(new Y,{rootCommand:J,exceptionHandler:e=>{g.error(`ERROR: ${e.message}`)}});export{};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-arkstack",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.17.
|
|
4
|
+
"version": "0.17.18",
|
|
5
5
|
"description": "Create new Arkstack framework applications on Express or H3 runtime drivers",
|
|
6
6
|
"homepage": "https://arkstack.toneflix.net",
|
|
7
7
|
"repository": {
|
|
@@ -56,14 +56,14 @@
|
|
|
56
56
|
"dependencies": {
|
|
57
57
|
"@antfu/install-pkg": "1.1.0",
|
|
58
58
|
"@h3ravel/collect.js": "^5.4.0",
|
|
59
|
-
"@h3ravel/musket": "^2.2.
|
|
60
|
-
"@h3ravel/shared": "^2.2.
|
|
61
|
-
"@h3ravel/support": "^2.2.
|
|
59
|
+
"@h3ravel/musket": "^2.2.13",
|
|
60
|
+
"@h3ravel/shared": "^2.2.7",
|
|
61
|
+
"@h3ravel/support": "^2.2.7",
|
|
62
62
|
"@inquirer/core": "^10.2.2",
|
|
63
63
|
"giget": "^2.0.0",
|
|
64
64
|
"inquirer": "^12.9.6",
|
|
65
65
|
"dotenv": "^17.4.2",
|
|
66
|
-
"tsdown": "^0.22.
|
|
66
|
+
"tsdown": "^0.22.14",
|
|
67
67
|
"unrun": "^0.3.0"
|
|
68
68
|
},
|
|
69
69
|
"devDependencies": {
|