@modernpoacher/deps 1.4.15 → 1.4.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/babel.config.js +2 -2
- package/bin/execute/app.js +2 -0
- package/lib/common/git/index.js +2 -2
- package/lib/common/index.js +1 -1
- package/lib/index.js +1 -1
- package/lib/install/index.js +1 -1
- package/package.json +15 -15
- package/src/common/git/index.js +32 -0
- package/src/common/index.js +12 -0
- package/src/index.js +78 -80
- package/src/install/index.js +12 -14
- package/test/common/git/index.spec.js +8 -0
- package/test/index.spec.js +288 -0
- package/test/install/index.spec.js +154 -0
package/babel.config.js
CHANGED
package/bin/execute/app.js
CHANGED
|
@@ -26,6 +26,7 @@ const {
|
|
|
26
26
|
gitCheckout,
|
|
27
27
|
gitPull,
|
|
28
28
|
gitPush,
|
|
29
|
+
gitPushTags,
|
|
29
30
|
gitAdd,
|
|
30
31
|
gitCommit
|
|
31
32
|
} = require('@modernpoacher/deps/common/git')
|
|
@@ -134,6 +135,7 @@ async function execute (directory = DIRECTORY, registry = REGISTRY, force = fals
|
|
|
134
135
|
await gitAdd(directory)
|
|
135
136
|
await gitCommit(directory)
|
|
136
137
|
await gitPush(directory)
|
|
138
|
+
await gitPushTags(directory)
|
|
137
139
|
} catch (e) {
|
|
138
140
|
handleError(e)
|
|
139
141
|
}
|
package/lib/common/git/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.catGitRefsRemotesOriginHead=catGitRefsRemotesOriginHead;exports.gitAdd=gitAdd;exports.gitCheckout=gitCheckout;exports.gitCommit=gitCommit;exports.gitPull=gitPull;exports.gitPush=gitPush;exports.gitRevParse=gitRevParse;var _debug=_interopRequireDefault(require("debug"));var _os=require("os");var _child_process=require("child_process");function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};}const DIRECTORY='.';const BRANCH='master';const ADD='package.json package-lock.json';const COMMIT=(0,_os.platform)()==='win32'?'Updated `package.json` &/ `package-lock.json`':'Updated \\`package.json\\` &/ \\`package-lock.json\\`';const OPTIONS={maxBuffer:1024*2000};const log=(0,_debug.default)('@modernpoacher/deps');log(`\`git\` (${_os.platform}) is awake`);const trim=v=>v.split('\n').map(v=>v.trimEnd()).join('\n').trim();function use(key){const log=(0,_debug.default)(`@modernpoacher/deps:${key}`);return function use(v){log(trim(v));};}function out(key,directory){const log=(0,_debug.default)(`@modernpoacher/deps:${key}`);return function out(v){const s=v.trim();if(directory===s)return;return log(trim(s));};}function err(key,directory){const log=(0,_debug.default)(`@modernpoacher/deps:${key}`);return function err(v){const s=v.trim();if(directory===s||s.toLowerCase().startsWith('fatal: not a git repository'))return;return log(trim(s));};}const getErrorCode=({code=0}={})=>code;const getErrorMessage=({message=''}={})=>message;function getCatGitRefsRemotesOriginHeadCommand(directory=DIRECTORY){log('getCatGitRefsRemotesOriginHeadCommand');return`
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.catGitRefsRemotesOriginHead=catGitRefsRemotesOriginHead;exports.gitAdd=gitAdd;exports.gitCheckout=gitCheckout;exports.gitCommit=gitCommit;exports.gitPull=gitPull;exports.gitPush=gitPush;exports.gitPushTags=gitPushTags;exports.gitRevParse=gitRevParse;var _debug=_interopRequireDefault(require("debug"));var _os=require("os");var _child_process=require("child_process");function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};}const DIRECTORY='.';const BRANCH='master';const ADD='package.json package-lock.json';const COMMIT=(0,_os.platform)()==='win32'?'Updated `package.json` &/ `package-lock.json`':'Updated \\`package.json\\` &/ \\`package-lock.json\\`';const OPTIONS={maxBuffer:1024*2000};const log=(0,_debug.default)('@modernpoacher/deps');log(`\`git\` (${_os.platform}) is awake`);const trim=v=>v.split('\n').map(v=>v.trimEnd()).join('\n').trim();function use(key){const log=(0,_debug.default)(`@modernpoacher/deps:${key}`);return function use(v){log(trim(v));};}function out(key,directory){const log=(0,_debug.default)(`@modernpoacher/deps:${key}`);return function out(v){const s=v.trim();if(directory===s)return;return log(trim(s));};}function err(key,directory){const log=(0,_debug.default)(`@modernpoacher/deps:${key}`);return function err(v){const s=v.trim();if(directory===s||s.toLowerCase().startsWith('fatal: not a git repository'))return;return log(trim(s));};}const getErrorCode=({code=0}={})=>code;const getErrorMessage=({message=''}={})=>message;function getCatGitRefsRemotesOriginHeadCommand(directory=DIRECTORY){log('getCatGitRefsRemotesOriginHeadCommand');return`
|
|
2
2
|
DIR=$(echo "${directory}/.git/refs/remotes/origin/HEAD" | sed -e "s/\\//\\\\\\/g" -e "s/://" | cat 2> /dev/null)
|
|
3
3
|
[[ $DIR =~ "[-0-9a-zA-Z]*$" ]]
|
|
4
4
|
echo "$\{BASH_REMATCH[0]}"
|
|
5
|
-
`;}function isCommandError(e){log('isCommandError');return getErrorCode(e)===1&&getErrorMessage(e).toLowerCase().startsWith('command failed:');}function catGitRefsRemotesOriginHead(directory=DIRECTORY){log('catGitRefsRemotesOriginHead');return new Promise((resolve,reject)=>{const command=getCatGitRefsRemotesOriginHeadCommand(directory);const{stdout,stderr}=(0,_child_process.exec)(command,{...OPTIONS,cwd:directory},(e,v='')=>!e?resolve(trim(v)):reject(e));stdout.on('data',out('cat-git-refs-remotes-origin-head',directory));stderr.on('data',err('cat-git-refs-remotes-origin-head',directory));});}function gitRevParse(directory=DIRECTORY){log('gitRevParse');return new Promise((resolve,reject)=>{const command='git rev-parse --show-toplevel';const{stdout,stderr}=(0,_child_process.exec)(command,{...OPTIONS,cwd:directory},(e,v='')=>!e?resolve(trim(v)):reject(e));stdout.on('data',out('git-rev-parse',directory));stderr.on('data',err('git-rev-parse',directory));});}function gitCheckout(directory=DIRECTORY,branch=BRANCH){log('gitCheckout');return new Promise((resolve,reject)=>{const command=`cd "${directory}" && git checkout ${branch}`;const{stdout,stderr}=(0,_child_process.exec)(command,{...OPTIONS,cwd:directory},(e,v)=>e?isCommandError(e)?resolve(v):reject(e):resolve(v));stdout.on('data',use('git-checkout'));stderr.on('data',use('git-checkout'));});}function gitPull(directory=DIRECTORY){log('gitPull');return new Promise((resolve,reject)=>{const command=`cd "${directory}" && git pull`;const{stdout,stderr}=(0,_child_process.exec)(command,{...OPTIONS,cwd:directory},(e,v)=>e?isCommandError(e)?resolve(v):reject(e):resolve(v));stdout.on('data',use('git-pull'));stderr.on('data',use('git-pull'));});}function gitPush(directory=DIRECTORY){log('gitPush');return new Promise((resolve,reject)=>{const command=`cd "${directory}" && git push`;const{stdout,stderr}=(0,_child_process.exec)(command,{...OPTIONS,cwd:directory},(e,v)=>e?isCommandError(e)?resolve(v):reject(e):resolve(v));stdout.on('data',use('git-push'));stderr.on('data',use('git-push'));});}function gitAdd(directory=DIRECTORY,add=ADD){log('gitAdd');return new Promise((resolve,reject)=>{const command=`cd "${directory}" && git add ${add}`;const{stdout,stderr}=(0,_child_process.exec)(command,{...OPTIONS,cwd:directory},(e,v)=>e?isCommandError(e)?resolve(v):reject(e):resolve(v));stdout.on('data',use('git-add'));stderr.on('data',use('git-add'));});}function gitCommit(directory=DIRECTORY,commit=COMMIT){log('gitCommit');return new Promise((resolve,reject)=>{const command=`cd "${directory}" && git commit -m "${commit}"`;const{stdout,stderr}=(0,_child_process.exec)(command,{...OPTIONS,cwd:directory},(e,v)=>e?isCommandError(e)?resolve(v):reject(e):resolve(v));stdout.on('data',use('git-commit'));stderr.on('data',use('git-commit'));});}
|
|
5
|
+
`;}function isCommandError(e){log('isCommandError');return getErrorCode(e)===1&&getErrorMessage(e).toLowerCase().startsWith('command failed:');}function catGitRefsRemotesOriginHead(directory=DIRECTORY){log('catGitRefsRemotesOriginHead');return new Promise((resolve,reject)=>{const command=getCatGitRefsRemotesOriginHeadCommand(directory);const{stdout,stderr}=(0,_child_process.exec)(command,{...OPTIONS,cwd:directory},(e,v='')=>!e?resolve(trim(v)):reject(e));stdout.on('data',out('cat-git-refs-remotes-origin-head',directory));stderr.on('data',err('cat-git-refs-remotes-origin-head',directory));});}function gitRevParse(directory=DIRECTORY){log('gitRevParse');return new Promise((resolve,reject)=>{const command='git rev-parse --show-toplevel';const{stdout,stderr}=(0,_child_process.exec)(command,{...OPTIONS,cwd:directory},(e,v='')=>!e?resolve(trim(v)):reject(e));stdout.on('data',out('git-rev-parse',directory));stderr.on('data',err('git-rev-parse',directory));});}function gitCheckout(directory=DIRECTORY,branch=BRANCH){log('gitCheckout');return new Promise((resolve,reject)=>{const command=`cd "${directory}" && git checkout ${branch}`;const{stdout,stderr}=(0,_child_process.exec)(command,{...OPTIONS,cwd:directory},(e,v)=>e?isCommandError(e)?resolve(v):reject(e):resolve(v));stdout.on('data',use('git-checkout'));stderr.on('data',use('git-checkout'));});}function gitPull(directory=DIRECTORY){log('gitPull');return new Promise((resolve,reject)=>{const command=`cd "${directory}" && git pull`;const{stdout,stderr}=(0,_child_process.exec)(command,{...OPTIONS,cwd:directory},(e,v)=>e?isCommandError(e)?resolve(v):reject(e):resolve(v));stdout.on('data',use('git-pull'));stderr.on('data',use('git-pull'));});}function gitPush(directory=DIRECTORY){log('gitPush');return new Promise((resolve,reject)=>{const command=`cd "${directory}" && git push`;const{stdout,stderr}=(0,_child_process.exec)(command,{...OPTIONS,cwd:directory},(e,v)=>e?isCommandError(e)?resolve(v):reject(e):resolve(v));stdout.on('data',use('git-push'));stderr.on('data',use('git-push'));});}function gitPushTags(directory=DIRECTORY){log('gitPushTags');return new Promise((resolve,reject)=>{const command=`cd "${directory}" && git push --tags`;const{stdout,stderr}=(0,_child_process.exec)(command,{...OPTIONS,cwd:directory},(e,v)=>e?isCommandError(e)?resolve(v):reject(e):resolve(v));stdout.on('data',use('git-push-tags'));stderr.on('data',use('git-push-tags'));});}function gitAdd(directory=DIRECTORY,add=ADD){log('gitAdd');return new Promise((resolve,reject)=>{const command=`cd "${directory}" && git add ${add}`;const{stdout,stderr}=(0,_child_process.exec)(command,{...OPTIONS,cwd:directory},(e,v)=>e?isCommandError(e)?resolve(v):reject(e):resolve(v));stdout.on('data',use('git-add'));stderr.on('data',use('git-add'));});}function gitCommit(directory=DIRECTORY,commit=COMMIT){log('gitCommit');return new Promise((resolve,reject)=>{const command=`cd "${directory}" && git commit -m "${commit}"`;const{stdout,stderr}=(0,_child_process.exec)(command,{...OPTIONS,cwd:directory},(e,v)=>e?isCommandError(e)?resolve(v):reject(e):resolve(v));stdout.on('data',use('git-commit'));stderr.on('data',use('git-commit'));});}
|
package/lib/common/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.getCommands=exports.getBundleDependencies=exports.REGISTRY=exports.NVM=exports.DIRECTORY=void 0;exports.getDeps=getDeps;exports.getDepsExact=getDepsExact;exports.isExact=exports.getSaveProdParameter=exports.getSaveOptionalParameter=exports.getSaveExactParameter=exports.getSaveDevParameter=exports.getSaveBundleParameter=exports.getRegistryParameter=exports.getProdDependencies=exports.getPeerDependencies=exports.getOptionalDependencies=exports.getNoSaveParameter=exports.getDevDependencies=void 0;exports.normalise=normalise;exports.transform=transform;exports.transformDependency=void 0;var _debug=_interopRequireDefault(require("debug"));var _os=require("os");var _path=require("path");function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};}const log=(0,_debug.default)('@modernpoacher/deps');log(`\`common\` (${_os.platform}) is awake`);const{path:MODULE_PATH}=module;const DIRECTORY='.';exports.DIRECTORY=DIRECTORY;const REGISTRY='https://registry.npmjs.org';exports.REGISTRY=REGISTRY;const NVM=(0,_path.resolve)(MODULE_PATH,'../../nvm.sh');exports.NVM=NVM;const getSaveProdParameter=commands=>commands.concat(' --save-prod');exports.getSaveProdParameter=getSaveProdParameter;const getSaveDevParameter=commands=>commands.concat(' --save-dev');exports.getSaveDevParameter=getSaveDevParameter;const getSaveBundleParameter=commands=>commands.concat(' --save-bundle');exports.getSaveBundleParameter=getSaveBundleParameter;const getSaveOptionalParameter=commands=>commands.concat(' --save-optional');exports.getSaveOptionalParameter=getSaveOptionalParameter;const getRegistryParameter=(r,commands)=>r?commands.concat(` --registry ${r}`):commands;exports.getRegistryParameter=getRegistryParameter;const getNoSaveParameter=(s,commands)=>s?commands:commands.concat(' --no-save');exports.getNoSaveParameter=getNoSaveParameter;const getSaveExactParameter=commands=>commands.concat(' --save-exact');exports.getSaveExactParameter=getSaveExactParameter;const getCommands=(directory=DIRECTORY,commands='npm i')=>`
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.getCommands=exports.getBundleDependencies=exports.REGISTRY=exports.NVM=exports.DIRECTORY=void 0;exports.getDeps=getDeps;exports.getDepsExact=getDepsExact;exports.isExact=exports.getSaveProdParameter=exports.getSaveOptionalParameter=exports.getSaveExactParameter=exports.getSaveDevParameter=exports.getSaveBundleParameter=exports.getRegistryParameter=exports.getProdDependencies=exports.getPeerDependencies=exports.getOptionalDependencies=exports.getNoSaveParameter=exports.getForceParameter=exports.getDevDependencies=void 0;exports.normalise=normalise;exports.transform=transform;exports.transformDependency=void 0;var _debug=_interopRequireDefault(require("debug"));var _os=require("os");var _path=require("path");function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};}const log=(0,_debug.default)('@modernpoacher/deps');log(`\`common\` (${_os.platform}) is awake`);const{path:MODULE_PATH}=module;const DIRECTORY='.';exports.DIRECTORY=DIRECTORY;const REGISTRY='https://registry.npmjs.org';exports.REGISTRY=REGISTRY;const NVM=(0,_path.resolve)(MODULE_PATH,'../../nvm.sh');exports.NVM=NVM;const getSaveProdParameter=commands=>commands.concat(' --save-prod');exports.getSaveProdParameter=getSaveProdParameter;const getSaveDevParameter=commands=>commands.concat(' --save-dev');exports.getSaveDevParameter=getSaveDevParameter;const getSaveBundleParameter=commands=>commands.concat(' --save-bundle');exports.getSaveBundleParameter=getSaveBundleParameter;const getSaveOptionalParameter=commands=>commands.concat(' --save-optional');exports.getSaveOptionalParameter=getSaveOptionalParameter;const getRegistryParameter=(r,commands)=>r?commands.concat(` --registry ${r}`):commands;exports.getRegistryParameter=getRegistryParameter;const getForceParameter=(f,commands)=>f?commands.concat(' --force'):commands;exports.getForceParameter=getForceParameter;const getNoSaveParameter=(s,commands)=>s?commands:commands.concat(' --no-save');exports.getNoSaveParameter=getNoSaveParameter;const getSaveExactParameter=commands=>commands.concat(' --save-exact');exports.getSaveExactParameter=getSaveExactParameter;const getCommands=(directory=DIRECTORY,commands='npm i')=>`
|
|
2
2
|
export PATH=/usr/local/bin:$PATH &> /dev/null
|
|
3
3
|
|
|
4
4
|
cd "${directory}"
|
package/lib/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.executeBundle=executeBundle;exports.executeDev=executeDev;exports.executeOptional=executeOptional;exports.executeProd=executeProd;exports.getInstallCommands=void 0;exports.getInstallSaveBundleCommands=getInstallSaveBundleCommands;exports.getInstallSaveBundleSaveExactCommands=getInstallSaveBundleSaveExactCommands;exports.getInstallSaveDevCommands=getInstallSaveDevCommands;exports.getInstallSaveDevSaveExactCommands=getInstallSaveDevSaveExactCommands;exports.getInstallSaveExactCommands=void 0;exports.getInstallSaveOptionalCommands=getInstallSaveOptionalCommands;exports.getInstallSaveOptionalSaveExactCommands=getInstallSaveOptionalSaveExactCommands;exports.getInstallSaveProdCommands=getInstallSaveProdCommands;exports.getInstallSaveProdSaveExactCommands=getInstallSaveProdSaveExactCommands;exports.installSaveBundle=installSaveBundle;exports.installSaveBundleSaveExact=installSaveBundleSaveExact;exports.installSaveDev=installSaveDev;exports.installSaveDevSaveExact=installSaveDevSaveExact;exports.installSaveOptional=installSaveOptional;exports.installSaveOptionalSaveExact=installSaveOptionalSaveExact;exports.installSaveProd=installSaveProd;exports.installSaveProdSaveExact=installSaveProdSaveExact;var _debug=_interopRequireDefault(require("debug"));var _os=require("os");var _child_process=require("child_process");var _common=require("./common");function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};}const log=(0,_debug.default)('@modernpoacher/deps');log(`\`deps\` (${_os.platform}) is awake`);const getInstallSaveExactCommands=(p,
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.executeBundle=executeBundle;exports.executeDev=executeDev;exports.executeOptional=executeOptional;exports.executeProd=executeProd;exports.getInstallCommands=void 0;exports.getInstallSaveBundleCommands=getInstallSaveBundleCommands;exports.getInstallSaveBundleSaveExactCommands=getInstallSaveBundleSaveExactCommands;exports.getInstallSaveDevCommands=getInstallSaveDevCommands;exports.getInstallSaveDevSaveExactCommands=getInstallSaveDevSaveExactCommands;exports.getInstallSaveExactCommands=void 0;exports.getInstallSaveOptionalCommands=getInstallSaveOptionalCommands;exports.getInstallSaveOptionalSaveExactCommands=getInstallSaveOptionalSaveExactCommands;exports.getInstallSaveProdCommands=getInstallSaveProdCommands;exports.getInstallSaveProdSaveExactCommands=getInstallSaveProdSaveExactCommands;exports.installSaveBundle=installSaveBundle;exports.installSaveBundleSaveExact=installSaveBundleSaveExact;exports.installSaveDev=installSaveDev;exports.installSaveDevSaveExact=installSaveDevSaveExact;exports.installSaveOptional=installSaveOptional;exports.installSaveOptionalSaveExact=installSaveOptionalSaveExact;exports.installSaveProd=installSaveProd;exports.installSaveProdSaveExact=installSaveProdSaveExact;var _debug=_interopRequireDefault(require("debug"));var _os=require("os");var _child_process=require("child_process");var _common=require("./common");function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};}const log=(0,_debug.default)('@modernpoacher/deps');log(`\`deps\` (${_os.platform}) is awake`);const getInstallSaveExactCommands=(p,r,f)=>{log('getInstallSaveExactCommands');const c=(0,_common.transform)(p);log(c);const commands=`npm i ${c}`;return(0,_common.normalise)((0,_common.getRegistryParameter)(r,(0,_common.getForceParameter)(f,(0,_common.getSaveExactParameter)(commands))));};exports.getInstallSaveExactCommands=getInstallSaveExactCommands;const getInstallCommands=(p,r,f)=>{log('getInstallCommands');const c=(0,_common.transform)(p);log(c);const commands=`npm i ${c}`;return(0,_common.normalise)((0,_common.getRegistryParameter)(r,(0,_common.getForceParameter)(f,commands)));};exports.getInstallCommands=getInstallCommands;function getInstallSaveBundleSaveExactCommands(p,r,f){log('getInstallSaveBundleSaveExactCommands');const commands=getInstallSaveExactCommands(p,r,f);return(0,_common.normalise)((0,_common.getSaveBundleParameter)(commands));}function getInstallSaveBundleCommands(p,r,f){log('getInstallSaveBundleCommands');const commands=getInstallCommands(p,r,f);return(0,_common.normalise)((0,_common.getSaveBundleParameter)(commands));}function getInstallSaveOptionalSaveExactCommands(p,r,f){log('getInstallSaveOptionalSaveExactCommands');const commands=getInstallSaveExactCommands(p,r,f);return(0,_common.normalise)((0,_common.getSaveOptionalParameter)(commands));}function getInstallSaveOptionalCommands(p,r,f){log('getInstallSaveOptionalCommands');const commands=getInstallCommands(p,r,f);return(0,_common.normalise)((0,_common.getSaveOptionalParameter)(commands));}function getInstallSaveDevSaveExactCommands(p,r,f){log('getInstallSaveDevSaveExactCommands');const commands=getInstallSaveExactCommands(p,r,f);return(0,_common.normalise)((0,_common.getSaveDevParameter)(commands));}function getInstallSaveDevCommands(p,r,f){log('getInstallSaveDevCommands');const commands=getInstallCommands(p,r,f);return(0,_common.normalise)((0,_common.getSaveDevParameter)(commands));}function getInstallSaveProdSaveExactCommands(p,r,f){log('getInstallSaveProdSaveExactCommands');const commands=getInstallSaveExactCommands(p,r,f);return(0,_common.normalise)((0,_common.getSaveProdParameter)(commands));}function getInstallSaveProdCommands(p,r,f){log('getInstallSaveProdCommands');const commands=getInstallCommands(p,r,f);return(0,_common.normalise)((0,_common.getSaveProdParameter)(commands));}function installSaveBundleSaveExact(d,p,r,f){log('installSaveBundleSaveExact');return new Promise((resolve,reject)=>{const commands=(0,_common.getCommands)(d,getInstallSaveBundleSaveExactCommands(p,r,f));(0,_child_process.spawn)('/bin/bash',['-c',commands],{shell:true,stdio:'inherit'},e=>!e?resolve():reject(e)).on('close',resolve).on('error',reject);});}function installSaveBundle(d,p,r,f){log('installSaveBundle');return new Promise((resolve,reject)=>{const commands=(0,_common.getCommands)(d,getInstallSaveBundleCommands(p,r,f));(0,_child_process.spawn)('/bin/bash',['-c',commands],{shell:true,stdio:'inherit'},e=>!e?resolve():reject(e)).on('close',resolve).on('error',reject);});}function installSaveOptionalSaveExact(d,p,r,f){log('installSaveOptionalSaveExact');return new Promise((resolve,reject)=>{const commands=(0,_common.getCommands)(d,getInstallSaveOptionalSaveExactCommands(p,r,f));(0,_child_process.spawn)('/bin/bash',['-c',commands],{shell:true,stdio:'inherit'},e=>!e?resolve():reject(e)).on('close',resolve).on('error',reject);});}function installSaveOptional(d,p,r,f){log('installSaveOptional');return new Promise((resolve,reject)=>{const commands=(0,_common.getCommands)(d,getInstallSaveOptionalCommands(p,r,f));(0,_child_process.spawn)('/bin/bash',['-c',commands],{shell:true,stdio:'inherit'},e=>!e?resolve():reject(e)).on('close',resolve).on('error',reject);});}function installSaveDevSaveExact(d,p,r,f){log('installSaveDevSaveExact');return new Promise((resolve,reject)=>{const commands=(0,_common.getCommands)(d,getInstallSaveDevSaveExactCommands(p,r,f));(0,_child_process.spawn)('/bin/bash',['-c',commands],{shell:true,stdio:'inherit'},e=>!e?resolve():reject(e)).on('close',resolve).on('error',reject);});}function installSaveDev(d,p,r,f){log('installSaveDev');return new Promise((resolve,reject)=>{const commands=(0,_common.getCommands)(d,getInstallSaveDevCommands(p,r,f));(0,_child_process.spawn)('/bin/bash',['-c',commands],{shell:true,stdio:'inherit'},e=>!e?resolve():reject(e)).on('close',resolve).on('error',reject);});}function installSaveProdSaveExact(d,p,r,f){log('installSaveProdSaveExact');return new Promise((resolve,reject)=>{const commands=(0,_common.getCommands)(d,getInstallSaveProdSaveExactCommands(p,r,f));(0,_child_process.spawn)('/bin/bash',['-c',commands],{shell:true,stdio:'inherit'},e=>!e?resolve():reject(e)).on('close',resolve).on('error',reject);});}function installSaveProd(d,p,r,f){log('installSaveProd');return new Promise((resolve,reject)=>{const commands=(0,_common.getCommands)(d,getInstallSaveProdCommands(p,r,f));(0,_child_process.spawn)('/bin/bash',['-c',commands],{shell:true,stdio:'inherit'},e=>!e?resolve():reject(e)).on('close',resolve).on('error',reject);});}async function executeBundle(directory=_common.DIRECTORY,packages={},configuration={},registry=_common.REGISTRY,force=false){log('executeBundle');const depsExact=(0,_common.getDepsExact)(packages,configuration);if(depsExact.length)await installSaveBundleSaveExact(directory,depsExact,registry,force);const deps=(0,_common.getDeps)(packages);if(deps.length)await installSaveBundle(directory,deps,registry,force);}async function executeOptional(directory=_common.DIRECTORY,packages={},configuration={},registry=_common.REGISTRY,force=false){log('executeOptional');const depsExact=(0,_common.getDepsExact)(packages,configuration);if(depsExact.length)await installSaveOptionalSaveExact(directory,depsExact,registry);const deps=(0,_common.getDeps)(packages);if(deps.length)await installSaveOptional(directory,deps,registry);}async function executeDev(directory=_common.DIRECTORY,packages={},configuration={},registry=_common.REGISTRY,force=false){log('executeDev');const depsExact=(0,_common.getDepsExact)(packages,configuration);if(depsExact.length)await installSaveDevSaveExact(directory,depsExact,registry,force);const deps=(0,_common.getDeps)(packages);if(deps.length)await installSaveDev(directory,deps,registry,force);}async function executeProd(directory=_common.DIRECTORY,packages={},configuration={},registry=_common.REGISTRY,force=false){log('executeProd');const depsExact=(0,_common.getDepsExact)(packages,configuration);if(depsExact.length)await installSaveProdSaveExact(directory,depsExact,registry,force);const deps=(0,_common.getDeps)(packages);if(deps.length)await installSaveProd(directory,deps,registry,force);}
|
package/lib/install/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.execute=execute;exports.getInstallSaveExactCommands=exports.getInstallCommands=void 0;exports.install=install;exports.installSaveExact=installSaveExact;var _debug=_interopRequireDefault(require("debug"));var _os=require("os");var _child_process=require("child_process");var _common=require("../common");function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};}const log=(0,_debug.default)('@modernpoacher/deps:install');log(`\`install\` (${_os.platform}) is awake`);const getInstallSaveExactCommands=(p,
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.execute=execute;exports.getInstallSaveExactCommands=exports.getInstallCommands=void 0;exports.install=install;exports.installSaveExact=installSaveExact;var _debug=_interopRequireDefault(require("debug"));var _os=require("os");var _child_process=require("child_process");var _common=require("../common");function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};}const log=(0,_debug.default)('@modernpoacher/deps:install');log(`\`install\` (${_os.platform}) is awake`);const getInstallSaveExactCommands=(p,s,r,f)=>{log('getInstallSaveExactCommands');const commands=`npm i ${(0,_common.transform)(p)}`;return(0,_common.normalise)((0,_common.getNoSaveParameter)(s,(0,_common.getRegistryParameter)(r,(0,_common.getForceParameter)(f,(0,_common.getSaveExactParameter)(commands)))));};exports.getInstallSaveExactCommands=getInstallSaveExactCommands;const getInstallCommands=(p,s,r,f)=>{log('getInstallCommands');const commands=`npm i ${(0,_common.transform)(p)}`;return(0,_common.normalise)((0,_common.getNoSaveParameter)(s,(0,_common.getRegistryParameter)(r,(0,_common.getForceParameter)(f,commands))));};exports.getInstallCommands=getInstallCommands;function installSaveExact(d,p,s,r,f){log('installSaveExact');return new Promise((resolve,reject)=>{const commands=(0,_common.getCommands)(d,getInstallSaveExactCommands(p,s,r,f));(0,_child_process.spawn)('/bin/bash',['-c',commands],{shell:true,stdio:'inherit'},e=>!e?resolve():reject(e)).on('close',resolve).on('error',reject);});}function install(d,p,s,r,f){log('install');return new Promise((resolve,reject)=>{const commands=(0,_common.getCommands)(d,getInstallCommands(p,s,r,f));(0,_child_process.spawn)('/bin/bash',['-c',commands],{shell:true,stdio:'inherit'},e=>!e?resolve():reject(e)).on('close',resolve).on('error',reject);});}async function execute(directory=_common.DIRECTORY,packages={},configuration={},save=false,registry=_common.REGISTRY,force=false){log('execute');const depsExact=(0,_common.getDepsExact)(packages,configuration);if(depsExact.length)await installSaveExact(directory,depsExact,save,registry,force);const deps=(0,_common.getDeps)(packages);if(deps.length)await install(directory,deps,save,registry,force);}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@modernpoacher/deps",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.18",
|
|
4
4
|
"description": "Update NPM package dependencies from the command line",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"deps",
|
|
@@ -50,30 +50,30 @@
|
|
|
50
50
|
"deps-head": "bin/head.sh"
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
|
-
"commander": "^
|
|
54
|
-
"debug": "^4.3.
|
|
55
|
-
"glob-all": "^3.
|
|
53
|
+
"commander": "^9.1.0",
|
|
54
|
+
"debug": "^4.3.4",
|
|
55
|
+
"glob-all": "^3.3.0",
|
|
56
56
|
"module-alias": "^2.2.2",
|
|
57
|
-
"supports-color": "^9.1
|
|
57
|
+
"supports-color": "^9.2.1"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
|
-
"@babel/cli": "^7.
|
|
61
|
-
"@babel/core": "^7.
|
|
62
|
-
"@babel/eslint-parser": "^7.
|
|
63
|
-
"@babel/preset-env": "^7.16.
|
|
64
|
-
"@babel/register": "^7.
|
|
60
|
+
"@babel/cli": "^7.17.6",
|
|
61
|
+
"@babel/core": "^7.17.8",
|
|
62
|
+
"@babel/eslint-parser": "^7.17.0",
|
|
63
|
+
"@babel/preset-env": "^7.16.11",
|
|
64
|
+
"@babel/register": "^7.17.7",
|
|
65
65
|
"babel-plugin-module-resolver": "^4.1.0",
|
|
66
|
-
"chai": "^4.3.
|
|
67
|
-
"core-js": "^3.
|
|
66
|
+
"chai": "^4.3.6",
|
|
67
|
+
"core-js": "^3.21.1",
|
|
68
68
|
"cross-env": "^7.0.3",
|
|
69
69
|
"eslint": "7.32.0",
|
|
70
70
|
"eslint-config-standard": "^16.0.3",
|
|
71
71
|
"eslint-import-resolver-babel-module": "^5.3.1",
|
|
72
|
-
"eslint-plugin-import": "^2.25.
|
|
72
|
+
"eslint-plugin-import": "^2.25.4",
|
|
73
73
|
"eslint-plugin-node": "^11.1.0",
|
|
74
|
-
"eslint-plugin-promise": "
|
|
74
|
+
"eslint-plugin-promise": "5.2.0",
|
|
75
75
|
"husky": "^7.0.4",
|
|
76
|
-
"mocha": "^9.
|
|
76
|
+
"mocha": "^9.2.2",
|
|
77
77
|
"rimraf": "^3.0.2"
|
|
78
78
|
},
|
|
79
79
|
"_moduleAliases": {
|
package/src/common/git/index.js
CHANGED
|
@@ -191,6 +191,7 @@ export function gitRevParse (directory = DIRECTORY) {
|
|
|
191
191
|
* Switch to the default value if none is supplied
|
|
192
192
|
*
|
|
193
193
|
* @param {String} directory - A directory configured for Git
|
|
194
|
+
* @param {String} branch - The Git branch
|
|
194
195
|
*
|
|
195
196
|
* @return {Promise}
|
|
196
197
|
*/
|
|
@@ -278,6 +279,37 @@ export function gitPush (directory = DIRECTORY) {
|
|
|
278
279
|
)
|
|
279
280
|
}
|
|
280
281
|
|
|
282
|
+
/**
|
|
283
|
+
* @function gitPushTags
|
|
284
|
+
*
|
|
285
|
+
* Push tags changes to the Git remote
|
|
286
|
+
*
|
|
287
|
+
* @param {String} directory - A directory configured for Git
|
|
288
|
+
*
|
|
289
|
+
* @return {Promise}
|
|
290
|
+
*/
|
|
291
|
+
export function gitPushTags (directory = DIRECTORY) {
|
|
292
|
+
log('gitPushTags')
|
|
293
|
+
|
|
294
|
+
return (
|
|
295
|
+
new Promise((resolve, reject) => {
|
|
296
|
+
const command = `cd "${directory}" && git push --tags`
|
|
297
|
+
|
|
298
|
+
/**
|
|
299
|
+
* log(command)
|
|
300
|
+
*/
|
|
301
|
+
|
|
302
|
+
const {
|
|
303
|
+
stdout,
|
|
304
|
+
stderr
|
|
305
|
+
} = exec(command, { ...OPTIONS, cwd: directory }, (e, v) => (e) ? isCommandError(e) ? resolve(v) : reject(e) : resolve(v))
|
|
306
|
+
|
|
307
|
+
stdout.on('data', use('git-push-tags'))
|
|
308
|
+
stderr.on('data', use('git-push-tags'))
|
|
309
|
+
})
|
|
310
|
+
)
|
|
311
|
+
}
|
|
312
|
+
|
|
281
313
|
/**
|
|
282
314
|
* @function gitAdd
|
|
283
315
|
*
|
package/src/common/index.js
CHANGED
|
@@ -78,6 +78,18 @@ export const getSaveOptionalParameter = (commands) => commands.concat(' --save-o
|
|
|
78
78
|
*/
|
|
79
79
|
export const getRegistryParameter = (r, commands) => r ? commands.concat(` --registry ${r}`) : commands
|
|
80
80
|
|
|
81
|
+
/**
|
|
82
|
+
* @function getForceParameter
|
|
83
|
+
*
|
|
84
|
+
* Get the "force" parameter and argument
|
|
85
|
+
*
|
|
86
|
+
* @param {String} force
|
|
87
|
+
* @param {String} current commands string
|
|
88
|
+
*
|
|
89
|
+
* @return {String}
|
|
90
|
+
*/
|
|
91
|
+
export const getForceParameter = (f, commands) => f ? commands.concat(' --force') : commands
|
|
92
|
+
|
|
81
93
|
/**
|
|
82
94
|
* @function getNoSaveParameter
|
|
83
95
|
*
|
package/src/index.js
CHANGED
|
@@ -35,16 +35,19 @@ log(`\`deps\` (${platform}) is awake`)
|
|
|
35
35
|
* Get the `npm install --save-exact` commands as a string of parameters and arguments
|
|
36
36
|
*
|
|
37
37
|
* @param {Object} p - Packages
|
|
38
|
-
* @param {Object} c - Configuration
|
|
39
38
|
* @param {String} r - Registry
|
|
40
|
-
* @param {Boolean}
|
|
39
|
+
* @param {Boolean} f - Force
|
|
41
40
|
*
|
|
42
41
|
* @return {Array}
|
|
43
42
|
*/
|
|
44
|
-
export const getInstallSaveExactCommands = (p,
|
|
43
|
+
export const getInstallSaveExactCommands = (p, r, f) => {
|
|
45
44
|
log('getInstallSaveExactCommands')
|
|
46
45
|
|
|
47
|
-
const
|
|
46
|
+
const c = transform(p)
|
|
47
|
+
|
|
48
|
+
log(c)
|
|
49
|
+
|
|
50
|
+
const commands = `npm i ${c}`
|
|
48
51
|
|
|
49
52
|
return normalise(
|
|
50
53
|
getRegistryParameter(r, getForceParameter(f, getSaveExactParameter(commands)))
|
|
@@ -57,16 +60,19 @@ export const getInstallSaveExactCommands = (p, c, r, f) => {
|
|
|
57
60
|
* Get the `npm install` commands as a string of parameters and arguments
|
|
58
61
|
*
|
|
59
62
|
* @param {Object} p - Packages
|
|
60
|
-
* @param {Object} c - Configuration
|
|
61
63
|
* @param {String} r - Registry
|
|
62
|
-
* @param {Boolean}
|
|
64
|
+
* @param {Boolean} f - Force
|
|
63
65
|
*
|
|
64
66
|
* @return {Array}
|
|
65
67
|
*/
|
|
66
|
-
export const getInstallCommands = (p,
|
|
68
|
+
export const getInstallCommands = (p, r, f) => {
|
|
67
69
|
log('getInstallCommands')
|
|
68
70
|
|
|
69
|
-
const
|
|
71
|
+
const c = transform(p)
|
|
72
|
+
|
|
73
|
+
log(c)
|
|
74
|
+
|
|
75
|
+
const commands = `npm i ${c}`
|
|
70
76
|
|
|
71
77
|
return normalise(
|
|
72
78
|
getRegistryParameter(r, getForceParameter(f, commands))
|
|
@@ -79,16 +85,15 @@ export const getInstallCommands = (p, c, r, f) => {
|
|
|
79
85
|
* Get the `npm install --save-bundle --save-exact` commands as a string of parameters and arguments
|
|
80
86
|
*
|
|
81
87
|
* @param {Object} p - Packages
|
|
82
|
-
* @param {Object} c - Configuration
|
|
83
88
|
* @param {String} r - Registry
|
|
84
|
-
* @param {Boolean}
|
|
89
|
+
* @param {Boolean} f - Force
|
|
85
90
|
*
|
|
86
91
|
* @return {Array}
|
|
87
92
|
*/
|
|
88
|
-
export function getInstallSaveBundleSaveExactCommands (p,
|
|
93
|
+
export function getInstallSaveBundleSaveExactCommands (p, r, f) {
|
|
89
94
|
log('getInstallSaveBundleSaveExactCommands')
|
|
90
95
|
|
|
91
|
-
const commands = getInstallSaveExactCommands(p,
|
|
96
|
+
const commands = getInstallSaveExactCommands(p, r, f)
|
|
92
97
|
|
|
93
98
|
return normalise(
|
|
94
99
|
getSaveBundleParameter(commands)
|
|
@@ -101,16 +106,15 @@ export function getInstallSaveBundleSaveExactCommands (p, c, r, f) {
|
|
|
101
106
|
* Get the `npm install --save-bundle` commands as a string of parameters and arguments
|
|
102
107
|
*
|
|
103
108
|
* @param {Object} p - Packages
|
|
104
|
-
* @param {Object} c - Configuration
|
|
105
109
|
* @param {String} r - Registry
|
|
106
|
-
* @param {Boolean}
|
|
110
|
+
* @param {Boolean} f - Force
|
|
107
111
|
*
|
|
108
112
|
* @return {Array}
|
|
109
113
|
*/
|
|
110
|
-
export function getInstallSaveBundleCommands (p,
|
|
114
|
+
export function getInstallSaveBundleCommands (p, r, f) {
|
|
111
115
|
log('getInstallSaveBundleCommands')
|
|
112
116
|
|
|
113
|
-
const commands = getInstallCommands(p,
|
|
117
|
+
const commands = getInstallCommands(p, r, f)
|
|
114
118
|
|
|
115
119
|
return normalise(
|
|
116
120
|
getSaveBundleParameter(commands)
|
|
@@ -123,16 +127,15 @@ export function getInstallSaveBundleCommands (p, c, r, f) {
|
|
|
123
127
|
* Get the `npm install --save-optional --save-exact` commands as a string of parameters and arguments
|
|
124
128
|
*
|
|
125
129
|
* @param {Object} p - Packages
|
|
126
|
-
* @param {Object} c - Configuration
|
|
127
130
|
* @param {String} r - Registry
|
|
128
|
-
* @param {Boolean}
|
|
131
|
+
* @param {Boolean} f - Force
|
|
129
132
|
*
|
|
130
133
|
* @return {Array}
|
|
131
134
|
*/
|
|
132
|
-
export function getInstallSaveOptionalSaveExactCommands (p,
|
|
135
|
+
export function getInstallSaveOptionalSaveExactCommands (p, r, f) {
|
|
133
136
|
log('getInstallSaveOptionalSaveExactCommands')
|
|
134
137
|
|
|
135
|
-
const commands = getInstallSaveExactCommands(p,
|
|
138
|
+
const commands = getInstallSaveExactCommands(p, r, f)
|
|
136
139
|
|
|
137
140
|
return normalise(
|
|
138
141
|
getSaveOptionalParameter(commands)
|
|
@@ -145,16 +148,15 @@ export function getInstallSaveOptionalSaveExactCommands (p, c, r, f) {
|
|
|
145
148
|
* Get the `npm install --save-optional` commands as a string of parameters and arguments
|
|
146
149
|
*
|
|
147
150
|
* @param {Object} p - Packages
|
|
148
|
-
* @param {Object} c - Configuration
|
|
149
151
|
* @param {String} r - Registry
|
|
150
|
-
* @param {Boolean}
|
|
152
|
+
* @param {Boolean} f - Force
|
|
151
153
|
*
|
|
152
154
|
* @return {Array}
|
|
153
155
|
*/
|
|
154
|
-
export function getInstallSaveOptionalCommands (p,
|
|
156
|
+
export function getInstallSaveOptionalCommands (p, r, f) {
|
|
155
157
|
log('getInstallSaveOptionalCommands')
|
|
156
158
|
|
|
157
|
-
const commands = getInstallCommands(p,
|
|
159
|
+
const commands = getInstallCommands(p, r, f)
|
|
158
160
|
|
|
159
161
|
return normalise(
|
|
160
162
|
getSaveOptionalParameter(commands)
|
|
@@ -167,16 +169,15 @@ export function getInstallSaveOptionalCommands (p, c, r, f) {
|
|
|
167
169
|
* Get the `npm install --save-dev --save-exact` commands as a string of parameters and arguments
|
|
168
170
|
*
|
|
169
171
|
* @param {Object} p - Packages
|
|
170
|
-
* @param {Object} c - Configuration
|
|
171
172
|
* @param {String} r - Registry
|
|
172
|
-
* @param {Boolean}
|
|
173
|
+
* @param {Boolean} f - Force
|
|
173
174
|
*
|
|
174
175
|
* @return {Array}
|
|
175
176
|
*/
|
|
176
|
-
export function getInstallSaveDevSaveExactCommands (p,
|
|
177
|
+
export function getInstallSaveDevSaveExactCommands (p, r, f) {
|
|
177
178
|
log('getInstallSaveDevSaveExactCommands')
|
|
178
179
|
|
|
179
|
-
const commands = getInstallSaveExactCommands(p,
|
|
180
|
+
const commands = getInstallSaveExactCommands(p, r, f)
|
|
180
181
|
|
|
181
182
|
return normalise(
|
|
182
183
|
getSaveDevParameter(commands)
|
|
@@ -189,16 +190,15 @@ export function getInstallSaveDevSaveExactCommands (p, c, r, f) {
|
|
|
189
190
|
* Get the `npm install --save-dev` commands as a string of parameters and arguments
|
|
190
191
|
*
|
|
191
192
|
* @param {Object} p - Packages
|
|
192
|
-
* @param {Object} c - Configuration
|
|
193
193
|
* @param {String} r - Registry
|
|
194
|
-
* @param {Boolean}
|
|
194
|
+
* @param {Boolean} f - Force
|
|
195
195
|
*
|
|
196
196
|
* @return {Array}
|
|
197
197
|
*/
|
|
198
|
-
export function getInstallSaveDevCommands (p,
|
|
198
|
+
export function getInstallSaveDevCommands (p, r, f) {
|
|
199
199
|
log('getInstallSaveDevCommands')
|
|
200
200
|
|
|
201
|
-
const commands = getInstallCommands(p,
|
|
201
|
+
const commands = getInstallCommands(p, r, f)
|
|
202
202
|
|
|
203
203
|
return normalise(
|
|
204
204
|
getSaveDevParameter(commands)
|
|
@@ -211,16 +211,15 @@ export function getInstallSaveDevCommands (p, c, r, f) {
|
|
|
211
211
|
* Get the `npm install --save-prod --save-exact` commands as a string of parameters and arguments
|
|
212
212
|
*
|
|
213
213
|
* @param {Object} p - Packages
|
|
214
|
-
* @param {Object} c - Configuration
|
|
215
214
|
* @param {String} r - Registry
|
|
216
|
-
* @param {Boolean}
|
|
215
|
+
* @param {Boolean} f - Force
|
|
217
216
|
*
|
|
218
217
|
* @return {Array}
|
|
219
218
|
*/
|
|
220
|
-
export function getInstallSaveProdSaveExactCommands (p,
|
|
219
|
+
export function getInstallSaveProdSaveExactCommands (p, r, f) {
|
|
221
220
|
log('getInstallSaveProdSaveExactCommands')
|
|
222
221
|
|
|
223
|
-
const commands = getInstallSaveExactCommands(p,
|
|
222
|
+
const commands = getInstallSaveExactCommands(p, r, f)
|
|
224
223
|
|
|
225
224
|
return normalise(
|
|
226
225
|
getSaveProdParameter(commands)
|
|
@@ -233,16 +232,15 @@ export function getInstallSaveProdSaveExactCommands (p, c, r, f) {
|
|
|
233
232
|
* Get the `npm install --save-prod` commands as a string of parameters and arguments
|
|
234
233
|
*
|
|
235
234
|
* @param {Object} p - Packages
|
|
236
|
-
* @param {Object} c - Configuration
|
|
237
235
|
* @param {String} r - Registry
|
|
238
|
-
* @param {Boolean}
|
|
236
|
+
* @param {Boolean} f - Force
|
|
239
237
|
*
|
|
240
238
|
* @return {Array}
|
|
241
239
|
*/
|
|
242
|
-
export function getInstallSaveProdCommands (p,
|
|
240
|
+
export function getInstallSaveProdCommands (p, r, f) {
|
|
243
241
|
log('getInstallSaveProdCommands')
|
|
244
242
|
|
|
245
|
-
const commands = getInstallCommands(p,
|
|
243
|
+
const commands = getInstallCommands(p, r, f)
|
|
246
244
|
|
|
247
245
|
return normalise(
|
|
248
246
|
getSaveProdParameter(commands)
|
|
@@ -256,17 +254,17 @@ export function getInstallSaveProdCommands (p, c, r, f) {
|
|
|
256
254
|
*
|
|
257
255
|
* @param {String} d - Directory
|
|
258
256
|
* @param {Object} p - Packages
|
|
259
|
-
* @param {Object} c - Configuration
|
|
260
257
|
* @param {String} r - Registry
|
|
258
|
+
* @param {Boolean} f - Force
|
|
261
259
|
*
|
|
262
260
|
* @return {Promise}
|
|
263
261
|
*/
|
|
264
|
-
export function installSaveBundleSaveExact (d, p,
|
|
262
|
+
export function installSaveBundleSaveExact (d, p, r, f) {
|
|
265
263
|
log('installSaveBundleSaveExact')
|
|
266
264
|
|
|
267
265
|
return (
|
|
268
266
|
new Promise((resolve, reject) => {
|
|
269
|
-
const commands = getCommands(d, getInstallSaveBundleSaveExactCommands(p,
|
|
267
|
+
const commands = getCommands(d, getInstallSaveBundleSaveExactCommands(p, r, f))
|
|
270
268
|
|
|
271
269
|
spawn('/bin/bash', ['-c', commands], { shell: true, stdio: 'inherit' }, (e) => (!e) ? resolve() : reject(e))
|
|
272
270
|
.on('close', resolve)
|
|
@@ -282,17 +280,17 @@ export function installSaveBundleSaveExact (d, p, c, r, f) {
|
|
|
282
280
|
*
|
|
283
281
|
* @param {String} d - Directory
|
|
284
282
|
* @param {Object} p - Packages
|
|
285
|
-
* @param {Object} c - Configuration
|
|
286
283
|
* @param {String} r - Registry
|
|
284
|
+
* @param {Boolean} f - Force
|
|
287
285
|
*
|
|
288
286
|
* @return {Promise}
|
|
289
287
|
*/
|
|
290
|
-
export function installSaveBundle (d, p,
|
|
288
|
+
export function installSaveBundle (d, p, r, f) {
|
|
291
289
|
log('installSaveBundle')
|
|
292
290
|
|
|
293
291
|
return (
|
|
294
292
|
new Promise((resolve, reject) => {
|
|
295
|
-
const commands = getCommands(d, getInstallSaveBundleCommands(p,
|
|
293
|
+
const commands = getCommands(d, getInstallSaveBundleCommands(p, r, f))
|
|
296
294
|
|
|
297
295
|
spawn('/bin/bash', ['-c', commands], { shell: true, stdio: 'inherit' }, (e) => (!e) ? resolve() : reject(e))
|
|
298
296
|
.on('close', resolve)
|
|
@@ -308,17 +306,17 @@ export function installSaveBundle (d, p, c, r, f) {
|
|
|
308
306
|
*
|
|
309
307
|
* @param {String} d - Directory
|
|
310
308
|
* @param {Object} p - Packages
|
|
311
|
-
* @param {Object} c - Configuration
|
|
312
309
|
* @param {String} r - Registry
|
|
310
|
+
* @param {Boolean} f - Force
|
|
313
311
|
*
|
|
314
312
|
* @return {Promise}
|
|
315
313
|
*/
|
|
316
|
-
export function installSaveOptionalSaveExact (d, p,
|
|
314
|
+
export function installSaveOptionalSaveExact (d, p, r, f) {
|
|
317
315
|
log('installSaveOptionalSaveExact')
|
|
318
316
|
|
|
319
317
|
return (
|
|
320
318
|
new Promise((resolve, reject) => {
|
|
321
|
-
const commands = getCommands(d, getInstallSaveOptionalSaveExactCommands(p,
|
|
319
|
+
const commands = getCommands(d, getInstallSaveOptionalSaveExactCommands(p, r, f))
|
|
322
320
|
|
|
323
321
|
spawn('/bin/bash', ['-c', commands], { shell: true, stdio: 'inherit' }, (e) => (!e) ? resolve() : reject(e))
|
|
324
322
|
.on('close', resolve)
|
|
@@ -334,17 +332,17 @@ export function installSaveOptionalSaveExact (d, p, c, r, f) {
|
|
|
334
332
|
*
|
|
335
333
|
* @param {String} d - Directory
|
|
336
334
|
* @param {Object} p - Packages
|
|
337
|
-
* @param {Object} c - Configuration
|
|
338
335
|
* @param {String} r - Registry
|
|
336
|
+
* @param {Boolean} f - Force
|
|
339
337
|
*
|
|
340
338
|
* @return {Promise}
|
|
341
339
|
*/
|
|
342
|
-
export function installSaveOptional (d, p,
|
|
340
|
+
export function installSaveOptional (d, p, r, f) {
|
|
343
341
|
log('installSaveOptional')
|
|
344
342
|
|
|
345
343
|
return (
|
|
346
344
|
new Promise((resolve, reject) => {
|
|
347
|
-
const commands = getCommands(d, getInstallSaveOptionalCommands(p,
|
|
345
|
+
const commands = getCommands(d, getInstallSaveOptionalCommands(p, r, f))
|
|
348
346
|
|
|
349
347
|
spawn('/bin/bash', ['-c', commands], { shell: true, stdio: 'inherit' }, (e) => (!e) ? resolve() : reject(e))
|
|
350
348
|
.on('close', resolve)
|
|
@@ -360,17 +358,17 @@ export function installSaveOptional (d, p, c, r, f) {
|
|
|
360
358
|
*
|
|
361
359
|
* @param {String} d - Directory
|
|
362
360
|
* @param {Object} p - Packages
|
|
363
|
-
* @param {Object} c - Configuration
|
|
364
361
|
* @param {String} r - Registry
|
|
362
|
+
* @param {Boolean} f - Force
|
|
365
363
|
*
|
|
366
364
|
* @return {Promise}
|
|
367
365
|
*/
|
|
368
|
-
export function installSaveDevSaveExact (d, p,
|
|
366
|
+
export function installSaveDevSaveExact (d, p, r, f) {
|
|
369
367
|
log('installSaveDevSaveExact')
|
|
370
368
|
|
|
371
369
|
return (
|
|
372
370
|
new Promise((resolve, reject) => {
|
|
373
|
-
const commands = getCommands(d, getInstallSaveDevSaveExactCommands(p,
|
|
371
|
+
const commands = getCommands(d, getInstallSaveDevSaveExactCommands(p, r, f))
|
|
374
372
|
|
|
375
373
|
spawn('/bin/bash', ['-c', commands], { shell: true, stdio: 'inherit' }, (e) => (!e) ? resolve() : reject(e))
|
|
376
374
|
.on('close', resolve)
|
|
@@ -386,17 +384,17 @@ export function installSaveDevSaveExact (d, p, c, r, f) {
|
|
|
386
384
|
*
|
|
387
385
|
* @param {String} d - Directory
|
|
388
386
|
* @param {Object} p - Packages
|
|
389
|
-
* @param {Object} c - Configuration
|
|
390
387
|
* @param {String} r - Registry
|
|
388
|
+
* @param {Boolean} f - Force
|
|
391
389
|
*
|
|
392
390
|
* @return {Promise}
|
|
393
391
|
*/
|
|
394
|
-
export function installSaveDev (d, p,
|
|
392
|
+
export function installSaveDev (d, p, r, f) {
|
|
395
393
|
log('installSaveDev')
|
|
396
394
|
|
|
397
395
|
return (
|
|
398
396
|
new Promise((resolve, reject) => {
|
|
399
|
-
const commands = getCommands(d, getInstallSaveDevCommands(p,
|
|
397
|
+
const commands = getCommands(d, getInstallSaveDevCommands(p, r, f))
|
|
400
398
|
|
|
401
399
|
spawn('/bin/bash', ['-c', commands], { shell: true, stdio: 'inherit' }, (e) => (!e) ? resolve() : reject(e))
|
|
402
400
|
.on('close', resolve)
|
|
@@ -412,17 +410,17 @@ export function installSaveDev (d, p, c, r, f) {
|
|
|
412
410
|
*
|
|
413
411
|
* @param {String} d - Directory
|
|
414
412
|
* @param {Object} p - Packages
|
|
415
|
-
* @param {Object} c - Configuration
|
|
416
413
|
* @param {String} r - Registry
|
|
414
|
+
* @param {Boolean} f - Force
|
|
417
415
|
*
|
|
418
416
|
* @return {Promise}
|
|
419
417
|
*/
|
|
420
|
-
export function installSaveProdSaveExact (d, p,
|
|
418
|
+
export function installSaveProdSaveExact (d, p, r, f) {
|
|
421
419
|
log('installSaveProdSaveExact')
|
|
422
420
|
|
|
423
421
|
return (
|
|
424
422
|
new Promise((resolve, reject) => {
|
|
425
|
-
const commands = getCommands(d, getInstallSaveProdSaveExactCommands(p,
|
|
423
|
+
const commands = getCommands(d, getInstallSaveProdSaveExactCommands(p, r, f))
|
|
426
424
|
|
|
427
425
|
spawn('/bin/bash', ['-c', commands], { shell: true, stdio: 'inherit' }, (e) => (!e) ? resolve() : reject(e))
|
|
428
426
|
.on('close', resolve)
|
|
@@ -438,17 +436,17 @@ export function installSaveProdSaveExact (d, p, c, r, f) {
|
|
|
438
436
|
*
|
|
439
437
|
* @param {String} d - Directory
|
|
440
438
|
* @param {Object} p - Packages
|
|
441
|
-
* @param {Object} c - Configuration
|
|
442
439
|
* @param {String} r - Registry
|
|
440
|
+
* @param {Boolean} f - Force
|
|
443
441
|
*
|
|
444
442
|
* @return {Promise}
|
|
445
443
|
*/
|
|
446
|
-
export function installSaveProd (d, p,
|
|
444
|
+
export function installSaveProd (d, p, r, f) {
|
|
447
445
|
log('installSaveProd')
|
|
448
446
|
|
|
449
447
|
return (
|
|
450
448
|
new Promise((resolve, reject) => {
|
|
451
|
-
const commands = getCommands(d, getInstallSaveProdCommands(p,
|
|
449
|
+
const commands = getCommands(d, getInstallSaveProdCommands(p, r, f))
|
|
452
450
|
|
|
453
451
|
spawn('/bin/bash', ['-c', commands], { shell: true, stdio: 'inherit' }, (e) => (!e) ? resolve() : reject(e))
|
|
454
452
|
.on('close', resolve)
|
|
@@ -465,21 +463,21 @@ export function installSaveProd (d, p, c, r, f) {
|
|
|
465
463
|
* @param {String} d - Directory
|
|
466
464
|
* @param {Object} p - Packages
|
|
467
465
|
* @param {Object} c - Configuration
|
|
468
|
-
* @param {Boolean} s - Save
|
|
469
466
|
* @param {String} r - Registry
|
|
467
|
+
* @param {Boolean} f - Force
|
|
470
468
|
*
|
|
471
469
|
* @return {Promise}
|
|
472
470
|
*/
|
|
473
471
|
export async function executeBundle (directory = DIRECTORY, packages = {}, configuration = {}, registry = REGISTRY, force = false) {
|
|
474
472
|
log('executeBundle')
|
|
475
473
|
|
|
476
|
-
const
|
|
474
|
+
const depsExact = getDepsExact(packages, configuration)
|
|
477
475
|
|
|
478
|
-
if (
|
|
476
|
+
if (depsExact.length) await installSaveBundleSaveExact(directory, depsExact, registry, force)
|
|
479
477
|
|
|
480
478
|
const deps = getDeps(packages)
|
|
481
479
|
|
|
482
|
-
if (deps.length) await installSaveBundle(directory, deps,
|
|
480
|
+
if (deps.length) await installSaveBundle(directory, deps, registry, force)
|
|
483
481
|
}
|
|
484
482
|
|
|
485
483
|
/**
|
|
@@ -490,21 +488,21 @@ export async function executeBundle (directory = DIRECTORY, packages = {}, confi
|
|
|
490
488
|
* @param {String} d - Directory
|
|
491
489
|
* @param {Object} p - Packages
|
|
492
490
|
* @param {Object} c - Configuration
|
|
493
|
-
* @param {Boolean} s - Save
|
|
494
491
|
* @param {String} r - Registry
|
|
492
|
+
* @param {Boolean} f - Force
|
|
495
493
|
*
|
|
496
494
|
* @return {Promise}
|
|
497
495
|
*/
|
|
498
496
|
export async function executeOptional (directory = DIRECTORY, packages = {}, configuration = {}, registry = REGISTRY, force = false) {
|
|
499
497
|
log('executeOptional')
|
|
500
498
|
|
|
501
|
-
const
|
|
499
|
+
const depsExact = getDepsExact(packages, configuration)
|
|
502
500
|
|
|
503
|
-
if (
|
|
501
|
+
if (depsExact.length) await installSaveOptionalSaveExact(directory, depsExact, registry)
|
|
504
502
|
|
|
505
503
|
const deps = getDeps(packages)
|
|
506
504
|
|
|
507
|
-
if (deps.length) await installSaveOptional(directory, deps,
|
|
505
|
+
if (deps.length) await installSaveOptional(directory, deps, registry)
|
|
508
506
|
}
|
|
509
507
|
|
|
510
508
|
/**
|
|
@@ -515,21 +513,21 @@ export async function executeOptional (directory = DIRECTORY, packages = {}, con
|
|
|
515
513
|
* @param {String} d - Directory
|
|
516
514
|
* @param {Object} p - Packages
|
|
517
515
|
* @param {Object} c - Configuration
|
|
518
|
-
* @param {Boolean} s - Save
|
|
519
516
|
* @param {String} r - Registry
|
|
517
|
+
* @param {Boolean} f - Force
|
|
520
518
|
*
|
|
521
519
|
* @return {Promise}
|
|
522
520
|
*/
|
|
523
521
|
export async function executeDev (directory = DIRECTORY, packages = {}, configuration = {}, registry = REGISTRY, force = false) {
|
|
524
522
|
log('executeDev')
|
|
525
523
|
|
|
526
|
-
const
|
|
524
|
+
const depsExact = getDepsExact(packages, configuration)
|
|
527
525
|
|
|
528
|
-
if (
|
|
526
|
+
if (depsExact.length) await installSaveDevSaveExact(directory, depsExact, registry, force)
|
|
529
527
|
|
|
530
528
|
const deps = getDeps(packages)
|
|
531
529
|
|
|
532
|
-
if (deps.length) await installSaveDev(directory, deps,
|
|
530
|
+
if (deps.length) await installSaveDev(directory, deps, registry, force)
|
|
533
531
|
}
|
|
534
532
|
|
|
535
533
|
/**
|
|
@@ -540,19 +538,19 @@ export async function executeDev (directory = DIRECTORY, packages = {}, configur
|
|
|
540
538
|
* @param {String} d - Directory
|
|
541
539
|
* @param {Object} p - Packages
|
|
542
540
|
* @param {Object} c - Configuration
|
|
543
|
-
* @param {Boolean} s - Save
|
|
544
541
|
* @param {String} r - Registry
|
|
542
|
+
* @param {Boolean} f - Force
|
|
545
543
|
*
|
|
546
544
|
* @return {Promise}
|
|
547
545
|
*/
|
|
548
546
|
export async function executeProd (directory = DIRECTORY, packages = {}, configuration = {}, registry = REGISTRY, force = false) {
|
|
549
547
|
log('executeProd')
|
|
550
548
|
|
|
551
|
-
const
|
|
549
|
+
const depsExact = getDepsExact(packages, configuration)
|
|
552
550
|
|
|
553
|
-
if (
|
|
551
|
+
if (depsExact.length) await installSaveProdSaveExact(directory, depsExact, registry, force)
|
|
554
552
|
|
|
555
553
|
const deps = getDeps(packages)
|
|
556
554
|
|
|
557
|
-
if (deps.length) await installSaveProd(directory, deps,
|
|
555
|
+
if (deps.length) await installSaveProd(directory, deps, registry, force)
|
|
558
556
|
}
|
package/src/install/index.js
CHANGED
|
@@ -32,17 +32,16 @@ log(`\`install\` (${platform}) is awake`)
|
|
|
32
32
|
* Get the `install --save-exact` commands as a string of parameters and arguments
|
|
33
33
|
*
|
|
34
34
|
* @param {Object} p - Packages
|
|
35
|
-
* @param {Object} c - Configuration
|
|
36
35
|
* @param {Boolean} s - Save
|
|
37
36
|
* @param {String} r - Registry
|
|
38
|
-
* @param {Boolean}
|
|
37
|
+
* @param {Boolean} f - Force
|
|
39
38
|
*
|
|
40
39
|
* @return {Array}
|
|
41
40
|
*/
|
|
42
|
-
export const getInstallSaveExactCommands = (p,
|
|
41
|
+
export const getInstallSaveExactCommands = (p, s, r, f) => {
|
|
43
42
|
log('getInstallSaveExactCommands')
|
|
44
43
|
|
|
45
|
-
const commands = `npm i ${transform(p
|
|
44
|
+
const commands = `npm i ${transform(p)}`
|
|
46
45
|
|
|
47
46
|
return normalise(
|
|
48
47
|
getNoSaveParameter(s, getRegistryParameter(r, getForceParameter(f, getSaveExactParameter(commands))))
|
|
@@ -55,17 +54,16 @@ export const getInstallSaveExactCommands = (p, c, s, r, f) => {
|
|
|
55
54
|
* Get the `install` commands as a string of parameters and arguments
|
|
56
55
|
*
|
|
57
56
|
* @param {Object} p - Packages
|
|
58
|
-
* @param {Object} c - Configuration
|
|
59
57
|
* @param {Boolean} s - Save
|
|
60
58
|
* @param {String} r - Registry
|
|
61
|
-
* @param {Boolean}
|
|
59
|
+
* @param {Boolean} f - Force
|
|
62
60
|
*
|
|
63
61
|
* @return {Array}
|
|
64
62
|
*/
|
|
65
|
-
export const getInstallCommands = (p,
|
|
63
|
+
export const getInstallCommands = (p, s, r, f) => {
|
|
66
64
|
log('getInstallCommands')
|
|
67
65
|
|
|
68
|
-
const commands = `npm i ${transform(p
|
|
66
|
+
const commands = `npm i ${transform(p)}`
|
|
69
67
|
|
|
70
68
|
return normalise(
|
|
71
69
|
getNoSaveParameter(s, getRegistryParameter(r, getForceParameter(f, commands)))
|
|
@@ -85,12 +83,12 @@ export const getInstallCommands = (p, c, s, r, f) => {
|
|
|
85
83
|
*
|
|
86
84
|
* @return {Promise}
|
|
87
85
|
*/
|
|
88
|
-
export function installSaveExact (d, p,
|
|
86
|
+
export function installSaveExact (d, p, s, r, f) {
|
|
89
87
|
log('installSaveExact')
|
|
90
88
|
|
|
91
89
|
return (
|
|
92
90
|
new Promise((resolve, reject) => {
|
|
93
|
-
const commands = getCommands(d, getInstallSaveExactCommands(p,
|
|
91
|
+
const commands = getCommands(d, getInstallSaveExactCommands(p, s, r, f))
|
|
94
92
|
|
|
95
93
|
spawn('/bin/bash', ['-c', commands], { shell: true, stdio: 'inherit' }, (e) => (!e) ? resolve() : reject(e))
|
|
96
94
|
.on('close', resolve)
|
|
@@ -112,12 +110,12 @@ export function installSaveExact (d, p, c, s, r, f) {
|
|
|
112
110
|
*
|
|
113
111
|
* @return {Promise}
|
|
114
112
|
*/
|
|
115
|
-
export function install (d, p,
|
|
113
|
+
export function install (d, p, s, r, f) {
|
|
116
114
|
log('install')
|
|
117
115
|
|
|
118
116
|
return (
|
|
119
117
|
new Promise((resolve, reject) => {
|
|
120
|
-
const commands = getCommands(d, getInstallCommands(p,
|
|
118
|
+
const commands = getCommands(d, getInstallCommands(p, s, r, f))
|
|
121
119
|
|
|
122
120
|
spawn('/bin/bash', ['-c', commands], { shell: true, stdio: 'inherit' }, (e) => (!e) ? resolve() : reject(e))
|
|
123
121
|
.on('close', resolve)
|
|
@@ -144,9 +142,9 @@ export async function execute (directory = DIRECTORY, packages = {}, configurati
|
|
|
144
142
|
|
|
145
143
|
const depsExact = getDepsExact(packages, configuration)
|
|
146
144
|
|
|
147
|
-
if (depsExact.length) await installSaveExact(directory, depsExact,
|
|
145
|
+
if (depsExact.length) await installSaveExact(directory, depsExact, save, registry, force)
|
|
148
146
|
|
|
149
147
|
const deps = getDeps(packages)
|
|
150
148
|
|
|
151
|
-
if (deps.length) await install(directory, deps,
|
|
149
|
+
if (deps.length) await install(directory, deps, save, registry, force)
|
|
152
150
|
}
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
gitCheckout,
|
|
8
8
|
gitPull,
|
|
9
9
|
gitPush,
|
|
10
|
+
gitPushTags,
|
|
10
11
|
gitAdd,
|
|
11
12
|
gitCommit
|
|
12
13
|
} from '@modernpoacher/deps/common/git'
|
|
@@ -50,6 +51,13 @@ describe('@modernpoacher/deps/common/git', () => {
|
|
|
50
51
|
})
|
|
51
52
|
})
|
|
52
53
|
|
|
54
|
+
describe('`gitPushTags`', () => {
|
|
55
|
+
it('is a function', () => {
|
|
56
|
+
return expect(gitPushTags)
|
|
57
|
+
.to.be.a('function')
|
|
58
|
+
})
|
|
59
|
+
})
|
|
60
|
+
|
|
53
61
|
describe('`gitAdd`', () => {
|
|
54
62
|
it('is a function', () => {
|
|
55
63
|
return expect(gitAdd)
|
package/test/index.spec.js
CHANGED
|
@@ -191,4 +191,292 @@ describe('@modernpoacher/deps', () => {
|
|
|
191
191
|
.to.be.a('function')
|
|
192
192
|
})
|
|
193
193
|
})
|
|
194
|
+
|
|
195
|
+
describe('`getInstallSaveProdSaveExactCommands()`', () => {
|
|
196
|
+
describe('Always', () => {
|
|
197
|
+
it('returns a string', () => {
|
|
198
|
+
const MOCK_PACKAGES = { name: 'PACKAGE NAME', version: 'PACKAGE VERSION' }
|
|
199
|
+
|
|
200
|
+
return expect(getInstallSaveProdSaveExactCommands(MOCK_PACKAGES))
|
|
201
|
+
.to.equal('npm i PACKAGE NAME@PACKAGE VERSION --save-exact --save-prod')
|
|
202
|
+
})
|
|
203
|
+
})
|
|
204
|
+
|
|
205
|
+
describe('Registry is defined', () => {
|
|
206
|
+
it('returns a string', () => {
|
|
207
|
+
const MOCK_PACKAGES = { name: 'PACKAGE NAME', version: 'PACKAGE VERSION' }
|
|
208
|
+
const MOCK_REGISTRY = 'REGISTRY'
|
|
209
|
+
|
|
210
|
+
return expect(getInstallSaveProdSaveExactCommands(MOCK_PACKAGES, MOCK_REGISTRY))
|
|
211
|
+
.to.equal('npm i PACKAGE NAME@PACKAGE VERSION --save-exact --registry REGISTRY --save-prod')
|
|
212
|
+
})
|
|
213
|
+
|
|
214
|
+
describe('Force is true', () => {
|
|
215
|
+
it('returns a string', () => {
|
|
216
|
+
const MOCK_PACKAGES = { name: 'PACKAGE NAME', version: 'PACKAGE VERSION' }
|
|
217
|
+
const MOCK_REGISTRY = 'REGISTRY'
|
|
218
|
+
const MOCK_FORCE = true
|
|
219
|
+
|
|
220
|
+
return expect(getInstallSaveProdSaveExactCommands(MOCK_PACKAGES, MOCK_REGISTRY, MOCK_FORCE))
|
|
221
|
+
.to.equal('npm i PACKAGE NAME@PACKAGE VERSION --save-exact --force --registry REGISTRY --save-prod')
|
|
222
|
+
})
|
|
223
|
+
})
|
|
224
|
+
})
|
|
225
|
+
})
|
|
226
|
+
|
|
227
|
+
describe('`getInstallSaveDevSaveExactCommands()`', () => {
|
|
228
|
+
describe('Always', () => {
|
|
229
|
+
it('returns a string', () => {
|
|
230
|
+
const MOCK_PACKAGES = { name: 'PACKAGE NAME', version: 'PACKAGE VERSION' }
|
|
231
|
+
|
|
232
|
+
return expect(getInstallSaveDevSaveExactCommands(MOCK_PACKAGES))
|
|
233
|
+
.to.equal('npm i PACKAGE NAME@PACKAGE VERSION --save-exact --save-dev')
|
|
234
|
+
})
|
|
235
|
+
})
|
|
236
|
+
|
|
237
|
+
describe('Registry is defined', () => {
|
|
238
|
+
it('returns a string', () => {
|
|
239
|
+
const MOCK_PACKAGES = { name: 'PACKAGE NAME', version: 'PACKAGE VERSION' }
|
|
240
|
+
const MOCK_REGISTRY = 'REGISTRY'
|
|
241
|
+
|
|
242
|
+
return expect(getInstallSaveDevSaveExactCommands(MOCK_PACKAGES, MOCK_REGISTRY))
|
|
243
|
+
.to.equal('npm i PACKAGE NAME@PACKAGE VERSION --save-exact --registry REGISTRY --save-dev')
|
|
244
|
+
})
|
|
245
|
+
|
|
246
|
+
describe('Force is true', () => {
|
|
247
|
+
it('returns a string', () => {
|
|
248
|
+
const MOCK_PACKAGES = { name: 'PACKAGE NAME', version: 'PACKAGE VERSION' }
|
|
249
|
+
const MOCK_REGISTRY = 'REGISTRY'
|
|
250
|
+
const MOCK_FORCE = true
|
|
251
|
+
|
|
252
|
+
return expect(getInstallSaveDevSaveExactCommands(MOCK_PACKAGES, MOCK_REGISTRY, MOCK_FORCE))
|
|
253
|
+
.to.equal('npm i PACKAGE NAME@PACKAGE VERSION --save-exact --force --registry REGISTRY --save-dev')
|
|
254
|
+
})
|
|
255
|
+
})
|
|
256
|
+
})
|
|
257
|
+
})
|
|
258
|
+
|
|
259
|
+
describe('`getInstallSaveOptionalSaveExactCommands()`', () => {
|
|
260
|
+
describe('Always', () => {
|
|
261
|
+
it('returns a string', () => {
|
|
262
|
+
const MOCK_PACKAGES = { name: 'PACKAGE NAME', version: 'PACKAGE VERSION' }
|
|
263
|
+
|
|
264
|
+
return expect(getInstallSaveOptionalSaveExactCommands(MOCK_PACKAGES))
|
|
265
|
+
.to.equal('npm i PACKAGE NAME@PACKAGE VERSION --save-exact --save-optional')
|
|
266
|
+
})
|
|
267
|
+
})
|
|
268
|
+
|
|
269
|
+
describe('Registry is defined', () => {
|
|
270
|
+
it('returns a string', () => {
|
|
271
|
+
const MOCK_PACKAGES = { name: 'PACKAGE NAME', version: 'PACKAGE VERSION' }
|
|
272
|
+
const MOCK_REGISTRY = 'REGISTRY'
|
|
273
|
+
|
|
274
|
+
return expect(getInstallSaveOptionalSaveExactCommands(MOCK_PACKAGES, MOCK_REGISTRY))
|
|
275
|
+
.to.equal('npm i PACKAGE NAME@PACKAGE VERSION --save-exact --registry REGISTRY --save-optional')
|
|
276
|
+
})
|
|
277
|
+
|
|
278
|
+
describe('Force is true', () => {
|
|
279
|
+
it('returns a string', () => {
|
|
280
|
+
const MOCK_PACKAGES = { name: 'PACKAGE NAME', version: 'PACKAGE VERSION' }
|
|
281
|
+
const MOCK_REGISTRY = 'REGISTRY'
|
|
282
|
+
const MOCK_FORCE = true
|
|
283
|
+
|
|
284
|
+
return expect(getInstallSaveOptionalSaveExactCommands(MOCK_PACKAGES, MOCK_REGISTRY, MOCK_FORCE))
|
|
285
|
+
.to.equal('npm i PACKAGE NAME@PACKAGE VERSION --save-exact --force --registry REGISTRY --save-optional')
|
|
286
|
+
})
|
|
287
|
+
})
|
|
288
|
+
})
|
|
289
|
+
})
|
|
290
|
+
|
|
291
|
+
describe('`getInstallSaveBundleSaveExactCommands()`', () => {
|
|
292
|
+
describe('Always', () => {
|
|
293
|
+
it('returns a string', () => {
|
|
294
|
+
const MOCK_PACKAGES = { name: 'PACKAGE NAME', version: 'PACKAGE VERSION' }
|
|
295
|
+
|
|
296
|
+
return expect(getInstallSaveBundleSaveExactCommands(MOCK_PACKAGES))
|
|
297
|
+
.to.equal('npm i PACKAGE NAME@PACKAGE VERSION --save-exact --save-bundle')
|
|
298
|
+
})
|
|
299
|
+
})
|
|
300
|
+
|
|
301
|
+
describe('Registry is defined', () => {
|
|
302
|
+
it('returns a string', () => {
|
|
303
|
+
const MOCK_PACKAGES = { name: 'PACKAGE NAME', version: 'PACKAGE VERSION' }
|
|
304
|
+
const MOCK_REGISTRY = 'REGISTRY'
|
|
305
|
+
|
|
306
|
+
return expect(getInstallSaveBundleSaveExactCommands(MOCK_PACKAGES, MOCK_REGISTRY))
|
|
307
|
+
.to.equal('npm i PACKAGE NAME@PACKAGE VERSION --save-exact --registry REGISTRY --save-bundle')
|
|
308
|
+
})
|
|
309
|
+
|
|
310
|
+
describe('Force is true', () => {
|
|
311
|
+
it('returns a string', () => {
|
|
312
|
+
const MOCK_PACKAGES = { name: 'PACKAGE NAME', version: 'PACKAGE VERSION' }
|
|
313
|
+
const MOCK_REGISTRY = 'REGISTRY'
|
|
314
|
+
const MOCK_FORCE = true
|
|
315
|
+
|
|
316
|
+
return expect(getInstallSaveBundleSaveExactCommands(MOCK_PACKAGES, MOCK_REGISTRY, MOCK_FORCE))
|
|
317
|
+
.to.equal('npm i PACKAGE NAME@PACKAGE VERSION --save-exact --force --registry REGISTRY --save-bundle')
|
|
318
|
+
})
|
|
319
|
+
})
|
|
320
|
+
})
|
|
321
|
+
})
|
|
322
|
+
|
|
323
|
+
describe('`getInstallSaveProdCommands()`', () => {
|
|
324
|
+
describe('Always', () => {
|
|
325
|
+
it('returns a string', () => {
|
|
326
|
+
const MOCK_PACKAGES = { name: 'PACKAGE NAME', version: 'PACKAGE VERSION' }
|
|
327
|
+
|
|
328
|
+
return expect(getInstallSaveProdCommands(MOCK_PACKAGES))
|
|
329
|
+
.to.equal('npm i PACKAGE NAME@PACKAGE VERSION --save-prod')
|
|
330
|
+
})
|
|
331
|
+
})
|
|
332
|
+
|
|
333
|
+
describe('Registry is defined', () => {
|
|
334
|
+
it('returns a string', () => {
|
|
335
|
+
const MOCK_PACKAGES = { name: 'PACKAGE NAME', version: 'PACKAGE VERSION' }
|
|
336
|
+
const MOCK_REGISTRY = 'REGISTRY'
|
|
337
|
+
|
|
338
|
+
return expect(getInstallSaveProdCommands(MOCK_PACKAGES, MOCK_REGISTRY))
|
|
339
|
+
.to.equal('npm i PACKAGE NAME@PACKAGE VERSION --registry REGISTRY --save-prod')
|
|
340
|
+
})
|
|
341
|
+
|
|
342
|
+
describe('Force is true', () => {
|
|
343
|
+
it('returns a string', () => {
|
|
344
|
+
const MOCK_PACKAGES = { name: 'PACKAGE NAME', version: 'PACKAGE VERSION' }
|
|
345
|
+
const MOCK_REGISTRY = 'REGISTRY'
|
|
346
|
+
const MOCK_FORCE = true
|
|
347
|
+
|
|
348
|
+
return expect(getInstallSaveProdCommands(MOCK_PACKAGES, MOCK_REGISTRY, MOCK_FORCE))
|
|
349
|
+
.to.equal('npm i PACKAGE NAME@PACKAGE VERSION --force --registry REGISTRY --save-prod')
|
|
350
|
+
})
|
|
351
|
+
})
|
|
352
|
+
})
|
|
353
|
+
})
|
|
354
|
+
|
|
355
|
+
describe('`getInstallSaveDevCommands()`', () => {
|
|
356
|
+
describe('Always', () => {
|
|
357
|
+
it('returns a string', () => {
|
|
358
|
+
const MOCK_PACKAGES = { name: 'PACKAGE NAME', version: 'PACKAGE VERSION' }
|
|
359
|
+
|
|
360
|
+
return expect(getInstallSaveDevCommands(MOCK_PACKAGES))
|
|
361
|
+
.to.equal('npm i PACKAGE NAME@PACKAGE VERSION --save-dev')
|
|
362
|
+
})
|
|
363
|
+
})
|
|
364
|
+
|
|
365
|
+
describe('Registry is defined', () => {
|
|
366
|
+
it('returns a string', () => {
|
|
367
|
+
const MOCK_PACKAGES = { name: 'PACKAGE NAME', version: 'PACKAGE VERSION' }
|
|
368
|
+
const MOCK_REGISTRY = 'REGISTRY'
|
|
369
|
+
|
|
370
|
+
return expect(getInstallSaveDevCommands(MOCK_PACKAGES, MOCK_REGISTRY))
|
|
371
|
+
.to.equal('npm i PACKAGE NAME@PACKAGE VERSION --registry REGISTRY --save-dev')
|
|
372
|
+
})
|
|
373
|
+
|
|
374
|
+
describe('Force is true', () => {
|
|
375
|
+
it('returns a string', () => {
|
|
376
|
+
const MOCK_PACKAGES = { name: 'PACKAGE NAME', version: 'PACKAGE VERSION' }
|
|
377
|
+
const MOCK_REGISTRY = 'REGISTRY'
|
|
378
|
+
const MOCK_FORCE = true
|
|
379
|
+
|
|
380
|
+
return expect(getInstallSaveDevCommands(MOCK_PACKAGES, MOCK_REGISTRY, MOCK_FORCE))
|
|
381
|
+
.to.equal('npm i PACKAGE NAME@PACKAGE VERSION --force --registry REGISTRY --save-dev')
|
|
382
|
+
})
|
|
383
|
+
})
|
|
384
|
+
})
|
|
385
|
+
})
|
|
386
|
+
|
|
387
|
+
describe('`getInstallSaveOptionalCommands()`', () => {
|
|
388
|
+
describe('Always', () => {
|
|
389
|
+
it('returns a string', () => {
|
|
390
|
+
const MOCK_PACKAGES = { name: 'PACKAGE NAME', version: 'PACKAGE VERSION' }
|
|
391
|
+
|
|
392
|
+
return expect(getInstallSaveOptionalCommands(MOCK_PACKAGES))
|
|
393
|
+
.to.equal('npm i PACKAGE NAME@PACKAGE VERSION --save-optional')
|
|
394
|
+
})
|
|
395
|
+
})
|
|
396
|
+
|
|
397
|
+
describe('Registry is defined', () => {
|
|
398
|
+
it('returns a string', () => {
|
|
399
|
+
const MOCK_PACKAGES = { name: 'PACKAGE NAME', version: 'PACKAGE VERSION' }
|
|
400
|
+
const MOCK_REGISTRY = 'REGISTRY'
|
|
401
|
+
|
|
402
|
+
return expect(getInstallSaveOptionalCommands(MOCK_PACKAGES, MOCK_REGISTRY))
|
|
403
|
+
.to.equal('npm i PACKAGE NAME@PACKAGE VERSION --registry REGISTRY --save-optional')
|
|
404
|
+
})
|
|
405
|
+
|
|
406
|
+
describe('Force is true', () => {
|
|
407
|
+
it('returns a string', () => {
|
|
408
|
+
const MOCK_PACKAGES = { name: 'PACKAGE NAME', version: 'PACKAGE VERSION' }
|
|
409
|
+
const MOCK_REGISTRY = 'REGISTRY'
|
|
410
|
+
const MOCK_FORCE = true
|
|
411
|
+
|
|
412
|
+
return expect(getInstallSaveOptionalCommands(MOCK_PACKAGES, MOCK_REGISTRY, MOCK_FORCE))
|
|
413
|
+
.to.equal('npm i PACKAGE NAME@PACKAGE VERSION --force --registry REGISTRY --save-optional')
|
|
414
|
+
})
|
|
415
|
+
})
|
|
416
|
+
})
|
|
417
|
+
})
|
|
418
|
+
|
|
419
|
+
describe('`getInstallSaveBundleCommands()`', () => {
|
|
420
|
+
describe('Always', () => {
|
|
421
|
+
it('returns a string', () => {
|
|
422
|
+
const MOCK_PACKAGES = { name: 'PACKAGE NAME', version: 'PACKAGE VERSION' }
|
|
423
|
+
|
|
424
|
+
return expect(getInstallSaveBundleCommands(MOCK_PACKAGES))
|
|
425
|
+
.to.equal('npm i PACKAGE NAME@PACKAGE VERSION --save-bundle')
|
|
426
|
+
})
|
|
427
|
+
})
|
|
428
|
+
|
|
429
|
+
describe('Registry is defined', () => {
|
|
430
|
+
it('returns a string', () => {
|
|
431
|
+
const MOCK_PACKAGES = { name: 'PACKAGE NAME', version: 'PACKAGE VERSION' }
|
|
432
|
+
const MOCK_REGISTRY = 'REGISTRY'
|
|
433
|
+
|
|
434
|
+
return expect(getInstallSaveBundleCommands(MOCK_PACKAGES, MOCK_REGISTRY))
|
|
435
|
+
.to.equal('npm i PACKAGE NAME@PACKAGE VERSION --registry REGISTRY --save-bundle')
|
|
436
|
+
})
|
|
437
|
+
|
|
438
|
+
describe('Force is true', () => {
|
|
439
|
+
it('returns a string', () => {
|
|
440
|
+
const MOCK_PACKAGES = { name: 'PACKAGE NAME', version: 'PACKAGE VERSION' }
|
|
441
|
+
const MOCK_REGISTRY = 'REGISTRY'
|
|
442
|
+
const MOCK_FORCE = true
|
|
443
|
+
|
|
444
|
+
return expect(getInstallSaveBundleCommands(MOCK_PACKAGES, MOCK_REGISTRY, MOCK_FORCE))
|
|
445
|
+
.to.equal('npm i PACKAGE NAME@PACKAGE VERSION --force --registry REGISTRY --save-bundle')
|
|
446
|
+
})
|
|
447
|
+
})
|
|
448
|
+
})
|
|
449
|
+
})
|
|
450
|
+
|
|
451
|
+
describe('`getInstallCommands()`', () => {
|
|
452
|
+
describe('Always', () => {
|
|
453
|
+
it('returns a string', () => {
|
|
454
|
+
const MOCK_PACKAGES = { name: 'PACKAGE NAME', version: 'PACKAGE VERSION' }
|
|
455
|
+
|
|
456
|
+
return expect(getInstallCommands(MOCK_PACKAGES))
|
|
457
|
+
.to.equal('npm i PACKAGE NAME@PACKAGE VERSION')
|
|
458
|
+
})
|
|
459
|
+
})
|
|
460
|
+
|
|
461
|
+
describe('Registry is defined', () => {
|
|
462
|
+
it('returns a string', () => {
|
|
463
|
+
const MOCK_PACKAGES = { name: 'PACKAGE NAME', version: 'PACKAGE VERSION' }
|
|
464
|
+
const MOCK_REGISTRY = 'REGISTRY'
|
|
465
|
+
|
|
466
|
+
return expect(getInstallCommands(MOCK_PACKAGES, MOCK_REGISTRY))
|
|
467
|
+
.to.equal('npm i PACKAGE NAME@PACKAGE VERSION --registry REGISTRY')
|
|
468
|
+
})
|
|
469
|
+
|
|
470
|
+
describe('Force is true', () => {
|
|
471
|
+
it('returns a string', () => {
|
|
472
|
+
const MOCK_PACKAGES = { name: 'PACKAGE NAME', version: 'PACKAGE VERSION' }
|
|
473
|
+
const MOCK_REGISTRY = 'REGISTRY'
|
|
474
|
+
const MOCK_FORCE = true
|
|
475
|
+
|
|
476
|
+
return expect(getInstallCommands(MOCK_PACKAGES, MOCK_REGISTRY, MOCK_FORCE))
|
|
477
|
+
.to.equal('npm i PACKAGE NAME@PACKAGE VERSION --force --registry REGISTRY')
|
|
478
|
+
})
|
|
479
|
+
})
|
|
480
|
+
})
|
|
481
|
+
})
|
|
194
482
|
})
|
|
@@ -55,4 +55,158 @@ describe('@modernpoacher/deps/install', () => {
|
|
|
55
55
|
.to.be.a('function')
|
|
56
56
|
})
|
|
57
57
|
})
|
|
58
|
+
|
|
59
|
+
describe('`getInstallSaveExactCommands()`', () => {
|
|
60
|
+
describe('Always', () => {
|
|
61
|
+
it('returns a string', () => {
|
|
62
|
+
const MOCK_PACKAGES = { name: 'PACKAGE NAME', version: 'PACKAGE VERSION' }
|
|
63
|
+
|
|
64
|
+
return expect(getInstallSaveExactCommands(MOCK_PACKAGES))
|
|
65
|
+
.to.equal('npm i PACKAGE NAME@PACKAGE VERSION --save-exact --no-save')
|
|
66
|
+
})
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
describe('Save is true', () => {
|
|
70
|
+
it('returns a string', () => {
|
|
71
|
+
const MOCK_PACKAGES = { name: 'PACKAGE NAME', version: 'PACKAGE VERSION' }
|
|
72
|
+
const MOCK_SAVE = true
|
|
73
|
+
|
|
74
|
+
return expect(getInstallSaveExactCommands(MOCK_PACKAGES, MOCK_SAVE))
|
|
75
|
+
.to.equal('npm i PACKAGE NAME@PACKAGE VERSION --save-exact')
|
|
76
|
+
})
|
|
77
|
+
|
|
78
|
+
describe('Registry is defined', () => {
|
|
79
|
+
it('returns a string', () => {
|
|
80
|
+
const MOCK_PACKAGES = { name: 'PACKAGE NAME', version: 'PACKAGE VERSION' }
|
|
81
|
+
const MOCK_SAVE = true
|
|
82
|
+
const MOCK_REGISTRY = 'REGISTRY'
|
|
83
|
+
|
|
84
|
+
return expect(getInstallSaveExactCommands(MOCK_PACKAGES, MOCK_SAVE, MOCK_REGISTRY))
|
|
85
|
+
.to.equal('npm i PACKAGE NAME@PACKAGE VERSION --save-exact --registry REGISTRY')
|
|
86
|
+
})
|
|
87
|
+
|
|
88
|
+
describe('Force is true', () => {
|
|
89
|
+
it('returns a string', () => {
|
|
90
|
+
const MOCK_PACKAGES = { name: 'PACKAGE NAME', version: 'PACKAGE VERSION' }
|
|
91
|
+
const MOCK_SAVE = true
|
|
92
|
+
const MOCK_REGISTRY = 'REGISTRY'
|
|
93
|
+
const MOCK_FORCE = true
|
|
94
|
+
|
|
95
|
+
return expect(getInstallSaveExactCommands(MOCK_PACKAGES, MOCK_SAVE, MOCK_REGISTRY, MOCK_FORCE))
|
|
96
|
+
.to.equal('npm i PACKAGE NAME@PACKAGE VERSION --save-exact --force --registry REGISTRY')
|
|
97
|
+
})
|
|
98
|
+
})
|
|
99
|
+
})
|
|
100
|
+
})
|
|
101
|
+
|
|
102
|
+
describe('Save is false', () => {
|
|
103
|
+
it('returns a string', () => {
|
|
104
|
+
const MOCK_PACKAGES = { name: 'PACKAGE NAME', version: 'PACKAGE VERSION' }
|
|
105
|
+
const MOCK_SAVE = false
|
|
106
|
+
|
|
107
|
+
return expect(getInstallSaveExactCommands(MOCK_PACKAGES, MOCK_SAVE))
|
|
108
|
+
.to.equal('npm i PACKAGE NAME@PACKAGE VERSION --save-exact --no-save')
|
|
109
|
+
})
|
|
110
|
+
|
|
111
|
+
describe('Registry is defined', () => {
|
|
112
|
+
it('returns a string', () => {
|
|
113
|
+
const MOCK_PACKAGES = { name: 'PACKAGE NAME', version: 'PACKAGE VERSION' }
|
|
114
|
+
const MOCK_SAVE = false
|
|
115
|
+
const MOCK_REGISTRY = 'REGISTRY'
|
|
116
|
+
|
|
117
|
+
return expect(getInstallSaveExactCommands(MOCK_PACKAGES, MOCK_SAVE, MOCK_REGISTRY))
|
|
118
|
+
.to.equal('npm i PACKAGE NAME@PACKAGE VERSION --save-exact --registry REGISTRY --no-save')
|
|
119
|
+
})
|
|
120
|
+
|
|
121
|
+
describe('Force is true', () => {
|
|
122
|
+
it('returns a string', () => {
|
|
123
|
+
const MOCK_PACKAGES = { name: 'PACKAGE NAME', version: 'PACKAGE VERSION' }
|
|
124
|
+
const MOCK_SAVE = false
|
|
125
|
+
const MOCK_REGISTRY = 'REGISTRY'
|
|
126
|
+
const MOCK_FORCE = true
|
|
127
|
+
|
|
128
|
+
return expect(getInstallSaveExactCommands(MOCK_PACKAGES, MOCK_SAVE, MOCK_REGISTRY, MOCK_FORCE))
|
|
129
|
+
.to.equal('npm i PACKAGE NAME@PACKAGE VERSION --save-exact --force --registry REGISTRY --no-save')
|
|
130
|
+
})
|
|
131
|
+
})
|
|
132
|
+
})
|
|
133
|
+
})
|
|
134
|
+
})
|
|
135
|
+
|
|
136
|
+
describe('`getInstallCommands()`', () => {
|
|
137
|
+
describe('Always', () => {
|
|
138
|
+
it('returns a string', () => {
|
|
139
|
+
const MOCK_PACKAGES = { name: 'PACKAGE NAME', version: 'PACKAGE VERSION' }
|
|
140
|
+
|
|
141
|
+
return expect(getInstallCommands(MOCK_PACKAGES))
|
|
142
|
+
.to.equal('npm i PACKAGE NAME@PACKAGE VERSION --no-save')
|
|
143
|
+
})
|
|
144
|
+
})
|
|
145
|
+
|
|
146
|
+
describe('Save is true', () => {
|
|
147
|
+
it('returns a string', () => {
|
|
148
|
+
const MOCK_PACKAGES = { name: 'PACKAGE NAME', version: 'PACKAGE VERSION' }
|
|
149
|
+
const MOCK_SAVE = true
|
|
150
|
+
|
|
151
|
+
return expect(getInstallCommands(MOCK_PACKAGES, MOCK_SAVE))
|
|
152
|
+
.to.equal('npm i PACKAGE NAME@PACKAGE VERSION')
|
|
153
|
+
})
|
|
154
|
+
|
|
155
|
+
describe('Registry is defined', () => {
|
|
156
|
+
it('returns a string', () => {
|
|
157
|
+
const MOCK_PACKAGES = { name: 'PACKAGE NAME', version: 'PACKAGE VERSION' }
|
|
158
|
+
const MOCK_SAVE = true
|
|
159
|
+
const MOCK_REGISTRY = 'REGISTRY'
|
|
160
|
+
|
|
161
|
+
return expect(getInstallCommands(MOCK_PACKAGES, MOCK_SAVE, MOCK_REGISTRY))
|
|
162
|
+
.to.equal('npm i PACKAGE NAME@PACKAGE VERSION --registry REGISTRY')
|
|
163
|
+
})
|
|
164
|
+
|
|
165
|
+
describe('Force is true', () => {
|
|
166
|
+
it('returns a string', () => {
|
|
167
|
+
const MOCK_PACKAGES = { name: 'PACKAGE NAME', version: 'PACKAGE VERSION' }
|
|
168
|
+
const MOCK_SAVE = true
|
|
169
|
+
const MOCK_REGISTRY = 'REGISTRY'
|
|
170
|
+
const MOCK_FORCE = true
|
|
171
|
+
|
|
172
|
+
return expect(getInstallCommands(MOCK_PACKAGES, MOCK_SAVE, MOCK_REGISTRY, MOCK_FORCE))
|
|
173
|
+
.to.equal('npm i PACKAGE NAME@PACKAGE VERSION --force --registry REGISTRY')
|
|
174
|
+
})
|
|
175
|
+
})
|
|
176
|
+
})
|
|
177
|
+
})
|
|
178
|
+
|
|
179
|
+
describe('Save is false', () => {
|
|
180
|
+
it('returns a string', () => {
|
|
181
|
+
const MOCK_PACKAGES = { name: 'PACKAGE NAME', version: 'PACKAGE VERSION' }
|
|
182
|
+
const MOCK_SAVE = false
|
|
183
|
+
|
|
184
|
+
return expect(getInstallCommands(MOCK_PACKAGES, MOCK_SAVE))
|
|
185
|
+
.to.equal('npm i PACKAGE NAME@PACKAGE VERSION --no-save')
|
|
186
|
+
})
|
|
187
|
+
|
|
188
|
+
describe('Registry is defined', () => {
|
|
189
|
+
it('returns a string', () => {
|
|
190
|
+
const MOCK_PACKAGES = { name: 'PACKAGE NAME', version: 'PACKAGE VERSION' }
|
|
191
|
+
const MOCK_SAVE = false
|
|
192
|
+
const MOCK_REGISTRY = 'REGISTRY'
|
|
193
|
+
|
|
194
|
+
return expect(getInstallCommands(MOCK_PACKAGES, MOCK_SAVE, MOCK_REGISTRY))
|
|
195
|
+
.to.equal('npm i PACKAGE NAME@PACKAGE VERSION --registry REGISTRY --no-save')
|
|
196
|
+
})
|
|
197
|
+
|
|
198
|
+
describe('Force is true', () => {
|
|
199
|
+
it('returns a string', () => {
|
|
200
|
+
const MOCK_PACKAGES = { name: 'PACKAGE NAME', version: 'PACKAGE VERSION' }
|
|
201
|
+
const MOCK_SAVE = false
|
|
202
|
+
const MOCK_REGISTRY = 'REGISTRY'
|
|
203
|
+
const MOCK_FORCE = true
|
|
204
|
+
|
|
205
|
+
return expect(getInstallCommands(MOCK_PACKAGES, MOCK_SAVE, MOCK_REGISTRY, MOCK_FORCE))
|
|
206
|
+
.to.equal('npm i PACKAGE NAME@PACKAGE VERSION --force --registry REGISTRY --no-save')
|
|
207
|
+
})
|
|
208
|
+
})
|
|
209
|
+
})
|
|
210
|
+
})
|
|
211
|
+
})
|
|
58
212
|
})
|