xpm 0.0.3 → 0.0.4
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 +4 -4
- data/bin/xpm +39 -17
- data/lib/xpm/all.rb +8 -0
- data/lib/xpm/configuration.rb +14 -0
- data/lib/xpm/depmanagers/abstract.rb +28 -0
- data/lib/xpm/depmanagers/bower.rb +102 -0
- data/lib/xpm/version.rb +1 -1
- data/lib/xpm/xp.rb +0 -41
- data/lib/xpm.rb +13 -3
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5ed6140605575b4c422beb6ab792df8fe87fde0e
|
4
|
+
data.tar.gz: 65249c6ce942bc89b977fe8159920c8bd660007c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 60a5701196f5a483227d092875b916a238ef7ade00b926673a91a640a64bb51dc8097792f1d55f23566cce10593a13368f3c1c836291ff723c766b82cf86999e
|
7
|
+
data.tar.gz: 2fbecd6213bb18deab52104259304aebfcc14f4ffca9fe15324ce40d36d90f21b86d3286b7d67a3583322d4ae640222b3d242e7931b06648eb7694de77f6bf82
|
data/bin/xpm
CHANGED
@@ -3,26 +3,48 @@
|
|
3
3
|
require "thor"
|
4
4
|
require "xpm"
|
5
5
|
|
6
|
-
class XpmCli < Thor
|
7
6
|
|
8
|
-
desc "new [NAME]", "Create a new project called NAME in the current directory"
|
9
|
-
option :packages
|
10
|
-
def new(name)
|
11
|
-
xp = XPM::XP.new()
|
12
|
-
xp.new(name, :packages => options[:packages])
|
13
|
-
end
|
14
7
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
8
|
+
class Cache < Thor
|
9
|
+
|
10
|
+
desc "clean", "Clean cached packages"
|
11
|
+
def clean()
|
12
|
+
XPM.config.depmanager.new.cacheclean()
|
13
|
+
end
|
20
14
|
|
21
|
-
|
22
|
-
|
23
|
-
|
15
|
+
desc "list", "List cached packages"
|
16
|
+
def list()
|
17
|
+
XPM.config.depmanager.new.cachelist()
|
18
|
+
end
|
24
19
|
end
|
25
20
|
|
26
|
-
end
|
27
21
|
|
28
|
-
|
22
|
+
class XPMCli < Thor
|
23
|
+
|
24
|
+
desc "new [NAME]", "Create a new project called NAME in the current directory"
|
25
|
+
option :packages
|
26
|
+
def new(name)
|
27
|
+
xp = XPM::XP.new()
|
28
|
+
xp.new(name, :packages => options[:packages])
|
29
|
+
end
|
30
|
+
|
31
|
+
desc "install [package]", "Install a package locally"
|
32
|
+
def install(package=nil)
|
33
|
+
XPM.config.depmanager.new.install(package)
|
34
|
+
end
|
35
|
+
|
36
|
+
desc "link [package]", "Symlink a package folder"
|
37
|
+
def link(package=nil)
|
38
|
+
XPM.config.depmanager.new.link(package)
|
39
|
+
end
|
40
|
+
|
41
|
+
desc "version", "gives the current version"
|
42
|
+
def version
|
43
|
+
puts XPM::VERSION
|
44
|
+
end
|
45
|
+
|
46
|
+
desc "cache", "Manage cache "
|
47
|
+
subcommand "cache", Cache
|
48
|
+
end
|
49
|
+
|
50
|
+
XPMCli.start(ARGV)
|
data/lib/xpm/all.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
module XPM
|
2
|
+
|
3
|
+
module Depmanager
|
4
|
+
|
5
|
+
class Abstract
|
6
|
+
|
7
|
+
def install(package=nil)
|
8
|
+
raise MethodUnavailableError
|
9
|
+
end
|
10
|
+
|
11
|
+
def link(name=nil)
|
12
|
+
raise MethodUnavailableError
|
13
|
+
end
|
14
|
+
|
15
|
+
def cacheclean
|
16
|
+
raise MethodUnavailableError
|
17
|
+
end
|
18
|
+
|
19
|
+
def cachelist
|
20
|
+
raise MethodUnavailableError
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
|
@@ -0,0 +1,102 @@
|
|
1
|
+
require 'open-uri'
|
2
|
+
require 'zlib'
|
3
|
+
require 'open3'
|
4
|
+
require 'logger'
|
5
|
+
require 'json'
|
6
|
+
require 'fileutils'
|
7
|
+
|
8
|
+
module XPM
|
9
|
+
|
10
|
+
module Depmanager
|
11
|
+
|
12
|
+
class Bower < Abstract
|
13
|
+
|
14
|
+
def initialize(options = {})
|
15
|
+
@logger = options[:logger] || Logger.new(STDOUT)
|
16
|
+
end
|
17
|
+
|
18
|
+
|
19
|
+
def install(package=nil)
|
20
|
+
_preinstall(package)
|
21
|
+
_install(package)
|
22
|
+
_postinstall(package)
|
23
|
+
end
|
24
|
+
|
25
|
+
def link(package=nil)
|
26
|
+
cmd = 'bower link ' + package.to_s
|
27
|
+
Open3.popen3(cmd) do |stdin, stdout, stderr, wait_thr|
|
28
|
+
@logger.info "Linking " + package.to_s
|
29
|
+
@logger.info stdout.read
|
30
|
+
err = stderr.read
|
31
|
+
@logger.error err unless err.empty?
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def cacheclean
|
36
|
+
cmd = 'bower cache clean '
|
37
|
+
Open3.popen3(cmd) do |stdin, stdout, stderr, wait_thr|
|
38
|
+
@logger.info "Cleaning the cache "
|
39
|
+
@logger.info stdout.read
|
40
|
+
err = stderr.read
|
41
|
+
@logger.error err unless err.empty?
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def cachelist
|
46
|
+
cmd = 'bower cache list '
|
47
|
+
Open3.popen3(cmd) do |stdin, stdout, stderr, wait_thr|
|
48
|
+
@logger.info "Linking "
|
49
|
+
@logger.info stdout.read
|
50
|
+
err = stderr.read
|
51
|
+
@logger.error err unless err.empty?
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
private
|
58
|
+
|
59
|
+
def _preinstall(package=nil)
|
60
|
+
end
|
61
|
+
|
62
|
+
def _install(package=nil)
|
63
|
+
cmd = 'bower install ' + package.to_s
|
64
|
+
# TODO abstract this (@depmanager.install)
|
65
|
+
Open3.popen3(cmd) do |stdin, stdout, stderr, wait_thr|
|
66
|
+
@logger.info "Installing dependencies"
|
67
|
+
@logger.info stdout.read
|
68
|
+
err = stderr.read
|
69
|
+
@logger.error err unless err.empty?
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
def _postinstall(package=nil)
|
74
|
+
mpath = "xpm_modules"
|
75
|
+
bowers = Dir.glob("#{mpath}/*");
|
76
|
+
|
77
|
+
# TODO rescue
|
78
|
+
bowers.each do |bower|
|
79
|
+
desc = File.read(File.join(bower, "bower.json"))
|
80
|
+
desc = JSON.parse(desc)
|
81
|
+
mname = File.basename(bower)
|
82
|
+
exports = desc["exports"]
|
83
|
+
@logger.debug "exporting files for #{mname}"
|
84
|
+
exports.each do |export|
|
85
|
+
source_file = File.join(bower, export)
|
86
|
+
destination_file = File.join("exports", mname, export)
|
87
|
+
destination_directory = File.dirname(destination_file)
|
88
|
+
FileUtils.mkdir_p destination_directory
|
89
|
+
if (!File.exist?(destination_file))
|
90
|
+
@logger.debug "exporting #{export}"
|
91
|
+
FileUtils.cp source_file, destination_file
|
92
|
+
end
|
93
|
+
end unless exports.nil?
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
end
|
98
|
+
|
99
|
+
end
|
100
|
+
|
101
|
+
end
|
102
|
+
|
data/lib/xpm/version.rb
CHANGED
data/lib/xpm/xp.rb
CHANGED
@@ -8,7 +8,6 @@ require 'fileutils'
|
|
8
8
|
module XPM
|
9
9
|
class XP
|
10
10
|
|
11
|
-
|
12
11
|
def initialize(options = {})
|
13
12
|
@logger = options[:logger] || Logger.new(STDOUT)
|
14
13
|
end
|
@@ -47,46 +46,6 @@ module XPM
|
|
47
46
|
|
48
47
|
end # init
|
49
48
|
|
50
|
-
def install(package = nil)
|
51
|
-
|
52
|
-
# TODO @depmanager.preinstall ?
|
53
|
-
|
54
|
-
cmd = 'bower install ' + package.to_s
|
55
|
-
# TODO abstract this (@depmanager.install)
|
56
|
-
Open3.popen3(cmd) do |stdin, stdout, stderr, wait_thr|
|
57
|
-
@logger.info "installing dependencies"
|
58
|
-
@logger.info stdout.read
|
59
|
-
err = stderr.read
|
60
|
-
@logger.error err unless err.empty?
|
61
|
-
end
|
62
|
-
|
63
|
-
# TODO hook postinstall (@depmanager.postinstall)
|
64
|
-
# for now loop over bower_components/* and export
|
65
|
-
# files to ./exports/<module name>/.
|
66
|
-
mpath = "xpm_modules"
|
67
|
-
bowers = Dir.glob("#{mpath}/*");
|
68
|
-
|
69
|
-
# TODO rescue
|
70
|
-
bowers.each do |bower|
|
71
|
-
desc = File.read(File.join(bower, "bower.json"))
|
72
|
-
desc = JSON.parse(desc)
|
73
|
-
mname = File.basename(bower)
|
74
|
-
exports = desc["exports"]
|
75
|
-
@logger.debug "exporting files for #{mname}"
|
76
|
-
exports.each do |export|
|
77
|
-
source_file = File.join(bower, export)
|
78
|
-
destination_file = File.join("exports", mname, export)
|
79
|
-
destination_directory = File.dirname(destination_file)
|
80
|
-
FileUtils.mkdir_p destination_directory
|
81
|
-
if (!File.exist?(destination_file))
|
82
|
-
@logger.debug "exporting #{export}"
|
83
|
-
FileUtils.cp source_file, destination_file
|
84
|
-
end
|
85
|
-
end unless exports.nil?
|
86
|
-
end
|
87
|
-
|
88
|
-
end # install
|
89
|
-
|
90
49
|
end
|
91
50
|
end
|
92
51
|
|
data/lib/xpm.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: xpm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- msimonin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-05-
|
11
|
+
date: 2014-05-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -67,6 +67,10 @@ files:
|
|
67
67
|
- Rakefile
|
68
68
|
- bin/xpm
|
69
69
|
- lib/xpm.rb
|
70
|
+
- lib/xpm/all.rb
|
71
|
+
- lib/xpm/configuration.rb
|
72
|
+
- lib/xpm/depmanagers/abstract.rb
|
73
|
+
- lib/xpm/depmanagers/bower.rb
|
70
74
|
- lib/xpm/version.rb
|
71
75
|
- lib/xpm/xp.rb
|
72
76
|
- xpm.gemspec
|