Inject package version, files into nuspec on build

* Move /build/ -> /pkg/
* Add nuspec
* Refactor package:nuget workflow to create a temporary directory to build the package from - so we can store the transformed file
* Add grunt-template task to transform the nuspec
This commit is contained in:
Tom Fulton
2014-01-12 01:12:50 -07:00
parent 9a7bf3693c
commit eafd2d454c
4 changed files with 38 additions and 8 deletions
+2 -1
View File
@@ -13,4 +13,5 @@ $RECYCLE.BIN/
dist/
node_modules/
build/*.nupkg
pkg/tmp/
pkg/*.nupkg
+30 -4
View File
@@ -2,6 +2,9 @@ module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
dest: 'dist',
version: '0.0.0',
package_dir: 'pkg',
package_temp_dir: '<%= package_dir %>/tmp/',
watch: {
less: {
@@ -37,6 +40,11 @@ module.exports = function(grunt) {
{expand: true, src: ['app/package.manifest'], dest: '<%= dest %>', flatten: true},
{expand: true, src: ['app/views/archetype.html'], dest: '<%= dest %>/views', flatten: true}
]
},
nuget_prepare: {
files: [
{expand: true, cwd: '<%= dest %>/', src: ['**'], dest: '<%= package_temp_dir %>/nuget/content/', flatten: false},
]
}
},
@@ -66,12 +74,29 @@ module.exports = function(grunt) {
nugetpack: {
dist: {
src: 'build/nuget/package.nuspec',
dest: 'build'
src: '<%= package_temp_dir %>/nuget/package.nuspec',
dest: '<%= package_dir %>'
}
},
clean: ['<%= dest %>']
template: {
'nuget_manifest': {
'options': {
'data': {
version: '<%= version %>',
files: [{ path: '..\\..\\..\\<%= dest %>\\**', target: 'content\\App_Plugins\\Archetype'}]
}
},
'files': {
'<%= package_temp_dir %>/nuget/package.nuspec': ['<%= package_dir %>/nuget/package.nuspec']
}
}
},
clean: {
build: ['<%= dest %>'],
package_temp: ['<%= package_temp_dir %>']
}
});
@@ -83,9 +108,10 @@ module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-nuget');
grunt.loadNpmTasks('grunt-template');
grunt.registerTask('package:nuget', ['default', ' nugetpack']);
grunt.registerTask('package:nuget', ['default', 'clean:package_temp', 'copy:nuget_prepare', 'template:nuget_manifest', 'nugetpack', 'clean:package_temp']);
grunt.registerTask('css:build', ['less']);
grunt.registerTask('js:build', ['concat']);
grunt.registerTask('default', ['clean', 'css:build', 'js:build', 'copy']);
+2 -1
View File
@@ -12,6 +12,7 @@
"grunt-contrib-jshint": "~0.7.2",
"grunt-cli": "~0.1.11",
"grunt-contrib-clean": "~0.5.0",
"grunt-nuget": "~0.1.1"
"grunt-nuget": "~0.1.1",
"grunt-template": "~0.2.2"
}
}
@@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata>
<id>Archetype</id>
<version>0.0.0.0</version>
<version><%= version %></version>
<title>Archetype</title>
<authors>imulus, tomfulton</authors>
<owners>imulus, tomfulton</owners>
@@ -13,6 +13,8 @@
<licenseUrl>http://www.opensource.org/licenses/mit-license.php</licenseUrl>
</metadata>
<files>
<file src="..\..\dist\**\*.*" target="content" />
<% for (var file in files) { %>
<file src="<%- files[file].path %>" target="<%= files[file].target %>" />
<% } %>
</files>
</package>