-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add index resolution for modules, resources and segments #590
Changes from 12 commits
58a4dc9
ad5a900
34c5e3b
7a682a0
b2d1d94
175a2c8
0f655e4
f26ca29
ba75dc2
4724363
5b58639
699153a
bf5412c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,52 @@ | ||||||
--- | ||||||
layout: doc | ||||||
|
||||||
prev: | ||||||
text: Build settings | ||||||
link: /build/settings | ||||||
|
||||||
next: | ||||||
text: Segmentation | ||||||
link: /deploy/segmentation | ||||||
|
||||||
--- | ||||||
|
||||||
# Configuration | ||||||
|
||||||
The jitar build process is configured using a `jitar.json` file. This file is optional and defines the location of the `source`, `target`, `segments`, and `resources` folders. These values are used to split the application in separate deployable bundles and create the necessary configuration files for the jitar runtime. | ||||||
|
||||||
## Jitar configuration file | ||||||
|
||||||
The `jitar.json` file is a JSON file that contains the following properties: | ||||||
|
||||||
```json | ||||||
{ | ||||||
"source": "./src", | ||||||
"target": "./dist", | ||||||
"segments": "./segments", | ||||||
"resources": "./resources" | ||||||
} | ||||||
``` | ||||||
|
||||||
There are four properties in the configuration file: | ||||||
* `source` - the location of the source files (default `./src`). | ||||||
* `target` - the location of the target files (default `./dist`). | ||||||
* `segments` - the location of the segment configuration files (default `./segments`). | ||||||
* `resources` - the location of the resource files (default `./resources`). | ||||||
|
||||||
::: tip NOTE | ||||||
For a TypeScript project, the `source` folder should be the target folder after transpilation, so it should be `./dist` instead of `./src`. The `target` folder can be the same as the `source` folder in this case, but it can also be a different folder. | ||||||
::: | ||||||
|
||||||
::: tip NOTE | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
The build process deletes the files in the `target` folder during the build process. Make sure that it doesn't point to the `src` folder. | ||||||
::: | ||||||
|
||||||
::: tip NOTE | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This note contains general configuration information, so doesn't have to be a not in my opinion. Should we move the text up and place it above the first note? This also avoids a stack of notes. |
||||||
The configuration also supports environment variables. They can be used by wrapping the variable name in `${}`. For example, `${source}`. | ||||||
```json | ||||||
{ | ||||||
"source": "${source}" | ||||||
} | ||||||
``` | ||||||
::: |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
--- | ||
layout: doc | ||
|
||
prev: | ||
text: Debugging | ||
link: /develop/debugging | ||
|
||
next: | ||
text: Build configuration | ||
link: /build/configuration | ||
|
||
--- | ||
|
||
# Settings | ||
|
||
The build process accepts a few command line arguments to configure its build behavior. A fully configured command line looks like this: | ||
|
||
```bash | ||
jitar build --env-file=.env --log-level=info --config=jitar.json | ||
``` | ||
|
||
## Environment file | ||
|
||
The `--env-file` argument can be used to specify a file that contains environment variables. This is an optional argument without a default value. | ||
|
||
## Log level | ||
|
||
To control the level of logging, the optional `--log-level` argument can be used. The default for this value is `info`. A more elaborate description of the log levels can be found in the [logging](../monitor/logging) section. | ||
|
||
## Configuration file | ||
|
||
To control the input and output of the build process. The `--config` argument can be used to specify a configuration file. This is an optional argument with the default value `jitar.json`. |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -19,12 +19,12 @@ In Jitar's [segmentation model](/deploy/segmentation), each segment is isolated | |||||
|
||||||
### Resource files | ||||||
|
||||||
Jitar will search for resource definitions files in the project directory. The files are named `*.resources.json`. Each entry defines the entry point of the `module` that should be used as a resource. | ||||||
Jitar will search for resource definitions files in the `resources` directory. The files are named `*.json`. Each entry defines the entry point of the `module` that should be used as a resource. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
The file has the following structure: | ||||||
|
||||||
```json | ||||||
// app.resources.json | ||||||
// app.json | ||||||
[ | ||||||
"./integrations/authentication/entry-file", | ||||||
"./integrations/database/index", | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,7 @@ At the root level of a project we use at least the following subfolders. | |
|
||
```txt | ||
. | ||
├─ resources | ||
├─ segments | ||
├─ services | ||
├─ src | ||
|
@@ -29,6 +30,7 @@ At the root level of a project we use at least the following subfolders. | |
|
||
Although the names are quite self explanatory, this how we use them: | ||
|
||
* resources - contains all resource configuration files; | ||
* segments - contains all segment configuration files; | ||
* services - contains all service configuration files; | ||
* src - contains all application code; | ||
|
@@ -54,11 +56,10 @@ src | |
│ ├─ downloads | ||
│ ├─ images | ||
│ ├─ ... | ||
├─ integrations | ||
│ ├─ database | ||
│ ├─ notifications | ||
│ ├─ ... | ||
└─ jitar.ts | ||
└─ integrations | ||
├─ database | ||
├─ notifications | ||
├─ ... | ||
``` | ||
|
||
Each folder has it's own responsibility: | ||
|
@@ -100,23 +101,22 @@ test | |
│ ├─ downloads | ||
│ ├─ images | ||
│ ├─ ... | ||
├─ integrations | ||
│ ├─ database | ||
│ ├─ notifications | ||
│ ├─ ... | ||
└─ jitar.ts | ||
└─ integrations | ||
├─ database | ||
├─ notifications | ||
├─ ... | ||
Comment on lines
+104
to
+107
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a part of our future-proof vision. Should we reflect it in the Jitar docs? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Created the following Issue so we can keep track of these items. |
||
``` | ||
|
||
By keeping a 1-on-1 relation with the source files makes it easy to find the associated tests. | ||
|
||
## Segments | ||
|
||
The `segments` folder contains all [segment configuration](../fundamentals/building-blocks#segments) files. Although Jitar doesn't care about their location, we find it more clear to group them here. | ||
The `segments` folder contains all [segment configuration](../fundamentals/building-blocks#segments) files. | ||
|
||
```txt | ||
segments | ||
├─ first.segment.json | ||
└─ second.segment.json | ||
├─ first.json | ||
└─ second.json | ||
``` | ||
|
||
Defining the right segments heavily depends on the application and how it is used. A single client / server application may suffice with a 'client' and 'server' segment. Other (larger) applications might benefit from segmentation by concept like 'account' or 'reporting'. | ||
|
@@ -125,7 +125,7 @@ We recommend defining the segments as late as possible, and only add them for re | |
|
||
## Services | ||
|
||
The `services` folder contains all [service configuration](../fundamentals/runtime-services) files. Just like the segments, Jitar doesn't care about their location, but we do. | ||
The `services` folder contains all [service configuration](../fundamentals/runtime-services) files. Jitar doesn't care about their location, but we do. | ||
|
||
```txt | ||
services | ||
|
@@ -140,3 +140,14 @@ services | |
The required services depend on the segmentation needs of the application. Applications that do not need any scaling or replication can suffice with a standalone service. Otherwise multiple services are needed to run the application. We always make sure the configuration name reflects its service type. | ||
|
||
We always add a standalone configuration, even if the application is deployed with multiple services. We use this configuration for developing the application to simplify the development setup. | ||
|
||
## Resources | ||
|
||
The `resources` folder contains all [resource configuration](../deploy/resources) files. | ||
|
||
```txt | ||
services | ||
└─ global.json | ||
``` | ||
|
||
Any resource that needs to be initialized in a startup or stopped in a teardown phase must be defined here. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -153,11 +153,11 @@ import { modify } from './modify'; | |
export async function test(): Promise<void> | ||
{ | ||
// create new instance | ||
const person: Person = new Person( 'John Doe', 42); | ||
const original = new Person( 'John Doe', 42); | ||
|
||
modify(person); | ||
const copy = await modify(original); | ||
|
||
console.log(person); | ||
console.log(copy); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How does logging the copy proves that the original hasn't been modified? |
||
} | ||
``` | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
{ | ||
"source": "./dist", | ||
"target": "./.jitar" | ||
"target": "./.jitar", | ||
"segments": "./segments", | ||
"resources": "./resources" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[ | ||
"./database" | ||
] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The term
settings
feels a bit weird in the context of providing arguments for the CLI parameters. Maybe something likearguments
,parameters
orflags
is a better fit?