maril 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 +12 -2
- data/Rakefile +13 -0
- data/lib/maril/generator.rb +2 -2
- data/lib/maril/version.rb +1 -1
- data/userscript/maril.user.js +66 -0
- data/userscript/maril.user.js.erb +66 -0
- 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: 93388dd3ee1c7ee421e13f3385ce3da8ce159185
|
4
|
+
data.tar.gz: c5dc7f08a4487f18db14e9f543d2bd6d6ba44d17
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 62b4232a83180f2c0a266fddc80083efc7c86e4404c4e62495264ea0aaa6459b66fd10be0394574f8ab514c701597d211f5c2e85e15624f23305848378db4af0
|
7
|
+
data.tar.gz: f94e7b19042302b76efb99a9059f18152a4ea1daa3b4c9338d8ff8b139f0ec6450a74b1b22ddf42398f7784666afc91f1f1c11db48581b649710e8385ada1ddd
|
data/README.md
CHANGED
@@ -6,14 +6,24 @@ Maril is abbreviation of "Marathon Application Run In Local". Which is a command
|
|
6
6
|
|
7
7
|
Open your terminal and execute:
|
8
8
|
|
9
|
-
|
9
|
+
```
|
10
|
+
$ gem install maril
|
11
|
+
```
|
12
|
+
|
13
|
+
I also provide a greasemonkey userscript. It will add a button on your marathon application page. You just need to click it and the `docker run` command will be saved into your clipboard.
|
14
|
+
|
15
|
+

|
16
|
+
|
17
|
+
You can click [here](https://raw.githubusercontent.com/agate/maril/master/userscript/maril.user.js) to install it.
|
18
|
+
|
19
|
+
> Remember: You have to either change `@match` or add new `@match` in this userscript to match your marathon site. So that this button can show up.
|
10
20
|
|
11
21
|
## Usage
|
12
22
|
|
13
23
|
Open your terminal and run:
|
14
24
|
|
15
25
|
```
|
16
|
-
$ maril http://your.marathon.domain /your/application/id
|
26
|
+
$ maril --host http://your.marathon.domain --id /your/application/id
|
17
27
|
```
|
18
28
|
|
19
29
|
## Development
|
data/Rakefile
CHANGED
@@ -1,6 +1,19 @@
|
|
1
1
|
require "bundler/gem_tasks"
|
2
2
|
require "rspec/core/rake_task"
|
3
|
+
require "erb"
|
3
4
|
|
4
5
|
RSpec::Core::RakeTask.new(:spec)
|
5
6
|
|
6
7
|
task :default => :spec
|
8
|
+
|
9
|
+
desc "Build maril.user.js"
|
10
|
+
task "build_userscript" do
|
11
|
+
gemspec = Gem::Specification::load("maril.gemspec")
|
12
|
+
src_path = "userscript/maril.user.js.erb"
|
13
|
+
dis_path = "userscript/maril.user.js"
|
14
|
+
content = ERB.new(File.read(src_path)).result(binding)
|
15
|
+
File.write(dis_path, content)
|
16
|
+
puts "Compiled #{src_path} => #{dis_path}"
|
17
|
+
end
|
18
|
+
|
19
|
+
task "build" => "build_userscript"
|
data/lib/maril/generator.rb
CHANGED
@@ -7,7 +7,7 @@ module Maril
|
|
7
7
|
|
8
8
|
def generate
|
9
9
|
app = fetch_app
|
10
|
-
cmd = [ 'docker run' ]
|
10
|
+
cmd = [ 'docker run --rm -it' ]
|
11
11
|
app['env'].each do |k, v|
|
12
12
|
cmd << "-e #{k}=#{v}"
|
13
13
|
end
|
@@ -19,7 +19,7 @@ module Maril
|
|
19
19
|
end
|
20
20
|
cmd << app['container']['docker']['image']
|
21
21
|
cmd << app['cmd'] if app['cmd']
|
22
|
-
cmd.join("
|
22
|
+
cmd.join(" ")
|
23
23
|
end
|
24
24
|
|
25
25
|
private
|
data/lib/maril/version.rb
CHANGED
@@ -0,0 +1,66 @@
|
|
1
|
+
// ==UserScript==
|
2
|
+
// @name Maril
|
3
|
+
// @namespace https://github.com/agate/maril
|
4
|
+
// @version 0.1.1
|
5
|
+
// @description Marathon Application Run In Local
|
6
|
+
// @author agate<agate.hao@gmail.com>
|
7
|
+
// @match http://PUT.YOUR.MARATHON.DOMAIN.HERE/*
|
8
|
+
// @grant GM_xmlhttpRequest
|
9
|
+
// @grant GM_setClipboard
|
10
|
+
// ==/UserScript==
|
11
|
+
|
12
|
+
(function() {
|
13
|
+
'use strict';
|
14
|
+
|
15
|
+
let currentAppId = null;
|
16
|
+
|
17
|
+
const generateDockerCmd = () => {
|
18
|
+
let url = `${location.origin}/v2/apps${currentAppId}`;
|
19
|
+
GM_xmlhttpRequest({
|
20
|
+
method: "GET",
|
21
|
+
url: url,
|
22
|
+
onload: function(response) {
|
23
|
+
let app = JSON.parse(response.responseText).app;
|
24
|
+
let cmd = [ "docker run --rm -it" ];
|
25
|
+
|
26
|
+
for (var key in app.env) {
|
27
|
+
cmd.push(`-e ${key}=${app.env[key]}`);
|
28
|
+
}
|
29
|
+
app.container.docker.parameters.forEach((parameter) => {
|
30
|
+
cmd.push(`--${parameter.key} ${parameter.value}`);
|
31
|
+
});
|
32
|
+
app.container.docker.portMappings.forEach((mapping) => {
|
33
|
+
cmd.push(`-p ${mapping.containerPort}:${mapping.containerPort}`);
|
34
|
+
});
|
35
|
+
cmd.push(app.container.docker.image);
|
36
|
+
|
37
|
+
GM_setClipboard(cmd.join(" "));
|
38
|
+
alert("Already saved the docker run command into your clipboard.");
|
39
|
+
},
|
40
|
+
onerror: (response) => {
|
41
|
+
alert("error");
|
42
|
+
}
|
43
|
+
});
|
44
|
+
};
|
45
|
+
|
46
|
+
const attachButton = () => {
|
47
|
+
let hash = window.location.hash.slice(1);
|
48
|
+
if (hash.match(/^\/apps\/[^/]+$/)) {
|
49
|
+
let appId = decodeURIComponent(hash.slice(6));
|
50
|
+
if (currentAppId != appId) {
|
51
|
+
currentAppId = appId;
|
52
|
+
let parentEle = document.querySelector('.header-btn');
|
53
|
+
let btn = document.createElement('a');
|
54
|
+
let btnTxt = document.createTextNode("Generate Docker CMD");
|
55
|
+
btn.setAttribute("class", "btn btn-lg btn-default");
|
56
|
+
btn.style["margin-left"] = "5px";
|
57
|
+
btn.appendChild(btnTxt);
|
58
|
+
btn.addEventListener("click", generateDockerCmd, false);
|
59
|
+
parentEle.appendChild(btn);
|
60
|
+
}
|
61
|
+
}
|
62
|
+
};
|
63
|
+
|
64
|
+
window.addEventListener("hashchange", attachButton, false);
|
65
|
+
attachButton();
|
66
|
+
})();
|
@@ -0,0 +1,66 @@
|
|
1
|
+
// ==UserScript==
|
2
|
+
// @name Maril
|
3
|
+
// @namespace https://github.com/agate/maril
|
4
|
+
// @version <%= gemspec.version %>
|
5
|
+
// @description <%= gemspec.summary %>
|
6
|
+
// @author <%= gemspec.authors.map.with_index{ |a, i| "#{a}<#{gemspec.email[i]}>" }.join(", ") %>
|
7
|
+
// @match http://PUT.YOUR.MARATHON.DOMAIN.HERE/*
|
8
|
+
// @grant GM_xmlhttpRequest
|
9
|
+
// @grant GM_setClipboard
|
10
|
+
// ==/UserScript==
|
11
|
+
|
12
|
+
(function() {
|
13
|
+
'use strict';
|
14
|
+
|
15
|
+
let currentAppId = null;
|
16
|
+
|
17
|
+
const generateDockerCmd = () => {
|
18
|
+
let url = `${location.origin}/v2/apps${currentAppId}`;
|
19
|
+
GM_xmlhttpRequest({
|
20
|
+
method: "GET",
|
21
|
+
url: url,
|
22
|
+
onload: function(response) {
|
23
|
+
let app = JSON.parse(response.responseText).app;
|
24
|
+
let cmd = [ "docker run --rm -it" ];
|
25
|
+
|
26
|
+
for (var key in app.env) {
|
27
|
+
cmd.push(`-e ${key}=${app.env[key]}`);
|
28
|
+
}
|
29
|
+
app.container.docker.parameters.forEach((parameter) => {
|
30
|
+
cmd.push(`--${parameter.key} ${parameter.value}`);
|
31
|
+
});
|
32
|
+
app.container.docker.portMappings.forEach((mapping) => {
|
33
|
+
cmd.push(`-p ${mapping.containerPort}:${mapping.containerPort}`);
|
34
|
+
});
|
35
|
+
cmd.push(app.container.docker.image);
|
36
|
+
|
37
|
+
GM_setClipboard(cmd.join(" "));
|
38
|
+
alert("Already saved the docker run command into your clipboard.");
|
39
|
+
},
|
40
|
+
onerror: (response) => {
|
41
|
+
alert("error");
|
42
|
+
}
|
43
|
+
});
|
44
|
+
};
|
45
|
+
|
46
|
+
const attachButton = () => {
|
47
|
+
let hash = window.location.hash.slice(1);
|
48
|
+
if (hash.match(/^\/apps\/[^/]+$/)) {
|
49
|
+
let appId = decodeURIComponent(hash.slice(6));
|
50
|
+
if (currentAppId != appId) {
|
51
|
+
currentAppId = appId;
|
52
|
+
let parentEle = document.querySelector('.header-btn');
|
53
|
+
let btn = document.createElement('a');
|
54
|
+
let btnTxt = document.createTextNode("Generate Docker CMD");
|
55
|
+
btn.setAttribute("class", "btn btn-lg btn-default");
|
56
|
+
btn.style["margin-left"] = "5px";
|
57
|
+
btn.appendChild(btnTxt);
|
58
|
+
btn.addEventListener("click", generateDockerCmd, false);
|
59
|
+
parentEle.appendChild(btn);
|
60
|
+
}
|
61
|
+
}
|
62
|
+
};
|
63
|
+
|
64
|
+
window.addEventListener("hashchange", attachButton, false);
|
65
|
+
attachButton();
|
66
|
+
})();
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: maril
|
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
|
- agate
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-08-
|
11
|
+
date: 2017-08-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -104,6 +104,8 @@ files:
|
|
104
104
|
- lib/maril/generator.rb
|
105
105
|
- lib/maril/version.rb
|
106
106
|
- maril.gemspec
|
107
|
+
- userscript/maril.user.js
|
108
|
+
- userscript/maril.user.js.erb
|
107
109
|
homepage: https://github.com/agate/maril
|
108
110
|
licenses:
|
109
111
|
- MIT
|