Skip to content

Commit

Permalink
feat: update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
thetutlage committed Aug 22, 2023
1 parent c52185b commit 9470fd9
Show file tree
Hide file tree
Showing 15 changed files with 395 additions and 154 deletions.
8 changes: 4 additions & 4 deletions content/docs/ace/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ node ace list --ansi

## Creating command aliases

Command aliases provide a convenience layer to define aliases for commonly used commands. For example, if you often create singular resourceful controllers, you may create an alias for it inside the `.adonisrc.json` file.
Command aliases provide a convenience layer to define aliases for commonly used commands. For example, if you often create singular resourceful controllers, you may create an alias for it inside the `adonisrc.ts` file.

```json
```ts
{
"commandsAliases": {
"resource": "make:controller --resource --singular"
commandsAliases: {
resource: 'make:controller --resource --singular'
}
}
```
Expand Down
6 changes: 6 additions & 0 deletions content/docs/db.json
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,12 @@
"contentPath": "./http/exception_handling.md",
"category": "HTTP"
},
{
"permalink": "views-and-templates",
"title": "Views and Templates",
"contentPath": "./http/views_and_templates.md",
"category": "HTTP"
},
{
"permalink": "static-file-server",
"redirects": ["guides/static-assets"],
Expand Down
2 changes: 1 addition & 1 deletion content/docs/digging_deeper/scaffolding.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ node ace eject make/command

## make\:provider

Create a service provider. The provider will automatically be registered with the `.adonisrc.json` file.
Create a service provider. The provider will automatically be registered with the `adonisrc.ts` file.

- Form: `singular`
- Suffix: `provider`
Expand Down
193 changes: 97 additions & 96 deletions content/docs/fundamentals/adonisrc_file.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
# AdonisRC file

The `.adonisrc.json` file is used to configure the workspace settings of your application. In this file, you can [register providers](#providers), define [command aliases](#commandsaliases), specify the [files to copy](#metafiles) to the production build, and much more.
The `adonisrc.ts` file is used to configure the workspace settings of your application. In this file, you can [register providers](#providers), define [command aliases](#commandsaliases), specify the [files to copy](#metafiles) to the production build, and much more.

:::warning

The `adonisrc.ts` file is imported by tools other than your AdonisJS application. Therefore, you must not write any application specific code or environment specific conditionals in this file.

:::

The file contains the minimum required configuration to run your application. However, you can view the complete file contents by running the `node ace inspect:rcfile` command.

Expand All @@ -24,30 +30,30 @@ The `typescript` property informs the framework and the Ace commands that your a

A set of directories and their paths used by the [scaffolding commands](../digging_deeper/scaffolding.md). If you decide to rename specific directories, update their new path inside the `directories` object to notify scaffolding commands.

```json
```ts
{
"directories": {
"config": "config",
"commands": "commands",
"contracts": "contracts",
"public": "public",
"providers": "providers",
"languageFiles": "resources/lang",
"migrations": "database/migrations",
"seeders": "database/seeders",
"factories": "database/factories",
"views": "resources/views",
"start": "start",
"tmp": "tmp",
"tests": "tests",
"httpControllers": "app/controllers",
"models": "app/models",
"services": "app/services",
"exceptions": "app/exceptions",
"mailers": "app/mailers",
"middleware": "app/middleware",
"policies": "app/policies",
"validators": "app/validators"
directories: {
config: 'config',
commands: 'commands',
contracts: 'contracts',
public: 'public',
providers: 'providers',
languageFiles: 'resources/lang',
migrations: 'database/migrations',
seeders: 'database/seeders',
factories: 'database/factories',
views: 'resources/views',
start: 'start',
tmp: 'tmp',
tests: 'tests',
httpControllers: 'app/controllers',
models: 'app/models',
services: 'app/services',
exceptions: 'app/exceptions',
mailers: 'app/mailers',
middleware: 'app/middleware',
policies: 'app/policies',
validators: 'app/validators'
}
}
```
Expand All @@ -71,21 +77,23 @@ You can create and register a preload file using the `node ace make:preload` com
:::


```json
```ts
{
"preloads": ["./start/view.js"]
preloads: [
() => import('./start/view.js')
]
}
```

```json
```ts
{
"preloads": [
preloads: [
{
"file": "./start/routes.js",
"environment": [
"web",
"console",
"test"
file: () => import('./start/view.js'),
environment: [
'web',
'console',
'test'
]
},
]
Expand All @@ -101,32 +109,31 @@ These are non-TypeScript/JavaScript files that must exist in the production buil
- `pattern`: The [glob pattern](https://github.com/sindresorhus/globby#globbing-patterns) to find matching files.
- `reloadServer`: Reload the development server when matching files change.

```json
```ts
{
"metaFiles": [
metaFiles: [
{
"pattern": "public/**",
"reloadServer": false
pattern: 'public/**',
reloadServer: false
},
{
"pattern": "resources/views/**/*.edge",
"reloadServer": false
pattern: 'resources/views/**/*.edge',
reloadServer: false
}
]
}
```

## commands
An array of paths to import ace commands. You can define a relative path like `./commands/main.js` or a path to an installed package.
An array of functions to lazy import ace commands from installed packages. Your applications commands will be imported automatically and hence you do not have to register them explicitly.

See also: [Creating ace commands](../ace/creating_commands.md)

```json
```ts
{
"commands": [
"./commands/main.js",
"@adonisjs/core/commands",
"@adonisjs/lucid/commands"
commands: [
() => import('@adonisjs/core/commands'),
() => import('@adonisjs/lucid/commands')
]
}
```
Expand All @@ -136,21 +143,21 @@ A key-value pair of command aliases. This is usually to help you create memorabl

See also: [Creating command aliases](../ace/introduction.md#creating-command-aliases)

```json
```ts
{
"commandsAliases": {
"migrate": "migration:run"
commandsAliases: {
migrate: 'migration:run'
}
}
```

You can also define multiple aliases by adding multiple entries.
You can also define multiple aliases for the same command.

```json
```ts
{
"commandsAliases": {
"migrate": "migration:run",
"up": "migration:run"
commandsAliases: {
migrate: 'migration:run',
up: 'migration:run'
}
}
```
Expand All @@ -161,26 +168,24 @@ The `tests` object registers the test suites and some of the global settings for

See also: [Introduction to testing](../testing/introduction.md)

```json
```ts
{
"tests": {
"timeout": 2000,
"forceExit": false,
"suites": [
tests: {
timeout: 2000,
forceExit: false,
suites: [
{
"name": "functional",
"files": [
"tests/functional/**/*.spec.ts"
name: 'functional',
files: [
'tests/functional/**/*.spec.ts'
],
"timeout": 30000
timeout: 30000
}
]
}
}
```



- `timeout`: Define the default timeout for all the tests.
- `forceExit`: Forcefully exit the application process as soon as the tests are complete. Usually, it is good practice to perform a graceful exit.
- `suite.name`: A unique name for the test suite.
Expand All @@ -203,40 +208,36 @@ Providers are loaded in the same order as registered inside the `providers` arra

See also: [Service providers](../fundamentals/service_providers.md)

```json
```ts
{
"providers": [
"./providers/app_provider.js",
"@adonisjs/core/providers/app_provider",
"@adonisjs/core/providers/http_provider",
"@adonisjs/core/providers/hash_provider"
providers: [
() => import('@adonisjs/core/providers/app_provider'),
() => import('@adonisjs/core/providers/http_provider'),
() => import('@adonisjs/core/providers/hash_provider'),
() => import('./providers/app_provider.js'),
]
}
```

```json
```ts
{
"providers": [
providers: [
{
"file": "./providers/app_provider.js",
"environment": [
"web",
"console",
"test"
file: () => import('./providers/app_provider.js'),
environment: [
'web',
'console',
'test'
]
},
{
"file": "@adonisjs/core/providers/app_provider"
},
{
"file": "@adonisjs/core/providers/http_provider",
"environment": [
"web"
file: () => import('@adonisjs/core/providers/http_provider'),
environment: [
'web'
]
},
{
"file": "@adonisjs/core/providers/hash_provider"
}
() => import('@adonisjs/core/providers/hash_provider'),
() => import('@adonisjs/core/providers/app_provider')
]
}
```
Expand All @@ -247,19 +248,19 @@ The `serve` and `build` command attempts to detect the assets used by your appli

The detection is performed for [vite](https://vitejs.dev) by searching for the `vite.config.js` file and [Webpack encore](https://github.com/symfony/webpack-encore) by searching for the `webpack.config.js` file.

However, if you use a different assets bundler, you can configure it inside the `.adonisrc.json` file as follows.
However, if you use a different assets bundler, you can configure it inside the `adonisrc.ts` file as follows.

```json
```ts
{
"assetsBundler": {
"name": "vite",
"devServer": {
"command": "vite",
"args": []
assetsBundler: {
name: 'vite',
devServer: {
command: 'vite',
args: []
},
"build": {
"command": "vite",
"args": ["build"]
build: {
command: 'vite',
args: ["build"]
},
}
}
Expand Down
2 changes: 1 addition & 1 deletion content/docs/fundamentals/application.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ The state refers to the current state of the application. The framework features
The application is always in one of the following known states.

- `created`: It is the default state of the application.
- `initiated`: In this state, we parse/validate the environment variables and process the `.adonisrc.json` file.
- `initiated`: In this state, we parse/validate the environment variables and process the `adonisrc.ts` file.
- `booted`: The application service providers are registered and booted at this state.
- `ready`: The ready state varies between different environments. For example, in the `web` environment, the ready state means the application is ready to accept new HTTP requests.
- `terminated`: The application has been terminated, and the process will exit shortly. The application will not accept new HTTP requests in the `web` environment.
Expand Down
2 changes: 1 addition & 1 deletion content/docs/fundamentals/application_lifecycle.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ new Ignitor(APP_ROOT, { importer: IMPORTER })
})
```

- `initiating`: The hook actions are called before the application moves to the initiated state. The `.adonisrc.json` file is parsed after executing the `initiating` hooks.
- `initiating`: The hook actions are called before the application moves to the initiated state. The `adonisrc.ts` file is parsed after executing the `initiating` hooks.

- `booting`: The hook actions are called before booting the app. The config files are imported after executing `booting` hooks.

Expand Down
20 changes: 10 additions & 10 deletions content/docs/fundamentals/service_providers.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,26 @@ A service provider can register [bindings into the container](./ioc_container.md

Service providers are the entry point to an AdonisJS application with the ability to modify the application state before it is considered ready.

The providers are registered inside the `.adonisrc.json` file under the `providers` array. The value is a path to a module that can be resolved using the `import.meta.resolve` method.
The providers are registered inside the `adonisrc.ts` file under the `providers` array. The value is a function to lazily import the service provider

```json
```ts
{
"providers": [
"@adonisjs/core/providers/app_provider",
"./providers/app_provider.js"
providers: [
() => import('@adonisjs/core/providers/app_provider'),
() => import('./providers/app_provider.js'),
]
}
```

By default, a provider is loaded in all the runtime environments. However, you can limit the provider to run in specific environments.

```json
```ts
{
"providers": [
"@adonisjs/core/providers/app_provider",
providers: [
() => import('@adonisjs/core/providers/app_provider'),
{
"file": "./providers/app_provider.js",
"environments": ["web", "repl"]
file: import('./providers/app_provider.js'),
environments: ['web', 'repl']
}
]
}
Expand Down
Loading

0 comments on commit 9470fd9

Please sign in to comment.