From eafd2d454ce773ca16cf1ff0a58f257da8d0cfcb Mon Sep 17 00:00:00 2001 From: Tom Fulton Date: Sun, 12 Jan 2014 01:12:50 -0700 Subject: [PATCH] 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 --- .gitignore | 3 ++- Gruntfile.js | 34 +++++++++++++++++++++++++---- package.json | 3 ++- {build => pkg}/nuget/package.nuspec | 6 +++-- 4 files changed, 38 insertions(+), 8 deletions(-) rename {build => pkg}/nuget/package.nuspec (76%) diff --git a/.gitignore b/.gitignore index 5683196..0963175 100644 --- a/.gitignore +++ b/.gitignore @@ -13,4 +13,5 @@ $RECYCLE.BIN/ dist/ node_modules/ -build/*.nupkg \ No newline at end of file +pkg/tmp/ +pkg/*.nupkg \ No newline at end of file diff --git a/Gruntfile.js b/Gruntfile.js index 4e0e726..4410baf 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -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']); diff --git a/package.json b/package.json index ec424d9..547e799 100644 --- a/package.json +++ b/package.json @@ -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" } } diff --git a/build/nuget/package.nuspec b/pkg/nuget/package.nuspec similarity index 76% rename from build/nuget/package.nuspec rename to pkg/nuget/package.nuspec index e6a9720..e5143cc 100644 --- a/build/nuget/package.nuspec +++ b/pkg/nuget/package.nuspec @@ -2,7 +2,7 @@ Archetype - 0.0.0.0 + <%= version %> Archetype imulus, tomfulton imulus, tomfulton @@ -13,6 +13,8 @@ http://www.opensource.org/licenses/mit-license.php - + <% for (var file in files) { %> + + <% } %> \ No newline at end of file