Skip to content

Commit 7c0dece

Browse files
committed
fix: handle merge conflicts
2 parents 77a585f + 63a3ffb commit 7c0dece

File tree

7 files changed

+69
-19
lines changed

7 files changed

+69
-19
lines changed

.github/workflows/build-branch.yaml

+8-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,14 @@ jobs:
1515
uses: actions/setup-node@v3
1616
with:
1717
node-version: 18
18-
- run: npm ci
19-
- run: npm test
18+
- name: Install dependencies
19+
run: find . -name 'package-lock.json' -execdir npm ci \;
20+
- name: Run server
21+
run: npm start &
22+
- name: Wait for server to start
23+
run: npx wait-on tcp:8585
24+
- name: Run tests
25+
run: npm run test
2026
build-latest:
2127
name: Build branch
2228
runs-on: ubuntu-latest

.github/workflows/build-latest.yaml

+8-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,14 @@ jobs:
1414
uses: actions/setup-node@v3
1515
with:
1616
node-version: 18
17-
- run: npm ci
18-
- run: npm test
17+
- name: Install dependencies
18+
run: find . -name 'package-lock.json' -execdir npm ci \;
19+
- name: Run server
20+
run: npm start &
21+
- name: Wait for server to start
22+
run: npx wait-on tcp:8585
23+
- name: Run tests
24+
run: npm run test
1925
build-latest:
2026
name: Build latest
2127
runs-on: ubuntu-latest

.github/workflows/release.yaml

+8-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,14 @@ jobs:
1515
uses: actions/setup-node@v3
1616
with:
1717
node-version: 18
18-
- run: npm ci
19-
- run: npm test
18+
- name: Install dependencies
19+
run: find . -name 'package-lock.json' -execdir npm ci \;
20+
- name: Run server
21+
run: npm start &
22+
- name: Wait for server to start
23+
run: npx wait-on tcp:8585
24+
- name: Run tests
25+
run: npm run test
2026
build:
2127
name: Build with google cloud
2228
runs-on: ubuntu-latest

README.md

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Onify Functions
22

3-
[![Build latest](https://github.com/onify/functions/actions/workflows/build.yaml/badge.svg)](https://github.com/onify/functions/actions/workflows/build.yaml)
3+
[![Build latest](https://github.com/onify/functions/actions/workflows/build-latest.yaml/badge.svg)](https://github.com/onify/functions/actions/workflows/build-latest.yaml)
44

55
**Onify Functions** is a set of REST-API functions based on [Node.js](https://nodejs.org/). It can be used in the Onify ecosystem, eg. Onify Flow or Onify Helix. You are also free to use outside of Onify. Onify Functions also support downloading Onify Hub resources and adding your own custom functions. Feel free to [Contribute](#contribute)! Good luck!
66

@@ -403,7 +403,5 @@ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file
403403

404404
## TODO
405405

406-
- Fix `npm run test`
407-
- Fix CI/CD pipeline
408406
- CI/CD pipeline examples for custom image
409407
- Fix/Move mergeImportData to other endpoint

package-lock.json

+33-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"scripts": {
88
"start": "node app.js",
99
"dev": "nodemon --inspect=0.0.0.0:9229 app.js",
10-
"test": "vitest run",
10+
"test": "vitest",
1111
"prepare": "husky"
1212
},
1313
"repository": {
@@ -40,7 +40,8 @@
4040
"pino-pretty": "^10.3.1",
4141
"prettier": "^3.2.5",
4242
"swagger-ui-express": "^5.0.0",
43-
"vitest": "^0.34.6"
43+
"vitest": "^0.34.6",
44+
"wait-on": "^7.2.0"
4445
},
4546
"devDependencies": {
4647
"@commitlint/cli": "^19.3.0",

src/lib/setup-app.js

+8-7
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ dotenv.config();
1515
const rootDir = resolve();
1616
let allResources = null; // This will store the entire resources tree.
1717

18-
const port = process.env.PORT || 8585;
18+
const port =
19+
process.env.PORT_OVERRIDE || process.env.ONIFY_API_INTERNAL_PORT || 8585;
1920
const resourcesSource = process.env.ONIFY_API_RESOURCES_SOURCE || '/';
2021
const resourceURL = `${process.env.ONIFY_API_URL}/admin/resources/file?stream=false&path=${resourcesSource}`;
2122
const listResourcesURL = `${process.env.ONIFY_API_URL}/admin/resources?tree=true`;
@@ -69,7 +70,7 @@ async function downloadFile(resourcePath, destinationPath) {
6970
// Decode the base64 content
7071
const decodedContent = Buffer.from(
7172
response.result.content,
72-
'base64'
73+
'base64',
7374
).toString('utf-8');
7475

7576
// Save the decoded content as a utf-8 encoded file. Creating the directory if it doesn't exist.
@@ -102,7 +103,7 @@ const downloadResourcesFromFolder = async (folderPath) => {
102103
allResources.errors
103104
? JSON.stringify(allResources.errors, null, 2)
104105
: ''
105-
}`
106+
}`,
106107
);
107108
}
108109
}
@@ -154,15 +155,15 @@ const handleResourceRequest = (response) => {
154155
logger.warn(
155156
`Failed to fetch resources history. Received status code ${statusCode}. ${
156157
result.errors ? JSON.stringify(result.errors, null, 2) : ''
157-
}`
158+
}`,
158159
);
159160

160161
return false;
161162
}
162163

163164
if (result.length === 0) {
164165
logger.warn(
165-
'Git in Onify API (resources) is not configured or working! Skipping (cannot) download resources.'
166+
'Git in Onify API (resources) is not configured or working! Skipping (cannot) download resources.',
166167
);
167168

168169
return false;
@@ -244,7 +245,7 @@ async function setupApp() {
244245

245246
app.listen(port, () => {
246247
logger.info(
247-
`Server version ${packageJson.version} is running on port ${port} in ${process.env.NODE_ENV} mode.`
248+
`Server version ${packageJson.version} is running on port ${port} in ${process.env.NODE_ENV} mode.`,
248249
);
249250
});
250251

@@ -256,7 +257,7 @@ async function setupApp() {
256257

257258
if (renewedResources) {
258259
logger.info(
259-
'Resources are updated. Stopping (and restarting) service...'
260+
'Resources are updated. Stopping (and restarting) service...',
260261
);
261262
process.exit(0);
262263
}

0 commit comments

Comments
 (0)