فهرست منبع

Merge pull request #3081 from blink1073/patch-release-script

Patch release script
Afshin Darian 7 سال پیش
والد
کامیت
873076a542
4فایلهای تغییر یافته به همراه67 افزوده شده و 3 حذف شده
  1. 14 0
      RELEASE.md
  2. 1 1
      lerna.json
  3. 2 2
      package.json
  4. 50 0
      scripts/patch-release.js

+ 14 - 0
RELEASE.md

@@ -105,3 +105,17 @@ files from the previous branch, as well as the `package.json` fields up to
 ### Set master back to dev version
 - Update `jupyterlab/_version.py` with a `dev` version
 - Commit and push the version update.
+
+
+## Making a patch release of a JavaScript Package
+- Create a branch based on the last Python release if one does not exist.
+- Create a PR against that branch with the changes.
+- Merge the PR.
+- Run the following script from the branch to make a patch release, 
+where the package is in `/packages/packageFolder`:
+
+```bash
+node scripts/patch-release.js packageFolder
+```
+
+- Push the resulting commit and tag.

+ 1 - 1
lerna.json

@@ -1,5 +1,5 @@
 {
-  "lerna": "2.0.0-beta.38",
+  "lerna": "2.4.0",
   "packages": [
     "jupyterlab",
     "jupyterlab/tests/mock-mimeextension",

+ 2 - 2
package.json

@@ -19,7 +19,7 @@
     "docs": "lerna run docs",
     "get:dependency": "node scripts/get-dependency.js",
     "integrity": "node scripts/package-integrity.js",
-    "publish": "npm update && npm install && npm run clean && npm run build:packages && lerna publish -m \"Publish\"",
+    "publish": "npm update && npm install && npm run clean && npm run build:packages && lerna publish --force-publish=* -m \"Publish\"",
     "test": "cd test && npm test",
     "test:services": "cd packages/services && npm test && npm run test:integration && cd examples/node && python main.py",
     "test:chrome": "lerna run test:chrome --stream",
@@ -33,6 +33,6 @@
   },
   "dependencies": {},
   "devDependencies": {
-    "lerna": "2.0.0-beta.38"
+    "lerna": "^2.4.0"
   }
 }

+ 50 - 0
scripts/patch-release.js

@@ -0,0 +1,50 @@
+#!/usr/bin/env node
+var fs = require('fs');
+var path = require('path');
+var childProcess = require('child_process');
+
+
+// Make sure we have required command line arguments.
+if (process.argv.length < 3) {
+    var msg = '** Must supply a target package';
+    process.stderr.write(msg);
+    process.exit(1);
+}
+
+// Extract the desired package target.
+var target = process.argv[2];
+
+var packagePath = path.resolve(path.join('packages', target));
+
+if (!fs.existsSync(packagePath)) {
+  console.log('Invalid package path', packagePath);
+  process.exit(1);
+}
+
+
+/**
+ * Run a command with terminal output.
+ */
+function run(cmd, options) {
+  options = options || {};
+  options['stdio'] = [1,2,3];
+  console.log('>', cmd);
+  childProcess.execSync(cmd, options);
+}
+
+// Perform the patch operations.
+console.log('Patching', target, '...');
+run('npm run build:packages');
+run('npm version patch', { cwd: packagePath });
+run('npm publish', { cwd: packagePath});
+
+// Extract the new package info.
+var data = require(path.join(packagePath, 'package.json'));
+var name = data.name;
+var version = data.version;
+
+run('npm run update:dependency ' + name + ' ^' + version);
+run('git commit -a -m "Release ' + name + '@' + version + '"');
+run('git tag ' + name + '@' + version);
+
+console.log('\n\nFinished, make sure to push the commit and the tag.')