Skip to content

Commit 8d79d15

Browse files
committed
fix: add default config
1 parent 016be7e commit 8d79d15

File tree

16 files changed

+71
-96
lines changed

16 files changed

+71
-96
lines changed

.env.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ CLIENT_ID=e231#used to validate CM event
44
# Messanger apps env
55
SLACK_WEBHOOK=https://hooks.slack.com/services/123
66
# Teams webhook URL
7-
TEAMS_WEBHOOK=https://prod-123.westus.logic.azure.com:443/workflows/123
7+
# TEAMS_WEBHOOK=https://prod-123.westus.logic.azure.com:443/workflows/123
88
# Teams email, alternative approach, if Webhook is disabled
99
TEAMS_EMAIL=email.onmicrosoft.com@amer.teams.ms
1010
# Email sender env

.github/workflows/ci.yml

Lines changed: 0 additions & 31 deletions
This file was deleted.

.github/workflows/manual-release.yml

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -24,48 +24,25 @@ env:
2424
GIT_COMMITTER_NAME: github-actions
2525
GIT_COMMITTER_EMAIL: github-actions@github.com
2626
CI: true
27-
CONFIG_NODE_VERSION: '["20.x"]'
28-
CONFIG_OS: '["ubuntu-latest"]'
2927
# Main Job
3028
jobs:
31-
config:
32-
runs-on: ubuntu-latest
33-
outputs:
34-
NODE_VERSION: ${{ steps.set-config.outputs.CONFIG_NODE_VERSION }}
35-
OS: ${{ steps.set-config.outputs.CONFIG_OS }}
36-
steps:
37-
- id: set-config
38-
run: |
39-
echo "CONFIG_NODE_VERSION=${{ toJSON(env.CONFIG_NODE_VERSION) }}" >> $GITHUB_OUTPUT
40-
echo "CONFIG_OS=${{ toJSON(env.CONFIG_OS) }}" >> $GITHUB_OUTPUT
4129
release:
4230
name: Test, Build and force Release
43-
needs: config
44-
45-
runs-on: ${{ matrix.OS }}
46-
strategy:
47-
matrix:
48-
OS: ${{ fromJSON(needs.config.outputs.OS) }}
49-
NODE_VERSION: ${{ fromJSON(needs.config.outputs.NODE_VERSION) }}
50-
31+
runs-on: ubuntu-latest
5132
steps:
5233
- name: Checkout repo
5334
uses: actions/checkout@v4
54-
- name: Setup Node.js ${{ matrix.NODE_VERSION }}
35+
- name: Setup Node.js
5536
uses: actions/setup-node@v4
5637
with:
57-
node-version: ${{ matrix.NODE_VERSION }}
38+
node-version: "20.x"
5839
- name: Commit trigger
5940
run: |
6041
git commit --allow-empty -m "${{ github.event.inputs.version }}: Trigger Manual Release
6142
6243
${{ github.event.inputs.version }}:Forced Manual Release without code changes"
6344
- name: Install dependencies
6445
run: npm ci
65-
- name: Build Library
66-
run: npm run build --if-present
67-
- name: Run Tests
68-
run: npm test --if-present
6946
- name: Publish npm package
7047
uses: cycjimmy/semantic-release-action@v4
7148
with:

.github/workflows/release.yml

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,11 @@ on:
77

88
jobs:
99
release:
10-
name: Test, Build and Release
11-
runs-on: ${{ matrix.os }}
12-
strategy:
13-
matrix:
14-
os: [ ubuntu-latest ]
15-
node-version: [ 20.x ]
16-
10+
name: Release
11+
runs-on: ubuntu-latest
1712
steps:
1813
- name: Checkout
1914
uses: actions/checkout@v4
20-
- name: Setup Node.js
21-
uses: actions/setup-node@v4
22-
with:
23-
node-version: ${{ matrix['node-version'] }}
24-
- name: Install dependencies
25-
run: npm ci
26-
- name: Build Library
27-
run: npm run build --if-present
28-
- name: Run Tests
29-
run: npm test --if-present
3015
- name: Release
3116
uses: cycjimmy/semantic-release-action@v4
3217
with:

cli/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const {
66
setupGoogle,
77
setupAdobe
88
} = require('../index');
9+
const { DEFAULT_CONFIG } = require('../config');
910

1011
console.log('Starting cli...');
1112

@@ -28,7 +29,7 @@ switch (scriptName) {
2829
break;
2930
case 'start:ngrok':
3031
console.log('Starting ngrok...');
31-
startNgrok().catch(console.error);
32+
startNgrok(DEFAULT_CONFIG.port, DEFAULT_CONFIG.ngrokDomain).catch(console.error);
3233
process.stdin.resume();
3334
break;
3435
case 'setup:google':

config.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
require('dotenv').config();
2+
3+
const DEFAULT_CONFIG = {
4+
fromEmail: process.env.EMAIL_FROM,
5+
ngrokDomain: process.env.NGROK_DOMAIN,
6+
port: process.env.PORT || 4000,
7+
}
8+
9+
module.exports = {
10+
DEFAULT_CONFIG
11+
};

ngrok/start.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
const ngrok = require('@ngrok/ngrok');
22

3-
require('dotenv').config();
4-
5-
async function startNgrok() {
3+
async function startNgrok(port, domain) {
64
try {
75
const listener = await ngrok.connect({
8-
addr: 4000,
9-
domain: process.env.NGROK_DOMAIN,
6+
addr: port,
7+
domain,
108
authtoken_from_env: true,
119
request_header_add: ['ngrok-skip-browser-warning: true'],
1210
onLogRequest: (req) => {
@@ -19,7 +17,7 @@ async function startNgrok() {
1917

2018
const url = listener.url();
2119
console.log('Ngrok connection established');
22-
console.log(`Domain: ${process.env.NGROK_DOMAIN}`);
20+
console.log(`Domain: ${domain}`);
2321
console.log(`URL: ${url}`);
2422
} catch (error) {
2523
console.error('Ngrok startup error:', error.message);

package.json

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,6 @@
1616
"cm-notify": "./cli/index.js"
1717
},
1818
"scripts": {
19-
"start": "node ./cli/index.js start",
20-
"start:app": "node ./cli/index.js start:app",
21-
"start:ngrok": "node ./cli/index.js start:ngrok",
22-
"setup:google": "node ./cli/index.js setup:google",
23-
"setup:adobe": "node ./cli/index.js setup:adobe",
2419
"test": "echo \"Error: no test specified\""
2520
},
2621
"dependencies": {

server/createHttpServer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ function createHttpServer(app, serverPort) {
44
/**
55
* Get port from environment and store in Express.
66
*/
7-
const port = normalizePort(serverPort || process.env.PORT || '4000');
7+
const port = normalizePort(serverPort);
88
app.set('port', port);
99

1010
/**

server/index.server.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
const app = require('./app');
22
const { createHttpServer } = require('./createHttpServer');
3+
const { DEFAULT_CONFIG } = require('../config');
34

4-
const startApp = () => {
5-
return createHttpServer(app);
5+
const startApp = (port) => {
6+
return createHttpServer(app, port || DEFAULT_CONFIG.port);
67
}
78

89
module.exports = { startApp };

0 commit comments

Comments
 (0)