Skip to content

Commit

Permalink
Configurable package location paths (#106)
Browse files Browse the repository at this point in the history
  • Loading branch information
andersevenrud committed Apr 11, 2020
1 parent 8e235fd commit 1de1c61
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
3 changes: 3 additions & 0 deletions src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ export const defaultConfiguration = {

packages: {
manifest: '/api/packages/manifest',
vfsPaths: [
'home:/.packages'
],
metadata: []
},

Expand Down
8 changes: 6 additions & 2 deletions src/packages.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,12 @@ export default class Packages {

const manifest = this.core.config('packages.manifest');

const query = this.core.config('packages.vfsPaths', [])
.map(str => `root[]=${encodeURIComponent(str)}`)
.join('&');

return manifest
? this.core.request(manifest, {}, 'json')
? this.core.request(`${manifest}?${query}`, {}, 'json')
.then(metadata => this.addPackages(metadata))
.then(() => true)
.catch(error => logger.error(error))
Expand Down Expand Up @@ -390,7 +394,7 @@ export default class Packages {
if (list instanceof Array) {
const append = list
.map(iter => Object.assign({
_user: false,
_vfs: null,
type: 'application',
files: []
}, iter));
Expand Down
4 changes: 2 additions & 2 deletions src/utils/url.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ export const urlResolver = configuration => {
metadata.type === 'icons' ? 'icons' : 'apps'
);

if (metadata._user) {
url = `vfs/readfile?path=${encodeURIComponent(`home:/.packages/${metadata.name}${path}`)}`;
if (metadata._vfs) {
url = `vfs/readfile?path=${encodeURIComponent(`${metadata._vfs}/${metadata.name}${path}`)}`;
} else {
url = `${type}/${metadata.name}${path}`;
}
Expand Down

0 comments on commit 1de1c61

Please sign in to comment.