Skip to content

Commit

Permalink
fix: handle merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
blaise-favor committed May 17, 2024
2 parents 77a585f + 63a3ffb commit 7c0dece
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 19 deletions.
10 changes: 8 additions & 2 deletions .github/workflows/build-branch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,14 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: 18
- run: npm ci
- run: npm test
- name: Install dependencies
run: find . -name 'package-lock.json' -execdir npm ci \;
- name: Run server
run: npm start &
- name: Wait for server to start
run: npx wait-on tcp:8585
- name: Run tests
run: npm run test
build-latest:
name: Build branch
runs-on: ubuntu-latest
Expand Down
10 changes: 8 additions & 2 deletions .github/workflows/build-latest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,14 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: 18
- run: npm ci
- run: npm test
- name: Install dependencies
run: find . -name 'package-lock.json' -execdir npm ci \;
- name: Run server
run: npm start &
- name: Wait for server to start
run: npx wait-on tcp:8585
- name: Run tests
run: npm run test
build-latest:
name: Build latest
runs-on: ubuntu-latest
Expand Down
10 changes: 8 additions & 2 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,14 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: 18
- run: npm ci
- run: npm test
- name: Install dependencies
run: find . -name 'package-lock.json' -execdir npm ci \;
- name: Run server
run: npm start &
- name: Wait for server to start
run: npx wait-on tcp:8585
- name: Run tests
run: npm run test
build:
name: Build with google cloud
runs-on: ubuntu-latest
Expand Down
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Onify Functions

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

**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!

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

## TODO

- Fix `npm run test`
- Fix CI/CD pipeline
- CI/CD pipeline examples for custom image
- Fix/Move mergeImportData to other endpoint
34 changes: 33 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"scripts": {
"start": "node app.js",
"dev": "nodemon --inspect=0.0.0.0:9229 app.js",
"test": "vitest run",
"test": "vitest",
"prepare": "husky"
},
"repository": {
Expand Down Expand Up @@ -40,7 +40,8 @@
"pino-pretty": "^10.3.1",
"prettier": "^3.2.5",
"swagger-ui-express": "^5.0.0",
"vitest": "^0.34.6"
"vitest": "^0.34.6",
"wait-on": "^7.2.0"
},
"devDependencies": {
"@commitlint/cli": "^19.3.0",
Expand Down
15 changes: 8 additions & 7 deletions src/lib/setup-app.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ dotenv.config();
const rootDir = resolve();
let allResources = null; // This will store the entire resources tree.

const port = process.env.PORT || 8585;
const port =
process.env.PORT_OVERRIDE || process.env.ONIFY_API_INTERNAL_PORT || 8585;
const resourcesSource = process.env.ONIFY_API_RESOURCES_SOURCE || '/';
const resourceURL = `${process.env.ONIFY_API_URL}/admin/resources/file?stream=false&path=${resourcesSource}`;
const listResourcesURL = `${process.env.ONIFY_API_URL}/admin/resources?tree=true`;
Expand Down Expand Up @@ -69,7 +70,7 @@ async function downloadFile(resourcePath, destinationPath) {
// Decode the base64 content
const decodedContent = Buffer.from(
response.result.content,
'base64'
'base64',
).toString('utf-8');

// Save the decoded content as a utf-8 encoded file. Creating the directory if it doesn't exist.
Expand Down Expand Up @@ -102,7 +103,7 @@ const downloadResourcesFromFolder = async (folderPath) => {
allResources.errors
? JSON.stringify(allResources.errors, null, 2)
: ''
}`
}`,
);
}
}
Expand Down Expand Up @@ -154,15 +155,15 @@ const handleResourceRequest = (response) => {
logger.warn(
`Failed to fetch resources history. Received status code ${statusCode}. ${
result.errors ? JSON.stringify(result.errors, null, 2) : ''
}`
}`,
);

return false;
}

if (result.length === 0) {
logger.warn(
'Git in Onify API (resources) is not configured or working! Skipping (cannot) download resources.'
'Git in Onify API (resources) is not configured or working! Skipping (cannot) download resources.',
);

return false;
Expand Down Expand Up @@ -244,7 +245,7 @@ async function setupApp() {

app.listen(port, () => {
logger.info(
`Server version ${packageJson.version} is running on port ${port} in ${process.env.NODE_ENV} mode.`
`Server version ${packageJson.version} is running on port ${port} in ${process.env.NODE_ENV} mode.`,
);
});

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

if (renewedResources) {
logger.info(
'Resources are updated. Stopping (and restarting) service...'
'Resources are updated. Stopping (and restarting) service...',
);
process.exit(0);
}
Expand Down

0 comments on commit 7c0dece

Please sign in to comment.