create-tezx-app 4.0.7 → 4.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin +53 -52
- package/package.json +1 -1
package/bin
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { execSync as
|
|
2
|
+
var O = Object.defineProperty; var c = (o, s) => O(o, "name", { value: s, configurable: !0 }); import { execSync as j } from "node:child_process"; import { mkdirSync as v, writeFileSync as h } from "node:fs"; import k, { join as g, resolve as A } from "node:path"; import T from "node:readline"; const d = c((o, s) => ({ version: s, npm: ["npm install", o], bun: ["bun add", o], yarn: ["yarn add", o], pnpm: ["pnpm add", o] }), "packageManagerCommands"), I = {
|
|
3
3
|
readme: `
|
|
4
4
|
# \u{1F510} GitHub OAuth2 Example for TezX
|
|
5
5
|
|
|
@@ -21,7 +21,7 @@ This example demonstrates how to implement GitHub OAuth2 login using \`@tezx/git
|
|
|
21
21
|
### 1. Install the required package
|
|
22
22
|
|
|
23
23
|
\`\`\`bash
|
|
24
|
-
${Object.values(
|
|
24
|
+
${Object.values(d("@tezx/github-oauth2", "^1.0.9"))?.filter(o => typeof o != "string")?.join(`
|
|
25
25
|
#or
|
|
26
26
|
`)}
|
|
27
27
|
\`\`\`
|
|
@@ -125,8 +125,8 @@ app.get('/github/callback', verifyGithubToken({
|
|
|
125
125
|
`.trim(), files: [{
|
|
126
126
|
content: `GITHUB_CLIENT_ID=12323
|
|
127
127
|
GITHUB_CLIENT_SECRET=234234`, path: ".env"
|
|
128
|
-
}], import: ["import { GitHubOauthClient, getGithubOAuthURL, verifyGithubToken } from '@tezx/github-oauth2';"], package: [
|
|
129
|
-
}
|
|
128
|
+
}], import: ["import { GitHubOauthClient, getGithubOAuthURL, verifyGithubToken } from '@tezx/github-oauth2';"], package: [d("@tezx/github-oauth2", "^1.0.9")]
|
|
129
|
+
}, G = {
|
|
130
130
|
readme: `
|
|
131
131
|
# \u{1F510} Google OAuth2 Example for TezX
|
|
132
132
|
|
|
@@ -150,12 +150,12 @@ This example demonstrates how to use \`@tezx/google-oauth2\` to implement Google
|
|
|
150
150
|
Choose your package manager and install:
|
|
151
151
|
|
|
152
152
|
\`\`\`bash
|
|
153
|
-
${Object.values(
|
|
153
|
+
${Object.values(d("@tezx/google-oauth2", "^1.0.13")).filter(o => typeof o != "string").join(`
|
|
154
154
|
# or
|
|
155
155
|
`)}
|
|
156
156
|
|
|
157
157
|
# Plus Google OAuth SDK
|
|
158
|
-
${Object.values(
|
|
158
|
+
${Object.values(d("@googleapis/oauth2", "^2.0.1")).filter(o => typeof o != "string").join(`
|
|
159
159
|
# or
|
|
160
160
|
`)}
|
|
161
161
|
\`\`\`
|
|
@@ -288,8 +288,8 @@ app.get('/auth/callback', verifyGoogleToken({
|
|
|
288
288
|
content: `GOOGLE_CLIENT_ID=12323
|
|
289
289
|
GOOGLE_CLIENT_SECRET=234234
|
|
290
290
|
`, path: ".env"
|
|
291
|
-
}], import: ['import { GoogleOauthClient, getGoogleOAuthURL, verifyGoogleToken } from "@tezx/google-oauth2";'], package: [
|
|
292
|
-
}
|
|
291
|
+
}], import: ['import { GoogleOauthClient, getGoogleOAuthURL, verifyGoogleToken } from "@tezx/google-oauth2";'], package: [d("@tezx/google-oauth2", "^1.0.13"), d("@googleapis/oauth2", "^2.0.1")]
|
|
292
|
+
}, R = {
|
|
293
293
|
readme: `
|
|
294
294
|
# TezX View Engine Example
|
|
295
295
|
|
|
@@ -368,8 +368,8 @@ app.get("engine", async (ctx) => {
|
|
|
368
368
|
</body>
|
|
369
369
|
</html>
|
|
370
370
|
`.trim(), path: "views/home.ejs"
|
|
371
|
-
}], import: ['import { ViewEngine } from "@tezx/view-engine";'], package: [
|
|
372
|
-
};
|
|
371
|
+
}], import: ['import { ViewEngine } from "@tezx/view-engine";'], package: [d("@tezx/view-engine", "^1.0.3"), d("ejs", "^3.1.10")]
|
|
372
|
+
}; let H = `
|
|
373
373
|
<!DOCTYPE html>
|
|
374
374
|
<html lang="en">
|
|
375
375
|
<head>
|
|
@@ -534,11 +534,11 @@ app.get("engine", async (ctx) => {
|
|
|
534
534
|
appendMessage("Client: ping", "client");
|
|
535
535
|
}
|
|
536
536
|
}
|
|
537
|
-
|
|
537
|
+
<\/script>
|
|
538
538
|
</body>
|
|
539
539
|
</html>
|
|
540
|
-
|
|
541
|
-
|
|
540
|
+
`; const W = {
|
|
541
|
+
readme: `
|
|
542
542
|
# \u{1F50C} TezX WebSocket Example
|
|
543
543
|
|
|
544
544
|
This example demonstrates how to set up a WebSocket server using \`upgradeWebSocket\` from \`tezx/ws\`.
|
|
@@ -598,7 +598,7 @@ A simple HTML file is included in \`public/ws.html\`:
|
|
|
598
598
|
ws.onclose = () => {
|
|
599
599
|
console.log("Disconnected.");
|
|
600
600
|
};
|
|
601
|
-
|
|
601
|
+
<\/script>
|
|
602
602
|
\`\`\`
|
|
603
603
|
|
|
604
604
|
---
|
|
@@ -653,15 +653,15 @@ app.get(
|
|
|
653
653
|
return ctx.sendFile("public/ws.html");
|
|
654
654
|
},
|
|
655
655
|
);
|
|
656
|
-
`.trim(), files: [{ content:
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
`), t.forEach((
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
656
|
+
`.trim(), files: [{ content: H, path: "public/ws.html" }], import: ['import { upgradeWebSocket } from "tezx/ws";']
|
|
657
|
+
}; let C = { minimal: { readme: "", content: "", files: [], import: [], package: [] }, ws: W, "github-oauth2": I, "google-oauth2": G, "view-engine": R }; async function _(o, s, t) {
|
|
658
|
+
return new Promise(a => {
|
|
659
|
+
let n = 0; T.emitKeypressEvents(process.stdin, o), process.stdin.isTTY && process.stdin.setRawMode(!0); const u = c(() => {
|
|
660
|
+
process.stdout.write("\x1B[2J\x1B[0f"), console.log(s + ` (Use \u2191 \u2193 arrows, Enter to confirm)
|
|
661
|
+
`), t.forEach((l, r) => { console.log(`${r === n ? "\u{1F449}" : " "} ${r === n ? "\x1B[36m" : "\x1B[0m"}${l}\x1B[0m`) })
|
|
662
|
+
}, "render"), i = c((l, r) => { if (r.name === "up") n = (n - 1 + t.length) % t.length, u(); else if (r.name === "down") n = (n + 1) % t.length, u(); else if (r.name === "return") return a(t[n]) }, "onKeyPress"); u(), process.stdin.on("keypress", i)
|
|
663
|
+
})
|
|
664
|
+
} c(_, "arrowSelect"); const $ = { 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, s) { return `${$[s]}${o}${$.reset}` } c(e, "colorText"); const F = "4.0.1"; let D = `
|
|
665
665
|
# \u26A1 TezX \u2013 High-Performance JavaScript Framework for **Bun**
|
|
666
666
|
|
|
667
667
|
**TezX** is a modern, ultra-fast, and lightweight JavaScript framework built specifically for **Bun**.
|
|
@@ -852,8 +852,8 @@ Your support helps improve the framework.
|
|
|
852
852
|
|
|
853
853
|
---
|
|
854
854
|
|
|
855
|
-
`,
|
|
856
|
-
|
|
855
|
+
`, P = c(({ ts: o, template: s, root: t, useStatic: a = !1, staticFolder: n }) => {
|
|
856
|
+
const u = g(t, o ? "src/index.ts" : "src/index.js"); v(g(t, "src"), { recursive: !0 }); let i = ""; s?.import?.push('import { wsHandlers } from "tezx/ws";'), i = `
|
|
857
857
|
let PORT = Number(process.env.PORT) || 3000;
|
|
858
858
|
Bun.serve({
|
|
859
859
|
port: PORT,
|
|
@@ -866,26 +866,27 @@ Bun.serve({
|
|
|
866
866
|
})
|
|
867
867
|
});
|
|
868
868
|
console.log(\`\u{1F680} TezX is running at http://localhost:\${PORT}\`);
|
|
869
|
-
`; let
|
|
869
|
+
`; let l = `
|
|
870
870
|
import { TezX } from "tezx";
|
|
871
871
|
import { serveStatic } from "tezx/static";
|
|
872
872
|
import { logger } from "tezx/middleware";
|
|
873
873
|
${s?.import?.join(`
|
|
874
874
|
`)}
|
|
875
875
|
const app = new TezX({
|
|
876
|
+
debugMode: true,
|
|
876
877
|
// Additional options
|
|
877
878
|
});
|
|
878
879
|
app.use([logger()]);
|
|
879
880
|
|
|
880
881
|
app.get("/", (ctx) => ctx.text("Hello from TezX"));
|
|
881
882
|
|
|
882
|
-
${a ? `app.static(serveStatic("${
|
|
883
|
+
${a ? `app.static(serveStatic("${n || "public"}"));` : ""}
|
|
883
884
|
${s?.content ? `
|
|
884
885
|
${s?.content?.trim()}
|
|
885
886
|
`: ""}
|
|
886
887
|
${i}
|
|
887
|
-
`; if (
|
|
888
|
-
|
|
888
|
+
`; if (o) {
|
|
889
|
+
const r = `
|
|
889
890
|
{
|
|
890
891
|
"compilerOptions": {
|
|
891
892
|
"module": "esnext",
|
|
@@ -899,10 +900,10 @@ ${i}
|
|
|
899
900
|
"include": ["src"],
|
|
900
901
|
"exclude": ["node_modules", "dist"]
|
|
901
902
|
}
|
|
902
|
-
`.trim();
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
903
|
+
`.trim(); h(g(t, "tsconfig.json"), r)
|
|
904
|
+
} h(u, l.trim())
|
|
905
|
+
}, "index"), X = c(({ template: o, root: s, projectName: t, ts: a, useWS: n, choiceStep: u }) => {
|
|
906
|
+
let i = []; Array.isArray(o?.package) && o?.package?.forEach(b => { let { version: x, npm: m } = b || {}; i.push(`"${m?.[1]}": "${x}"`) }); let l = ['"@types/bun": "^1.3.1"']; a && (l.push('"typescript": "^5.8.2"'), l.push('"@types/node": "^22.13.14"')); let r = `
|
|
906
907
|
{
|
|
907
908
|
"name": "${t || "tezx-app-example"}",
|
|
908
909
|
"version": "1.0.0",
|
|
@@ -925,18 +926,18 @@ ${i}
|
|
|
925
926
|
},
|
|
926
927
|
"homepage": "https://github.com/tezxjs/tezx-app-example",
|
|
927
928
|
"dependencies": {
|
|
928
|
-
"tezx": "^${
|
|
929
|
+
"tezx": "^${F}"${i.length ? `,
|
|
929
930
|
${i.join(`,
|
|
930
931
|
`)}` : ""}
|
|
931
932
|
},
|
|
932
933
|
"devDependencies": {
|
|
933
|
-
${
|
|
934
|
+
${l.join(`,
|
|
934
935
|
`)}
|
|
935
936
|
}
|
|
936
937
|
}
|
|
937
|
-
`.trim();
|
|
938
|
-
|
|
939
|
-
|
|
938
|
+
`.trim(); h(g(s, "package.json"), r)
|
|
939
|
+
}, "packageJson"); const N = c(({ root: o }) => {
|
|
940
|
+
const s = `
|
|
940
941
|
# Node dependencies
|
|
941
942
|
node_modules/
|
|
942
943
|
.env
|
|
@@ -1006,22 +1007,22 @@ Thumbs.db
|
|
|
1006
1007
|
.vscode/
|
|
1007
1008
|
.idea/
|
|
1008
1009
|
*.swp
|
|
1009
|
-
`.trim();
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1010
|
+
`.trim(); h(g(o, ".gitignore"), s, { encoding: "utf8" })
|
|
1011
|
+
}, "gitignore"), L = c(({ root: o, readme: s }) => { const t = typeof s == "string" && s ? s?.trim() : D.trim(); h(g(o, "README.md"), t, { encoding: "utf8" }) }, "README"); let S = ["npm", "bun", "yarn", "pnpm"]; function M(o) {
|
|
1012
|
+
let s = 0; const t = ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"], a = setInterval(() => { process.stdout.write(`\r${t[s = ++s % t.length]} ${o}`) }, 80); return () => {
|
|
1013
|
+
clearInterval(a), process.stdout.write(`\r\u2705 Done!
|
|
1013
1014
|
`)
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
\u26A1 TezX App Creator(v${
|
|
1015
|
+
}
|
|
1016
|
+
} c(M, "startLoader"); const E = T.createInterface({ input: process.stdin, output: process.stdout }); T.emitKeypressEvents(process.stdin), process.stdin.isTTY && process.stdin.setRawMode(!0); const y = c((o, s = "") => new Promise(t => { E.question(s ? `${o} (${s}): ` : o, a => { t(a.trim() || s) }) }), "ask"); async function U(o) {
|
|
1017
|
+
let s = o?.directory, t = o?.options; console.log(e(`
|
|
1018
|
+
\u26A1 TezX App Creator(v${F})`, "orange")), s || (s = await y(e("\u{1F4E6} Project name: ", "magenta")), s || (console.log(e("\u274C Project name required.", "red")), process.exit(0))); let a = k.basename(s); const n = A(process.cwd(), s); let u = !!t?.ts, i = t?.staticFolder || "public", l = !0, r = { content: "", import: [], readme: "", files: [] }; if (t?.t || t?.template) { const p = t.t || t.template, w = C?.[p]; w || (console.error(`\u274C Unknown template: "${p}"`), console.error(`\u2139\uFE0F Available templates: ${Object.keys(C).join(", ")}`), process.exit(0)), r = w } else u = !!(t?.ts || (await y("\u{1F7E6} Use TypeScript? (y/N): ")).toLowerCase() === "y"), l = !!t?.useStatic || (await y("\u{1F4C1} Use static folder? (y/N): ")).toLowerCase() === "y", i = l ? t?.staticFolder || await y("\u{1F4C2} Static folder name? (default: public): ") : ""; let b = t?.pm || t?.p; const x = S?.includes(b) ? b : await _(E, "\u{1F4E6} Choose your package manager", S), m = t?.i === "true" || t?.install === "true" || (await y("\u{1F4E5} Install dependencies now? (y/N): ")).toLowerCase() === "y"; console.log(`
|
|
1018
1019
|
\u{1F4C1} Creating project: ${a}...
|
|
1019
|
-
`); let
|
|
1020
|
+
`); let B = M("Creating Project"); if (v(n, { recursive: !0 }), l) { const p = g(n, i || "public"); v(p, { recursive: !0 }) } let f = { bun: { cd: "cd " + s, install: "bun install", dev: "bun dev", build: "bun build:esm && bun build:dts" }, npm: { cd: "cd " + s, install: "npm install", dev: "npm run dev", build: "npm run build:esm && npm run build:dts" }, yarn: { cd: "cd " + s, install: "yarn", dev: "yarn dev", build: "yarn build:esm && yarn build:dts" }, pnpm: { cd: "cd " + s, install: "pnpm install", dev: "pnpm run dev", build: "pnpm run build:esm && pnpm run build:dts" } }[x]; P({ template: r, root: n, ts: !!u, staticFolder: i, useStatic: l }), X({ projectName: a, root: n, ts: !!u, template: r, choiceStep: f }), N({ root: n }), L({ root: n, readme: r?.readme }), E.close(), r?.files?.forEach(p => { let w = k.join(n, k.dirname(p?.path)); v(w, { recursive: !0 }), h(k.join(n, p?.path), p?.content) }), m && j(f?.install, { cwd: n, stdio: "inherit" }), console.log(e(`
|
|
1020
1021
|
\u2705 TezX project "${a}" is ready!
|
|
1021
|
-
`, "green")), console.log(e("\u{1F9F0} Summary of your configuration:", "cyan")), console.log(`\u{1F4C1} Project Name: ${e(a, "yellow")}`); let
|
|
1022
|
-
`), console.log(e("\u{1F449} Next Steps:", "cyan")), console.log(e(` ${f?.cd}`, "white")), m || console.log(e(` ${f?.install}`, "white")), console.log(e(` ${f?.dev}`, "white")), console.log(""),
|
|
1023
|
-
|
|
1024
|
-
|
|
1022
|
+
`, "green")), console.log(e("\u{1F9F0} Summary of your configuration:", "cyan")), console.log(`\u{1F4C1} Project Name: ${e(a, "yellow")}`); let z = t?.t || t?.template; z && console.log(`\u{1F4C1} Template Name: ${e(z, "orange")}`), console.log(`\u{1F7E6} TypeScript: ${e(u ? "Yes" : "No", u ? "green" : "gray")}`), console.log(`\u{1F4C1} Static Folder: ${e(l ? i || "public" : "Not Used", l ? "green" : "gray")}`), console.log(`\u{1F4E6} Package Manager: ${e(x, "magenta")}`), console.log(`\u{1F4E5} Dependencies Installed: ${e(m ? "Yes" : "No", m ? "green" : "red")}
|
|
1023
|
+
`), console.log(e("\u{1F449} Next Steps:", "cyan")), console.log(e(` ${f?.cd}`, "white")), m || console.log(e(` ${f?.install}`, "white")), console.log(e(` ${f?.dev}`, "white")), console.log(""), B(), process.exit(0)
|
|
1024
|
+
} c(U, "create"); function q() {
|
|
1025
|
+
console.log(`
|
|
1025
1026
|
${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")}
|
|
1026
1027
|
${e("\u2502", "gray")}${e(" \u26A1 Create TezX", "yellow")} - Scaffold your next backend app ${e("\u2502", "gray")}
|
|
1027
1028
|
${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")}
|
|
@@ -1060,4 +1061,4 @@ Thumbs.db
|
|
|
1060
1061
|
|
|
1061
1062
|
${e("\u{1F9D1}\u200D\u{1F4BB} Author:", "cyan")}
|
|
1062
1063
|
Rakibul Islam ${e("<https://github.com/srakib17>", "blue")}`), process.exit(0)
|
|
1063
|
-
|
|
1064
|
+
} c(q, "showHelp"); function V() { console.log(`TezX CLI v${F}`), process.exit(0) } c(V, "showVersion"), (async () => { const o = c((u, i) => { i.name === "c" && i.ctrl && (process.stdin.off("keypress", o), process.stdin.isTTY && process.stdin.setRawMode(!1), process.exit(0)) }, "onKeyPress"); process.stdin.on("keypress", o); const s = process.argv.slice(2); let t = {}, a; for (let u = 0; u < s.length; u++) { const i = s[u]; if (i.startsWith("--")) { const l = i.slice(2), r = s[u + 1]; r && !r.startsWith("-") ? (t[l] = r, u++) : t[l] = "true" } else if (i.startsWith("-")) { const l = i.slice(1), r = s[u + 1]; r && !r.startsWith("-") ? (t[l] = r, u++) : t[l] = "true" } else a || (a = i) } let n = { directory: a, options: t }; if ((t.y === "true" || t.yes === "true") && (n.options.ts = "true", n.options.useStatic = "true", n.options.staticFolder = "public", n.options.pm = S?.includes(n.options?.p || n?.options?.pm) ? n.options?.p || n?.options?.pm : "npm", n.options.p = S?.includes(n.options?.p || n?.options?.pm) ? n.options?.p || n?.options?.pm : "npm", n.options.install = "true"), t.help || t.h) { q(); return } if (t.v || t.version) { V(); return } U(n) })();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-tezx-app",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.9",
|
|
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",
|