yarnlock 0.1.0 → 0.1.1
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/README.md +10 -1
- data/lib/yarnlock.rb +14 -17
- data/lib/yarnlock/config.rb +12 -0
- data/lib/yarnlock/js_executor.rb +17 -0
- data/lib/yarnlock/version.rb +1 -1
- data/yarnlock.gemspec +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 971a86fd881953dd44f8cb81309d879707e29471
|
4
|
+
data.tar.gz: 2d91494c6c74878999cf1b54e18fc85b3f4fdaa1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8b10a8e7554b0fa385cee918333209e6c0f1c80fadfd08ef3a82e76aec10edb9d1f41e3f9302cbb72ec81989020bca12bb37317e1dd9d2626d98e012fea313cc
|
7
|
+
data.tar.gz: e0787a52a5b613d2cefe12299811eda7d17e0330d949f86e055f8cad9f9997ae0d978e844774a2da5c945fa9eb6316860fc1cf65583259f6296816b49c730362
|
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# Ruby-Yarnlock
|
2
2
|
|
3
3
|
[](https://badge.fury.io/rb/yarnlock)
|
4
|
-
[](https://travis-ci.org/
|
4
|
+
[](https://travis-ci.org/hiromi2424/ruby-yarnlock)
|
5
5
|
|
6
6
|
Thin wrapper of [@yarnpkg/lockfile](https://yarnpkg.com/ja/package/@yarnpkg/lockfile) for Ruby.
|
7
7
|
|
@@ -44,6 +44,15 @@ Yarnlock.load 'yarn.lock'
|
|
44
44
|
Yarnlock.stringify parsed_hash
|
45
45
|
```
|
46
46
|
|
47
|
+
You can configure paths for Node.js(`'node'` by default) and JS scripts dir(`'{package root}/scripts'` by default).
|
48
|
+
|
49
|
+
```ruby
|
50
|
+
Yarnlock.configure do |config|
|
51
|
+
config.script_dir = '/path/to/my/dir'
|
52
|
+
config.node_path = '/usr/local/bin/node'
|
53
|
+
end
|
54
|
+
```
|
55
|
+
|
47
56
|
## Development
|
48
57
|
|
49
58
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
data/lib/yarnlock.rb
CHANGED
@@ -1,11 +1,23 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'yarnlock/version'
|
4
|
+
|
5
|
+
require 'yarnlock/config'
|
6
|
+
require 'yarnlock/js_executor'
|
7
|
+
|
4
8
|
require 'json'
|
5
9
|
|
6
10
|
module Yarnlock
|
11
|
+
def self.config
|
12
|
+
@config ||= Config.new
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.configure
|
16
|
+
yield config
|
17
|
+
end
|
18
|
+
|
7
19
|
def self.parse(yarnlock)
|
8
|
-
json_string =
|
20
|
+
json_string = JsExecutor.execute 'parse', yarnlock
|
9
21
|
parsed = JSON.parse json_string
|
10
22
|
raise "An error was occurred when parsing yarn.lock: #{parsed}" unless parsed.is_a? Hash
|
11
23
|
raise "Could not parse yarn.lock: #{parsed['reason']}" unless parsed['type'] == 'success'
|
@@ -13,7 +25,7 @@ module Yarnlock
|
|
13
25
|
end
|
14
26
|
|
15
27
|
def self.stringify(object)
|
16
|
-
json_string =
|
28
|
+
json_string = JsExecutor.execute 'stringify', JSON.generate(object)
|
17
29
|
parsed = JSON.parse json_string
|
18
30
|
raise "An error was occurred when stringing object: #{parsed}" unless parsed.is_a? Hash
|
19
31
|
raise "Could not stringing object: #{parsed['reason']}" unless parsed['type'] == 'success'
|
@@ -23,19 +35,4 @@ module Yarnlock
|
|
23
35
|
def self.load(file)
|
24
36
|
parse File.read(file)
|
25
37
|
end
|
26
|
-
|
27
|
-
def self.execute_script(script, stdin)
|
28
|
-
IO.popen("node #{script_dir}/#{script}", 'r+') do |io|
|
29
|
-
io.puts stdin
|
30
|
-
io.close_write
|
31
|
-
io.gets
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
def self.script_dir
|
36
|
-
return @script_dir unless @script_dir.nil?
|
37
|
-
@script_dir = File.join File.dirname(__dir__), '/scripts'
|
38
|
-
end
|
39
|
-
|
40
|
-
private_class_method :execute_script, :script_dir
|
41
38
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Yarnlock
|
4
|
+
module JsExecutor
|
5
|
+
def self.execute(script, stdin)
|
6
|
+
IO.popen(script_path(script), 'r+') do |io|
|
7
|
+
io.puts stdin
|
8
|
+
io.close_write
|
9
|
+
io.gets
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.script_path(script)
|
14
|
+
"#{Yarnlock.config.node_path} #{Yarnlock.config.script_dir}/#{script}"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/lib/yarnlock/version.rb
CHANGED
data/yarnlock.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yarnlock
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hiroki Shimizu
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-03-
|
11
|
+
date: 2018-03-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -87,6 +87,8 @@ files:
|
|
87
87
|
- bin/console
|
88
88
|
- bin/setup
|
89
89
|
- lib/yarnlock.rb
|
90
|
+
- lib/yarnlock/config.rb
|
91
|
+
- lib/yarnlock/js_executor.rb
|
90
92
|
- lib/yarnlock/version.rb
|
91
93
|
- package.json
|
92
94
|
- scripts/parse.js
|