Return-Path: X-Original-To: apmail-cordova-commits-archive@www.apache.org Delivered-To: apmail-cordova-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 1F82517BF3 for ; Wed, 1 Oct 2014 19:27:32 +0000 (UTC) Received: (qmail 75741 invoked by uid 500); 1 Oct 2014 19:27:32 -0000 Delivered-To: apmail-cordova-commits-archive@cordova.apache.org Received: (qmail 75716 invoked by uid 500); 1 Oct 2014 19:27:32 -0000 Mailing-List: contact commits-help@cordova.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cordova.apache.org Delivered-To: mailing list commits@cordova.apache.org Received: (qmail 75707 invoked by uid 99); 1 Oct 2014 19:27:32 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 01 Oct 2014 19:27:32 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id BDCC4925BE8; Wed, 1 Oct 2014 19:27:31 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: marcelk@apache.org To: commits@cordova.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: spec commit: CB-7686 add check of npm-link when using master of tools Date: Wed, 1 Oct 2014 19:27:31 +0000 (UTC) Repository: cordova-mobile-spec Updated Branches: refs/heads/master 59f4b8325 -> e0f753036 CB-7686 add check of npm-link when using master of tools Project: http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/repo Commit: http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/commit/e0f75303 Tree: http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/tree/e0f75303 Diff: http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/diff/e0f75303 Branch: refs/heads/master Commit: e0f7530366e945b232ada3bf7bc189d5ec0090db Parents: 59f4b83 Author: Marcel Kinard Authored: Wed Oct 1 15:26:20 2014 -0400 Committer: Marcel Kinard Committed: Wed Oct 1 15:27:09 2014 -0400 ---------------------------------------------------------------------- createmobilespec/createmobilespec.js | 75 ++++++++++++++++++++++++++++++- 1 file changed, 73 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/blob/e0f75303/createmobilespec/createmobilespec.js ---------------------------------------------------------------------- diff --git a/createmobilespec/createmobilespec.js b/createmobilespec/createmobilespec.js index d8913fc..b532995 100755 --- a/createmobilespec/createmobilespec.js +++ b/createmobilespec/createmobilespec.js @@ -102,7 +102,7 @@ var top_dir = process.cwd() + path.sep, "windows8": ["www"], "windows": ["www"], "wp8": ["www"]}, - argv = optimist.usage("\nUsage: $0 PLATFORM... [--help] [--plugman] [--global] [--globalplugins] [--skipjs] [directoryName]\n" + + argv = optimist.usage("\nUsage: $0 PLATFORM... [--help] [--plugman] [--global] [--globalplugins] [--skipjs] [--skiplink] [directoryName]\n" + "A project will be created with the mobile-spec app and all the core plugins.\n" + "At least one platform must be specified. See the included README.md.\n" + "\tPLATFORM: [--]\n" + @@ -127,6 +127,8 @@ var top_dir = process.cwd() + path.sep, .boolean("skipjs").describe("skipjs", "Do not update the platform's cordova.js from the js git repo, use the one already present in the platform.\n" + "\t\t\tRarely used, generally to test RC releases.\n" + "\t\t\tCannot be used with --global because it is implied when --global is used.") + .boolean("skiplink").describe("skiplink", "Do not check 'npm link' of our own dependent modules such as cordova-lib when on master.\n" + + "\t\t\tUse only when you know what you are doing, this should be very rare.") .alias("h", "help") .argv; @@ -158,7 +160,12 @@ if (argv.skipjs && argv.global) { quit(); } if (argv.globalplugins && argv.global) { - console.log("This --globalplugins option can not be used with the --global option."); + console.log("The --globalplugins option can not be used with the --global option."); + optimist.showHelp(); + quit(); +} +if (argv.skiplink && argv.global) { + console.log("The --skiplink option can not be used with the --global option."); optimist.showHelp(); quit(); } @@ -230,6 +237,70 @@ if (argv.global || argv.globalplugins) { shelljs.rm("-rf", path.join(home_dir, ".plugman")); } +function getPathFromModuleName(moduleName) { + if (moduleName == "cordova-lib") { + return(moduleName + path.sep + moduleName); + } else { + return(moduleName); + } +} + +function cdInto(moduleName) { + var myPath = getPathFromModuleName(moduleName); + pushd(myPath); +} + +function cdOutOf() { + popd(); +} + +function getBranchName(moduleName) { + cdInto(moduleName); + // output should look like: refs/head/master + var gitOutput = shelljs.exec("git symbolic-ref HEAD").output; + var match = /refs\/heads\/(.*)/.exec(gitOutput); + if (!match) { + throw new Error('Could not parse branch name from: ' + gitOutput); + } + cdOutOf(); + return match[1]; +} + +function verifyNpmLinkOf(linkedModule, installedModule) { + cdInto(installedModule); + var linkedPath = shelljs.pwd() + path.sep + "node_modules" + path.sep + linkedModule; + if (fs.existsSync(linkedPath)) { + var myStat = fs.lstatSync(linkedPath); + if (!myStat.isSymbolicLink()) { + throw new Error('Module ' + linkedModule + ' installed in ' + installedModule + ' is not npm-linked. I recommend you run "coho npm-link".'); + } + } else { + throw new Error('Module ' + linkedModule + ' is not installed at all (direct or npm-linked) in ' + installedModule); + } + cdOutOf(); +} + +if (!argv.skiplink) { + console.log("Checking if you are using master branch of tools"); + // if js, lib, plugman, and cli have master checked out, should npm link. + var jsBranch = getBranchName("cordova-js"); + var libBranch = getBranchName("cordova-lib"); + var plugmanBranch = getBranchName("cordova-plugman"); + var cliBranch = getBranchName("cordova-cli"); + if ((jsBranch == "master") && (libBranch == "master") && (plugmanBranch == "master") && (cliBranch == "master")) { + // make sure the dependent modules are 'npm link'ed to each other, + // so they actually get tested instead of downloading the last published + // one from the npm registry. Fail if they are not. + console.log("You are on master branch of tools, checking npm links"); + verifyNpmLinkOf("cordova-js", "cordova-lib"); + verifyNpmLinkOf("cordova-lib", "cordova-plugman"); + verifyNpmLinkOf("cordova-lib", "cordova-cli"); + console.log("npm links are OK"); + } else { + console.log("Using non-master of one or more tools."); + } +} + ////////////////////// create the project for each platform function myDelete(myDir) {