Skip to content

Commit

Permalink
Expose local filesystem and assets over url alias
Browse files Browse the repository at this point in the history
  • Loading branch information
wojtkowiak committed Dec 7, 2016
1 parent 6ef14fb commit 5f084e6
Show file tree
Hide file tree
Showing 12 changed files with 380 additions and 124 deletions.
1 change: 1 addition & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"process",
"devtron",
"ava",
"send",
"meteor-desktop-test-suite"
]
},
Expand Down
2 changes: 1 addition & 1 deletion lib/skeletonDependencies.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
export default {
connect: '3.5.0',
'serve-static': '1.11.1',
'server-destroy': '1.0.1',
'connect-modrewrite': '0.9.0',
winston: '2.2.0',
Expand All @@ -11,5 +10,6 @@ export default {
request: '2.75.0',
queue: '4.0.0',
reify: '0.3.8',
send: '0.14.1',
'fs-plus': '2.9.2'
};
1 change: 1 addition & 0 deletions scaffold/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"autoUpdateCheckOnStart": true,
"rebuildNativeNodeModules": false,
"webAppStartupTimeout": 60000,
"exposeLocalFilesystem": false,
"window": {
"icon": "@assets/meteor.png",
"_windows": {
Expand Down
11 changes: 7 additions & 4 deletions skeleton/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,9 @@ class App {
if (internal && moduleName === 'autoupdate') {
settings = this.prepareAutoupdateSettings();
}
if (internal && moduleName === 'localServer') {
settings = { localFilesystem: this.settings.exposeLocalFilesystem };
}

this.modules[moduleName] = new AppModule({
log: this.loggerManager.configureLogger(moduleName),
Expand Down Expand Up @@ -394,8 +397,8 @@ class App {
);

this.localServer.init(
this.modules.autoupdate.getDirectory(),
this.modules.autoupdate.getParentDirectory()
this.modules.autoupdate.getCurrentAssetBundle(),
this.desktopPath
);

this.emit('afterInitialization');
Expand Down Expand Up @@ -535,8 +538,8 @@ class App {

// Reinitialize the local server.
this.localServer.init(
this.modules.autoupdate.getDirectory(),
this.modules.autoupdate.getParentDirectory(),
this.modules.autoupdate.getCurrentAssetBundle(),
this.desktopPath,
true
);
}
Expand Down
14 changes: 14 additions & 0 deletions skeleton/modules/autoupdate.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,10 @@ export default class HCPClient {
this.pendingAssetBundle = null;
}

/**
* Reverts to either last known good version or the initial version if there is none available.
* @private
*/
useLastKnownGoodVersion() {
const lastKnownGoodVersion = this.config.lastKnownGoodVersion;
this.log.debug(`last known good version is ${this.config.lastKnownGoodVersion}`);
Expand Down Expand Up @@ -249,6 +253,16 @@ export default class HCPClient {
return null;
}


/**
* Returns the currently used asset bundle.
*
* @returns {null|AssetBundle}
*/
getCurrentAssetBundle() {
return this.currentAssetBundle;
}

/**
* Returns the current assets bundle's directory.
* @returns {string}
Expand Down
14 changes: 11 additions & 3 deletions skeleton/modules/autoupdate/assetBundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,14 @@ export default class AssetBundle {
}
}

/**
* Get index.html path.
* @returns {string}
*/
getIndexFile() {
return this.indexFile;
}

/**
* Directory uri getter.
* @returns {string}
Expand Down Expand Up @@ -302,13 +310,13 @@ export default class AssetBundle {
*
* @param {string} urlPath - Url path of the asset.
*
* @returns {Asset}
* @returns {Asset|null}
*/
assetForUrlPath(urlPath) {
let asset;
let asset = null;
if (urlPath in this.ownAssetsByURLPath) {
asset = this.ownAssetsByURLPath[urlPath];
} else if (this.parentAssetBundle !== null) {
} else if (this.parentAssetBundle) {
asset = this.parentAssetBundle.assetForUrlPath(urlPath);
}
return asset;
Expand Down
Loading

0 comments on commit 5f084e6

Please sign in to comment.