cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From an-s...@apache.org
Subject cordova-coho git commit: CB-9782 Adds npm-link support for cordova-android
Date Tue, 20 Oct 2015 09:13:32 GMT
Repository: cordova-coho
Updated Branches:
  refs/heads/master a214d55c3 -> 69262bb5f


CB-9782 Adds npm-link support for cordova-android

Also ensures that `cordova-common` linked properly before creating release archive


Project: http://git-wip-us.apache.org/repos/asf/cordova-coho/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-coho/commit/69262bb5
Tree: http://git-wip-us.apache.org/repos/asf/cordova-coho/tree/69262bb5
Diff: http://git-wip-us.apache.org/repos/asf/cordova-coho/diff/69262bb5

Branch: refs/heads/master
Commit: 69262bb5fa1cc6ba8537cd3e8a9ba6f4a176fd22
Parents: a214d55
Author: Vladimir Kotikov <v-vlkoti@microsoft.com>
Authored: Mon Oct 12 16:42:16 2015 +0300
Committer: Vladimir Kotikov <v-vlkoti@microsoft.com>
Committed: Mon Oct 12 18:40:03 2015 +0300

----------------------------------------------------------------------
 src/create-verify-archive.js | 484 +++++++++++++++++++-------------------
 src/npm-link.js              | 203 ++++++++--------
 2 files changed, 347 insertions(+), 340 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-coho/blob/69262bb5/src/create-verify-archive.js
----------------------------------------------------------------------
diff --git a/src/create-verify-archive.js b/src/create-verify-archive.js
index 577dabb..3edf26b 100644
--- a/src/create-verify-archive.js
+++ b/src/create-verify-archive.js
@@ -1,239 +1,245 @@
-/*
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements.  See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership.  The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License.  You may obtain a copy of the License at
-
-http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing,
-software distributed under the License is distributed on an
-"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-KIND, either express or implied.  See the License for the
-specific language governing permissions and limitations
-under the License.
-*/
-
-var glob = require('glob');
-var optimist = require('optimist');
-var shelljs = require('shelljs');
-var chalk = require('chalk');
-var fs = require('fs');
-var path = require('path');
-var apputil = require('./apputil');
-var executil = require('./executil');
-var flagutil = require('./flagutil');
-var gitutil = require('./gitutil');
-var repoutil = require('./repoutil');
-var npm_link = require('./npm-link');
-var print = apputil.print;
-var settingUpGpg = path.resolve(path.dirname(__dirname), 'docs', 'setting-up-gpg.md');
-var isWin = process.platform === 'win32';
-
-exports.createCommand = function*(argv) {
-    var opt = flagutil.registerRepoFlag(optimist)
-    opt = opt
-        .options('tag', {
-            desc: 'The pre-existing tag or hash to archive (defaults to newest tag on branch)'
-         })
-        .options('allow-pending', {
-            desc: 'Whether to allow uncommitted changes to exist when packing (use only for
testing)',
-            type: 'boolean'
-         })
-        .options('sign', {
-            desc: 'Whether to create .asc, .md5, .sha files (defaults to true)',
-            type: 'boolean',
-            default: 'true'
-         })
-        .options('dest', {
-            desc: 'The directory to hold the resulting files.',
-            default: '.'
-         });
-    opt = flagutil.registerHelpFlag(opt);
-    var argv = opt
-        .usage('Creates a .zip, .asc, .md5, .sha for a repo at a tag or hash.\n' +
-               'Refer to ' + settingUpGpg + ' for how to set up gpg\n' +
-               '\n' +
-               'Usage: $0 create-archive [--tag tagname] [--sign] --repo=name [-r repos]
--dest cordova-dist-dev/CB-1111')
-        .argv;
-    // Optimist doesn't cast from string :(
-    argv.sign = argv.sign === true || argv.sign == 'true';
-    argv['allow-pending'] = argv['allow-pending'] === true || argv['allow-pending'] == 'true';
-
-    if (argv.h) {
-        optimist.showHelp();
-        process.exit(1);
-    }
-    var repos = flagutil.computeReposFromFlag(argv.r, {includeModules: true});
-
-    if (argv.sign && !shelljs.which('gpg')) {
-        apputil.fatal('gpg command not found on your PATH. Refer to ' + settingUpGpg);
-    }
-
-    var outDir = apputil.resolveUserSpecifiedPath(argv.dest);
-    shelljs.mkdir('-p', outDir);
-    var absOutDir = path.resolve(outDir);
-
-    yield repoutil.forEachRepo(repos, function*(repo) {
-        if(isWin) {
-            yield checkLineEndings(repo);
-        }
-
-        var tag = argv.tag || (yield gitutil.findMostRecentTag(repo.versionPrefix));
-        if (!tag) {
-            apputil.fatal('Could not find most recent tag. Try running with --tag');
-        }
-        if (!argv['allow-pending'] && (yield gitutil.pendingChangesExist())) {
-            apputil.fatal('Aborting because pending changes exist in ' + repo.repoName +
' (run "git status")');
-        }
-        var origBranch = yield gitutil.retrieveCurrentBranchName(true);
-
-        yield gitutil.gitCheckout(tag);
-        print('Creating archive of ' + repo.repoName + '@' + tag);
-
-        var outPath;
-        if (repo.id !=='mobile-spec') {
-            // Before doing an `npm pack` let's check if cordova-common is
-            // npm-linked to cordova-lib otherwise built package will be invalid
-            if (repo.id === 'lib') {
-                print('Verifying if "cordova-common" is npm-linked into "cordova-lib"');
-                apputil.setShellSilent(function () {
-                    shelljs.pushd(apputil.getBaseDir());
-                    if (!npm_link.verifyLink('cordova-common', 'cordova-lib')) {
-                        apputil.fatal('Module "cordova-common" is not properly npm-linked
into "cordova-lib". Run "coho npm-link" to ensure that the link set up properly.');
-                    }
-                    shelljs.popd();
-                });
-            }
-
-            var pkgInfo = require(path.resolve('package'));
-            var tgzname = pkgInfo.name + '-' + pkgInfo.version + '.tgz';
-
-            yield executil.execHelper(executil.ARGS('npm pack'), 1, false);
-            outPath = path.join(absOutDir, tgzname);
-            if (path.resolve(tgzname) != outPath) {
-                shelljs.rm('-f', outPath + "*");
-                shelljs.mv(tgzname, outPath);
-            }
-            print('Created archive: ' + outPath);
-        } else {
-            outPath = path.join(absOutDir, repo.repoName + '-' + tag + '.zip');
-            yield executil.execHelper(executil.ARGS('git archive --format zip --prefix '
+ repo.repoName + '/ -o ', outPath, tag));
-            print('Created archive: ' + outPath);
-        }
-
-        if (argv.sign) {
-            yield executil.execHelper(executil.ARGS('gpg --armor --detach-sig --output',
outPath + '.asc', outPath));
-            fs.writeFileSync(outPath + '.md5', (yield computeHash(outPath, 'MD5')) + '\n');
-            fs.writeFileSync(outPath + '.sha', (yield computeHash(outPath, 'SHA512')) + '\n');
-        }
-
-        if (origBranch) {
-            yield gitutil.gitCheckout(origBranch);
-        }
-    });
-    print();
-    print('Archives created.');
-    print('Verify them using: coho verify-archive ' + path.join(outDir, '*.tgz'));
-}
-
-exports.verifyCommand = function*() {
-    var opt = flagutil.registerHelpFlag(optimist);
-    var argv = opt
-        .usage('Ensures the given .zip files match their neighbouring .asc, .md5, .sha files.\n'
+
-               'Refer to ' + settingUpGpg + ' for how to set up gpg\n' +
-               '\n' +
-               'Usage: $0 verify-archive a.zip b.zip c.zip')
-        .argv;
-
-    var zipPaths = argv._.slice(1);
-    if (argv.h || !zipPaths.length) {
-        optimist.showHelp();
-        process.exit(1);
-    }
-    if (!shelljs.which('gpg')) {
-        apputil.fatal('gpg command not found on your PATH. Refer to ' + settingUpGpg);
-    }
-
-    var resolvedZipPaths = zipPaths.reduce(function (current, zipPath) {
-        var matchingPaths = glob.sync(apputil.resolveUserSpecifiedPath(zipPath));
-        if (!matchingPaths || !matchingPaths.length) {
-            apputil.fatal(chalk.red('No files found that match \'' + zipPath + '\''));
-        }
-        return current.concat(matchingPaths);
-    }, []);
-
-    for (var i = 0; i < resolvedZipPaths.length; ++i) {
-        var zipPath = resolvedZipPaths[i];
-        var result = yield executil.execHelper(executil.ARGS('gpg --verify', zipPath + '.asc',
zipPath), false, true);
-        if (result === null) {
-            apputil.fatal('Verification failed. You may need to update your keys. Run: curl
"https://dist.apache.org/repos/dist/release/cordova/KEYS" | gpg --import');
-        }
-        var md5 = yield computeHash(zipPath, 'MD5');
-        if (extractHashFromOutput(fs.readFileSync(zipPath + '.md5', 'utf8')) !== md5) {
-            apputil.fatal('MD5 does not match.');
-        }
-        var sha = yield computeHash(zipPath, 'SHA512');
-        if (extractHashFromOutput(fs.readFileSync(zipPath + '.sha', 'utf8')) !== sha) {
-            apputil.fatal('SHA512 does not match.');
-        }
-        print(zipPath + chalk.green(' signature and hashes verified.'));
-    }
-    print(chalk.green('Verified ' + resolvedZipPaths.length + ' signatures and hashes.'));
-};
-
-function *computeHash(path, algo) {
-    print('Computing ' + algo + ' for: ' + path);
-    var result = yield executil.execHelper(executil.ARGS('gpg --print-md', algo, path), true);
-    return extractHashFromOutput(result);
-}
-
-function extractHashFromOutput(output) {
-    return output.slice(output.lastIndexOf(':') + 1).replace(/\s*/g, '').toLowerCase();
-}
-
-function *checkLineEndings(repo) {
-    var autoCRLF;
-    var eol;
-    var msg = '';
-
-    try {
-        autoCRLF = yield executil.execHelper(executil.ARGS('git config --get core.autocrlf'),
true);
-    } catch(e) {
-        autoCRLF = '';
-    }
-
-    try {
-        eol = yield executil.execHelper(executil.ARGS('git config --get core.eol'), true);
-    } catch(e) {
-        eol = '';
-    }
-
-    if(autoCRLF !== 'false') {
-        msg = 'Warning: core.autocrlf is set to "' + autoCRLF + '".\n' +
-            'Set either "' + repo.repoName + '" or global core.autocrlf setting to "false"
to avoid issues with executables on non-Windows OS.\n';
-    }
-
-    if(eol !== 'lf') {
-        msg += 'Warning: core.eol is set to "' + eol + '". Set it to "lf" to normalize line
endings.\n';
-    }
-
-    if(!!msg) {
-        console.error(msg +
-            'Run these commands in the repos:\n' +
-            '    git config core.eol lf\n' +
-            '    git config core.autocrlf false\n' +
-            '    git rm --cached -r .\n' +
-            '    git reset --hard\n' +
-            'Alternatively you can setup it globally for your user:\n' +
-            '    git config --global core.eol lf\n' +
-            '    git config --global core.autocrlf false\n' +
-            'Or update the repos automatically using coho (change the repo groups to your
ones):\n' +
-            '   coho for-each -r tools -r android -r ios -r windows "git config core.eol
lf && git config core.autocrlf false && git rm --cached -r . && git
reset --hard"');
-
-        process.exit(1);
-    }
-}
+/*
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+*/
+
+var glob = require('glob');
+var optimist = require('optimist');
+var shelljs = require('shelljs');
+var chalk = require('chalk');
+var fs = require('fs');
+var path = require('path');
+var apputil = require('./apputil');
+var executil = require('./executil');
+var flagutil = require('./flagutil');
+var gitutil = require('./gitutil');
+var repoutil = require('./repoutil');
+var npm_link = require('./npm-link');
+var print = apputil.print;
+var settingUpGpg = path.resolve(path.dirname(__dirname), 'docs', 'setting-up-gpg.md');
+var isWin = process.platform === 'win32';
+
+exports.createCommand = function*(argv) {
+    var opt = flagutil.registerRepoFlag(optimist)
+    opt = opt
+        .options('tag', {
+            desc: 'The pre-existing tag or hash to archive (defaults to newest tag on branch)'
+         })
+        .options('allow-pending', {
+            desc: 'Whether to allow uncommitted changes to exist when packing (use only for
testing)',
+            type: 'boolean'
+         })
+        .options('sign', {
+            desc: 'Whether to create .asc, .md5, .sha files (defaults to true)',
+            type: 'boolean',
+            default: 'true'
+         })
+        .options('dest', {
+            desc: 'The directory to hold the resulting files.',
+            default: '.'
+         });
+    opt = flagutil.registerHelpFlag(opt);
+    var argv = opt
+        .usage('Creates a .zip, .asc, .md5, .sha for a repo at a tag or hash.\n' +
+               'Refer to ' + settingUpGpg + ' for how to set up gpg\n' +
+               '\n' +
+               'Usage: $0 create-archive [--tag tagname] [--sign] --repo=name [-r repos]
--dest cordova-dist-dev/CB-1111')
+        .argv;
+    // Optimist doesn't cast from string :(
+    argv.sign = argv.sign === true || argv.sign == 'true';
+    argv['allow-pending'] = argv['allow-pending'] === true || argv['allow-pending'] == 'true';
+
+    if (argv.h) {
+        optimist.showHelp();
+        process.exit(1);
+    }
+    var repos = flagutil.computeReposFromFlag(argv.r, {includeModules: true});
+
+    if (argv.sign && !shelljs.which('gpg')) {
+        apputil.fatal('gpg command not found on your PATH. Refer to ' + settingUpGpg);
+    }
+
+    var outDir = apputil.resolveUserSpecifiedPath(argv.dest);
+    shelljs.mkdir('-p', outDir);
+    var absOutDir = path.resolve(outDir);
+
+    yield repoutil.forEachRepo(repos, function*(repo) {
+        if(isWin) {
+            yield checkLineEndings(repo);
+        }
+
+        var tag = argv.tag || (yield gitutil.findMostRecentTag(repo.versionPrefix));
+        if (!tag) {
+            apputil.fatal('Could not find most recent tag. Try running with --tag');
+        }
+        if (!argv['allow-pending'] && (yield gitutil.pendingChangesExist())) {
+            apputil.fatal('Aborting because pending changes exist in ' + repo.repoName +
' (run "git status")');
+        }
+        var origBranch = yield gitutil.retrieveCurrentBranchName(true);
+
+        yield gitutil.gitCheckout(tag);
+        print('Creating archive of ' + repo.repoName + '@' + tag);
+
+        var outPath;
+        if (repo.id !=='mobile-spec') {
+            // Before doing an `npm pack` let's check if link to cordova-common
+            // is set up (if required) otherwise built package will be invalid
+            validateLinksForRepo(repo);
+
+            var pkgInfo = require(path.resolve('package'));
+            var tgzname = pkgInfo.name + '-' + pkgInfo.version + '.tgz';
+
+            yield executil.execHelper(executil.ARGS('npm pack'), 1, false);
+            outPath = path.join(absOutDir, tgzname);
+            if (path.resolve(tgzname) != outPath) {
+                shelljs.rm('-f', outPath + "*");
+                shelljs.mv(tgzname, outPath);
+            }
+            print('Created archive: ' + outPath);
+        } else {
+            outPath = path.join(absOutDir, repo.repoName + '-' + tag + '.zip');
+            yield executil.execHelper(executil.ARGS('git archive --format zip --prefix '
+ repo.repoName + '/ -o ', outPath, tag));
+            print('Created archive: ' + outPath);
+        }
+
+        if (argv.sign) {
+            yield executil.execHelper(executil.ARGS('gpg --armor --detach-sig --output',
outPath + '.asc', outPath));
+            fs.writeFileSync(outPath + '.md5', (yield computeHash(outPath, 'MD5')) + '\n');
+            fs.writeFileSync(outPath + '.sha', (yield computeHash(outPath, 'SHA512')) + '\n');
+        }
+
+        if (origBranch) {
+            yield gitutil.gitCheckout(origBranch);
+        }
+    });
+    print();
+    print('Archives created.');
+    print('Verify them using: coho verify-archive ' + path.join(outDir, '*.tgz'));
+}
+
+exports.verifyCommand = function*() {
+    var opt = flagutil.registerHelpFlag(optimist);
+    var argv = opt
+        .usage('Ensures the given .zip files match their neighbouring .asc, .md5, .sha files.\n'
+
+               'Refer to ' + settingUpGpg + ' for how to set up gpg\n' +
+               '\n' +
+               'Usage: $0 verify-archive a.zip b.zip c.zip')
+        .argv;
+
+    var zipPaths = argv._.slice(1);
+    if (argv.h || !zipPaths.length) {
+        optimist.showHelp();
+        process.exit(1);
+    }
+    if (!shelljs.which('gpg')) {
+        apputil.fatal('gpg command not found on your PATH. Refer to ' + settingUpGpg);
+    }
+
+    var resolvedZipPaths = zipPaths.reduce(function (current, zipPath) {
+        var matchingPaths = glob.sync(apputil.resolveUserSpecifiedPath(zipPath));
+        if (!matchingPaths || !matchingPaths.length) {
+            apputil.fatal(chalk.red('No files found that match \'' + zipPath + '\''));
+        }
+        return current.concat(matchingPaths);
+    }, []);
+
+    for (var i = 0; i < resolvedZipPaths.length; ++i) {
+        var zipPath = resolvedZipPaths[i];
+        var result = yield executil.execHelper(executil.ARGS('gpg --verify', zipPath + '.asc',
zipPath), false, true);
+        if (result === null) {
+            apputil.fatal('Verification failed. You may need to update your keys. Run: curl
"https://dist.apache.org/repos/dist/release/cordova/KEYS" | gpg --import');
+        }
+        var md5 = yield computeHash(zipPath, 'MD5');
+        if (extractHashFromOutput(fs.readFileSync(zipPath + '.md5', 'utf8')) !== md5) {
+            apputil.fatal('MD5 does not match.');
+        }
+        var sha = yield computeHash(zipPath, 'SHA512');
+        if (extractHashFromOutput(fs.readFileSync(zipPath + '.sha', 'utf8')) !== sha) {
+            apputil.fatal('SHA512 does not match.');
+        }
+        print(zipPath + chalk.green(' signature and hashes verified.'));
+    }
+    print(chalk.green('Verified ' + resolvedZipPaths.length + ' signatures and hashes.'));
+};
+
+function *computeHash(path, algo) {
+    print('Computing ' + algo + ' for: ' + path);
+    var result = yield executil.execHelper(executil.ARGS('gpg --print-md', algo, path), true);
+    return extractHashFromOutput(result);
+}
+
+function extractHashFromOutput(output) {
+    return output.slice(output.lastIndexOf(':') + 1).replace(/\s*/g, '').toLowerCase();
+}
+
+function *checkLineEndings(repo) {
+    var autoCRLF;
+    var eol;
+    var msg = '';
+
+    try {
+        autoCRLF = yield executil.execHelper(executil.ARGS('git config --get core.autocrlf'),
true);
+    } catch(e) {
+        autoCRLF = '';
+    }
+
+    try {
+        eol = yield executil.execHelper(executil.ARGS('git config --get core.eol'), true);
+    } catch(e) {
+        eol = '';
+    }
+
+    if(autoCRLF !== 'false') {
+        msg = 'Warning: core.autocrlf is set to "' + autoCRLF + '".\n' +
+            'Set either "' + repo.repoName + '" or global core.autocrlf setting to "false"
to avoid issues with executables on non-Windows OS.\n';
+    }
+
+    if(eol !== 'lf') {
+        msg += 'Warning: core.eol is set to "' + eol + '". Set it to "lf" to normalize line
endings.\n';
+    }
+
+    if(!!msg) {
+        console.error(msg +
+            'Run these commands in the repos:\n' +
+            '    git config core.eol lf\n' +
+            '    git config core.autocrlf false\n' +
+            '    git rm --cached -r .\n' +
+            '    git reset --hard\n' +
+            'Alternatively you can setup it globally for your user:\n' +
+            '    git config --global core.eol lf\n' +
+            '    git config --global core.autocrlf false\n' +
+            'Or update the repos automatically using coho (change the repo groups to your
ones):\n' +
+            '   coho for-each -r tools -r android -r ios -r windows "git config core.eol
lf && git config core.autocrlf false && git rm --cached -r . && git
reset --hard"');
+
+        process.exit(1);
+    }
+}
+
+function validateLinksForRepo (repo) {
+    // Ve only want to check links in some particular repos
+    if (['lib', 'android'].indexOf(repo.id) === -1) return;
+
+    print('Verifying if "cordova-common" is npm-linked into "' + repo.repoName + '"');
+    apputil.setShellSilent(function () {
+        shelljs.pushd(apputil.getBaseDir());
+        if (!npm_link.verifyLink('cordova-common', repo.repoName)) {
+            apputil.fatal('Module "cordova-common" is not properly npm-linked into "' + repo.repoName
+
+                '". Run "coho npm-link" to ensure that the link set up properly.');
+        }
+        shelljs.popd();
+    });
+}

http://git-wip-us.apache.org/repos/asf/cordova-coho/blob/69262bb5/src/npm-link.js
----------------------------------------------------------------------
diff --git a/src/npm-link.js b/src/npm-link.js
index 244b581..d55bd08 100644
--- a/src/npm-link.js
+++ b/src/npm-link.js
@@ -1,101 +1,102 @@
-/*
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements.  See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership.  The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License.  You may obtain a copy of the License at
-
-http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing,
-software distributed under the License is distributed on an
-"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-KIND, either express or implied.  See the License for the
-specific language governing permissions and limitations
-under the License.
-*/
-
-var fs = require('fs');
-var path = require('path');
-var optimist = require('optimist');
-var shelljs = require('shelljs');
-var flagutil = require('./flagutil');
-
-function *createLink(argv) {
-    var opt = flagutil.registerHelpFlag(optimist);
-    argv = opt
-        .usage('Does an npm-link of the modules that we publish. Ensures we are testing live
versions of our own dependencies instead of the last published version.\n' +
-               '\n' +
-               'Usage: $0 npm-link')
-        .argv;
-
-    if (argv.h) {
-        optimist.showHelp();
-        process.exit(1);
-    }
-
-    function npmLinkIn(linkedModule, installingModule) {
-       cdInto(installingModule);
-       // 'npm link' will automatically unbuild a non-linked module if it is present,
-       // so don't need to explicitly 'rm -r' it first.
-       shelljs.exec("npm link " + linkedModule);
-       cdOutOf();
-    }
-
-    function npmLinkOut(moduleName) {
-        cdInto(moduleName);
-        shelljs.exec("npm link");
-        cdOutOf();
-    }
-
-    console.log("npm-linking dependent modules");
-
-    npmLinkOut("cordova-js");
-    npmLinkIn("cordova-js", "cordova-lib");
-
-    npmLinkOut("cordova-common");
-    npmLinkIn("cordova-common", "cordova-lib");
-
-    npmLinkOut("cordova-lib");
-    npmLinkIn("cordova-lib", "cordova-plugman");
-    npmLinkIn("cordova-lib", "cordova-cli");
-}
-
-module.exports = createLink;
-
-function getPathFromModuleName(moduleName) {
-    if (moduleName == "cordova-lib" || moduleName == "cordova-common") {
-        return("cordova-lib" + path.sep + moduleName);
-    }
-
-    return(moduleName);
-}
-
-function cdInto(moduleName) {
-    var myPath = getPathFromModuleName(moduleName);
-    shelljs.pushd(myPath);
-}
-
-function cdOutOf() {
-    shelljs.popd();
-}
-
-function verifyLink (linkedModule, installedModule) {
-    cdInto(installedModule);
-    var linkedPath = path.join(shelljs.pwd(), "node_modules", linkedModule);
-    if (!fs.existsSync(linkedPath)) {
-        return false;
-    }
-
-    var myStat = fs.lstatSync(linkedPath);
-    if (!myStat.isSymbolicLink()) {
-        return false;
-    }
-
-    cdOutOf();
-    return true;
-}
-
-module.exports.verifyLink = verifyLink;
+/*
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+*/
+
+var fs = require('fs');
+var path = require('path');
+var optimist = require('optimist');
+var shelljs = require('shelljs');
+var flagutil = require('./flagutil');
+
+function *createLink(argv) {
+    var opt = flagutil.registerHelpFlag(optimist);
+    argv = opt
+        .usage('Does an npm-link of the modules that we publish. Ensures we are testing live
versions of our own dependencies instead of the last published version.\n' +
+               '\n' +
+               'Usage: $0 npm-link')
+        .argv;
+
+    if (argv.h) {
+        optimist.showHelp();
+        process.exit(1);
+    }
+
+    function npmLinkIn(linkedModule, installingModule) {
+       cdInto(installingModule);
+       // 'npm link' will automatically unbuild a non-linked module if it is present,
+       // so don't need to explicitly 'rm -r' it first.
+       shelljs.exec("npm link " + linkedModule);
+       cdOutOf();
+    }
+
+    function npmLinkOut(moduleName) {
+        cdInto(moduleName);
+        shelljs.exec("npm link");
+        cdOutOf();
+    }
+
+    console.log("npm-linking dependent modules");
+
+    npmLinkOut("cordova-js");
+    npmLinkIn("cordova-js", "cordova-lib");
+
+    npmLinkOut("cordova-common");
+    npmLinkIn("cordova-common", "cordova-lib");
+    npmLinkIn("cordova-common", "cordova-android");
+
+    npmLinkOut("cordova-lib");
+    npmLinkIn("cordova-lib", "cordova-plugman");
+    npmLinkIn("cordova-lib", "cordova-cli");
+}
+
+module.exports = createLink;
+
+function getPathFromModuleName(moduleName) {
+    if (moduleName == "cordova-lib" || moduleName == "cordova-common") {
+        return("cordova-lib" + path.sep + moduleName);
+    }
+
+    return(moduleName);
+}
+
+function cdInto(moduleName) {
+    var myPath = getPathFromModuleName(moduleName);
+    shelljs.pushd(myPath);
+}
+
+function cdOutOf() {
+    shelljs.popd();
+}
+
+function verifyLink (linkedModule, installedModule) {
+    cdInto(installedModule);
+    var linkedPath = path.join(shelljs.pwd(), "node_modules", linkedModule);
+    if (!fs.existsSync(linkedPath)) {
+        return false;
+    }
+
+    var myStat = fs.lstatSync(linkedPath);
+    if (!myStat.isSymbolicLink()) {
+        return false;
+    }
+
+    cdOutOf();
+    return true;
+}
+
+module.exports.verifyLink = verifyLink;


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


Mime
View raw message