Merge master into janpio-repaire_plugin_interactive
diff --git a/.travis.yml b/.travis.yml
index 29b0192..7fa7de6 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -2,12 +2,13 @@
sudo: false
node_js:
- - "6"
- - "8"
- - "10"
+ - 6
+ - 8
+ - 10
+ - 12
install:
- - "npm install"
+ - npm install
script:
- - "npm test"
+ - npm test
diff --git a/README.md b/README.md
index 7b3da93..06a3dd4 100644
--- a/README.md
+++ b/README.md
@@ -100,7 +100,7 @@
### Note about global context
-Note that for some commands you may need to use the `-g` or `--global` flag to work in an npm global context, since coho was originally designed for use in another context.
+By default `coho` is executed in the parent of where it is installed or checked out (since coho was originally designed for use in another context where this was needed). To work in a global context, meaning the current folder where you are executing `coho`, most commands require you to use the `-g` or `--global` flag. To make this more obvious, all commands first output their current working directory: `Running from ...`.
## Contributing
diff --git a/appveyor.yml b/appveyor.yml
index f34dfbd..6fd0acd 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -3,9 +3,14 @@
environment:
matrix:
- - nodejs_version: "6"
- - nodejs_version: "8"
- - nodejs_version: "10"
+ - nodejs_version: 6
+ - nodejs_version: 8
+ - nodejs_version: 10
+ - nodejs_version: 12
+
+matrix:
+ allow_failures:
+ - nodejs_version: 12
install:
- ps: Install-Product node $env:nodejs_version
diff --git a/docs/platforms-release-process.md b/docs/platforms-release-process.md
index 69abc5d..d50f81d 100644
--- a/docs/platforms-release-process.md
+++ b/docs/platforms-release-process.md
@@ -21,24 +21,22 @@
# Release Process for Cordova Platforms
-This page describes the technical steps for doing a `Platforms Release`.
+This page describes the technical steps for doing a Platforms Release.
## Table of contents
-It describes the following steps:
-
- [General instructions](#general-instructions)
* [Read first](#read-first)
* [Repository setup](#repository-setup)
- [Before you start](#before-you-start)
- * [Read through Apache release policy](#read-through-apache-release-policy)
+ * [Choose a Release Identifier](#choose-a-release-identifier)
* [Request buy-in](#request-buy-in)
- [Before Release](#before-release)
- * [npm audit check](#npm-audit-check)
+ * [Make sure you're up-to-date](#make-sure-youre-up-to-date)
* [Check dependencies](#check-dependencies)
- * [Resolve any outdated dependencies](#resolve-any-outdated-dependencies)
+ - [Resolve any outdated dependencies](#resolve-any-outdated-dependencies)
+ * [`npm audit` check](#npm-audit-check)
* [License Check](#license-check)
- * [Create JIRA issue](#create-jira-issue)
- [Prepare Release](#prepare-release)
* [Optional: Set release version in `package.json`](#optional-set-release-version-in-packagejson)
- [Remove the `-dev` suffix from version](#remove-the--dev-suffix-from-version)
@@ -56,7 +54,7 @@
* [4) `cordova-lib` tests](#4-cordova-lib-tests)
* [5) Clean up](#5-clean-up)
* [When a regression is found](#when-a-regression-is-found)
- * [To submit a fix](#to-submit-a-fix)
+ - [To submit a fix](#to-submit-a-fix)
- [Push Changes](#push-changes)
* [Push commits](#push-commits)
* [Tag and push tag](#tag-and-push-tag)
@@ -68,14 +66,13 @@
* [Start VOTE Thread](#start-vote-thread)
* [Email the result of the vote](#email-the-result-of-the-vote)
* [If the Vote does *not* Pass](#if-the-vote-does-not-pass)
- * [Otherwise: Publish real release to `dist/` & npm](#otherwise-publish-real-release-to-dist--npm)
+ * [Otherwise: Publish release to `dist/` & npm](#otherwise-publish-release-to-dist--npm)
* [(Android only) Uploading to Bintray](#android-only-uploading-to-bintray)
* [Add permanent Apache release tag to repository](#add-permanent-apache-release-tag-to-repository)
- [Follow up steps](#follow-up-steps)
* [Tell Apache about Release](#tell-apache-about-release)
* [Email a release announcement to the mailing list](#email-a-release-announcement-to-the-mailing-list)
* [Announce It!](#announce-it)
- * [Close JIRA issue](#close-jira-issue)
* [Finally](#finally)
- [Other stuff that should be reviewed and moved up to the appropriate places](#other-stuff-that-should-be-reviewed-and-moved-up-to-the-appropriate-places)
* [Update the Docs](#update-the-docs)
@@ -83,7 +80,6 @@
<!-- created with https://ecotrust-canada.github.io/markdown-toc/ and some manual fixing -->
-(Yes this list is long and scary, but represents the content below)
## General instructions
@@ -98,11 +94,22 @@
You should have your platform repository checked out in a folder where you also have checked out all/most/some of the other Cordova repositories. If you followed the [Cloning/Updating Cordova repositories
](../README.md#cloningupdating-cordova-repositories) instructions of `cordova-coho`, this should already be the case.
+
## Before you start
-### Read through Apache release policy
-Read through the [Apache Releases Policy](http://www.apache.org/dev/release) as stated above.
+### Choose a Release Identifier
+
+Releases are identified by a "Release Identifier" that is used in commit messages and for temporary folders.
+
+Good choices are unique and have a direct relation to the release you are about to perform. Examples for valid identifiers would be `android20190506` or `android@503`. You can also create a release issue and use that (including the repository name): `cordova-android#123`.
+
+Then set it as an environment variable:
+
+```
+RELEASE=android20190506
+echo $RELEASE
+```
### Request buy-in
@@ -121,19 +128,16 @@
Note that it would be possible to continue with some of the [Before Release](#before-release) items while waiting for a possible response.
+
## Before Release
-### npm audit check
-
-Ensure that the latest version of npm is installed (using a command such as `npm i npm@latest`), `package-lock.json` is present (do `npm i --package-lock-only` if needed), and then check:
-
- (cd cordova-android && npm audit)
-
-### Check dependencies
+### Make sure you're up-to-date
Ensure your checkout of the repository is up-to-date:
- coho repo-update -r android
+ coho repo-update -r android # updates the repos
+
+### Check dependencies
See if any dependencies are outdated
@@ -141,16 +145,24 @@
(The `--depth=0` prevents from listing dependencies of dependencies.)
-### Resolve any outdated dependencies
+#### Resolve any outdated dependencies
**Alternative 1:**
- Explicitly pin the outdated dependency versions in the `dependencies` section of `package.json`.
-- Raise a new JIRA issue to update the dependencies in an upcoming release.
+- Raise a new issue to update the dependencies in an upcoming release.
**Alternative 2:**
-Within a new JIRA issue: update any outdated dependencies in the project's `package.json` file. Be sure to run through the test section below for compatibility issues.
+Within a new Pull Request: update any outdated dependencies in the project's `package.json` file. Be sure to run through the test section below for compatibility issues.
+
+### `npm audit` check
+
+Ensure that the latest version of npm is installed (using a command such as `npm i npm@latest`), `package-lock.json` is present (do `npm i --package-lock-only` if needed), and then check:
+
+ (cd cordova-android && npm audit)
+
+TODO Get rid of package-lock.json afterwards
### License Check
@@ -162,21 +174,6 @@
coho check-license -r android
-### Create JIRA issue
-
-After waiting for any possible objections from the email sent according to the [Request buy-in](#request-buy-in) section above:
-
- * Create a JIRA issue to track the status of the release.
- - Make it of type "Task"
- - Title should be "Cordova-Android Platform Release _August 21, 2014_"
- - Description should be: "Following steps at https://github.com/apache/cordova-coho/blob/master/docs/platforms-release-process.md"
- * Comments should be added to this bug after each top-level step below is taken
- * Set a variable in your terminal for use later on
-
-
-```
-JIRA="CB-????" # Set this to the release bug.
-```
## Prepare Release
@@ -211,6 +208,7 @@
coho update-release-notes -r android
(`--from-tag` and/or `--to-tag` may be needed in case of non-master branch)
+TODO what does that mean? Examples.
Then curate:
@@ -222,9 +220,9 @@
Commit these changes together in a single commit (one commit).
- (cd cordova-android && v="$(grep '"version"' package.json | cut -d'"' -f4)" && git commit -am "$JIRA Update RELEASENOTES & version for release $v")
+ (cd cordova-android && v="$(grep '"version"' package.json | cut -d'"' -f4)" && git commit -am "Update RELEASENOTES & version for release $v ($RELEASE)")
-(Should be "$JIRA Update RELEASENOTES.md for release $v" in case `version` is not yet updated in `package.json`.)
+(Should be `Update RELEASENOTES.md for release $v ($RELEASE)` in case `version` is not yet updated in `package.json`.)
### Special Case 1: Release notes in release branch for patch release
@@ -246,7 +244,7 @@
1. Creates a release branch `5.0.x` (if it doesn't already exist)
2. Updates `cordova.js` snapshot on both `5.0.x` and `master`
3. Propagates version number from `--version` argument (or from `package.json` if there is no `--version` argument) to all other files (`VERSION` and similar [e.g. `build.gradle` for Android]) on the release branch `5.0.x`
-4. Prepares `master` for future development already: It gives version (`package.json`, `VERSION` and similar) a minor bump and adds `-dev` (=> `5.1.0-dev`) again
+4. Prepares `master` for future development already: It gives version (`package.json`, `VERSION` and similar) a minor bump and adds `-dev` (=> `5.1.0-dev`) back
Run the following command (make sure to replace the version below with what is listed inside `package.json`).
@@ -322,9 +320,9 @@
### When a regression is found
-Create a JIRA issue for it, and mark it as a blocker.
+Create an issue for it and fix it via a Pull Request before continuing.
-### To submit a fix
+#### To submit a fix
git checkout master
git commit -am 'Your commit message'
@@ -372,15 +370,15 @@
Create archives from your tags:
- coho create-archive -r android --dest cordova-dist-dev/$JIRA --tag 5.0.0
+ coho create-archive -r android --dest cordova-dist-dev/$RELEASE --tag 5.0.0
Sanity Check:
- coho verify-archive cordova-dist-dev/$JIRA/*.tgz
+ coho verify-archive cordova-dist-dev/$RELEASE/*.tgz
Upload:
- (cd cordova-dist-dev && svn add $JIRA && svn commit -m "$JIRA Uploading release candidates for android release")
+ (cd cordova-dist-dev && svn add $RELEASE && svn commit -m "Uploading release candidates for android release ($RELEASE)")
If everything went well the Release Candidate will show up here: https://dist.apache.org/repos/dist/dev/cordova/
@@ -414,10 +412,8 @@
Please review and vote on this 5.0.0 Android Release
by replying to this email (and keep discussion on the DISCUSS thread)
- Release issue: https://issues.apache.org/jira/browse/CB-XXXX
-
The archive has been published to dist/dev:
- https://dist.apache.org/repos/dist/dev/cordova/CB-XXXX
+ https://dist.apache.org/repos/dist/dev/cordova/XXX/
The package was published from its corresponding git tag:
### PASTE OUTPUT OF: coho print-tags -r android --tag 5.0.0 ###
@@ -472,10 +468,11 @@
* Revert adding of `-dev`
* Address the concerns
* Re-tag release using `git tag -f`
+TODO this seems to be missing a few steps here
* Add back `-dev`
* Start a new vote
-### Otherwise: Publish real release to `dist/` & npm
+### Otherwise: Publish release to `dist/` & npm
First move the release package files to `dist/`:
@@ -484,9 +481,9 @@
cd cordova-dist
svn up
svn rm platforms/cordova-android*
- cp ../cordova-dist-dev/$JIRA/cordova-android* platforms/
+ cp ../cordova-dist-dev/$RELEASE/cordova-android* platforms/
svn add platforms/cordova-android*
- svn commit -m "$JIRA Published android release to dist"
+ svn commit -m "Published android release to dist ($RELEASE)"
Now you can find your release here: https://dist.apache.org/repos/dist/release/cordova/
@@ -494,11 +491,11 @@
cd ../cordova-dist-dev
svn up
- svn rm $JIRA
- svn commit -m "$JIRA Removing release candidates from dist/dev"
+ svn rm $RELEASE
+ svn commit -m "Removing release candidates from dist/dev ($RELEASE)"
cd ..
-And finally you can publish your package to `npm`:
+And finally you can publish your package to npm:
cd cordova-dist
npm publish platforms/cordova-android-5.0.0.tgz
@@ -559,11 +556,6 @@
* Publish the release blog post
* Tweet it on https://twitter.com/apachecordova
-### Close JIRA Issue
-
-- Double check that the issue includes comments that record the steps you took
-- Mark it as fixed
-
### Finally
- Update these instructions if they were missing anything.
diff --git a/docs/plugins-release-process.md b/docs/plugins-release-process.md
index b3b0516..ef2be5e 100644
--- a/docs/plugins-release-process.md
+++ b/docs/plugins-release-process.md
@@ -19,34 +19,80 @@
#
-->
-# Release Process for ''Core Plugins''
+# Release Process for Cordova Core Plugins
-Before cutting any releases, read the Apache's [Releases Policy](http://www.apache.org/dev/release)
+This page describes the steps for doing a Plugins Release.
-If you have not done so already, create a GPG key (see: [setting-up-gpg.md](setting-up-gpg.md)).
+## Table of Contents
-Core Plugins are released at most weekly (see: [versioning-and-release-strategy.md](versioning-and-release-strategy.md)).
+- [General Instructions](#general-instructions)
+ * [Read first](#read-first)
+ * [Repository setup](#repository-setup)
+- [Interactive Plugins Release](#interactive-plugins-release)
+- [Manual](#manual)
+ * [Before you start](#before-you-start)
+ + [Identify which plugins have changes](#identify-which-plugins-have-changes)
+ + [Choose a Release Identifier](#choose-a-release-identifier)
+ + [Request buy-in](#request-buy-in)
+ * [Before Release](#before-release)
+ + [Make sure you're up-to-date](#make-sure-youre-up-to-date)
+ + [Check dependencies](#check-dependencies)
+ - [Resolve any outdated dependencies](#resolve-any-outdated-dependencies)
+ + [`npm audit` check](#npm-audit-check)
+ + [License Check](#license-check)
+ * [Prepare Release](#prepare-release)
+ + [Update Version](#update-version)
+ + [Create Release Notes](#create-release-notes)
+ + [Commit Release Notes and optional version changes together](#commit-release-notes-and-optional-version-changes-together)
+ * [Testing](#testing)
+ * [Push Changes](#push-changes)
+ + [Tag](#tag)
+ + [Create Release Branch](#create-release-branch)
+ + [Update version to add back `-dev` suffix](#update-version-to-add-back--dev-suffix)
+ + [Push tags, branches and changes](#push-tags-branches-and-changes)
+ * [Publish Release Candidate to `dist/dev`](#publish-release-candidate-to-distdev)
+ * [Documentation and Communication](#documentation-and-communication)
+ + [Prepare Blog Post](#prepare-blog-post)
+ * [Voting and Release](#voting-and-release)
+ + [Start VOTE Thread](#start-vote-thread)
+ + [Voting](#voting)
+ + [Email the result of the vote](#email-the-result-of-the-vote)
+ + [If the Vote does *not* Pass](#if-the-vote-does-not-pass)
+ + [Otherwise: Publish release to `dist/` & npm](#otherwise-publish-release-to-dist--npm)
+ + [Add permanent Apache release tag to repository](#add-permanent-apache-release-tag-to-repository)
+ * [Follow up steps](#follow-up-steps)
+ + [Tell Apache about Release](#tell-apache-about-release)
+ + [Publish the prepared blog post](#publish-the-prepared-blog-post)
+ + [Email a release announcement to the mailing list](#email-a-release-announcement-to-the-mailing-list)
+ + [Finally:](#finally)
-A plugins release is performed by a single person each week. We call this person the "Release Manager". How to select the Release Manager is still TDB.
+<!--<small><i><a href='http://ecotrust-canada.github.io/markdown-toc/'>Table of contents generated with markdown-toc</a></i></small>-->
-TODO: We may want to be using [signed tags](http://git-scm.com/book/en/Git-Basics-Tagging), or at least annotated tags.
-TODO: Add step about ensuring plugman owner
- * Note: can base this on: https://github.com/MobileChromeApps/mobile-chrome-apps/blob/master/dev-bin/check-published-plugin.js
+## General Instructions
-TODO: Add step about releasing cordova-plugins
+### Read first
-TODO: Should not mention testing other than checking medic
+- Before cutting any releases, read the Apache's [Releases Policy](http://www.apache.org/dev/release)
+- If you have not done so already, create a GPG key (see: [setting-up-gpg.md](setting-up-gpg.md)).
+- Core Plugins are released at most weekly (see: [versioning-and-release-strategy.md](versioning-and-release-strategy.md)).
-# Interactive Plugins Release
+Important: This whole release process does _not_ work in **Windows** Command Prompt or Powershell. If you really want to do this release process on Windows, you have to use [Git Bash](https://gitforwindows.org/#bash) or similar.
-Though we are still working out some kinks, it is recommended to try the new coho interactive plugins release command which will handle many of the manual steps listed below.
+### Repository setup
+
+You should have your platform repository checked out in a folder where you also have checked out all/most/some of the other Cordova repositories. If you followed the [Cloning/Updating Cordova repositories
+](../README.md#cloningupdating-cordova-repositories) instructions of `cordova-coho`, and used `coho repo-clone`, this should already be the case.
+
+## Interactive Plugins Release
+
+The coho interactive plugins release command which will handle many of the manual steps listed below.
`coho prepare-plugins-release`
This will do the following:
-* Create JIRA issue
+* Ask for Release Identifier
* Update repos
* Let you select which repos to release
* Let you modify release notes and finalize version to release
@@ -54,157 +100,280 @@
* Increment version on master with `-dev`
* Create svn dist archives for you to share with the cordova list for voting purposes.
-# Manual
+(Caution: This interactive process still has some kinks)
+
+## Manual
Try to the interactive plugins release process. If you struggle with, use the manual process which is documented below.
-## Get Buy-in
- 1. Email the dev mailing-list and see if anyone has reason to postpone the release.
- * Subject should be "[DISCUSS] Plugins release
- * If so, agree upon a branching date / time.
+### Before you start
-## Create JIRA issues
+#### Identify which plugins have changes
- * Create a JIRA issue to track the status of the release.
- * Make it of type "Task"
- * Subject should be "Plugins Release _Feb 2, 2014_" (Use the current date, not the expected release date)
- * Description should be: "Following steps at https://github.com/apache/cordova-coho/blob/master/docs/plugins-release-process.md"
- * Assignee should be the Release Manager
- * Comments should be added to this bug after each top-level step below is taken
- * Set an environment variable in your terminal for use later on:
-
-
- JIRA="CB-????" # Set this to the release bug.
-
-
-## Make sure you're up-to-date
-
- # Update your repos
- coho repo-status -r plugins -b master
- coho repo-update -r plugins
- coho repo-clone -r plugins
- coho foreach -r plugins "git checkout master"
-
-## Identify which plugins have changes
+This whole process depends on the `ACTIVE` environment variable being set and containing a list of the plugins you want to release. This command can automatically select the plugins that need a release:
ACTIVE=$(for l in cordova-plugin-*; do ( cd $l; last_release=$(git describe --tags --abbrev=0 2>/dev/null || git rev-list --max-parents=0 HEAD); git log --pretty=format:'* %s' --topo-order --no-merges $last_release..master | grep -v "Incremented plugin version" > /dev/null && echo $l); done | xargs echo)
echo $ACTIVE
-If you don't want to release all plugins, but you have specific plugins you want to release, you need to set `ACTIVE` equal to them.
+If you don't want to release all plugins, but you have specific plugins you want to release, you need to set `ACTIVE` equal to them:
ACTIVE="cordova-plugin-camera cordova-plugin-contacts cordova-plugin-device-motion"
echo $ACTIVE
-## Ensure license headers are present everywhere:
+#### Choose a Release Identifier
+
+Releases are identified by a "Release Identifier" that is used in commit messages and for temporary folders.
+
+Good choices are unique and have a direct relation to the release you are about to perform. Examples for valid identifiers would be `plugins20190506` or `splashscreen@503`. You can also create a release issue and use that (including the repository name): `cordova-plugin-splashscreen#123`.
+
+You set it similar to the active plugins:
+
+```
+RELEASE=plugins20190506
+echo $RELEASE
+```
+
+#### Request buy-in
+
+Email the dev mailing-list at <dev@cordova.apache.org> and see if anyone has reason to postpone the release.
+
+E.g.:
+
+ Subject: [DISCUSS] Cordova Plugins Release
+
+ Does anyone have any reason to delay a Cordova plugins release?
+ Any outstanding patches to land?
+
+ If not, I will start the release tomorrow.
+
+Make sure to adapt the subject and content to the actual plugins you want to release.
+
+Note that it would be possible to continue with some of the [Before Release](#before-release) items while waiting for a possible response.
+
+
+### Before Release
+
+#### Make sure you're up-to-date
+
+ # Update your repos
+ coho repo-status -r plugins -b master # check if there are any unpushed changes in the repos
+ coho repo-update -r plugins # updates the repos
+ coho repo-clone -r plugins # clone any possibly missing plugin repos
+ coho foreach -r plugins "git checkout master" # make sure all plugins have master checked out
+
+TODO How to do only for active? => See `${ACTIVE// //` foo below
+
+#### Check dependencies
+
+TODO How to run for many repo folders?
+
+See if any dependencies are outdated
+
+ (cd ... && npm outdated --depth=0)
+
+(The `--depth=0` prevents from listing dependencies of dependencies.)
+
+##### Resolve any outdated dependencies
+
+**Alternative 1:**
+
+- Explicitly pin the outdated dependency versions in the `dependencies` section of `package.json`.
+- Raise a new issue to update the dependencies in an upcoming release.
+
+**Alternative 2:**
+
+Within a new Pull Request: update any outdated dependencies in the project's `package.json` file. Be sure to run through the test section below for compatibility issues.
+
+#### `npm audit` check
+
+Ensure that the latest version of npm is installed (using a command such as `npm i npm@latest`), `package-lock.json` is present (do `npm i --package-lock-only` if needed), and then check:
+
+ (cd cordova-plugin-splashscreen && npm audit)
+
+TODO How to run `npm audit` for many repo folders?
+TODO Get rid of package-lock.json afterwards
+
+#### License Check
+
+Ensure license headers are present everywhere. For reference, see this [background](http://www.apache.org/legal/src-headers.html). Expect some noise in the output, for example some files from test fixtures will show up.
coho audit-license-headers -r active-plugins | less
- # Tip: Skim by searching for "Unknown Licenses"
+
+TODO only run for $ACTIVE, not for all active-plugins
+
+Tip: Skim by searching for "Unknown Licenses" where the number infront it not 0.
-For reference, see this [background](http://www.apache.org/legal/src-headers.html)
-
-## Ensure all dependencies and subdependencies have Apache-compatible licenses
+Ensure all dependencies and subdependencies have Apache-compatible licenses.
coho check-license -r active-plugins
+
+TODO only run for $ACTIVE, not for all active-plugins
-## Update RELEASENOTES.md & Version
-Remove the ''-dev'' suffix on the version in plugin.xml.
+### Prepare Release
- for l in $ACTIVE; do ( cd $l; v="$(grep version= plugin.xml | grep -v xml | head -n1 | cut -d'"' -f2)"; v2="${v%-dev}"; if [ "$v" != "$v2" ]; then echo "$l: Setting version in plugin.xml to $v2"; sed -i '' -E s:"version=\"$v\":version=\"$v2\":" plugin.xml; fi) ; done
+#### Update Version
-Remove the ''-dev'' suffix on the version in package.json.
+Remove the `-dev` suffix on the version in `plugin.xml`:
- for l in $ACTIVE; do ( cd $l; v="$(grep -m 1 '"version"' package.json | cut -d'"' -f4)"; if [[ $v = *-dev ]]; then v2="${v%-dev}"; echo "$l: Setting version in package.json to $v2"; sed -i '' -E '1,/version":.*/s/version":.*/version": "'$v2'",/' package.json; fi) ; done
+ for l in $ACTIVE; do ( cd $l; v="$(grep version= plugin.xml | grep -v xml | head -n1 | cut -d'"' -f2)"; v2="${v%-dev}"; if [ "$v" != "$v2" ]; then echo "$l: Setting version in plugin.xml to $v2"; sed -i -E s:"version=\"$v\":version=\"$v2\":" plugin.xml; fi) ; done
-If the changes merit it, manually bump the major / minor version instead of the micro. Manual process, but list the changes via:
+Remove the `-dev` suffix on the version in `package.json`:
- for l in $ACTIVE; do ( cd $l; echo $l; last_release=$(git describe --tags --abbrev=0 2>/dev/null || git rev-list --max-parents=0 HEAD); git log --pretty=format:'* %s' --topo-order --no-merges $last_release..master | grep -v "Incremented plugin version" ); done
+ for l in $ACTIVE; do ( cd $l; v="$(grep -m 1 '"version"' package.json | cut -d'"' -f4)"; if [[ $v = *-dev ]]; then v2="${v%-dev}"; echo "$l: Setting version in package.json to $v2"; sed -i -E '1,/version":.*/s/version":.*/version": "'$v2'",/' package.json; fi) ; done
For each of the plugins that have a test project inside it, update the version number there (`cordova-plugin-*/tests/plugin.xml`) to match the version of the plugin itself (`cordova-plugin-*/plugin.xml`).
- for l in $ACTIVE; do ( cd $l; v="$(grep version= plugin.xml | grep -v xml | head -n1 | cut -d'"' -f2)"; vt="$(grep version= tests/plugin.xml | grep -v xml | head -n1 | cut -d'"' -f2)"; if [ "$v" != "$vt" ]; then echo "$l: Setting version to $v"; sed -i '' -E s:"version=\"$vt\":version=\"$v\":" tests/plugin.xml; fi); done
+ for l in $ACTIVE; do ( cd $l; v="$(grep version= plugin.xml | grep -v xml | head -n1 | cut -d'"' -f2)"; vt="$(grep version= tests/plugin.xml | grep -v xml | head -n1 | cut -d'"' -f2)"; if [ "$v" != "$vt" ]; then echo "$l: Setting version in tests/plugin.xml to $v"; sed -i -E s:"version=\"$vt\":version=\"$v\":" tests/plugin.xml; fi); done
-Update its RELEASENOTES.md file with changes.
+And same for `cordova-plugin-*/tests/package.json` and `cordova-plugin-*/package.json`:
+
+ for l in $ACTIVE; do ( cd $l; v="$(grep -m 1 '"version"' package.json | cut -d'"' -f4)"; vt="$(grep -m 1 '"version"' tests/package.json | cut -d'"' -f4)"; if [ "$v" != "$vt" ]; then echo "$l: Setting version in tests/package.json to $v"; sed -i -E '1,/version":.*/s/version":.*/version": "'$v'",/' tests/package.json; fi); done
+
+TODO Output how many files were edited for success control
+
+##### Minor or Major version update
+
+If the changes merit it, manually bump the major / minor version instead of the patch version. Manual process, but list the changes via:
+
+ for l in $ACTIVE; do ( cd $l; echo $l; last_release=$(git describe --tags --abbrev=0 2>/dev/null || git rev-list --max-parents=0 HEAD); git log --pretty=format:'* %s' --topo-order --no-merges $last_release..master | grep -v "Incremented plugin version" ); done
+
+If this justifies or requires a major / minor version update, manually edit the version numbers in the files that currently already have uncommitted changes.
+
+TODO Decide _before_ updating version numbers
+
+#### Create Release Notes
+
+Update their `RELEASENOTES.md` files with changes since the last release:
for l in $ACTIVE; do (coho update-release-notes -r $l); done
- # Then curate:
+
+Then curate:
+
vim ${ACTIVE// //RELEASENOTES.md }/RELEASENOTES.md
-Commit these changes together (plugin.xml, RELEASENOTES.md, tests/plugin.xml)
+or use your favorite text editor manually.
- for l in $ACTIVE; do ( cd $l; v="$(grep version= plugin.xml | grep -v xml | head -n1 | cut -d'"' -f2)"; git commit -am "$JIRA Updated version and RELEASENOTES.md for release $v"); done
+#### Commit Release Notes and optional version changes together
+
+Commit these changes (`plugin.xml`, `package.json`, `RELEASENOTES.md`, `tests/plugin.xml`) together:
+
+ for l in $ACTIVE; do ( cd $l; v="$(grep version= plugin.xml | grep -v xml | head -n1 | cut -d'"' -f2)"; git commit -am "Updated version and RELEASENOTES.md for release $v ($RELEASE)"); done
Reply to the DISCUSS thread with a link to the updated release notes.
-## Tag
+### Testing
- for l in $ACTIVE; do ( cd $l; v="$(grep version= plugin.xml | grep -v xml | head -n1 | cut -d'"' -f2)"; echo "Tagging $l to $v"; git tag "$v" ); done
+TODO This will only work if you have _all_ the Cordova plugins checked out via Coho, not just a few of them
-## Test
- Create mobilespec and sanity check all plugins on at least one platform (preferably, a released version of the platform and not master). Run through mobilespec, ensuring to do manual tests that relate to changes in the RELEASENOTES.md
-
+Create mobilespec and sanity check all plugins on at least one platform (preferably, a released version of the platform and not master). Run through mobilespec, ensuring to do manual tests that relate to changes in the `RELEASENOTES.md`:
cordova-mobile-spec/createmobilespec/createmobilespec.js --android --ios
(cd mobilespec && ./cordova build && ./cordova run android --device)
(cd mobilespec && ./cordova build && ./cordova run ios --device)
-## Create Release Branch
+This should start a black-ish app with a "Plugin tests" button. When clicking it you end up in a screen with "Auto Tests" and "Manual Tests" buttons. You should run both and see if all/most/the expected ones succeed.
+
+### Push Changes
+
+#### Tag
+
+ for l in $ACTIVE; do ( cd $l; v="$(grep version= plugin.xml | grep -v xml | head -n1 | cut -d'"' -f2)"; echo "Tagging $l to $v"; git tag "$v" ); done
+
+#### Create Release Branch
+
+If there currently is no release branch (e.g. `5.0.x`) on the remote, you can create one with this command:
for l in $ACTIVE; do ( cd $l; v="$(grep version= plugin.xml | grep -v xml | head -n1 | cut -d'"' -f2)"; b=`expr $v : '^\(....\)'`; x="x"; b=$b$x; git branch $b; echo "Creating branch $b for $l"); done
-If a branch already exists, you will have to manually checkout the branch, merge master and then checkout master.
+##### Update Release Branch
-## Update version to add back -dev suffix
+If a release branch already exists on the remote, you will have to manually checkout the branch, merge `master` into it and then checkout `master` again:
- for l in $ACTIVE; do ( cd $l; v="$(grep version= plugin.xml | grep -v xml | head -n1 | cut -d'"' -f2)"; v_no_dev="${v%-dev}"; if [ "$v" = "$v_no_dev" ]; then v2="$(echo $v|awk -F"." '{$NF+=1}{print $0RT}' OFS="." ORS="")-dev"; echo "$l: Setting version in plugin.xml to $v2"; sed -i '' -E s:"version=\"$v\":version=\"$v2\":" plugin.xml; fi) ; done
+ # in each plugin
+ v="$(grep version= plugin.xml | grep -v xml | head -n1 | cut -d'"' -f2)"; b=`expr $v : '^\(....\)'`; x="x"; b=$b$x;
+ git checkout $b
+ git merge master
+ # fix eventual merge conflicts and commit
+ git checkout master
+
+#### Update version to add back `-dev` suffix
+
+ # update plugin.xml
+ for l in $ACTIVE; do ( cd $l; v="$(grep version= plugin.xml | grep -v xml | head -n1 | cut -d'"' -f2)"; v_no_dev="${v%-dev}"; if [ "$v" = "$v_no_dev" ]; then v2="$(echo $v|awk -F"." '{$NF+=1}{print $0RT}' OFS="." ORS="")-dev"; echo "$l: Setting version in plugin.xml to $v2"; sed -i -E s:"version=\"$v\":version=\"$v2\":" plugin.xml; fi) ; done
+
# update package.json
- for l in $ACTIVE; do ( cd $l; v="$(grep -m 1 '"version"' package.json | cut -d'"' -f4)"; if [[ $v != *-dev ]]; then v2="$(echo $v|awk -F"." '{$NF+=1}{print $0RT}' OFS="." ORS="")-dev"; echo "$l: Setting version in package.json to $v2"; sed -i '' -E '1,/version":.*/s/version":.*/version": "'$v2'",/' package.json; fi); done
- # update the nested test
- for l in $ACTIVE; do ( cd $l; v="$(grep version= plugin.xml | grep -v xml | head -n1 | cut -d'"' -f2)"; vt="$(grep version= tests/plugin.xml | grep -v xml | head -n1 | cut -d'"' -f2)"; if [ "$v" != "$vt" ]; then echo "$l: Setting version to $v"; sed -i '' -E s:"version=\"$vt\":version=\"$v\":" tests/plugin.xml; fi); done
- for l in $ACTIVE; do (cd $l; git commit -am "$JIRA Incremented plugin version." ); done
+ for l in $ACTIVE; do ( cd $l; v="$(grep -m 1 '"version"' package.json | cut -d'"' -f4)"; if [[ $v != *-dev ]]; then v2="$(echo $v|awk -F"." '{$NF+=1}{print $0RT}' OFS="." ORS="")-dev"; echo "$l: Setting version in package.json to $v2"; sed -i -E '1,/version":.*/s/version":.*/version": "'$v2'",/' package.json; fi); done
+
+ # update the nested test plugin.xml
+ for l in $ACTIVE; do ( cd $l; v="$(grep version= plugin.xml | grep -v xml | head -n1 | cut -d'"' -f2)"; vt="$(grep version= tests/plugin.xml | grep -v xml | head -n1 | cut -d'"' -f2)"; if [ "$v" != "$vt" ]; then echo "$l: Setting version in tests/plugin.xml to $v"; sed -i -E s:"version=\"$vt\":version=\"$v\":" tests/plugin.xml; fi); done
+
+ # update the nested test package.json
+ for l in $ACTIVE; do ( cd $l; v="$(grep -m 1 '"version"' package.json | cut -d'"' -f4)"; vt="$(grep -m 1 '"version"' tests/package.json | cut -d'"' -f4)"; if [ "$v" != "$vt" ]; then echo "$l: Setting version in tests/package.json to $v"; sed -i -E '1,/version":.*/s/version":.*/version": "'$v'",/' tests/package.json; fi); done
+
+ # commit
+ for l in $ACTIVE; do (cd $l; git commit -am "Incremented plugin version. ($RELEASE)" ); done
-## Push tags, branches and changes
+#### Push tags, branches and changes
+
+First command shows which commit will be pushed, second one if there are uncommited files in any of the plugin checkouts.
+
# Sanity check:
coho repo-status -r plugins
coho foreach -r plugins "git status -s"
+
+ Then push the changes (commits in `master`, tag and release branch):
+
# Push: (assumes "origin" is apache remote)
for l in $ACTIVE; do ( cd $l; tag=$(git describe --tags --abbrev=0); echo $l; set -x; git push origin master && git push origin refs/tags/$tag); done
for l in $ACTIVE; do ( cd $l; v="$(grep version= plugin.xml | grep -v xml | head -n1 | cut -d'"' -f2)"; b=`expr $v : '^\(....\)'`; x="x"; b=$b$x; git push origin $b;); done
+
+ Finally check it's all pushed now:
+
# Check that it was all successful:
coho repo-update -r plugins
coho repo-status -r plugins
-## Publish to dist/dev
+### Publish Release Candidate to `dist/dev`
+
+**Attention**: The following steps need [SVN](https://subversion.apache.org/packages.html#windows) installed and [unfortunately don't give an error if it is not, failing silently](https://issues.apache.org/jira/browse/CB-8006). You also need do [have a secret key set up](setting-up-gpg.md) for signing the release.
+
Ensure you have the svn repos checked out:
coho repo-clone -r dist -r dist/dev
Create archives from your tags:
- coho create-archive -r ${ACTIVE// / -r } --dest cordova-dist-dev/$JIRA
+ coho create-archive -r ${ACTIVE// / -r } --dest cordova-dist-dev/$RELEASE
Sanity Check:
# Manually double check version numbers are correct on the file names
# Then run:
- coho verify-archive cordova-dist-dev/$JIRA/*.tgz
+ coho verify-archive cordova-dist-dev/$RELEASE/*.tgz
Upload:
- (cd cordova-dist-dev && svn up && svn add $JIRA && svn commit -m "$JIRA Uploading release candidates for plugins release")
+ (cd cordova-dist-dev && svn up && svn add $RELEASE && svn commit -m "Uploading release candidates for plugins release ($RELEASE)")
-* Find your release here: https://dist.apache.org/repos/dist/dev/cordova/
+If everything went well the Release Candidate will show up here: https://dist.apache.org/repos/dist/dev/cordova/
-## Prepare Blog Post
-Run the following script to get release notes from RELEASENOTS.md.
+### Documentation and Communication
- for l in $ACTIVE; do (cd $l; current_release=$(git describe --tags --abbrev=0); previous_release=$(git describe --abbrev=0 --tags `git rev-list --tags --skip=1 --max-count=1`); echo "$l@$current_release"; awk '/### '$current_release'.*/,/### '$previous_release'.*/ {temp=match($0,/### '$previous_release'/); title=match($0, /### '$current_release'/); if(temp == 0 && title == 0) print $0}' < RELEASENOTES.md); done
+#### Prepare Blog Post
- * Combine the output from above into a Release Announcement blog post
- * Instructions on [sites page README](https://svn.apache.org/repos/asf/cordova/site/README.md)
- * Get blog post proof-read.
+* Gather highlights from `RELEASENOTES.md` into a Release Announcement blog post
+ This command can do that automatically:
+
+ for l in $ACTIVE; do (cd $l; current_release=$(git describe --tags --abbrev=0); previous_release=$(git describe --abbrev=0 --tags `git rev-list --tags --skip=1 --max-count=1`); echo "$l@$current_release"; awk '/### '$current_release'.*/,/### '$previous_release'.*/ {temp=match($0,/### '$previous_release'/); title=match($0, /### '$current_release'/); if(temp == 0 && title == 0) print $0}' < RELEASENOTES.md); done
-## Start VOTE Thread
+* Instructions on publishing a blog post are on the [`cordova-docs` repo](https://github.com/apache/cordova-docs#writing-a-blog-post)
+* Get blog post proofread by submitting a PR to `cordova-docs` and asking someone on dev list to +1 it.
+
+### Voting and Release
+
+#### Start VOTE Thread
+
Send an email to dev ML with:
__Subject:__
@@ -216,13 +385,11 @@
Please review and vote on the release of this plugins release
by replying to this email (and keep discussion on the DISCUSS thread)
- Release issue: https://issues.apache.org/jira/browse/CB-XXXX
-
The plugins have been published to dist/dev:
- https://dist.apache.org/repos/dist/dev/cordova/CB-XXXX/
+ https://dist.apache.org/repos/dist/dev/cordova/$RELEASE/
The packages were published from their corresponding git tags:
- PASTE OUTPUT OF: coho print-tags -r ${ACTIVE// / -r }
+ ### PASTE OUTPUT OF: coho print-tags -r ${ACTIVE// / -r }
Upon a successful vote I will upload the archives to dist/, upload them to npm, and post the corresponding blog post.
@@ -236,28 +403,41 @@
* Ran coho check-license to ensure all dependencies and subdependencies have Apache-compatible licenses
* Ensured continuous build was green when repos were tagged
+Replace `$RELEASE` and `### ...` line with the actual values!
+TODO Include Release notes in email, at least as a link
-## Voting
+#### Voting
+
+TODO This needs much better instructions
+
Steps to verify a plugins release
1) Setup
-Repo clone can be skipped if you have cordova-dist-dev. Warning, this requires svn setup.
+ Repo clone can be skipped if you have cordova-dist-dev. Warning, this requires svn setup.
coho repo-clone -r cordova-dist-dev
(cd cordova-dist-dev && svn up)
2) Verify
- coho verify-archive cordova-dist-dev/$JIRA/*.tgz
+Verify the release:
+
+ // Verify the archive
+ // $RELEASE should be included in the vote email
+ coho verify-archive cordova-dist-dev/$RELEASE/*.tgz
+
+ // update local checkouts
coho repo-update -r plugins
+
+ // check licences
coho check-license -r active-plugins
coho audit-license-headers -r active-plugins | less
- # Tip: Skim by searching for "Unknown Licenses"
+ // Tip: Skim by searching for "Unknown Licenses"
3) Test
-Review [ci.cordova.io](http://ci.cordova.io/).
+Check plugins CI
(Optional locally run `mobile-spec`)
@@ -265,16 +445,12 @@
(cd mobilespec && ./cordova build && ./cordova run android --device)
(cd mobilespec && ./cordova build && ./cordova run ios --device)
+TODO
-## Email the result of the vote
+#### Email the result of the vote
+
Respond to the vote thread with:
-__Subject:__
-
- [RESULT][VOTE] Plugins Release
-
-__Body:__
-
The vote has now closed. The results are:
Positive Binding Votes: (# of PMC members that +1'ed)
@@ -303,81 +479,78 @@
_Note: list of PMC members: http://people.apache.org/phonebook.html?pmc=cordova_
-## If the Vote does *not* Pass
-* Revert adding of `-dev` on master branch
+#### If the Vote does *not* Pass
+
+* Revert commit adding `-dev` on master branch
* Address the concerns (on master branch)
* Re-tag release using `git tag -f`
+*
* Add back `-dev`
* Start a new vote
+#### Otherwise: Publish release to `dist/` & npm
-## Publish to dist/
+If you've lost your list of ACTIVE, you can recreate it from the voted on release:
-If you've lost your list of ACTIVE:
-
- ACTIVE=$(cd cordova-dist-dev/$JIRA; ls *.tgz | sed -E 's:-[^-]*$::')
+ ACTIVE=$(cd cordova-dist-dev/$RELEASE; ls *.tgz | sed -E 's:-[^-]*$::')
Publish:
cd cordova-dist
svn up
for l in $ACTIVE; do ( svn rm plugins/$l* ); done
- cp ../cordova-dist-dev/$JIRA/* plugins/
+ cp ../cordova-dist-dev/$RELEASE/* plugins/
svn add plugins/*
- svn commit -m "$JIRA Published plugins release to dist"
-
- cd ../cordova-dist-dev
- svn up
- svn rm $JIRA
- svn commit -m "$JIRA Removing release candidates from dist/dev"
- cd ..
+ svn commit -m "Published plugins release to dist ($RELEASE)"
Find your release here: https://dist.apache.org/repos/dist/release/cordova/plugins/
-### Tell Apache about Release
+Then you can also remove the release candidate from `dist-dev/`:
-TODO: Please someone write a coho helper for doing this POST request!
+ cd ../cordova-dist-dev
+ svn up
+ svn rm $RELEASE
+ svn commit -m "Removing release candidates from dist/dev ($RELEASE)"
+ cd ..
-1. Go to: https://reporter.apache.org/addrelease.html?cordova
-2. Use version "cordova-plugin-$FOO@x.x.x"
-
-## Publish to npm
+And finally you can publish your package to npm:
cd cordova-dist/plugins
for l in $ACTIVE; do (
npm publish $l-*.tgz
) done;
-## Add new apache release tags
+#### Add permanent Apache release tag to repository
-Make a copy of your released tag with a prefix of `rel\YOURTAG`. These are permanent release tags for Apache.
+Make a copy of your released tag with a prefix of `rel\YOURTAG`:
for l in $ACTIVE; do ( cd $l; tag=$(git describe --tags --abbrev=0); git checkout $tag; git tag 'rel/'$tag; git push origin refs/tags/'rel/'$tag; git checkout master); done
-
-## Post blog Post
-
-See instructions in the cordova-docs [README](https://github.com/apache/cordova-docs#writing-a-blog-post)
-
-## Do other announcements
-
- Do the same things regarding announcements as described in cadence-release-process, where they make sense.
-
-Send email to dev list with a subject [ANNOUNCE] Plugin Release and include blog post and tweet links
-
-__Subject:__
- [ANNOUNCE] Plugin Release
+These are permanent release tags for Apache.
-__Body:__
-
+
+### Follow up steps
+
+#### Tell Apache about Release
+
+1. Go to: https://reporter.apache.org/addrelease.html?cordova
+2. Use `cordova-plugin-$FOO@x.x.x` as "Full version name"
+3. Click "Update release data" to submit it to the list
+
+#### Publish the prepared blog post
+
+Merge the prepare Pull Request with the blog post to publish it on the Cordova Blog.
+
+#### Email a release announcement to the mailing list
+
+ Subject: [ANNOUNCE] Plugin Release
+
+ cordova-plugin-xxx@VERSION has been released!
+
Blog: http://cordova.apache.org/news/YYYY/MM/DD/plugin-release.html
Tweet: https://twitter.com/apachecordova/status/xxxxxxxxxxxx
-## Close JIRA Issue
- * Double check that the issue has comments that record the steps you took
- * Mark it as fixed
-
-## Finally:
+#### Finally:
* Update *these instructions* if they were missing anything.
diff --git a/docs/setting-up-gpg.md b/docs/setting-up-gpg.md
index 3fda40c..599f006 100644
--- a/docs/setting-up-gpg.md
+++ b/docs/setting-up-gpg.md
@@ -46,13 +46,16 @@
### Create a key
-How to create a key:
-http://www.apache.org/dev/openpgp.html#generate-key
+Create a new key with
* email = you@apache.org
- * description = CODE SIGNING KEY
+ * description = "CODE SIGNING KEY"
+
+Use this command
-Then follow these instructions: http://www.apache.org/dev/openpgp.html#generation-final-steps
+ gpg --gen-key
+
+(more elaborate instructions at http://www.apache.org/dev/openpgp.html#generate-key + http://www.apache.org/dev/openpgp.html#generation-final-steps)
### Get Key ID
@@ -69,7 +72,11 @@
sub 4096R/A59029E7 2014-02-27
sig 8A496450 2014-02-27 Andrew Grieve (CODE SIGNING KEY) <agrieve@apache.org>
-In this example, `8A496450` is your `$KEY_ID`
+In this example, `8A496450` is your key ID. Set it to a environment variable:
+
+ KEY_ID=8A496450
+
+(Or on Windows: `set KEY_ID=8A496450`. Everywhere you see `$KEY_ID` from now on, use `%KEY_ID%` instead)
### Publish Key
@@ -77,9 +84,13 @@
# Clone `cordova-dist` if you don't have it already:
coho repo-clone -r dist
+
+ # Append your key to the KEYS file
gpg --armor --export $KEY_ID >> cordova-dist/KEYS
+
# Make sure that's the only change to the file
( cd cordova-dist && svn diff )
+
# Commit
( cd cordova-dist && svn commit -m "Added my signing PGP key to KEYS" )
@@ -101,12 +112,9 @@
gpg --armor --export $KEY_ID > $KEY_ID.asc
scp $KEY_ID.asc people.apache.org:
-Optional:
-Sign into: https://id.apache.org/ and add your fingerprint (not your KEY_ID)
- * This will cause emails from Apache to you to be encrypted.
+#### Optional
-Phew! That was easy :P
-
+Sign into: https://id.apache.org/ and add your fingerprint (not your KEY_ID). This will cause emails from Apache to you to be encrypted.
## Importing PMC Members' PGP keys
diff --git a/docs/tools-release-process.md b/docs/tools-release-process.md
index 9f37240..c8a21ab 100644
--- a/docs/tools-release-process.md
+++ b/docs/tools-release-process.md
@@ -36,6 +36,8 @@
### cordova-common singleton rule
+**Does not apply since Cordova 9 (cordova-common@3.1.0):**
+
The most important rule is that packages such as `cordova-lib` and `cordova-cli` should not use multiple versions of `cordova-common` through the chain of dependencies. This rule is due to the use of multiple singletons in `cordova-common`. This means that if `cordova-common` is updated it should be released before other packages such as `cordova-fetch`, `cordova-create`, `cordova-lib`, `cordova-cli`, etc.
### Alternative approaches
diff --git a/src/apputil.js b/src/apputil.js
index d979a89..39af9de 100644
--- a/src/apputil.js
+++ b/src/apputil.js
@@ -34,7 +34,7 @@
process.chdir(newDir);
baseWorkingDir = newDir;
}
- console.log('Running from ' + baseWorkingDir);
+ console.log('Running from ' + baseWorkingDir + ' (use `-g` to run in current working directory)');
};
exports.getBaseDir = function () {
diff --git a/src/check-npm-install-util.js b/src/check-npm-install-util.js
new file mode 100644
index 0000000..dbb9dd0
--- /dev/null
+++ b/src/check-npm-install-util.js
@@ -0,0 +1,31 @@
+/*
+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.
+*/
+
+try {
+ // Ensure npm install has been run.
+ Object.keys(require('../package').dependencies).forEach(require);
+} catch (e) {
+ const path = require('path'); // Built-in Node.js module
+ console.log(
+ 'Please run "npm install" from this directory:\n\t' +
+ path.join(__dirname, '..')); // correct path
+ process.exit(2);
+}
+
+module.exports = {};
diff --git a/src/lazy-require-util.js b/src/lazy-require-util.js
new file mode 100644
index 0000000..f327b62
--- /dev/null
+++ b/src/lazy-require-util.js
@@ -0,0 +1,28 @@
+/*
+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.
+*/
+
+function * lazyRequire (name, opt_prop) {
+ if (opt_prop) {
+ yield require(name)[opt_prop];
+ } else {
+ yield require(name);
+ }
+}
+
+module.exports = lazyRequire;
diff --git a/src/main.js b/src/main.js
index 8f949c8..de3c14f 100644
--- a/src/main.js
+++ b/src/main.js
@@ -17,29 +17,19 @@
under the License.
*/
-var executil = require('./executil');
+// Verify that npm install was run before importing anything else
+require('./check-npm-install-util');
-try {
- var co = require('co');
- var optimist = require('optimist');
- // Ensure npm install has been run.
- Object.keys(require('../package').dependencies).forEach(require);
-} catch (e) {
- console.log('Please run "npm install" from this directory:\n\t' + __dirname); // eslint-disable-line no-path-concat
- process.exit(2);
-}
-var apputil = require('./apputil');
+const co = require('co');
+const optimist = require('optimist');
-function * lazyRequire (name, opt_prop) {
- if (opt_prop) {
- yield require(name)[opt_prop];
- } else {
- yield require(name);
- }
-}
+const executil = require('./executil');
+const apputil = require('./apputil');
+
+const lazyRequire = require('./lazy-require-util');
module.exports = function () {
- var repoCommands = [
+ const repoCommands = [
{
name: 'repo-clone',
desc: 'Clones git repositories as siblings of cordova-coho (unless --no-chdir or --global is used).',
@@ -69,7 +59,8 @@
desc: 'Update specified git remote to point to corresponding apache github repo',
entryPoint: lazyRequire('./remote-update')
}];
- var releaseCommands = [{
+
+ const releaseCommands = [{
name: 'prepare-platform-release-branch',
desc: 'Branches, updates JS, updates VERSION. Safe to run multiple times.',
entryPoint: lazyRequire('./platform-release', 'prepareReleaseBranchCommand')
@@ -130,7 +121,8 @@
desc: 'Unpublishes last nightly versions for all specified repositories',
entryPoint: lazyRequire('./npm-publish', 'unpublishNightly')
}];
- var otherCommands = [{
+
+ const otherCommands = [{
name: 'list-pulls',
desc: 'Shows a list of GitHub pull requests for all specified repositories.',
entryPoint: lazyRequire('./list-pulls')
@@ -171,9 +163,9 @@
console.log(require('../package').version);
yield Promise.resolve();
}
- }
- ];
- var commandMap = {};
+ }];
+
+ const commandMap = {};
function addToCommandMap (cmd) {
commandMap[cmd.name] = cmd;
}
@@ -183,7 +175,7 @@
// aliases:
commandMap['foreach'] = commandMap['for-each'];
- var usage = 'Usage: $0 command [options]\n\n';
+ let usage = 'Usage: $0 command [options]\n\n';
function addCommandUsage (cmd) {
usage += ' ' + cmd.name + ': ' + cmd.desc + '\n';
}
@@ -203,8 +195,9 @@
usage += ' ./cordova-coho/coho for-each -r plugins "git clean -fd"\n';
usage += ' ./cordova-coho/coho last-week --me';
- var command = commandMap[optimist.argv._[0]];
- var opts = optimist
+ const command = commandMap[optimist.argv._[0]];
+
+ let opts = optimist
.usage(usage)
.options('verbose', {
desc: 'Enable verbose logging',
@@ -232,8 +225,9 @@
default: true
});
}
- var argv = opts.check(function (argv) {
- var commandName = argv._[0];
+
+ const argv = opts.check(function (argv) {
+ const commandName = argv._[0];
if (!commandName) {
throw 'No command specified.';
}
@@ -244,13 +238,18 @@
throw 'No repositories specified, see list-repos';
}
}).argv;
+
if (!command.noChdir) {
// Change directory to be a sibling of coho.
apputil.initWorkingDir(argv.chdir);
+ } else {
+ console.log('Running from ' + apputil.getBaseDir());
}
+
if (argv.verbose) {
executil.verbose = true;
}
- var entry = command.entryPoint;
+
+ const entry = command.entryPoint;
co(entry).then();
};