npm-scripts-versioning
Advanced tools
| #!/usr/bin/env node | ||
| /** | ||
| * ISC License (ISC) | ||
| * | ||
| * Copyright (c) 2017, Brandon D. Sara (https://bsara.pro/) | ||
| * | ||
| * Permission to use, copy, modify, and/or distribute this software for any | ||
| * purpose with or without fee is hereby granted, provided that the above | ||
| * copyright notice and this permission notice appear in all copies. | ||
| * | ||
| * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH | ||
| * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY | ||
| * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, | ||
| * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM | ||
| * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR | ||
| * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR | ||
| * PERFORMANCE OF THIS SOFTWARE. | ||
| */ | ||
| /* global echo, exec, exit, which */ | ||
| require('shelljs/global'); | ||
| const fs = require('fs'); | ||
| const path = require('path'); | ||
| const { files, version } = require(path.join(process.cwd(), 'package.json')); | ||
| const filePaths = files.filter((filePath) => (filePath.startsWith("!") === false)); | ||
| filePaths.push('package.json'); | ||
| if (fs.existsSync('package-lock.json')) { | ||
| filePaths.push('package-lock.json'); | ||
| } | ||
| // Commit & push changes | ||
| // ------------------------------------------------------------- | ||
| if (!which('git')) { | ||
| echo("git executable not found! Install git and try again."); | ||
| exit(1); | ||
| } | ||
| _execCmd(`git add ${filePaths.join(" ")}`, "add (`git add`) changed version reference files"); | ||
| _execCmd(`git commit -m "version bump (v${version})"`, "commit version changes"); | ||
| _execCmd('git push', "push git version bump commit to default git remote"); | ||
| // Helpers | ||
| // ------------------------------------------------------------- | ||
| function _execCmd(cmdStr, cmdDesc) { | ||
| const cmdReturnCode = exec(cmdStr).code; | ||
| if (cmdReturnCode !== 0) { | ||
| echo(`Error: Failed to ${cmdDesc}`); | ||
| exit(cmdReturnCode); | ||
| } | ||
| } |
+3
-4
| { | ||
| "name": "npm-scripts-versioning", | ||
| "version": "1.0.0-beta.4", | ||
| "version": "1.0.0-beta.5", | ||
| "description": "", | ||
@@ -31,3 +31,2 @@ "authors": [ | ||
| "files": [ | ||
| "index.js", | ||
| "lib/*.js" | ||
@@ -37,3 +36,3 @@ ], | ||
| "update-version-comment-refs": "lib/update-version-comment-refs.js", | ||
| "push-changed-version-ref-files": "lib/push-changed-version-ref-files.js", | ||
| "push-version-comment-refs": "lib/push-version-comment-refs.js", | ||
| "tag-version": "lib/tag-version.js" | ||
@@ -48,3 +47,3 @@ }, | ||
| "bump:patch": "npm --no-git-tag-version version patch", | ||
| "postversion": "./lib/update-version-comment-refs.js && ./lib/push-changed-version-files.js", | ||
| "postversion": "./lib/update-version-comment-refs.js && ./lib/push-version-comment-refs.js", | ||
| "prepublishOnly": "npm run lint && git push && npx ./lib/tag-version.js", | ||
@@ -51,0 +50,0 @@ "postpublish": "npm run bump" |
| #!/usr/bin/env node | ||
| /** | ||
| * ISC License (ISC) | ||
| * | ||
| * Copyright (c) 2017, Brandon D. Sara (https://bsara.pro/) | ||
| * | ||
| * Permission to use, copy, modify, and/or distribute this software for any | ||
| * purpose with or without fee is hereby granted, provided that the above | ||
| * copyright notice and this permission notice appear in all copies. | ||
| * | ||
| * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH | ||
| * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY | ||
| * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, | ||
| * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM | ||
| * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR | ||
| * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR | ||
| * PERFORMANCE OF THIS SOFTWARE. | ||
| */ | ||
| /* global echo, exec, exit, which */ | ||
| require('shelljs/global'); | ||
| const fs = require('fs'); | ||
| const path = require('path'); | ||
| const { files, version } = require(path.join(process.cwd(), 'package.json')); | ||
| const filePaths = files.filter((filePath) => (filePath.startsWith("!") === false)); | ||
| filePaths.push('package.json'); | ||
| if (fs.existsSync('package-lock.json')) { | ||
| filePaths.push('package-lock.json'); | ||
| } | ||
| // Commit & push changes | ||
| // ------------------------------------------------------------- | ||
| if (!which('git')) { | ||
| echo("git executable not found! Install git and try again."); | ||
| exit(1); | ||
| } | ||
| _execCmd(`git add ${filePaths.join(" ")}`, "add (`git add`) changed version reference files"); | ||
| _execCmd(`git commit -m "version bump (v${version})"`, "commit version changes"); | ||
| _execCmd('git push', "push git version bump commit to default git remote"); | ||
| // Helpers | ||
| // ------------------------------------------------------------- | ||
| function _execCmd(cmdStr, cmdDesc) { | ||
| const cmdReturnCode = exec(cmdStr).code; | ||
| if (cmdReturnCode !== 0) { | ||
| echo(`Error: Failed to ${cmdDesc}`); | ||
| exit(cmdReturnCode); | ||
| } | ||
| } |
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
9064
-0.3%