startx 1.0.5 → 1.0.8

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.
Files changed (34) hide show
  1. package/apps/core-server/Dockerfile +7 -2
  2. package/apps/core-server/src/middlewares/auth-middleware.ts +74 -30
  3. package/apps/queue-worker/Dockerfile +15 -8
  4. package/apps/queue-worker/package.json +5 -1
  5. package/apps/queue-worker/src/bullmq/board.ts +28 -0
  6. package/apps/queue-worker/src/index.ts +2 -0
  7. package/apps/startx-cli/dist/index.mjs +2 -2
  8. package/apps/startx-cli/src/configs/scripts.ts +40 -0
  9. package/package.json +8 -2
  10. package/packages/@db/drizzle/drizzle.config.ts +1 -1
  11. package/packages/@db/drizzle/src/index.ts +4 -15
  12. package/packages/@repo/lib/src/cookie-module/cookie-module.ts +94 -38
  13. package/packages/@repo/lib/src/extra/index.ts +1 -0
  14. package/packages/@repo/lib/src/extra/token-module.ts +50 -21
  15. package/packages/@repo/lib/src/mail-module/nodemailer.ts +33 -21
  16. package/packages/@repo/lib/src/session-module/i-session.ts +132 -59
  17. package/packages/@repo/lib/src/session-module/index.ts +8 -2
  18. package/packages/@repo/lib/src/session-module/redis-session.ts +53 -23
  19. package/packages/@repo/lib/src/validation-module/index.ts +50 -78
  20. package/packages/@repo/model/eslint.config.ts +4 -0
  21. package/packages/@repo/model/package.json +41 -0
  22. package/packages/@repo/model/src/index.ts +0 -0
  23. package/packages/@repo/model/tsconfig.json +7 -0
  24. package/packages/@repo/model/vitest.config.ts +3 -0
  25. package/packages/common/src/time.ts +95 -22
  26. package/packages/queue/src/adapter/bullmq-adapter.ts +138 -47
  27. package/packages/queue/src/index.ts +3 -0
  28. package/packages/queue/src/queue-interface.ts +12 -5
  29. package/packages/queue/src/registry.ts +2 -2
  30. package/packages/queue/tsconfig.json +1 -1
  31. package/packages/ui/src/api/use-api/react-query/types.ts +3 -3
  32. package/packages/ui/src/api/use-api/react-query/use-api.ts +10 -11
  33. package/pnpm-workspace.yaml +4 -2
  34. package/turbo.json +20 -0
@@ -11,6 +11,7 @@ COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./
11
11
 
12
12
  COPY --parents apps/*/package.json ./
13
13
  COPY --parents packages/*/package.json ./
14
+ COPY --parents packages/*/*/package.json ./
14
15
  COPY --parents configs/*/package.json ./
15
16
 
16
17
  RUN --mount=type=cache,id=pnpm,target=/root/.local/share/pnpm/store \
@@ -21,14 +22,18 @@ COPY packages ./packages
21
22
  COPY configs ./configs
22
23
  COPY turbo.json ./
23
24
 
24
- # Build the required packages
25
- RUN pnpm build --filter=core-server
25
+ # Build the required packages with Turbo cache mounted
26
+ RUN --mount=type=cache,id=turbo,target=/app/.turbo/cache \
27
+ pnpm build --filter=queue-worker
26
28
 
27
29
  # --- Final production image ---
28
30
  FROM node:24-alpine
29
31
 
30
32
  WORKDIR /app
31
33
 
34
+ # Install external dependencies locally
35
+ RUN npm install sharp
36
+
32
37
  # Copy built server dist
33
38
  COPY --from=builder /app/apps/core-server/dist ./
34
39
  EXPOSE 3000
@@ -1,30 +1,83 @@
1
- import { UserSession } from "@repo/lib/session-module";
1
+ import { TokenModule } from "@repo/lib/extra";
2
+ import { defaultUserSession } from "@repo/lib/session-module";
2
3
  import type { NextFunction, Request, Response } from "express";
3
4
 
4
- type ExpressHandler = (req: Request, res: Response, next: NextFunction) => unknown;
5
+ type ExpressHandler = (req: Request, res: Response, next: NextFunction) => Promise<void> | void;
6
+
7
+ function extractBearerToken(req: Request): string | null {
8
+ const auth = req.headers.authorization;
9
+
10
+ if (!auth) return null;
11
+
12
+ const [scheme, token] = auth.split(" ");
13
+
14
+ if (scheme !== "Bearer" || !token) {
15
+ return null;
16
+ }
17
+
18
+ return token;
19
+ }
20
+
21
+ async function authenticateRequest(req: Request) {
22
+ const accessToken = extractBearerToken(req);
23
+
24
+ if (!accessToken) {
25
+ return {
26
+ ok: false as const,
27
+ status: 401,
28
+ message: "Access token missing",
29
+ };
30
+ }
31
+
32
+ const payload = TokenModule.verifyAccessToken(accessToken);
33
+
34
+ if (!payload?.sessionID) {
35
+ return {
36
+ ok: false as const,
37
+ status: 401,
38
+ message: "Invalid access token",
39
+ };
40
+ }
41
+
42
+ const session = await defaultUserSession.validateSession(payload.sessionID);
43
+
44
+ if (!session) {
45
+ return {
46
+ ok: false as const,
47
+ status: 401,
48
+ message: "Session expired or revoked",
49
+ };
50
+ }
51
+
52
+ return {
53
+ ok: true as const,
54
+ user: session.user,
55
+ session,
56
+ };
57
+ }
5
58
 
6
59
  export class AuthMiddlewares {
7
60
  static async validateActiveSession(req: Request, res: Response, next: NextFunction) {
8
61
  try {
9
- const accessToken = req.headers["authorization"]?.split(" ")[1];
10
- if (!accessToken) {
11
- res.status(401).json({ message: "access token missing" });
62
+ const auth = await authenticateRequest(req);
63
+
64
+ if (!auth.ok) {
65
+ res.status(auth.status).json({
66
+ success: false,
67
+ message: auth.message,
68
+ });
12
69
  return;
13
70
  }
14
71
 
15
- const payload = await UserSession.getSessionUser(accessToken);
72
+ req.user = auth.user;
16
73
 
17
- if (!payload) {
18
- res.status(401).json({ message: "invalid access token" });
19
- return;
20
- }
21
- req.user = payload;
22
- return next();
74
+ next();
23
75
  } catch (error) {
24
76
  next(error);
25
77
  }
26
78
  }
27
79
  }
80
+
28
81
  export function validateSession() {
29
82
  return function <T extends ExpressHandler>(
30
83
  _target: unknown,
@@ -35,30 +88,21 @@ export function validateSession() {
35
88
 
36
89
  if (!originalMethod) return;
37
90
 
38
- descriptor.value = async function (
39
- this: unknown,
40
- req: Request,
41
- res: Response,
42
- next: NextFunction
43
- ) {
91
+ descriptor.value = async function (this: unknown, req: Request, res: Response, next: NextFunction) {
44
92
  try {
45
- const accessToken = req.headers.authorization?.split(" ")[1];
46
-
47
- if (!accessToken) {
48
- res.status(401).json({ message: "access token missing" });
49
- return;
50
- }
51
-
52
- const payload = await UserSession.getSessionUser(accessToken);
93
+ const auth = await authenticateRequest(req);
53
94
 
54
- if (!payload) {
55
- res.status(401).json({ message: "invalid access token" });
95
+ if (!auth.ok) {
96
+ res.status(auth.status).json({
97
+ success: false,
98
+ message: auth.message,
99
+ });
56
100
  return;
57
101
  }
58
102
 
59
- req.user = payload;
103
+ req.user = auth.user;
60
104
 
61
- return originalMethod.call(this, req, res, next);
105
+ await originalMethod.call(this, req, res, next);
62
106
  } catch (error) {
63
107
  next(error);
64
108
  }
@@ -1,7 +1,8 @@
1
+ # syntax=docker/dockerfile:1
2
+
1
3
  FROM node:24-alpine AS base
2
- RUN apk add --no-cache git \
3
- && corepack enable \
4
- && corepack prepare pnpm@latest --activate
4
+ RUN corepack enable && corepack prepare pnpm@11.5.1 --activate
5
+
5
6
  WORKDIR /app
6
7
 
7
8
  FROM base AS builder
@@ -10,26 +11,32 @@ COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./
10
11
 
11
12
  COPY --parents apps/*/package.json ./
12
13
  COPY --parents packages/*/package.json ./
14
+ COPY --parents packages/*/*/package.json ./
13
15
  COPY --parents configs/*/package.json ./
14
16
 
15
17
  RUN --mount=type=cache,id=pnpm,target=/root/.local/share/pnpm/store \
16
18
  pnpm install --frozen-lockfile
17
19
 
18
- COPY apps/bullmq-worker/ ./apps/bullmq-worker/
20
+ COPY apps/queue-worker/ ./apps/queue-worker/
19
21
  COPY packages ./packages
20
22
  COPY configs ./configs
23
+ COPY assets ./assets
21
24
  COPY turbo.json ./
22
25
 
23
- # Build the required packages
24
- RUN pnpm build:web
26
+ # Build the required packages with Turbo cache mounted
27
+ RUN --mount=type=cache,id=turbo,target=/app/.turbo/cache \
28
+ pnpm build --filter=queue-worker
25
29
 
26
30
  # --- Final production image ---
27
31
  FROM node:24-alpine
28
32
 
29
33
  WORKDIR /app
30
34
 
35
+ # Install external dependencies locally
36
+ RUN npm install sharp @bull-board/api @bull-board/ui @bull-board/express
37
+
31
38
  # Copy built server dist
32
- COPY --from=builder /app/apps/bullmq-worker/dist ./
33
- EXPOSE 3000
39
+ COPY --from=builder /app/apps/queue-worker/dist ./
40
+ EXPOSE 2866
34
41
 
35
42
  CMD ["node", "./index.mjs"]
@@ -26,10 +26,14 @@
26
26
  "@repo/redis": "workspace:^",
27
27
  "@repo/env": "workspace:^",
28
28
  "@repo/logger": "workspace:^",
29
- "@repo/queue": "workspace:*"
29
+ "@repo/queue": "workspace:*",
30
+ "@bull-board/api": "catalog:",
31
+ "@bull-board/express": "catalog:",
32
+ "express": "catalog:"
30
33
  },
31
34
  "devDependencies": {
32
35
  "eslint-config": "workspace:*",
36
+ "@types/express": "catalog:",
33
37
  "vitest-config": "workspace:*",
34
38
  "tsdown-config": "workspace:*",
35
39
  "typescript-config": "workspace:*"
@@ -0,0 +1,28 @@
1
+ import { createBullBoard } from "@bull-board/api";
2
+ import { BullMQAdapter } from "@bull-board/api/bullMQAdapter";
3
+ import { ExpressAdapter } from "@bull-board/express";
4
+ import { defineEnv } from "@repo/env";
5
+ import { logger } from "@repo/logger";
6
+ import { BullQueue, queueList } from "@repo/queue";
7
+ import express from "express";
8
+ import { z } from "zod";
9
+
10
+ const serverAdapter = new ExpressAdapter();
11
+
12
+ serverAdapter.setBasePath("/");
13
+
14
+ createBullBoard({
15
+ serverAdapter,
16
+ queues: queueList.map(queue => new BullMQAdapter(BullQueue.getQueue(queue))),
17
+ });
18
+ const port = defineEnv({
19
+ BULL_BOARD_PORT: z.coerce.number().default(2866),
20
+ });
21
+ export const startBullBoard = () => {
22
+ const app = express();
23
+ app.use("/", serverAdapter.getRouter() as express.Router);
24
+
25
+ app.listen(port.BULL_BOARD_PORT, () => {
26
+ logger.info(`Bull Board listening on port ${port.BULL_BOARD_PORT}`);
27
+ });
28
+ };
@@ -1,3 +1,5 @@
1
+ import { startBullBoard } from "./bullmq/board.js";
1
2
  import { bullWorker } from "./bullmq/worker.js";
2
3
 
3
4
  bullWorker();
5
+ startBullBoard();
@@ -199,7 +199,7 @@ $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,`$1$2`).replace(/\
199
199
  `)+1;for(;e!==0;)this.onNewLine(this.offset+e),e=this.source.indexOf(`
200
200
  `,e)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(e){let t=e.items[e.items.length-1];switch(this.type){case`newline`:if(this.onKeyLine=!1,t.value){let n=`end`in t.value?t.value.end:void 0;(Array.isArray(n)?n[n.length-1]:void 0)?.type===`comment`?n?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case`space`:case`comment`:if(t.value)e.items.push({start:[this.sourceToken]});else if(t.sep)t.sep.push(this.sourceToken);else{if(this.atIndentedComment(t.start,e.indent)){let n=e.items[e.items.length-2]?.value?.end;if(Array.isArray(n)){Array.prototype.push.apply(n,t.start),n.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return}if(this.indent>=e.indent){let n=!this.onKeyLine&&this.indent===e.indent,r=n&&(t.sep||t.explicitKey)&&this.type!==`seq-item-ind`,a=[];if(r&&t.sep&&!t.value){let n=[];for(let r=0;r<t.sep.length;++r){let i=t.sep[r];switch(i.type){case`newline`:n.push(r);break;case`space`:break;case`comment`:i.indent>e.indent&&(n.length=0);break;default:n.length=0}}n.length>=2&&(a=t.sep.splice(n[1]))}switch(this.type){case`anchor`:case`tag`:r||t.value?(a.push(this.sourceToken),e.items.push({start:a}),this.onKeyLine=!0):t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case`explicit-key-ind`:!t.sep&&!t.explicitKey?(t.start.push(this.sourceToken),t.explicitKey=!0):r||t.value?(a.push(this.sourceToken),e.items.push({start:a,explicitKey:!0})):this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken],explicitKey:!0}]}),this.onKeyLine=!0;return;case`map-value-ind`:if(t.explicitKey)if(!t.sep)if(i(t.start,`newline`))Object.assign(t,{key:null,sep:[this.sourceToken]});else{let e=c(t.start);this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:e,key:null,sep:[this.sourceToken]}]})}else if(t.value)e.items.push({start:[],key:null,sep:[this.sourceToken]});else if(i(t.sep,`map-value-ind`))this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:a,key:null,sep:[this.sourceToken]}]});else if(o(t.key)&&!i(t.sep,`newline`)){let e=c(t.start),n=t.key,r=t.sep;r.push(this.sourceToken),delete t.key,delete t.sep,this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:e,key:n,sep:r}]})}else a.length>0?t.sep=t.sep.concat(a,this.sourceToken):t.sep.push(this.sourceToken);else t.sep?t.value||r?e.items.push({start:a,key:null,sep:[this.sourceToken]}):i(t.sep,`map-value-ind`)?this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]}):t.sep.push(this.sourceToken):Object.assign(t,{key:null,sep:[this.sourceToken]});this.onKeyLine=!0;return;case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:{let n=this.flowScalar(this.type);r||t.value?(e.items.push({start:a,key:n,sep:[]}),this.onKeyLine=!0):t.sep?this.stack.push(n):(Object.assign(t,{key:n,sep:[]}),this.onKeyLine=!0);return}default:{let r=this.startBlockValue(e);if(r){if(r.type===`block-seq`){if(!t.explicitKey&&t.sep&&!i(t.sep,`newline`)){yield*this.pop({type:`error`,offset:this.offset,message:`Unexpected block-seq-ind on same line with key`,source:this.source});return}}else n&&e.items.push({start:a});this.stack.push(r);return}}}}yield*this.pop(),yield*this.step()}*blockSequence(e){let t=e.items[e.items.length-1];switch(this.type){case`newline`:if(t.value){let n=`end`in t.value?t.value.end:void 0;(Array.isArray(n)?n[n.length-1]:void 0)?.type===`comment`?n?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else t.start.push(this.sourceToken);return;case`space`:case`comment`:if(t.value)e.items.push({start:[this.sourceToken]});else{if(this.atIndentedComment(t.start,e.indent)){let n=e.items[e.items.length-2]?.value?.end;if(Array.isArray(n)){Array.prototype.push.apply(n,t.start),n.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return;case`anchor`:case`tag`:if(t.value||this.indent<=e.indent)break;t.start.push(this.sourceToken);return;case`seq-item-ind`:if(this.indent!==e.indent)break;t.value||i(t.start,`seq-item-ind`)?e.items.push({start:[this.sourceToken]}):t.start.push(this.sourceToken);return}if(this.indent>e.indent){let t=this.startBlockValue(e);if(t){this.stack.push(t);return}}yield*this.pop(),yield*this.step()}*flowCollection(e){let t=e.items[e.items.length-1];if(this.type===`flow-error-end`){let e;do yield*this.pop(),e=this.peek(1);while(e?.type===`flow-collection`)}else if(e.end.length===0){switch(this.type){case`comma`:case`explicit-key-ind`:!t||t.sep?e.items.push({start:[this.sourceToken]}):t.start.push(this.sourceToken);return;case`map-value-ind`:!t||t.value?e.items.push({start:[],key:null,sep:[this.sourceToken]}):t.sep?t.sep.push(this.sourceToken):Object.assign(t,{key:null,sep:[this.sourceToken]});return;case`space`:case`comment`:case`newline`:case`anchor`:case`tag`:!t||t.value?e.items.push({start:[this.sourceToken]}):t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:{let n=this.flowScalar(this.type);!t||t.value?e.items.push({start:[],key:n,sep:[]}):t.sep?this.stack.push(n):Object.assign(t,{key:n,sep:[]});return}case`flow-map-end`:case`flow-seq-end`:e.end.push(this.sourceToken);return}let n=this.startBlockValue(e);n?this.stack.push(n):(yield*this.pop(),yield*this.step())}else{let t=this.peek(2);if(t.type===`block-map`&&(this.type===`map-value-ind`&&t.indent===e.indent||this.type===`newline`&&!t.items[t.items.length-1].sep))yield*this.pop(),yield*this.step();else if(this.type===`map-value-ind`&&t.type!==`flow-collection`){let n=c(s(t));l(e);let r=e.end.splice(1,e.end.length);r.push(this.sourceToken);let i={type:`block-map`,offset:e.offset,indent:e.indent,items:[{start:n,key:e,sep:r}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=i}else yield*this.lineEnd(e)}}flowScalar(e){if(this.onNewLine){let e=this.source.indexOf(`
201
201
  `)+1;for(;e!==0;)this.onNewLine(this.offset+e),e=this.source.indexOf(`
202
- `,e)+1}return{type:e,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(e){switch(this.type){case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:return this.flowScalar(this.type);case`block-scalar-header`:return{type:`block-scalar`,offset:this.offset,indent:this.indent,props:[this.sourceToken],source:``};case`flow-map-start`:case`flow-seq-start`:return{type:`flow-collection`,offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case`seq-item-ind`:return{type:`block-seq`,offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case`explicit-key-ind`:{this.onKeyLine=!0;let t=c(s(e));return t.push(this.sourceToken),{type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:t,explicitKey:!0}]}}case`map-value-ind`:{this.onKeyLine=!0;let t=c(s(e));return{type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:t,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,t){return this.type!==`comment`||this.indent<=t?!1:e.every(e=>e.type===`newline`||e.type===`space`)}*documentEnd(e){this.type!==`doc-mode`&&(e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type===`newline`&&(yield*this.pop()))}*lineEnd(e){switch(this.type){case`comma`:case`doc-start`:case`doc-end`:case`flow-seq-end`:case`flow-map-end`:case`map-value-ind`:yield*this.pop(),yield*this.step();break;case`newline`:this.onKeyLine=!1;default:e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type===`newline`&&(yield*this.pop())}}}})),ky=_((e=>{var t=xy(),n=iy(),r=ay(),i=kv(),a=$(),o=Dy(),s=Oy();function c(e){let t=e.prettyErrors!==!1;return{lineCounter:e.lineCounter||t&&new o.LineCounter||null,prettyErrors:t}}function l(e,n={}){let{lineCounter:i,prettyErrors:a}=c(n),o=new s.Parser(i?.addNewLine),l=new t.Composer(n),u=Array.from(l.compose(o.parse(e)));if(a&&i)for(let t of u)t.errors.forEach(r.prettifyError(e,i)),t.warnings.forEach(r.prettifyError(e,i));return u.length>0?u:Object.assign([],{empty:!0},l.streamInfo())}function u(e,n={}){let{lineCounter:i,prettyErrors:a}=c(n),o=new s.Parser(i?.addNewLine),l=new t.Composer(n),u=null;for(let t of l.compose(o.parse(e),!0,e.length))if(!u)u=t;else if(u.options.logLevel!==`silent`){u.errors.push(new r.YAMLParseError(t.range.slice(0,2),`MULTIPLE_DOCS`,`Source contains multiple documents; please use YAML.parseAllDocuments()`));break}return a&&i&&(u.errors.forEach(r.prettifyError(e,i)),u.warnings.forEach(r.prettifyError(e,i))),u}function d(e,t,n){let r;typeof t==`function`?r=t:n===void 0&&t&&typeof t==`object`&&(n=t);let a=u(e,n);if(!a)return null;if(a.warnings.forEach(e=>i.warn(a.options.logLevel,e)),a.errors.length>0){if(a.options.logLevel!==`silent`)throw a.errors[0];a.errors=[]}return a.toJS(Object.assign({reviver:r},n))}function f(e,t,r){let i=null;if(typeof t==`function`||Array.isArray(t)?i=t:r===void 0&&t&&(r=t),typeof r==`string`&&(r=r.length),typeof r==`number`){let e=Math.round(r);r=e<1?void 0:e>8?{indent:8}:{indent:e}}if(e===void 0){let{keepUndefined:e}=r??t??{};if(!e)return}return a.isDocument(e)&&!i?e.toString(r):new n.Document(e,i,r).toString(r)}e.parse=d,e.parseAllDocuments=l,e.parseDocument=u,e.stringify=f})),Ay=b(_((e=>{var t=xy(),n=iy(),r=ny(),i=ay(),a=bv(),o=$(),s=Mv(),c=xv(),l=Pv(),u=Iv();Ty();var d=Ey(),f=Dy(),p=Oy(),m=ky(),h=mv();e.Composer=t.Composer,e.Document=n.Document,e.Schema=r.Schema,e.YAMLError=i.YAMLError,e.YAMLParseError=i.YAMLParseError,e.YAMLWarning=i.YAMLWarning,e.Alias=a.Alias,e.isAlias=o.isAlias,e.isCollection=o.isCollection,e.isDocument=o.isDocument,e.isMap=o.isMap,e.isNode=o.isNode,e.isPair=o.isPair,e.isScalar=o.isScalar,e.isSeq=o.isSeq,e.Pair=s.Pair,e.Scalar=c.Scalar,e.YAMLMap=l.YAMLMap,e.YAMLSeq=u.YAMLSeq,e.Lexer=d.Lexer,e.LineCounter=f.LineCounter,e.Parser=p.Parser,e.parse=m.parse,e.parseAllDocuments=m.parseAllDocuments,e.parseDocument=m.parseDocument,e.stringify=m.stringify,e.visit=h.visit,e.visitAsync=h.visitAsync}))(),1);function jy(){return Kh.NODE_ENV===`development`?t.resolve(process.cwd(),`../../`):process.cwd()}const My=new class{root=jy();async pathExists(e){try{return await a.access(e),!0}catch{return!1}}async writeFile({file:e,content:n}){await a.writeFile(t.resolve(this.root,e),n)}async writeJSONFile({file:e,content:n,dir:r}){e=`${e}.json`;let i=t.resolve(this.root,e);if(r){let n=t.resolve(this.root,r);await this.ensurePathExists({dir:r}),i=t.resolve(n,e)}await a.writeFile(i,JSON.stringify(n,null,2))}async readFile({file:e}){return await a.readFile(t.resolve(this.root,e),`utf-8`)}async readJSONFile({file:e,dir:n}){try{e=`${e}.json`;let r=t.resolve(this.root,n??``,e),i=await a.readFile(r,`utf-8`);return JSON.parse(i)}catch(t){return console.error(`Failed to read JSON file at ${e}:`,t),null}}async readYamlFile({file:e,dir:n}){try{e=`${e}.yaml`;let r=t.resolve(this.root,n??``,e),i=await a.readFile(r,`utf-8`);return Ay.parseDocument(i)}catch(t){return console.error(`Failed to read Yaml file at ${e}:`,t),null}}async ensurePathExists({dir:e}){let n=t.resolve(this.root,e);await this.pathExists(n)||await a.mkdir(n,{recursive:!0})}async avoidOverriding({file:e}){let n=t.resolve(this.root,e);if(await this.pathExists(n))throw Error(`File ${n} already exists`)}async removeFile({file:e}){let n=t.resolve(this.root,e);await this.pathExists(n)&&await a.unlink(n)}async removeDirectory({dir:e,target:n}){let r=t.resolve(this.root,e,n);await this.pathExists(r)&&await a.rm(r,{recursive:!0,force:!0})}async copyFile({from:e,to:n}){await this.ensurePathExists({dir:t.dirname(n)}),await a.copyFile(t.resolve(this.root,e),t.resolve(this.root,n))}async copyDirectory({from:e,to:n,recursive:r=!0,include:i,exclude:o}){let s=t.resolve(this.root,e),c=t.resolve(this.root,n);if(!await this.pathExists(s))return;await this.ensurePathExists({dir:t.join(n)});let l=await a.readdir(s,{withFileTypes:!0});for(let u of l){let l=t.join(s,u.name),d=t.join(c,u.name),f=(!i||i.test(u.name))&&(!o||!o.test(u.name));u.isDirectory()?r&&await this.copyDirectory({from:t.join(e,u.name),to:t.join(n,u.name),recursive:r,include:i,exclude:o}):u.isFile()&&f&&await a.copyFile(l,d)}}async listDirectories({dir:e}){try{return(await a.readdir(t.resolve(this.root,e),{withFileTypes:!0})).filter(e=>e.isDirectory()).map(e=>e.name)}catch(t){return console.error(`Error listing directories in ${e}:`,t),[]}}async listFiles({dir:e}){try{return(await a.readdir(t.resolve(this.root,e),{withFileTypes:!0})).filter(e=>e.isFile()).map(e=>e.name)}catch(t){return console.error(`Error listing files in ${e}:`,t),[]}}},Ny={"startx.json":{tags:[`never`]},".npmignore":{tags:[`never`]},".npmrc":{tags:[`never`]},".prettier.cjs":{tags:[`prettier`]},".prettierignore":{tags:[`biome`]},"biome.json":{tags:[`biome`]},"pnpm-lock.yaml":{tags:[`never`]},"pnpm-workspace.yaml":{tags:[`root`]},"turbo.json":{tags:[`root`]},LICENSE:{tags:[`never`]},".env":{tags:[`never`]},"tsdown.config.ts":{tags:[`tsdown`]},"eslint.config.ts":{tags:[`eslint`,`node`]},"vitest.config.ts":{tags:[`vitest`,`node`]},"package.json":{tags:[`never`]}},Py=Gh({STARTX_ENV:Bp.enum([`development`,`production`,`test`,`staging`]).default(`production`)});var Fy=class{static getDirectory(){let e=r(import.meta.url),n=t.dirname(e),i=process.cwd();return n=Py.STARTX_ENV===`development`?t.resolve(n,`../../../../`):t.resolve(n,`../../../`),{template:n,workspace:i}}static async getPackageList(){let e=this.getDirectory().template,n=async(n,r,i=``,a)=>{let o=t.join(e,...n.split(`/`));try{let n=await My.listDirectories({dir:o});return a&&(n=n.filter(a)),(await Promise.all(n.map(async n=>{let a=t.join(o,n),s=t.relative(e,a),c=i?`${i}${n}`:n,l;try{l=await this.parsePackageJson({dir:a})}catch{l=null}return l?{type:r,path:a,relativePath:s,name:c,packageJson:l}:(console.error(`Ignoring this package failed to read package.json: ${c}`),null)}))).filter(e=>e!==null)}catch(e){return console.error(`Error reading directory ${o}:`,e),[]}},r=[`@repo`,`@db`];return(await Promise.all([n(`apps`,`apps`),n(`configs`,`configs`),n(`packages`,`packages`,``,e=>!r.includes(e)),n(`packages/@repo`,`packages`,`@repo/`),n(`packages/@db`,`packages`,`@db/`)])).flat()}static async parsePackageJson({dir:e,file:t=`package`}){return await My.readJSONFile({dir:e,file:t})}static async parsePnpmWorkspace({dir:e}){return(await My.readYamlFile({file:`pnpm-workspace`,dir:e}))?.toJSON()}};const Iy={"@biomejs/biome":{tags:[`node`,`biome`,`root`],version:`catalog:`,isDevDependency:!0},prettier:{tags:[`node`,`prettier`,`root`],version:`catalog:`,isDevDependency:!0},eslint:{tags:[`node`,`eslint`,`root`],version:`catalog:`,isDevDependency:!0},vitest:{tags:[`node`,`vitest`,`root`],version:`catalog:`,isDevDependency:!0},tsdown:{isDevDependency:!0,tags:[`node`,`tsdown`,`root`],version:`catalog:`},"tsdown-config":{tags:[`node`,`tsdown`,`runnable`],version:`workspace:^`,isDevDependency:!0},"@types/node":{tags:[`node`,`root`],version:`catalog:`,isDevDependency:!0},"typescript-config":{tags:[`node`],version:`workspace:^`,isDevDependency:!0},"eslint-config":{tags:[`node`,`eslint`],version:`workspace:^`,isDevDependency:!0},"vitest-config":{tags:[`node`,`vitest`],version:`workspace:^`,isDevDependency:!0}},Ly={dev:[{script:`turbo run dev`,tags:[`runnable`,`root`]},{script:`tsx watch src/index.ts`,tags:[`runnable`,`node`,`backend`,`express`]},{script:`email dev --port 3014 --dir ./src`,tags:[`node`,`mail`]},{script:`react-router dev`,tags:[`react-router`,`frontend`]}],"dev:debug":[{script:`turbo run dev:debug`,tags:[`node`,`runnable`,`root`]},{script:`tsx watch --inspect src/index.ts`,tags:[`backend`,`node`,`runnable`,`express`]}],"bun:dev":[{script:`turbo run bun:dev`,tags:[`node`,`runnable`,`root`]},{script:`bun --watch src/index.ts`,tags:[`backend`,`node`,`runnable`,`express`]}],build:[{script:`turbo run build`,tags:[`runnable`,`root`]},{script:`react-router build`,tags:[`react-router`,`frontend`,`runnable`]},{script:`tsdown --config-loader unrun`,tags:[`runnable`,`node`,`tsdown`]}],cli:[{script:`turbo run cli -- `,tags:[`runnable`,`node`,`cli`,`root`]},{script:`tsx src/index.ts`,tags:[`runnable`,`node`,`cli`,`commander`]}],start:[{script:`turbo run start`,tags:[`backend`,`runnable`,`node`,`root`]},{script:`node dist/index.mjs`,tags:[`node`,`runnable`]},{script:`react-router-serve ./build/server/index.js`,tags:[`react-router`,`frontend`]}],lint:[{script:`turbo run lint`,tags:[`node`,`eslint`,`root`]},{script:`eslint .`,tags:[`node`,`eslint`]}],"lint:fix":[{script:`turbo run lint:fix`,tags:[`node`,`eslint`,`root`]},{script:`eslint . src/**/*.ts --fix`,tags:[`node`,`eslint`]}],clean:[{script:`turbo run clean`,tags:[`root`]},{script:`rimraf dist build .turbo`,tags:[]}],"deep:clean":[{script:`turbo run deep:clean`,tags:[`root`]},{script:`rimraf node_modules dist build .turbo`,tags:[`node`]}],"db:push":[{script:`drizzle-kit push`,tags:[`drizzle`,`db`]},{script:`turbo run db:push`,tags:[`db`,`root`]}],"db:studio":[{script:`drizzle-kit studio`,tags:[`drizzle`,`db`]},{script:`turbo run db:studio`,tags:[`db`,`root`]}],typecheck:[{script:`turbo run typecheck`,tags:[`node`,`root`]},{script:`tsc --noEmit`,tags:[`node`]},{script:`react-router typegen && tsc`,tags:[`react-router`,`frontend`]}],format:[{script:`turbo run format`,tags:[`node`,`root`]},{script:`biome format --write .`,tags:[`node`,`biome`,`prettier`]},{script:`prettier --write .`,tags:[`node`,`prettier`]}],"format:check":[{script:`turbo run format:check`,tags:[`node`,`root`]},{script:`biome ci .`,tags:[`node`,`biome`,`prettier`]},{script:`prettier --check .`,tags:[`node`,`prettier`]}],test:[{script:`turbo run test`,tags:[`node`,`vitest`,`root`]},{script:`vitest run`,tags:[`node`,`vitest`]}]},Ry={packageManager:`pnpm@10.28.2`,node:`>=22`};var zy=class{static objSorter(e,t=[]){let n=Object.fromEntries(Object.entries(e).filter(([,e])=>e!=null)),r=[];for(let e of t)e in n&&(r.push([e,n[e]]),delete n[e]);for(let e of Object.entries(n))r.push(e);return Object.fromEntries(r)}static handlePackageJson(e){let t=!!e.app.devDependencies?.turbo,n=t?[...e.tags,`root`]:[...e.tags],r=t?{version:`1.0.0`,packageManager:Ry.packageManager,engines:{node:Ry.node}}:{},i=Object.fromEntries(Object.entries(Ly).map(([e,t])=>{let r=t.find(e=>e.tags.every(e=>n.includes(e)));return r?[e,r.script]:null}).filter(e=>e!==null)),a=e=>Object.fromEntries(Object.entries(e??{}).filter(([e])=>{let t=Iy[e];return!t||t.tags.every(e=>n.includes(e))})),o=a(e.app.dependencies),s=a(e.app.devDependencies);for(let[e,t]of Object.entries(o))t.includes(`workspace:`)&&delete o[e];for(let[e,t]of Object.entries(s))t.includes(`workspace:`)&&delete s[e];if(e.dependencies)for(let[t,n]of Object.entries(e.dependencies))o[t]||(o[t]=n);e.app.startx?.requiredDevDeps?.forEach(e=>s[e]=`workspace:^`),e.app.startx?.requiredDeps?.forEach(e=>o[e]=`workspace:^`);for(let[e,r]of Object.entries(Iy)){if(!r.tags.every(e=>n.includes(e))||t&&!r.tags.includes(`root`))continue;let i=r.isDevDependency;i&&!s[e]?s[e]=r.version:!i&&!o[e]&&(o[e]=r.version)}for(let t of e.app.startx?.ignore??[])delete o[t],delete s[t];let c={name:e.name||e.app.name,description:e.app.description,type:`module`,exports:e.app.exports,files:e.app.files,scripts:i,dependencies:o,devDependencies:s,...r};return{packageJson:this.objSorter(c,[`name`,`description`,`version`,`type`,`scripts`,`files`,`exports`,`dependencies`,`devDependencies`,`packageManager`,`engines`]),isWorkspace:t}}};const By=(e,t=[])=>e.name===`up`||t.includes(`vim`)&&e.name===`k`||t.includes(`emacs`)&&e.ctrl&&e.name===`p`,Vy=(e,t=[])=>e.name===`down`||t.includes(`vim`)&&e.name===`j`||t.includes(`emacs`)&&e.ctrl&&e.name===`n`,Hy=e=>e.name===`space`,Uy=e=>e.name===`backspace`,Wy=e=>e.name===`tab`,Gy=e=>`1234567890`.includes(e.name),Ky=e=>e.name===`enter`||e.name===`return`;var qy=class extends Error{name=`AbortPromptError`;message=`Prompt was aborted`;constructor(e){super(),this.cause=e?.cause}},Jy=class extends Error{name=`CancelPromptError`;message=`Prompt was canceled`},Yy=class extends Error{name=`ExitPromptError`},Xy=class extends Error{name=`HookError`},Zy=class extends Error{name=`ValidationError`};const Qy=new o;function $y(e){return{rl:e,hooks:[],hooksCleanup:[],hooksEffect:[],index:0,handleChange(){}}}function eb(e,t){let n=$y(e);return Qy.run(n,()=>{function e(e){n.handleChange=()=>{n.index=0,e()},n.handleChange()}return t(e)})}function tb(){let e=Qy.getStore();if(!e)throw new Xy(`[Inquirer] Hook functions can only be called from within a prompt`);return e}function nb(){return tb().rl}function rb(e){return s.bind((...t)=>{let n=tb(),r=!1,i=n.handleChange;n.handleChange=()=>{r=!0};let a=e(...t);return r&&i(),n.handleChange=i,a})}function ib(e){let t=tb(),{index:n}=t,r=e({get(){return t.hooks[n]},set(e){t.hooks[n]=e},initialized:n in t.hooks});return t.index++,r}function ab(){tb().handleChange()}const ob={queue(e){let t=tb(),{index:n}=t;t.hooksEffect.push(()=>{t.hooksCleanup[n]?.();let r=e(nb());if(r!=null&&typeof r!=`function`)throw new Zy(`useEffect return value must be a cleanup function or nothing.`);t.hooksCleanup[n]=r})},run(){let e=tb();rb(()=>{e.hooksEffect.forEach(e=>{e()}),e.hooksEffect.length=0})()},clearAll(){let e=tb();e.hooksCleanup.forEach(e=>{e?.()}),e.hooksEffect.length=0,e.hooksCleanup.length=0}};function sb(e){return ib(t=>{let n=s.bind(function(e){t.get()!==e&&(t.set(e),ab())});if(t.initialized)return[t.get(),n];let r=typeof e==`function`?e():e;return t.set(r),[r,n]})}function cb(e,t){ib(n=>{let r=n.get();(!Array.isArray(r)||t.some((e,t)=>!Object.is(e,r[t])))&&ob.queue(e),n.set(t)})}function lb(){return i.platform===`win32`?!!i.env.WT_SESSION||!!i.env.TERMINUS_SUBLIME||i.env.ConEmuTask===`{cmd::Cmder}`||i.env.TERM_PROGRAM===`Terminus-Sublime`||i.env.TERM_PROGRAM===`vscode`||i.env.TERM===`xterm-256color`||i.env.TERM===`alacritty`||i.env.TERMINAL_EMULATOR===`JetBrains-JediTerm`:i.env.TERM!==`linux`}const ub={circleQuestionMark:`(?)`,questionMarkPrefix:`(?)`,square:`█`,squareDarkShade:`▓`,squareMediumShade:`▒`,squareLightShade:`░`,squareTop:`▀`,squareBottom:`▄`,squareLeft:`▌`,squareRight:`▐`,squareCenter:`■`,bullet:`●`,dot:`․`,ellipsis:`…`,pointerSmall:`›`,triangleUp:`▲`,triangleUpSmall:`▴`,triangleDown:`▼`,triangleDownSmall:`▾`,triangleLeftSmall:`◂`,triangleRightSmall:`▸`,home:`⌂`,heart:`♥`,musicNote:`♪`,musicNoteBeamed:`♫`,arrowUp:`↑`,arrowDown:`↓`,arrowLeft:`←`,arrowRight:`→`,arrowLeftRight:`↔`,arrowUpDown:`↕`,almostEqual:`≈`,notEqual:`≠`,lessOrEqual:`≤`,greaterOrEqual:`≥`,identical:`≡`,infinity:`∞`,subscriptZero:`₀`,subscriptOne:`₁`,subscriptTwo:`₂`,subscriptThree:`₃`,subscriptFour:`₄`,subscriptFive:`₅`,subscriptSix:`₆`,subscriptSeven:`₇`,subscriptEight:`₈`,subscriptNine:`₉`,oneHalf:`½`,oneThird:`⅓`,oneQuarter:`¼`,oneFifth:`⅕`,oneSixth:`⅙`,oneEighth:`⅛`,twoThirds:`⅔`,twoFifths:`⅖`,threeQuarters:`¾`,threeFifths:`⅗`,threeEighths:`⅜`,fourFifths:`⅘`,fiveSixths:`⅚`,fiveEighths:`⅝`,sevenEighths:`⅞`,line:`─`,lineBold:`━`,lineDouble:`═`,lineDashed0:`┄`,lineDashed1:`┅`,lineDashed2:`┈`,lineDashed3:`┉`,lineDashed4:`╌`,lineDashed5:`╍`,lineDashed6:`╴`,lineDashed7:`╶`,lineDashed8:`╸`,lineDashed9:`╺`,lineDashed10:`╼`,lineDashed11:`╾`,lineDashed12:`−`,lineDashed13:`–`,lineDashed14:`‐`,lineDashed15:`⁃`,lineVertical:`│`,lineVerticalBold:`┃`,lineVerticalDouble:`║`,lineVerticalDashed0:`┆`,lineVerticalDashed1:`┇`,lineVerticalDashed2:`┊`,lineVerticalDashed3:`┋`,lineVerticalDashed4:`╎`,lineVerticalDashed5:`╏`,lineVerticalDashed6:`╵`,lineVerticalDashed7:`╷`,lineVerticalDashed8:`╹`,lineVerticalDashed9:`╻`,lineVerticalDashed10:`╽`,lineVerticalDashed11:`╿`,lineDownLeft:`┐`,lineDownLeftArc:`╮`,lineDownBoldLeftBold:`┓`,lineDownBoldLeft:`┒`,lineDownLeftBold:`┑`,lineDownDoubleLeftDouble:`╗`,lineDownDoubleLeft:`╖`,lineDownLeftDouble:`╕`,lineDownRight:`┌`,lineDownRightArc:`╭`,lineDownBoldRightBold:`┏`,lineDownBoldRight:`┎`,lineDownRightBold:`┍`,lineDownDoubleRightDouble:`╔`,lineDownDoubleRight:`╓`,lineDownRightDouble:`╒`,lineUpLeft:`┘`,lineUpLeftArc:`╯`,lineUpBoldLeftBold:`┛`,lineUpBoldLeft:`┚`,lineUpLeftBold:`┙`,lineUpDoubleLeftDouble:`╝`,lineUpDoubleLeft:`╜`,lineUpLeftDouble:`╛`,lineUpRight:`└`,lineUpRightArc:`╰`,lineUpBoldRightBold:`┗`,lineUpBoldRight:`┖`,lineUpRightBold:`┕`,lineUpDoubleRightDouble:`╚`,lineUpDoubleRight:`╙`,lineUpRightDouble:`╘`,lineUpDownLeft:`┤`,lineUpBoldDownBoldLeftBold:`┫`,lineUpBoldDownBoldLeft:`┨`,lineUpDownLeftBold:`┥`,lineUpBoldDownLeftBold:`┩`,lineUpDownBoldLeftBold:`┪`,lineUpDownBoldLeft:`┧`,lineUpBoldDownLeft:`┦`,lineUpDoubleDownDoubleLeftDouble:`╣`,lineUpDoubleDownDoubleLeft:`╢`,lineUpDownLeftDouble:`╡`,lineUpDownRight:`├`,lineUpBoldDownBoldRightBold:`┣`,lineUpBoldDownBoldRight:`┠`,lineUpDownRightBold:`┝`,lineUpBoldDownRightBold:`┡`,lineUpDownBoldRightBold:`┢`,lineUpDownBoldRight:`┟`,lineUpBoldDownRight:`┞`,lineUpDoubleDownDoubleRightDouble:`╠`,lineUpDoubleDownDoubleRight:`╟`,lineUpDownRightDouble:`╞`,lineDownLeftRight:`┬`,lineDownBoldLeftBoldRightBold:`┳`,lineDownLeftBoldRightBold:`┯`,lineDownBoldLeftRight:`┰`,lineDownBoldLeftBoldRight:`┱`,lineDownBoldLeftRightBold:`┲`,lineDownLeftRightBold:`┮`,lineDownLeftBoldRight:`┭`,lineDownDoubleLeftDoubleRightDouble:`╦`,lineDownDoubleLeftRight:`╥`,lineDownLeftDoubleRightDouble:`╤`,lineUpLeftRight:`┴`,lineUpBoldLeftBoldRightBold:`┻`,lineUpLeftBoldRightBold:`┷`,lineUpBoldLeftRight:`┸`,lineUpBoldLeftBoldRight:`┹`,lineUpBoldLeftRightBold:`┺`,lineUpLeftRightBold:`┶`,lineUpLeftBoldRight:`┵`,lineUpDoubleLeftDoubleRightDouble:`╩`,lineUpDoubleLeftRight:`╨`,lineUpLeftDoubleRightDouble:`╧`,lineUpDownLeftRight:`┼`,lineUpBoldDownBoldLeftBoldRightBold:`╋`,lineUpDownBoldLeftBoldRightBold:`╈`,lineUpBoldDownLeftBoldRightBold:`╇`,lineUpBoldDownBoldLeftRightBold:`╊`,lineUpBoldDownBoldLeftBoldRight:`╉`,lineUpBoldDownLeftRight:`╀`,lineUpDownBoldLeftRight:`╁`,lineUpDownLeftBoldRight:`┽`,lineUpDownLeftRightBold:`┾`,lineUpBoldDownBoldLeftRight:`╂`,lineUpDownLeftBoldRightBold:`┿`,lineUpBoldDownLeftBoldRight:`╃`,lineUpBoldDownLeftRightBold:`╄`,lineUpDownBoldLeftBoldRight:`╅`,lineUpDownBoldLeftRightBold:`╆`,lineUpDoubleDownDoubleLeftDoubleRightDouble:`╬`,lineUpDoubleDownDoubleLeftRight:`╫`,lineUpDownLeftDoubleRightDouble:`╪`,lineCross:`╳`,lineBackslash:`╲`,lineSlash:`╱`},db={tick:`✔`,info:`ℹ`,warning:`⚠`,cross:`✘`,squareSmall:`◻`,squareSmallFilled:`◼`,circle:`◯`,circleFilled:`◉`,circleDotted:`◌`,circleDouble:`◎`,circleCircle:`ⓞ`,circleCross:`ⓧ`,circlePipe:`Ⓘ`,radioOn:`◉`,radioOff:`◯`,checkboxOn:`☒`,checkboxOff:`☐`,checkboxCircleOn:`ⓧ`,checkboxCircleOff:`Ⓘ`,pointer:`❯`,triangleUpOutline:`△`,triangleLeft:`◀`,triangleRight:`▶`,lozenge:`◆`,lozengeOutline:`◇`,hamburger:`☰`,smiley:`㋡`,mustache:`෴`,star:`★`,play:`▶`,nodejs:`⬢`,oneSeventh:`⅐`,oneNinth:`⅑`,oneTenth:`⅒`},fb={tick:`√`,info:`i`,warning:`‼`,cross:`×`,squareSmall:`□`,squareSmallFilled:`■`,circle:`( )`,circleFilled:`(*)`,circleDotted:`( )`,circleDouble:`( )`,circleCircle:`(○)`,circleCross:`(×)`,circlePipe:`(│)`,radioOn:`(*)`,radioOff:`( )`,checkboxOn:`[×]`,checkboxOff:`[ ]`,checkboxCircleOn:`(×)`,checkboxCircleOff:`( )`,pointer:`>`,triangleUpOutline:`∆`,triangleLeft:`◄`,triangleRight:`►`,lozenge:`♦`,lozengeOutline:`◊`,hamburger:`≡`,smiley:`☺`,mustache:`┌─┐`,star:`✶`,play:`►`,nodejs:`♦`,oneSeventh:`1/7`,oneNinth:`1/9`,oneTenth:`1/10`},pb={...ub,...db},mb={...ub,...fb};var hb=lb()?pb:mb;Object.entries(db);const gb={prefix:{idle:l(`blue`,`?`),done:l(`green`,hb.tick)},spinner:{interval:80,frames:[`⠋`,`⠙`,`⠹`,`⠸`,`⠼`,`⠴`,`⠦`,`⠧`,`⠇`,`⠏`].map(e=>l(`yellow`,e))},style:{answer:e=>l(`cyan`,e),message:e=>l(`bold`,e),error:e=>l(`red`,`> ${e}`),defaultAnswer:e=>l(`dim`,`(${e})`),help:e=>l(`dim`,e),highlight:e=>l(`cyan`,e),key:e=>l(`cyan`,l(`bold`,`<${e}>`))}};function _b(e){if(typeof e!=`object`||!e)return!1;let t=e;for(;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function vb(...e){let t={};for(let n of e)for(let[e,r]of Object.entries(n)){let n=t[e];t[e]=_b(n)&&_b(r)?vb(n,r):r}return t}function yb(...e){return vb(gb,...e.filter(e=>e!=null))}function bb({status:e=`idle`,theme:t}){let[n,r]=sb(!1),[i,a]=sb(0),{prefix:o,spinner:s}=yb(t);return cb(()=>{if(e===`loading`){let e,t=-1,n=setTimeout(()=>{r(!0),e=setInterval(()=>{t+=1,a(t%s.frames.length)},s.interval)},300);return()=>{clearTimeout(n),clearInterval(e)}}else r(!1)},[e]),n?s.frames[i]:typeof o==`string`?o:o[e===`loading`?`idle`:e]??o.idle}function xb(e,t){return ib(n=>{let r=n.get();if(!r||r.dependencies.length!==t.length||r.dependencies.some((e,n)=>e!==t[n])){let r=e();return n.set({value:r,dependencies:t}),r}return r.value})}function Sb(e){return sb({current:e})[0]}function Cb(e){let t=Sb(e);t.current=e,cb(e=>{let n=!1,r=rb((r,i)=>{n||t.current(i,e)});return e.input.on(`keypress`,r),()=>{n=!0,e.input.removeListener(`keypress`,r)}},[])}var wb=_(((e,t)=>{t.exports=r;function n(e){let t={defaultWidth:0,output:process.stdout,tty:x(`tty`)};return e?(Object.keys(t).forEach(function(n){e[n]||(e[n]=t[n])}),e):t}function r(e){let t=n(e);if(t.output.getWindowSize)return t.output.getWindowSize()[0]||t.defaultWidth;if(t.tty.getWindowSize)return t.tty.getWindowSize()[1]||t.defaultWidth;if(t.output.columns)return t.output.columns;if(process.env.CLI_WIDTH){let e=parseInt(process.env.CLI_WIDTH,10);if(!isNaN(e)&&e!==0)return e}return t.defaultWidth}}));const Tb=(()=>{let e=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g;return t=>{let n=0;for(e.lastIndex=0;e.test(t);)n+=1;return t.length-n}})(),Eb=e=>e===12288||e>=65281&&e<=65376||e>=65504&&e<=65510,Db=e=>e===8987||e===9001||e>=12272&&e<=12287||e>=12289&&e<=12350||e>=12441&&e<=12543||e>=12549&&e<=12591||e>=12593&&e<=12686||e>=12688&&e<=12771||e>=12783&&e<=12830||e>=12832&&e<=12871||e>=12880&&e<=19903||e>=65040&&e<=65049||e>=65072&&e<=65106||e>=65108&&e<=65126||e>=65128&&e<=65131||e>=127488&&e<=127490||e>=127504&&e<=127547||e>=127552&&e<=127560||e>=131072&&e<=196605||e>=196608&&e<=262141,Ob=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y,kb=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,Ab=/(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/uy,jb=/\t{1,1000}/y,Mb=/[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/uy,Nb=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,Pb=/\p{M}+/gu,Fb={limit:1/0,ellipsis:``},Ib=(e,t={},n={})=>{let r=t.limit??1/0,i=t.ellipsis??``,a=t?.ellipsisWidth??(i?Ib(i,Fb,n).width:0),o=n.controlWidth??0,s=n.tabWidth??8,c=n.emojiWidth??2,l=n.regularWidth??1,u=n.wideWidth??2,d=[[Nb,l],[Ob,0],[kb,o],[jb,s],[Mb,c],[Ab,u]],f=0,p=0,m=e.length,h=0,g=!1,_=m,v=Math.max(0,r-a),y=0,b=0,x=0,S=0;outer:for(;;){if(b>y||p>=m&&p>f){let t=e.slice(y,b)||e.slice(f,p);h=0;for(let e of t.replaceAll(Pb,``)){let t=e.codePointAt(0)||0;if(S=Eb(t)?2:Db(t)?u:l,x+S>v&&(_=Math.min(_,Math.max(y,f)+h)),x+S>r){g=!0;break outer}h+=e.length,x+=S}y=b=0}if(p>=m)break outer;for(let t=0,n=d.length;t<n;t++){let[n,i]=d[t];if(n.lastIndex=p,n.test(e)){if(h=n===Ab?Tb(e.slice(p,n.lastIndex)):n===Mb?1:n.lastIndex-p,S=h*i,x+S>v&&(_=Math.min(_,p+Math.floor((v-x)/i))),x+S>r){g=!0;break outer}x+=S,y=f,b=p,p=f=n.lastIndex;continue outer}}p+=1}return{width:g?v:x,index:g?_:m,truncated:g,ellipsed:g&&r>=a}};var Lb=Ib;const Rb={limit:1/0,ellipsis:``,ellipsisWidth:0};var zb=(e,t={})=>Lb(e,Rb,t).width;const Bb=`]8;;`,Vb=RegExp(`(?:\\[(?<code>\\d+)m|\\${Bb}(?<uri>.*))`,`y`),Hb=e=>{if(e>=30&&e<=37||e>=90&&e<=97)return 39;if(e>=40&&e<=47||e>=100&&e<=107)return 49;if(e===1||e===2)return 22;if(e===3)return 23;if(e===4)return 24;if(e===7)return 27;if(e===8)return 28;if(e===9)return 29;if(e===0)return 0},Ub=e=>`[${e}m`,Wb=e=>`${Bb}${e}`,Gb=(e,t,n)=>{let r=t[Symbol.iterator](),i=!1,a=!1,o=e.at(-1),s=o===void 0?0:zb(o),c=r.next(),l=r.next(),u=0;for(;!c.done;){let o=c.value,d=zb(o);s+d<=n?e[e.length-1]+=o:(e.push(o),s=0),(o===`\x1B`||o===`›`)&&(i=!0,a=t.startsWith(Bb,u+1)),i?a?o===`\x07`&&(i=!1,a=!1):o===`m`&&(i=!1):(s+=d,s===n&&!l.done&&(e.push(``),s=0)),c=l,l=r.next(),u+=o.length}o=e.at(-1),!s&&o!==void 0&&o.length&&e.length>1&&(e[e.length-2]+=e.pop())},Kb=e=>{let t=e.split(` `),n=t.length;for(;n&&!zb(t[n-1]);)n--;return n===t.length?e:t.slice(0,n).join(` `)+t.slice(n).join(``)},qb=(e,t,n={})=>{if(n.trim!==!1&&e.trim()===``)return``;let r=``,i,a,o=e.split(` `),s=[``],c=0;for(let e=0;e<o.length;e++){let r=o[e];if(n.trim!==!1){let e=s.at(-1)??``,t=e.trimStart();e.length!==t.length&&(s[s.length-1]=t,c=zb(t))}e!==0&&(c>=t&&(n.wordWrap===!1||n.trim===!1)&&(s.push(``),c=0),(c||n.trim===!1)&&(s[s.length-1]+=` `,c++));let i=zb(r);if(n.hard&&i>t){let e=t-c,n=1+Math.floor((i-e-1)/t);Math.floor((i-1)/t)<n&&s.push(``),Gb(s,r,t),c=zb(s.at(-1)??``);continue}if(c+i>t&&c&&i){if(n.wordWrap===!1&&c<t){Gb(s,r,t),c=zb(s.at(-1)??``);continue}s.push(``),c=0}if(c+i>t&&n.wordWrap===!1){Gb(s,r,t),c=zb(s.at(-1)??``);continue}s[s.length-1]+=r,c+=i}n.trim!==!1&&(s=s.map(e=>Kb(e)));let l=s.join(`
202
+ `,e)+1}return{type:e,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(e){switch(this.type){case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:return this.flowScalar(this.type);case`block-scalar-header`:return{type:`block-scalar`,offset:this.offset,indent:this.indent,props:[this.sourceToken],source:``};case`flow-map-start`:case`flow-seq-start`:return{type:`flow-collection`,offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case`seq-item-ind`:return{type:`block-seq`,offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case`explicit-key-ind`:{this.onKeyLine=!0;let t=c(s(e));return t.push(this.sourceToken),{type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:t,explicitKey:!0}]}}case`map-value-ind`:{this.onKeyLine=!0;let t=c(s(e));return{type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:t,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,t){return this.type!==`comment`||this.indent<=t?!1:e.every(e=>e.type===`newline`||e.type===`space`)}*documentEnd(e){this.type!==`doc-mode`&&(e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type===`newline`&&(yield*this.pop()))}*lineEnd(e){switch(this.type){case`comma`:case`doc-start`:case`doc-end`:case`flow-seq-end`:case`flow-map-end`:case`map-value-ind`:yield*this.pop(),yield*this.step();break;case`newline`:this.onKeyLine=!1;default:e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type===`newline`&&(yield*this.pop())}}}})),ky=_((e=>{var t=xy(),n=iy(),r=ay(),i=kv(),a=$(),o=Dy(),s=Oy();function c(e){let t=e.prettyErrors!==!1;return{lineCounter:e.lineCounter||t&&new o.LineCounter||null,prettyErrors:t}}function l(e,n={}){let{lineCounter:i,prettyErrors:a}=c(n),o=new s.Parser(i?.addNewLine),l=new t.Composer(n),u=Array.from(l.compose(o.parse(e)));if(a&&i)for(let t of u)t.errors.forEach(r.prettifyError(e,i)),t.warnings.forEach(r.prettifyError(e,i));return u.length>0?u:Object.assign([],{empty:!0},l.streamInfo())}function u(e,n={}){let{lineCounter:i,prettyErrors:a}=c(n),o=new s.Parser(i?.addNewLine),l=new t.Composer(n),u=null;for(let t of l.compose(o.parse(e),!0,e.length))if(!u)u=t;else if(u.options.logLevel!==`silent`){u.errors.push(new r.YAMLParseError(t.range.slice(0,2),`MULTIPLE_DOCS`,`Source contains multiple documents; please use YAML.parseAllDocuments()`));break}return a&&i&&(u.errors.forEach(r.prettifyError(e,i)),u.warnings.forEach(r.prettifyError(e,i))),u}function d(e,t,n){let r;typeof t==`function`?r=t:n===void 0&&t&&typeof t==`object`&&(n=t);let a=u(e,n);if(!a)return null;if(a.warnings.forEach(e=>i.warn(a.options.logLevel,e)),a.errors.length>0){if(a.options.logLevel!==`silent`)throw a.errors[0];a.errors=[]}return a.toJS(Object.assign({reviver:r},n))}function f(e,t,r){let i=null;if(typeof t==`function`||Array.isArray(t)?i=t:r===void 0&&t&&(r=t),typeof r==`string`&&(r=r.length),typeof r==`number`){let e=Math.round(r);r=e<1?void 0:e>8?{indent:8}:{indent:e}}if(e===void 0){let{keepUndefined:e}=r??t??{};if(!e)return}return a.isDocument(e)&&!i?e.toString(r):new n.Document(e,i,r).toString(r)}e.parse=d,e.parseAllDocuments=l,e.parseDocument=u,e.stringify=f})),Ay=b(_((e=>{var t=xy(),n=iy(),r=ny(),i=ay(),a=bv(),o=$(),s=Mv(),c=xv(),l=Pv(),u=Iv();Ty();var d=Ey(),f=Dy(),p=Oy(),m=ky(),h=mv();e.Composer=t.Composer,e.Document=n.Document,e.Schema=r.Schema,e.YAMLError=i.YAMLError,e.YAMLParseError=i.YAMLParseError,e.YAMLWarning=i.YAMLWarning,e.Alias=a.Alias,e.isAlias=o.isAlias,e.isCollection=o.isCollection,e.isDocument=o.isDocument,e.isMap=o.isMap,e.isNode=o.isNode,e.isPair=o.isPair,e.isScalar=o.isScalar,e.isSeq=o.isSeq,e.Pair=s.Pair,e.Scalar=c.Scalar,e.YAMLMap=l.YAMLMap,e.YAMLSeq=u.YAMLSeq,e.Lexer=d.Lexer,e.LineCounter=f.LineCounter,e.Parser=p.Parser,e.parse=m.parse,e.parseAllDocuments=m.parseAllDocuments,e.parseDocument=m.parseDocument,e.stringify=m.stringify,e.visit=h.visit,e.visitAsync=h.visitAsync}))(),1);function jy(){return Kh.NODE_ENV===`development`?t.resolve(process.cwd(),`../../`):process.cwd()}const My=new class{root=jy();async pathExists(e){try{return await a.access(e),!0}catch{return!1}}async writeFile({file:e,content:n}){await a.writeFile(t.resolve(this.root,e),n)}async writeJSONFile({file:e,content:n,dir:r}){e=`${e}.json`;let i=t.resolve(this.root,e);if(r){let n=t.resolve(this.root,r);await this.ensurePathExists({dir:r}),i=t.resolve(n,e)}await a.writeFile(i,JSON.stringify(n,null,2))}async readFile({file:e}){return await a.readFile(t.resolve(this.root,e),`utf-8`)}async readJSONFile({file:e,dir:n}){try{e=`${e}.json`;let r=t.resolve(this.root,n??``,e),i=await a.readFile(r,`utf-8`);return JSON.parse(i)}catch(t){return console.error(`Failed to read JSON file at ${e}:`,t),null}}async readYamlFile({file:e,dir:n}){try{e=`${e}.yaml`;let r=t.resolve(this.root,n??``,e),i=await a.readFile(r,`utf-8`);return Ay.parseDocument(i)}catch(t){return console.error(`Failed to read Yaml file at ${e}:`,t),null}}async ensurePathExists({dir:e}){let n=t.resolve(this.root,e);await this.pathExists(n)||await a.mkdir(n,{recursive:!0})}async avoidOverriding({file:e}){let n=t.resolve(this.root,e);if(await this.pathExists(n))throw Error(`File ${n} already exists`)}async removeFile({file:e}){let n=t.resolve(this.root,e);await this.pathExists(n)&&await a.unlink(n)}async removeDirectory({dir:e,target:n}){let r=t.resolve(this.root,e,n);await this.pathExists(r)&&await a.rm(r,{recursive:!0,force:!0})}async copyFile({from:e,to:n}){await this.ensurePathExists({dir:t.dirname(n)}),await a.copyFile(t.resolve(this.root,e),t.resolve(this.root,n))}async copyDirectory({from:e,to:n,recursive:r=!0,include:i,exclude:o}){let s=t.resolve(this.root,e),c=t.resolve(this.root,n);if(!await this.pathExists(s))return;await this.ensurePathExists({dir:t.join(n)});let l=await a.readdir(s,{withFileTypes:!0});for(let u of l){let l=t.join(s,u.name),d=t.join(c,u.name),f=(!i||i.test(u.name))&&(!o||!o.test(u.name));u.isDirectory()?r&&await this.copyDirectory({from:t.join(e,u.name),to:t.join(n,u.name),recursive:r,include:i,exclude:o}):u.isFile()&&f&&await a.copyFile(l,d)}}async listDirectories({dir:e}){try{return(await a.readdir(t.resolve(this.root,e),{withFileTypes:!0})).filter(e=>e.isDirectory()).map(e=>e.name)}catch(t){return console.error(`Error listing directories in ${e}:`,t),[]}}async listFiles({dir:e}){try{return(await a.readdir(t.resolve(this.root,e),{withFileTypes:!0})).filter(e=>e.isFile()).map(e=>e.name)}catch(t){return console.error(`Error listing files in ${e}:`,t),[]}}},Ny={"startx.json":{tags:[`never`]},".npmignore":{tags:[`never`]},".npmrc":{tags:[`never`]},".prettier.cjs":{tags:[`prettier`]},".prettierignore":{tags:[`biome`]},"biome.json":{tags:[`biome`]},"pnpm-lock.yaml":{tags:[`never`]},"pnpm-workspace.yaml":{tags:[`root`]},"turbo.json":{tags:[`root`]},LICENSE:{tags:[`never`]},".env":{tags:[`never`]},"tsdown.config.ts":{tags:[`tsdown`]},"eslint.config.ts":{tags:[`eslint`,`node`]},"vitest.config.ts":{tags:[`vitest`,`node`]},"package.json":{tags:[`never`]}},Py=Gh({STARTX_ENV:Bp.enum([`development`,`production`,`test`,`staging`]).default(`production`)});var Fy=class{static getDirectory(){let e=r(import.meta.url),n=t.dirname(e),i=process.cwd();return n=Py.STARTX_ENV===`development`?t.resolve(n,`../../../../`):t.resolve(n,`../../../`),{template:n,workspace:i}}static async getPackageList(){let e=this.getDirectory().template,n=async(n,r,i=``,a)=>{let o=t.join(e,...n.split(`/`));try{let n=await My.listDirectories({dir:o});return a&&(n=n.filter(a)),(await Promise.all(n.map(async n=>{let a=t.join(o,n),s=t.relative(e,a),c=i?`${i}${n}`:n,l;try{l=await this.parsePackageJson({dir:a})}catch{l=null}return l?{type:r,path:a,relativePath:s,name:c,packageJson:l}:(console.error(`Ignoring this package failed to read package.json: ${c}`),null)}))).filter(e=>e!==null)}catch(e){return console.error(`Error reading directory ${o}:`,e),[]}},r=[`@repo`,`@db`];return(await Promise.all([n(`apps`,`apps`),n(`configs`,`configs`),n(`packages`,`packages`,``,e=>!r.includes(e)),n(`packages/@repo`,`packages`,`@repo/`),n(`packages/@db`,`packages`,`@db/`)])).flat()}static async parsePackageJson({dir:e,file:t=`package`}){return await My.readJSONFile({dir:e,file:t})}static async parsePnpmWorkspace({dir:e}){return(await My.readYamlFile({file:`pnpm-workspace`,dir:e}))?.toJSON()}};const Iy={"@biomejs/biome":{tags:[`node`,`biome`,`root`],version:`catalog:`,isDevDependency:!0},prettier:{tags:[`node`,`prettier`,`root`],version:`catalog:`,isDevDependency:!0},eslint:{tags:[`node`,`eslint`,`root`],version:`catalog:`,isDevDependency:!0},vitest:{tags:[`node`,`vitest`,`root`],version:`catalog:`,isDevDependency:!0},tsdown:{isDevDependency:!0,tags:[`node`,`tsdown`,`root`],version:`catalog:`},"tsdown-config":{tags:[`node`,`tsdown`,`runnable`],version:`workspace:^`,isDevDependency:!0},"@types/node":{tags:[`node`,`root`],version:`catalog:`,isDevDependency:!0},"typescript-config":{tags:[`node`],version:`workspace:^`,isDevDependency:!0},"eslint-config":{tags:[`node`,`eslint`],version:`workspace:^`,isDevDependency:!0},"vitest-config":{tags:[`node`,`vitest`],version:`workspace:^`,isDevDependency:!0}},Ly={dev:[{script:`turbo run dev`,tags:[`runnable`,`root`]},{script:`tsx watch src/index.ts`,tags:[`runnable`,`node`,`backend`,`express`]},{script:`email dev --port 3014 --dir ./src`,tags:[`node`,`mail`]},{script:`react-router dev`,tags:[`react-router`,`frontend`]}],"dev:debug":[{script:`turbo run dev:debug`,tags:[`node`,`runnable`,`root`]},{script:`tsx watch --inspect src/index.ts`,tags:[`backend`,`node`,`runnable`,`express`]}],"bun:dev":[{script:`turbo run bun:dev`,tags:[`node`,`runnable`,`root`]},{script:`bun --watch src/index.ts`,tags:[`backend`,`node`,`runnable`,`express`]}],build:[{script:`turbo run build`,tags:[`runnable`,`root`]},{script:`react-router build`,tags:[`react-router`,`frontend`,`runnable`]},{script:`tsdown --config-loader unrun`,tags:[`runnable`,`node`,`tsdown`]}],cli:[{script:`turbo run cli -- `,tags:[`runnable`,`node`,`cli`,`root`]},{script:`tsx src/index.ts`,tags:[`runnable`,`node`,`cli`,`commander`]}],start:[{script:`turbo run start`,tags:[`backend`,`runnable`,`node`,`root`]},{script:`node dist/index.mjs`,tags:[`node`,`runnable`]},{script:`react-router-serve ./build/server/index.js`,tags:[`react-router`,`frontend`]}],lint:[{script:`turbo run lint`,tags:[`node`,`eslint`,`root`]},{script:`eslint .`,tags:[`node`,`eslint`]}],"lint:fix":[{script:`turbo run lint:fix`,tags:[`node`,`eslint`,`root`]},{script:`eslint . src/**/*.ts --fix`,tags:[`node`,`eslint`]}],clean:[{script:`turbo run clean`,tags:[`root`]},{script:`rimraf dist build .turbo`,tags:[]}],"deep:clean":[{script:`turbo run deep:clean`,tags:[`root`]},{script:`rimraf node_modules dist build .turbo`,tags:[`node`]}],"db:push":[{script:`drizzle-kit push`,tags:[`drizzle`,`db`]},{script:`turbo run db:push`,tags:[`db`,`root`]}],"db:studio":[{script:`drizzle-kit studio`,tags:[`drizzle`,`db`]},{script:`turbo run db:studio`,tags:[`db`,`root`]}],"db:pull":[{script:`drizzle-kit pull`,tags:[`drizzle`,`db`]},{script:`turbo run db:pull`,tags:[`db`,`root`]}],"db:generate":[{script:`drizzle-kit generate`,tags:[`drizzle`,`db`]},{script:`turbo run db:generate`,tags:[`db`,`root`]}],"db:migrate":[{script:`drizzle-kit migrate`,tags:[`drizzle`,`db`]},{script:`turbo run db:migrate`,tags:[`db`,`root`]}],"db:check":[{script:`drizzle-kit check`,tags:[`drizzle`,`db`]},{script:`turbo run db:check`,tags:[`db`,`root`]}],typecheck:[{script:`turbo run typecheck`,tags:[`node`,`root`]},{script:`tsc --noEmit`,tags:[`node`]},{script:`react-router typegen && tsc`,tags:[`react-router`,`frontend`]}],format:[{script:`turbo run format`,tags:[`node`,`root`]},{script:`biome format --write .`,tags:[`node`,`biome`,`prettier`]},{script:`prettier --write .`,tags:[`node`,`prettier`]}],"format:check":[{script:`turbo run format:check`,tags:[`node`,`root`]},{script:`biome ci .`,tags:[`node`,`biome`,`prettier`]},{script:`prettier --check .`,tags:[`node`,`prettier`]}],test:[{script:`turbo run test`,tags:[`node`,`vitest`,`root`]},{script:`vitest run`,tags:[`node`,`vitest`]}]},Ry={packageManager:`pnpm@10.28.2`,node:`>=22`};var zy=class{static objSorter(e,t=[]){let n=Object.fromEntries(Object.entries(e).filter(([,e])=>e!=null)),r=[];for(let e of t)e in n&&(r.push([e,n[e]]),delete n[e]);for(let e of Object.entries(n))r.push(e);return Object.fromEntries(r)}static handlePackageJson(e){let t=!!e.app.devDependencies?.turbo,n=t?[...e.tags,`root`]:[...e.tags],r=t?{version:`1.0.0`,packageManager:Ry.packageManager,engines:{node:Ry.node}}:{},i=Object.fromEntries(Object.entries(Ly).map(([e,t])=>{let r=t.find(e=>e.tags.every(e=>n.includes(e)));return r?[e,r.script]:null}).filter(e=>e!==null)),a=e=>Object.fromEntries(Object.entries(e??{}).filter(([e])=>{let t=Iy[e];return!t||t.tags.every(e=>n.includes(e))})),o=a(e.app.dependencies),s=a(e.app.devDependencies);for(let[e,t]of Object.entries(o))t.includes(`workspace:`)&&delete o[e];for(let[e,t]of Object.entries(s))t.includes(`workspace:`)&&delete s[e];if(e.dependencies)for(let[t,n]of Object.entries(e.dependencies))o[t]||(o[t]=n);e.app.startx?.requiredDevDeps?.forEach(e=>s[e]=`workspace:^`),e.app.startx?.requiredDeps?.forEach(e=>o[e]=`workspace:^`);for(let[e,r]of Object.entries(Iy)){if(!r.tags.every(e=>n.includes(e))||t&&!r.tags.includes(`root`))continue;let i=r.isDevDependency;i&&!s[e]?s[e]=r.version:!i&&!o[e]&&(o[e]=r.version)}for(let t of e.app.startx?.ignore??[])delete o[t],delete s[t];let c={name:e.name||e.app.name,description:e.app.description,type:`module`,exports:e.app.exports,files:e.app.files,scripts:i,dependencies:o,devDependencies:s,...r};return{packageJson:this.objSorter(c,[`name`,`description`,`version`,`type`,`scripts`,`files`,`exports`,`dependencies`,`devDependencies`,`packageManager`,`engines`]),isWorkspace:t}}};const By=(e,t=[])=>e.name===`up`||t.includes(`vim`)&&e.name===`k`||t.includes(`emacs`)&&e.ctrl&&e.name===`p`,Vy=(e,t=[])=>e.name===`down`||t.includes(`vim`)&&e.name===`j`||t.includes(`emacs`)&&e.ctrl&&e.name===`n`,Hy=e=>e.name===`space`,Uy=e=>e.name===`backspace`,Wy=e=>e.name===`tab`,Gy=e=>`1234567890`.includes(e.name),Ky=e=>e.name===`enter`||e.name===`return`;var qy=class extends Error{name=`AbortPromptError`;message=`Prompt was aborted`;constructor(e){super(),this.cause=e?.cause}},Jy=class extends Error{name=`CancelPromptError`;message=`Prompt was canceled`},Yy=class extends Error{name=`ExitPromptError`},Xy=class extends Error{name=`HookError`},Zy=class extends Error{name=`ValidationError`};const Qy=new o;function $y(e){return{rl:e,hooks:[],hooksCleanup:[],hooksEffect:[],index:0,handleChange(){}}}function eb(e,t){let n=$y(e);return Qy.run(n,()=>{function e(e){n.handleChange=()=>{n.index=0,e()},n.handleChange()}return t(e)})}function tb(){let e=Qy.getStore();if(!e)throw new Xy(`[Inquirer] Hook functions can only be called from within a prompt`);return e}function nb(){return tb().rl}function rb(e){return s.bind((...t)=>{let n=tb(),r=!1,i=n.handleChange;n.handleChange=()=>{r=!0};let a=e(...t);return r&&i(),n.handleChange=i,a})}function ib(e){let t=tb(),{index:n}=t,r=e({get(){return t.hooks[n]},set(e){t.hooks[n]=e},initialized:n in t.hooks});return t.index++,r}function ab(){tb().handleChange()}const ob={queue(e){let t=tb(),{index:n}=t;t.hooksEffect.push(()=>{t.hooksCleanup[n]?.();let r=e(nb());if(r!=null&&typeof r!=`function`)throw new Zy(`useEffect return value must be a cleanup function or nothing.`);t.hooksCleanup[n]=r})},run(){let e=tb();rb(()=>{e.hooksEffect.forEach(e=>{e()}),e.hooksEffect.length=0})()},clearAll(){let e=tb();e.hooksCleanup.forEach(e=>{e?.()}),e.hooksEffect.length=0,e.hooksCleanup.length=0}};function sb(e){return ib(t=>{let n=s.bind(function(e){t.get()!==e&&(t.set(e),ab())});if(t.initialized)return[t.get(),n];let r=typeof e==`function`?e():e;return t.set(r),[r,n]})}function cb(e,t){ib(n=>{let r=n.get();(!Array.isArray(r)||t.some((e,t)=>!Object.is(e,r[t])))&&ob.queue(e),n.set(t)})}function lb(){return i.platform===`win32`?!!i.env.WT_SESSION||!!i.env.TERMINUS_SUBLIME||i.env.ConEmuTask===`{cmd::Cmder}`||i.env.TERM_PROGRAM===`Terminus-Sublime`||i.env.TERM_PROGRAM===`vscode`||i.env.TERM===`xterm-256color`||i.env.TERM===`alacritty`||i.env.TERMINAL_EMULATOR===`JetBrains-JediTerm`:i.env.TERM!==`linux`}const ub={circleQuestionMark:`(?)`,questionMarkPrefix:`(?)`,square:`█`,squareDarkShade:`▓`,squareMediumShade:`▒`,squareLightShade:`░`,squareTop:`▀`,squareBottom:`▄`,squareLeft:`▌`,squareRight:`▐`,squareCenter:`■`,bullet:`●`,dot:`․`,ellipsis:`…`,pointerSmall:`›`,triangleUp:`▲`,triangleUpSmall:`▴`,triangleDown:`▼`,triangleDownSmall:`▾`,triangleLeftSmall:`◂`,triangleRightSmall:`▸`,home:`⌂`,heart:`♥`,musicNote:`♪`,musicNoteBeamed:`♫`,arrowUp:`↑`,arrowDown:`↓`,arrowLeft:`←`,arrowRight:`→`,arrowLeftRight:`↔`,arrowUpDown:`↕`,almostEqual:`≈`,notEqual:`≠`,lessOrEqual:`≤`,greaterOrEqual:`≥`,identical:`≡`,infinity:`∞`,subscriptZero:`₀`,subscriptOne:`₁`,subscriptTwo:`₂`,subscriptThree:`₃`,subscriptFour:`₄`,subscriptFive:`₅`,subscriptSix:`₆`,subscriptSeven:`₇`,subscriptEight:`₈`,subscriptNine:`₉`,oneHalf:`½`,oneThird:`⅓`,oneQuarter:`¼`,oneFifth:`⅕`,oneSixth:`⅙`,oneEighth:`⅛`,twoThirds:`⅔`,twoFifths:`⅖`,threeQuarters:`¾`,threeFifths:`⅗`,threeEighths:`⅜`,fourFifths:`⅘`,fiveSixths:`⅚`,fiveEighths:`⅝`,sevenEighths:`⅞`,line:`─`,lineBold:`━`,lineDouble:`═`,lineDashed0:`┄`,lineDashed1:`┅`,lineDashed2:`┈`,lineDashed3:`┉`,lineDashed4:`╌`,lineDashed5:`╍`,lineDashed6:`╴`,lineDashed7:`╶`,lineDashed8:`╸`,lineDashed9:`╺`,lineDashed10:`╼`,lineDashed11:`╾`,lineDashed12:`−`,lineDashed13:`–`,lineDashed14:`‐`,lineDashed15:`⁃`,lineVertical:`│`,lineVerticalBold:`┃`,lineVerticalDouble:`║`,lineVerticalDashed0:`┆`,lineVerticalDashed1:`┇`,lineVerticalDashed2:`┊`,lineVerticalDashed3:`┋`,lineVerticalDashed4:`╎`,lineVerticalDashed5:`╏`,lineVerticalDashed6:`╵`,lineVerticalDashed7:`╷`,lineVerticalDashed8:`╹`,lineVerticalDashed9:`╻`,lineVerticalDashed10:`╽`,lineVerticalDashed11:`╿`,lineDownLeft:`┐`,lineDownLeftArc:`╮`,lineDownBoldLeftBold:`┓`,lineDownBoldLeft:`┒`,lineDownLeftBold:`┑`,lineDownDoubleLeftDouble:`╗`,lineDownDoubleLeft:`╖`,lineDownLeftDouble:`╕`,lineDownRight:`┌`,lineDownRightArc:`╭`,lineDownBoldRightBold:`┏`,lineDownBoldRight:`┎`,lineDownRightBold:`┍`,lineDownDoubleRightDouble:`╔`,lineDownDoubleRight:`╓`,lineDownRightDouble:`╒`,lineUpLeft:`┘`,lineUpLeftArc:`╯`,lineUpBoldLeftBold:`┛`,lineUpBoldLeft:`┚`,lineUpLeftBold:`┙`,lineUpDoubleLeftDouble:`╝`,lineUpDoubleLeft:`╜`,lineUpLeftDouble:`╛`,lineUpRight:`└`,lineUpRightArc:`╰`,lineUpBoldRightBold:`┗`,lineUpBoldRight:`┖`,lineUpRightBold:`┕`,lineUpDoubleRightDouble:`╚`,lineUpDoubleRight:`╙`,lineUpRightDouble:`╘`,lineUpDownLeft:`┤`,lineUpBoldDownBoldLeftBold:`┫`,lineUpBoldDownBoldLeft:`┨`,lineUpDownLeftBold:`┥`,lineUpBoldDownLeftBold:`┩`,lineUpDownBoldLeftBold:`┪`,lineUpDownBoldLeft:`┧`,lineUpBoldDownLeft:`┦`,lineUpDoubleDownDoubleLeftDouble:`╣`,lineUpDoubleDownDoubleLeft:`╢`,lineUpDownLeftDouble:`╡`,lineUpDownRight:`├`,lineUpBoldDownBoldRightBold:`┣`,lineUpBoldDownBoldRight:`┠`,lineUpDownRightBold:`┝`,lineUpBoldDownRightBold:`┡`,lineUpDownBoldRightBold:`┢`,lineUpDownBoldRight:`┟`,lineUpBoldDownRight:`┞`,lineUpDoubleDownDoubleRightDouble:`╠`,lineUpDoubleDownDoubleRight:`╟`,lineUpDownRightDouble:`╞`,lineDownLeftRight:`┬`,lineDownBoldLeftBoldRightBold:`┳`,lineDownLeftBoldRightBold:`┯`,lineDownBoldLeftRight:`┰`,lineDownBoldLeftBoldRight:`┱`,lineDownBoldLeftRightBold:`┲`,lineDownLeftRightBold:`┮`,lineDownLeftBoldRight:`┭`,lineDownDoubleLeftDoubleRightDouble:`╦`,lineDownDoubleLeftRight:`╥`,lineDownLeftDoubleRightDouble:`╤`,lineUpLeftRight:`┴`,lineUpBoldLeftBoldRightBold:`┻`,lineUpLeftBoldRightBold:`┷`,lineUpBoldLeftRight:`┸`,lineUpBoldLeftBoldRight:`┹`,lineUpBoldLeftRightBold:`┺`,lineUpLeftRightBold:`┶`,lineUpLeftBoldRight:`┵`,lineUpDoubleLeftDoubleRightDouble:`╩`,lineUpDoubleLeftRight:`╨`,lineUpLeftDoubleRightDouble:`╧`,lineUpDownLeftRight:`┼`,lineUpBoldDownBoldLeftBoldRightBold:`╋`,lineUpDownBoldLeftBoldRightBold:`╈`,lineUpBoldDownLeftBoldRightBold:`╇`,lineUpBoldDownBoldLeftRightBold:`╊`,lineUpBoldDownBoldLeftBoldRight:`╉`,lineUpBoldDownLeftRight:`╀`,lineUpDownBoldLeftRight:`╁`,lineUpDownLeftBoldRight:`┽`,lineUpDownLeftRightBold:`┾`,lineUpBoldDownBoldLeftRight:`╂`,lineUpDownLeftBoldRightBold:`┿`,lineUpBoldDownLeftBoldRight:`╃`,lineUpBoldDownLeftRightBold:`╄`,lineUpDownBoldLeftBoldRight:`╅`,lineUpDownBoldLeftRightBold:`╆`,lineUpDoubleDownDoubleLeftDoubleRightDouble:`╬`,lineUpDoubleDownDoubleLeftRight:`╫`,lineUpDownLeftDoubleRightDouble:`╪`,lineCross:`╳`,lineBackslash:`╲`,lineSlash:`╱`},db={tick:`✔`,info:`ℹ`,warning:`⚠`,cross:`✘`,squareSmall:`◻`,squareSmallFilled:`◼`,circle:`◯`,circleFilled:`◉`,circleDotted:`◌`,circleDouble:`◎`,circleCircle:`ⓞ`,circleCross:`ⓧ`,circlePipe:`Ⓘ`,radioOn:`◉`,radioOff:`◯`,checkboxOn:`☒`,checkboxOff:`☐`,checkboxCircleOn:`ⓧ`,checkboxCircleOff:`Ⓘ`,pointer:`❯`,triangleUpOutline:`△`,triangleLeft:`◀`,triangleRight:`▶`,lozenge:`◆`,lozengeOutline:`◇`,hamburger:`☰`,smiley:`㋡`,mustache:`෴`,star:`★`,play:`▶`,nodejs:`⬢`,oneSeventh:`⅐`,oneNinth:`⅑`,oneTenth:`⅒`},fb={tick:`√`,info:`i`,warning:`‼`,cross:`×`,squareSmall:`□`,squareSmallFilled:`■`,circle:`( )`,circleFilled:`(*)`,circleDotted:`( )`,circleDouble:`( )`,circleCircle:`(○)`,circleCross:`(×)`,circlePipe:`(│)`,radioOn:`(*)`,radioOff:`( )`,checkboxOn:`[×]`,checkboxOff:`[ ]`,checkboxCircleOn:`(×)`,checkboxCircleOff:`( )`,pointer:`>`,triangleUpOutline:`∆`,triangleLeft:`◄`,triangleRight:`►`,lozenge:`♦`,lozengeOutline:`◊`,hamburger:`≡`,smiley:`☺`,mustache:`┌─┐`,star:`✶`,play:`►`,nodejs:`♦`,oneSeventh:`1/7`,oneNinth:`1/9`,oneTenth:`1/10`},pb={...ub,...db},mb={...ub,...fb};var hb=lb()?pb:mb;Object.entries(db);const gb={prefix:{idle:l(`blue`,`?`),done:l(`green`,hb.tick)},spinner:{interval:80,frames:[`⠋`,`⠙`,`⠹`,`⠸`,`⠼`,`⠴`,`⠦`,`⠧`,`⠇`,`⠏`].map(e=>l(`yellow`,e))},style:{answer:e=>l(`cyan`,e),message:e=>l(`bold`,e),error:e=>l(`red`,`> ${e}`),defaultAnswer:e=>l(`dim`,`(${e})`),help:e=>l(`dim`,e),highlight:e=>l(`cyan`,e),key:e=>l(`cyan`,l(`bold`,`<${e}>`))}};function _b(e){if(typeof e!=`object`||!e)return!1;let t=e;for(;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function vb(...e){let t={};for(let n of e)for(let[e,r]of Object.entries(n)){let n=t[e];t[e]=_b(n)&&_b(r)?vb(n,r):r}return t}function yb(...e){return vb(gb,...e.filter(e=>e!=null))}function bb({status:e=`idle`,theme:t}){let[n,r]=sb(!1),[i,a]=sb(0),{prefix:o,spinner:s}=yb(t);return cb(()=>{if(e===`loading`){let e,t=-1,n=setTimeout(()=>{r(!0),e=setInterval(()=>{t+=1,a(t%s.frames.length)},s.interval)},300);return()=>{clearTimeout(n),clearInterval(e)}}else r(!1)},[e]),n?s.frames[i]:typeof o==`string`?o:o[e===`loading`?`idle`:e]??o.idle}function xb(e,t){return ib(n=>{let r=n.get();if(!r||r.dependencies.length!==t.length||r.dependencies.some((e,n)=>e!==t[n])){let r=e();return n.set({value:r,dependencies:t}),r}return r.value})}function Sb(e){return sb({current:e})[0]}function Cb(e){let t=Sb(e);t.current=e,cb(e=>{let n=!1,r=rb((r,i)=>{n||t.current(i,e)});return e.input.on(`keypress`,r),()=>{n=!0,e.input.removeListener(`keypress`,r)}},[])}var wb=_(((e,t)=>{t.exports=r;function n(e){let t={defaultWidth:0,output:process.stdout,tty:x(`tty`)};return e?(Object.keys(t).forEach(function(n){e[n]||(e[n]=t[n])}),e):t}function r(e){let t=n(e);if(t.output.getWindowSize)return t.output.getWindowSize()[0]||t.defaultWidth;if(t.tty.getWindowSize)return t.tty.getWindowSize()[1]||t.defaultWidth;if(t.output.columns)return t.output.columns;if(process.env.CLI_WIDTH){let e=parseInt(process.env.CLI_WIDTH,10);if(!isNaN(e)&&e!==0)return e}return t.defaultWidth}}));const Tb=(()=>{let e=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g;return t=>{let n=0;for(e.lastIndex=0;e.test(t);)n+=1;return t.length-n}})(),Eb=e=>e===12288||e>=65281&&e<=65376||e>=65504&&e<=65510,Db=e=>e===8987||e===9001||e>=12272&&e<=12287||e>=12289&&e<=12350||e>=12441&&e<=12543||e>=12549&&e<=12591||e>=12593&&e<=12686||e>=12688&&e<=12771||e>=12783&&e<=12830||e>=12832&&e<=12871||e>=12880&&e<=19903||e>=65040&&e<=65049||e>=65072&&e<=65106||e>=65108&&e<=65126||e>=65128&&e<=65131||e>=127488&&e<=127490||e>=127504&&e<=127547||e>=127552&&e<=127560||e>=131072&&e<=196605||e>=196608&&e<=262141,Ob=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y,kb=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,Ab=/(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/uy,jb=/\t{1,1000}/y,Mb=/[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/uy,Nb=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,Pb=/\p{M}+/gu,Fb={limit:1/0,ellipsis:``},Ib=(e,t={},n={})=>{let r=t.limit??1/0,i=t.ellipsis??``,a=t?.ellipsisWidth??(i?Ib(i,Fb,n).width:0),o=n.controlWidth??0,s=n.tabWidth??8,c=n.emojiWidth??2,l=n.regularWidth??1,u=n.wideWidth??2,d=[[Nb,l],[Ob,0],[kb,o],[jb,s],[Mb,c],[Ab,u]],f=0,p=0,m=e.length,h=0,g=!1,_=m,v=Math.max(0,r-a),y=0,b=0,x=0,S=0;outer:for(;;){if(b>y||p>=m&&p>f){let t=e.slice(y,b)||e.slice(f,p);h=0;for(let e of t.replaceAll(Pb,``)){let t=e.codePointAt(0)||0;if(S=Eb(t)?2:Db(t)?u:l,x+S>v&&(_=Math.min(_,Math.max(y,f)+h)),x+S>r){g=!0;break outer}h+=e.length,x+=S}y=b=0}if(p>=m)break outer;for(let t=0,n=d.length;t<n;t++){let[n,i]=d[t];if(n.lastIndex=p,n.test(e)){if(h=n===Ab?Tb(e.slice(p,n.lastIndex)):n===Mb?1:n.lastIndex-p,S=h*i,x+S>v&&(_=Math.min(_,p+Math.floor((v-x)/i))),x+S>r){g=!0;break outer}x+=S,y=f,b=p,p=f=n.lastIndex;continue outer}}p+=1}return{width:g?v:x,index:g?_:m,truncated:g,ellipsed:g&&r>=a}};var Lb=Ib;const Rb={limit:1/0,ellipsis:``,ellipsisWidth:0};var zb=(e,t={})=>Lb(e,Rb,t).width;const Bb=`]8;;`,Vb=RegExp(`(?:\\[(?<code>\\d+)m|\\${Bb}(?<uri>.*))`,`y`),Hb=e=>{if(e>=30&&e<=37||e>=90&&e<=97)return 39;if(e>=40&&e<=47||e>=100&&e<=107)return 49;if(e===1||e===2)return 22;if(e===3)return 23;if(e===4)return 24;if(e===7)return 27;if(e===8)return 28;if(e===9)return 29;if(e===0)return 0},Ub=e=>`[${e}m`,Wb=e=>`${Bb}${e}`,Gb=(e,t,n)=>{let r=t[Symbol.iterator](),i=!1,a=!1,o=e.at(-1),s=o===void 0?0:zb(o),c=r.next(),l=r.next(),u=0;for(;!c.done;){let o=c.value,d=zb(o);s+d<=n?e[e.length-1]+=o:(e.push(o),s=0),(o===`\x1B`||o===`›`)&&(i=!0,a=t.startsWith(Bb,u+1)),i?a?o===`\x07`&&(i=!1,a=!1):o===`m`&&(i=!1):(s+=d,s===n&&!l.done&&(e.push(``),s=0)),c=l,l=r.next(),u+=o.length}o=e.at(-1),!s&&o!==void 0&&o.length&&e.length>1&&(e[e.length-2]+=e.pop())},Kb=e=>{let t=e.split(` `),n=t.length;for(;n&&!zb(t[n-1]);)n--;return n===t.length?e:t.slice(0,n).join(` `)+t.slice(n).join(``)},qb=(e,t,n={})=>{if(n.trim!==!1&&e.trim()===``)return``;let r=``,i,a,o=e.split(` `),s=[``],c=0;for(let e=0;e<o.length;e++){let r=o[e];if(n.trim!==!1){let e=s.at(-1)??``,t=e.trimStart();e.length!==t.length&&(s[s.length-1]=t,c=zb(t))}e!==0&&(c>=t&&(n.wordWrap===!1||n.trim===!1)&&(s.push(``),c=0),(c||n.trim===!1)&&(s[s.length-1]+=` `,c++));let i=zb(r);if(n.hard&&i>t){let e=t-c,n=1+Math.floor((i-e-1)/t);Math.floor((i-1)/t)<n&&s.push(``),Gb(s,r,t),c=zb(s.at(-1)??``);continue}if(c+i>t&&c&&i){if(n.wordWrap===!1&&c<t){Gb(s,r,t),c=zb(s.at(-1)??``);continue}s.push(``),c=0}if(c+i>t&&n.wordWrap===!1){Gb(s,r,t),c=zb(s.at(-1)??``);continue}s[s.length-1]+=r,c+=i}n.trim!==!1&&(s=s.map(e=>Kb(e)));let l=s.join(`
203
203
  `),u=!1;for(let e=0;e<l.length;e++){let t=l[e];if(r+=t,u)u=!1;else if(u=t>=`\ud800`&&t<=`\udbff`,u)continue;if(t===`\x1B`||t===`›`){Vb.lastIndex=e+1;let t=Vb.exec(l)?.groups;if(t?.code!==void 0){let e=Number.parseFloat(t.code);i=e===39?void 0:e}else t?.uri!==void 0&&(a=t.uri.length===0?void 0:t.uri)}if(l[e+1]===`
204
204
  `){a&&(r+=Wb(``));let e=i?Hb(i):void 0;i&&e&&(r+=Ub(e))}else t===`
205
205
  `&&(i&&Hb(i)&&(r+=Ub(i)),a&&(r+=Wb(a)))}return r},Jb=/\r?\n/;function Yb(e,t,n){return String(e).normalize().split(Jb).map(e=>qb(e,t,n)).join(`
@@ -215,4 +215,4 @@ $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,`$1$2`).replace(/\
215
215
  `+t:``),o=Math.floor(n.length/i)-this.cursorPos.rows+(t?Sx(t):0);o>0&&(a+=_x(o)),a+=yx(this.cursorPos.cols),this.write(vx(this.extraLinesUnderPrompt)+xx(this.height)+a),this.extraLinesUnderPrompt=o,this.height=Sx(a)}checkCursorPos(){let e=this.rl.getCursorPos();e.cols!==this.cursorPos.cols&&(this.write(yx(e.cols)),this.cursorPos=e)}done({clearContent:e}){this.rl.setPrompt(``);let t=vx(this.extraLinesUnderPrompt);t+=e?xx(this.height):`
216
216
  `,t+=`\x1B[?25h`,this.write(t),this.rl.close()}},Tx=class extends Promise{static withResolver(){let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}},Ex=b(tx(),1);const Dx=globalThis.setImmediate;function Ox(){let e=Error.prepareStackTrace,t=[];try{Error.prepareStackTrace=(e,n)=>{let r=n.slice(1);return t=r,r},Error().stack}catch{return t}return Error.prepareStackTrace=e,t}function kx(e){let t=Ox();return(n,r={})=>{let{input:i=process.stdin,signal:a}=r,o=new Set,c=new Ex.default;c.pipe(r.output??process.stdout),c.mute();let l=u.createInterface({terminal:!0,input:i,output:c}),d=new wx(l),{promise:f,resolve:p,reject:m}=Tx.withResolver(),h=()=>m(new Jy);if(a){let e=()=>m(new qy({cause:a.reason}));if(a.aborted)return e(),Object.assign(f,{cancel:h});a.addEventListener(`abort`,e),o.add(()=>a.removeEventListener(`abort`,e))}o.add(px((e,t)=>{m(new Yy(`User force closed the prompt with ${e} ${t}`))}));let g=()=>m(new Yy(`User force closed the prompt with SIGINT`));return l.on(`SIGINT`,g),o.add(()=>l.removeListener(`SIGINT`,g)),eb(l,a=>{let u=s.bind(()=>ob.clearAll());l.on(`close`,u),o.add(()=>l.removeListener(`close`,u));let g=()=>{let r=()=>d.checkCursorPos();l.input.on(`keypress`,r),o.add(()=>l.input.removeListener(`keypress`,r)),a(()=>{try{let r=e(n,e=>{setImmediate(()=>p(e))});if(r===void 0){let e=t[1]?.getFileName();throw Error(`Prompt functions must return a string.\n at ${e}`)}let[i,a]=typeof r==`string`?[r]:r;d.render(i,a),ob.run()}catch(e){m(e)}})};return`readableFlowing`in i?Dx(g):g(),Object.assign(f.then(e=>(ob.clearAll(),e),e=>{throw ob.clearAll(),e}).finally(()=>{o.forEach(e=>e()),d.done({clearContent:!!r.clearPromptOnDone}),c.end()}).then(()=>f),{cancel:h})})}}var Ax=class{separator=l(`dim`,Array.from({length:15}).join(hb.line));type=`separator`;constructor(e){e&&(this.separator=e)}static isSeparator(e){return!!(e&&typeof e==`object`&&`type`in e&&e.type===`separator`)}};const jx={icon:{checked:l(`green`,hb.circleFilled),unchecked:hb.circle,cursor:hb.pointer,disabledChecked:l(`green`,hb.circleDouble),disabledUnchecked:`-`},style:{disabled:e=>l(`dim`,e),renderSelectedChoices:e=>e.map(e=>e.short).join(`, `),description:e=>l(`cyan`,e),keysHelpTip:e=>e.map(([e,t])=>`${l(`bold`,e)} ${l(`dim`,t)}`).join(l(`dim`,` • `))},i18n:{disabledError:`This option is disabled and cannot be toggled.`},keybindings:[]};function Mx(e){return!Ax.isSeparator(e)&&!e.disabled}function Nx(e){return!Ax.isSeparator(e)}function Px(e){return!Ax.isSeparator(e)&&e.checked}function Fx(e){return Mx(e)?{...e,checked:!e.checked}:e}function Ix(e){return function(t){return Mx(t)?{...t,checked:e}:t}}function Lx(e){return e.map(e=>{if(Ax.isSeparator(e))return e;if(typeof e==`string`)return{value:e,name:e,short:e,checkedName:e,disabled:!1,checked:!1};let t=e.name??String(e.value),n={value:e.value,name:t,short:e.short??t,checkedName:e.checkedName??t,disabled:e.disabled??!1,checked:e.checked??!1};return e.description&&(n.description=e.description),n})}var Rx=kx((e,t)=>{let{pageSize:n=7,loop:r=!0,required:i,validate:a=()=>!0}=e,o={all:`a`,invert:`i`,...e.shortcuts},s=yb(jx,e.theme),{keybindings:c}=s,[l,u]=sb(`idle`),d=bb({status:l,theme:s}),[f,p]=sb(Lx(e.choices)),m=xb(()=>{let e=f.findIndex(Nx),t=f.findLastIndex(Nx);if(e===-1)throw new Zy(`[checkbox prompt] No selectable choices. All choices are disabled.`);return{first:e,last:t}},[f]),[h,g]=sb(m.first),[_,v]=sb();Cb(async e=>{if(Ky(e)){let e=f.filter(Px),n=await a([...e]);i&&!e.length?v(`At least one choice must be selected`):n===!0?(u(`done`),t(e.map(e=>e.value))):v(n||`You must select a valid value`)}else if(By(e,c)||Vy(e,c)){if(_&&v(void 0),r||By(e,c)&&h!==m.first||Vy(e,c)&&h!==m.last){let t=By(e,c)?-1:1,n=h;do n=(n+t+f.length)%f.length;while(!Nx(f[n]));g(n)}}else if(Hy(e)){let e=f[h];e&&!Ax.isSeparator(e)&&(e.disabled?v(s.i18n.disabledError):(v(void 0),p(f.map((e,t)=>t===h?Fx(e):e))))}else if(e.name===o.all){let e=f.some(e=>Mx(e)&&!e.checked);p(f.map(Ix(e)))}else if(e.name===o.invert)p(f.map(Fx));else if(Gy(e)){let t=Number(e.name)-1,n=-1,r=f.findIndex(e=>Ax.isSeparator(e)?!1:(n++,n===t)),i=f[r];i&&Mx(i)&&(g(r),p(f.map((e,t)=>t===r?Fx(e):e)))}});let y=s.style.message(e.message,l),b,x=ex({items:f,active:h,renderItem({item:e,isActive:t}){if(Ax.isSeparator(e))return` ${e.separator}`;let n=t?s.icon.cursor:` `;if(e.disabled){let t=typeof e.disabled==`string`?e.disabled:`(disabled)`,r=e.checked?s.icon.disabledChecked:s.icon.disabledUnchecked;return s.style.disabled(`${n}${r} ${e.name} ${t}`)}t&&(b=e.description);let r=e.checked?s.icon.checked:s.icon.unchecked,i=e.checked?e.checkedName:e.name;return(t?s.style.highlight:e=>e)(`${n}${r} ${i}`)},pageSize:n,loop:r});if(l===`done`){let e=f.filter(Px);return[d,y,s.style.answer(s.style.renderSelectedChoices(e,f))].filter(Boolean).join(` `)}let S=[[`↑↓`,`navigate`],[`space`,`select`]];o.all&&S.push([o.all,`all`]),o.invert&&S.push([o.invert,`invert`]),S.push([`⏎`,`submit`]);let C=s.style.keysHelpTip(S);return`${[[d,y].filter(Boolean).join(` `),x,` `,b?s.style.description(b):``,_?s.style.error(_):``,C].filter(Boolean).join(`
217
217
  `).trimEnd()}${gx}`});function zx(e,t){let n=t!==!1;return/^(y|yes)/i.test(e)?n=!0:/^(n|no)/i.test(e)&&(n=!1),n}function Bx(e){return e?`Yes`:`No`}var Vx=kx((e,t)=>{let{transformer:n=Bx}=e,[r,i]=sb(`idle`),[a,o]=sb(``),s=yb(e.theme),c=bb({status:r,theme:s});Cb((s,c)=>{if(r===`idle`)if(Ky(s)){let r=zx(a,e.default);o(n(r)),i(`done`),t(r)}else if(Wy(s)){let t=Bx(!zx(a,e.default));c.clearLine(0),c.write(t),o(t)}else o(c.line)});let l=a,u=``;return r===`done`?l=s.style.answer(a):u=` ${s.style.defaultAnswer(e.default===!1?`y/N`:`Y/n`)}`,`${c} ${s.style.message(e.message,r)}${u} ${l}`});const Hx={validationFailureMode:`keep`};var Ux=kx((e,t)=>{let{prefill:n=`tab`}=e,r=yb(Hx,e.theme),[i,a]=sb(`idle`),[o,s]=sb(String(e.default??``)),[c,l]=sb(),[u,d]=sb(``),f=bb({status:i,theme:r});async function p(t){let{required:n,pattern:r,patternError:i=`Invalid input`}=e;return n&&!t?`You must provide a value`:r&&!r.test(t)?i:typeof e.validate==`function`?await e.validate(t)||`You must provide a valid value`:!0}Cb(async(e,n)=>{if(i===`idle`)if(Ky(e)){let e=u||o;a(`loading`);let i=await p(e);i===!0?(d(e),a(`done`),t(e)):(r.validationFailureMode===`clear`?d(``):n.write(u),l(i),a(`idle`))}else Uy(e)&&!u?s(``):Wy(e)&&!u?(s(``),n.clearLine(0),n.write(o),d(o)):(d(n.line),l(void 0))}),cb(e=>{n===`editable`&&o&&(e.write(o),d(o))},[]);let m=r.style.message(e.message,i),h=u;typeof e.transformer==`function`?h=e.transformer(u,{isFinal:i===`done`}):i===`done`&&(h=r.style.answer(u));let g;o&&i!==`done`&&!u&&(g=r.style.defaultAnswer(o));let _=``;return c&&(_=r.style.error(c)),[[f,m,g,h].filter(e=>e!==void 0).join(` `),_]});const Wx={icon:{cursor:hb.pointer},style:{disabled:e=>l(`dim`,e),description:e=>l(`cyan`,e),keysHelpTip:e=>e.map(([e,t])=>`${l(`bold`,e)} ${l(`dim`,t)}`).join(l(`dim`,` • `))},i18n:{disabledError:`This option is disabled and cannot be selected.`},indexMode:`hidden`,keybindings:[]};function Gx(e){return!Ax.isSeparator(e)&&!e.disabled}function Kx(e){return!Ax.isSeparator(e)}function qx(e){return e.map(e=>{if(Ax.isSeparator(e))return e;if(typeof e!=`object`||!e||!(`value`in e)){let t=String(e);return{value:e,name:t,short:t,disabled:!1}}let t=e.name??String(e.value),n={value:e.value,name:t,short:e.short??t,disabled:e.disabled??!1};return e.description&&(n.description=e.description),n})}var Jx=kx((e,t)=>{let{loop:n=!0,pageSize:r=7}=e,i=yb(Wx,e.theme),{keybindings:a}=i,[o,s]=sb(`idle`),c=bb({status:o,theme:i}),l=Sb(),u=!a.includes(`vim`),d=xb(()=>qx(e.choices),[e.choices]),f=xb(()=>{let e=d.findIndex(Kx),t=d.findLastIndex(Kx);if(e===-1)throw new Zy(`[select prompt] No selectable choices. All choices are disabled.`);return{first:e,last:t}},[d]),p=xb(()=>`default`in e?d.findIndex(t=>Gx(t)&&t.value===e.default):-1,[e.default,d]),[m,h]=sb(p===-1?f.first:p),g=d[m],[_,v]=sb();Cb((e,r)=>{if(clearTimeout(l.current),_&&v(void 0),Ky(e))g.disabled?v(i.i18n.disabledError):(s(`done`),t(g.value));else if(By(e,a)||Vy(e,a)){if(r.clearLine(0),n||By(e,a)&&m!==f.first||Vy(e,a)&&m!==f.last){let t=By(e,a)?-1:1,n=m;do n=(n+t+d.length)%d.length;while(!Kx(d[n]));h(n)}}else if(Gy(e)&&!Number.isNaN(Number(r.line))){let e=Number(r.line)-1,t=-1,n=d.findIndex(n=>Ax.isSeparator(n)?!1:(t++,t===e)),i=d[n];i!=null&&Gx(i)&&h(n),l.current=setTimeout(()=>{r.clearLine(0)},700)}else if(Uy(e))r.clearLine(0);else if(u){let e=r.line.toLowerCase(),t=d.findIndex(t=>Ax.isSeparator(t)||!Gx(t)?!1:t.name.toLowerCase().startsWith(e));t!==-1&&h(t),l.current=setTimeout(()=>{r.clearLine(0)},700)}}),cb(()=>()=>{clearTimeout(l.current)},[]);let y=i.style.message(e.message,o),b=i.style.keysHelpTip([[`↑↓`,`navigate`],[`⏎`,`select`]]),x=0,S=ex({items:d,active:m,renderItem({item:e,isActive:t,index:n}){if(Ax.isSeparator(e))return x++,` ${e.separator}`;let r=t?i.icon.cursor:` `,a=i.indexMode===`number`?`${n+1-x}. `:``;if(e.disabled){let n=typeof e.disabled==`string`?e.disabled:`(disabled)`,r=t?i.icon.cursor:`-`;return i.style.disabled(`${r} ${a}${e.name} ${n}`)}return(t?i.style.highlight:e=>e)(`${r} ${a}${e.name}`)},pageSize:r,loop:n});if(o===`done`)return[c,y,i.style.answer(g.short)].filter(Boolean).join(` `);let{description:C}=g;return`${[[c,y].filter(Boolean).join(` `),S,` `,C?i.style.description(C):``,_?i.style.error(_):``,b].filter(Boolean).join(`
218
- `).trimEnd()}${gx}`}),Yx=class{static async confirm(e){return await Vx({message:e.message,default:e.default})}static async getText(e){let{message:t,schema:n,default:r}=e,i;if(n&&r!==void 0){let e=n.safeParse(r);e.success&&(i=e.data)}else !n&&r!==void 0&&(i=r);if(n&&n instanceof wf)return await Jx({message:t,choices:n.options.map(e=>({value:e})),default:i});let a=await Ux({message:t,default:i,validate:e=>{if(!n)return!0;let t=e;if(n instanceof xd){if(e.trim()===``)return`Input cannot be empty`;let n=Number(e);if(Number.isNaN(n))return`Please enter a valid number`;t=n}let r=n.safeParse(t);return r.success?!0:r.error.issues[0]?.message??`Invalid input`}});if(!n)return a;let o=n instanceof xd?Number(a):a;return n.parse(o)}static async choose(e){let{message:t,options:n,mode:r=`single`,default:i,includeAllOption:a=!1,required:o=!1}=e,s=`__all__`,c=r===`single`?[i]:[...i||[]],l=[...r===`multiple`&&a?[{name:`All`,value:s,checked:c.includes(s)}]:[],...n.map(e=>({name:e,value:e,checked:c.includes(e)}))];if(r===`multiple`){let e=await Rx({message:t,choices:l,validate:e=>o&&e.length===0?`You must select at least one option.`:!0});return a&&e.includes(s)?n:e}return await Jx({message:t,choices:n.map(e=>({name:e,value:e})),default:typeof i==`string`?i:void 0})}},Xx=class e{static command=new uv(`init`).argument(`[projectName]`).option(`-d, --dir <path>`,`workspace directory`).action(e.run.bind(e));static async run(e,t){let n=await Fy.getPackageList(),r=n.filter(e=>e.type===`apps`&&e.packageJson?.startx?.mode!==`silent`),i=await this.getPrefs({projectName:e,options:t,projects:r}),a=n.filter(e=>e.type!==`apps`),o=await this.getConfigPrefs({selectedApps:i.selectedApps,packages:a}),s=await this.getPackagesPrefs({selectedPackages:o.selectedConfigs,packages:a,tags:o.gTags}),c=[...s.gTags,`runnable`];await this.installWorkspace({name:i.projectName,tags:[...c,`runnable`],dir:i.directory});let l=[...s.selectedPackages,...i.selectedApps];await Promise.all(l.map(async e=>{let t={},n=new Set(s.gTags);e.packageJson?.startx?.mode===`standalone`&&n.add(`runnable`),e.type===`apps`&&(n.add(`runnable`),s.selectedPackages.filter(t=>t.type!==`packages`||t.packageJson?.startx?.mode===`standalone`?!1:t.packageJson?.startx?.iTags?.every(t=>e.packageJson?.startx?.gTags?.includes(t))).forEach(e=>{let n=e.packageJson?.name||e.name;t[n]=`workspace:^`})),await this.installPackage({pkg:e,directory:i.directory,tags:Array.from(n),dependencies:t})}))}static async getPrefs(e){let n=await Yx.getText({message:`Project name`,name:`projectName`,default:e.projectName,schema:Bp.string().min(1,`Package name is required`).max(214,`Package name too long`).regex(/^(?:@[a-z0-9-~][a-z0-9-._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/,`Invalid package name`)});if(e.projects.length===0)throw Error(`No apps found to install.`);let r=Fy.getDirectory(),i=e.options.dir?t.resolve(r.workspace,e.options.dir):t.join(r.workspace,n),a=await Yx.choose({message:`Select apps to install`,options:e.projects.map(e=>e.name),includeAllOption:!0,mode:`multiple`,required:!0});return{projectName:n,directory:{workspace:i,template:r.template},selectedApps:e.projects.filter(e=>a.includes(e.name))}}static async getConfigPrefs(e){let t=new Set([`common`]),n=new Map;this.getGlobalTags({pkgs:e.selectedApps}).forEach(e=>t.add(e)),this.getPackageDeps({allPkgs:e.packages,pkgs:e.selectedApps}).forEach(e=>n.set(e.name,e));let r=e.packages.filter(e=>e.type!==`configs`||e.packageJson?.startx?.mode===`silent`||n.has(e.name)?!1:e.packageJson?.startx?.iTags?.every(e=>t.has(e))??!0);if(r.length>0){let e=await Yx.choose({message:`Select configs to install`,options:r.map(e=>e.name),includeAllOption:!0,mode:`multiple`,required:!1});r.filter(t=>e.includes(t.name)).forEach(e=>n.set(e.name,e))}return t.has(`node`)&&(await Yx.choose({message:`Select formatter`,options:[`prettier + biome`,`prettier`],mode:`single`,default:`prettier`,required:!0})===`prettier`||t.add(`biome`),t.add(`prettier`)),this.getPackageDeps({allPkgs:e.packages,pkgs:Array.from(n.values())}).forEach(e=>n.set(e.name,e)),this.getGlobalTags({pkgs:Array.from(n.values())}).forEach(e=>t.add(e)),{gTags:Array.from(t),selectedConfigs:Array.from(n.values())}}static async getPackagesPrefs(e){let t=new Set(e.tags),n=new Map(e.selectedPackages.map(e=>[e.name,e])),r=e.packages.filter(e=>e.type!==`packages`||e.packageJson?.startx?.mode===`silent`||n.has(e.name)?!1:e.packageJson?.startx?.iTags?.every(e=>t.has(e))??!1);if(r.length>0){let e=await Yx.choose({message:`Select packages to install`,options:r.map(e=>e.name),includeAllOption:!0,mode:`multiple`,required:!1});r.filter(t=>e.includes(t.name)).forEach(e=>n.set(e.name,e))}return this.getPackageDeps({allPkgs:e.packages,pkgs:Array.from(n.values())}).forEach(e=>n.set(e.name,e)),this.getGlobalTags({pkgs:Array.from(n.values())}).forEach(e=>t.add(e)),{gTags:Array.from(t),selectedPackages:Array.from(n.values())}}static async installPackage(e){if(!e.pkg.packageJson)throw Error(`Missing package.json for ${e.pkg.name}`);let n=new Set([...e.tags,...e.pkg.packageJson.startx?.tags||[]]),r=e.pkg.packageJson.startx?.ignore||[];r.includes(`eslint-config`)&&n.delete(`eslint`),r.includes(`vitest-config`)&&n.delete(`vitest`);let{packageJson:i,isWorkspace:a}=zy.handlePackageJson({app:e.pkg.packageJson,tags:Array.from(n),name:e.packageName||e.pkg.packageJson.name||e.pkg.name,dependencies:e.dependencies});if(a)throw Error(`Cannot install workspace as a package: ${e.pkg.name}`);let o=t.join(e.directory.workspace,e.pkg.relativePath),s=t.join(e.pkg.path);await My.writeJSONFile({dir:o,file:`package`,content:i}),await this.copyValidatedFilesFromFolder(s,o,n),await My.copyDirectory({from:t.join(s,`src`),to:t.join(o,`src`),exclude:n.has(`vitest`)?void 0:/\.test\.tsx?$/}),X_.info(`Successfully installed ${e.pkg.name}`)}static async installWorkspace(e){let t=await Fy.parsePackageJson({dir:e.dir.template}),n=await Fy.parsePackageJson({dir:e.dir.template,file:`startx`});if(!t)throw Error(`Failed to parse root package.json`);t.dependencies={...t.dependencies,...n?.dependencies||{}},t.devDependencies={...t.devDependencies,...n?.devDependencies||{}};let{packageJson:r}=zy.handlePackageJson({app:t,tags:[`root`,...e.tags],name:e.name});await My.writeJSONFile({dir:e.dir.workspace,file:`package`,content:r}),await this.copyValidatedFilesFromFolder(e.dir.template,e.dir.workspace,new Set([`root`,...e.tags]))}static getPackageDeps(e){let t=new Map(e.pkgs.map(e=>[e.name,e]));return Array.from(t.values()).forEach(n=>{[...n.packageJson?.startx?.requiredDeps||[],...n.packageJson?.startx?.requiredDevDeps||[]].forEach(n=>{let r=e.allPkgs.find(e=>e.packageJson?.name===n);r&&t.set(r.name,r)})}),e.pkgs.forEach(e=>t.delete(e.name)),Array.from(t.values())}static getGlobalTags(e){let t=new Set(e.gTags||[]);return e.pkgs.forEach(e=>{e.packageJson?.startx?.gTags?.forEach(e=>t.add(e))}),Array.from(t)}static async copyValidatedFilesFromFolder(e,n,r){let i=await My.listFiles({dir:e}).catch(()=>[]);for(let a of i){let i=Ny[a];if(i&&!i.tags.every(e=>r.has(e)))continue;let o=a===`_gitignore`?`.gitignore`:a;try{await My.copyFile({from:t.join(e,a),to:t.join(n,o)})}catch(e){X_.error(`Failed to copy file ${a}:`,e)}}}},Zx=`1.0.5`;const Qx=new uv;Qx.name(`startx`).description(`StartX CLI - Your all in one monorepo startup tool.`).version(Zx),Qx.command(`ping`).action(()=>{X_.info(`pong`)}),Qx.addCommand(Xx.command),Qx.parse(process.argv);export{};
218
+ `).trimEnd()}${gx}`}),Yx=class{static async confirm(e){return await Vx({message:e.message,default:e.default})}static async getText(e){let{message:t,schema:n,default:r}=e,i;if(n&&r!==void 0){let e=n.safeParse(r);e.success&&(i=e.data)}else !n&&r!==void 0&&(i=r);if(n&&n instanceof wf)return await Jx({message:t,choices:n.options.map(e=>({value:e})),default:i});let a=await Ux({message:t,default:i,validate:e=>{if(!n)return!0;let t=e;if(n instanceof xd){if(e.trim()===``)return`Input cannot be empty`;let n=Number(e);if(Number.isNaN(n))return`Please enter a valid number`;t=n}let r=n.safeParse(t);return r.success?!0:r.error.issues[0]?.message??`Invalid input`}});if(!n)return a;let o=n instanceof xd?Number(a):a;return n.parse(o)}static async choose(e){let{message:t,options:n,mode:r=`single`,default:i,includeAllOption:a=!1,required:o=!1}=e,s=`__all__`,c=r===`single`?[i]:[...i||[]],l=[...r===`multiple`&&a?[{name:`All`,value:s,checked:c.includes(s)}]:[],...n.map(e=>({name:e,value:e,checked:c.includes(e)}))];if(r===`multiple`){let e=await Rx({message:t,choices:l,validate:e=>o&&e.length===0?`You must select at least one option.`:!0});return a&&e.includes(s)?n:e}return await Jx({message:t,choices:n.map(e=>({name:e,value:e})),default:typeof i==`string`?i:void 0})}},Xx=class e{static command=new uv(`init`).argument(`[projectName]`).option(`-d, --dir <path>`,`workspace directory`).action(e.run.bind(e));static async run(e,t){let n=await Fy.getPackageList(),r=n.filter(e=>e.type===`apps`&&e.packageJson?.startx?.mode!==`silent`),i=await this.getPrefs({projectName:e,options:t,projects:r}),a=n.filter(e=>e.type!==`apps`),o=await this.getConfigPrefs({selectedApps:i.selectedApps,packages:a}),s=await this.getPackagesPrefs({selectedPackages:o.selectedConfigs,packages:a,tags:o.gTags}),c=[...s.gTags,`runnable`];await this.installWorkspace({name:i.projectName,tags:[...c,`runnable`],dir:i.directory});let l=[...s.selectedPackages,...i.selectedApps];await Promise.all(l.map(async e=>{let t={},n=new Set(s.gTags);e.packageJson?.startx?.mode===`standalone`&&n.add(`runnable`),e.type===`apps`&&(n.add(`runnable`),s.selectedPackages.filter(t=>t.type!==`packages`||t.packageJson?.startx?.mode===`standalone`?!1:t.packageJson?.startx?.iTags?.every(t=>e.packageJson?.startx?.gTags?.includes(t))).forEach(e=>{let n=e.packageJson?.name||e.name;t[n]=`workspace:^`})),await this.installPackage({pkg:e,directory:i.directory,tags:Array.from(n),dependencies:t})}))}static async getPrefs(e){let n=await Yx.getText({message:`Project name`,name:`projectName`,default:e.projectName,schema:Bp.string().min(1,`Package name is required`).max(214,`Package name too long`).regex(/^(?:@[a-z0-9-~][a-z0-9-._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/,`Invalid package name`)});if(e.projects.length===0)throw Error(`No apps found to install.`);let r=Fy.getDirectory(),i=e.options.dir?t.resolve(r.workspace,e.options.dir):t.join(r.workspace,n),a=await Yx.choose({message:`Select apps to install`,options:e.projects.map(e=>e.name),includeAllOption:!0,mode:`multiple`,required:!0});return{projectName:n,directory:{workspace:i,template:r.template},selectedApps:e.projects.filter(e=>a.includes(e.name))}}static async getConfigPrefs(e){let t=new Set([`common`]),n=new Map;this.getGlobalTags({pkgs:e.selectedApps}).forEach(e=>t.add(e)),this.getPackageDeps({allPkgs:e.packages,pkgs:e.selectedApps}).forEach(e=>n.set(e.name,e));let r=e.packages.filter(e=>e.type!==`configs`||e.packageJson?.startx?.mode===`silent`||n.has(e.name)?!1:e.packageJson?.startx?.iTags?.every(e=>t.has(e))??!0);if(r.length>0){let e=await Yx.choose({message:`Select configs to install`,options:r.map(e=>e.name),includeAllOption:!0,mode:`multiple`,required:!1});r.filter(t=>e.includes(t.name)).forEach(e=>n.set(e.name,e))}return t.has(`node`)&&(await Yx.choose({message:`Select formatter`,options:[`prettier + biome`,`prettier`],mode:`single`,default:`prettier`,required:!0})===`prettier`||t.add(`biome`),t.add(`prettier`)),this.getPackageDeps({allPkgs:e.packages,pkgs:Array.from(n.values())}).forEach(e=>n.set(e.name,e)),this.getGlobalTags({pkgs:Array.from(n.values())}).forEach(e=>t.add(e)),{gTags:Array.from(t),selectedConfigs:Array.from(n.values())}}static async getPackagesPrefs(e){let t=new Set(e.tags),n=new Map(e.selectedPackages.map(e=>[e.name,e])),r=e.packages.filter(e=>e.type!==`packages`||e.packageJson?.startx?.mode===`silent`||n.has(e.name)?!1:e.packageJson?.startx?.iTags?.every(e=>t.has(e))??!1);if(r.length>0){let e=await Yx.choose({message:`Select packages to install`,options:r.map(e=>e.name),includeAllOption:!0,mode:`multiple`,required:!1});r.filter(t=>e.includes(t.name)).forEach(e=>n.set(e.name,e))}return this.getPackageDeps({allPkgs:e.packages,pkgs:Array.from(n.values())}).forEach(e=>n.set(e.name,e)),this.getGlobalTags({pkgs:Array.from(n.values())}).forEach(e=>t.add(e)),{gTags:Array.from(t),selectedPackages:Array.from(n.values())}}static async installPackage(e){if(!e.pkg.packageJson)throw Error(`Missing package.json for ${e.pkg.name}`);let n=new Set([...e.tags,...e.pkg.packageJson.startx?.tags||[]]),r=e.pkg.packageJson.startx?.ignore||[];r.includes(`eslint-config`)&&n.delete(`eslint`),r.includes(`vitest-config`)&&n.delete(`vitest`);let{packageJson:i,isWorkspace:a}=zy.handlePackageJson({app:e.pkg.packageJson,tags:Array.from(n),name:e.packageName||e.pkg.packageJson.name||e.pkg.name,dependencies:e.dependencies});if(a)throw Error(`Cannot install workspace as a package: ${e.pkg.name}`);let o=t.join(e.directory.workspace,e.pkg.relativePath),s=t.join(e.pkg.path);await My.writeJSONFile({dir:o,file:`package`,content:i}),await this.copyValidatedFilesFromFolder(s,o,n),await My.copyDirectory({from:t.join(s,`src`),to:t.join(o,`src`),exclude:n.has(`vitest`)?void 0:/\.test\.tsx?$/}),X_.info(`Successfully installed ${e.pkg.name}`)}static async installWorkspace(e){let t=await Fy.parsePackageJson({dir:e.dir.template}),n=await Fy.parsePackageJson({dir:e.dir.template,file:`startx`});if(!t)throw Error(`Failed to parse root package.json`);t.dependencies={...t.dependencies,...n?.dependencies||{}},t.devDependencies={...t.devDependencies,...n?.devDependencies||{}};let{packageJson:r}=zy.handlePackageJson({app:t,tags:[`root`,...e.tags],name:e.name});await My.writeJSONFile({dir:e.dir.workspace,file:`package`,content:r}),await this.copyValidatedFilesFromFolder(e.dir.template,e.dir.workspace,new Set([`root`,...e.tags]))}static getPackageDeps(e){let t=new Map(e.pkgs.map(e=>[e.name,e]));return Array.from(t.values()).forEach(n=>{[...n.packageJson?.startx?.requiredDeps||[],...n.packageJson?.startx?.requiredDevDeps||[]].forEach(n=>{let r=e.allPkgs.find(e=>e.packageJson?.name===n);r&&t.set(r.name,r)})}),e.pkgs.forEach(e=>t.delete(e.name)),Array.from(t.values())}static getGlobalTags(e){let t=new Set(e.gTags||[]);return e.pkgs.forEach(e=>{e.packageJson?.startx?.gTags?.forEach(e=>t.add(e))}),Array.from(t)}static async copyValidatedFilesFromFolder(e,n,r){let i=await My.listFiles({dir:e}).catch(()=>[]);for(let a of i){let i=Ny[a];if(i&&!i.tags.every(e=>r.has(e)))continue;let o=a===`_gitignore`?`.gitignore`:a;try{await My.copyFile({from:t.join(e,a),to:t.join(n,o)})}catch(e){X_.error(`Failed to copy file ${a}:`,e)}}}},Zx=`1.0.8`;const Qx=new uv;Qx.name(`startx`).description(`StartX CLI - Your all in one monorepo startup tool.`).version(Zx),Qx.command(`ping`).action(()=>{X_.info(`pong`)}),Qx.addCommand(Xx.command),Qx.parse(process.argv);export{};
@@ -137,6 +137,46 @@ export const scripts: SCRIPT = {
137
137
  tags: ["db", "root"],
138
138
  },
139
139
  ],
140
+ "db:pull": [
141
+ {
142
+ script: "drizzle-kit pull",
143
+ tags: ["drizzle", "db"],
144
+ },
145
+ {
146
+ script: "turbo run db:pull",
147
+ tags: ["db", "root"],
148
+ },
149
+ ],
150
+ "db:generate": [
151
+ {
152
+ script: "drizzle-kit generate",
153
+ tags: ["drizzle", "db"],
154
+ },
155
+ {
156
+ script: "turbo run db:generate",
157
+ tags: ["db", "root"],
158
+ },
159
+ ],
160
+ "db:migrate": [
161
+ {
162
+ script: "drizzle-kit migrate",
163
+ tags: ["drizzle", "db"],
164
+ },
165
+ {
166
+ script: "turbo run db:migrate",
167
+ tags: ["db", "root"],
168
+ },
169
+ ],
170
+ "db:check": [
171
+ {
172
+ script: "drizzle-kit check",
173
+ tags: ["drizzle", "db"],
174
+ },
175
+ {
176
+ script: "turbo run db:check",
177
+ tags: ["db", "root"],
178
+ },
179
+ ],
140
180
  "typecheck": [
141
181
  {
142
182
  script: "turbo run typecheck",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "startx",
3
3
  "description": "",
4
- "version": "1.0.5",
4
+ "version": "1.0.8",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/avinashid/startx.git"
@@ -33,6 +33,12 @@
33
33
  "clean": "turbo clean",
34
34
  "test": "turbo test",
35
35
  "format": "turbo format",
36
- "db:push": "turbo db:push"
36
+ "db:push": "turbo run db:push",
37
+ "db:studio": "turbo run db:studio",
38
+ "db:generate": "turbo run db:generate",
39
+ "db:migrate": "turbo run db:migrate",
40
+ "db:up": "turbo run db:up",
41
+ "db:check": "turbo run db:check",
42
+ "db:pull": "turbo run db:pull"
37
43
  }
38
44
  }
@@ -6,7 +6,7 @@ const env = defineEnv({
6
6
  });
7
7
  export default defineConfig({
8
8
  out: "./drizzle",
9
- schema: "./src/schema/index.ts",
9
+ schema: "./src/schema/**/*.ts",
10
10
  dialect: "postgresql",
11
11
  dbCredentials: {
12
12
  url: env.DATABASE_URL!,
@@ -1,26 +1,15 @@
1
1
  import { defineEnv } from "@repo/env";
2
- import type { ExtractTablesWithRelations } from "drizzle-orm";
3
2
  import { drizzle, type NodePgQueryResultHKT } from "drizzle-orm/node-postgres";
4
- import { type PgTransaction } from "drizzle-orm/pg-core";
5
- import Pg from "pg";
3
+ import { PgAsyncTransaction } from "drizzle-orm/pg-core";
6
4
  import z from "zod";
7
5
 
8
- import * as schema from "./schema/index.js";
9
-
10
6
  const env = defineEnv({
11
7
  DATABASE_URL: z.string(),
12
8
  });
13
- export const client = new Pg.Pool({
14
- connectionString: env.DATABASE_URL,
15
- });
16
- const db = drizzle({ client, schema });
17
- export type DrizzleTransaction = PgTransaction<
18
- NodePgQueryResultHKT,
19
- typeof schema,
20
- ExtractTablesWithRelations<typeof schema>
21
- >;
9
+ export type DrizzleTransaction = PgAsyncTransaction<NodePgQueryResultHKT>;
10
+ const db = drizzle(env.DATABASE_URL);
11
+
22
12
  export type DrizzleDB = typeof db;
23
13
  export { db };
24
14
  export * from "drizzle-orm";
25
15
  export * from "./functions.js";
26
- export * from "./schema/index.js";