create-tezx-app 1.0.8 → 2.0.6
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 +30 -30
- package/package.json +1 -1
package/bin
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{execSync as
|
|
2
|
+
import{execSync as H}from"node:child_process";import{mkdirSync as z,writeFileSync as X}from"node:fs";import $,{join as Y,resolve as J}from"node:path";import _ from"node:readline";var g=(s,n)=>({version:n,npm:["npm install",s],bun:["bun add",s],yarn:["yarn add",s],pnpm:["pnpm add",s]});var I={content:`
|
|
3
3
|
// 1. Initialize OAuth2 client
|
|
4
4
|
const client = GitHubOauthClient({
|
|
5
5
|
clientId: process.env.GITHUB_CLIENT_ID,
|
|
@@ -31,7 +31,7 @@ app.get('/github/callback', verifyGithubToken({
|
|
|
31
31
|
});
|
|
32
32
|
`,files:[{content:`GITHUB_CLIENT_ID = 12323
|
|
33
33
|
GITHUB_CLIENT_SECRET=234234
|
|
34
|
-
`,path:".env"}],import:["import { GitHubOauthClient, getGithubOAuthURL, verifyGithubToken } from '@tezx/github-oauth2'; "],package:[g("@tezx/github-oauth2","^1.0.2")]};var
|
|
34
|
+
`,path:".env"}],import:["import { GitHubOauthClient, getGithubOAuthURL, verifyGithubToken } from '@tezx/github-oauth2'; "],package:[g("@tezx/github-oauth2","^1.0.2")]};var G={content:`
|
|
35
35
|
// 1. Initialize OAuth2 client
|
|
36
36
|
const client = GoogleOauthClient({
|
|
37
37
|
clientId: process.env.GOOGLE_CLIENT_ID,
|
|
@@ -86,7 +86,7 @@ app.get('/auth/callback', verifyGoogleToken({
|
|
|
86
86
|
});
|
|
87
87
|
`,files:[{content:`GOOGLE_CLIENT_ID = 12323
|
|
88
88
|
GOOGLE_CLIENT_SECRET=234234
|
|
89
|
-
`,path:".env"}],import:['import { GoogleOauthClient, getGoogleOAuthURL, verifyGoogleToken } from "@tezx/google-oauth2";'],package:[g("@tezx/google-oauth2","^1.0.8"),g("@googleapis/oauth2","^2.0.1")]};var
|
|
89
|
+
`,path:".env"}],import:['import { GoogleOauthClient, getGoogleOAuthURL, verifyGoogleToken } from "@tezx/google-oauth2";'],package:[g("@tezx/google-oauth2","^1.0.8"),g("@googleapis/oauth2","^2.0.1")]};var D=`
|
|
90
90
|
<!DOCTYPE html>
|
|
91
91
|
<html lang="en">
|
|
92
92
|
<head>
|
|
@@ -254,7 +254,7 @@ GOOGLE_CLIENT_SECRET=234234
|
|
|
254
254
|
</script>
|
|
255
255
|
</body>
|
|
256
256
|
</html>
|
|
257
|
-
`,
|
|
257
|
+
`,N={content:`
|
|
258
258
|
const socket = [];
|
|
259
259
|
app.get(
|
|
260
260
|
"/ws",
|
|
@@ -290,12 +290,12 @@ app.get(
|
|
|
290
290
|
return ctx.sendFile("public/ws.html");
|
|
291
291
|
},
|
|
292
292
|
);
|
|
293
|
-
`,files:[{content:
|
|
294
|
-
`),t.forEach((l,
|
|
293
|
+
`,files:[{content:D,path:"public/ws.html"}],import:['import { upgradeWebSocket } from "tezx/ws";']};var C={minimal:{content:"",files:[],import:[],package:[]},ws:N,"github-oauth2":I,"google-oauth2":G};import F from"node:readline";async function j(s,n,t){return new Promise(r=>{let o=0;F.emitKeypressEvents(process.stdin,s),process.stdin.isTTY&&process.stdin.setRawMode(!0);let a=()=>{process.stdout.write("\x1B[2J\x1B[0f"),console.log(n+` (Use \u2191 \u2193 arrows, Enter to confirm)
|
|
294
|
+
`),t.forEach((l,i)=>{console.log(`${i===o?"\u{1F449}":" "} ${i===o?"\x1B[36m":"\x1B[0m"}${l}\x1B[0m`)})},c=(l,i)=>{if(i.name==="up")o=(o-1+t.length)%t.length,a();else if(i.name==="down")o=(o+1)%t.length,a();else if(i.name==="return")return r(t[o])};a(),process.stdin.on("keypress",c)})}var L={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(s,n){return`${L[n]}${s}${L.reset}`}import{mkdirSync as B,writeFileSync as O}from"node:fs";import{join as k}from"node:path";var T="2.0.6";var M=({ts:s,template:n,root:t,env:r,useStatic:o=!1,staticFolder:a})=>{let c=k(t,s?"src/index.ts":"src/index.js");B(k(t,"src"),{recursive:!0});let l=`
|
|
295
295
|
import { TezX } from "tezx";
|
|
296
|
-
import { ${
|
|
296
|
+
import { ${r}Adapter ,loadEnv} from "tezx/${r}";
|
|
297
297
|
import { logger } from "tezx/middleware";
|
|
298
|
-
${
|
|
298
|
+
${n?.import?.join(`
|
|
299
299
|
`)}
|
|
300
300
|
const app = new TezX({
|
|
301
301
|
env: loadEnv(),
|
|
@@ -304,16 +304,16 @@ const app = new TezX({
|
|
|
304
304
|
});
|
|
305
305
|
app.use([logger()]);
|
|
306
306
|
|
|
307
|
-
app.get("/", (ctx) => ctx.text("Hello from TezX (${
|
|
307
|
+
app.get("/", (ctx) => ctx.text("Hello from TezX (${r})"));
|
|
308
308
|
|
|
309
|
-
${
|
|
310
|
-
${
|
|
311
|
-
${
|
|
309
|
+
${o?`app.static("${a||"public"}");`:""}
|
|
310
|
+
${n?.content?`
|
|
311
|
+
${n?.content?.trim()}
|
|
312
312
|
`:""}
|
|
313
|
-
${
|
|
313
|
+
${r}Adapter(app).listen(3000, () => {
|
|
314
314
|
console.log("\u{1F680} TezX running on http://localhost:3000");
|
|
315
315
|
});
|
|
316
|
-
`;if(
|
|
316
|
+
`;if(s){let i=`
|
|
317
317
|
{
|
|
318
318
|
"compilerOptions": {
|
|
319
319
|
"outDir": "./dist",
|
|
@@ -335,18 +335,18 @@ ${n}Adapter(app).listen(3000, () => {
|
|
|
335
335
|
"tests"
|
|
336
336
|
]
|
|
337
337
|
}
|
|
338
|
-
`.trim();
|
|
338
|
+
`.trim();O(k(t,"tsconfig.json"),i)}O(c,l.trim())},R=({template:s,root:n,projectName:t,env:r,ts:o,useWS:a,choiceStep:c})=>{let l=[];Array.isArray(s?.package)&&s?.package?.forEach(d=>{let{version:x,npm:h}=d||{};l.push(`"${h?.[1]}": "${x}"`)});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=`
|
|
339
339
|
{
|
|
340
340
|
"name": "${t||"tezx-app-example"}",
|
|
341
341
|
"version": "1.0.0",
|
|
342
342
|
"type": "module",
|
|
343
343
|
"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.",
|
|
344
|
-
"scripts": { ${
|
|
344
|
+
"scripts": { ${o?`
|
|
345
345
|
"build:esm": "tsc --module ESNext --outDir dist --removeComments",
|
|
346
346
|
"build:dts": "tsc --module ESNext --outDir dist --declaration --emitDeclarationOnly",
|
|
347
347
|
"build": "${c?.build}",`:""}
|
|
348
|
-
"start": "${
|
|
349
|
-
"dev": "${
|
|
348
|
+
"start": "${i?.[r]?.start}",
|
|
349
|
+
"dev": "${i?.[r]?.dev}"
|
|
350
350
|
},
|
|
351
351
|
"repository": {
|
|
352
352
|
"type": "git",
|
|
@@ -360,9 +360,9 @@ ${n}Adapter(app).listen(3000, () => {
|
|
|
360
360
|
},
|
|
361
361
|
"homepage": "https://github.com/tezxjs/tezx-app-example",
|
|
362
362
|
"dependencies": {
|
|
363
|
-
${
|
|
364
|
-
"tezx": "
|
|
365
|
-
"tsx": "^4.19.2"`:""}${
|
|
363
|
+
${o?'"typescript": "^5.8.2",':""}
|
|
364
|
+
"tezx": "^${T}"${r=="node"?`,
|
|
365
|
+
"tsx": "^4.19.2"`:""}${a&&r=="node"?`,
|
|
366
366
|
"ws": "^8.18.1"`:""}${l.length?`,
|
|
367
367
|
${l?.join(`,
|
|
368
368
|
`)}`:""}
|
|
@@ -370,15 +370,15 @@ ${n}Adapter(app).listen(3000, () => {
|
|
|
370
370
|
"devDependencies": {
|
|
371
371
|
"@types/node": "^22.13.14"
|
|
372
372
|
}
|
|
373
|
-
}`.trim();
|
|
374
|
-
`)}}var
|
|
373
|
+
}`.trim();O(k(n,"package.json"),p)};var y=["npm","bun","yarn","pnpm"],f=["node","bun","deno"];function K(s){let n=0,t=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"],r=setInterval(()=>{process.stdout.write(`\r${t[n=++n%t.length]} ${s}`)},80);return()=>{clearInterval(r),process.stdout.write(`\r\u2705 Done!
|
|
374
|
+
`)}}var S=_.createInterface({input:process.stdin,output:process.stdout});_.emitKeypressEvents(process.stdin);process.stdin.isTTY&&process.stdin.setRawMode(!0);var b=(s,n="")=>new Promise(t=>{S.question(n?`${s} (${n}): `:s,r=>{t(r.trim()||n)})});async function A(s){let n=s?.directory,t=s?.options;console.log(e(`
|
|
375
375
|
\u26A1 TezX App Creator (no dependencies CLI)
|
|
376
|
-
`,"orange")),
|
|
377
|
-
\u{1F4C1} Creating project: ${
|
|
378
|
-
`);let
|
|
379
|
-
\u2705 TezX project "${
|
|
380
|
-
`,"green")),console.log(e("\u{1F9F0} Summary of your configuration:","cyan")),console.log(`\u{1F4C1} Project Name: ${e(
|
|
381
|
-
`),console.log(e("\u{1F449} Next Steps:","cyan")),console.log(e(` ${u?.cd}`,"white")),w||console.log(e(` ${u?.install}`,"white")),console.log(e(` ${u?.dev}`,"white")),console.log(""),
|
|
376
|
+
`,"orange")),n||(n=await b(e("\u{1F4E6} Project name: ","magenta")),n||(console.log(e("\u274C Project name required.","red")),process.exit(0)));let r=$.basename(n),o=J(process.cwd(),n),a=!!t?.ts,c=t?.env||t?.runtime,l=f?.includes(c)?c:await j(S,"\u{1F4BB} Runtime?",f),i=t?.staticFolder||"public",p=!0,d={content:"",import:[],files:[]};if(t?.t||t?.template){let m=t.t||t.template,v=C?.[m];v||(console.error(`\u274C Unknown template: "${m}"`),console.error(`\u2139\uFE0F Available templates: ${Object.keys(C).join(", ")}`),process.exit(0)),d=v}else a=!!(t?.ts||(await b("\u{1F7E6} Use TypeScript? (y/N): ")).toLowerCase()==="y"),p=!!t?.useStatic||(await b("\u{1F4C1} Use static folder? (y/N): ")).toLowerCase()==="y",i=p?t?.staticFolder||await b("\u{1F4C2} Static folder name? (default: public): "):"";let x=t?.pm||t?.p,h=y?.includes(x)?x:await j(S,"\u{1F4E6} Choose your package manager",y),w=t?.i==="true"||t?.install==="true"||(await b("\u{1F4E5} Install dependencies now? (y/N): ")).toLowerCase()==="y";console.log(`
|
|
377
|
+
\u{1F4C1} Creating project: ${r}...
|
|
378
|
+
`);let U=K("Creating Project");if(z(o,{recursive:!0}),p){let m=Y(o,i||"public");z(m,{recursive:!0})}let u={bun:{cd:"cd "+n,install:"bun install",dev:"bun dev",build:"bun build:cjs && bun build:esm && bun build:dts"},npm:{cd:"cd "+n,install:"npm install",dev:"npm run dev",build:"npm run build:cjs && npm run build:esm && npm run build:dts"},yarn:{cd:"cd "+n,install:"yarn",dev:"yarn dev",build:"yarn build:cjs && yarn build:esm && yarn build:dts"},pnpm:{cd:"cd "+n,install:"pnpm install",dev:"pnpm run dev",build:"pnpm run build:cjs && pnpm run build:esm && pnpm run build:dts"}}[h];M({template:d,root:o,ts:!!a,env:l,staticFolder:i,useStatic:p}),R({projectName:r,env:l,root:o,ts:!!a,template:d,choiceStep:u}),S.close(),d?.files?.forEach(m=>{let v=$.join(o,$.dirname(m?.path));z(v,{recursive:!0}),X($.join(o,m?.path),m?.content)}),w&&H(u?.install,{cwd:o,stdio:"inherit"}),console.log(e(`
|
|
379
|
+
\u2705 TezX project "${r}" is ready!
|
|
380
|
+
`,"green")),console.log(e("\u{1F9F0} Summary of your configuration:","cyan")),console.log(`\u{1F4C1} Project Name: ${e(r,"yellow")}`);let E=t?.t||t?.template;E&&console.log(`\u{1F4C1} Template Name: ${e(E,"orange")}`),console.log(`\u{1F7E6} TypeScript: ${e(a?"Yes":"No",a?"green":"gray")}`),console.log(`\u{1F4BB} Runtime: ${e(l,"blue")}`),console.log(`\u{1F4C1} Static Folder: ${e(p?i||"public":"Not Used",p?"green":"gray")}`),console.log(`\u{1F4E6} Package Manager: ${e(h,"magenta")}`),console.log(`\u{1F4E5} Dependencies Installed: ${e(w?"Yes":"No",w?"green":"red")}
|
|
381
|
+
`),console.log(e("\u{1F449} Next Steps:","cyan")),console.log(e(` ${u?.cd}`,"white")),w||console.log(e(` ${u?.install}`,"white")),console.log(e(` ${u?.dev}`,"white")),console.log(""),U(),process.exit(0)}function P(){console.log(`
|
|
382
382
|
${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\u256E","gray")}
|
|
383
383
|
${e("\u2502","gray")} ${e("\u26A1 Create TezX","yellow")} - Scaffold your next backend app ${e("\u2502","gray")}
|
|
384
384
|
${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\u256F","gray")}
|
|
@@ -418,4 +418,4 @@ ${n}Adapter(app).listen(3000, () => {
|
|
|
418
418
|
${e("https://github.com/tezxjs/tezx","underline")}
|
|
419
419
|
|
|
420
420
|
${e("\u{1F9D1}\u200D\u{1F4BB} Author:","cyan")}
|
|
421
|
-
Rakibul Islam ${e("<https://github.com/srakib17>","blue")}`),process.exit(0)}function
|
|
421
|
+
Rakibul Islam ${e("<https://github.com/srakib17>","blue")}`),process.exit(0)}function W(){console.log(`TezX CLI v${T}`),process.exit(0)}(async()=>{let s=(a,c)=>{c.name==="c"&&c.ctrl&&(process.stdin.off("keypress",s),process.stdin.isTTY&&process.stdin.setRawMode(!1),process.exit(0))};process.stdin.on("keypress",s);let n=process.argv.slice(2),t={},r;for(let a=0;a<n.length;a++){let c=n[a];if(c.startsWith("--")){let l=c.slice(2),i=n[a+1];i&&!i.startsWith("-")?(t[l]=i,a++):t[l]="true"}else if(c.startsWith("-")){let l=c.slice(1),i=n[a+1];i&&!i.startsWith("-")?(t[l]=i,a++):t[l]="true"}else r||(r=c)}let o={directory:r,options:t};if((t.y==="true"||t.yes==="true")&&(o.options.ts="true",o.options.useStatic="true",o.options.staticFolder="public",o.options.pm=y?.includes(o.options?.p||o?.options?.pm)?o.options?.p||o?.options?.pm:"npm",o.options.p=y?.includes(o.options?.p||o?.options?.pm)?o.options?.p||o?.options?.pm:"npm",o.options.env=f?.includes(o.options?.env||o?.options?.runtime)?o.options?.env||o?.options?.runtime:"node",o.options.runtime=f?.includes(o.options?.env||o?.options?.runtime)?o.options?.env||o?.options?.runtime:"node",o.options.install="true"),t.help||t.h){P();return}if(t.v||t.version){W();return}A(o)})();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-tezx-app",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.6",
|
|
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",
|