npm-scripts-versioning
Advanced tools
@@ -6,3 +6,3 @@ #!/usr/bin/env node | ||
| * | ||
| * Copyright (c) 2017, Brandon D. Sara (https://bsara.github.io/) | ||
| * Copyright (c) 2017, Brandon D. Sara (https://bsara.pro/) | ||
| * | ||
@@ -27,6 +27,17 @@ * Permission to use, copy, modify, and/or distribute this software for any | ||
| const { files, version } = require('../package.json'); | ||
| const fs = require('fs'); | ||
| const { files, version } = require('package.json'); | ||
| const filePaths = pkg.files.filter((filePath) => (filePath.startsWith("!") === false)); | ||
| if (fs.existsSync('package-lock.json')) { | ||
| filePaths.push('package-lock.json'); | ||
| } | ||
| // Commit & push changes | ||
| // ------------------------------------------------------------- | ||
| if (!which('git')) { | ||
@@ -37,3 +48,3 @@ echo("git executable not found! Install git and try again."); | ||
| _execCmd(`git add package.json ${files.join(" ")}`, "add (`git add`) changed version reference files"); | ||
| _execCmd(`git add package.json ${filePaths.join(" ")}`, "add (`git add`) changed version reference files"); | ||
| _execCmd(`git commit -m "version bump (v${version})"`, "commit version changes"); | ||
@@ -40,0 +51,0 @@ _execCmd('git push', "push git version bump commit to default git remote"); |
@@ -6,3 +6,3 @@ #!/usr/bin/env node | ||
| * | ||
| * Copyright (c) 2017, Brandon D. Sara (https://bsara.github.io/) | ||
| * Copyright (c) 2017, Brandon D. Sara (http://bsara.pro/) | ||
| * | ||
@@ -27,3 +27,3 @@ * Permission to use, copy, modify, and/or distribute this software for any | ||
| const { version } = require('../package.json'); | ||
| const { version } = require('package.json'); | ||
@@ -30,0 +30,0 @@ |
@@ -6,3 +6,3 @@ #!/usr/bin/env node | ||
| * | ||
| * Copyright (c) 2017, Brandon D. Sara (https://bsara.github.io/) | ||
| * Copyright (c) 2017, Brandon D. Sara (https://bsara.pro/) | ||
| * | ||
@@ -27,8 +27,18 @@ * Permission to use, copy, modify, and/or distribute this software for any | ||
| const { name, files, version } = require('../package.json'); | ||
| const escapeStringRegexp = require('escape-string-regexp'); | ||
| const { name, files, version } = require('package.json'); | ||
| files.forEach(function(filePath) { | ||
| sed('-i', RegExp(`\\*\\s+${name}\\s+\\d+\\.\\d+\\.\\d+(-\\w+){0,1}(\\.\\d+){0,1}`), `* ${name} v${version}`, filePath); | ||
| const filePaths = files.filter((filePath) => (filePath.startsWith("!") === false)); | ||
| // CREDIT: `semver-regex` NPM package (https://github.com/sindresorhus/semver-regex/blob/master/index.js) | ||
| const semverRegex = '\\bv?(?:0|[1-9]\\d*)\\\.(?:0|[1-9]\\d*)\\.(?:0|[1-9]\\d*)(?:-[\\da-z\\-]+(?:\\.[a-z\\d\\-]+)*)?(?:\\+[a-z\\d\\-]+(?:\\.[a-z\\d\\-]+)*)?\\b'; | ||
| // Update all files containing project's version in comments | ||
| // ------------------------------------------------------------- | ||
| filePaths.forEach(function(filePath) { | ||
| sed('-i', RegExp(`\\*\\s+${escapeStringRegexp(name)}\\s+${semverRegex}`), `* ${name} v${version}`, filePath); | ||
| }); |
+1
-1
| ISC License (ISC) | ||
| Copyright (c) 2017, Brandon D. Sara (https://bsara.github.io/) | ||
| Copyright (c) 2017, Brandon D. Sara (https://bsara.pro/) | ||
@@ -5,0 +5,0 @@ Permission to use, copy, modify, and/or distribute this software for any |
+7
-5
| { | ||
| "name": "npm-scripts-versioning", | ||
| "version": "1.0.0-beta.0", | ||
| "version": "1.0.0-beta.1", | ||
| "description": "", | ||
| "authors": [ | ||
| "Brandon Sara (https://bsara.github.io/)" | ||
| "Brandon Sara (https://bsara.pro/)" | ||
| ], | ||
@@ -40,11 +40,13 @@ "license": "ISC", | ||
| "scripts": { | ||
| "lint": "eslint ." | ||
| "l": "npm run lint", | ||
| "lint": "npx eslint ." | ||
| }, | ||
| "dependencies": { | ||
| "escape-string-regexp": "^1.0.5", | ||
| "shelljs": "^0.7.6" | ||
| }, | ||
| "devDependencies": { | ||
| "eslint": "^3.16.1", | ||
| "eslint-config-bsara": "^1.1.0" | ||
| "@bsara/eslint-config": "^2.1.5", | ||
| "eslint": "^3.19.0" | ||
| } | ||
| } |
+1
-1
@@ -32,3 +32,3 @@ # NPM Scripts: Versioning [][npm] | ||
| Copyright (c) 2017, Brandon D. Sara (https://bsara.github.io/) | ||
| Copyright (c) 2017, Brandon D. Sara (https://bsara.pro/) | ||
@@ -35,0 +35,0 @@ Permission to use, copy, modify, and/or distribute this software for any |
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
8420
11.6%111
13.27%2
100%2
100%+ Added
+ Added