See the release notes for a list of changes and features.
# Steps to migration from v1.x
- Adjust the versions in all
package.jsonfiles from1to2for@app-config/mainand plugins. - Move any
app-config.{ext}files to.app-config.{ext} - In Node.js applications, call the asynchronous
loadConfigbefore accessing any config properties. - Find and variable substitutions (eg.
'$PORT'in a string) and surround it with$substitute. - Make sure to look out for any usage of internal APIs of app-config. TypeScript should catch these.
As stated above, your main file should look like this:
import config, { loadConfig } from '@app-config/main';
async function main() {
await loadConfig();
// after loadConfig is resolved (not just called!), `config` is accessible
console.log(config);
}
This isn't a complete list, though it should cover most issues. You'll want to
test things out thoroughly before moving to v2 in production. One nice feature
is that you can install @app-config/main@2 globally on your system, and run
it with CWD of your project:
yarn global add @app-config/main@2
app-config vars -C ~/dev/my-project
This is a good way to verify that config and schema loading works. Check the values it outputs. Also check that your environment-specific variables are correct.
And of course, run your application in a variety of different configurations.