Hey Hey Welcome! 👋
Ask me about my work or anything else:
Handle versioning of a project using grunt
License: MIT License
Hey Hey Welcome! 👋
Ask me about my work or anything else:
Stumbled upon it while I was looking for a stricter regexp for version number matching ([0-9\.]+
).
version: {
src: '__doc__.js',
}
Pattern not found in file
Path: _doc_.js
Pattern: /([^\-]version['"]?\s*[:=]\s*['"])([0-9a-zA-Z\-_\.]+)/g
WTF?
Hi there,
I'm currently using https://github.com/yoniholmes/grunt-text-replace to update the version number. I prefer the way your plugin works, as it's really designed for version updates. Here is how I use grunt-text-replace at the moment:
replace: {
pluginVersion: {
src: [
'plugin-reviews.php'
],
overwrite: true,
replacements: [{
from: /^Version: .*$/m,
to: 'Version: <%= pkg.version %>'
}]
},
pluginConstant: {
src: [
'plugin-reviews.php'
],
overwrite: true,
replacements: [{
from: /define\( '(.*?)',\s*'(.*)' \);/,
to: 'define( \'WR_VERSION\', \'<%= pkg.version %>\' );'
}]
},
stableTag: {
src: [
'readme.txt'
],
overwrite: true,
replacements: [{
from: /^Stable tag: .*$/m,
to: 'Stable tag: <%= pkg.version %>'
}]
}
},
I suck at creating regex that works, even with the help of online tools. So perhaps you could let me know if the above 3 cases could work with your plugin?
Thanks
It appears that the specific / explicit syntax you mention in #13 isn't working for me. When I type grunt version::2.01
, I just get the following response:
File skipped.
Path: tester-2.php
Current version and new version are equal: 1.0.0
Here's my task:
version: {
css: {
options: {
prefix: '@version\\s*'
},
src: [ 'tester-2.php' ],
},
},
Looks like it's not registering the version number I'm using to call the task directly.
Also, how would this look in a grunt build process? Can I just do something like this:
grunt.registerTask( 'build', [
'clean',
'version::5.0'
] );
Where 5.0 is the version I want to bump to? Is there another way to explicitly specify a specific version to bump to?
Thanks
If the src is set to *.js and a folder exists with the name jimu.js it causes the error "Warning: Unable to read "dist/jimu.js" file (Error code: EISDIR)."
Sorry, I didn't name the library esri did.
I have the following in my gruntfile:
version: {
scss: {
options: {
prefix: 'Version\\:\\s'
},
src: [ 'assets/scss/style.scss' ]
},
json: {
src: [ 'bower.json', 'package.json' ]
}
},
When I run grunt version --verbose
, I get the following:
Running tasks: version
Running "version" task
Running "version:scss" (version) task
Verifying property version.scss exists in config...OK
Files: assets/scss/style.scss
Options: encoding="utf8", algorithm="md5", format=false, minify, minifyname="min", length=8, rename=false, querystring={}, manifest=false, summaryOnly=false, prefix="Version\\:\\s"
Reading assets/scss/style.scss...OK
Reading undefined...ERROR
Warning: Unable to read "undefined" file (Error code: ENOENT). Use --force to continue.
Aborted due to warnings.
Any ideas? I've tried it with the scss block commented out and still get the same "undefined" file error.
Hi @kswedberg. This looks awesome and I'd like to use it. Will you get it published to npm soon? I'll try it out directly from your repo for now.
I added grunt-version to my package.json devDependencies like this:
"devDependencies": {
"grunt-version": "https://github.com/kswedberg/grunt-version/tarball/master"
}
and when I run grunt version
it updates the package.json version value correctly, but it also updates the grunt-version value....
"devDependencies": {
"grunt-version": "0.1.1://github.com/kswedberg/grunt-version/tarball/master"
}
Is there an option to set a specific version to update?
I like to change grunt config values dynamically so It would be great to have an option to do this in case that I'd want to overwrite the version number.
Thanks in advance
Seems like your package.json line 32 is locking grunt at version 1 (outdated).
Because of this the mkdirp is also locked at version 0.5 (also outdated) and that finally causes the minimist package to get stuck at 0.0.8.
Because of the outdated version of minimist Github throws a vulnerability warning.
$ npm ls minimist
`-- [email protected]
`-- [email protected]
+-- [email protected]
| `-- [email protected]
| `-- [email protected]
`-- [email protected]
`-- [email protected]
Can you update grunt?
GHSA-7fhm-mqm4-2wp7
moderate severity
Vulnerable versions: < 1.2.2
Patched version: 1.2.2
There are high severity security vulnerabilities in two of ESLints dependencies:
The releases 1.8.3 and lower of svjsl (JSLib-npm) are vulnerable, but only if installed in a developer environment. A patch has been released (v1.8.4) which fixes these vulnerabilities.
Identifiers:
CVE-2020-7598
SNYK-JS-ACORN-559469 (doesn't have a CVE identifier)
version: {
package: {
src: ['package.json']
},
default: {
options: {
prefix: '#define MyAppVersion "'
},
src: ['XPBackup.iss']
}
}
Is possible to preserve a encoding from file?
Ex: XPBackup.iss is encoding in ANSI when grunt replace the new encoding is UTF8, so it has an error ...
ANSI:
[Messages]
WelcomeLabel1=Bem-vindo ao Assistente de Instalação/Atualização do XPBackup
UTF8:
[Messages]
WelcomeLabel1=Bem-vindo ao Assistente de Instala��o/Atualiza��o do XPBackup
hi there,
how about writing a file only if the verysion number is different?
Because it change the modification-date of the file.
Thanks!
if (!matches) {
grunt.log.subhead('Pattern not found in file');
grunt.log.writeln('Path: ' + filepath);
grunt.log.writeln('Pattern: ' + pattern);
} else {
var fileVersion = matches.pop();
grunt.log.subhead('File updated');
grunt.log.writeln('Path: ' + filepath);
grunt.log.writeln('Old version: ' + fileVersion + '. New version: ' + version + '.');
}
if(version != fileVersion){
grunt.file.write(filepath, newfile);
}
Hello,
First of all thanks for your hard work on this plugin, I love it!
I want to run all targets without passing release type argument like this grunt version::
or just grunt version
but when I try to do that it's only taking the first target, would be great to run it without passing the release argument and instead (or optionally) take the default options value:
version: {
options: {
pkg: 'package.json'
release: 'patch'
},
dist: {
options: {
prefix: 'Current Version\\:\\s'
},
src: [ 'readme.md']
},
pkg: {
src: ['package.json']
}
}
Thanks in advance
I did "npm install grunt-version" and got an old version package, which did not support "flags" option. Could you please update npm repository?
BTW, this package is very usefule. Thanks!
In composer.json files we sometimes have multiple items with versions. The task updates all versions to the new one.
grunt task:
project: { options: { release: 'patch' }, src: ['package.json', 'bower.json', 'composer.json'] },
composer file (sample)
{ "version": "5.0.10", ... etc ... "repositories":[ { "type" : "package", "package": { "name" : "wordpress", "type" : "webroot", **"version": "4",** ... etc ... } }, ],
the version number inside of the repositories path should not be updated.
it there any way to update only the first occurrence of version or a way to somehow regexp to only a version tag in the root level of the json?
Including build metadata in a build number won't work.
Running "version:defaults" (version) task >>2.11.0+1443 must be a valid release name or semver version. Version will not be updated.
See http://semver.org/ , section 10 of the specification:
Build metadata MAY be denoted by appending a plus sign and a series of dot separated identifiers immediately following the patch or pre-release version. Identifiers MUST comprise only ASCII alphanumerics and hyphen [0-9A-Za-z-]. Identifiers MUST NOT be empty. Build metadata SHOULD be ignored when determining version precedence. Thus two versions that differ only in the build metadata, have the same precedence. Examples: 1.0.0-alpha+001, 1.0.0+20130313144700, 1.0.0-beta+exp.sha.5114f85.
I tried to bump version on multiple files with multiple prefixes:
version: {
package: {
src: ['package.json', 'bower.json'],
},
module: {
options: {
prefix: "\\('version',\\s*'"
},
src: ['src/example.js'],
},
}
Then grunt version::patch
will increment version in the files listed in package
and increment twice (e.g. 1.0.0 to 1.0.2) in the files listed in module
. A workaround is do two calls:
grunt version:package:patch
grunt version
I think the current behaviour is a bug because nobody wants to bump version twice.
Hi Karl,
First of all, thanks for putting together this plugin, I can't believe there are very view viable solutions in this area.
I feel like grunt-version could have more "natural" behavior with smarter defaults.
At this point I have to write too many self-repeating lines to get things to work the way most projects would.
...
,version: {
major: {
options: {
release: 'major'
,pkg: 'package.json'
}
,src: [ 'package.json', 'bower.json', 'phonegap/config.json' ]
}
,minor: {
options: {
release: 'minor'
,pkg: 'package.json'
}
,src: [ 'package.json', 'bower.json', 'phonegap/config.json' ]
}
,patch: {
options: {
release: 'patch'
,pkg: 'package.json'
}
,src: [ 'package.json', 'bower.json', 'phonegap/config.json' ]
}
}
...
But I feel that this should be sufficient:
version: {
src: [ 'bower.json', 'phonegap/config.json' ]
}
So, we have release: 'major' || 'minor' || 'patch'
option declared, and it most cases users would want to call version[:release]
in their build/deployment/orwhatever task to bump up the version of package.json and sync that version across multiple config files. Custom files we, of course, specify ourselves.
Suppose you got a package.json with this version:
"version": "0.3.4"
And you add a batch task like this:
grunt.registerTask('build', ['updatePackageJsonVersion','version'])
Note that the first task is going to alter an info in the package.json. Now it's:
"version": "0.3.5"
By the time the "version" task is run, it's loaded with the old version because Gruntfile.js has read package.json before anything happened.
Any chances to read it on the fly? Say, instead of reading the pkg option, we can provide the name of the file so the bump can get it during execution.
Hello there,
I find your task/plugin very useful and I'm thankful for it, however I need one more possibility that I miss and it could be useful for a wider range of people.
The missing possibility is to directly set the version via command parameter, no increment than while parameter is provided etc.
Please let me know if this is something to be done and will be done.
Thanks,
Althain
I have the following config:
version: {
default: {
options: {
prefix: 'widget version="'
},
src: ['config.xml']
}
}
When executing the task passing "minor/major/patch", weird things happen (at least with minor and patch). Following is an example of consecutive calls to the task:
$ grunt version::2.1.0
Running "version:default:2.1.0" (version) task
File updated.
Path: config.xml
Old version: 1.1.0. New version: 2.1.0.
Done, without errors.
$ grunt version::patch
Running "version:default:patch" (version) task
File updated.
Path: config.xml
Old version: 2.1.0. New version: 1.0.1.
Done, without errors.
$ grunt version::major
Running "version:default:major" (version) task
File updated.
Path: config.xml
Old version: 1.0.1. New version: 2.0.0.
Done, without errors.
$ grunt version::minor
Running "version:default:minor" (version) task
File updated.
Path: config.xml
Old version: 2.0.0. New version: 1.1.0.
Done, without errors.
I am using Windows 8.1, and the config.xml line that I want to change is like this one:
<widget version="1.1.0" id="myappId">
Is a config.xml file for a cordova app. Explicit version syntax works without problem.
Cheers!
Would be good to support regexp flags: e.g., 'i' to allow for case-insensitive matches.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.