Skip to content

Commit

Permalink
fix: revert accidental minor release with breaking changes
Browse files Browse the repository at this point in the history
  • Loading branch information
IlyaSemenov committed Apr 30, 2023
1 parent e6b73ba commit 512fc6b
Show file tree
Hide file tree
Showing 25 changed files with 2,426 additions and 1,320 deletions.
3 changes: 3 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/dist/
tap-snapshots
!.eslintrc.js
1 change: 0 additions & 1 deletion .eslintrc.cjs → .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,4 @@ module.exports = {
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/explicit-module-boundary-types": "off",
},
ignorePatterns: ["/dist/"],
}
6 changes: 6 additions & 0 deletions .taprc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
coverage: false
node-arg:
[
"-r",
"esbuild-runner/register",
]
28 changes: 10 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

## Install

```sh
npm i grammy-scenes
```
yarn add grammy-scenes
```

## Use
Expand Down Expand Up @@ -80,22 +80,19 @@ import { BotContext } from "../bot"

export const mainScene = new Scene<BotContext>("main")

// Define scene flow with middlewares.
// Make sure you call next() or the scene will stop.
mainScene.use(async (ctx, next) => {
await ctx.reply("Entering main scene...")
// Scene extends Composer, so you may use all methods such as .use() .on() etc.
mainScene.use((ctx, next) => {
console.log("Entering main scene...")
return next()
})

// do() is a shortcut for use() which automatically calls next()
// Simply put, do() is a use() which automatically calls next()
mainScene.do(async (ctx) => {
await ctx.reply("Enter your name:")
await ctx.reply(`Enter your name:`)
})

// As the flow comes to wait(), the execution will stop.
// Next Telegram updates will be passed to the inner middleware.
// As the flow comes to wait() middleware, the execution will stop and next Telegram updates will be passed to the inner middleware.
// The inner middleware should call ctx.scene.resume() to proceed to the next scene step.
// Make sure to use unique name in each wait() block.
mainScene.wait().on("message:text", async (ctx) => {
const name = ctx.message.text
if (name.toLowerCase() === "john") {
Expand All @@ -108,11 +105,6 @@ mainScene.wait().on("message:text", async (ctx) => {
}
})

// Add more steps...
mainScene.do(async (ctx) => {
await ctx.reply("Proceeding...")
})

// Mark position in the scene to be able to jump to it (see below).
mainScene.label("start")

Expand Down Expand Up @@ -341,8 +333,8 @@ scene.always().do(async (ctx) => {
}
})

scene.do((ctx) => {
ctx.scene.session = { foo_id: 123 } // Save ID to session
scene.do(async (ctx) => {
ctx.session = { foo_id: 123 } // Save ID to session
})

scene.wait().on("message", async (ctx) => {
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions lint-staged.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export default {
"*.{cjs,js,ts}": "eslint --fix",
module.exports = {
"*.{js,ts}": "eslint --fix",
}
62 changes: 31 additions & 31 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,27 @@
},
"author": "Ilya Semenov",
"license": "MIT",
"type": "module",
"exports": {
"import": "./dist/index.js",
"require": "./dist/index.cjs"
},
"main": "dist/index.js",
"module": "dist/index.mjs",
"types": "dist/index.d.ts",
"source": "src/index.ts",
"files": [
"dist",
"src"
"src",
"!**/*.test.*"
],
"scripts": {
"build": "tsup",
"prepack": "npm run build",
"lint": "eslint --fix '**/*.{cjs,js,ts}' && prettier --write '**/*.json'",
"lint": "eslint --fix '**/*.{js,ts}'",
"prepare": "husky install",
"test": "npm run test:types",
"test": "npm run test:types && tap 'tests/**/*.test.ts'",
"test:types": "tsc --noEmit",
"dev": "vite-node --watch"
"dev": "NODE_OPTIONS='-r dotenv/config' nodemon --exec esr"
},
"dependencies": {
"ts-essentials": "^9",
"uuid": "^8 || ^9"
"ts-essentials": "^9.1.0",
"uuid": "^8.3.2"
},
"peerDependencies": {
"grammy": "^1.5.4",
Expand All @@ -42,26 +40,28 @@
}
},
"devDependencies": {
"@commitlint/cli": "~17.6.1",
"@commitlint/config-conventional": "~17.6.1",
"@tsconfig/node18": "~2.0.0",
"@types/node": "~18.16.3",
"@types/uuid": "~9.0.1",
"@typescript-eslint/eslint-plugin": "~5.59.1",
"@typescript-eslint/parser": "~5.59.1",
"eslint": "~8.39.0",
"eslint-config-prettier": "~8.8.0",
"eslint-plugin-prettier": "~4.2.1",
"eslint-plugin-simple-import-sort": "~10.0.0",
"@commitlint/cli": "^15.0.0",
"@commitlint/config-conventional": "^15.0.0",
"@tsconfig/node14": "^1.0.1",
"@types/tap": "^15.0.5",
"@types/uuid": "^8.3.3",
"@typescript-eslint/eslint-plugin": "^5.8.0",
"@typescript-eslint/parser": "^5.8.0",
"dotenv": "^14.1.0",
"esbuild": "^0.14.8",
"esbuild-runner": "^2.2.1",
"eslint": "^8.5.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-simple-import-sort": "^7.0.0",
"grammy": "~1.16.0",
"grammy-pseudo-update": "^3.0.1",
"husky": "~8.0.3",
"lint-staged": "~13.2.2",
"prettier": "~2.8.8",
"tsup": "~6.7.0",
"typescript": "~5.0.4",
"vite": "~4.3.3",
"vite-node": "~0.30.1",
"vite-tsconfig-paths": "~4.2.0"
"grammy-pseudo-update": "^3.0.0",
"husky": ">=6",
"lint-staged": ">=10",
"nodemon": "^2.0.15",
"prettier": "^2.1.2",
"tap": "^15.1.5",
"tsup": "^5.11.9",
"typescript": "^4.0.5"
}
}
Loading

0 comments on commit 512fc6b

Please sign in to comment.