Skip to content

Commit 1de1c61

Browse files
committed
Configurable package location paths (#106)
1 parent 8e235fd commit 1de1c61

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

src/config.js

+3
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ export const defaultConfiguration = {
7171

7272
packages: {
7373
manifest: '/api/packages/manifest',
74+
vfsPaths: [
75+
'home:/.packages'
76+
],
7477
metadata: []
7578
},
7679

src/packages.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,12 @@ export default class Packages {
134134

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

137+
const query = this.core.config('packages.vfsPaths', [])
138+
.map(str => `root[]=${encodeURIComponent(str)}`)
139+
.join('&');
140+
137141
return manifest
138-
? this.core.request(manifest, {}, 'json')
142+
? this.core.request(`${manifest}?${query}`, {}, 'json')
139143
.then(metadata => this.addPackages(metadata))
140144
.then(() => true)
141145
.catch(error => logger.error(error))
@@ -390,7 +394,7 @@ export default class Packages {
390394
if (list instanceof Array) {
391395
const append = list
392396
.map(iter => Object.assign({
393-
_user: false,
397+
_vfs: null,
394398
type: 'application',
395399
files: []
396400
}, iter));

src/utils/url.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ export const urlResolver = configuration => {
5252
metadata.type === 'icons' ? 'icons' : 'apps'
5353
);
5454

55-
if (metadata._user) {
56-
url = `vfs/readfile?path=${encodeURIComponent(`home:/.packages/${metadata.name}${path}`)}`;
55+
if (metadata._vfs) {
56+
url = `vfs/readfile?path=${encodeURIComponent(`${metadata._vfs}/${metadata.name}${path}`)}`;
5757
} else {
5858
url = `${type}/${metadata.name}${path}`;
5959
}

0 commit comments

Comments
 (0)