Commit Graph

229 Commits

Author SHA1 Message Date
Anton Morgunov 03567a51b9
DEV: bump the moment-timezone version to 0.5.45 (#26002)
Bump the moment-timezone version in package.json to reflect 2024a release of TZDB
2024-03-11 11:46:09 +11:00
dependabot[bot] ba3508d706
Build(deps-dev): Bump puppeteer-core from 22.4.0 to 22.4.1 (#26115)
Bumps [puppeteer-core](https://github.com/puppeteer/puppeteer) from 22.4.0 to 22.4.1.
- [Release notes](https://github.com/puppeteer/puppeteer/releases)
- [Changelog](https://github.com/puppeteer/puppeteer/blob/main/release-please-config.json)
- [Commits](https://github.com/puppeteer/puppeteer/compare/puppeteer-core-v22.4.0...puppeteer-core-v22.4.1)

---
updated-dependencies:
- dependency-name: puppeteer-core
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-03-11 06:57:19 +08:00
dependabot[bot] 3f066b98c9
Build(deps-dev): Bump typescript from 5.3.3 to 5.4.2 (#26066)
Bumps [typescript](https://github.com/Microsoft/TypeScript) from 5.3.3 to 5.4.2.
- [Release notes](https://github.com/Microsoft/TypeScript/releases)
- [Changelog](https://github.com/microsoft/TypeScript/blob/main/azure-pipelines.release.yml)
- [Commits](https://github.com/Microsoft/TypeScript/compare/v5.3.3...v5.4.2)

---
updated-dependencies:
- dependency-name: typescript
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-03-07 01:05:19 +01:00
Chris Pelatari b3dce458d2
DEV: Support `yarn dev` 2024-03-06 08:25:46 +08:00
dependabot[bot] 475333c787
Build(deps-dev): Bump puppeteer-core from 22.3.0 to 22.4.0 (#26038)
Bumps [puppeteer-core](https://github.com/puppeteer/puppeteer) from 22.3.0 to 22.4.0.
- [Release notes](https://github.com/puppeteer/puppeteer/releases)
- [Changelog](https://github.com/puppeteer/puppeteer/blob/main/release-please-config.json)
- [Commits](https://github.com/puppeteer/puppeteer/compare/puppeteer-core-v22.3.0...puppeteer-core-v22.4.0)

---
updated-dependencies:
- dependency-name: puppeteer-core
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-03-06 07:02:24 +08:00
dependabot[bot] bdf429cce8
Build(deps-dev): Bump lefthook from 1.6.4 to 1.6.5 (#26020)
Bumps [lefthook](https://github.com/evilmartians/lefthook) from 1.6.4 to 1.6.5.
- [Release notes](https://github.com/evilmartians/lefthook/releases)
- [Changelog](https://github.com/evilmartians/lefthook/blob/master/CHANGELOG.md)
- [Commits](https://github.com/evilmartians/lefthook/compare/v1.6.4...v1.6.5)

---
updated-dependencies:
- dependency-name: lefthook
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-03-05 22:43:38 +01:00
dependabot[bot] f0d47c1117
Build(deps-dev): Bump lefthook from 1.6.3 to 1.6.4 (#25942)
Bumps [lefthook](https://github.com/evilmartians/lefthook) from 1.6.3 to 1.6.4.
- [Release notes](https://github.com/evilmartians/lefthook/releases)
- [Changelog](https://github.com/evilmartians/lefthook/blob/master/CHANGELOG.md)
- [Commits](https://github.com/evilmartians/lefthook/compare/v1.6.3...v1.6.4)

---
updated-dependencies:
- dependency-name: lefthook
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-02-28 23:41:55 +01:00
dependabot[bot] 4bec404730
Build(deps-dev): Bump lefthook from 1.6.2 to 1.6.3 (#25919)
Bumps [lefthook](https://github.com/evilmartians/lefthook) from 1.6.2 to 1.6.3.
- [Release notes](https://github.com/evilmartians/lefthook/releases)
- [Changelog](https://github.com/evilmartians/lefthook/blob/master/CHANGELOG.md)
- [Commits](https://github.com/evilmartians/lefthook/compare/v1.6.2...v1.6.3)

---
updated-dependencies:
- dependency-name: lefthook
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-02-27 23:20:08 +01:00
Jarek Radosz b337ae5ae9
DEV: Update chrome-launcher from 0.15.2 to 1.1.0 (#25909) 2024-02-27 11:25:11 +01:00
Jarek Radosz 299b323d9a
DEV: Update ember-cli to 5.6.0 (#25886) 2024-02-27 10:48:30 +01:00
Alan Guo Xiang Tan e84d462e28
Revert "Build(deps-dev): Bump chrome-launcher from 0.15.2 to 1.1.0 (#25894)" (#25897)
This reverts commit f219135415.

Broke our internal smoke tests.
2024-02-27 09:55:59 +08:00
dependabot[bot] f219135415
Build(deps-dev): Bump chrome-launcher from 0.15.2 to 1.1.0 (#25894)
Bumps [chrome-launcher](https://github.com/GoogleChrome/chrome-launcher) from 0.15.2 to 1.1.0.
- [Release notes](https://github.com/GoogleChrome/chrome-launcher/releases)
- [Changelog](https://github.com/GoogleChrome/chrome-launcher/blob/main/changelog.md)
- [Commits](https://github.com/GoogleChrome/chrome-launcher/commits)

---
updated-dependencies:
- dependency-name: chrome-launcher
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-02-27 09:17:27 +08:00
dependabot[bot] a3e564ee74
Build(deps-dev): Bump @discourse/lint-configs from 1.3.5 to 1.3.7 (#25893)
Bumps [@discourse/lint-configs](https://github.com/discourse/lint-configs) from 1.3.5 to 1.3.7.
- [Commits](https://github.com/discourse/lint-configs/commits)

---
updated-dependencies:
- dependency-name: "@discourse/lint-configs"
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-02-26 23:09:54 +01:00
dependabot[bot] 12d6e9a163
Build(deps-dev): Bump esbuild from 0.19.2 to 0.20.1 (#25864)
Bumps [esbuild](https://github.com/evanw/esbuild) from 0.19.2 to 0.20.1.
- [Release notes](https://github.com/evanw/esbuild/releases)
- [Changelog](https://github.com/evanw/esbuild/blob/main/CHANGELOG.md)
- [Commits](https://github.com/evanw/esbuild/compare/v0.19.2...v0.20.1)

---
updated-dependencies:
- dependency-name: esbuild
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-02-26 16:04:55 +00:00
dependabot[bot] 8f30bc34bc
Build(deps-dev): Bump lefthook from 1.4.3 to 1.6.2 (#25867)
Bumps [lefthook](https://github.com/evilmartians/lefthook) from 1.4.3 to 1.6.2.
- [Release notes](https://github.com/evilmartians/lefthook/releases)
- [Changelog](https://github.com/evilmartians/lefthook/blob/master/CHANGELOG.md)
- [Commits](https://github.com/evilmartians/lefthook/compare/v1.4.3...v1.6.2)

---
updated-dependencies:
- dependency-name: lefthook
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-02-26 16:04:34 +00:00
dependabot[bot] fb53a887bd
Build(deps-dev): Bump puppeteer-core from 21.0.3 to 22.3.0 (#25866)
* Build(deps-dev): Bump puppeteer-core from 21.0.3 to 22.3.0

Bumps [puppeteer-core](https://github.com/puppeteer/puppeteer) from 21.0.3 to 22.3.0.
- [Release notes](https://github.com/puppeteer/puppeteer/releases)
- [Changelog](https://github.com/puppeteer/puppeteer/blob/main/release-please-config.json)
- [Commits](https://github.com/puppeteer/puppeteer/compare/puppeteer-core-v21.0.3...puppeteer-core-v22.3.0)

---
updated-dependencies:
- dependency-name: puppeteer-core
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

* Remove xpath usage

* timeout

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: David Taylor <david@taylorhq.com>
2024-02-26 16:03:49 +00:00
dependabot[bot] d7ae479802
Build(deps-dev): Bump chrome-remote-interface from 0.31.3 to 0.33.0 (#25868)
Bumps [chrome-remote-interface](https://github.com/cyrus-and/chrome-remote-interface) from 0.31.3 to 0.33.0.
- [Commits](https://github.com/cyrus-and/chrome-remote-interface/compare/v0.31.3...v0.33.0)

---
updated-dependencies:
- dependency-name: chrome-remote-interface
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-02-26 16:03:23 +00:00
dependabot[bot] c4a16ff136
Build(deps-dev): Bump eslint from 8.56.0 to 8.57.0 (#25877)
Bumps [eslint](https://github.com/eslint/eslint) from 8.56.0 to 8.57.0.
- [Release notes](https://github.com/eslint/eslint/releases)
- [Changelog](https://github.com/eslint/eslint/blob/main/CHANGELOG.md)
- [Commits](https://github.com/eslint/eslint/compare/v8.56.0...v8.57.0)

---
updated-dependencies:
- dependency-name: eslint
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-02-26 15:16:29 +01:00
dependabot[bot] 3475fbe825
Build(deps-dev): Bump typescript from 5.1.6 to 5.3.3 (#25876)
Bumps [typescript](https://github.com/Microsoft/TypeScript) from 5.1.6 to 5.3.3.
- [Release notes](https://github.com/Microsoft/TypeScript/releases)
- [Changelog](https://github.com/microsoft/TypeScript/blob/main/azure-pipelines.release.yml)
- [Commits](https://github.com/Microsoft/TypeScript/compare/v5.1.6...v5.3.3)

---
updated-dependencies:
- dependency-name: typescript
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-02-26 15:16:18 +01:00
dependabot[bot] 7bfbb36259
Build(deps-dev): Bump concurrently from 8.2.1 to 8.2.2 (#25872)
Bumps [concurrently](https://github.com/open-cli-tools/concurrently) from 8.2.1 to 8.2.2.
- [Release notes](https://github.com/open-cli-tools/concurrently/releases)
- [Commits](https://github.com/open-cli-tools/concurrently/compare/v8.2.1...v8.2.2)

---
updated-dependencies:
- dependency-name: concurrently
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-02-26 15:12:33 +01:00
David Taylor 588a79c80c
DEV: Merge root JS packages (#25857)
Before this commit, we had a yarn package set up in the root directory and also in `app/assets/javascripts`. That meant two `yarn install` calls and two `node_modules` directories. This commit merges them both into the root location, and updates references to node_modules.

A previous attempt can be found at https://github.com/discourse/discourse/pull/21172. This commit re-uses that script to merge the `yarn.lock` files.

Co-authored-by: Jarek Radosz <jradosz@gmail.com>
2024-02-26 13:45:58 +00:00
Jarek Radosz 57c4b6bd50
DEV: Update js linting setup (#25365) 2024-01-24 15:30:03 +01:00
David Taylor 451581d50a
DEV: Remove unmaintained tidy-jsdoc dependency (#25110)
This was used by chat's HTML documentation experiment. That documentation experiment isn't being actively used/updated, but may be revisited in future. Therefore, this commit updates the jsdoc config to remove the custom theme, but keeps it functional (with the default jsdoc theme).
2024-01-03 10:30:54 +00:00
David Taylor 0878dde213
DEV: Modernise highlightjs loading (#24197)
- Remove vendored copy
- Update Rails implementation to look for language definitions in node_modules
- Use webpack-based dynamic import for hljs core
- Use browser-native dynamic import for site-specific language bundle (and fallback to webpack-based dynamic import in tests)
- Simplify markdown implementation to allow all languages into the `lang-{blah}` className
- Now that all languages are passed through, resolve aliases at runtime to avoid the need for the pre-built `highlightjs-aliases` index
2023-11-10 20:39:48 +00:00
Jarek Radosz c84fe69e10
DEV: Use `@discourse/lint-configs` (#24038) 2023-10-23 12:08:35 +02:00
Godfrey Chan c34f8b65cb
DEV: Rename I18n imports to discourse-i18n (#23915)
As of #23867 this is now a real package, so updating the imports to
use the real package name, rather than relying on the alias. The
name change in the package name is because `I18n` is not a valid
name as NPM packages must be all lowercase.

This commit also introduces an eslint rule to prevent importing from
the old I18n path.

For themes/plugins, the old 'i18n' name remains functional.
2023-10-18 11:07:09 +01:00
David Taylor 48193767bf DEV: Sort imports
Automatically generated by `eslint --fix` to satisfy the updated configuration
2023-10-10 21:46:54 +01:00
David Taylor 31e4191a9b DEV: Update eslint-config-discourse 2023-10-10 21:46:54 +01:00
Bianca Nenciu e3d3e34e57
DEV: Update to diffHTML 1.0.0-beta.30 (#23729) 2023-10-03 10:15:17 +03:00
Jarek Radosz 19567daeb9
DEV: Update linting setup (#23434)
* Update eslint-config-discourse
* Update eslint-plugin-ember
* Update ember-template-lint
* Update concurrently
* Update glint
* Dedup + yarn 
* Whitespace fix
2023-09-06 14:23:06 +02:00
David Taylor 887772db6b
DEV: Auto `yarn install` root package in development (#23276)
We were already running `yarn install` for the app directory before booting ember-cli via `bin/ember-cli`. This commit extends that so that it also runs `yarn install` for the root of the repository. In the long-term we hope to combine these packages, but for now they are separate.

The post-install hook for the root package is also updated to pass through the `-s` flag. Previously, we only passed through the `--frozen-lockfile` flag.
2023-08-25 20:53:24 +01:00
Jarek Radosz 70f1cc5552
DEV: Use esbuild to make DiscourseJsProcessor (#23223)
Reverts e2705df and re-lands #23187 and #23219.

The issue was incorrect order of execution of Rails' `assets:precompile` task in our own precompilation stack.

Co-authored-by: David Taylor <david@taylorhq.com>
2023-08-24 16:36:22 +02:00
David Taylor e2705df0f4
Revert "DEV: Use esbuild to make DiscourseJsProcessor (#23187)" (#23221)
This reverts commit 4dfe25d062 and 4fdeb6281e. We are investigating an issue related to asset compilation and S3 assets
2023-08-24 13:25:44 +01:00
Jarek Radosz 4dfe25d062
DEV: Use esbuild to make DiscourseJsProcessor (#23187)
Co-authored-by: David Taylor <david@taylorhq.com>
2023-08-24 12:43:59 +02:00
Vinoth Kannan 9643151419
FIX: use the latest version of `puppeteer-core` package to fix `page.click` issue (#22989)
Previously, the `page.click` method randomly failed in some situations.
2023-08-16 10:36:45 +05:30
David Taylor b7e642d99d
DEV: Introduce decorator-position lint rule (#22937) 2023-08-04 12:26:06 +01:00
David Taylor eb94ec16da
DEV: introduce Ember `<template>` tag support (.gjs) (#22719)
The gjs/gts formats are a new pattern for authoring Ember components. This commit introduces support for these patterns to our build pipeline for core/plugins, and converts a handful of components to use the new format. It also introduces relevant updates to our linting config, and to our sample vscode configuration.

Co-authored-by: Godfrey Chan <godfreykfc@gmail.com>
Co-authored-by: Krystan HuffMenne <kmenne+github@gmail.com>
2023-07-20 21:01:12 +01:00
Jarek Radosz 5584fb1e3b
DEV: Clean up package.json files (#22349)
Motivation: aligning us with JS/Ember practices (runtime deps in `dependencies`, build/dev-time deps in `devDependencies`)

1. Move deps to devDeps where applicable (rule of thumb: it's a devDep unless it's required at runtime by the rails app or it's imported in the addon's code)
2. Remove unused dependencies and add missing ones (in addons)
3. Remove empty `repository` fields
4. Move `engines` and `ember` fields to the bottom
2023-06-30 13:01:45 +02:00
Jarek Radosz e8490a735b
DEV: Update sub-dependencies (#22325)
Achieved by running `yarn upgrade --latest` both yarn.lock directories, then reverting changes to package.json files and running `yarn` again.

I also de-duped yarn.lock files with `npx yarn-deduplicate && yarn`
2023-06-29 17:08:33 +02:00
Jarek Radosz d3facec7d0
DEV: Update `@json-editor/json-editor` (#22308)
Manually tried it out by editing a json_schema setting of a theme component
2023-06-27 23:01:58 +02:00
Jarek Radosz a318fb5be4
DEV: Update moment-timezone (#22284) 2023-06-27 02:09:13 +02:00
Jarek Radosz ba62d20f71
DEV: Update ember-template-lint (#22242) 2023-06-22 22:54:46 +02:00
Jarek Radosz 876ff17cc2
DEV: Update eslint/prettier (#22226) 2023-06-21 20:59:03 +02:00
David Taylor 9c926ce645
PERF: Improve workbox loading strategy (#22019)
Previously workbox JS was vendored into our git repository, and would be loaded from the `public/javascripts` directory with a 1 day cache lifetime. The main aim of this commit is to add 'cachebuster' to the workbox URL so that the cache lifetime can be increased.

- Remove vendored copies of workbox.
- Use ember-cli/broccoli to collect workbox files from node_modules into assets/workbox-{digest}
- Add assets to sprockets manifest so that they're collected from the ember-cli output directory (and uploaded to s3 when configured)

Some of the sprockets-related changes in this commit are not ideal, but we hope to remove sprockets in the not-too-distant future.
2023-06-09 11:14:11 +01:00
Isaac Janzen b0e640c086
DEV: Bump eslint-config version (#21325) 2023-05-02 09:17:52 -05:00
Jarek Radosz 43e0025141
Revert "DEV: Merge package.json files (#21172)" (#21182)
This reverts commit 49a1e1cd0e.

Is causing issues in prod-adjacent environments (Jenkins)
2023-04-20 14:57:40 +02:00
Jarek Radosz 49a1e1cd0e
DEV: Merge package.json files (#21172)
This means: a single yarn.lock and removing one of the package.json files
2023-04-20 12:46:12 +02:00
David Taylor a328153ec2
DEV: Enable patch-package in production and in `javascripts/discourse` (#21078)
When running `yarn install` in a yarn workspace, the lifecycle hooks in the root package.json are not triggered. https://github.com/yarnpkg/yarn/issues/5790

As a workaround, we can additionally run `patch-package` from the `javascripts/discourse/package.json` `postinstall` hook. `patch-package` is idempotent, so it doesn't matter if it is triggered multiple times.

Longer term we intend to move to pnpm, which has built-in patch support.
2023-04-12 13:15:53 +01:00
NullVoxPopuli bdaaac9c9f
DEV: Setup lint to the future (#20990)
## How does this work?

Any time a lint rule is added or changed, you can run `yarn lint:fix` to handle all the auto-fixable situations.
But not all lints are auto-fixable -- for those, lint-to-the-future has tooling to automatically ignore present violations.
An alias has been added for lint-to-the-future to ignore new violations, `yarn lttf:ignore`.
The command will add lint-ignore declarations throughout all the files with present violations, which should then be committed.

An excerpt from lint-to-the-future's [README](https://github.com/mansona/lint-to-the-future#lint-to-the-future-dashboard):

> The point of Lint to the Future is to allow you to progressively update your codebase using new lint rules without overwhelming you with the task. You can easily ignore lint rules using project-based ignores in your config files but that doesn't prevent you from making the same errors in new files.

> We chose to do the ignores on a file basis as it is a perfect balance and it means that the tracking/graphing aspects of Lint to the Future provide you with achievable goals, especially in large codebases.

## How do I view progress?

lint-to-the-future provides graphs of violations-over-time per lint rule in a dashboard format, so we can track how well we're doing at cleaning up the violations.

To view the dashboard locally, run `yarn lint-progress` and visit `http://localhost:8084` (or whatever the port it chose, as it will choose a new port if 8084 is preoccupied)

Also there is a `list` command which shows a JSON object of:
```ts
{
  [date: string]: { // yyyy-mm-dd
    [pluginName: string]: {
      [fileName: string]: string[]; // list of files with violations
    }
  }
}
```


```bash
yarn lint-to-the-future list --stdout
```

## What about lint-todo?

Lint todo is another system available for both eslint and ember-template-lint that _forces_ folks to "leave things better than they found them" by being transparent / line-specific ignoring of violations. 
It was decided that for _this_ project, it made more sense, and would be less disruptive to new contributors to have the ignore declarations explicitly defined in each file (whereas in lint-todo, they are hidden).
To effectively use lint-todo, a whole team needs to agree to the workflow, and in open source, we want "just anyway" to be able to contribute, and throwing surprises at them can deter contributions.
2023-04-06 17:25:01 +01:00
Martin Brennan 60ad836313
DEV: Chat service object initial implementation (#19814)
This is a combined work of Martin Brennan, Loïc Guitaut, and Joffrey Jaffeux.

---

This commit implements a base service object when working in chat. The documentation is available at https://discourse.github.io/discourse/chat/backend/Chat/Service.html

Generating documentation has been made as part of this commit with a bigger goal in mind of generally making it easier to dive into the chat project.

Working with services generally involves 3 parts:

- The service object itself, which is a series of steps where few of them are specialized (model, transaction, policy)

```ruby
class UpdateAge
  include Chat::Service::Base

  model :user, :fetch_user
  policy :can_see_user
  contract
  step :update_age

  class Contract
    attribute :age, :integer
  end

  def fetch_user(user_id:, **)
    User.find_by(id: user_id)
  end

  def can_see_user(guardian:, **)
    guardian.can_see_user(user)
  end

  def update_age(age:, **)
    user.update!(age: age)
  end
end
```

- The `with_service` controller helper, handling success and failure of the service within a service and making easy to return proper response to it from the controller

```ruby
def update
  with_service(UpdateAge) do
    on_success { render_serialized(result.user, BasicUserSerializer, root: "user") }
  end
end
```

- Rspec matchers and steps inspector, improving the dev experience while creating specs for a service

```ruby
RSpec.describe(UpdateAge) do
  subject(:result) do
    described_class.call(guardian: guardian, user_id: user.id, age: age)
  end

  fab!(:user) { Fabricate(:user) }
  fab!(:current_user) { Fabricate(:admin) }

  let(:guardian) { Guardian.new(current_user) }
  let(:age) { 1 }

   it { expect(user.reload.age).to eq(age) }
end
```

Note in case of unexpected failure in your spec, the output will give all the relevant information:

```
  1) UpdateAge when no channel_id is given is expected to fail to find a model named 'user'
     Failure/Error: it { is_expected.to fail_to_find_a_model(:user) }

       Expected model 'foo' (key: 'result.model.user') was not found in the result object.

       [1/4] [model] 'user' 
       [2/4] [policy] 'can_see_user'
       [3/4] [contract] 'default'
       [4/4] [step] 'update_age'

       /Users/joffreyjaffeux/Code/pr-discourse/plugins/chat/app/services/update_age.rb:32:in `fetch_user': missing keyword: :user_id (ArgumentError)
       	from /Users/joffreyjaffeux/Code/pr-discourse/plugins/chat/app/services/base.rb:202:in `instance_exec'
       	from /Users/joffreyjaffeux/Code/pr-discourse/plugins/chat/app/services/base.rb:202:in `call'
       	from /Users/joffreyjaffeux/Code/pr-discourse/plugins/chat/app/services/base.rb:219:in `call'
       	from /Users/joffreyjaffeux/Code/pr-discourse/plugins/chat/app/services/base.rb:417:in `block in run!'
       	from /Users/joffreyjaffeux/Code/pr-discourse/plugins/chat/app/services/base.rb:417:in `each'
       	from /Users/joffreyjaffeux/Code/pr-discourse/plugins/chat/app/services/base.rb:417:in `run!'
       	from /Users/joffreyjaffeux/Code/pr-discourse/plugins/chat/app/services/base.rb:411:in `run'
       	from <internal:kernel>:90:in `tap'
       	from /Users/joffreyjaffeux/Code/pr-discourse/plugins/chat/app/services/base.rb:302:in `call'
       	from /Users/joffreyjaffeux/Code/pr-discourse/plugins/chat/spec/services/update_age_spec.rb:15:in `block (3 levels) in <main>'
```
2023-02-13 13:09:57 +01:00