From 237c98a15d5e1510b2a6936c02b87e3e1649bf5d Mon Sep 17 00:00:00 2001 From: Rob Cameron Date: Fri, 23 Aug 2024 14:56:18 -0700 Subject: [PATCH 1/2] Adds docs for jobs setup and generate commands --- docs/docs/cli-commands.md | 65 ++++++++++++++++++++++++++++++++------- 1 file changed, 54 insertions(+), 11 deletions(-) diff --git a/docs/docs/cli-commands.md b/docs/docs/cli-commands.md index 35afdca162ad..0e99b25d6982 100644 --- a/docs/docs/cli-commands.md +++ b/docs/docs/cli-commands.md @@ -45,15 +45,15 @@ Create a Redwood project using the yarn create command: yarn create redwood-app [option] ``` -| Arguments & Options | Description | -| :--------------------- | :---------------------------------------------------------------------------------------------------------------------- | -| `project directory` | Specify the project directory [Required] | -| `--yarn-install` | Enables the yarn install step and version-requirement checks. You can pass `--no-yarn-install` to disable this behavior | -| `--typescript`, `--ts` | Generate a TypeScript project. JavaScript by default | -| `--overwrite` | Create the project even if the specified project directory isn't empty | -| `--no-telemetry` | Disable sending telemetry events for this create command and all Redwood CLI commands: https://telemetry.redwoodjs.com | -| `--yarn1` | Use yarn 1 instead of yarn 3 | -| `--git-init`, `--git` | Initialize a git repo during the install process, disabled by default | +| Arguments & Options | Description | +| :--------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `project directory` | Specify the project directory [Required] | +| `--yarn-install` | Enables the yarn install step and version-requirement checks. You can pass `--no-yarn-install` to disable this behavior | +| `--typescript`, `--ts` | Generate a TypeScript project. JavaScript by default | +| `--overwrite` | Create the project even if the specified project directory isn't empty | +| `--no-telemetry` | Disable sending telemetry events for this create command and all Redwood CLI commands: [https://telemetry.redwoodjs.com](https://telemetry.redwoodjs.com) | +| `--yarn1` | Use yarn 1 instead of yarn 3 | +| `--git-init`, `--git` | Initialize a git repo during the install process, disabled by default | If you run into trouble during the yarn install step, which may happen if you're developing on an external drive and in other miscellaneous scenarios, try the `--yarn1` flag: @@ -248,7 +248,7 @@ yarn redwood deploy | Commands | Description | | :---------------------------- | :--------------------------------------- | -| `serverless ` | Deploy to AWS using Serverless framework | +| `serverless` | Deploy to AWS using Serverless framework | | `netlify [...commands]` | Build command for Netlify deploy | | `render [...commands]` | Build command for Render deploy | | `vercel [...commands]` | Build command for Vercel deploy | @@ -436,7 +436,8 @@ Some generators require that their argument be a model in your `schema.prisma`. | `dataMigration ` | Generate a data migration component | | `dbAuth` | Generate sign in, sign up and password reset pages for dbAuth | | `deploy ` | Generate a deployment configuration | -| `function ` | Generate a Function | +| `function ` | Generate a Job | +| `job ` | Generate a background job | | `layout ` | Generate a layout component | | `page [path]` | Generate a page component | | `scaffold ` | Generate Pages, SDL, and Services files based on a given DB schema Model. Also accepts `` | @@ -735,6 +736,35 @@ $ /redwood-app/node_modules/.bin/dev-server 17:21:49 api | ► http://localhost:8911/user/ ``` +### generate job + +Generate a background job file (and optional tests) in `api/src/jobs`. + +```bash +yarn redwood generate job +``` + +| Arguments & Options | Description | +| -------------------- | ------------------------------------------------------------------------------------- | +| `name` | Name of the job ("Job" suffix is optional) | +| `--force, -f` | Overwrite existing files | +| `--typescript, --ts` | Generate TypeScript files. Enabled by default if we detect your project is TypeScript | +| `--tests` | Generate test files [default: true] | + +#### Example + +```bash +yarn redwood generate job WelcomeEmail +# or +yarn rw g job WelcomeEmail +``` + +:::info Job naming +By convention a job filename and exported code ends in `Job` and the generate command enforces this. If you don't include "Job" at the end of the name, the generator will add it. For example, with the above command, the file generated would be `api/src/jobs/WelcomeEmailJob/WelcomeEmailJob.{js|ts}`. +::: + +Learn more about jobs in the [Background Jobs docs](background-jobs). + ### generate layout Generate a layout component. @@ -1755,6 +1785,7 @@ yarn redwood setup | `deploy` | Set up a deployment configuration for a provider | | `generator` | Copy default Redwood generator templates locally for customization | | `i18n` | Set up i18n | +| `jobs` | Set up background job creation and processing | | `package` | Peform setup actions by running a third-party npm package | | `tsconfig` | Add relevant tsconfig so you can start using TypeScript | | `ui` | Set up a UI design or style library | @@ -1896,6 +1927,18 @@ In order to use [Netlify Dev](https://www.netlify.com/products/dev/) you need to > Note: To detect the RedwoodJS framework, please use netlify-cli v3.34.0 or greater. +### setup jobs + +This command adds the necessary packages and files defining the configuration for Redwood's [Background Jobs](background-jobs) processing. + +``` +yarn redwood setup jobs +``` + +| Arguments & Options | Description | +| :------------------ | :----------------------- | +| `--force, -f` | Overwrite existing files | + ### setup mailer This command adds the necessary packages and files to get started using the RedwoodJS mailer. By default it also creates an example mail template which can be skipped with the `--skip-examples` flag. From d5599a18ead5c4b018bc195945080efa7fe00f45 Mon Sep 17 00:00:00 2001 From: Rob Cameron Date: Fri, 23 Aug 2024 15:18:56 -0700 Subject: [PATCH 2/2] Whoops, text wrap --- docs/docs/cli-commands.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/docs/cli-commands.md b/docs/docs/cli-commands.md index 0e99b25d6982..c7b608d277dd 100644 --- a/docs/docs/cli-commands.md +++ b/docs/docs/cli-commands.md @@ -436,7 +436,7 @@ Some generators require that their argument be a model in your `schema.prisma`. | `dataMigration ` | Generate a data migration component | | `dbAuth` | Generate sign in, sign up and password reset pages for dbAuth | | `deploy ` | Generate a deployment configuration | -| `function ` | Generate a Job | +| `function ` | Generate a Function | | `job ` | Generate a background job | | `layout ` | Generate a layout component | | `page [path]` | Generate a page component |