create-gramstax 0.0.27 → 0.1.1
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/LICENSE +25 -25
- package/dist/src/index.cjs +2 -2
- package/dist/src/index.js +2 -2
- package/dist/src/templates/.env.example +15 -18
- package/dist/src/templates/.prettierrc +23 -23
- package/dist/src/templates/README.md +120 -121
- package/dist/src/templates/bunfig.toml +1 -1
- package/dist/src/templates/package.json +48 -54
- package/dist/src/templates/src/base/guard.ts +11 -11
- package/dist/src/templates/src/base/index.ts +4 -0
- package/dist/src/templates/src/base/page.ts +3 -3
- package/dist/src/templates/src/base/repository.ts +1 -1
- package/dist/src/templates/src/base/service.ts +1 -1
- package/dist/src/templates/src/core/bot.ts +23 -23
- package/dist/src/templates/src/core/ctx.ts +3 -3
- package/dist/src/templates/src/core/index.ts +2 -0
- package/dist/src/templates/src/db/index.ts +1 -3
- package/dist/src/templates/src/env.ts +5 -6
- package/dist/src/templates/src/guards/index.ts +1 -0
- package/dist/src/templates/src/guards/user.ts +19 -19
- package/dist/src/templates/src/index.ts +15 -15
- package/dist/src/templates/src/pages/general-error-input-notfound.ts +28 -39
- package/dist/src/templates/src/pages/general-error.ts +60 -59
- package/dist/src/templates/src/pages/help.ts +49 -61
- package/dist/src/templates/src/pages/start.ts +69 -70
- package/dist/src/templates/src/pages/username-notfound.ts +33 -46
- package/dist/src/templates/src/repositories/example.ts +3 -5
- package/dist/src/templates/src/repositories/index.ts +1 -0
- package/dist/src/templates/src/services/example.ts +3 -4
- package/dist/src/templates/src/services/index.ts +1 -0
- package/dist/src/templates/src/threads/index.ts +1 -0
- package/dist/src/templates/src/threads/main.ts +9 -9
- package/dist/src/templates/src/utils/index.ts +1 -0
- package/dist/src/templates/src/utils/log.ts +2 -3
- package/dist/src/templates/tsconfig.json +37 -37
- package/package.json +8 -2
- package/dist/src/templates/.prettierignore +0 -1
- package/dist/src/templates/ecosystem.config.js +0 -26
- package/dist/src/templates/src/base/general.ts +0 -3
|
@@ -1,46 +1,33 @@
|
|
|
1
|
-
import { HelpPage } from "./help"
|
|
2
|
-
import { PageBase } from "~/base
|
|
3
|
-
|
|
4
|
-
export class UserNameNotFoundPage extends PageBase {
|
|
5
|
-
public kb() {
|
|
6
|
-
return this.inlineKeyboard((kb, arr) => {
|
|
7
|
-
return kb
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
await this.
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
<keyboard type="inline">..
|
|
25
|
-
<keyboard lang="
|
|
26
|
-
|
|
27
|
-
<
|
|
28
|
-
|
|
29
|
-
<message>
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
Please set the username first before using the bot.
|
|
35
|
-
</message>
|
|
36
|
-
|
|
37
|
-
<message lang="it">
|
|
38
|
-
Prima di utilizzare il bot, imposta prima il nome utente.
|
|
39
|
-
</message>
|
|
40
|
-
|
|
41
|
-
<message lang="id">
|
|
42
|
-
Tolong set username dulu sebelum memakai bot
|
|
43
|
-
</message>
|
|
44
|
-
</base>
|
|
45
|
-
`
|
|
46
|
-
}
|
|
1
|
+
import { HelpPage } from "./help"
|
|
2
|
+
import { PageBase } from "~/base"
|
|
3
|
+
|
|
4
|
+
export class UserNameNotFoundPage extends PageBase {
|
|
5
|
+
public kb() {
|
|
6
|
+
return this.inlineKeyboard((kb, arr) => {
|
|
7
|
+
return kb.text(arr[0]!, HelpPage.data.callbackData())
|
|
8
|
+
})
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
public async transition(edit = true) {
|
|
12
|
+
const kb = this.kb()
|
|
13
|
+
if (edit) {
|
|
14
|
+
await this.edit(kb)
|
|
15
|
+
} else {
|
|
16
|
+
await this.reply(kb)
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
public static template = /*jsx*/ `
|
|
21
|
+
<base>
|
|
22
|
+
<keyboard type="inline">.. Home</keyboard>
|
|
23
|
+
<keyboard lang="en" type="inline">.. Home</keyboard>
|
|
24
|
+
<keyboard lang="es" type="inline">.. Inicio</keyboard>
|
|
25
|
+
<keyboard lang="id" type="inline">.. Beranda</keyboard>
|
|
26
|
+
|
|
27
|
+
<message>Please set the username first before using the bot.</message>
|
|
28
|
+
<message lang="en">Please set the username first before using the bot.</message>
|
|
29
|
+
<message lang="it">Prima di utilizzare il bot, imposta prima il nome utente.</message>
|
|
30
|
+
<message lang="id">Tolong set username dulu sebelum memakai bot</message>
|
|
31
|
+
</base>
|
|
32
|
+
`
|
|
33
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./example"
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export class ExampleService extends ServiceBase {}
|
|
1
|
+
import { ServiceBase } from "~/base/service"
|
|
2
|
+
|
|
3
|
+
export class ExampleService extends ServiceBase {}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./example"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./main"
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { isMainThread } from "bun"
|
|
2
|
-
|
|
3
|
-
export class MainThread {
|
|
4
|
-
constructor(
|
|
5
|
-
if (isMainThread === true) {
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
}
|
|
1
|
+
import { isMainThread } from "bun"
|
|
2
|
+
|
|
3
|
+
export class MainThread {
|
|
4
|
+
constructor(wrapCode: () => any) {
|
|
5
|
+
if (isMainThread === true) {
|
|
6
|
+
wrapCode()
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./log"
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
export const log = new LoggingPretty()
|
|
1
|
+
import { log } from "gramstax"
|
|
2
|
+
export { log }
|
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
// Short relative path
|
|
4
|
-
"baseUrl": ".",
|
|
5
|
-
"paths": {
|
|
6
|
-
"~/*": [
|
|
7
|
-
"./src/*"
|
|
8
|
-
]
|
|
9
|
-
},
|
|
10
|
-
// Environment setup & latest features
|
|
11
|
-
"lib": [
|
|
12
|
-
"ESNext"
|
|
13
|
-
],
|
|
14
|
-
"target": "ESNext",
|
|
15
|
-
"module": "Preserve",
|
|
16
|
-
"moduleDetection": "force",
|
|
17
|
-
"types": [
|
|
18
|
-
//{{types}}
|
|
19
|
-
],
|
|
20
|
-
"jsx": "react-jsx",
|
|
21
|
-
"allowJs": true,
|
|
22
|
-
// Bundler mode
|
|
23
|
-
"moduleResolution": "bundler",
|
|
24
|
-
"allowImportingTsExtensions": true,
|
|
25
|
-
"verbatimModuleSyntax": true,
|
|
26
|
-
"noEmit": true,
|
|
27
|
-
// Best practices
|
|
28
|
-
"strict": true,
|
|
29
|
-
"skipLibCheck": true,
|
|
30
|
-
"noFallthroughCasesInSwitch": true,
|
|
31
|
-
"noUncheckedIndexedAccess": true,
|
|
32
|
-
// Some stricter flags (disabled by default)
|
|
33
|
-
"noImplicitOverride": false,
|
|
34
|
-
"noUnusedLocals": false,
|
|
35
|
-
"noUnusedParameters": false,
|
|
36
|
-
"noPropertyAccessFromIndexSignature": false,
|
|
37
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
// Short relative path
|
|
4
|
+
"baseUrl": ".",
|
|
5
|
+
"paths": {
|
|
6
|
+
"~/*": [
|
|
7
|
+
"./src/*"
|
|
8
|
+
]
|
|
9
|
+
},
|
|
10
|
+
// Environment setup & latest features
|
|
11
|
+
"lib": [
|
|
12
|
+
"ESNext"
|
|
13
|
+
],
|
|
14
|
+
"target": "ESNext",
|
|
15
|
+
"module": "Preserve",
|
|
16
|
+
"moduleDetection": "force",
|
|
17
|
+
"types": [
|
|
18
|
+
//{{types}}
|
|
19
|
+
],
|
|
20
|
+
"jsx": "react-jsx",
|
|
21
|
+
"allowJs": true,
|
|
22
|
+
// Bundler mode
|
|
23
|
+
"moduleResolution": "bundler",
|
|
24
|
+
"allowImportingTsExtensions": true,
|
|
25
|
+
"verbatimModuleSyntax": true,
|
|
26
|
+
"noEmit": true,
|
|
27
|
+
// Best practices
|
|
28
|
+
"strict": true,
|
|
29
|
+
"skipLibCheck": true,
|
|
30
|
+
"noFallthroughCasesInSwitch": true,
|
|
31
|
+
"noUncheckedIndexedAccess": true,
|
|
32
|
+
// Some stricter flags (disabled by default)
|
|
33
|
+
"noImplicitOverride": false,
|
|
34
|
+
"noUnusedLocals": false,
|
|
35
|
+
"noUnusedParameters": false,
|
|
36
|
+
"noPropertyAccessFromIndexSignature": false,
|
|
37
|
+
}
|
|
38
38
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-gramstax",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"private": false,
|
|
5
|
+
"publishConfig": {
|
|
6
|
+
"access": "public",
|
|
7
|
+
"provenance": false
|
|
8
|
+
},
|
|
5
9
|
"description": "CLI tool to quickly create a new Gramstax Telegram bot project with all the best practices",
|
|
6
10
|
"keywords": [
|
|
7
11
|
"create-gramstax",
|
|
@@ -13,6 +17,9 @@
|
|
|
13
17
|
"scaffold",
|
|
14
18
|
"telegram-bot"
|
|
15
19
|
],
|
|
20
|
+
"scripts": {
|
|
21
|
+
"nx-release-publish": "npm publish --access public"
|
|
22
|
+
},
|
|
16
23
|
"repository": {
|
|
17
24
|
"type": "git",
|
|
18
25
|
"url": "git+https://github.com/gramstax/gramstax.git",
|
|
@@ -51,7 +58,6 @@
|
|
|
51
58
|
"dependencies": {
|
|
52
59
|
"commander": "^14.0.2",
|
|
53
60
|
"enquirer": "^2.4.1",
|
|
54
|
-
"gramstax": "latest",
|
|
55
61
|
"logging-pretty": "^3.0.0"
|
|
56
62
|
}
|
|
57
63
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
*.html
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
apps: [
|
|
3
|
-
{
|
|
4
|
-
name: `{{projectName}}`, // Process name (appears in 'pm2 list')
|
|
5
|
-
script: `bun`, // Main command to run (using Bun runtime)
|
|
6
|
-
args: `src/index.ts`, // Arguments for the command (entry file)
|
|
7
|
-
instances: 1, // Number of instances (use 'max' for multi-core)
|
|
8
|
-
exec_mode: `fork`, // Cluster mode (PM2 will balance across cores)
|
|
9
|
-
autorestart: true, // Automatically restart if the process crashes
|
|
10
|
-
watch: false, // Disable auto-reload on file changes (set true for dev)
|
|
11
|
-
max_memory_restart: undefined, // Restart if memory usage exceeds (default undefined)
|
|
12
|
-
env: {
|
|
13
|
-
NODE_ENV: `production`, // Default environment variables
|
|
14
|
-
},
|
|
15
|
-
env_production: {
|
|
16
|
-
NODE_ENV: `production`, // Environment variables for production mode
|
|
17
|
-
},
|
|
18
|
-
error_file: `./logs/err.log`, // Error log file
|
|
19
|
-
out_file: `./logs/out.log`, // Standard output log file
|
|
20
|
-
log_file: `./logs/combined.log`, // Combined log file
|
|
21
|
-
time: false, // Add timestamps to logs
|
|
22
|
-
merge_logs: false, // Merge logs from multiple instances
|
|
23
|
-
log_date_format: `YYYY-MM-DD HH:mm:ss Z`, // Log date format
|
|
24
|
-
},
|
|
25
|
-
],
|
|
26
|
-
};
|