From 05aaed07b2aad9c983db2cbf217c3471b404186f Mon Sep 17 00:00:00 2001 From: Paulo Castro Date: Wed, 3 Jul 2019 22:50:53 +0100 Subject: [PATCH] Patch oclif to use "npx npm@6.9.0 install" if npm is older than 6.9.0 Change-type: patch Signed-off-by: Paulo Castro --- patches/@oclif+dev-cli+1.22.0.patch | 24 +++++++++++++----------- patches/qqjs++execa+0.10.0.patch | 19 +++++++++++++++---- 2 files changed, 28 insertions(+), 15 deletions(-) diff --git a/patches/@oclif+dev-cli+1.22.0.patch b/patches/@oclif+dev-cli+1.22.0.patch index 61ce7fec..6c84a29b 100644 --- a/patches/@oclif+dev-cli+1.22.0.patch +++ b/patches/@oclif+dev-cli+1.22.0.patch @@ -48,7 +48,7 @@ index a9d4276..75c2f8b 100644 exports.default = PackWin; const scripts = { diff --git a/node_modules/@oclif/dev-cli/lib/tarballs/build.js b/node_modules/@oclif/dev-cli/lib/tarballs/build.js -index 3e613e0..c73a04c 100644 +index 3e613e0..129d041 100644 --- a/node_modules/@oclif/dev-cli/lib/tarballs/build.js +++ b/node_modules/@oclif/dev-cli/lib/tarballs/build.js @@ -17,8 +17,11 @@ const pack = async (from, to) => { @@ -93,20 +93,22 @@ index 3e613e0..c73a04c 100644 const updatePJSON = async () => { qq.cd(c.workspace()); const pjson = await qq.readJSON('package.json'); -@@ -55,7 +80,11 @@ async function build(c, options = {}) { - if (!await qq.exists(lockpath)) { +@@ -56,7 +81,13 @@ async function build(c, options = {}) { lockpath = qq.join(c.root, 'npm-shrinkwrap.json'); } -- await qq.cp(lockpath, '.'); -+ try { -+ await qq.cp(lockpath, '.'); -+ } catch (err) { -+ console.log('WARNING: found neiter package-lock.json nor npm-shrinkwrap.json') + await qq.cp(lockpath, '.'); +- await qq.x('npm install --production'); ++ ++ const npmVersion = await qq.x.stdout('npm', ['--version']); ++ if (require('semver').lt(npmVersion, '6.9.0')) { ++ await qq.x('npx npm@6.9.0 install --production'); ++ } else { ++ await qq.x('npm install --production'); + } - await qq.x('npm install --production'); } }; -@@ -71,7 +100,8 @@ async function build(c, options = {}) { + const buildTarget = async (target) => { +@@ -71,7 +102,8 @@ async function build(c, options = {}) { output: path.join(workspace, 'bin', 'node'), platform: target.platform, arch: target.arch, @@ -116,7 +118,7 @@ index 3e613e0..c73a04c 100644 }); if (options.pack === false) return; -@@ -124,7 +154,8 @@ async function build(c, options = {}) { +@@ -124,7 +156,8 @@ async function build(c, options = {}) { await qq.writeJSON(c.dist(config.s3Key('manifest')), manifest); }; log_1.log(`gathering workspace for ${config.bin} to ${c.workspace()}`); diff --git a/patches/qqjs++execa+0.10.0.patch b/patches/qqjs++execa+0.10.0.patch index 226ea0f1..dddfc7e6 100644 --- a/patches/qqjs++execa+0.10.0.patch +++ b/patches/qqjs++execa+0.10.0.patch @@ -1,5 +1,5 @@ diff --git a/node_modules/qqjs/node_modules/execa/index.js b/node_modules/qqjs/node_modules/execa/index.js -index 06f3969..7ab1b66 100644 +index 06f3969..8bca191 100644 --- a/node_modules/qqjs/node_modules/execa/index.js +++ b/node_modules/qqjs/node_modules/execa/index.js @@ -14,6 +14,17 @@ const stdio = require('./lib/stdio'); @@ -20,7 +20,7 @@ index 06f3969..7ab1b66 100644 function handleArgs(cmd, args, opts) { let parsed; -@@ -104,13 +115,21 @@ function handleShell(fn, cmd, opts) { +@@ -104,13 +115,22 @@ function handleShell(fn, cmd, opts) { opts = Object.assign({}, opts); @@ -38,12 +38,23 @@ index 06f3969..7ab1b66 100644 opts.windowsVerbatimArguments = true; } -+ console.log(`[patched execa] handleShell file="${file}" args="[${args}]"`); ++ const argStr = (args && args.length) ? `["${args.join('", "')}"]` : args; ++ console.log(`[patched execa] handleShell file="${file}" args=${argStr}`); + if (opts.shell) { file = opts.shell; delete opts.shell; -@@ -364,3 +383,7 @@ module.exports.sync = (cmd, args, opts) => { +@@ -199,6 +219,9 @@ module.exports = (cmd, args, opts) => { + const maxBuffer = parsed.opts.maxBuffer; + const joinedCmd = joinCmd(cmd, args); + ++ const argStr = (args && args.length) ? `["${args.join('", "')}"]` : args; ++ console.log(`[patched execa] parsed.cmd="${parsed.cmd}" parsed.args=${argStr}`); ++ + let spawned; + try { + spawned = childProcess.spawn(parsed.cmd, parsed.args, parsed.opts); +@@ -364,3 +387,7 @@ module.exports.sync = (cmd, args, opts) => { module.exports.shellSync = (cmd, opts) => handleShell(module.exports.sync, cmd, opts); module.exports.spawn = util.deprecate(module.exports, 'execa.spawn() is deprecated. Use execa() instead.');