@plotdb/registry 0.0.11 → 0.0.13
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.
- package/CHANGELOG.md +21 -0
- package/README.md +10 -0
- package/designate.js +3 -1
- package/package.json +1 -1
- package/providers/github.js +44 -27
- package/route.js +32 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
# Change Logs
|
|
2
2
|
|
|
3
|
+
## v0.0.13
|
|
4
|
+
|
|
5
|
+
- bug fix:
|
|
6
|
+
- github provider: read versions from `dist/vX.Y.Z` release tags as well. fedep >= 1.8
|
|
7
|
+
( `publish -g` ) cuts the release on `dist/vX.Y.Z` - the bare `vX.Y.Z` it also pushes is a
|
|
8
|
+
tag without a release, invisible to the releases api - so `latest` resolved to the invalid
|
|
9
|
+
version `dist/v0.0.3` ( 400 ), an exact version 404'd and range lists dropped those releases.
|
|
10
|
+
`src/vX.Y.Z` ( the source commit ) is never taken as a version. an exact version tries
|
|
11
|
+
`vX.Y.Z` first, then `dist/vX.Y.Z`.
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## v0.0.12
|
|
15
|
+
|
|
16
|
+
- tweaks:
|
|
17
|
+
- check `root.fs` once when `registry.route` / `registry.designate` is created ( i.e., on
|
|
18
|
+
server start ): create it if missing and verify it is writable. on failure, warn with a
|
|
19
|
+
fix command instead of failing on the first fetch with an opaque 500
|
|
20
|
+
( e.g. `EACCES: permission denied, mkdir '/var/lib/cdn'` when `/var/lib/cdn` is not
|
|
21
|
+
prepared ). only warns, so a broken registry root does not keep the server from starting.
|
|
22
|
+
|
|
23
|
+
|
|
3
24
|
## v0.0.11
|
|
4
25
|
|
|
5
26
|
- bug fix:
|
package/README.md
CHANGED
|
@@ -47,6 +47,16 @@ add a route:
|
|
|
47
47
|
internal: "/ilib" # internal redirect URL from server to nginx.
|
|
48
48
|
});
|
|
49
49
|
|
|
50
|
+
`fs` must be writable by the server user. it is checked when the route is created ( a warning
|
|
51
|
+
with a fix command is printed if not ). the conventional location is `/var/lib/cdn/cache`; since
|
|
52
|
+
`/var/lib` is root-only, prepare it beforehand, e.g. with systemd-tmpfiles:
|
|
53
|
+
|
|
54
|
+
echo 'd /var/lib/cdn/cache 0755 <server-user> <server-user> -' | sudo tee /etc/tmpfiles.d/registry-cdn.conf
|
|
55
|
+
sudo systemd-tmpfiles --create /etc/tmpfiles.d/registry-cdn.conf
|
|
56
|
+
|
|
57
|
+
note that `fs` is not a pure cache: `main` symlinks record admin designation ( see Caching Model ),
|
|
58
|
+
so keep it across deploys instead of treating it as disposable.
|
|
59
|
+
|
|
50
60
|
generate customied nginx config:
|
|
51
61
|
|
|
52
62
|
npx registry-nginx -c myconfig.yaml > reg.ngx
|
package/designate.js
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
// Generated by LiveScript 1.6.0
|
|
2
2
|
(function(){
|
|
3
|
-
var pthk, lderror, designate;
|
|
3
|
+
var pthk, lderror, checkRoot, designate;
|
|
4
4
|
pthk = require('pthk');
|
|
5
5
|
lderror = require('lderror');
|
|
6
|
+
checkRoot = require('./route').checkRoot;
|
|
6
7
|
designate = function(arg$){
|
|
7
8
|
var provider, root, opt;
|
|
8
9
|
provider = arg$.provider, root = arg$.root, opt = arg$.opt;
|
|
9
10
|
if (!root.pub.endsWith('/')) {
|
|
10
11
|
root.pub = root.pub + "/";
|
|
11
12
|
}
|
|
13
|
+
checkRoot(root.fs);
|
|
12
14
|
return function(req, res){
|
|
13
15
|
var url, id, _o;
|
|
14
16
|
url = req.originalUrl;
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"author":"zbryikt","name":"@plotdb/registry","license":"MIT","description":"registry","version":"0.0.
|
|
1
|
+
{"author":"zbryikt","name":"@plotdb/registry","license":"MIT","description":"registry","version":"0.0.13","main":"index.js","homepage":"https://github.com/plotdb/registry","repository":{"type":"git","url":"https://github.com/plotdb/registry"},"engines":{"node":">=18","npm":">=6.4.1"},"scripts":{"start":"npx server -r web -o true","server":"cd web; ../node_modules/.bin/lsc server.ls","build":"lsc -c -o dist src/index.ls src/route.ls src/provider.ls src/designate.ls src/unbox.ls src/ngxgen.ls && lsc -c -o dist/providers src/providers/index.ls src/providers/github.ls src/providers/npm.ls && cp src/config.ngx dist/config.ngx","test":"lsc test/index.ls"},"bin":{"registry-ngx":"./bin/ngxgen"},"dependencies":{"@plotdb/guides":"github:plotdb/guides#master","@plotdb/semver":"^0.0.4","@zbryikt/template":"^2.4.2","fs-extra":"^8.1.0","js-yaml":"^4.1.1","lderror":"^2.4.6","livescript":"^1.6.0","node-fetch":"^2.6.7","pthk":"^0.0.1","tar":"^7.5.21","template-text":"^0.2.0","yargs":"^17.6.0","yauzl":"^2.10.0"},"devDependencies":{"@loadingio/bootstrap.ext":"^0.0.12","@loadingio/debounce.js":"^1.0.1","@loadingio/ldquery":"^3.0.6","@plotdb/block":"^5.6.3","@plotdb/csscope":"^5.0.4","@plotdb/rescope":"^5.0.17","bootstrap":"^4.6.1","bootstrap.native":"^3.0.14","fedep":"^1.7.6","ldcover":"^3.5.6","ldloader":"^3.0.3","ldview":"^1.7.0","proxise":"^1.0.1"},"frontendDependencies":{"root":"web/static/assets/lib","modules":["@loadingio/bootstrap.ext","@loadingio/debounce.js","@loadingio/ldquery","bootstrap","bootstrap.native","@plotdb/block","@plotdb/csscope","@plotdb/rescope","@plotdb/semver","ldcover","ldloader","ldview","proxise"]}}
|
package/providers/github.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Generated by LiveScript 1.6.0
|
|
2
2
|
(function(){
|
|
3
|
-
var nodeFetch, lderror, provider, unbox, semver, getToken, pvd;
|
|
3
|
+
var nodeFetch, lderror, provider, unbox, semver, getToken, tagVersion, get, pvd;
|
|
4
4
|
nodeFetch = require('node-fetch');
|
|
5
5
|
lderror = require('lderror');
|
|
6
6
|
provider = require('../provider');
|
|
@@ -15,6 +15,31 @@
|
|
|
15
15
|
? null
|
|
16
16
|
: (opt.scope || (opt.scope = {}))[scope] || (opt.repo || (opt.repo = {}))[name] || opt.token || null;
|
|
17
17
|
};
|
|
18
|
+
tagVersion = function(tag){
|
|
19
|
+
var v;
|
|
20
|
+
tag = (tag || '') + "";
|
|
21
|
+
if (/^src\//.exec(tag)) {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
v = tag.replace(/^dist\//, '').replace(/^v/, '');
|
|
25
|
+
if (semver.valid(v)) {
|
|
26
|
+
return v;
|
|
27
|
+
} else {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
get = function(url, headers){
|
|
32
|
+
return nodeFetch(url, {
|
|
33
|
+
method: 'GET',
|
|
34
|
+
headers: headers
|
|
35
|
+
}).then(function(r){
|
|
36
|
+
if (r.status !== 200) {
|
|
37
|
+
return lderror.reject(404);
|
|
38
|
+
} else {
|
|
39
|
+
return r.json();
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
};
|
|
18
43
|
pvd = new provider({
|
|
19
44
|
name: 'github',
|
|
20
45
|
fetchVersionList: function(arg$){
|
|
@@ -29,25 +54,16 @@
|
|
|
29
54
|
}
|
|
30
55
|
: {};
|
|
31
56
|
jsonurl = "https://api.github.com/repos/" + name.replace('@', '') + "/releases?per_page=100";
|
|
32
|
-
return
|
|
33
|
-
method: 'GET',
|
|
34
|
-
headers: headers
|
|
35
|
-
}).then(function(r){
|
|
36
|
-
if (r.status !== 200) {
|
|
37
|
-
return lderror.reject(404);
|
|
38
|
-
} else {
|
|
39
|
-
return r.json();
|
|
40
|
-
}
|
|
41
|
-
}).then(function(rs){
|
|
57
|
+
return get(jsonurl, headers).then(function(rs){
|
|
42
58
|
return rs.map(function(it){
|
|
43
|
-
return (it.tag_name
|
|
59
|
+
return tagVersion(it.tag_name);
|
|
44
60
|
}).filter(function(it){
|
|
45
|
-
return
|
|
61
|
+
return it;
|
|
46
62
|
});
|
|
47
63
|
});
|
|
48
64
|
},
|
|
49
65
|
fetchRealVersion: function(arg$){
|
|
50
|
-
var root, path, name, cachetime, version, versionType, force, headers, token,
|
|
66
|
+
var root, path, name, cachetime, version, versionType, force, headers, token, base, p;
|
|
51
67
|
root = arg$.root, path = arg$.path, name = arg$.name, cachetime = arg$.cachetime, version = arg$.version, versionType = arg$.versionType, force = arg$.force;
|
|
52
68
|
headers = (token = getToken({
|
|
53
69
|
name: name,
|
|
@@ -57,22 +73,22 @@
|
|
|
57
73
|
"Authorization": "token " + token
|
|
58
74
|
}
|
|
59
75
|
: {};
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
76
|
+
base = "https://api.github.com/repos/" + name.replace('@', '');
|
|
77
|
+
p = versionType === 'latest'
|
|
78
|
+
? get(base + "/releases/latest", headers)
|
|
79
|
+
: get(base + "/releases/tags/v" + version, headers)['catch'](function(e){
|
|
80
|
+
if (lderror.id(e) !== 404) {
|
|
81
|
+
return Promise.reject(e);
|
|
82
|
+
}
|
|
83
|
+
return get(base + "/releases/tags/dist/v" + version, headers);
|
|
84
|
+
});
|
|
85
|
+
return p.then(function(r){
|
|
86
|
+
var v;
|
|
87
|
+
if (!(v = tagVersion(r.tag_name))) {
|
|
69
88
|
return lderror.reject(404);
|
|
70
|
-
} else {
|
|
71
|
-
return r.json();
|
|
72
89
|
}
|
|
73
|
-
}).then(function(r){
|
|
74
90
|
return {
|
|
75
|
-
version:
|
|
91
|
+
version: v,
|
|
76
92
|
url: r.tarball_url
|
|
77
93
|
};
|
|
78
94
|
});
|
|
@@ -101,6 +117,7 @@
|
|
|
101
117
|
});
|
|
102
118
|
}
|
|
103
119
|
});
|
|
120
|
+
pvd.tagVersion = tagVersion;
|
|
104
121
|
module.exports = pvd;
|
|
105
122
|
/*
|
|
106
123
|
params =
|
package/route.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Generated by LiveScript 1.6.0
|
|
2
2
|
(function(){
|
|
3
|
-
var pthk, lderror, fs, versionType, handle, route;
|
|
3
|
+
var pthk, lderror, fs, versionType, handle, checked, checkRoot, route;
|
|
4
4
|
pthk = require('pthk');
|
|
5
5
|
lderror = require('lderror');
|
|
6
6
|
fs = require("fs-extra");
|
|
@@ -76,12 +76,42 @@
|
|
|
76
76
|
return lderror.reject(404);
|
|
77
77
|
});
|
|
78
78
|
};
|
|
79
|
+
checked = {};
|
|
80
|
+
checkRoot = function(dir){
|
|
81
|
+
var e, user;
|
|
82
|
+
if (!dir) {
|
|
83
|
+
return false;
|
|
84
|
+
}
|
|
85
|
+
if (checked[dir] != null) {
|
|
86
|
+
return checked[dir];
|
|
87
|
+
}
|
|
88
|
+
return checked[dir] = (function(){
|
|
89
|
+
try {
|
|
90
|
+
fs.ensureDirSync(dir);
|
|
91
|
+
fs.accessSync(dir, fs.constants.W_OK);
|
|
92
|
+
return true;
|
|
93
|
+
} catch (e$) {
|
|
94
|
+
e = e$;
|
|
95
|
+
user = (function(){
|
|
96
|
+
try {
|
|
97
|
+
return require('os').userInfo().username;
|
|
98
|
+
} catch (e$) {
|
|
99
|
+
e = e$;
|
|
100
|
+
return '<server-user>';
|
|
101
|
+
}
|
|
102
|
+
}());
|
|
103
|
+
console.warn("[@plotdb/registry] fs root `" + dir + "` is not writable ( " + (e.code || e.message) + " ).\nfetching packages will fail with 500 until it is fixed, e.g.:\n sudo mkdir -p " + dir + " && sudo chown " + user + " " + dir);
|
|
104
|
+
return false;
|
|
105
|
+
}
|
|
106
|
+
}());
|
|
107
|
+
};
|
|
79
108
|
route = function(arg$){
|
|
80
109
|
var provider, root, opt;
|
|
81
110
|
provider = arg$.provider, root = arg$.root, opt = arg$.opt;
|
|
82
111
|
if (!root.pub.endsWith('/')) {
|
|
83
112
|
root.pub = root.pub + "/";
|
|
84
113
|
}
|
|
114
|
+
checkRoot(root.fs);
|
|
85
115
|
return function(req, res){
|
|
86
116
|
var url, id, _o;
|
|
87
117
|
url = req.originalUrl;
|
|
@@ -113,6 +143,7 @@
|
|
|
113
143
|
});
|
|
114
144
|
};
|
|
115
145
|
};
|
|
146
|
+
route.checkRoot = checkRoot;
|
|
116
147
|
module.exports = route;
|
|
117
148
|
function import$(obj, src){
|
|
118
149
|
var own = {}.hasOwnProperty;
|