adapt-authoring-core 2.5.0 → 3.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/releases.yml +9 -24
- package/conf/config.schema.json +16 -0
- package/conf/deprecated-lang.json +4 -0
- package/conf/deprecated-logger.json +7 -0
- package/docs/configure-environment.md +78 -0
- package/docs/developer-workflow.md +649 -0
- package/docs/error-handling.md +49 -0
- package/docs/plugins/configuration.js +75 -0
- package/docs/plugins/configuration.md +14 -0
- package/docs/plugins/errors.js +22 -0
- package/docs/plugins/errorsref.md +9 -0
- package/errors/errors.json +87 -0
- package/errors/node-core.json +39 -0
- package/index.js +5 -0
- package/lib/AbstractModule.js +3 -13
- package/lib/AdaptError.js +57 -0
- package/lib/App.js +66 -51
- package/lib/Config.js +226 -0
- package/lib/DataCache.js +6 -0
- package/lib/DependencyLoader.js +46 -103
- package/lib/Errors.js +50 -0
- package/lib/Hook.js +2 -3
- package/lib/Lang.js +126 -0
- package/lib/Logger.js +149 -0
- package/lib/utils/getArgs.js +4 -6
- package/migrations/3.0.0-conf-migrate-lang-config.js +7 -0
- package/migrations/3.0.0-conf-migrate-logger-config.js +9 -0
- package/package.json +8 -25
- package/tests/AbstractModule.spec.js +4 -54
- package/tests/AdaptError.spec.js +62 -0
- package/tests/Config.spec.js +122 -0
- package/tests/DataCache.spec.js +84 -1
- package/tests/DependencyLoader.spec.js +61 -146
- package/tests/Errors.spec.js +91 -0
- package/tests/Lang.spec.js +116 -0
- package/tests/Logger.spec.js +187 -0
- package/tests/utils-getArgs.spec.js +2 -8
- package/tests/App.spec.js +0 -160
|
@@ -1,32 +1,17 @@
|
|
|
1
1
|
name: Release
|
|
2
|
+
|
|
2
3
|
on:
|
|
3
4
|
push:
|
|
4
5
|
branches:
|
|
5
6
|
- master
|
|
6
7
|
|
|
8
|
+
permissions:
|
|
9
|
+
contents: write
|
|
10
|
+
issues: write
|
|
11
|
+
pull-requests: write
|
|
12
|
+
id-token: write
|
|
13
|
+
packages: write
|
|
14
|
+
|
|
7
15
|
jobs:
|
|
8
16
|
release:
|
|
9
|
-
|
|
10
|
-
runs-on: ubuntu-latest
|
|
11
|
-
permissions:
|
|
12
|
-
contents: write # to be able to publish a GitHub release
|
|
13
|
-
issues: write # to be able to comment on released issues
|
|
14
|
-
pull-requests: write # to be able to comment on released pull requests
|
|
15
|
-
id-token: write # to enable use of OIDC for trusted publishing and npm provenance
|
|
16
|
-
steps:
|
|
17
|
-
- name: Checkout
|
|
18
|
-
uses: actions/checkout@v3
|
|
19
|
-
with:
|
|
20
|
-
fetch-depth: 0
|
|
21
|
-
- name: Setup Node.js
|
|
22
|
-
uses: actions/setup-node@v3
|
|
23
|
-
with:
|
|
24
|
-
node-version: 'lts/*'
|
|
25
|
-
- name: Update npm
|
|
26
|
-
run: npm install -g npm@latest
|
|
27
|
-
- name: Install dependencies
|
|
28
|
-
run: npm install
|
|
29
|
-
- name: Release
|
|
30
|
-
env:
|
|
31
|
-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
32
|
-
run: npx semantic-release
|
|
17
|
+
uses: adaptlearning/semantic-release-config/.github/workflows/release.yml@master
|
package/conf/config.schema.json
CHANGED
|
@@ -24,6 +24,22 @@
|
|
|
24
24
|
"type": "string",
|
|
25
25
|
"isDirectory": true,
|
|
26
26
|
"default": "$ROOT/APP_DATA/temp"
|
|
27
|
+
},
|
|
28
|
+
"logLevels": {
|
|
29
|
+
"description": "Configures which log levels should be shown. Entries can target four granularities, with more-specific rules winning over less-specific. Global level: 'debug', '!debug'. Per-level module override: 'debug.core', '!debug.core'. Id-wide override (applies at every level): 'core', '!core'. Line-level override (matches when args[0] is the named short id): 'debug.core.LOAD', '!debug.core.LOAD'. Set to an empty array to mute all logging.",
|
|
30
|
+
"type": "array",
|
|
31
|
+
"items": { "type": "string" },
|
|
32
|
+
"default": ["error", "warn", "success", "info", "debug", "verbose"]
|
|
33
|
+
},
|
|
34
|
+
"showLogTimestamp": {
|
|
35
|
+
"description": "Whether to prepend a timestamp to each log message",
|
|
36
|
+
"type": "boolean",
|
|
37
|
+
"default": true
|
|
38
|
+
},
|
|
39
|
+
"defaultLang": {
|
|
40
|
+
"description": "The default language used by the server",
|
|
41
|
+
"type": "string",
|
|
42
|
+
"default": "en"
|
|
27
43
|
}
|
|
28
44
|
}
|
|
29
45
|
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# Configuring your environment
|
|
2
|
+
> For a list of all supported configuration options, see [this page](configuration).
|
|
3
|
+
|
|
4
|
+
The authoring tool has been built to allow for multiple configurations for different system environments (e.g. testing, production, development).
|
|
5
|
+
|
|
6
|
+
## Set up your environment
|
|
7
|
+
|
|
8
|
+
To configure your tool for a specific environment, you must create a config file in `/conf` named according to the env value your system will be using (e.g. `dev.config.js`, `production.config.js`, `helloworld.config.js`). We recommend sticking to something short like `dev`, or `test`, but it's up to you what you name these; just make sure to set the environment variable to the same.
|
|
9
|
+
|
|
10
|
+
> The `NODE_ENV` environment variable is used to determine the current environment, so make sure that this is set appropriately when running the application:
|
|
11
|
+
|
|
12
|
+
Express.js has a number of [performance enhancing features](https://expressjs.com/en/advanced/best-practice-performance.html#set-node_env-to-production) which are only enabled when the NODE_ENV is set to `production`, so we strongly recommend you use this for your production env name.
|
|
13
|
+
|
|
14
|
+
### Creating your config
|
|
15
|
+
|
|
16
|
+
Each config file is a JavaScript file which exports a single object. Within this file, settings are grouped by module:
|
|
17
|
+
|
|
18
|
+
```Javascript
|
|
19
|
+
export default {
|
|
20
|
+
'modulename': {
|
|
21
|
+
// settings
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
See [this page](configuration) for a complete list of all configuration options.
|
|
27
|
+
|
|
28
|
+
####
|
|
29
|
+
For convenience, we've bundled a script which will generate a new config file for you automatically.
|
|
30
|
+
|
|
31
|
+
You can do this by running the following:
|
|
32
|
+
```bash
|
|
33
|
+
npx at-confgen [NODE_ENV]
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
> If you choose to include the default settings in your configuration, please be aware that once set, these values will not be updated if the defaults change in the future. It is advised therefore that you leave out any settings that you don't wish to change.
|
|
37
|
+
|
|
38
|
+
See the [Bin scripts](binscripts#at-confgen) page for more information, included supported flags.
|
|
39
|
+
|
|
40
|
+
### Setting your 'env'
|
|
41
|
+
|
|
42
|
+
You can do this temporarily using the following:
|
|
43
|
+
|
|
44
|
+
**Bash/Mac OS Terminal**:
|
|
45
|
+
```bash
|
|
46
|
+
$ NODE_ENV=dev npm start
|
|
47
|
+
```
|
|
48
|
+
**Windows Powershell/Command Prompt**:
|
|
49
|
+
```bash
|
|
50
|
+
> set NODE_ENV=dev | npm start
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Please see the documentation for your own operating system for instructions on how to save environment variables in a more permanent way.
|
|
54
|
+
|
|
55
|
+
## Using environment variables for configuration
|
|
56
|
+
|
|
57
|
+
As an alternative to config files, any configuration option can be set via an environment variable using the following naming convention:
|
|
58
|
+
|
|
59
|
+
```
|
|
60
|
+
ADAPT_AUTHORING_<MODULE>__<property>
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
- The module name is converted to uppercase with underscores replacing hyphens (e.g. `adapt-authoring-server` becomes `ADAPT_AUTHORING_SERVER`)
|
|
64
|
+
- A double underscore (`__`) separates the module name from the property name
|
|
65
|
+
- The property name is kept in its original camelCase format
|
|
66
|
+
|
|
67
|
+
For example:
|
|
68
|
+
|
|
69
|
+
| Environment variable | Config equivalent |
|
|
70
|
+
| --- | --- |
|
|
71
|
+
| `ADAPT_AUTHORING_SERVER__host` | `adapt-authoring-server.host` |
|
|
72
|
+
| `ADAPT_AUTHORING_SERVER__port` | `adapt-authoring-server.port` |
|
|
73
|
+
| `ADAPT_AUTHORING_MONGODB__connectionUri` | `adapt-authoring-mongodb.connectionUri` |
|
|
74
|
+
| `ADAPT_AUTHORING_AUTH_LOCAL__saltRounds` | `adapt-authoring-auth-local.saltRounds` |
|
|
75
|
+
|
|
76
|
+
Values are parsed as JSON where possible, so non-string types like numbers and booleans can be set directly (e.g. `ADAPT_AUTHORING_SERVER__port=5678`).
|
|
77
|
+
|
|
78
|
+
Any environment variables that do not start with `ADAPT_AUTHORING_` are available under the `env` namespace (e.g. `NODE_ENV` becomes `env.NODE_ENV`).
|