@plotdb/registry 0.0.1 → 0.0.2
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/dist/route.js +12 -8
- package/package.json +4 -1
- package/bin/ngxgen.js +0 -34
- package/build +0 -19
- package/doc/design.md +0 -68
- package/doc/draft.md +0 -98
- package/sample/config.ngx +0 -54
- package/sample/config.yaml +0 -7
- package/src/config.ngx +0 -43
- package/src/index.ls +0 -2
- package/src/ngxgen.ls +0 -27
- package/src/provider.ls +0 -112
- package/src/providers/github.ls +0 -38
- package/src/providers/index.ls +0 -3
- package/src/providers/npm.ls +0 -34
- package/src/route.ls +0 -46
- package/src/unbox.ls +0 -31
- package/web/.view/index.js +0 -171
- package/web/server.ls +0 -38
- package/web/src/pug/index.ls +0 -22
- package/web/src/pug/index.pug +0 -15
- package/web/static/favicon.ico +0 -0
- package/web/static/index.html +0 -1
package/dist/route.js
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
lderror = require('lderror');
|
|
5
5
|
fs = require("fs-extra");
|
|
6
6
|
handle = function(arg$){
|
|
7
|
-
var provider, id, root, ref$, paths, obj;
|
|
8
|
-
provider = arg$.provider, id = arg$.id, root = arg$.root;
|
|
7
|
+
var provider, id, root, opt, ref$, paths, obj;
|
|
8
|
+
provider = arg$.provider, id = arg$.id, root = arg$.root, opt = arg$.opt;
|
|
9
9
|
ref$ = [{}, {}, pthk.rectify(id)], paths = ref$[0], obj = ref$[1], id = ref$[2];
|
|
10
10
|
return Promise.resolve().then(function(){
|
|
11
11
|
var ids;
|
|
@@ -27,13 +27,13 @@
|
|
|
27
27
|
if (!(obj.name && obj.version && obj.path)) {
|
|
28
28
|
return lderror.reject(404);
|
|
29
29
|
}
|
|
30
|
-
return provider.fetch({
|
|
30
|
+
return provider.fetch(import$({
|
|
31
31
|
root: root.fs,
|
|
32
32
|
name: obj.name,
|
|
33
33
|
version: obj.version,
|
|
34
34
|
force: false,
|
|
35
35
|
cachetime: 60 * 60
|
|
36
|
-
});
|
|
36
|
+
}, opt));
|
|
37
37
|
})['catch'](function(e){
|
|
38
38
|
if (lderror.id(e) === 998) {
|
|
39
39
|
return;
|
|
@@ -45,19 +45,23 @@
|
|
|
45
45
|
});
|
|
46
46
|
};
|
|
47
47
|
route = function(arg$){
|
|
48
|
-
var provider, root;
|
|
49
|
-
provider = arg$.provider, root = arg$.root;
|
|
48
|
+
var provider, root, opt;
|
|
49
|
+
provider = arg$.provider, root = arg$.root, opt = arg$.opt;
|
|
50
50
|
if (!root.pub.endsWith('/')) {
|
|
51
51
|
root.pub = root.pub + "/";
|
|
52
52
|
}
|
|
53
53
|
return function(req, res){
|
|
54
|
-
var url, id;
|
|
54
|
+
var url, id, _o;
|
|
55
55
|
url = req.originalUrl;
|
|
56
56
|
id = url.replace(root.pub, '').replace(/[#?].*$/, '');
|
|
57
|
+
_o = !opt
|
|
58
|
+
? {}
|
|
59
|
+
: typeof opt === 'function' ? opt(req, res) : opt;
|
|
57
60
|
return handle({
|
|
58
61
|
provider: provider,
|
|
59
62
|
id: id,
|
|
60
|
-
root: root
|
|
63
|
+
root: root,
|
|
64
|
+
opt: _o
|
|
61
65
|
}).then(function(){
|
|
62
66
|
res.set({
|
|
63
67
|
"X-Accel-Redirect": pthk.join(root.internal, id)
|
package/package.json
CHANGED
|
@@ -3,8 +3,11 @@
|
|
|
3
3
|
"name": "@plotdb/registry",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "registry",
|
|
6
|
-
"version": "0.0.
|
|
6
|
+
"version": "0.0.2",
|
|
7
7
|
"main": "./dist/index.js",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist/**/*"
|
|
10
|
+
],
|
|
8
11
|
"homepage": "https://github.com/plotdb/registry",
|
|
9
12
|
"repository": {
|
|
10
13
|
"type": "git",
|
package/bin/ngxgen.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
(function(){
|
|
3
|
-
var fs, path, templateText, jsYaml, yargs, lib, cfgfile, argv, temp, code, cfg, e;
|
|
4
|
-
fs = require('fs');
|
|
5
|
-
path = require('path');
|
|
6
|
-
templateText = require('template-text');
|
|
7
|
-
jsYaml = require('js-yaml');
|
|
8
|
-
yargs = require('yargs');
|
|
9
|
-
lib = fs.realpathSync(path.dirname(__filename));
|
|
10
|
-
cfgfile = 'config.json';
|
|
11
|
-
argv = yargs.option('config', {
|
|
12
|
-
alias: 'c',
|
|
13
|
-
description: "config json",
|
|
14
|
-
type: 'string'
|
|
15
|
-
}).help('help').alias('help', 'h').check(function(argv, options){
|
|
16
|
-
if (!argv.c) {
|
|
17
|
-
throw new Error("config file required");
|
|
18
|
-
}
|
|
19
|
-
cfgfile = path.join(argv.c);
|
|
20
|
-
if (!fs.existsSync(cfgfile)) {
|
|
21
|
-
throw new Error("config file not found: " + cfgfile);
|
|
22
|
-
}
|
|
23
|
-
return true;
|
|
24
|
-
}).argv;
|
|
25
|
-
temp = fs.readFileSync(path.join(lib, '..', 'dist', 'config.ngx')).toString();
|
|
26
|
-
code = fs.readFileSync(cfgfile).toString();
|
|
27
|
-
try {
|
|
28
|
-
cfg = JSON.parse(code);
|
|
29
|
-
} catch (e$) {
|
|
30
|
-
e = e$;
|
|
31
|
-
cfg = jsYaml.load(code);
|
|
32
|
-
}
|
|
33
|
-
console.log(templateText(temp, cfg, lib));
|
|
34
|
-
}).call(this);
|
package/build
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
|
|
3
|
-
rm -rf dist
|
|
4
|
-
mkdir -p dist
|
|
5
|
-
rm -rf bin
|
|
6
|
-
mkdir -p bin
|
|
7
|
-
|
|
8
|
-
echo "transpile livescript in src to dist ..."
|
|
9
|
-
./node_modules/.bin/lsc -co dist --no-header src
|
|
10
|
-
echo "build src/ngxgen.ls -> bin/ngxgen.js ..."
|
|
11
|
-
echo "#!/usr/bin/env node" > bin/ngxgen.js
|
|
12
|
-
./node_modules/.bin/lsc -cp --no-header src/ngxgen.ls >> bin/ngxgen.js
|
|
13
|
-
chmod 755 bin/ngxgen.js
|
|
14
|
-
|
|
15
|
-
echo "copy src/config.ngx to dist ..."
|
|
16
|
-
cp src/config.ngx dist
|
|
17
|
-
echo "done."
|
|
18
|
-
|
|
19
|
-
|
package/doc/design.md
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
## Module Naming
|
|
2
|
-
|
|
3
|
-
similar to `npm`, with a repo name and optional scope:
|
|
4
|
-
|
|
5
|
-
`@scope/repo`
|
|
6
|
-
|
|
7
|
-
for example:
|
|
8
|
-
|
|
9
|
-
`wrap-svg-text`
|
|
10
|
-
`@plotdb/form`
|
|
11
|
-
|
|
12
|
-
where names contain only [a-z-.] characters, and is case insensitive ( or, all lowercase characters ).
|
|
13
|
-
|
|
14
|
-
Naming should
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
## Module Grouping
|
|
18
|
-
|
|
19
|
-
Use `.` in module name for semantic grouping:
|
|
20
|
-
|
|
21
|
-
- base library: `@plotdb/form`
|
|
22
|
-
- widgets
|
|
23
|
-
- `@plotdb/form.short-answer`
|
|
24
|
-
- `@plotdb/form.long-answer`
|
|
25
|
-
|
|
26
|
-
These modules ( `@plotdb/form`, `@plotdb/form.short-answer`, `@plotdb/form.long-answer` ) are independent modules and have their own repo and version. Grouping is just a semantic suggestion and there won't any checks against it.
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
## Module Reference
|
|
30
|
-
|
|
31
|
-
Reference to module is possible with additional information or URL:
|
|
32
|
-
|
|
33
|
-
- `github:loadingio/ldcover`
|
|
34
|
-
- `https://plotdb.github.io/form/block/short-answer/0.0.1/index.html`
|
|
35
|
-
|
|
36
|
-
A formal definition of a reference to a module / a module's file can be done by following object:
|
|
37
|
-
|
|
38
|
-
{
|
|
39
|
-
ns: "namespace",
|
|
40
|
-
name: "module-name",
|
|
41
|
-
version: "0.0.1",
|
|
42
|
-
path: "path/some-file" /* optional path to file. default `index.html` if omitted. */
|
|
43
|
-
/* similar to web server rules, `path` may refer to `path/index.html`. */
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
## Registry service
|
|
48
|
-
|
|
49
|
-
`@plotdb/registry` is also a concept of on demend module provider. It can be implemented with 2 parts:
|
|
50
|
-
|
|
51
|
-
- web server which maps URL to file, or fallback to an api server which helps in prepraing the requested module.
|
|
52
|
-
- an api server that prepares request modules
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
For example, we can setup a nginx server to serve module files as follow:
|
|
56
|
-
|
|
57
|
-
- accept requests of module in `https://site/assets/lib/<name>/<version>/<path>`
|
|
58
|
-
- try files `/<rootdir>/static/assets/lib/<name>/<version>/<path>`
|
|
59
|
-
- if file is not found, pass this request to api server.
|
|
60
|
-
|
|
61
|
-
Then in the api server:
|
|
62
|
-
|
|
63
|
-
- fetch the requested files from public registries such as github, npm or other cdn
|
|
64
|
-
- write downloaded files in `/<rootdir>/static/assets/lib/<name>/<version>/<path>`
|
|
65
|
-
|
|
66
|
-
It's also possible that the api server uses symlinks for semver rules to speed up assets requests. In this case, registry should properly manage these symlink to reflect the most up-to-date status of modules - for example, provide a trigger which flushes these symlinks by request.
|
|
67
|
-
|
|
68
|
-
|
package/doc/draft.md
DELETED
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
## 模組管理
|
|
2
|
-
|
|
3
|
-
`@plotdb/block` 概念有了以後, 會需要管理
|
|
4
|
-
|
|
5
|
-
- 開發 - 不管怎麼開發.
|
|
6
|
-
- 但 plotdb 自己會透過 git + branch + tag 來在 repo 自行管理版本
|
|
7
|
-
- 也有可能會需要將多個 block 置於一 monorepo 中一次做 publish
|
|
8
|
-
- 發布 - 類似 NPM. 指定名稱、版號.
|
|
9
|
-
- 倉儲 - 背後管理機制?
|
|
10
|
-
- 本地端 - 自己跑一個 registrey server ?
|
|
11
|
-
- 可以依靠簡單 http server 機制 serve 檔案
|
|
12
|
-
- 依簡單 http server 的本地發布法
|
|
13
|
-
- 比方說發布到特定目錄
|
|
14
|
-
- 或發布到本地端的中央 registry server
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
## 命名規則
|
|
18
|
-
|
|
19
|
-
與 github, npm 對齊. 使用 type, scope + package 的概念:
|
|
20
|
-
|
|
21
|
-
- wrap-svg-text
|
|
22
|
-
- @plotdb/form
|
|
23
|
-
- github:loadingio/ldcover
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
考慮到前端元件可能有群組概念, 但我們又需要依賴現有機制管理, 因此我們在 package name 中利用 `.` 做語意上的分組:
|
|
27
|
-
|
|
28
|
-
- form.short-answer
|
|
29
|
-
- @plotdb/config.text
|
|
30
|
-
- github:loadingio/ldcover.error
|
|
31
|
-
|
|
32
|
-
不一定是功能上 ( 比方說都是圖表 ), 也可能是單純的集合 ( makeweb 的基本區塊集 ), 這種情況下更像是認知上的輔助:
|
|
33
|
-
|
|
34
|
-
- @makeweb/basic.hero
|
|
35
|
-
- @makeweb/basic.paragraph
|
|
36
|
-
- @makeweb/basic.gallery
|
|
37
|
-
- @makeweb/basic.footer
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
其它的選擇各有其問題.
|
|
41
|
-
|
|
42
|
-
- 使用子套件 ( @plotdb/form/short-answer )
|
|
43
|
-
- npm 跟 github 都不支援
|
|
44
|
-
- 若當成 @plotdb/form 下的 short-answer 檔案, 則版本就變成透過 @plotdb/form 管理, 會變得相依性很強, 造成問題.
|
|
45
|
-
- 使用 `@` ( @plotdb/form@short-ansmwer ) 或其它少見字元
|
|
46
|
-
- github 不支援. npm 不明, 但沒見過.
|
|
47
|
-
- 使用 `-` 或 `_` - 名稱太普遍.
|
|
48
|
-
- 使用 org 切分, 如 @plotdb-form/short-answer
|
|
49
|
-
- 語意較差因為實際上並沒有多出一個 @plotdb-form org.
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
## 內部模組
|
|
53
|
-
|
|
54
|
-
使用模組的套件, 不一定會全都依賴外部模組, 或者需要將所有模組都獨立管理. 套件本身也可能包含數個模組, 隨著套件本身進版.
|
|
55
|
-
這種情況下, 就可以透過子元件的方式存取模組, 如:
|
|
56
|
-
|
|
57
|
-
@plotdb/form@0.0.1/short-answer/
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
存取這類的模組可以有幾種做法:
|
|
61
|
-
|
|
62
|
-
- 完全繞過 registry, 自行管理 block.class
|
|
63
|
-
- 但若需要提供抽換機制, 我們還是得統一 "自行管理" 的方式 - 結果最好還是把機制做在 registry 中.
|
|
64
|
-
- 透過 registry, 但提供路徑概念.
|
|
65
|
-
- 如: `registry: ({name, version, path}) -> "/block/#name/#version/#path/index.html"`
|
|
66
|
-
- 接著就看套件如何將需求對應到 name, version, path 組
|
|
67
|
-
|
|
68
|
-
透過 registry 的情況下, 如使用 @plotdb/config 時我們會有 text field. 可以想像存取路徑為:
|
|
69
|
-
|
|
70
|
-
@plotdb/config@0.0.1/text/index.html
|
|
71
|
-
|
|
72
|
-
用戶則可能可以客製 text field, 並以下列套件名提供
|
|
73
|
-
|
|
74
|
-
@someone/config.text@.0.1
|
|
75
|
-
@someone/config.set@0.0.1/text/index.html
|
|
76
|
-
|
|
77
|
-
在 @plotdb/config 使用 text 時, 可以直接明確指定模組, 亦或者做轉換. 轉換則由用戶提供方式:
|
|
78
|
-
|
|
79
|
-
text -> @someone/config.set@0.0.1/text/index.html
|
|
80
|
-
|
|
81
|
-
也就是說, 套件提供一組預設轉換函式將 {name, version, type} 轉成 registry 要用的 {name, version, path}, 但這個預設函式可以被用戶客製. 如:
|
|
82
|
-
|
|
83
|
-
name: @plotdb/config -> name: @plotdb/config
|
|
84
|
-
version: 0.0.1 -> version: 0.0.1
|
|
85
|
-
type: text -> path: text/index.html
|
|
86
|
-
|
|
87
|
-
客製後:
|
|
88
|
-
|
|
89
|
-
name: @plotdb/config -> name: @someone/config.text
|
|
90
|
-
version: 0.0.1 -> version: 0.0.1
|
|
91
|
-
type: text -> path: index.html
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
指涉特定 block 的方式則為:
|
|
95
|
-
|
|
96
|
-
{name, version, path}
|
|
97
|
-
|
|
98
|
-
忽略 path 時, 預設為 `index.html`. ( 或者, 依網頁伺服器定義? )
|
package/sample/config.ngx
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
upstream apiserver {
|
|
2
|
-
server 127.0.0.1:9900;
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
proxy_cache_path /tmp/cache keys_zone=cache:10m levels=1:2 inactive=600s max_size=100m;
|
|
6
|
-
|
|
7
|
-
server {
|
|
8
|
-
listen 80;
|
|
9
|
-
server_name registry.loco;
|
|
10
|
-
|
|
11
|
-
# this should be put outside server block, where `<cache>` should be the same with `cache.name` config.
|
|
12
|
-
# proxy_cache_path /tmp/cache keys_zone=<cache>:10m levels=1:2 inactive=600s max_size=100m;
|
|
13
|
-
|
|
14
|
-
# requests to path under `internal` are from `X-Accel-Redirect` from registry backend
|
|
15
|
-
# and thus should not hit backend again.
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
location ~ ^/ilib/(.*)$ {
|
|
19
|
-
internal;
|
|
20
|
-
root /var/lib/cdn/cache/;
|
|
21
|
-
try_files /lib/$1 /lib/$1/index.html /$1/index.min.js =404;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
location ~ ^/lib/(.*)$ {
|
|
25
|
-
root /var/lib/cdn/cache/;
|
|
26
|
-
# proxy_cache is file-based. here we use `.reg.404` for pkg-based 404 detection
|
|
27
|
-
# however, we don't know how to invalidate this. So this is not used for now.
|
|
28
|
-
# to use this, we have to use location pattern such as:
|
|
29
|
-
#
|
|
30
|
-
# location ~ ^/lib/(?<scope>.+)/(?<name>.+)/(?<version>.+)/(?<path>.*)$ { ... }
|
|
31
|
-
# location ~ ^/lib/(?<name>.+)/(?<version>.+)/(?<path>.*)$ { ... }
|
|
32
|
-
#
|
|
33
|
-
# if (-f /var/lib/cdn/cache/lib/$name/$version/.reg.404) {
|
|
34
|
-
# return 404 "";
|
|
35
|
-
# break;
|
|
36
|
-
# }
|
|
37
|
-
try_files /lib/$1 /lib/$1/index.html /lib/$1/index.min.js @registry_backend;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
# a dedicated location for registry_backend so we can use a dedicated server for registry
|
|
41
|
-
# to offload requests from main backend. This is controlled by `upstream` config.
|
|
42
|
-
location @registry_backend {
|
|
43
|
-
proxy_set_header X-Real-IP $remote_addr;
|
|
44
|
-
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
45
|
-
proxy_set_header Host $http_host;
|
|
46
|
-
proxy_set_header X-NginX-Proxy true;
|
|
47
|
-
proxy_set_header X-Forwarded-Proto $scheme;
|
|
48
|
-
# cache 200 / 404 result for `cache-period` so user can't bombard our backend
|
|
49
|
-
proxy_cache cache;
|
|
50
|
-
proxy_cache_valid 200 404 10m;
|
|
51
|
-
proxy_pass http://apiserver;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
}
|
package/sample/config.yaml
DELETED
package/src/config.ngx
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
# this should be put outside server block, where `<cache>` should be the same with `cache.name` config.
|
|
3
|
-
# proxy_cache_path /tmp/cache keys_zone=<cache>:10m levels=1:2 inactive=600s max_size=100m;
|
|
4
|
-
|
|
5
|
-
# requests to path under `internal` are from `X-Accel-Redirect` from registry backend
|
|
6
|
-
# and thus should not hit backend again.
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
location ~ ^/!{internal}/(.*)$ {
|
|
10
|
-
internal;
|
|
11
|
-
root !{root};
|
|
12
|
-
try_files /!{pub}/$1 /!{pub}/$1/index.html /$1/index.min.js =404;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
location ~ ^/!{pub}/(.*)$ {
|
|
16
|
-
root !{root};
|
|
17
|
-
# proxy_cache is file-based. here we use `.reg.404` for pkg-based 404 detection
|
|
18
|
-
# however, we don't know how to invalidate this. So this is not used for now.
|
|
19
|
-
# to use this, we have to use location pattern such as:
|
|
20
|
-
#
|
|
21
|
-
# location ~ ^/lib/(?<scope>.+)/(?<name>.+)/(?<version>.+)/(?<path>.*)$ { ... }
|
|
22
|
-
# location ~ ^/lib/(?<name>.+)/(?<version>.+)/(?<path>.*)$ { ... }
|
|
23
|
-
#
|
|
24
|
-
# if (-f /var/lib/cdn/cache/lib/$name/$version/.reg.404) {
|
|
25
|
-
# return 404 "";
|
|
26
|
-
# break;
|
|
27
|
-
# }
|
|
28
|
-
try_files /!{pub}/$1 /!{pub}/$1/index.html /!{pub}/$1/index.min.js @registry_backend;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
# a dedicated location for registry_backend so we can use a dedicated server for registry
|
|
32
|
-
# to offload requests from main backend. This is controlled by `upstream` config.
|
|
33
|
-
location @registry_backend {
|
|
34
|
-
proxy_set_header X-Real-IP $remote_addr;
|
|
35
|
-
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
36
|
-
proxy_set_header Host $http_host;
|
|
37
|
-
proxy_set_header X-NginX-Proxy true;
|
|
38
|
-
proxy_set_header X-Forwarded-Proto $scheme;
|
|
39
|
-
# cache 200 / 404 result for `cache-period` so user can't bombard our backend
|
|
40
|
-
proxy_cache !{cache.name};
|
|
41
|
-
proxy_cache_valid 200 404 !{cache.period};
|
|
42
|
-
proxy_pass http://!{upstream};
|
|
43
|
-
}
|
package/src/index.ls
DELETED
package/src/ngxgen.ls
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
require! <[fs path template-text js-yaml yargs]>
|
|
2
|
-
|
|
3
|
-
lib = fs.realpathSync path.dirname __filename
|
|
4
|
-
cfgfile = 'config.json'
|
|
5
|
-
|
|
6
|
-
argv = yargs
|
|
7
|
-
.option \config, do
|
|
8
|
-
alias: \c
|
|
9
|
-
description: "config json"
|
|
10
|
-
type: \string
|
|
11
|
-
.help \help
|
|
12
|
-
.alias \help, \h
|
|
13
|
-
.check (argv, options) ->
|
|
14
|
-
if !argv.c => throw new Error("config file required")
|
|
15
|
-
cfgfile := path.join(argv.c)
|
|
16
|
-
if !fs.exists-sync(cfgfile) => throw new Error("config file not found: #cfgfile")
|
|
17
|
-
return true
|
|
18
|
-
.argv
|
|
19
|
-
|
|
20
|
-
temp = fs.read-file-sync path.join(lib, '..', \dist, \config.ngx) .toString!
|
|
21
|
-
code = fs.read-file-sync cfgfile .toString!
|
|
22
|
-
try
|
|
23
|
-
cfg = JSON.parse(code)
|
|
24
|
-
catch e
|
|
25
|
-
cfg = js-yaml.load code
|
|
26
|
-
|
|
27
|
-
console.log template-text(temp, cfg, lib)
|
package/src/provider.ls
DELETED
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
require! <[node-fetch lderror yauzl pthk tar]>
|
|
2
|
-
fs = require "fs-extra"
|
|
3
|
-
|
|
4
|
-
fetch = node-fetch
|
|
5
|
-
get-version-type = (v) ->
|
|
6
|
-
if v in <[latest main]> => \latest
|
|
7
|
-
else if /^\d+\.\d+\.\d+$/.test(v) => \specific
|
|
8
|
-
#else if /^[^~>]\d+\d.\d+\.\d+$/.test(v) => \range
|
|
9
|
-
else null
|
|
10
|
-
|
|
11
|
-
provider = (o = {}) ->
|
|
12
|
-
@_name = o.name or "unnamed#{provider._idx++}"
|
|
13
|
-
@_ps = [] ++ (o.chain or [])
|
|
14
|
-
@_fetch-real-version = o.fetch-real-version
|
|
15
|
-
@_fetch-bundle-file = o.fetch-bundle-file
|
|
16
|
-
@_check = o.check
|
|
17
|
-
@_opt = o.opt or {}
|
|
18
|
-
@
|
|
19
|
-
|
|
20
|
-
provider <<<
|
|
21
|
-
_hash: {}
|
|
22
|
-
_idx: 0
|
|
23
|
-
add: (p) -> @_hash[p._name] = p
|
|
24
|
-
get: (n) -> @_hash[n]
|
|
25
|
-
|
|
26
|
-
provider.prototype = Object.create(Object.prototype) <<<
|
|
27
|
-
opt: (o) -> @_opt = o or {}
|
|
28
|
-
fetch: (o = {}) ->
|
|
29
|
-
<~ Promise.resolve!then _
|
|
30
|
-
path = {base: {}}
|
|
31
|
-
{root, name, version, force, cachetime} = o
|
|
32
|
-
cachetime = cachetime or 60 * 60 # default 1hr
|
|
33
|
-
version-type = get-version-type(version)
|
|
34
|
-
if !version-type => return lderror.reject 400
|
|
35
|
-
params = {path, version-type, root, name, version, force, cachetime}
|
|
36
|
-
if !/^(?:@[0-9a-z._-]+\/)?[0-9a-z._-]+$/.test(name) => return lderror.reject 400
|
|
37
|
-
path.base.pkg = pthk.join(root, pthk.rectify name)
|
|
38
|
-
path.base.version = pthk.join(path.base.pkg, version)
|
|
39
|
-
path.version = pthk.join(path.base.version, '.reg.version')
|
|
40
|
-
path.404 = pthk.join(path.base.version, '.reg.404')
|
|
41
|
-
_ = (idx = -1) ~>
|
|
42
|
-
if idx >= 0 =>
|
|
43
|
-
if !(pr = @_ps[idx]) => return lderror.reject 404
|
|
44
|
-
p = pr.check({name, version}).then ~> pr._fetch params
|
|
45
|
-
else
|
|
46
|
-
p = @check({name, version})
|
|
47
|
-
.then ~>
|
|
48
|
-
if !@_fetch-real-version => lderror.reject 404
|
|
49
|
-
else @_fetch params
|
|
50
|
-
p.catch (e) -> return if (id = lderror.id e) != 404 => Promise.reject e else _(idx + 1)
|
|
51
|
-
_!catch (e) ->
|
|
52
|
-
if !((id = lderror.id(e)) in [403 404]) => return Promise.reject e
|
|
53
|
-
fs.ensure-dir path.base.version
|
|
54
|
-
.then -> fs.write-file path.404, ''
|
|
55
|
-
.then -> return lderror.reject 404
|
|
56
|
-
|
|
57
|
-
check: ({name, version}) -> if @_check => @_check {name, version} else Promise.resolve!
|
|
58
|
-
chain: (ps) -> @_ps.splice.apply @_ps, ([0, 0] ++ (if Array.isArray(ps) => ps else [ps]))
|
|
59
|
-
|
|
60
|
-
_fetch: (params) ->
|
|
61
|
-
{root, name, version, cachetime, force, path, version-type} = params
|
|
62
|
-
Promise.resolve!
|
|
63
|
-
.then ->
|
|
64
|
-
# 1. in this block, we test if a pkg is dirty/expired and should be fetched again.
|
|
65
|
-
if force => return
|
|
66
|
-
fs.exists path.version
|
|
67
|
-
.then (is-existed) ->
|
|
68
|
-
# return true if dirty
|
|
69
|
-
if !is-existed =>
|
|
70
|
-
return fs.exists path.404 .then (is404) ->
|
|
71
|
-
# not existed and 404 not found - never fetched and thus dirty
|
|
72
|
-
if !is404 => return true
|
|
73
|
-
(s) <- fs.stat path.404 .then _
|
|
74
|
-
# not existed, 404 - dirty if cache expires
|
|
75
|
-
dirty = Date.now! > s.mtime.getTime! + cachetime * 1000
|
|
76
|
-
return if !dirty => false else fs.remove path.404 .then -> true
|
|
77
|
-
# specific version existed. never dirty
|
|
78
|
-
if version-type == \specific => return false
|
|
79
|
-
# latest - dirty if cache expires.
|
|
80
|
-
if version-type == \latest =>
|
|
81
|
-
return fs.stat path.version .then (s) ->
|
|
82
|
-
Date.now! > s.mtime.getTime! + cachetime * 1000
|
|
83
|
-
# TODO range version
|
|
84
|
-
return false
|
|
85
|
-
.then (is-dirty) -> if !is-dirty => return lderror.reject 998
|
|
86
|
-
.then ~>
|
|
87
|
-
# 2. in this block, we peek real version for latest / range(TODO) version
|
|
88
|
-
(remote-info) <~ @_fetch-real-version params .then _
|
|
89
|
-
Promise.resolve!
|
|
90
|
-
.then ->
|
|
91
|
-
if force or version-type == \specific => return remote-info
|
|
92
|
-
# compare remote version with local version
|
|
93
|
-
fs.exists path.version .then (is-existed) ->
|
|
94
|
-
# no local version -> must fetch
|
|
95
|
-
if !is-existed => return
|
|
96
|
-
(r) <- fs.read-file path.version .then _
|
|
97
|
-
# local is older -> must fetch
|
|
98
|
-
if remote-info.version > JSON.parse(r).version => return
|
|
99
|
-
# no new version. skip fetch. touch version file for reset cache counter
|
|
100
|
-
now = new Date!
|
|
101
|
-
fs.utimes path.version, now, now
|
|
102
|
-
lderror.reject 998
|
|
103
|
-
.then ->
|
|
104
|
-
fs.remove path.base.version
|
|
105
|
-
#fs.remove path.404
|
|
106
|
-
.then -> fs.ensure-dir path.base.version
|
|
107
|
-
.then -> fs.write-file path.version, JSON.stringify(remote-info)
|
|
108
|
-
.then -> remote-info
|
|
109
|
-
.then (remote-info) ~> @_fetch-bundle-file({remote-info} <<< params)
|
|
110
|
-
|
|
111
|
-
if module? => module.exports = provider
|
|
112
|
-
else if window? => window.registry = provider
|
package/src/providers/github.ls
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
require! <[node-fetch lderror ../provider ../unbox]>
|
|
2
|
-
|
|
3
|
-
get-token = ({name, opt}) ->
|
|
4
|
-
ret = /^@([^/]+)\/(.+)$/.exec(name)
|
|
5
|
-
scope = if ret => ret.1 else null
|
|
6
|
-
token = if !opt => null else opt.{}scope[scope] or opt.{}repo[name] or opt.token or null
|
|
7
|
-
|
|
8
|
-
pvd = new provider do
|
|
9
|
-
name: \github
|
|
10
|
-
fetch-real-version: ({root, path, name, cachetime, version, version-type, force}) ->
|
|
11
|
-
headers = if (token = get-token({name, opt: @_opt})) => {"Authorization": "token #{token}"} else {}
|
|
12
|
-
release = if version-type == \latest => "releases/latest" else "releases/tags/v#version"
|
|
13
|
-
jsonurl = "https://api.github.com/repos/#{name.replace('@','')}/#release"
|
|
14
|
-
node-fetch jsonurl, {method: \GET, headers}
|
|
15
|
-
.then (r) -> if r.status != 200 => lderror.reject 404 else r.json!
|
|
16
|
-
.then (r) -> {version: (r.tag_name or '').replace(/^v/,''), url: r.tarball_url}
|
|
17
|
-
|
|
18
|
-
fetch-bundle-file: ({root, path, name, cachetime, version, remote-info, version-type, force}) ->
|
|
19
|
-
headers = if (token = get-token({name, opt: @_opt})) => {"Authorization": "token #{token}"} else {}
|
|
20
|
-
node-fetch remote-info.url, {method: \GET, headers}
|
|
21
|
-
.then (r) -> r.buffer!
|
|
22
|
-
.then (buf) -> unbox.untar {path, buf}
|
|
23
|
-
|
|
24
|
-
module.exports = pvd
|
|
25
|
-
/*
|
|
26
|
-
params =
|
|
27
|
-
root: 'lib'
|
|
28
|
-
name: 'some-repo'
|
|
29
|
-
version: 'latest'
|
|
30
|
-
cachetime: 1
|
|
31
|
-
opt: {token: "some-token"}
|
|
32
|
-
|
|
33
|
-
pvd.fetch-module params
|
|
34
|
-
.catch (e) ->
|
|
35
|
-
if !(lderror.id(e) in [404 998]) => return Promise.reject e
|
|
36
|
-
else console.log "return code: ", lderror.id(e)
|
|
37
|
-
.then -> console.log \done.
|
|
38
|
-
*/
|
package/src/providers/index.ls
DELETED
package/src/providers/npm.ls
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
require! <[node-fetch lderror ../provider ../unbox]>
|
|
2
|
-
|
|
3
|
-
pvd = new provider do
|
|
4
|
-
name: \github
|
|
5
|
-
fetch-real-version: ({root, path, name, cachetime, version, version-type, force, opt}) ->
|
|
6
|
-
jsonurl = "https://registry.npmjs.org/#name"
|
|
7
|
-
node-fetch jsonurl, {method: \GET}
|
|
8
|
-
.then (r) -> if r.status != 200 => lderror.reject 404 else r.json!
|
|
9
|
-
.then (r) ->
|
|
10
|
-
# TODO range version
|
|
11
|
-
v = if version-type == \latest => r["dist-tags"].latest else version
|
|
12
|
-
if !(url = r.versions{}[v].{}dist.tarball) => return lderror.reject 404
|
|
13
|
-
{version: v, url}
|
|
14
|
-
|
|
15
|
-
fetch-bundle-file: ({root, path, name, cachetime, version, remote-info, version-type, force, opt}) ->
|
|
16
|
-
headers = if (opt or {}).token => {"Authorization": "token #{opt.token}"} else {}
|
|
17
|
-
node-fetch remote-info.url, {method: \GET, headers}
|
|
18
|
-
.then (r) -> r.buffer!
|
|
19
|
-
.then (buf) -> unbox.untar {path, buf}
|
|
20
|
-
|
|
21
|
-
module.exports = pvd
|
|
22
|
-
/*
|
|
23
|
-
params =
|
|
24
|
-
root: 'npmlib'
|
|
25
|
-
name: 'ldcover'
|
|
26
|
-
version: 'latest'
|
|
27
|
-
cachetime: 60 * 60
|
|
28
|
-
|
|
29
|
-
pvd.fetch-module params
|
|
30
|
-
.catch (e) ->
|
|
31
|
-
if !(lderror.id(e) in [404 998]) => return Promise.reject e
|
|
32
|
-
else console.log "return code: ", lderror.id(e)
|
|
33
|
-
.then -> console.log \done.
|
|
34
|
-
*/
|
package/src/route.ls
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
require! <[pthk lderror]>
|
|
2
|
-
fs = require "fs-extra"
|
|
3
|
-
|
|
4
|
-
handle = ({provider, id, root}) ->
|
|
5
|
-
[paths, obj, id] = [{}, {}, pthk.rectify(id)]
|
|
6
|
-
Promise.resolve!
|
|
7
|
-
.then ->
|
|
8
|
-
if !/^[-_a-zA-Z0-9@./]+$/.exec(id) => return lderror.reject 404
|
|
9
|
-
ids = id.split(\/)
|
|
10
|
-
obj <<< if ids.length > 3 =>
|
|
11
|
-
name: "#{ids.0}/#{ids.1}"
|
|
12
|
-
version: ids.2
|
|
13
|
-
path: ids.slice(3).join(\/)
|
|
14
|
-
else
|
|
15
|
-
name: ids.0
|
|
16
|
-
version: ids.1
|
|
17
|
-
path: ids.slice(2).join(\/)
|
|
18
|
-
if !(obj.name and obj.version and obj.path) => return lderror.reject 404
|
|
19
|
-
provider.fetch {
|
|
20
|
-
root: root.fs
|
|
21
|
-
name: obj.name
|
|
22
|
-
version: obj.version
|
|
23
|
-
force: false
|
|
24
|
-
cachetime: 60 * 60
|
|
25
|
-
}
|
|
26
|
-
.catch (e) ->
|
|
27
|
-
if lderror.id(e) == 998 => return # skip fetching. as if fetch successfully.
|
|
28
|
-
if lderror.id(e) != 404 => return Promise.reject e
|
|
29
|
-
lderror.reject 404
|
|
30
|
-
|
|
31
|
-
route = ({provider, root}) ->
|
|
32
|
-
if !root.pub.endsWith \/ => root.pub = "#{root.pub}/"
|
|
33
|
-
(req, res) ->
|
|
34
|
-
url = req.originalUrl
|
|
35
|
-
id = url.replace(root.pub, '').replace(/[#?].*$/,'')
|
|
36
|
-
handle {provider, id, root}
|
|
37
|
-
.then ->
|
|
38
|
-
res.set { "X-Accel-Redirect": pthk.join(root.internal, id) }
|
|
39
|
-
res.send!
|
|
40
|
-
.catch (e) ->
|
|
41
|
-
if lderror.id(e) != 404 =>
|
|
42
|
-
console.log e
|
|
43
|
-
res.status 500 .send!
|
|
44
|
-
res.status 404 .send!
|
|
45
|
-
|
|
46
|
-
module.exports = route
|
package/src/unbox.ls
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
require! <[yauzl tar pthk stream]>
|
|
2
|
-
fs = require "fs-extra"
|
|
3
|
-
|
|
4
|
-
unzip = ({path, buf}) ->
|
|
5
|
-
(res, rej) <- new Promise _
|
|
6
|
-
(e, zipfile) <- yauzl.from-buffer buf, {autoClose: false, lazyEntries: true}, _
|
|
7
|
-
if e => return rej e
|
|
8
|
-
zipfile.read-entry!
|
|
9
|
-
zipfile.on \end, -> zipfile.close!; res!
|
|
10
|
-
zipfile.on \entry, (entry) ->
|
|
11
|
-
if /\/$/.test(entry.file-name) => return zipfile.read-entry!
|
|
12
|
-
(e, rs) <- zipfile.openReadStream entry, _
|
|
13
|
-
if e => return rej e
|
|
14
|
-
rs.on \end, -> zipfile.read-entry!
|
|
15
|
-
dirs = entry.file-name.split(\/)
|
|
16
|
-
# TODO this depends on how remote zip their packages.
|
|
17
|
-
if !(fn = dirs.slice 1 .join \/) => fn = entry.file-name
|
|
18
|
-
desfile = pthk.join(path.base.version, pthk.rectify(fn))
|
|
19
|
-
desdir = pthk.dirname desfile
|
|
20
|
-
fs.ensure-dir desdir
|
|
21
|
-
.then -> rs.pipe fs.createWriteStream(desfile)
|
|
22
|
-
|
|
23
|
-
untar = ({path, buf}) ->
|
|
24
|
-
stream.Readable.from buf
|
|
25
|
-
.pipe ws = tar.x strip: 1, cwd: path.base.version
|
|
26
|
-
(res, rej) <- new Promise _
|
|
27
|
-
ws.on \close, -> res!
|
|
28
|
-
ws.on \error, -> rej it
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
module.exports = {unzip, untar}
|
package/web/.view/index.js
DELETED
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
(function() { function pug_attr(t,e,n,r){if(!1===e||null==e||!e&&("class"===t||"style"===t))return"";if(!0===e)return" "+(r?t:t+'="'+t+'"');var f=typeof e;return"object"!==f&&"function"!==f||"function"!=typeof e.toJSON||(e=e.toJSON()),"string"==typeof e||(e=JSON.stringify(e),n||-1===e.indexOf('"'))?(n&&(e=pug_escape(e))," "+t+'="'+e+'"'):" "+t+"='"+e.replace(/'/g,"'")+"'"}
|
|
2
|
-
function pug_escape(e){var a=""+e,t=pug_match_html.exec(a);if(!t)return e;var r,c,n,s="";for(r=t.index,c=0;r<a.length;r++){switch(a.charCodeAt(r)){case 34:n=""";break;case 38:n="&";break;case 60:n="<";break;case 62:n=">";break;default:continue}c!==r&&(s+=a.substring(c,r)),c=r+1,s+=n}return c!==r?s+a.substring(c,r):s}
|
|
3
|
-
var pug_match_html=/["&<>]/;
|
|
4
|
-
function pug_rethrow(e,n,r,t){if(!(e instanceof Error))throw e;if(!("undefined"==typeof window&&n||t))throw e.message+=" on line "+r,e;var o,a,i,s;try{t=t||require("fs").readFileSync(n,{encoding:"utf8"}),o=3,a=t.split("\n"),i=Math.max(r-o,0),s=Math.min(a.length,r+o)}catch(t){return e.message+=" - could not read from "+n+" ("+t.message+")",void pug_rethrow(e,null,r)}o=a.slice(i,s).map(function(e,n){var t=n+i+1;return(t==r?" > ":" ")+t+"| "+e}).join("\n"),e.path=n;try{e.message=(n||"Pug")+":"+r+"\n"+o+"\n\n"+e.message}catch(e){}throw e}function template(locals) {var pug_html = "", pug_mixins = {}, pug_interp;var pug_debug_filename, pug_debug_line;try {;
|
|
5
|
-
var locals_for_with = (locals || {});
|
|
6
|
-
|
|
7
|
-
(function (Array, c, defer, libLoader, url, version) {
|
|
8
|
-
;pug_debug_line = 1;pug_debug_filename = "src\u002Fpug\u002Findex.pug";
|
|
9
|
-
pug_html = pug_html + "\u003C!DOCTYPE html\u003E";
|
|
10
|
-
;pug_debug_line = 2;pug_debug_filename = "\u002FUsers\u002Ftkirby\u002Fworkspace\u002Fzbryikt\u002Fplotdb\u002Fprojects\u002Fregistry\u002Fnode_modules\u002F@plotdb\u002Fsrcbuild\u002Fdist\u002Flib.pug";
|
|
11
|
-
if(!libLoader) {
|
|
12
|
-
libLoader = {
|
|
13
|
-
js: {url: {}},
|
|
14
|
-
css: {url: {}},
|
|
15
|
-
root: function(r) { libLoader._r = r; },
|
|
16
|
-
_r: "/assets/lib",
|
|
17
|
-
_v: "",
|
|
18
|
-
version: function(v) { libLoader._v = (v ? "?v=" + v : ""); }
|
|
19
|
-
}
|
|
20
|
-
if(version) { libLoader.version(version); }
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
;pug_debug_line = 15;pug_debug_filename = "\u002FUsers\u002Ftkirby\u002Fworkspace\u002Fzbryikt\u002Fplotdb\u002Fprojects\u002Fregistry\u002Fnode_modules\u002F@plotdb\u002Fsrcbuild\u002Fdist\u002Flib.pug";
|
|
24
|
-
pug_mixins["script"] = pug_interp = function(os,cfg){
|
|
25
|
-
var block = (this && this.block), attributes = (this && this.attributes) || {};
|
|
26
|
-
;pug_debug_line = 16;pug_debug_filename = "\u002FUsers\u002Ftkirby\u002Fworkspace\u002Fzbryikt\u002Fplotdb\u002Fprojects\u002Fregistry\u002Fnode_modules\u002F@plotdb\u002Fsrcbuild\u002Fdist\u002Flib.pug";
|
|
27
|
-
if(!Array.isArray(os)) { os = [os]; }
|
|
28
|
-
;pug_debug_line = 18;pug_debug_filename = "\u002FUsers\u002Ftkirby\u002Fworkspace\u002Fzbryikt\u002Fplotdb\u002Fprojects\u002Fregistry\u002Fnode_modules\u002F@plotdb\u002Fsrcbuild\u002Fdist\u002Flib.pug";
|
|
29
|
-
// iterate os
|
|
30
|
-
;(function(){
|
|
31
|
-
var $$obj = os;
|
|
32
|
-
if ('number' == typeof $$obj.length) {
|
|
33
|
-
for (var pug_index0 = 0, $$l = $$obj.length; pug_index0 < $$l; pug_index0++) {
|
|
34
|
-
var o = $$obj[pug_index0];
|
|
35
|
-
;pug_debug_line = 19;pug_debug_filename = "\u002FUsers\u002Ftkirby\u002Fworkspace\u002Fzbryikt\u002Fplotdb\u002Fprojects\u002Fregistry\u002Fnode_modules\u002F@plotdb\u002Fsrcbuild\u002Fdist\u002Flib.pug";
|
|
36
|
-
c = o;
|
|
37
|
-
if(typeof(o) == "string") { url = o; c = cfg || {};}
|
|
38
|
-
else if(o.url) { url = o.url; }
|
|
39
|
-
else { url = libLoader._r + "/" + o.name + "/" + (o.version || 'main') + "/" + (o.path || "index.min.js"); }
|
|
40
|
-
;pug_debug_line = 24;pug_debug_filename = "\u002FUsers\u002Ftkirby\u002Fworkspace\u002Fzbryikt\u002Fplotdb\u002Fprojects\u002Fregistry\u002Fnode_modules\u002F@plotdb\u002Fsrcbuild\u002Fdist\u002Flib.pug";
|
|
41
|
-
if (!libLoader.js.url[url]) {
|
|
42
|
-
;pug_debug_line = 25;pug_debug_filename = "\u002FUsers\u002Ftkirby\u002Fworkspace\u002Fzbryikt\u002Fplotdb\u002Fprojects\u002Fregistry\u002Fnode_modules\u002F@plotdb\u002Fsrcbuild\u002Fdist\u002Flib.pug";
|
|
43
|
-
libLoader.js.url[url] = true;
|
|
44
|
-
;pug_debug_line = 26;pug_debug_filename = "\u002FUsers\u002Ftkirby\u002Fworkspace\u002Fzbryikt\u002Fplotdb\u002Fprojects\u002Fregistry\u002Fnode_modules\u002F@plotdb\u002Fsrcbuild\u002Fdist\u002Flib.pug";
|
|
45
|
-
defer = (typeof(c.defer) == "undefined" ? true : !!c.defer);
|
|
46
|
-
;pug_debug_line = 27;pug_debug_filename = "\u002FUsers\u002Ftkirby\u002Fworkspace\u002Fzbryikt\u002Fplotdb\u002Fprojects\u002Fregistry\u002Fnode_modules\u002F@plotdb\u002Fsrcbuild\u002Fdist\u002Flib.pug";
|
|
47
|
-
if (/^https?:\/\/./.exec(url)) {
|
|
48
|
-
;pug_debug_line = 28;pug_debug_filename = "\u002FUsers\u002Ftkirby\u002Fworkspace\u002Fzbryikt\u002Fplotdb\u002Fprojects\u002Fregistry\u002Fnode_modules\u002F@plotdb\u002Fsrcbuild\u002Fdist\u002Flib.pug";
|
|
49
|
-
pug_html = pug_html + "\u003Cscript" + (" type=\"text\u002Fjavascript\""+pug_attr("src", url, true, true)+pug_attr("defer", defer, true, true)+pug_attr("async", !!c.async, true, true)) + "\u003E\u003C\u002Fscript\u003E";
|
|
50
|
-
}
|
|
51
|
-
else {
|
|
52
|
-
;pug_debug_line = 30;pug_debug_filename = "\u002FUsers\u002Ftkirby\u002Fworkspace\u002Fzbryikt\u002Fplotdb\u002Fprojects\u002Fregistry\u002Fnode_modules\u002F@plotdb\u002Fsrcbuild\u002Fdist\u002Flib.pug";
|
|
53
|
-
pug_html = pug_html + "\u003Cscript" + (" type=\"text\u002Fjavascript\""+pug_attr("src", url + libLoader._v, true, true)+pug_attr("defer", defer, true, true)+pug_attr("async", !!c.async, true, true)) + "\u003E\u003C\u002Fscript\u003E";
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
} else {
|
|
58
|
-
var $$l = 0;
|
|
59
|
-
for (var pug_index0 in $$obj) {
|
|
60
|
-
$$l++;
|
|
61
|
-
var o = $$obj[pug_index0];
|
|
62
|
-
;pug_debug_line = 19;pug_debug_filename = "\u002FUsers\u002Ftkirby\u002Fworkspace\u002Fzbryikt\u002Fplotdb\u002Fprojects\u002Fregistry\u002Fnode_modules\u002F@plotdb\u002Fsrcbuild\u002Fdist\u002Flib.pug";
|
|
63
|
-
c = o;
|
|
64
|
-
if(typeof(o) == "string") { url = o; c = cfg || {};}
|
|
65
|
-
else if(o.url) { url = o.url; }
|
|
66
|
-
else { url = libLoader._r + "/" + o.name + "/" + (o.version || 'main') + "/" + (o.path || "index.min.js"); }
|
|
67
|
-
;pug_debug_line = 24;pug_debug_filename = "\u002FUsers\u002Ftkirby\u002Fworkspace\u002Fzbryikt\u002Fplotdb\u002Fprojects\u002Fregistry\u002Fnode_modules\u002F@plotdb\u002Fsrcbuild\u002Fdist\u002Flib.pug";
|
|
68
|
-
if (!libLoader.js.url[url]) {
|
|
69
|
-
;pug_debug_line = 25;pug_debug_filename = "\u002FUsers\u002Ftkirby\u002Fworkspace\u002Fzbryikt\u002Fplotdb\u002Fprojects\u002Fregistry\u002Fnode_modules\u002F@plotdb\u002Fsrcbuild\u002Fdist\u002Flib.pug";
|
|
70
|
-
libLoader.js.url[url] = true;
|
|
71
|
-
;pug_debug_line = 26;pug_debug_filename = "\u002FUsers\u002Ftkirby\u002Fworkspace\u002Fzbryikt\u002Fplotdb\u002Fprojects\u002Fregistry\u002Fnode_modules\u002F@plotdb\u002Fsrcbuild\u002Fdist\u002Flib.pug";
|
|
72
|
-
defer = (typeof(c.defer) == "undefined" ? true : !!c.defer);
|
|
73
|
-
;pug_debug_line = 27;pug_debug_filename = "\u002FUsers\u002Ftkirby\u002Fworkspace\u002Fzbryikt\u002Fplotdb\u002Fprojects\u002Fregistry\u002Fnode_modules\u002F@plotdb\u002Fsrcbuild\u002Fdist\u002Flib.pug";
|
|
74
|
-
if (/^https?:\/\/./.exec(url)) {
|
|
75
|
-
;pug_debug_line = 28;pug_debug_filename = "\u002FUsers\u002Ftkirby\u002Fworkspace\u002Fzbryikt\u002Fplotdb\u002Fprojects\u002Fregistry\u002Fnode_modules\u002F@plotdb\u002Fsrcbuild\u002Fdist\u002Flib.pug";
|
|
76
|
-
pug_html = pug_html + "\u003Cscript" + (" type=\"text\u002Fjavascript\""+pug_attr("src", url, true, true)+pug_attr("defer", defer, true, true)+pug_attr("async", !!c.async, true, true)) + "\u003E\u003C\u002Fscript\u003E";
|
|
77
|
-
}
|
|
78
|
-
else {
|
|
79
|
-
;pug_debug_line = 30;pug_debug_filename = "\u002FUsers\u002Ftkirby\u002Fworkspace\u002Fzbryikt\u002Fplotdb\u002Fprojects\u002Fregistry\u002Fnode_modules\u002F@plotdb\u002Fsrcbuild\u002Fdist\u002Flib.pug";
|
|
80
|
-
pug_html = pug_html + "\u003Cscript" + (" type=\"text\u002Fjavascript\""+pug_attr("src", url + libLoader._v, true, true)+pug_attr("defer", defer, true, true)+pug_attr("async", !!c.async, true, true)) + "\u003E\u003C\u002Fscript\u003E";
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
}).call(this);
|
|
86
|
-
|
|
87
|
-
};
|
|
88
|
-
;pug_debug_line = 32;pug_debug_filename = "\u002FUsers\u002Ftkirby\u002Fworkspace\u002Fzbryikt\u002Fplotdb\u002Fprojects\u002Fregistry\u002Fnode_modules\u002F@plotdb\u002Fsrcbuild\u002Fdist\u002Flib.pug";
|
|
89
|
-
pug_mixins["css"] = pug_interp = function(os,cfg){
|
|
90
|
-
var block = (this && this.block), attributes = (this && this.attributes) || {};
|
|
91
|
-
;pug_debug_line = 33;pug_debug_filename = "\u002FUsers\u002Ftkirby\u002Fworkspace\u002Fzbryikt\u002Fplotdb\u002Fprojects\u002Fregistry\u002Fnode_modules\u002F@plotdb\u002Fsrcbuild\u002Fdist\u002Flib.pug";
|
|
92
|
-
if(!Array.isArray(os)) { os = [os]; }
|
|
93
|
-
;pug_debug_line = 35;pug_debug_filename = "\u002FUsers\u002Ftkirby\u002Fworkspace\u002Fzbryikt\u002Fplotdb\u002Fprojects\u002Fregistry\u002Fnode_modules\u002F@plotdb\u002Fsrcbuild\u002Fdist\u002Flib.pug";
|
|
94
|
-
// iterate os
|
|
95
|
-
;(function(){
|
|
96
|
-
var $$obj = os;
|
|
97
|
-
if ('number' == typeof $$obj.length) {
|
|
98
|
-
for (var pug_index1 = 0, $$l = $$obj.length; pug_index1 < $$l; pug_index1++) {
|
|
99
|
-
var o = $$obj[pug_index1];
|
|
100
|
-
;pug_debug_line = 36;pug_debug_filename = "\u002FUsers\u002Ftkirby\u002Fworkspace\u002Fzbryikt\u002Fplotdb\u002Fprojects\u002Fregistry\u002Fnode_modules\u002F@plotdb\u002Fsrcbuild\u002Fdist\u002Flib.pug";
|
|
101
|
-
c = o;
|
|
102
|
-
if(typeof(o) == "string") { url = o; c = cfg || {};}
|
|
103
|
-
else if(o.url) { url = o.url; }
|
|
104
|
-
else { url = libLoader._r + "/" + o.name + "/" + (o.version || 'main') + "/" + (o.path || "index.min.css"); }
|
|
105
|
-
;pug_debug_line = 41;pug_debug_filename = "\u002FUsers\u002Ftkirby\u002Fworkspace\u002Fzbryikt\u002Fplotdb\u002Fprojects\u002Fregistry\u002Fnode_modules\u002F@plotdb\u002Fsrcbuild\u002Fdist\u002Flib.pug";
|
|
106
|
-
if (!libLoader.css.url[url]) {
|
|
107
|
-
;pug_debug_line = 42;pug_debug_filename = "\u002FUsers\u002Ftkirby\u002Fworkspace\u002Fzbryikt\u002Fplotdb\u002Fprojects\u002Fregistry\u002Fnode_modules\u002F@plotdb\u002Fsrcbuild\u002Fdist\u002Flib.pug";
|
|
108
|
-
libLoader.css.url[url] = true;
|
|
109
|
-
;pug_debug_line = 43;pug_debug_filename = "\u002FUsers\u002Ftkirby\u002Fworkspace\u002Fzbryikt\u002Fplotdb\u002Fprojects\u002Fregistry\u002Fnode_modules\u002F@plotdb\u002Fsrcbuild\u002Fdist\u002Flib.pug";
|
|
110
|
-
pug_html = pug_html + "\u003Clink" + (" rel=\"stylesheet\" type=\"text\u002Fcss\""+pug_attr("href", url + libLoader._v, true, true)) + "\u003E";
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
} else {
|
|
114
|
-
var $$l = 0;
|
|
115
|
-
for (var pug_index1 in $$obj) {
|
|
116
|
-
$$l++;
|
|
117
|
-
var o = $$obj[pug_index1];
|
|
118
|
-
;pug_debug_line = 36;pug_debug_filename = "\u002FUsers\u002Ftkirby\u002Fworkspace\u002Fzbryikt\u002Fplotdb\u002Fprojects\u002Fregistry\u002Fnode_modules\u002F@plotdb\u002Fsrcbuild\u002Fdist\u002Flib.pug";
|
|
119
|
-
c = o;
|
|
120
|
-
if(typeof(o) == "string") { url = o; c = cfg || {};}
|
|
121
|
-
else if(o.url) { url = o.url; }
|
|
122
|
-
else { url = libLoader._r + "/" + o.name + "/" + (o.version || 'main') + "/" + (o.path || "index.min.css"); }
|
|
123
|
-
;pug_debug_line = 41;pug_debug_filename = "\u002FUsers\u002Ftkirby\u002Fworkspace\u002Fzbryikt\u002Fplotdb\u002Fprojects\u002Fregistry\u002Fnode_modules\u002F@plotdb\u002Fsrcbuild\u002Fdist\u002Flib.pug";
|
|
124
|
-
if (!libLoader.css.url[url]) {
|
|
125
|
-
;pug_debug_line = 42;pug_debug_filename = "\u002FUsers\u002Ftkirby\u002Fworkspace\u002Fzbryikt\u002Fplotdb\u002Fprojects\u002Fregistry\u002Fnode_modules\u002F@plotdb\u002Fsrcbuild\u002Fdist\u002Flib.pug";
|
|
126
|
-
libLoader.css.url[url] = true;
|
|
127
|
-
;pug_debug_line = 43;pug_debug_filename = "\u002FUsers\u002Ftkirby\u002Fworkspace\u002Fzbryikt\u002Fplotdb\u002Fprojects\u002Fregistry\u002Fnode_modules\u002F@plotdb\u002Fsrcbuild\u002Fdist\u002Flib.pug";
|
|
128
|
-
pug_html = pug_html + "\u003Clink" + (" rel=\"stylesheet\" type=\"text\u002Fcss\""+pug_attr("href", url + libLoader._v, true, true)) + "\u003E";
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
}).call(this);
|
|
133
|
-
|
|
134
|
-
};
|
|
135
|
-
;pug_debug_line = 2;pug_debug_filename = "src\u002Fpug\u002Findex.pug";
|
|
136
|
-
pug_html = pug_html + "\u003Chtml\u003E";
|
|
137
|
-
;pug_debug_line = 3;pug_debug_filename = "src\u002Fpug\u002Findex.pug";
|
|
138
|
-
pug_html = pug_html + "\u003Chead\u003E";
|
|
139
|
-
;pug_debug_line = 4;pug_debug_filename = "src\u002Fpug\u002Findex.pug";
|
|
140
|
-
pug_mixins["css"]([
|
|
141
|
-
{name: "bootstrap", path: "css/bootstrap.min.css"}
|
|
142
|
-
]);
|
|
143
|
-
pug_html = pug_html + "\u003C\u002Fhead\u003E";
|
|
144
|
-
;pug_debug_line = 7;pug_debug_filename = "src\u002Fpug\u002Findex.pug";
|
|
145
|
-
pug_html = pug_html + "\u003Cbody\u003E";
|
|
146
|
-
;pug_debug_line = 8;pug_debug_filename = "src\u002Fpug\u002Findex.pug";
|
|
147
|
-
pug_mixins["script"]([
|
|
148
|
-
{name: "proxise"},
|
|
149
|
-
{name: "@loadingio/debounce.js", path: "debounce.min.js"},
|
|
150
|
-
{name: "@plotdb/csscope"},
|
|
151
|
-
{name: "@plotdb/rescope"},
|
|
152
|
-
{name: "@plotdb/block"}
|
|
153
|
-
]);
|
|
154
|
-
;pug_debug_line = 15;pug_debug_filename = "src\u002Fpug\u002Findex.pug";
|
|
155
|
-
pug_html = pug_html + "\u003Cscript type=\"module\"\u003E";
|
|
156
|
-
;pug_debug_line = 15;pug_debug_filename = "src\u002Fpug\u002Findex.pug";
|
|
157
|
-
pug_html = pug_html + "var provider,rsp;provider={jsdelivr:function(n){var e,r,t,i;e=n.name,r=n.version,t=n.path;i=\"https:\u002F\u002Fcdn.jsdelivr.net\u002Fnpm\u002F\"+e+(r?\"@\"+r:\"\")+\"\u002F\"+(t||\"dist\u002Findex.min.js\");return fetch(i).then(function(n){var e;e=n.headers.get(\"x-jsd-version\");return n.text().then(function(n){return{version:e||r,content:n}})})},unpkg:function(n){var e,r,t;e=n.name,r=n.version,t=n.path;return Promise.resolve().then(function(){var n;n=\"https:\u002F\u002Funpkg.com\u002F\"+e+(r?\"@\"+r:\"\")+\"\u002F\"+(t||\"dist\u002Findex.min.js\");return fetch(n).then(function(n){var e;e=(\u002F^https:\\\u002F\\\u002Funpkg.com\\\u002F([^@]+)@([^\u002F]+)\\\u002F\u002F.exec(n.url)||[])[2];return n.text().then(function(n){return{version:e||r,content:n}})})})}};rsp=new rescope({registry:provider.jsdelivr});rsp.init().then(function(){return rsp.load([{name:\"ldview\",version:\"^0.1\"}]).then(function(n){return console.log(\"\u003E\",n)})});\u003C\u002Fscript\u003E\u003C\u002Fbody\u003E\u003C\u002Fhtml\u003E";
|
|
158
|
-
}.call(this, "Array" in locals_for_with ?
|
|
159
|
-
locals_for_with.Array :
|
|
160
|
-
typeof Array !== 'undefined' ? Array : undefined, "c" in locals_for_with ?
|
|
161
|
-
locals_for_with.c :
|
|
162
|
-
typeof c !== 'undefined' ? c : undefined, "defer" in locals_for_with ?
|
|
163
|
-
locals_for_with.defer :
|
|
164
|
-
typeof defer !== 'undefined' ? defer : undefined, "libLoader" in locals_for_with ?
|
|
165
|
-
locals_for_with.libLoader :
|
|
166
|
-
typeof libLoader !== 'undefined' ? libLoader : undefined, "url" in locals_for_with ?
|
|
167
|
-
locals_for_with.url :
|
|
168
|
-
typeof url !== 'undefined' ? url : undefined, "version" in locals_for_with ?
|
|
169
|
-
locals_for_with.version :
|
|
170
|
-
typeof version !== 'undefined' ? version : undefined));
|
|
171
|
-
;} catch (err) {pug_rethrow(err, pug_debug_filename, pug_debug_line);};return pug_html;}; module.exports = template; })()
|
package/web/server.ls
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
require! <[fs express path @plotdb/colors lderror]>
|
|
2
|
-
require! <[../src/provider ../src/route ../src/providers/github ../src/providers/npm]>
|
|
3
|
-
|
|
4
|
-
lib = fs.realpathSync path.dirname __filename
|
|
5
|
-
|
|
6
|
-
if !fs.exists-sync path.join(lib, \secret.json) =>
|
|
7
|
-
console.log "please add a `secret.json` file with a access token for github access, such as:"
|
|
8
|
-
console.log ""
|
|
9
|
-
console.log ' {"token": "your-access-token-goes-here"}'
|
|
10
|
-
console.log ""
|
|
11
|
-
process.exit!
|
|
12
|
-
|
|
13
|
-
token = JSON.parse(fs.read-file-sync path.join(lib, \secret.json) .toString!)
|
|
14
|
-
custom = new provider do
|
|
15
|
-
check: ({name, version, path}) ->
|
|
16
|
-
return if !(/^(ld|pth|@plotdb)/.exec(name)) => lderror.reject 403 else Promise.resolve!
|
|
17
|
-
|
|
18
|
-
github.opt token
|
|
19
|
-
custom.chain([github, npm])
|
|
20
|
-
|
|
21
|
-
server = do
|
|
22
|
-
init: (opt={}) ->
|
|
23
|
-
app = express!
|
|
24
|
-
app.use \/, express.static \static
|
|
25
|
-
app.get '/lib/*', route({
|
|
26
|
-
provider: custom
|
|
27
|
-
root:
|
|
28
|
-
pub: \/lib/
|
|
29
|
-
fs: \/var/lib/cdn/cache/lib
|
|
30
|
-
internal: \/ilib/
|
|
31
|
-
})
|
|
32
|
-
console.log "[Server] Express Initialized in #{app.get \env} Mode".green
|
|
33
|
-
server = app.listen opt.port, ->
|
|
34
|
-
delta = if opt.start-time => "( takes #{Date.now! - opt.start-time}ms )" else ''
|
|
35
|
-
console.log "[SERVER] listening on port #{server.address!port} #delta".cyan
|
|
36
|
-
|
|
37
|
-
server.init {port: 9900}
|
|
38
|
-
|
package/web/src/pug/index.ls
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
provider =
|
|
2
|
-
jsdelivr: ({name, version, path}) ->
|
|
3
|
-
url = "https://cdn.jsdelivr.net/npm/#{name}#{if version => '@' + version else ''}/#{path or 'dist/index.min.js'}"
|
|
4
|
-
fetch url
|
|
5
|
-
.then (response) ->
|
|
6
|
-
v = response.headers.get(\x-jsd-version)
|
|
7
|
-
response.text!then -> {version: v or version, content: it}
|
|
8
|
-
|
|
9
|
-
unpkg: ({name, version, path}) ->
|
|
10
|
-
Promise.resolve!then ->
|
|
11
|
-
url = "https://unpkg.com/#{name}#{if version => '@' + version else ''}/#{path or 'dist/index.min.js'}"
|
|
12
|
-
fetch url
|
|
13
|
-
.then (response) ->
|
|
14
|
-
v = (/^https:\/\/unpkg.com\/([^@]+)@([^/]+)\//.exec(response.url) or []).2
|
|
15
|
-
response.text!then -> {version: v or version, content: it}
|
|
16
|
-
|
|
17
|
-
rsp = new rescope registry: provider.jsdelivr
|
|
18
|
-
|
|
19
|
-
rsp.init!
|
|
20
|
-
.then ->
|
|
21
|
-
rsp.load [{name: "ldview", version: "^0.1"}]
|
|
22
|
-
.then -> console.log ">", it
|
package/web/src/pug/index.pug
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
doctype html
|
|
2
|
-
html
|
|
3
|
-
head
|
|
4
|
-
+css([
|
|
5
|
-
{name: "bootstrap", path: "css/bootstrap.min.css"}
|
|
6
|
-
])
|
|
7
|
-
body
|
|
8
|
-
+script([
|
|
9
|
-
{name: "proxise"},
|
|
10
|
-
{name: "@loadingio/debounce.js", path: "debounce.min.js"},
|
|
11
|
-
{name: "@plotdb/csscope"},
|
|
12
|
-
{name: "@plotdb/rescope"},
|
|
13
|
-
{name: "@plotdb/block"}
|
|
14
|
-
])
|
|
15
|
-
script(type="module"): include:lsc index.ls
|
package/web/static/favicon.ico
DELETED
|
File without changes
|
package/web/static/index.html
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html><html><head><link rel="stylesheet" type="text/css" href="/assets/lib/bootstrap/main/css/bootstrap.min.css"></head><body><script type="text/javascript" src="/assets/lib/proxise/main/index.min.js" defer></script><script type="text/javascript" src="/assets/lib/@loadingio/debounce.js/main/debounce.min.js" defer></script><script type="text/javascript" src="/assets/lib/@plotdb/csscope/main/index.min.js" defer></script><script type="text/javascript" src="/assets/lib/@plotdb/rescope/main/index.min.js" defer></script><script type="text/javascript" src="/assets/lib/@plotdb/block/main/index.min.js" defer></script><script type="module">var provider,rsp;provider={jsdelivr:function(n){var e,r,t,i;e=n.name,r=n.version,t=n.path;i="https://cdn.jsdelivr.net/npm/"+e+(r?"@"+r:"")+"/"+(t||"dist/index.min.js");return fetch(i).then(function(n){var e;e=n.headers.get("x-jsd-version");return n.text().then(function(n){return{version:e||r,content:n}})})},unpkg:function(n){var e,r,t;e=n.name,r=n.version,t=n.path;return Promise.resolve().then(function(){var n;n="https://unpkg.com/"+e+(r?"@"+r:"")+"/"+(t||"dist/index.min.js");return fetch(n).then(function(n){var e;e=(/^https:\/\/unpkg.com\/([^@]+)@([^/]+)\//.exec(n.url)||[])[2];return n.text().then(function(n){return{version:e||r,content:n}})})})}};rsp=new rescope({registry:provider.jsdelivr});rsp.init().then(function(){return rsp.load([{name:"ldview",version:"^0.1"}]).then(function(n){return console.log(">",n)})});</script></body></html>
|