-
Notifications
You must be signed in to change notification settings - Fork 304
/
Copy pathplatforms.js
193 lines (175 loc) · 8.67 KB
/
platforms.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
require('should');
var platforms = require('../lib/utils/platforms');
describe('Platforms', function() {
describe('Detect', function() {
it('should detect osx_64', function() {
platforms.detect('myapp-v0.25.1-darwin-x64.zip').should.be.exactly(platforms.OSX_64);
platforms.detect('myapp.dmg').should.be.exactly(platforms.OSX_64);
});
it('should detect windows_32', function() {
platforms.detect('myapp-v0.25.1-win32-ia32.zip').should.be.exactly(platforms.WINDOWS_32);
platforms.detect('atom-1.0.9-delta.nupkg').should.be.exactly(platforms.WINDOWS_32);
platforms.detect('RELEASES').should.be.exactly(platforms.WINDOWS_32);
});
it('should detect linux', function() {
platforms.detect('enterprise-amd64.tar.gz').should.be.exactly(platforms.LINUX_64);
platforms.detect('enterprise-amd64.tgz').should.be.exactly(platforms.LINUX_64);
platforms.detect('enterprise-ia32.tar.gz').should.be.exactly(platforms.LINUX_32);
platforms.detect('enterprise-ia32.tgz').should.be.exactly(platforms.LINUX_32);
});
it('should detect AppImage_32', function() {
platforms.detect('appimaged-i686.AppImage').should.be.exactly(platforms.LINUX_APPIMAGE_32);
});
it('should detect AppImage_64', function() {
platforms.detect('appimaged-x86_64.AppImage').should.be.exactly(platforms.LINUX_APPIMAGE_64);
});
it('should detect debian_32', function() {
platforms.detect('atom-ia32.deb').should.be.exactly(platforms.LINUX_DEB_32);
});
it('should detect debian_64', function() {
platforms.detect('atom-amd64.deb').should.be.exactly(platforms.LINUX_DEB_64);
});
it('should detect rpm_32', function() {
platforms.detect('atom-ia32.rpm').should.be.exactly(platforms.LINUX_RPM_32);
});
it('should detect rpm_64', function() {
platforms.detect('atom-amd64.rpm').should.be.exactly(platforms.LINUX_RPM_64);
});
});
describe('Resolve', function() {
var version = {
platforms: [
{
'type': 'osx_64',
'filename': 'test-3.3.1-darwin.dmg',
'download_url': 'https://api.github.com/repos/test/test2/releases/assets/793838',
'download_count': 2
},
{
'type': 'osx_64',
'filename': 'test-3.3.1-darwin-x64.zip',
'download_url': 'https://api.github.com/repos/test/test2/releases/assets/793869',
'download_count': 0
},
{
'type': 'windows_32',
'filename': 'atom-1.0.9-delta.nupkg',
'size': 1457531,
'content_type': 'application/zip',
'download_url': 'https://api.github.com/repos/atom/atom/releases/assets/825732',
'download_count': 55844
},
{
'type': 'windows_32',
'filename': 'atom-1.0.9-full.nupkg',
'size': 78181725,
'content_type': 'application/zip',
'download_url': 'https://api.github.com/repos/atom/atom/releases/assets/825730',
'download_count': 26987
},
{
'type': 'linux_32',
'filename': 'atom-ia32.tar.gz',
'size': 71292506,
'content_type': 'application/zip',
'download_url': 'https://api.github.com/repos/atom/atom/releases/assets/825658',
'download_count': 2494
},
{
'type': 'linux_64',
'filename': 'atom-amd64.tar.gz',
'size': 71292506,
'content_type': 'application/zip',
'download_url': 'https://api.github.com/repos/atom/atom/releases/assets/825658',
'download_count': 2494
},
{
'type': 'linux_AppImage_32',
'filename': 'appimaged-i686.AppImage',
'size': 244728,
'content_type': 'application/octet-stream',
'download_url': 'https://api.github.com/repos/AppImage/AppImageKit/releases/assets/5295931',
'download_count': 55
},
{
'type': 'linux_AppImage_64',
'filename': 'appimaged-x86_64.AppImage',
'size': 244728,
'content_type': 'application/octet-stream',
'download_url': 'https://api.github.com/repos/AppImage/AppImageKit/releases/assets/5295938',
'download_count': 55
},
{
'type': 'linux_rpm_32',
'filename': 'atom-ia32.rpm',
'size': 71292506,
'content_type': 'application/zip',
'download_url': 'https://api.github.com/repos/atom/atom/releases/assets/825658',
'download_count': 2494
},
{
'type': 'linux_rpm_64',
'filename': 'atom-amd64.rpm',
'size': 71292506,
'content_type': 'application/zip',
'download_url': 'https://api.github.com/repos/atom/atom/releases/assets/825658',
'download_count': 2494
},
{
'type': 'linux_deb_32',
'filename': 'atom-ia32.deb',
'size': 71292506,
'content_type': 'application/zip',
'download_url': 'https://api.github.com/repos/atom/atom/releases/assets/825658',
'download_count': 2494
},
{
'type': 'linux_deb_64',
'filename': 'atom-amd64.deb',
'size': 71292506,
'content_type': 'application/zip',
'download_url': 'https://api.github.com/repos/atom/atom/releases/assets/825658',
'download_count': 2494
},
{
'type': 'windows_32',
'filename': 'atom-windows.zip',
'size': 79815714,
'content_type': 'application/zip',
'download_url': 'https://api.github.com/repos/atom/atom/releases/assets/825729',
'download_count': 463
},
{
'type': 'windows_32',
'filename': 'AtomSetup.exe',
'size': 78675720,
'content_type': 'application/zip',
'download_url': 'https://api.github.com/repos/atom/atom/releases/assets/825728',
'download_count': 5612
}
]
};
it('should resolve to best platform', function() {
platforms.resolve(version, 'osx').filename.should.be.exactly('test-3.3.1-darwin.dmg');
platforms.resolve(version, 'win32').filename.should.be.exactly('AtomSetup.exe');
platforms.resolve(version, 'linux_64').filename.should.be.exactly('atom-amd64.tar.gz');
platforms.resolve(version, 'linux_32').filename.should.be.exactly('atom-ia32.tar.gz');
platforms.resolve(version, 'linux_AppImage_32').filename.should.be.exactly('appimaged-i686.AppImage');
platforms.resolve(version, 'linux_AppImage_64').filename.should.be.exactly('appimaged-x86_64.AppImage');
platforms.resolve(version, 'linux_rpm_32').filename.should.be.exactly('atom-ia32.rpm');
platforms.resolve(version, 'linux_rpm_64').filename.should.be.exactly('atom-amd64.rpm');
platforms.resolve(version, 'linux_deb_32').filename.should.be.exactly('atom-ia32.deb');
platforms.resolve(version, 'linux_deb_64').filename.should.be.exactly('atom-amd64.deb');
});
it('should resolve to best platform with a preferred filetype', function() {
platforms.resolve(version, 'osx', {
filePreference: ['.zip']
}).filename.should.be.exactly('test-3.3.1-darwin-x64.zip');
});
it('should resolve to best platform with a wanted filetype', function() {
platforms.resolve(version, 'osx', {
wanted: '.zip'
}).filename.should.be.exactly('test-3.3.1-darwin-x64.zip');
});
});
});