Skip to content

Commit

Permalink
Merge pull request #171 from line-o/fix/170
Browse files Browse the repository at this point in the history
fix(package): installation falls back to XMLRPC
  • Loading branch information
duncdrum committed Nov 16, 2023
2 parents 966fe84 + 6a98d50 commit dbc5d96
Show file tree
Hide file tree
Showing 6 changed files with 530 additions and 12 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/test-no-rest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Test - No REST

on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# pull image
- run: docker pull existdb/existdb:release
# create docker container
# --volume $(pwd)/empty:/exist/autodeploy:ro
- name: create eXist-db Container
run: docker create --name exist --publish 8080:8080 --publish 8443:8443 existdb/existdb:release
# - name: Start eXist-db Container
# run: docker start exist
# - name: Wait for eXist-db Startup
# run: timeout 90 sh -c 'until nc -z $0 $1; do sleep 3; done' localhost 8080
# get web.xml (use prepared web.xml instead)
# - run: docker cp exist:exist/etc/webapp/WEB-INF/web.xml ./web.xml
# modify web.xml
# - run: cat web.xml | \
# tr '\n' '\r' | \
# sed -E 's/(<param-name>hidden<\/param-name>\r[[:space:]]+<param-value>)false(<\/param-value>)/\1true\2/' | \
# tr '\r' '\n' > modified-web.xml
- name: Copy modified web.xml
run: docker cp ./spec/fixtures/web-no-rest.xml exist:exist/etc/webapp/WEB-INF/web.xml
- name: Restart eXist-db Container
# run: docker stop exist && docker wait; docker start exist
run: docker start exist
- name: Wait for eXist-db Startup
run: timeout 90 sh -c 'until nc -z $0 $1; do sleep 3; done' localhost 8080
- name: Use Node.js 20
uses: actions/setup-node@v3
with:
node-version: 20
- run: npm ci --no-optional
- run: npm link
- run: npm run test:norest

9 changes: 7 additions & 2 deletions commands/package/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,13 @@ export async function handler (argv) {
if (rest) {
upload = boundUpload
} else {
const test = await restClient.get('db')
upload = test.statusCode === 200 ? boundUpload : db.app.upload
try {
await restClient.get('db')
upload = boundUpload
} catch (e) {
console.log('Falling back to XMLRPC API')
upload = db.app.upload
}
}
}

Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
},
"scripts": {
"test": "standard && tape \"spec/tests/**/*.js\"",
"test:norest": "tape \"spec/norest/**/*.js\"",
"lint": "standard --fix"
},
"keywords": [
Expand Down
Loading

0 comments on commit dbc5d96

Please sign in to comment.