packages/autoupdate/autoupdate_server.js
function (shouldReloadClientProgram) {
  // Step 1: load the current client program on the server and update the
  // hash values in __meteor_runtime_config__.
  if (shouldReloadClientProgram) {
    WebAppInternals.reloadClientPrograms();
  }

  // If we just re-read the client program, or if we don't have an autoupdate
  // version, calculate it.
  if (shouldReloadClientProgram || Autoupdate.autoupdateVersion === null) {
    Autoupdate.autoupdateVersion =
      process.env.AUTOUPDATE_VERSION ||
      WebApp.calculateClientHashNonRefreshable();
  }
  // If we just recalculated it OR if it was set by (eg) test-in-browser,
  // ensure it ends up in __meteor_runtime_config__.
  __meteor_runtime_config__.autoupdateVersion =
    Autoupdate.autoupdateVersion;

  Autoupdate.autoupdateVersionRefreshable =
    __meteor_runtime_config__.autoupdateVersionRefreshable =
      process.env.AUTOUPDATE_VERSION ||
      WebApp.calculateClientHashRefreshable();

  Autoupdate.autoupdateVersionCordova =
    __meteor_runtime_config__.autoupdateVersionCordova =
      process.env.AUTOUPDATE_VERSION ||
      WebApp.calculateClientHashCordova();

  // Step 2: form the new client boilerplate which contains the updated
  // assets and __meteor_runtime_config__.
  if (shouldReloadClientProgram) {
    WebAppInternals.generateBoilerplate();
  }

  // XXX COMPAT WITH 0.8.3
  if (! ClientVersions.findOne({current: true})) {
    // To ensure apps with version of Meteor prior to 0.9.0 (in
    // which the structure of documents in `ClientVersions` was
    // different) also reload.
    ClientVersions.insert({current: true});
  }

  if (! ClientVersions.findOne({_id: "version"})) {
    ClientVersions.insert({
      _id: "version",
      version: Autoupdate.autoupdateVersion
    });
  } else {
    ClientVersions.update("version", { $set: {
      version: Autoupdate.autoupdateVersion
    }});
  }

  if (! ClientVersions.findOne({_id: "version-cordova"})) {
    ClientVersions.insert({
      _id: "version-cordova",
      version: Autoupdate.autoupdateVersionCordova,
      refreshable: false
    });
  } else {
    ClientVersions.update("version-cordova", { $set: {
      version: Autoupdate.autoupdateVersionCordova
    }});
  }

  // Use `onListening` here because we need to use
  // `WebAppInternals.refreshableAssets`, which is only set after
  // `WebApp.generateBoilerplate` is called by `main` in webapp.
  WebApp.onListening(function () {
    if (! ClientVersions.findOne({_id: "version-refreshable"})) {
      ClientVersions.insert({
        _id: "version-refreshable",
        version: Autoupdate.autoupdateVersionRefreshable,
        assets: WebAppInternals.refreshableAssets
      });
    } else {
      ClientVersions.update("version-refreshable", { $set: {
        version: Autoupdate.autoupdateVersionRefreshable,
        assets: WebAppInternals.refreshableAssets
      }});
    }
  });
}
function (shouldReloadClientProgram) {
  // Step 1: load the current client program on the server and update the
  // hash values in __meteor_runtime_config__.
  if (shouldReloadClientProgram) {
    WebAppInternals.reloadClientPrograms();
  }

  // If we just re-read the client program, or if we don't have an autoupdate
  // version, calculate it.
  if (shouldReloadClientProgram || Autoupdate.autoupdateVersion === null) {
    Autoupdate.autoupdateVersion =
      process.env.AUTOUPDATE_VERSION ||
      WebApp.calculateClientHashNonRefreshable();
  }
  // If we just recalculated it OR if it was set by (eg) test-in-browser,
  // ensure it ends up in __meteor_runtime_config__.
  __meteor_runtime_config__.autoupdateVersion =
    Autoupdate.autoupdateVersion;

  Autoupdate.autoupdateVersionRefreshable =
    __meteor_runtime_config__.autoupdateVersionRefreshable =
      process.env.AUTOUPDATE_VERSION ||
      WebApp.calculateClientHashRefreshable();

  Autoupdate.autoupdateVersionCordova =
    __meteor_runtime_config__.autoupdateVersionCordova =
      process.env.AUTOUPDATE_VERSION ||
      WebApp.calculateClientHashCordova();

  // Step 2: form the new client boilerplate which contains the updated
  // assets and __meteor_runtime_config__.
  if (shouldReloadClientProgram) {
    WebAppInternals.generateBoilerplate();
  }

  // XXX COMPAT WITH 0.8.3
  if (! ClientVersions.findOne({current: true})) {
    // To ensure apps with version of Meteor prior to 0.9.0 (in
    // which the structure of documents in `ClientVersions` was
    // different) also reload.
    ClientVersions.insert({current: true});
  }

  if (! ClientVersions.findOne({_id: "version"})) {
    ClientVersions.insert({
      _id: "version",
      version: Autoupdate.autoupdateVersion
    });
  } else {
    ClientVersions.update("version", { $set: {
      version: Autoupdate.autoupdateVersion
    }});
  }

  if (! ClientVersions.findOne({_id: "version-cordova"})) {
    ClientVersions.insert({
      _id: "version-cordova",
      version: Autoupdate.autoupdateVersionCordova,
      refreshable: false
    });
  } else {
    ClientVersions.update("version-cordova", { $set: {
      version: Autoupdate.autoupdateVersionCordova
    }});
  }

  // Use `onListening` here because we need to use
  // `WebAppInternals.refreshableAssets`, which is only set after
  // `WebApp.generateBoilerplate` is called by `main` in webapp.
  WebApp.onListening(function () {
    if (! ClientVersions.findOne({_id: "version-refreshable"})) {
      ClientVersions.insert({
        _id: "version-refreshable",
        version: Autoupdate.autoupdateVersionRefreshable,
        assets: WebAppInternals.refreshableAssets
      });
    } else {
      ClientVersions.update("version-refreshable", { $set: {
        version: Autoupdate.autoupdateVersionRefreshable,
        assets: WebAppInternals.refreshableAssets
      }});
    }
  });
}
function ( shouldReloadClientProgram ) { // Step 1: load the current client program on the server and update the // hash values in __meteor_runtime_config__. if ( shouldReloadClientProgram ) { WebAppInternals . reloadClientPrograms ( ) ; } // If we just re-read the client program, or if we don't have an autoupdate // version, calculate it. if ( shouldReloadClientProgram || Autoupdate . autoupdateVersion === null ) { Autoupdate . autoupdateVersion = process . env . AUTOUPDATE_VERSION || WebApp . calculateClientHashNonRefreshable ( ) ; } // If we just recalculated it OR if it was set by (eg) test-in-browser, // ensure it ends up in __meteor_runtime_config__. __meteor_runtime_config__ . autoupdateVersion = Autoupdate . autoupdateVersion ; Autoupdate . autoupdateVersionRefreshable = __meteor_runtime_config__ . autoupdateVersionRefreshable = process . env . AUTOUPDATE_VERSION || WebApp . calculateClientHashRefreshable ( ) ; Autoupdate . autoupdateVersionCordova = __meteor_runtime_config__ . autoupdateVersionCordova = process . env . AUTOUPDATE_VERSION || WebApp . calculateClientHashCordova ( ) ; // Step 2: form the new client boilerplate which contains the updated // assets and __meteor_runtime_config__. if ( shouldReloadClientProgram ) { WebAppInternals . generateBoilerplate ( ) ; } // XXX COMPAT WITH 0.8.3 if ( ! ClientVersions . findOne ( { current : true } ) ) { // To ensure apps with version of Meteor prior to 0.9.0 (in // which the structure of documents in `ClientVersions` was // different) also reload. ClientVersions . insert ( { current : true } ) ; } if ( ! ClientVersions . findOne ( { _id : "version" } ) ) { ClientVersions . insert ( { _id : "version" , version : Autoupdate . autoupdateVersion } ) ; } else { ClientVersions . update ( "version" , { $set : { version : Autoupdate . autoupdateVersion } } ) ; } if ( ! ClientVersions . findOne ( { _id : "version-cordova" } ) ) { ClientVersions . insert ( { _id : "version-cordova" , version : Autoupdate . autoupdateVersionCordova , refreshable : false } ) ; } else { ClientVersions . update ( "version-cordova" , { $set : { version : Autoupdate . autoupdateVersionCordova } } ) ; } // Use `onListening` here because we need to use // `WebAppInternals.refreshableAssets`, which is only set after // `WebApp.generateBoilerplate` is called by `main` in webapp. WebApp . onListening ( function ( ) { if ( ! ClientVersions . findOne ( { _id : "version-refreshable" } ) ) { ClientVersions . insert ( { _id : "version-refreshable" , version : Autoupdate . autoupdateVersionRefreshable , assets : WebAppInternals . refreshableAssets } ) ; } else { ClientVersions . update ( "version-refreshable" , { $set : { version : Autoupdate . autoupdateVersionRefreshable , assets : WebAppInternals . refreshableAssets } } ) ; } } ) ; }
updateVersions can only be called after the server has fully loaded.
updateVersions can only be called after the server has fully loaded .