disclose 0.4.0 → 0.5.0
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 +14 -0
- data/disclose.gemspec +20 -1
- data/lib/disclose.rb +7 -4
- data/lib/disclose/c.rb +74 -26
- data/lib/disclose/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 12b6c9cb872ab8098620fb864c7a507cc1ffe53f
|
4
|
+
data.tar.gz: 521c3c4d2f170c39c58939f0d36ef5ec24e06a9c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ac677eb6eb07cc39cff5d09ee0699c04ba3dfea7f1e0244987bdb02a254e3b9da200d6b09dfa17db0ba015f6f0c4da174df4649867deab005bc743c704689a8a
|
7
|
+
data.tar.gz: 39cc60843db112afad3a2020c29cc3ae02547859565d08999acd9f068ee4b815e0ef7bbad3f15fc8688372047a06cc85e6ee958577a433222c395be084bbd85e
|
data/README.md
CHANGED
@@ -12,12 +12,26 @@ Pack your Node.js project into an executable without recompiling Node.js.
|
|
12
12
|
|
13
13
|
$ gem install disclose
|
14
14
|
|
15
|
+
## Dependencies
|
16
|
+
|
17
|
+
Make sure that your system has the following components,
|
18
|
+
|
19
|
+
- tar
|
20
|
+
- xxd
|
21
|
+
- cc or cl.exe
|
22
|
+
|
15
23
|
## Usage
|
16
24
|
|
17
25
|
$ disclose [node_path] [project_path]
|
18
26
|
|
19
27
|
## Example
|
20
28
|
|
29
|
+
On Windows,
|
30
|
+
|
31
|
+
> disclose "C:\Program Files\nodejs\node.exe" "Z:\node_modules\coffee-script"
|
32
|
+
|
33
|
+
On Unix,
|
34
|
+
|
21
35
|
$ disclose /usr/local/bin/node /usr/local/lib/node_modules/coffee-script
|
22
36
|
|
23
37
|
## License
|
data/disclose.gemspec
CHANGED
@@ -14,7 +14,26 @@ Gem::Specification.new do |spec|
|
|
14
14
|
spec.homepage = "https://github.com/pmq20/disclose"
|
15
15
|
spec.license = "MIT"
|
16
16
|
|
17
|
-
spec.files =
|
17
|
+
spec.files = [
|
18
|
+
'.gitignore',
|
19
|
+
'.rspec',
|
20
|
+
'.travis.yml',
|
21
|
+
'Gemfile',
|
22
|
+
'LICENSE',
|
23
|
+
'README.md',
|
24
|
+
'Rakefile',
|
25
|
+
'bin/console',
|
26
|
+
'bin/setup',
|
27
|
+
'disclose.gemspec',
|
28
|
+
'exe/disclose',
|
29
|
+
'lib/disclose.rb',
|
30
|
+
'lib/disclose/c.rb',
|
31
|
+
'lib/disclose/libiconv_2_dll.h',
|
32
|
+
'lib/disclose/libintl_2_dll.h',
|
33
|
+
'lib/disclose/tar_exe.h',
|
34
|
+
'lib/disclose/version.rb',
|
35
|
+
'lib/disclose/windows.rb',
|
36
|
+
]
|
18
37
|
spec.bindir = "exe"
|
19
38
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
39
|
spec.require_paths = ["lib"]
|
data/lib/disclose.rb
CHANGED
@@ -42,9 +42,8 @@ Usage: disclose [node_path] [project_path]
|
|
42
42
|
end
|
43
43
|
|
44
44
|
def tar!
|
45
|
-
chdir(@
|
46
|
-
@
|
47
|
-
exe("tar cf #{Shellwords.escape(@tar_path)} . -C #{Shellwords.escape File.dirname @node_path} #{Shellwords.escape File.basename @node_path}")
|
45
|
+
chdir(@working_dir) do
|
46
|
+
exe("tar cf tar.tar -C \"#{@project_path}\" . -C \"#{File.dirname @node_path}\" \"#{File.basename @node_path}\"")
|
48
47
|
end
|
49
48
|
end
|
50
49
|
|
@@ -62,7 +61,11 @@ Usage: disclose [node_path] [project_path]
|
|
62
61
|
File.open("#{key}.c", "a") do |f|
|
63
62
|
C.src(f, value, @md5)
|
64
63
|
end
|
65
|
-
|
64
|
+
if Gem.win_platform?
|
65
|
+
exe("cl.exe #{key}.c")
|
66
|
+
else
|
67
|
+
exe("cc #{key}.c -o #{key}")
|
68
|
+
end
|
66
69
|
|
67
70
|
puts "======= Success ======="
|
68
71
|
puts File.join(@working_dir, key)
|
data/lib/disclose/c.rb
CHANGED
@@ -1,51 +1,107 @@
|
|
1
1
|
class Disclose
|
2
2
|
module C
|
3
3
|
class << self
|
4
|
+
def unistd
|
5
|
+
if Gem.win_platform?
|
6
|
+
%q{
|
7
|
+
#include <stdlib.h>
|
8
|
+
#include <io.h>
|
9
|
+
#include <process.h> /* for getpid() and the exec..() family */
|
10
|
+
#include <direct.h> /* for _getcwd() and _chdir() */
|
11
|
+
}
|
12
|
+
else
|
13
|
+
%q{
|
14
|
+
#include <unistd.h>
|
15
|
+
}
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def slash
|
20
|
+
Gem.win_platform? ? %q{\\\\} : '/'
|
21
|
+
end
|
22
|
+
|
4
23
|
def src(f, name, md5)
|
5
24
|
windows_prepare(f) if Gem.win_platform?
|
6
|
-
|
25
|
+
f.puts unistd
|
7
26
|
f.puts %Q{
|
8
|
-
#include <unistd.h>
|
9
27
|
#include <stdio.h>
|
10
28
|
#include <stdlib.h>
|
11
29
|
#include <assert.h>
|
12
30
|
#include <sys/types.h>
|
13
31
|
#include <sys/stat.h>
|
14
32
|
|
33
|
+
char *tmp_prefix;
|
34
|
+
char md5_path[1024];
|
35
|
+
char cwd_path[1024];
|
36
|
+
|
37
|
+
void get_tmp_prefix() {
|
38
|
+
tmp_prefix = getenv("TMPDIR");
|
39
|
+
if (NULL != tmp_prefix) return;
|
40
|
+
tmp_prefix = getenv("TMP");
|
41
|
+
if (NULL != tmp_prefix) return;
|
42
|
+
tmp_prefix = getenv("TEMP");
|
43
|
+
if (NULL != tmp_prefix) return;
|
44
|
+
tmp_prefix = cwd_path;
|
45
|
+
}
|
46
|
+
|
15
47
|
void untar() {
|
16
|
-
char cmd[
|
17
|
-
char file[] =
|
18
|
-
char dir[] =
|
48
|
+
char cmd[1024] = {0};
|
49
|
+
char file[1024] = {0};
|
50
|
+
char dir[1024] = {0};
|
19
51
|
FILE *fp = NULL;
|
20
52
|
int ret;
|
21
53
|
|
54
|
+
// Be careful about the number of XXXXXX
|
55
|
+
// Relate to the magical number 20 below.
|
56
|
+
snprintf(file, 1023, "%s#{slash}disclose.file.XXXXXX", tmp_prefix);
|
57
|
+
snprintf(dir, 1023, "%s#{slash}disclose.dir.XXXXXX", tmp_prefix);
|
58
|
+
|
22
59
|
mktemp(file);
|
23
|
-
|
60
|
+
mktemp(dir);
|
61
|
+
mkdir(dir#{', 0777' unless Gem.win_platform?});
|
24
62
|
|
25
63
|
fp = fopen(file, "wb");
|
26
64
|
assert(fp);
|
27
65
|
fwrite(tar_tar, sizeof(unsigned char), sizeof(tar_tar), fp);
|
28
66
|
fclose(fp);
|
29
67
|
|
30
|
-
#{Gem.win_platform?
|
68
|
+
#{tar_windows if Gem.win_platform?}
|
31
69
|
|
32
|
-
|
70
|
+
chdir(tmp_prefix);
|
71
|
+
|
72
|
+
snprintf(cmd, 1023, "tar xf \\"%s\\" -C \\"%s\\"", file + strlen(file) - 20, dir + strlen(dir) - 20);
|
73
|
+
ret = system(cmd);
|
74
|
+
assert(0 == ret);
|
75
|
+
|
76
|
+
chdir(cwd_path);
|
77
|
+
|
78
|
+
rename(dir, md5_path);
|
33
79
|
}
|
34
80
|
|
35
81
|
int main(int argc, char const *argv[]) {
|
36
82
|
char **argv2 = NULL;
|
37
83
|
int i, index;
|
38
84
|
struct stat info;
|
85
|
+
char arg0[1024] = {0};
|
86
|
+
char arg1[1024] = {0};
|
39
87
|
|
40
|
-
|
88
|
+
getcwd(cwd_path, sizeof(cwd_path));
|
89
|
+
get_tmp_prefix();
|
90
|
+
snprintf(md5_path, 1023, "%s#{slash}disclose.#{md5}", tmp_prefix);
|
91
|
+
|
92
|
+
if( stat( md5_path, &info ) != 0 )
|
41
93
|
untar();
|
42
94
|
|
43
|
-
assert(0 == stat(
|
95
|
+
assert(0 == stat( md5_path, &info ) && info.st_mode & S_IFDIR);
|
44
96
|
|
45
97
|
argv2 = malloc(sizeof(char*) * (argc + 10));
|
46
98
|
assert(argv2);
|
47
|
-
|
48
|
-
|
99
|
+
|
100
|
+
snprintf(arg0, 1023, "%s#{slash}node", md5_path);
|
101
|
+
snprintf(arg1, 1023, "%s#{slash}#{name}", md5_path);
|
102
|
+
|
103
|
+
argv2[0] = arg0;
|
104
|
+
argv2[1] = arg1;
|
49
105
|
index = 2;
|
50
106
|
for (i = 1; i < argc; ++i) {
|
51
107
|
argv2[index] = argv[i];
|
@@ -59,20 +115,14 @@ class Disclose
|
|
59
115
|
}
|
60
116
|
end
|
61
117
|
|
62
|
-
def tar
|
63
|
-
%Q{
|
64
|
-
snprintf(cmd, 255, "tar xf %s -C %s", file, dir);
|
65
|
-
ret = system(cmd);
|
66
|
-
assert(0 == ret);
|
67
|
-
}
|
68
|
-
end
|
69
|
-
|
70
118
|
def tar_windows
|
71
119
|
%Q{
|
72
|
-
char tardir[]
|
120
|
+
char tardir[1024];
|
121
|
+
snprintf(tardir, 1023, "%s#{slash}disclose.tardir.XXXXXX", tmp_prefix);
|
122
|
+
mktemp(tardir);
|
123
|
+
mkdir(tardir);
|
73
124
|
|
74
|
-
|
75
|
-
assert(0 == ret);
|
125
|
+
chdir(tardir);
|
76
126
|
|
77
127
|
fp = fopen("libiconv_2.dll", "wb");
|
78
128
|
assert(fp);
|
@@ -89,9 +139,7 @@ class Disclose
|
|
89
139
|
fwrite(tar_exe, sizeof(unsigned char), sizeof(tar_exe), fp);
|
90
140
|
fclose(fp);
|
91
141
|
|
92
|
-
|
93
|
-
ret = system(cmd);
|
94
|
-
assert(0 == ret);
|
142
|
+
chdir(cwd_path);
|
95
143
|
}
|
96
144
|
end
|
97
145
|
|
data/lib/disclose/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: disclose
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- The rugged tests are fragile
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-07-
|
11
|
+
date: 2016-07-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|