Skip to content

Commit daf5ce2

Browse files
committed
add dotenv documentation
1 parent 4d537f2 commit daf5ce2

File tree

2 files changed

+101
-75
lines changed

2 files changed

+101
-75
lines changed

packages/content/README.md

Lines changed: 43 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -45,54 +45,55 @@ Currently supported sources are:
4545

4646
Some content sources require credentials to access their APIs.
4747

48-
These can all be stored in a local `.credentials.json` file which maps content-source IDs to their credentials. For example:
48+
These can all be stored in a `.env` or `.env.local` file which will be automatically loaded by launchpad.
4949

50-
### `.credentials.json`
50+
### `.env.local`
5151

52-
```json
53-
{
54-
"airtable-cms": {
55-
"apiKey": "<YOUR_AIRTABLE_API_KEY>"
56-
},
57-
"contentful-cms": {
58-
"previewToken": "<YOUR_CONTENTFUL_PREVIEW_TOKEN>",
59-
"deliveryToken": "<YOUR_CONTENTFUL_DELIVERY_TOKEN>",
60-
"usePreviewApi": false
61-
},
62-
"sanity-cms": {
63-
"apiToken": "<YOUR_API_TOKEN>"
64-
},
65-
"strapi-cms": {
66-
"identifier": "<YOUR_API_USER>",
67-
"password": "<YOUR_API_PASS>"
68-
}
69-
}
52+
```sh
53+
AIRTABLE_API_KEY=<YOUR_AIRTABLE_API_KEY>
54+
55+
CONTENTFUL_PREVIEW_TOKEN=<YOUR_CONTENTFUL_PREVIEW_TOKEN>
56+
CONTENTFUL_DELIVERY_TOKEN=<YOUR_CONTENTFUL_DELIVERY_TOKEN>
57+
CONTENTFUL_USE_PREVIEW_API=false
58+
59+
SANITY_API_TOKEN=<YOUR_API_TOKEN>
60+
61+
STRAPI_IDENTIFIER=<YOUR_API_USER>
62+
STRAPI_PASSWORD=<YOUR_API_PASS>
7063
```
7164

72-
### `launchpad.json`
65+
### `launchpad.config.js`
7366

7467
```js
75-
{
76-
"content": {
77-
"sources": [{
78-
"id": "airtable-cms",
79-
"type": "airtable",
80-
//...
81-
}, {
82-
"id": "contentful-cms",
83-
"type": "contentful",
84-
//...
85-
}, {
86-
"id": "sanity-cms",
87-
"type": "sanity",
88-
//...
89-
}, {
90-
"id": "strapi-cms",
91-
"type": "strapi",
92-
//...
93-
}]
94-
}
95-
}
68+
export default defineConfig({
69+
content: {
70+
sources: [
71+
{
72+
id: "airtable-cms",
73+
type: "airtable",
74+
apiKey: process.env.AIRTABLE_API_KEY,
75+
},
76+
{
77+
id: "contentful-cms",
78+
type: "contentful",
79+
previewToken: process.env.CONTENTFUL_PREVIEW_TOKEN,
80+
deliveryToken: process.env.CONTENTFUL_DELIVERY_TOKEN,
81+
usePreviewApi: false,
82+
},
83+
{
84+
id: "sanity-cms",
85+
type: "sanity",
86+
apiToken: process.env.SANITY_API_TOKEN,
87+
},
88+
{
89+
id: "strapi-cms",
90+
type: "strapi",
91+
identifier: process.env.STRAPI_IDENTIFIER,
92+
},
93+
],
94+
},
95+
});
96+
9697
```
9798

9899
## Post Processing

packages/launchpad/README.md

Lines changed: 58 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ Launchpad is a highly configurable suite of tools to manage media installations.
1212
%%{ init: { 'flowchart': { 'curve': 'bumpX' } } }%%
1313
graph LR
1414
Launchpad:::package
15-
15+
1616
Launchpad --> Scaffold:::package -.-> PCs([PCs])
1717
Launchpad --> Content:::package -.-> APIs([APIs])
1818
Launchpad --> Monitor:::package -.-> Apps([Apps])
19-
19+
2020
APIs -.-> Cache[(Cache)]
2121
Apps -.-> Cache
2222
@@ -32,14 +32,14 @@ graph LR
3232

3333
1. Install launchpad: `npm i @bluecadet/launchpad`
3434
2. Create a `launchpad.config.js` config (see [configuration](#configuration))
35-
3. *Optional: [Bootstrap](/packages/scaffold) your PC with `npx launchpad scaffold`*
35+
3. _Optional: [Bootstrap](/packages/scaffold) your PC with `npx launchpad scaffold`_
3636
4. Run `npx launchpad`
3737

3838
![Screen Recording of Launchpad on Windows 11](https://user-images.githubusercontent.com/295789/197365153-d62d9218-2ffa-4611-ac61-fa5bf786766a.gif)
3939

4040
Run `npx launchpad --help` to see all available commands.
4141

42-
*Note: Launchpad is typically triggered run by a startup task (e.g. Windows Task Scheduler) using `npx launchpad`. When installed globally (`npm i -g @bluecadet/launchpad`), you can use the `launchpad` command instead. See [config loading](#config-loading) for more info.*
42+
_Note: Launchpad is typically triggered run by a startup task (e.g. Windows Task Scheduler) using `npx launchpad`. When installed globally (`npm i -g @bluecadet/launchpad`), you can use the `launchpad` command instead. See [config loading](#config-loading) for more info._
4343

4444
## Configuration
4545

@@ -49,32 +49,34 @@ Each [launchpad package](#packages) is configured via its own section in `launch
4949
import { defineConfig } from "@bluecadet/launchpad";
5050

5151
export default defineConfig({
52-
"content": {
53-
"sources": [
54-
{
55-
"id": "flickr-images",
56-
"files": {
57-
"spaceships.json": "https://api.flickr.com/services/feeds/photos_public.gne?format=json&nojsoncallback=1&tags=spaceship",
58-
"rockets.json": "https://api.flickr.com/services/feeds/photos_public.gne?format=json&nojsoncallback=1&tags=rocket"
59-
}
60-
}
61-
]
62-
},
63-
"monitor": {
64-
"apps": [
65-
{
66-
"pm2": {
67-
"name": "my-app",
68-
"script": "my-app.exe",
69-
"cwd": "./builds/"
70-
}
71-
}
72-
]
73-
}
52+
content: {
53+
sources: [
54+
{
55+
id: "flickr-images",
56+
files: {
57+
"spaceships.json":
58+
"https://api.flickr.com/services/feeds/photos_public.gne?format=json&nojsoncallback=1&tags=spaceship",
59+
"rockets.json":
60+
"https://api.flickr.com/services/feeds/photos_public.gne?format=json&nojsoncallback=1&tags=rocket",
61+
},
62+
},
63+
],
64+
},
65+
monitor: {
66+
apps: [
67+
{
68+
pm2: {
69+
name: "my-app",
70+
script: "my-app.exe",
71+
cwd: "./builds/",
72+
},
73+
},
74+
],
75+
},
7476
});
7577
```
7678

77-
*Note: [Scaffold](/packages/scaffold) is configured separately in a PowerShell file. This is a guided process when you run `npx launchpad scaffold`.*
79+
_Note: [Scaffold](/packages/scaffold) is configured separately in a PowerShell file. This is a guided process when you run `npx launchpad scaffold`._
7880

7981
### Documentation
8082

@@ -94,19 +96,42 @@ All available config settings across packages can be found in the links below:
9496
### Config Loading
9597

9698
- By default, Launchpad looks for `launchpad.config.js`, `launchpad.config.mjs`, `launchpad.json` or `config.json` at the cwd (where you ran `npx launchpad`/`launchpad` from)
97-
- You can change the default path with `--config=<YOUR_FILE_PATH>` (e.g. `npx launchpad --config=../settings/my-config.json`)
99+
- You can change the default path with `--config=<YOUR_FILE_PATH>` or `-c=<YOUR_FILE_PATH>` (e.g. `npx launchpad --config=../settings/my-config.json`)
98100
- If no config is found, Launchpad will traverse up directories (up to 64) to find one
99101
- All config values can be overridden via `--foo=bar` (e.g. `--logging.level=debug`)
100102

103+
### `.env` Files
104+
105+
Launchpad uses [dotenv](https://github.com/motdotla/dotenv) to load in environment variables from `.env` and `.env.local` files located in the same directory as your config file.
106+
107+
Environment variables are loaded before the config file is parsed, so you can use them in your config file. For example, you can use `process.env.MY_ENV_VAR` in your config file to access the value of `MY_ENV_VAR` in your `.env` file.
108+
109+
> [!WARNING]
110+
> We recommend using `.env.local` for sensitive credentials that should not be committed to source control. You should add `*.local` to your `.gitignore` to avoid them being checked into git.
111+
112+
All Launchpad CLI commands also accept `--env <ENV_FILE_PATH(S)>` (alias `-e`) options to manually specify one or more `.env` files to load. These paths are relative to the CWD (where you ran `npx launchpad`/`launchpad` from).
113+
114+
```sh
115+
# Load ../.env then ../.env.develop
116+
npx launchpad -e ../.env -e ../.env.develop
117+
```
118+
119+
Additionally, the `--cascade-env=<ENV_NAME>` (alias `-E`) option which will load the following files located alongside your config file:
120+
121+
- `.env`
122+
- `.env.local`
123+
- `.env.<ENV_NAME>`
124+
- `.env.<ENV_NAME>.local`
125+
101126
## Packages
102127

103128
This repo is a monorepo that includes the following packages:
104129

105-
* [`@bluecadet/launchpad`](/packages/launchpad)
106-
* [`@bluecadet/launchpad-content`](/packages/content)
107-
* [`@bluecadet/launchpad-monitor`](/packages/monitor)
108-
* [`@bluecadet/launchpad-scaffold`](/packages/scaffold)
109-
* [`@bluecadet/launchpad-utils`](/packages/utils)
130+
- [`@bluecadet/launchpad`](/packages/launchpad)
131+
- [`@bluecadet/launchpad-content`](/packages/content)
132+
- [`@bluecadet/launchpad-monitor`](/packages/monitor)
133+
- [`@bluecadet/launchpad-scaffold`](/packages/scaffold)
134+
- [`@bluecadet/launchpad-utils`](/packages/utils)
110135

111136
Each of these packages can be launched and configured independently (except for utils), so if you only need app-monitoring or content updates, you can install only `@bluecadet/launchpad-monitor` or `@bluecadet/launchpad-content`.
112137

0 commit comments

Comments
 (0)