create-tezx-app 2.0.10 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin +146 -84
- package/package.json +1 -1
package/bin
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{execSync as
|
|
2
|
+
var B = Object.defineProperty; var l = (o, n) => B(o, "name", { value: n, configurable: !0 }); import { execSync as R } from "node:child_process"; import { mkdirSync as S, writeFileSync as b } from "node:fs"; import T, { join as h, resolve as _ } from "node:path"; import z from "node:readline"; const g = l((o, n) => ({ version: n, npm: ["npm install", o], bun: ["bun add", o], yarn: ["yarn add", o], pnpm: ["pnpm add", o] }), "packageManagerCommands"), N = l(o => ({
|
|
3
|
+
readme: `
|
|
3
4
|
# \u{1F510} GitHub OAuth2 Example for TezX
|
|
4
5
|
|
|
5
6
|
This example demonstrates how to implement GitHub OAuth2 login using \`@tezx/github-oauth2\`.
|
|
@@ -20,7 +21,7 @@ This example demonstrates how to implement GitHub OAuth2 login using \`@tezx/git
|
|
|
20
21
|
### 1. Install the required package
|
|
21
22
|
|
|
22
23
|
\`\`\`bash
|
|
23
|
-
${Object.values(
|
|
24
|
+
${Object.values(g("@tezx/github-oauth2", "^1.0.9"))?.filter(n => typeof n != "string")?.join(`
|
|
24
25
|
#or
|
|
25
26
|
`)}
|
|
26
27
|
\`\`\`
|
|
@@ -50,7 +51,7 @@ Use callback URL:
|
|
|
50
51
|
app.get('/github', getGithubOAuthURL({
|
|
51
52
|
authClient: client,
|
|
52
53
|
}), (ctx) => {
|
|
53
|
-
return ctx.redirect(ctx.
|
|
54
|
+
return ctx.redirect(ctx.github.oauth_url);
|
|
54
55
|
});
|
|
55
56
|
\`\`\`
|
|
56
57
|
|
|
@@ -91,7 +92,7 @@ app.get('/github/callback', verifyGithubToken({
|
|
|
91
92
|
---
|
|
92
93
|
|
|
93
94
|
Login securely and build smarter auth with TezX! \u{1F680}
|
|
94
|
-
`.trim(),content
|
|
95
|
+
`.trim(), content: `
|
|
95
96
|
// 1. Initialize OAuth2 client
|
|
96
97
|
const client = GitHubOauthClient({
|
|
97
98
|
clientId: process.env.GITHUB_CLIENT_ID,
|
|
@@ -103,7 +104,7 @@ const client = GitHubOauthClient({
|
|
|
103
104
|
app.get('/github', getGithubOAuthURL({
|
|
104
105
|
authClient: client,
|
|
105
106
|
}), (ctx) => {
|
|
106
|
-
return ctx.redirect(ctx.
|
|
107
|
+
return ctx.redirect(ctx.github.oauth_url);
|
|
107
108
|
});
|
|
108
109
|
|
|
109
110
|
// Step 2: Verify GitHub token and handle user session
|
|
@@ -121,8 +122,12 @@ app.get('/github/callback', verifyGithubToken({
|
|
|
121
122
|
}), async (ctx) => {
|
|
122
123
|
return ctx.json({ success: true });
|
|
123
124
|
});
|
|
124
|
-
`.trim(),files:[{
|
|
125
|
-
|
|
125
|
+
`.trim(), files: [{
|
|
126
|
+
content: `GITHUB_CLIENT_ID=12323
|
|
127
|
+
GITHUB_CLIENT_SECRET=234234`, path: ".env"
|
|
128
|
+
}], import: ["import { GitHubOauthClient, getGithubOAuthURL, verifyGithubToken } from '@tezx/github-oauth2';"], package: [g("@tezx/github-oauth2", "^1.0.9")]
|
|
129
|
+
}), "githubOauth2Template"), D = l(() => ({
|
|
130
|
+
readme: `
|
|
126
131
|
# \u{1F510} Google OAuth2 Example for TezX
|
|
127
132
|
|
|
128
133
|
This example demonstrates how to use \`@tezx/google-oauth2\` to implement Google OAuth2 login in your TezX app.
|
|
@@ -145,12 +150,12 @@ This example demonstrates how to use \`@tezx/google-oauth2\` to implement Google
|
|
|
145
150
|
Choose your package manager and install:
|
|
146
151
|
|
|
147
152
|
\`\`\`bash
|
|
148
|
-
${Object.values(
|
|
153
|
+
${Object.values(g("@tezx/google-oauth2", "^1.0.13")).filter(o => typeof o != "string").join(`
|
|
149
154
|
# or
|
|
150
155
|
`)}
|
|
151
156
|
|
|
152
157
|
# Plus Google OAuth SDK
|
|
153
|
-
${Object.values(
|
|
158
|
+
${Object.values(g("@googleapis/oauth2", "^2.0.1")).filter(o => typeof o != "string").join(`
|
|
154
159
|
# or
|
|
155
160
|
`)}
|
|
156
161
|
\`\`\`
|
|
@@ -178,7 +183,7 @@ app.get('/auth/google', getGoogleOAuthURL({
|
|
|
178
183
|
authClient: client,
|
|
179
184
|
scopes: ['openid', 'email', 'profile'],
|
|
180
185
|
}), (ctx) => {
|
|
181
|
-
return ctx.redirect(ctx.
|
|
186
|
+
return ctx.redirect(ctx.google?.oauth_url);
|
|
182
187
|
});
|
|
183
188
|
\`\`\`
|
|
184
189
|
|
|
@@ -231,7 +236,7 @@ app.get('/auth/callback', verifyGoogleToken({
|
|
|
231
236
|
> \u{1F4A1} Note: TezX OAuth2 uses stateful sessions or JWTs depending on your setup. It supports advanced callback hooks for full control.
|
|
232
237
|
|
|
233
238
|
Secure your apps with Google the easy way \u{1F512}
|
|
234
|
-
`.trim(),content
|
|
239
|
+
`.trim(), content: `
|
|
235
240
|
// 1. Initialize OAuth2 client
|
|
236
241
|
const client = GoogleOauthClient({
|
|
237
242
|
clientId: process.env.GOOGLE_CLIENT_ID,
|
|
@@ -244,7 +249,7 @@ app.get('/auth/google', getGoogleOAuthURL({
|
|
|
244
249
|
authClient: client,
|
|
245
250
|
scopes: ['openid','email','profile'],
|
|
246
251
|
}), (ctx) => {
|
|
247
|
-
return ctx.redirect(ctx.
|
|
252
|
+
return ctx.redirect(ctx.google?.oauth_url);
|
|
248
253
|
});
|
|
249
254
|
|
|
250
255
|
// 3. Callback route, verify token and establish session
|
|
@@ -279,9 +284,13 @@ app.get('/auth/callback', verifyGoogleToken({
|
|
|
279
284
|
}), async (ctx) => {
|
|
280
285
|
return ctx.json({ success: true });
|
|
281
286
|
});
|
|
282
|
-
`.trim(),files:[{
|
|
287
|
+
`.trim(), files: [{
|
|
288
|
+
content: `GOOGLE_CLIENT_ID=12323
|
|
283
289
|
GOOGLE_CLIENT_SECRET=234234
|
|
284
|
-
`,path:".env"
|
|
290
|
+
`, path: ".env"
|
|
291
|
+
}], import: ['import { GoogleOauthClient, getGoogleOAuthURL, verifyGoogleToken } from "@tezx/google-oauth2";'], package: [g("@tezx/google-oauth2", "^1.0.13"), g("@googleapis/oauth2", "^2.0.1")]
|
|
292
|
+
}), "googleOauth2Template"), L = l(() => ({
|
|
293
|
+
readme: `
|
|
285
294
|
# TezX View Engine Example
|
|
286
295
|
|
|
287
296
|
This example demonstrates how to use the \`@tezx/view-engine\` package to render server-side views using template engines such as **EJS**, **Pug**, **Handlebars**, **Mustache**, or **Nunjucks**.
|
|
@@ -336,7 +345,7 @@ app.get("engine", async (ctx) => {
|
|
|
336
345
|
---
|
|
337
346
|
|
|
338
347
|
Happy TezX templating! \u{1F389}
|
|
339
|
-
`.trim(),content
|
|
348
|
+
`.trim(), content: `
|
|
340
349
|
const views = new ViewEngine("ejs", "./views");
|
|
341
350
|
|
|
342
351
|
app.get("engine", async (ctx) => {
|
|
@@ -346,7 +355,8 @@ app.get("engine", async (ctx) => {
|
|
|
346
355
|
});
|
|
347
356
|
return ctx.html(html);
|
|
348
357
|
});
|
|
349
|
-
`.trim(),files:[{
|
|
358
|
+
`.trim(), files: [{
|
|
359
|
+
content: `
|
|
350
360
|
<html lang="en">
|
|
351
361
|
<head>
|
|
352
362
|
<meta charset="UTF-8">
|
|
@@ -357,7 +367,9 @@ app.get("engine", async (ctx) => {
|
|
|
357
367
|
<p>Hello, <%= user.name %> \u{1F44B}</p>
|
|
358
368
|
</body>
|
|
359
369
|
</html>
|
|
360
|
-
`.trim(),path:"views/home.ejs"
|
|
370
|
+
`.trim(), path: "views/home.ejs"
|
|
371
|
+
}], import: ['import { ViewEngine } from "@tezx/view-engine";'], package: [g("@tezx/view-engine", "^1.0.3"), g("ejs", "^3.1.10")]
|
|
372
|
+
}), "viewEngineTemplate"); let P = `
|
|
361
373
|
<!DOCTYPE html>
|
|
362
374
|
<html lang="en">
|
|
363
375
|
<head>
|
|
@@ -522,10 +534,11 @@ app.get("engine", async (ctx) => {
|
|
|
522
534
|
appendMessage("Client: ping", "client");
|
|
523
535
|
}
|
|
524
536
|
}
|
|
525
|
-
|
|
537
|
+
<\/script>
|
|
526
538
|
</body>
|
|
527
539
|
</html>
|
|
528
|
-
|
|
540
|
+
`; const X = l(o => ({
|
|
541
|
+
readme: `
|
|
529
542
|
# \u{1F50C} TezX WebSocket Example
|
|
530
543
|
|
|
531
544
|
This example demonstrates how to set up a WebSocket server using \`upgradeWebSocket\` from \`tezx/ws\`.
|
|
@@ -585,7 +598,7 @@ A simple HTML file is included in \`public/ws.html\`:
|
|
|
585
598
|
ws.onclose = () => {
|
|
586
599
|
console.log("Disconnected.");
|
|
587
600
|
};
|
|
588
|
-
|
|
601
|
+
<\/script>
|
|
589
602
|
\`\`\`
|
|
590
603
|
|
|
591
604
|
---
|
|
@@ -603,7 +616,7 @@ A simple HTML file is included in \`public/ws.html\`:
|
|
|
603
616
|
---
|
|
604
617
|
|
|
605
618
|
Enjoy real-time power with TezX! \u26A1\uFE0F
|
|
606
|
-
`.trim(),content
|
|
619
|
+
`.trim(), content: `
|
|
607
620
|
const socket = [];
|
|
608
621
|
|
|
609
622
|
app.get(
|
|
@@ -640,8 +653,15 @@ app.get(
|
|
|
640
653
|
return ctx.sendFile("public/ws.html");
|
|
641
654
|
},
|
|
642
655
|
);
|
|
643
|
-
`.trim(),files:[{content:
|
|
644
|
-
|
|
656
|
+
`.trim(), files: [{ content: P, path: "public/ws.html" }], import: [`import { upgradeWebSocket } from "tezx/${o}";`]
|
|
657
|
+
}), "wsTemplate"); let j = { minimal: l(() => ({ readme: "", content: "", files: [], import: [], package: [] }), "minimal"), ws: X, "github-oauth2": N, "google-oauth2": D, "view-engine": L }; async function I(o, n, t) {
|
|
658
|
+
return new Promise(r => {
|
|
659
|
+
let s = 0; z.emitKeypressEvents(process.stdin, o), process.stdin.isTTY && process.stdin.setRawMode(!0); const u = l(() => {
|
|
660
|
+
process.stdout.write("\x1B[2J\x1B[0f"), console.log(n + ` (Use \u2191 \u2193 arrows, Enter to confirm)
|
|
661
|
+
`), t.forEach((a, i) => { console.log(`${i === s ? "\u{1F449}" : " "} ${i === s ? "\x1B[36m" : "\x1B[0m"}${a}\x1B[0m`) })
|
|
662
|
+
}, "render"), c = l((a, i) => { if (i.name === "up") s = (s - 1 + t.length) % t.length, u(); else if (i.name === "down") s = (s + 1) % t.length, u(); else if (i.name === "return") return r(t[s]) }, "onKeyPress"); u(), process.stdin.on("keypress", c)
|
|
663
|
+
})
|
|
664
|
+
} l(I, "arrowSelect"); const G = { reset: "\x1B[0m", bold: "\x1B[1m", underline: "\x1B[4m", gray: "\x1B[90m", white: "\x1B[97m", black: "\x1B[30m", red: "\x1B[31m", green: "\x1B[32m", yellow: "\x1B[33m", blue: "\x1B[34m", magenta: "\x1B[35m", cyan: "\x1B[36m", bgRed: "\x1B[41m", bgGreen: "\x1B[42m", bgYellow: "\x1B[43m", bgBlue: "\x1B[44m", bgMagenta: "\x1B[45m", bgCyan: "\x1B[46m", bgWhite: "\x1B[47m", orange: "\x1B[38;2;255;88;30m", bgOrange: "\x1B[48;2;255;88;30m" }; function e(o, n) { return `${G[n]}${o}${G.reset}` } l(e, "colorText"); const $ = "3.0.0"; let W = `
|
|
645
665
|
# \u{1F680} TezX Starter Template
|
|
646
666
|
|
|
647
667
|
Welcome to the **TezX Starter Template** \u2014 a blazing-fast, full-featured backend template built on [TezX](https://github.com/tezxjs/tezx), the lightweight web framework inspired by the best of Express, Hono, and Bun.
|
|
@@ -759,11 +779,38 @@ MIT \xA9 [SRAKIB17](https://github.com/SRAKIB17)
|
|
|
759
779
|
|
|
760
780
|
---
|
|
761
781
|
|
|
762
|
-
`,
|
|
782
|
+
`, H = l(({ ts: o, template: n, root: t, env: r, useStatic: s = !1, staticFolder: u }) => {
|
|
783
|
+
const c = h(t, o ? "src/index.ts" : "src/index.js"); S(h(t, "src"), { recursive: !0 }); let a = ""; r === "node" ? (n?.import.push('import { createServer } from "node:http";'), n?.import.push('import { mountTezXOnNode } from "tezx/node";'), a = `
|
|
784
|
+
const server = createServer();
|
|
785
|
+
|
|
786
|
+
// Mount TezX to handle requests
|
|
787
|
+
mountTezXOnNode(app, server);
|
|
788
|
+
|
|
789
|
+
// Start listening on the defined port
|
|
790
|
+
const PORT = process.env.PORT || 3000;
|
|
791
|
+
server.listen(PORT, () => {
|
|
792
|
+
console.log(\`\u{1F680} TezX is running at http://localhost:\${PORT}\`);
|
|
793
|
+
});
|
|
794
|
+
`) : r === "bun" ? (n?.import?.push('import { wsHandlers } from "tezx/bun";'), a = `
|
|
795
|
+
Bun.serve({
|
|
796
|
+
port: Number(process.env.PORT) || 3001,
|
|
797
|
+
reusePort: true, // Enables multi-process clustering
|
|
798
|
+
fetch(req, server) {
|
|
799
|
+
return app.serve(req, server); // Handle requests via TezX
|
|
800
|
+
},
|
|
801
|
+
websocket: wsHandlers({
|
|
802
|
+
// Optional WebSocket configure
|
|
803
|
+
})
|
|
804
|
+
});
|
|
805
|
+
`) : r === "deno" && (a = `
|
|
806
|
+
Deno.serve({ port: Number(Deno.env.get("PORT") || 5000) }, (req, connInfo) => {
|
|
807
|
+
return app.serve(req, connInfo);
|
|
808
|
+
});
|
|
809
|
+
`); let i = `
|
|
763
810
|
import { TezX } from "tezx";
|
|
764
|
-
import {
|
|
811
|
+
import { loadEnv, serveStatic} from "tezx/${r}";
|
|
765
812
|
import { logger } from "tezx/middleware";
|
|
766
|
-
${
|
|
813
|
+
${n?.import?.join(`
|
|
767
814
|
`)}
|
|
768
815
|
const app = new TezX({
|
|
769
816
|
env: loadEnv(),
|
|
@@ -774,14 +821,13 @@ app.use([logger()]);
|
|
|
774
821
|
|
|
775
822
|
app.get("/", (ctx) => ctx.text("Hello from TezX (${r})"));
|
|
776
823
|
|
|
777
|
-
${
|
|
778
|
-
${
|
|
779
|
-
${
|
|
780
|
-
`:""}
|
|
781
|
-
${
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
`;if(n){let i=`
|
|
824
|
+
${s ? `app.static(serveStatic("${u || "public"}"));` : ""}
|
|
825
|
+
${n?.content ? `
|
|
826
|
+
${n?.content?.trim()}
|
|
827
|
+
`: ""}
|
|
828
|
+
${a}
|
|
829
|
+
`; if (o) {
|
|
830
|
+
let p = `
|
|
785
831
|
{
|
|
786
832
|
"compilerOptions": {
|
|
787
833
|
"outDir": "./dist",
|
|
@@ -803,16 +849,19 @@ ${r}Adapter(app).listen(3000, () => {
|
|
|
803
849
|
"tests"
|
|
804
850
|
]
|
|
805
851
|
}
|
|
806
|
-
`.trim();
|
|
852
|
+
`.trim(); b(h(t, "tsconfig.json"), p)
|
|
853
|
+
} b(c, i.trim())
|
|
854
|
+
}, "index"), M = l(({ template: o, root: n, projectName: t, env: r, ts: s, useWS: u, choiceStep: c }) => {
|
|
855
|
+
let a = []; Array.isArray(o?.package) && o?.package?.forEach(d => { let { version: f, npm: w } = d || {}; a.push(`"${w?.[1]}": "${f}"`) }); let i = { bun: { start: "bun dist/index.js", dev: "bun run --hot --watch src/index.ts" }, deno: { start: "deno run --allow-all dist/index.js", dev: "deno run --watch --allow-all --unstable-sloppy-imports src/index.ts" }, node: { start: "node dist/index.js", dev: "tsx watch src/index.ts" } }, p = `
|
|
807
856
|
{
|
|
808
|
-
"name": "${t||"tezx-app-example"}",
|
|
857
|
+
"name": "${t || "tezx-app-example"}",
|
|
809
858
|
"version": "1.0.0",
|
|
810
859
|
"type": "module",
|
|
811
860
|
"description": "TezX is a high-performance, lightweight JavaScript framework designed for speed, scalability, and flexibility. It enables efficient routing, middleware management, and static file serving with minimal configuration. Fully compatible with Node.js, Deno, and Bun.",
|
|
812
|
-
"scripts": { ${
|
|
861
|
+
"scripts": { ${s ? `
|
|
813
862
|
"build:esm": "tsc --module ESNext --outDir dist --removeComments",
|
|
814
863
|
"build:dts": "tsc --module ESNext --outDir dist --declaration --emitDeclarationOnly",
|
|
815
|
-
"build": "${c?.build}"
|
|
864
|
+
"build": "${c?.build}",` : ""}
|
|
816
865
|
"start": "${i?.[r]?.start}",
|
|
817
866
|
"dev": "${i?.[r]?.dev}"
|
|
818
867
|
},
|
|
@@ -828,17 +877,21 @@ ${r}Adapter(app).listen(3000, () => {
|
|
|
828
877
|
},
|
|
829
878
|
"homepage": "https://github.com/tezxjs/tezx-app-example",
|
|
830
879
|
"dependencies": {
|
|
831
|
-
${
|
|
832
|
-
"tezx": "^${
|
|
833
|
-
"tsx": "^4.19.2"`:""}${
|
|
834
|
-
"ws": "^8.18.1"`:""}${
|
|
835
|
-
${
|
|
836
|
-
`)}
|
|
880
|
+
${s ? '"typescript": "^5.8.2",' : ""}
|
|
881
|
+
"tezx": "^${$}"${r == "node" ? `,
|
|
882
|
+
"tsx": "^4.19.2"`: ""}${u && r == "node" ? `,
|
|
883
|
+
"ws": "^8.18.1"`: ""}${a.length ? `,
|
|
884
|
+
${a?.join(`,
|
|
885
|
+
`)}` : ""}
|
|
837
886
|
},
|
|
838
887
|
"devDependencies": {
|
|
839
|
-
"@types/node": "^22.13.14"
|
|
888
|
+
"@types/node": "^22.13.14"${r === "bun" ? `,
|
|
889
|
+
"@types/bun": "^1.3.1"`: r === "deno" ? `,
|
|
890
|
+
"@types/deno" : "^2.5.0"`: ""}
|
|
840
891
|
}
|
|
841
|
-
}`.trim();
|
|
892
|
+
}`.trim(); b(h(n, "package.json"), p)
|
|
893
|
+
}, "packageJson"); const U = l(({ root: o }) => {
|
|
894
|
+
const n = `
|
|
842
895
|
# Node dependencies
|
|
843
896
|
node_modules/
|
|
844
897
|
.env
|
|
@@ -908,51 +961,60 @@ Thumbs.db
|
|
|
908
961
|
.vscode/
|
|
909
962
|
.idea/
|
|
910
963
|
*.swp
|
|
911
|
-
`.trim();
|
|
912
|
-
|
|
913
|
-
|
|
964
|
+
`.trim(); b(h(o, ".gitignore"), n, { encoding: "utf8" })
|
|
965
|
+
}, "gitignore"), V = l(({ root: o, readme: n }) => { const t = typeof n == "string" && n ? n?.trim() : W.trim(); b(h(o, "README.md"), t, { encoding: "utf8" }) }, "README"); let E = ["npm", "bun", "yarn", "pnpm"], F = ["node", "bun", "deno"]; function q(o) {
|
|
966
|
+
let n = 0; const t = ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"], r = setInterval(() => { process.stdout.write(`\r${t[n = ++n % t.length]} ${o}`) }, 80); return () => {
|
|
967
|
+
clearInterval(r), process.stdout.write(`\r\u2705 Done!
|
|
968
|
+
`)
|
|
969
|
+
}
|
|
970
|
+
} l(q, "startLoader"); const C = z.createInterface({ input: process.stdin, output: process.stdout }); z.emitKeypressEvents(process.stdin), process.stdin.isTTY && process.stdin.setRawMode(!0); const y = l((o, n = "") => new Promise(t => { C.question(n ? `${o} (${n}): ` : o, r => { t(r.trim() || n) }) }), "ask"); async function J(o) {
|
|
971
|
+
let n = o?.directory, t = o?.options; console.log(e(`
|
|
972
|
+
\u26A1 TezX App Creator(v${$})`, "orange")), n || (n = await y(e("\u{1F4E6} Project name: ", "magenta")), n || (console.log(e("\u274C Project name required.", "red")), process.exit(0))); let r = T.basename(n); const s = _(process.cwd(), n); let u = !!t?.ts, c = t?.env || t?.runtime; const a = F?.includes(c) ? c : await I(C, "\u{1F4BB} Runtime?", F); let i = t?.staticFolder || "public", p = !0, d = { content: "", import: [], readme: "", files: [] }; if (t?.t || t?.template) { const m = t.t || t.template, k = j?.[m]; k || (console.error(`\u274C Unknown template: "${m}"`), console.error(`\u2139\uFE0F Available templates: ${Object.keys(j).join(", ")}`), process.exit(0)), d = k(a) } else u = !!(t?.ts || (await y("\u{1F7E6} Use TypeScript? (y/N): ")).toLowerCase() === "y"), p = !!t?.useStatic || (await y("\u{1F4C1} Use static folder? (y/N): ")).toLowerCase() === "y", i = p ? t?.staticFolder || await y("\u{1F4C2} Static folder name? (default: public): ") : ""; let f = t?.pm || t?.p; const w = E?.includes(f) ? f : await I(C, "\u{1F4E6} Choose your package manager", E), v = t?.i === "true" || t?.install === "true" || (await y("\u{1F4E5} Install dependencies now? (y/N): ")).toLowerCase() === "y"; console.log(`
|
|
914
973
|
\u{1F4C1} Creating project: ${r}...
|
|
915
|
-
`);let
|
|
974
|
+
`); let A = q("Creating Project"); if (S(s, { recursive: !0 }), p) { const m = h(s, i || "public"); S(m, { recursive: !0 }) } let x = { bun: { cd: "cd " + n, install: "bun install", dev: "bun dev", build: "bun build:esm && bun build:dts" }, npm: { cd: "cd " + n, install: "npm install", dev: "npm run dev", build: "npm run build:esm && npm run build:dts" }, yarn: { cd: "cd " + n, install: "yarn", dev: "yarn dev", build: "yarn build:esm && yarn build:dts" }, pnpm: { cd: "cd " + n, install: "pnpm install", dev: "pnpm run dev", build: "pnpm run build:esm && pnpm run build:dts" } }[w]; H({ template: d, root: s, ts: !!u, env: a, staticFolder: i, useStatic: p }), M({ projectName: r, env: a, root: s, ts: !!u, template: d, choiceStep: x }), U({ root: s }), V({ root: s, readme: d?.readme }), C.close(), d?.files?.forEach(m => { let k = T.join(s, T.dirname(m?.path)); S(k, { recursive: !0 }), b(T.join(s, m?.path), m?.content) }), v && R(x?.install, { cwd: s, stdio: "inherit" }), console.log(e(`
|
|
916
975
|
\u2705 TezX project "${r}" is ready!
|
|
917
|
-
`,"green")),console.log(e("\u{1F9F0} Summary of your configuration:","cyan")),console.log(`\u{1F4C1} Project Name: ${e(r,"yellow")}`);let O=t?.t||t?.template;O&&console.log(`\u{1F4C1} Template Name: ${e(O,"orange")}`),console.log(`\u{1F7E6} TypeScript: ${e(
|
|
918
|
-
`),console.log(e("\u{1F449} Next Steps:","cyan")),console.log(e(` ${
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
${e("\
|
|
976
|
+
`, "green")), console.log(e("\u{1F9F0} Summary of your configuration:", "cyan")), console.log(`\u{1F4C1} Project Name: ${e(r, "yellow")}`); let O = t?.t || t?.template; O && console.log(`\u{1F4C1} Template Name: ${e(O, "orange")}`), console.log(`\u{1F7E6} TypeScript: ${e(u ? "Yes" : "No", u ? "green" : "gray")}`), console.log(`\u{1F4BB} Runtime: ${e(a, "blue")}`), console.log(`\u{1F4C1} Static Folder: ${e(p ? i || "public" : "Not Used", p ? "green" : "gray")}`), console.log(`\u{1F4E6} Package Manager: ${e(w, "magenta")}`), console.log(`\u{1F4E5} Dependencies Installed: ${e(v ? "Yes" : "No", v ? "green" : "red")}
|
|
977
|
+
`), console.log(e("\u{1F449} Next Steps:", "cyan")), console.log(e(` ${x?.cd}`, "white")), v || console.log(e(` ${x?.install}`, "white")), console.log(e(` ${x?.dev}`, "white")), console.log(""), A(), process.exit(0)
|
|
978
|
+
} l(J, "create"); function K() {
|
|
979
|
+
console.log(`
|
|
980
|
+
${e("\u256D\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256E", "gray")}
|
|
981
|
+
${e("\u2502", "gray")}${e(" \u26A1 Create TezX", "yellow")} - Scaffold your next backend app ${e("\u2502", "gray")}
|
|
982
|
+
${e("\u2570\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256F", "gray")}
|
|
922
983
|
|
|
923
|
-
${e("\u{1F4E6} Usage:","cyan")}
|
|
924
|
-
|
|
984
|
+
${e("\u{1F4E6} Usage:", "cyan")}
|
|
985
|
+
${e("create-tezx", "green")} ${e("[directory] [...options]", "gray")}
|
|
925
986
|
|
|
926
|
-
${e("\u{1F680} Quick Start:","cyan")}
|
|
927
|
-
${e("npm","magenta")} create tezx@latest
|
|
928
|
-
${e("yarn","magenta")} create tezx
|
|
929
|
-
${e("pnpm","magenta")} create tezx@latest
|
|
930
|
-
${e("bun","magenta")} create tezx@latest
|
|
931
|
-
${e("deno","magenta")} run -A npm:create-tezx@latest
|
|
987
|
+
${e("\u{1F680} Quick Start:", "cyan")}
|
|
988
|
+
${e("npm", "magenta")} create tezx@latest
|
|
989
|
+
${e("yarn", "magenta")} create tezx
|
|
990
|
+
${e("pnpm", "magenta")} create tezx@latest
|
|
991
|
+
${e("bun", "magenta")} create tezx@latest
|
|
992
|
+
${e("deno", "magenta")} run -A npm:create-tezx@latest
|
|
932
993
|
|
|
933
|
-
${e("\u{1F39B}\uFE0F Options:","cyan")}
|
|
994
|
+
${e("\u{1F39B}\uFE0F Options:", "cyan")}
|
|
934
995
|
|
|
935
|
-
${e("-t, --template <name>","green")} Use a specific starter template
|
|
936
|
-
${e("--ts, -ts","green")} Enable TypeScript setup
|
|
937
|
-
${e("--env, --runtime <env>","green")} Set runtime: node | bun | deno
|
|
938
|
-
${e("-p, --pm <manager>","green")} Package manager: npm | bun | yarn | pnpm
|
|
939
|
-
${e("-i, --install","green")} Automatically install dependencies
|
|
940
|
-
${e("-y, --yes","green")} Skip prompts using default options
|
|
941
|
-
${e("-v, --version","green")} Show CLI version
|
|
942
|
-
${e("-h, --help","green")} Display this help message
|
|
996
|
+
${e("-t, --template <name>", "green")} Use a specific starter template
|
|
997
|
+
${e("--ts, -ts", "green")} Enable TypeScript setup
|
|
998
|
+
${e("--env, --runtime <env>", "green")} Set runtime: node | bun | deno
|
|
999
|
+
${e("-p, --pm <manager>", "green")} Package manager: npm | bun | yarn | pnpm
|
|
1000
|
+
${e("-i, --install", "green")} Automatically install dependencies
|
|
1001
|
+
${e("-y, --yes", "green")} Skip prompts using default options
|
|
1002
|
+
${e("-v, --version", "green")} Show CLI version
|
|
1003
|
+
${e("-h, --help", "green")} Display this help message
|
|
943
1004
|
|
|
944
|
-
${e("\u{1F9F0} Examples:","cyan")}
|
|
945
|
-
${e("npm create tezx@latest my-app --template ws --ts --env node","gray")}
|
|
946
|
-
${e("bun create tezx@latest -- --install --pm bun","gray")}
|
|
1005
|
+
${e("\u{1F9F0} Examples:", "cyan")}
|
|
1006
|
+
${e("npm create tezx@latest my-app --template ws --ts --env node", "gray")}
|
|
1007
|
+
${e("bun create tezx@latest -- --install --pm bun", "gray")}
|
|
947
1008
|
|
|
948
|
-
${e("\u{1F4C1} Available Templates:","cyan")}
|
|
949
|
-
${e("minimal","yellow")} Minimal TypeScript setup
|
|
950
|
-
${e("ws","yellow")} Built-in WebSocket server
|
|
951
|
-
${e("google-oauth2","yellow")} Google OAuth2 Authentication
|
|
952
|
-
${e("github-oauth2","yellow")} GitHub OAuth2 Authentication
|
|
1009
|
+
${e("\u{1F4C1} Available Templates:", "cyan")}
|
|
1010
|
+
${e("minimal", "yellow")} Minimal TypeScript setup
|
|
1011
|
+
${e("ws", "yellow")} Built-in WebSocket server
|
|
1012
|
+
${e("google-oauth2", "yellow")} Google OAuth2 Authentication
|
|
1013
|
+
${e("github-oauth2", "yellow")} GitHub OAuth2 Authentication
|
|
953
1014
|
|
|
954
|
-
${e("\u{1F517} Repository:","cyan")}
|
|
955
|
-
${e("https://github.com/tezxjs/tezx","underline")}
|
|
1015
|
+
${e("\u{1F517} Repository:", "cyan")}
|
|
1016
|
+
${e("https://github.com/tezxjs/tezx", "underline")}
|
|
956
1017
|
|
|
957
|
-
${e("\u{1F9D1}\u200D\u{1F4BB} Author:","cyan")}
|
|
958
|
-
Rakibul Islam ${e("<https://github.com/srakib17>","blue")}`),
|
|
1018
|
+
${e("\u{1F9D1}\u200D\u{1F4BB} Author:", "cyan")}
|
|
1019
|
+
Rakibul Islam ${e("<https://github.com/srakib17>", "blue")}`), process.exit(0)
|
|
1020
|
+
} l(K, "showHelp"); function Y() { console.log(`TezX CLI v${$}`), process.exit(0) } l(Y, "showVersion"), (async () => { const o = l((u, c) => { c.name === "c" && c.ctrl && (process.stdin.off("keypress", o), process.stdin.isTTY && process.stdin.setRawMode(!1), process.exit(0)) }, "onKeyPress"); process.stdin.on("keypress", o); const n = process.argv.slice(2); let t = {}, r; for (let u = 0; u < n.length; u++) { const c = n[u]; if (c.startsWith("--")) { const a = c.slice(2), i = n[u + 1]; i && !i.startsWith("-") ? (t[a] = i, u++) : t[a] = "true" } else if (c.startsWith("-")) { const a = c.slice(1), i = n[u + 1]; i && !i.startsWith("-") ? (t[a] = i, u++) : t[a] = "true" } else r || (r = c) } let s = { directory: r, options: t }; if ((t.y === "true" || t.yes === "true") && (s.options.ts = "true", s.options.useStatic = "true", s.options.staticFolder = "public", s.options.pm = E?.includes(s.options?.p || s?.options?.pm) ? s.options?.p || s?.options?.pm : "npm", s.options.p = E?.includes(s.options?.p || s?.options?.pm) ? s.options?.p || s?.options?.pm : "npm", s.options.env = F?.includes(s.options?.env || s?.options?.runtime) ? s.options?.env || s?.options?.runtime : "node", s.options.runtime = F?.includes(s.options?.env || s?.options?.runtime) ? s.options?.env || s?.options?.runtime : "node", s.options.install = "true"), t.help || t.h) { K(); return } if (t.v || t.version) { Y(); return } J(s) })();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-tezx-app",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "TezX is a high-performance, lightweight JavaScript framework designed for speed, scalability, and flexibility. It enables efficient routing, middleware management, and static file serving with minimal configuration. Fully compatible with Node.js, Deno, and Bun.",
|
|
6
6
|
"bin": "./bin",
|