run-with-heroku-env 0.1.3 → 0.2.0
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/.oxfmtrc.json +9 -0
- package/package.json +7 -4
- package/run-with-heroku-env.js +22 -10
- package/.github/workflows/test.yml +0 -25
- package/.prettierrc.json +0 -6
package/.oxfmtrc.json
ADDED
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "run-with-heroku-env",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "execute command with heroku env",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"test": "
|
|
8
|
-
"
|
|
7
|
+
"test": "oxfmt --check .",
|
|
8
|
+
"format": "oxfmt --write ."
|
|
9
9
|
},
|
|
10
10
|
"bin": {
|
|
11
11
|
"run-with-heroku-env": "run-with-heroku-env.js"
|
|
@@ -24,7 +24,10 @@
|
|
|
24
24
|
"url": "https://github.com/shokai/run-with-heroku-env/issues"
|
|
25
25
|
},
|
|
26
26
|
"homepage": "https://github.com/shokai/run-with-heroku-env#readme",
|
|
27
|
+
"publishConfig": {
|
|
28
|
+
"registry": "https://registry.npmjs.org/"
|
|
29
|
+
},
|
|
27
30
|
"devDependencies": {
|
|
28
|
-
"
|
|
31
|
+
"oxfmt": "^0.42.0"
|
|
29
32
|
}
|
|
30
33
|
}
|
package/run-with-heroku-env.js
CHANGED
|
@@ -1,22 +1,34 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
const pkg = require('./package.json');
|
|
4
|
-
const {
|
|
4
|
+
const { execFileSync, spawn } = require('child_process');
|
|
5
5
|
const parseArgv = require('./parse-argv');
|
|
6
6
|
|
|
7
7
|
function getHerokuEnvs({ envs, herokuOptions } = {}) {
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
.
|
|
8
|
+
const args = ['config', '--json'];
|
|
9
|
+
for (const key of Object.keys(herokuOptions)) {
|
|
10
|
+
args.push(`--${key}`);
|
|
11
|
+
if (herokuOptions[key] !== true) {
|
|
12
|
+
args.push(String(herokuOptions[key]));
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
console.error(`== getting ENV ${envs}: heroku ${args.join(' ')}`);
|
|
11
17
|
|
|
12
|
-
const
|
|
13
|
-
|
|
18
|
+
const result = execFileSync('heroku', args);
|
|
19
|
+
const output = result.toString();
|
|
20
|
+
let config;
|
|
21
|
+
try {
|
|
22
|
+
config = JSON.parse(output);
|
|
23
|
+
} catch (e) {
|
|
24
|
+
console.error(output);
|
|
25
|
+
process.exit(1);
|
|
26
|
+
}
|
|
14
27
|
|
|
15
28
|
const herokuEnvs = {};
|
|
16
|
-
for (
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
herokuEnvs[key] = value;
|
|
29
|
+
for (const key of envs) {
|
|
30
|
+
if (config[key] !== undefined) {
|
|
31
|
+
herokuEnvs[key] = config[key];
|
|
20
32
|
}
|
|
21
33
|
}
|
|
22
34
|
return herokuEnvs;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
name: app-test
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
push:
|
|
5
|
-
branches: ['main']
|
|
6
|
-
pull_request:
|
|
7
|
-
branches: ['*']
|
|
8
|
-
|
|
9
|
-
jobs:
|
|
10
|
-
test:
|
|
11
|
-
runs-on: ubuntu-latest
|
|
12
|
-
|
|
13
|
-
strategy:
|
|
14
|
-
matrix:
|
|
15
|
-
node-version: [22.x, 24.x]
|
|
16
|
-
|
|
17
|
-
steps:
|
|
18
|
-
- uses: actions/checkout@v4
|
|
19
|
-
- name: Use Node.js ${{ matrix.node-version }}
|
|
20
|
-
uses: actions/setup-node@v4
|
|
21
|
-
with:
|
|
22
|
-
node-version: ${{ matrix.node-version }}
|
|
23
|
-
cache: 'npm'
|
|
24
|
-
- run: npm ci
|
|
25
|
-
- run: NODE_ENV=test npm run test
|