Skip to content

Commit

Permalink
Merge pull request #154 from line-o/feat/better-install
Browse files Browse the repository at this point in the history
Ease package installation
  • Loading branch information
line-o authored Jun 30, 2021
2 parents 29b1d59 + 2d64c30 commit bd8ca15
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 15 deletions.
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,10 +189,13 @@ exports.default = deployWithPermissions
#### Options
##### packageUri
##### packageUri (deprecated)
The unique package descriptor of the application to be installed.
**NOTE:** For versions after v4.0.2 this option is ignored and will be read
from the XAR itself.
##### customPackageRepoUrl
The application repository that will be used to resolve dependencies.
Expand All @@ -211,12 +214,10 @@ const exist = createClient({
pass: ''
}
})
// this MUST be the unique package identifier of the XAR you want to install
const packageUri = 'http://exist-db.org/apps/test-app'

function install () {
return src('spec/files/test-app.xar')
.pipe(exist.install({ packageUri }))
.pipe(exist.install())
}
```
Expand Down
10 changes: 4 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ function newer (client, options) {

/**
* @typedef {Object} GulpExistInstallationOptions
* @prop {string} packageUri
* @prop {string} [packageUri] deprecated
* @prop {string} [customPackageRepoUrl]
*/

Expand All @@ -293,9 +293,7 @@ function newer (client, options) {
* @return {TransformFunction} install XAR from vinyl file stream
*/
function install (client, options) {
if (!options || !options.packageUri) { return new PluginError('gulp-exist', 'packageUri must be declared') }
const packageUri = options.packageUri
const customPackageRepoUrl = options.customPackageRepoUrl || null
const customPackageRepoUrl = options && options.customPackageRepoUrl ? options.customPackageRepoUrl : null

function installPackage (file, enc, callback) {
const xarName = file.basename
Expand All @@ -310,8 +308,8 @@ function install (client, options) {
client.app.upload(file.contents, xarName)
.then(response => {
if (!response.success) { return callback(new PluginError('gulp-exist', 'XAR was not uploaded')) }
log(`Install ${packageUri} from ${xarName}`)
return client.app.install(xarName, packageUri, customPackageRepoUrl)
log(`Install ${xarName}`)
return client.app.install(xarName, customPackageRepoUrl)
})
.then(response => {
if (!response.success) { return callback(new PluginError('gulp-exist', 'XAR Installation failed')) }
Expand Down
6 changes: 3 additions & 3 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@
"tape": "^5.0.1"
},
"dependencies": {
"@existdb/node-exist": "^4.0.0",
"fancy-log": "^1.3.2",
"gulp": "^4.0.2",
"lodash.assign": "^4.2.0",
"@existdb/node-exist": "^3.0.1",
"plugin-error": "^1.0.1",
"through2": "^4.0.2",
"vinyl": "^2.2.1"
Expand Down
2 changes: 1 addition & 1 deletion spec/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ test('install XAR package', function (t) {
}

return gulp.src('test-app.xar', { cwd: 'spec/files' })
.pipe(testClient.install({ packageUri }))
.pipe(testClient.install())
.on('data', function (d) {
t.plan(3)
t.true(d.success, 'succeeded')
Expand Down

0 comments on commit bd8ca15

Please sign in to comment.