@plotdb/registry 0.0.11 → 0.0.12

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 CHANGED
@@ -1,5 +1,15 @@
1
1
  # Change Logs
2
2
 
3
+ ## v0.0.12
4
+
5
+ - tweaks:
6
+ - check `root.fs` once when `registry.route` / `registry.designate` is created ( i.e., on
7
+ server start ): create it if missing and verify it is writable. on failure, warn with a
8
+ fix command instead of failing on the first fetch with an opaque 500
9
+ ( e.g. `EACCES: permission denied, mkdir '/var/lib/cdn'` when `/var/lib/cdn` is not
10
+ prepared ). only warns, so a broken registry root does not keep the server from starting.
11
+
12
+
3
13
  ## v0.0.11
4
14
 
5
15
  - 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.11","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"]}}
1
+ {"author":"zbryikt","name":"@plotdb/registry","license":"MIT","description":"registry","version":"0.0.12","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/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;