dnnbundler 0.1.5 → 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6cbe59e15b822d31c419850068808fed5beff93c
4
- data.tar.gz: 81af67b4728e1b4b3faafc7f9e022f2f2f682c26
3
+ metadata.gz: 96c347bb2f330fdeefd588f01d2721339587b80d
4
+ data.tar.gz: d69601f50871db50d78185c5dbcad341d475eb7b
5
5
  SHA512:
6
- metadata.gz: cd9620df2a3ea1da99998d72c151c10b2f524dfa91f4a1d1867866953dcfdc3c5e9567c7dec110832d1d438fd77dddec8ae50a2f5ff21b0b497e7c6ed4de4527
7
- data.tar.gz: 5a9e95a2486189732827739d50c7545f214fe3882bf4a703924446df7d551c4014d5a1802429bb3eee1ca61686038b691570378a67d36d14038e4fdcd6914e6b
6
+ metadata.gz: f2e22d533440874f46923a28e58b0ce8f1ca8e50f23fb63ae4a08b5cffe4dea32b7b12d76f447d3678872d205191771a2679718177df31b5f6691dc2e1c65b32
7
+ data.tar.gz: 148501b005a3fec11644306275be2d60e0eb6d6b7aec9c2571ce0f2f83d0e4fb2579b6c4fa11877015abb3e8d989cf943476149211a9c32d5c4cc630164027b4
data/README.md CHANGED
@@ -25,34 +25,50 @@ Or install it yourself as:
25
25
  To configure packaging create a json config with the following schema:
26
26
 
27
27
  {
28
- "name": "out.zip",
29
- "entries": [
30
- "path_to_file",
31
- "path_to_directory", // real path in file system to file or directory
28
+ "packages": [
32
29
  {
33
- "type": "file", // type of entry, if absent will be treated as 'file'
34
- "name": "test.json", // real path in file system to file or directory
35
- "path": "new_path_in_zip" // optional
36
- },
37
- {
38
- "type": "zip", // nested zip archive
39
- "name": "test.zip", // name of nested zip archive, can include directories. 'path' property is being ignored for this kind of entries
40
- "ignoreEntries": [ ... ] // local array of entries to ignore
41
- "entries": [ // array of entries for nested zip file, same format as above
42
- "file",
43
- "dir",
44
- ...
30
+ "name": "out.[PACKAGE_VERSION].zip", // [PACKAGE_VERSION] is a placeholder for package version which will be taken from manifest file
31
+ "entries": [
32
+ "path_to_file",
33
+ "path_to_directory", // real path in file system to file or directory
34
+ {
35
+ "type": "file", // type of entry, if absent will be treated as 'file'
36
+ "name": "test.json", // real path in file system to file or directory
37
+ "path": "new_path_in_zip" // optional
38
+ },
39
+ {
40
+ "type": "zip", // nested zip archive
41
+ "name": "test.zip", // name of nested zip archive, can include directories. 'path' property is being ignored for this kind of entries
42
+ "ignoreEntries": [ ... ] // local array of entries to ignore
43
+ "entries": [ // array of entries for nested zip file, same format as above
44
+ "file",
45
+ "dir",
46
+ ...
47
+ ]
48
+ }
49
+ ],
50
+ "ignoreEntries": [
51
+ ".DS_Store"
45
52
  ]
46
53
  }
47
54
  ],
48
- "ignoreEntries": [
49
- ".DS_Store"
55
+ "manifests": [
56
+ "path_to_dnn_manifest" // dnn manifest file
50
57
  ]
51
58
  }
52
59
 
53
60
  to create package run:
54
61
 
55
- dnnbundler path_to_config.json
62
+ dnnbundler build path_to_config.json
63
+
64
+ it is possible to increment build or sprint numbers:
65
+
66
+ dnnbundler build path_to_config.json --bumpBuild
67
+ dnnbundler build path_to_config.json --bumpSprint
68
+
69
+ it is also possible to specify custom version number:
70
+
71
+ dnnbundler build path_to_config.json --targetVersion 2017.08.0004
56
72
 
57
73
  ## Development
58
74
 
@@ -1,21 +1,43 @@
1
1
  require "dnnbundler/zipFileGenerator"
2
+ require "dnnbundler/fileStringReplacer/fileStringReplacer"
2
3
  require "thor"
3
4
  require "json"
4
5
 
5
6
  module Dnnbundler
6
7
  class CLI < Thor
7
- desc "build CONFIG", ""
8
+ desc "build CONFIG [options]", "creates a zip package according to given configuration file"
8
9
  option :bumpBuild
10
+ option :bumpSprint
11
+ option :targetVersion, :type => :string
9
12
  def build( config )
10
13
  puts "Build with config #{config}"
11
14
  file = File.read(config)
12
15
  data_hash = JSON.parse(file)
13
16
 
14
- input_entries = data_hash["entries"]
15
- ignore_entries = data_hash["excludeEntries"]
16
- zip_file_name = data_hash["outFileName"]
17
- generator = ZipFileGenerator.new(data_hash)
18
- generator.write
17
+ manifest_files = data_hash["manifests"]
18
+ current_version = Dnnbundler::getVersionFromManifest manifest_files[0]
19
+ version_numbers = current_version.split(".").map { |x| x.to_i }
20
+
21
+ version_numbers[1] = version_numbers[1] + 1 if options[:bumpSprint]
22
+ version_numbers[2] = 1 if options[:bumpSprint]
23
+ version_numbers[2] = version_numbers[2] + 1 if options[:bumpBuild]
24
+ version_numbers = options[:targetVersion].split(".").map { |x| x.to_i } if options[:targetVersion]
25
+
26
+ new_version = Dnnbundler::formatVersion(version_numbers)
27
+ puts "current version is #{current_version}"
28
+ puts "new version is #{new_version}"
29
+
30
+ data_hash["packages"].each do |package|
31
+ package["name"].sub! "[PACKAGE_VERSION]", new_version
32
+ Dnnbundler::replaceVersionInManifestFiles manifest_files, new_version
33
+
34
+ generator = ZipFileGenerator.new(package)
35
+ generator.write
36
+ end
19
37
  end
20
38
  end
39
+
40
+ def self.formatVersion(version)
41
+ "#{version[0].to_s.rjust(4, "0")}.#{version[1].to_s.rjust(2, "0")}.#{version[2].to_s.rjust(4, "0")}"
42
+ end
21
43
  end
@@ -0,0 +1,26 @@
1
+ module Dnnbundler
2
+ def self.replaceVersionInManifestFiles(file_names, new_version)
3
+ file_names.each do |file_name|
4
+ text = File.read(file_name)
5
+ replace_expr = '\1' + new_version + '\3'
6
+ text.gsub!(ManifestVersionRegex::NewManifestRegex, replace_expr )
7
+ text.gsub!(ManifestVersionRegex::OldManifestRegex, replace_expr )
8
+
9
+ # To merely print the contents of the file, use:
10
+ # puts new_contents
11
+
12
+ # To write changes to the file, use:
13
+ File.open(file_name, "w") {|file| file.puts text }
14
+ end
15
+ end
16
+
17
+ def self.getVersionFromManifest(file_name)
18
+ text = File.read(file_name)
19
+ (ManifestVersionRegex::NewManifestRegex.match(text) || ManifestVersionRegex::OldManifestRegex.match(text)).captures[1]
20
+ end
21
+
22
+ module ManifestVersionRegex
23
+ OldManifestRegex = /(<version>)(\d*?\.\d*?\.\d*)(<\/version>)/
24
+ NewManifestRegex = /(<package .*? version=")(\d*?\.\d*?\.\d*)(.*?>)/
25
+ end
26
+ end
@@ -1,3 +1,3 @@
1
1
  module Dnnbundler
2
- VERSION = "0.1.5"
2
+ VERSION = "0.1.6"
3
3
  end
@@ -15,6 +15,8 @@ module Dnnbundler
15
15
  # Zip the input directory.
16
16
  def write
17
17
  buffer = create_zip @entries, @ignore_entries
18
+
19
+ puts "\nwrite file #{@output_file}"
18
20
  File.open(@output_file, "wb") {|f| f.write buffer.string }
19
21
  end
20
22
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dnnbundler
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Le0Michine
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-04-18 00:00:00.000000000 Z
11
+ date: 2017-04-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -102,6 +102,7 @@ files:
102
102
  - lib/dnnbundler/cli.rb
103
103
  - lib/dnnbundler/fileEntry.rb
104
104
  - lib/dnnbundler/fileEntryType.rb
105
+ - lib/dnnbundler/fileStringReplacer/fileStringReplacer.rb
105
106
  - lib/dnnbundler/jsonConfig.rb
106
107
  - lib/dnnbundler/version.rb
107
108
  - lib/dnnbundler/zipFileGenerator.rb