Skip to content

Commit fcdbb05

Browse files
committed
Merge branch 'jxcore'
* jxcore: Official manifest URL! reject unsupported platforms a bit fuzzier Scrape npmjx per jxcore release Update usage Remove spaces from platform name Update jxcore scraper drop --no-jxcore Run jxscore scraper from libexec/scrape Add jxcore scraper
2 parents a541f40 + 39d872a commit fcdbb05

File tree

3 files changed

+137
-8
lines changed

3 files changed

+137
-8
lines changed

bin/nodenv-update-version-defs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#!/usr/bin/env bash
22
#
3-
# Summary: Create build definitions from nodejs.org and iojs.org
3+
# Summary: Create build definitions from nodejs.org, iojs.org and jxcore.com
44
#
5-
# Usage: nodenv update-version-defs [-f] [-d <dir>] [-n] [--nodejs] [--iojs]
5+
# Usage: nodenv update-version-defs [-f] [-d <dir>] [-n] [--nodejs] [--iojs] [--jxcore]
66
#
77
# Scrapes nodejs.org and iojs.org to create build definitions for node
88
# versions not yet available to node-build
@@ -14,9 +14,11 @@
1414
# without doing so
1515
#
1616
# --nodejs Scrape nodejs.org for node definitions;
17-
# If none of --nodejs,--iojs are supplied, defaults to all
17+
# If none of --nodejs,--iojs, --jxcore are supplied, defaults to all
1818
# --iojs Scrape iojs.org for node definitions;
19-
# If none of --nodejs,--iojs are supplied, defaults to all
19+
# If none of --nodejs,--iojs, --jxcore are supplied, defaults to all
20+
# --jxcore Scrape jxcore.com for node definitions;
21+
# If none of --nodejs,--iojs, --jxcore are supplied, defaults to all
2022
#
2123

2224
set -e
@@ -66,6 +68,7 @@ while [ $# -gt 0 ]; do
6668
echo --help
6769
echo --iojs
6870
echo --nodejs
71+
echo --jxcore
6972
exit ;;
7073
-d | --destination )
7174
shift
@@ -75,7 +78,7 @@ while [ $# -gt 0 ]; do
7578
exec nodenv-help update-version-defs ;;
7679
-f | --force | \
7780
-n | --dry-run | \
78-
--iojs | --nodejs )
81+
--iojs | --nodejs | --jxcore )
7982
SCRAPE_OPTS[${#SCRAPE_OPTS[*]}]="$1" ;;
8083
* )
8184
nodenv-help --usage update-version-defs >&2

lib/scraper-jxcore.js

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
var format = require('util').format
2+
var Build = require('./build')().Build
3+
var Binary = require('./build')().Binary
4+
5+
module.exports = {
6+
name: 'jxcore',
7+
distributionListing: 'https://jxcore.s3.amazonaws.com/releases.json',
8+
distToBuild: function (release) {
9+
release.jxcore = release.jxcore.replace(/^Beta-/, '')
10+
var binaries = release.dist
11+
.map(normalizePlatform)
12+
.filter(supportedPlatforms)
13+
.reduce(expandDebianArm, [])
14+
15+
var v8Build = Object.assign(Object.create(V8Build), {
16+
version: release.jxcore,
17+
url: release.source.tar.url,
18+
shasum: release.source.tar.sha256,
19+
binaries: binaries,
20+
npm: release.npmjx.url + '#' + release.npmjx.sha256
21+
})
22+
var spiderMonkeyBuild = Object.assign(Object.create(SMBuild), {
23+
version: release.jxcore,
24+
url: release.source.tar.url,
25+
shasum: release.source.tar.sha256,
26+
binaries: binaries,
27+
npm: release.npmjx.url + '#' + release.npmjx.sha256
28+
})
29+
30+
return [ v8Build, spiderMonkeyBuild ]
31+
}
32+
}
33+
34+
// private
35+
36+
var JxcoreBuild = Object.create(Build, {
37+
binaries: {
38+
get: function () {
39+
return this._binaries
40+
},
41+
set: function (binaries) {
42+
this._binaries = binaries.filter(engine(this.engine)).map(createBinary)
43+
}
44+
},
45+
install: {
46+
get: function () {
47+
return format('install_package %s "%s"\n', this.packageName, this.downloadUri)
48+
}
49+
},
50+
name: {
51+
get: function () {
52+
return 'jxcore+' + this.engine
53+
}
54+
},
55+
packageName: {
56+
get: function () {
57+
return format('jxcore-%s', this.version)
58+
}
59+
},
60+
preamble: {
61+
value: 'after_install_package() {\n fix_jxcore_directory_structure\n}\n\n'
62+
},
63+
postamble: {
64+
get: function () {
65+
return format('install_package npm "%s" jxcore_npm\n', this.npm)
66+
}
67+
}
68+
})
69+
70+
var V8Build = Object.create(JxcoreBuild, {
71+
engine: { value: 'v8' }
72+
})
73+
74+
var SMBuild = Object.create(JxcoreBuild, {
75+
engine: { value: 'sm' },
76+
install: {
77+
get: function () {
78+
return format('install_package %s "%s" jxcore_spidermonkey standard\n', this.packageName, this.downloadUri)
79+
}
80+
}
81+
})
82+
83+
function normalizePlatform (dist) {
84+
dist.platform = dist.platform.toLowerCase().replace(/\s/g, '')
85+
.replace(/osxintel/, 'darwin')
86+
.replace(/rh\/centos\/fedora/, 'redhat')
87+
.replace(/ubuntu\/mint/, 'ubuntu')
88+
89+
dist.arch = (dist.arch || '').toLowerCase()
90+
.replace(/ia32/, 'x86')
91+
92+
return dist
93+
}
94+
95+
function supportedPlatforms (dist) {
96+
return !dist.platform.match(/(?:windows|android|ios)/)
97+
}
98+
99+
function expandDebianArm (binaries, binary) {
100+
if (binary.platform === 'debian' && binary.arch === 'arm') {
101+
binaries.push(
102+
Object.assign(Object.create(binary), {arch: 'arm64'}),
103+
Object.assign(Object.create(binary), {arch: 'armv7l'})
104+
)
105+
} else {
106+
binaries.push(binary)
107+
}
108+
return binaries
109+
}
110+
111+
function engine (engine) {
112+
return function (dist) { return dist.engine === engine }
113+
}
114+
115+
function createBinary (dist) {
116+
return Object.assign(Object.create(Binary), {
117+
arch: dist.arch,
118+
os: dist.platform,
119+
shasum: dist.sha256,
120+
url: dist.url
121+
})
122+
}

libexec/scrape

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ var scrape = require('../lib/scraper')
44

55
var nodejs = require('../lib/scraper-nodejs')
66
var iojs = require('../lib/scraper-iojs')
7+
var jxcore = require('../lib/scraper-jxcore')
78

89
var nodes = {}
910
var options = {
@@ -22,17 +23,20 @@ process.argv.forEach(function (arg) {
2223
case '--dry-run':
2324
options.dryRun = true
2425
break
26+
case '--iojs':
27+
nodes.iojs = iojs
28+
break
2529
case '--nodejs':
2630
nodes.nodejs = nodejs
2731
break
28-
case '--iojs':
29-
nodes.iojs = iojs
32+
case '--jxcore':
33+
nodes.jxcore = jxcore
3034
break
3135
}
3236
})
3337

3438
if (!Object.keys(nodes).length) {
35-
nodes = { nodejs: nodejs, iojs: iojs }
39+
nodes = { nodejs: nodejs, iojs: iojs, jxcore: jxcore }
3640
}
3741

3842
for (var node in nodes) {

0 commit comments

Comments
 (0)