diff --git a/app/meteor/meteor.js b/app/meteor/meteor.js index 4d648bccda5..2b0d7385947 100644 --- a/app/meteor/meteor.js +++ b/app/meteor/meteor.js @@ -521,7 +521,7 @@ Fiber(function () { .boolean('debug') .describe('debug', 'deploy in debug mode (don\'t minify, etc)') .boolean('tests') - .describe('settings', 'set optional data for Meteor.settings on the server') + .describe('settings', 'set optional data for Meteor.settings') // .describe('tests', 'deploy the tests instead of the actual application') .usage( // XXX document --tests in the future, once we publicly @@ -532,22 +532,24 @@ Fiber(function () { "\n" + "You can deploy to any available name under 'meteor.com'\n" + "without any additional configuration, for example,\n" + - "'myapp.meteor.com'. If you deploy to a custom domain, such as\n" + + "'myapp.meteor.com'. If you deploy to a custom domain, such as\n" + "'myapp.mydomain.com', then you'll also need to configure your domain's\n" + - "DNS records. See the Meteor docs for details.\n" + + "DNS records. See the Meteor docs for details.\n" + "\n" + "The --settings flag can be used to pass deploy-specific information to\n" + "the application. It will be available at runtime in Meteor.settings, but only\n" + - "on the server. The argument is the name of a file containing the JSON data\n" + - "to use. The settings will persist across deployments until you again specify\n" + - "a settings file. To unset Meteor.settings, pass an empty settings file.\n" + + "on the server. If the object contains a key named 'public', then\n" + + "Meteor.settings.public will also be available on the client. The argument\n" + + "is the name of a file containing the JSON data to use. The settings will\n" + + "persist across deployments until you again specify a settings file. To\n" + + "unset Meteor.settings, pass an empty settings file.\n" + "\n" + "The --delete flag permanently removes a deployed application, including\n" + "all of its stored data.\n" + "\n" + - "The --password flag sets an administrative password for the domain. Once\n" + + "The --password flag sets an administrative password for the domain. Once\n" + "set, any subsequent 'deploy', 'logs', or 'mongo' command will prompt for\n" + - "the password. You can change the password with a second 'deploy' command." + "the password. You can change the password with a second 'deploy' command." ); var new_argv = opt.argv; diff --git a/docs/client/api.js b/docs/client/api.js index b3547466f50..efd28869995 100644 --- a/docs/client/api.js +++ b/docs/client/api.js @@ -57,12 +57,13 @@ Template.api.absoluteUrl = { Template.api.settings = { id: "meteor_settings", name: "Meteor.settings", - locus: "Server", + locus: "Server and client", descr: ["`Meteor.settings` contains any deployment-specific options that were " + "provided using the `--settings` option for `meteor run` or `meteor deploy`. " + "If you provide the `--settings` option, `Meteor.settings` will be the " + "JSON object in the file you specify. Otherwise, `Meteor.settings` will " + - "be an empty object."] + "be an empty object. If the object contains a key named `public`, then " + + "`Meteor.settings.public` will also be available on the client."] }; Template.api.publish = { diff --git a/packages/meteor/client_environment.js b/packages/meteor/client_environment.js index ca2c972b8d5..6405709e300 100644 --- a/packages/meteor/client_environment.js +++ b/packages/meteor/client_environment.js @@ -2,3 +2,9 @@ Meteor = { isClient: true, isServer: false }; + +if (typeof __meteor_runtime_config__ !== 'undefined' && + __meteor_runtime_config__ && + __meteor_runtime_config__.PUBLIC_SETTINGS) { + Meteor.settings = { public: __meteor_runtime_config__.PUBLIC_SETTINGS }; +} diff --git a/packages/meteor/server_environment.js b/packages/meteor/server_environment.js index 62313947bcf..254e60f7862 100644 --- a/packages/meteor/server_environment.js +++ b/packages/meteor/server_environment.js @@ -3,11 +3,15 @@ Meteor = { isServer: true }; -try { - Meteor.settings = {}; - if (process.env.METEOR_SETTINGS) +Meteor.settings = {}; +if (process.env.METEOR_SETTINGS) { + try { Meteor.settings = JSON.parse(process.env.METEOR_SETTINGS); -} catch (e) { - throw new Error("Settings are not valid JSON"); + } catch (e) { + throw new Error("Settings are not valid JSON"); + } +} +// Push a subset of settings to the client. +if (Meteor.settings && Meteor.settings.public) { + __meteor_runtime_config__.PUBLIC_SETTINGS = Meteor.settings.public; } -