mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
This commit does the following: - Introduces the get-machine command. This command contacts the build farm server gets back a machine reservation and then opens a secure shell to the machine (Alternatively, you can ask for a json). This also involved factoring out some commands to deal with authenticated ddp from package-client into a more general auth-client. - No longer publish binary builds in publish or publish-release; instead give the user a warning to run get-machine and then publish-for-arch. Someone could ignore this: --existing-version and publish-for-arch both publish binary builds, but you need to be at least somewhat familiar with what you are doing to run them. Hopefully, you are running them from a certified build machine, but if you are not, then, well, it is your package. Stuff remaining: - We are going to have a url to external documentation, but I haven't written it yet. - We are currently talking to the test-build server, instead of the build server, so mac doesn't work. (Neither of those changes require significant tool changes)
112 lines
3.7 KiB
JavaScript
112 lines
3.7 KiB
JavaScript
var auth = require('./auth.js');
|
|
var Console = require('./console.js').Console;
|
|
var ServiceConnection = require('./service-connection.js');
|
|
var httpHelpers = require('./http-helpers.js');
|
|
var uniload = require('./uniload.js');
|
|
|
|
exports.AlreadyPrintedMessageError = function () {};
|
|
|
|
// Use uniload to load the packages that we need to open a meteor developer
|
|
// accounts ddp connection.
|
|
//
|
|
// meteor: base package and prerequsite for all others.
|
|
// ddp: DDP client interface to make a connection to the package server.
|
|
var getDDPPackages = function () {
|
|
return uniload.load({
|
|
packages: [ 'meteor', 'ddp']
|
|
});
|
|
};
|
|
|
|
// Opens a DDP connection to a package server. Loads the packages needed for a
|
|
// DDP connection, then calls DDP connect to the package server URL in config,
|
|
// using a current user-agent header composed by http-helpers.js.
|
|
exports.openServiceConnection = function (serverUrl) {
|
|
return new ServiceConnection(
|
|
getDDPPackages(),
|
|
serverUrl,
|
|
{headers: {"User-Agent": httpHelpers.getUserAgent()},
|
|
_dontPrintErrors: true});
|
|
};
|
|
|
|
|
|
// Handle an error thrown on attempting to connect. Print a message if it is a
|
|
// known error type, else throw the error.
|
|
//
|
|
// err: error
|
|
// label: name of the service that we are trying to use (ex: "package server")
|
|
exports.handlerConnectionError = function (error, label) {
|
|
if (error instanceof exports.AlreadyPrintedMessageError) {
|
|
// do nothing
|
|
} else if (error.errorType === 'Meteor.Error') {
|
|
var errorMsg = "Error from " + label;
|
|
if (error.message) {
|
|
errorMsg += ": " + error.message;
|
|
}
|
|
Console.info(errorMsg);
|
|
} else if (error.errorType === "DDP.ConnectionError") {
|
|
Console.info("Error connecting to " + label + ": "
|
|
+ error.message);
|
|
} else {
|
|
throw error;
|
|
}
|
|
};
|
|
|
|
// Returns a logged-in DDP connection to the given URL, or null if
|
|
// we cannot log in. If an error unrelated to login occurs
|
|
// (e.g. connection to package server times out), then it will be
|
|
// thrown.
|
|
//
|
|
// url: the url of the connection (ex: config.getPackageServerUrl)
|
|
// domain: the domain (ex: packages.meteor.com)
|
|
// sessionType: the name of the connection (ex: "package-server")
|
|
//
|
|
exports.loggedInConnection = function (url, domain, sessionType) {
|
|
// Make sure that we are logged in with Meteor Accounts so that we can
|
|
// do an OAuth flow.
|
|
if (auth.maybePrintRegistrationLink({onlyAllowIfRegistered: true})) {
|
|
// Oops, we're logged in but with a deferred-registration account.
|
|
// Message has already been printed.
|
|
throw new exports.AlreadyPrintedMessageError;
|
|
}
|
|
|
|
if (! auth.isLoggedIn()) {
|
|
// XXX we should have a better account signup page.
|
|
Console.stderr.write(
|
|
"Please log in with your Meteor developer account. If you don't have one,\n" +
|
|
"you can quickly create one at www.meteor.com.\n");
|
|
auth.doUsernamePasswordLogin({ retry: true });
|
|
}
|
|
|
|
var conn = exports.openServiceConnection(url);
|
|
var accountsConfiguration = auth.getAccountsConfiguration(conn);
|
|
try {
|
|
auth.loginWithTokenOrOAuth(
|
|
conn,
|
|
accountsConfiguration,
|
|
url,
|
|
domain,
|
|
sessionType
|
|
);
|
|
} catch (err) {
|
|
if (err.message === "access-denied") {
|
|
// Maybe we thought we were logged in, but our token had been
|
|
// revoked.
|
|
Console.stderr.write(
|
|
"It looks like you have been logged out! Please log in with your Meteor\n" +
|
|
"developer account. If you don't have one, you can quickly create one\n" +
|
|
"at www.meteor.com.\n");
|
|
auth.doUsernamePasswordLogin({ retry: true });
|
|
auth.loginWithTokenOrOAuth(
|
|
conn,
|
|
accountsConfiguration,
|
|
url,
|
|
domain,
|
|
sessionType
|
|
);
|
|
} else {
|
|
throw err;
|
|
}
|
|
}
|
|
return conn;
|
|
};
|