@eik/core 1.2.29 → 1.3.0
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 +7 -0
- package/lib/classes/alias.js +2 -3
- package/lib/classes/asset.js +4 -5
- package/lib/classes/author.js +2 -3
- package/lib/classes/http-incoming.js +2 -3
- package/lib/classes/http-outgoing.js +2 -4
- package/lib/classes/meta.js +2 -3
- package/lib/classes/package.js +4 -6
- package/lib/classes/versions.js +2 -4
- package/lib/handlers/alias.delete.js +12 -14
- package/lib/handlers/alias.get.js +15 -17
- package/lib/handlers/alias.post.js +19 -21
- package/lib/handlers/alias.put.js +19 -21
- package/lib/handlers/auth.post.js +10 -12
- package/lib/handlers/map.get.js +12 -14
- package/lib/handlers/map.put.js +24 -26
- package/lib/handlers/pkg.get.js +15 -17
- package/lib/handlers/pkg.log.js +12 -14
- package/lib/handlers/pkg.put.js +22 -25
- package/lib/handlers/versions.get.js +11 -13
- package/lib/main.js +25 -22
- package/lib/multipart/form-field.js +1 -3
- package/lib/multipart/form-file.js +1 -3
- package/lib/multipart/parser.js +12 -14
- package/lib/sinks/fs.js +10 -12
- package/lib/sinks/mem-entry.js +3 -4
- package/lib/sinks/mem.js +7 -9
- package/lib/sinks/test.js +9 -10
- package/lib/utils/defaults.js +4 -5
- package/lib/utils/globals.js +1 -3
- package/lib/utils/healthcheck.js +8 -12
- package/lib/utils/path-builders-fs.js +17 -15
- package/lib/utils/path-builders-uri.js +14 -14
- package/lib/utils/utils.js +9 -9
- package/package.json +4 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
# [1.3.0](https://github.com/eik-lib/core/compare/v1.2.29...v1.3.0) (2022-01-07)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* Convert to ESM ([#297](https://github.com/eik-lib/core/issues/297)) ([86c5cb3](https://github.com/eik-lib/core/commit/86c5cb3be753b777dafb6a79753e4dd5412cd352))
|
|
7
|
+
|
|
1
8
|
## [1.2.29](https://github.com/eik-lib/core/compare/v1.2.28...v1.2.29) (2022-01-05)
|
|
2
9
|
|
|
3
10
|
|
package/lib/classes/alias.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
1
|
const Alias = class Alias {
|
|
4
2
|
constructor({ name = '', type = '', alias = '', org = '' } = {}) {
|
|
5
3
|
this._version = '';
|
|
@@ -47,4 +45,5 @@ const Alias = class Alias {
|
|
|
47
45
|
return 'Alias';
|
|
48
46
|
}
|
|
49
47
|
}
|
|
50
|
-
|
|
48
|
+
|
|
49
|
+
export default Alias;
|
package/lib/classes/asset.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const mime = require('mime/lite');
|
|
4
|
-
const path = require('path');
|
|
1
|
+
import mime from 'mime';
|
|
2
|
+
import path from 'node:path';
|
|
5
3
|
|
|
6
4
|
/**
|
|
7
5
|
* Meta information about an Asset.
|
|
@@ -95,4 +93,5 @@ const Asset = class Asset {
|
|
|
95
93
|
return 'Asset';
|
|
96
94
|
}
|
|
97
95
|
}
|
|
98
|
-
|
|
96
|
+
|
|
97
|
+
export default Asset;
|
package/lib/classes/author.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
1
|
/**
|
|
4
2
|
* A bearer object to hold misc data through a http
|
|
5
3
|
* request / response cyclus.
|
|
@@ -70,4 +68,5 @@ const HttpIncoming = class HttpIncoming {
|
|
|
70
68
|
return 'HttpIncoming';
|
|
71
69
|
}
|
|
72
70
|
};
|
|
73
|
-
|
|
71
|
+
|
|
72
|
+
export default HttpIncoming;
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const { stream } = require('@eik/common');
|
|
1
|
+
import { stream } from '@eik/common';
|
|
4
2
|
|
|
5
3
|
const STATUS_CODES = [
|
|
6
4
|
100, 101, 102, 103,
|
|
@@ -88,4 +86,4 @@ const HttpOutgoing = class HttpOutgoing {
|
|
|
88
86
|
return 'HttpOutgoing';
|
|
89
87
|
}
|
|
90
88
|
}
|
|
91
|
-
|
|
89
|
+
export default HttpOutgoing;
|
package/lib/classes/meta.js
CHANGED
package/lib/classes/package.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const Asset = require('./asset');
|
|
5
|
-
const Meta = require('./meta');
|
|
1
|
+
import crypto from 'node:crypto';
|
|
2
|
+
import Asset from './asset.js';
|
|
3
|
+
import Meta from './meta.js';
|
|
6
4
|
|
|
7
5
|
const Package = class Package {
|
|
8
6
|
constructor({ version = '', type = '', name = '', org = '', author = {} } = {}) {
|
|
@@ -85,4 +83,4 @@ const Package = class Package {
|
|
|
85
83
|
return 'Package';
|
|
86
84
|
}
|
|
87
85
|
}
|
|
88
|
-
|
|
86
|
+
export default Package;
|
package/lib/classes/versions.js
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const semver = require('semver');
|
|
1
|
+
import semver from 'semver';
|
|
4
2
|
|
|
5
3
|
const Versions = class Versions {
|
|
6
4
|
constructor({ versions = [], type = '', name = '', org = '' } = {}) {
|
|
@@ -65,4 +63,4 @@ const Versions = class Versions {
|
|
|
65
63
|
return 'Versions';
|
|
66
64
|
}
|
|
67
65
|
}
|
|
68
|
-
|
|
66
|
+
export default Versions;
|
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
import { validators } from '@eik/common';
|
|
2
|
+
import originalUrl from 'original-url';
|
|
3
|
+
import HttpError from 'http-errors';
|
|
4
|
+
import Metrics from '@metrics/client';
|
|
5
|
+
import abslog from 'abslog';
|
|
2
6
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const abslog = require('abslog');
|
|
8
|
-
|
|
9
|
-
const { createFilePathToAlias } = require('../utils/path-builders-fs');
|
|
10
|
-
const HttpOutgoing = require('../classes/http-outgoing');
|
|
11
|
-
const config = require('../utils/defaults');
|
|
12
|
-
const utils = require('../utils/utils');
|
|
7
|
+
import { createFilePathToAlias } from '../utils/path-builders-fs.js';
|
|
8
|
+
import { decodeUriComponent } from '../utils/utils.js';
|
|
9
|
+
import HttpOutgoing from '../classes/http-outgoing.js';
|
|
10
|
+
import config from '../utils/defaults.js';
|
|
13
11
|
|
|
14
12
|
const AliasDel = class AliasDel {
|
|
15
13
|
constructor({
|
|
@@ -61,8 +59,8 @@ const AliasDel = class AliasDel {
|
|
|
61
59
|
async handler(req, user, type, name, alias) {
|
|
62
60
|
const end = this._histogram.timer();
|
|
63
61
|
|
|
64
|
-
const pAlias =
|
|
65
|
-
const pName =
|
|
62
|
+
const pAlias = decodeUriComponent(alias);
|
|
63
|
+
const pName = decodeUriComponent(name);
|
|
66
64
|
|
|
67
65
|
try {
|
|
68
66
|
validators.alias(pAlias);
|
|
@@ -124,4 +122,4 @@ const AliasDel = class AliasDel {
|
|
|
124
122
|
return outgoing;
|
|
125
123
|
}
|
|
126
124
|
};
|
|
127
|
-
|
|
125
|
+
export default AliasDel;
|
|
@@ -1,16 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
import { validators } from '@eik/common';
|
|
2
|
+
import originalUrl from 'original-url';
|
|
3
|
+
import HttpError from 'http-errors';
|
|
4
|
+
import abslog from 'abslog';
|
|
5
|
+
import Metrics from '@metrics/client';
|
|
2
6
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const { createURIToTargetOfAlias } = require('../utils/path-builders-uri');
|
|
10
|
-
const { createFilePathToAlias } = require('../utils/path-builders-fs');
|
|
11
|
-
const HttpOutgoing = require('../classes/http-outgoing');
|
|
12
|
-
const utils = require('../utils/utils');
|
|
13
|
-
const config = require('../utils/defaults');
|
|
7
|
+
import { decodeUriComponent, readJSON } from '../utils/utils.js';
|
|
8
|
+
import { createURIToTargetOfAlias } from '../utils/path-builders-uri.js';
|
|
9
|
+
import { createFilePathToAlias } from '../utils/path-builders-fs.js';
|
|
10
|
+
import HttpOutgoing from '../classes/http-outgoing.js';
|
|
11
|
+
import config from '../utils/defaults.js';
|
|
14
12
|
|
|
15
13
|
const AliasGet = class AliasGet {
|
|
16
14
|
constructor({
|
|
@@ -53,9 +51,9 @@ const AliasGet = class AliasGet {
|
|
|
53
51
|
async handler(req, type, name, alias, extra) {
|
|
54
52
|
const end = this._histogram.timer();
|
|
55
53
|
|
|
56
|
-
const pAlias =
|
|
57
|
-
const pExtra =
|
|
58
|
-
const pName =
|
|
54
|
+
const pAlias = decodeUriComponent(alias);
|
|
55
|
+
const pExtra = decodeUriComponent(extra);
|
|
56
|
+
const pName = decodeUriComponent(name);
|
|
59
57
|
|
|
60
58
|
try {
|
|
61
59
|
validators.alias(pAlias);
|
|
@@ -82,7 +80,7 @@ const AliasGet = class AliasGet {
|
|
|
82
80
|
const path = createFilePathToAlias({ org, type, name: pName, alias: pAlias });
|
|
83
81
|
|
|
84
82
|
try {
|
|
85
|
-
const obj = await
|
|
83
|
+
const obj = await readJSON(this._sink, path);
|
|
86
84
|
const location = createURIToTargetOfAlias({ extra: pExtra, ...obj });
|
|
87
85
|
|
|
88
86
|
const outgoing = new HttpOutgoing();
|
|
@@ -103,4 +101,4 @@ const AliasGet = class AliasGet {
|
|
|
103
101
|
}
|
|
104
102
|
}
|
|
105
103
|
};
|
|
106
|
-
|
|
104
|
+
export default AliasGet;
|
|
@@ -1,23 +1,21 @@
|
|
|
1
|
-
|
|
1
|
+
import { validators } from '@eik/common';
|
|
2
|
+
import originalUrl from 'original-url';
|
|
3
|
+
import HttpError from 'http-errors';
|
|
4
|
+
import abslog from 'abslog';
|
|
5
|
+
import Metrics from '@metrics/client';
|
|
2
6
|
|
|
3
|
-
|
|
4
|
-
const originalUrl = require('original-url');
|
|
5
|
-
const HttpError = require('http-errors');
|
|
6
|
-
const abslog = require('abslog');
|
|
7
|
-
const Metrics = require('@metrics/client');
|
|
8
|
-
|
|
9
|
-
const {
|
|
7
|
+
import {
|
|
10
8
|
createFilePathToAlias,
|
|
11
9
|
createFilePathToAliasOrigin,
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
10
|
+
} from '../utils/path-builders-fs.js';
|
|
11
|
+
import { createURIToAlias } from '../utils/path-builders-uri.js';
|
|
12
|
+
import MultipartParser from '../multipart/parser.js';
|
|
13
|
+
import HttpIncoming from '../classes/http-incoming.js';
|
|
14
|
+
import HttpOutgoing from '../classes/http-outgoing.js';
|
|
15
|
+
import Author from '../classes/author.js';
|
|
16
|
+
import Alias from '../classes/alias.js';
|
|
17
|
+
import config from '../utils/defaults.js';
|
|
18
|
+
import { decodeUriComponent, writeJSON } from '../utils/utils.js';
|
|
21
19
|
|
|
22
20
|
const AliasPost = class AliasPost {
|
|
23
21
|
constructor({
|
|
@@ -112,7 +110,7 @@ const AliasPost = class AliasPost {
|
|
|
112
110
|
);
|
|
113
111
|
|
|
114
112
|
try {
|
|
115
|
-
await
|
|
113
|
+
await writeJSON(
|
|
116
114
|
this._sink,
|
|
117
115
|
path,
|
|
118
116
|
alias,
|
|
@@ -152,8 +150,8 @@ const AliasPost = class AliasPost {
|
|
|
152
150
|
async handler(req, user, type, name, alias) {
|
|
153
151
|
const end = this._histogram.timer();
|
|
154
152
|
|
|
155
|
-
const pAlias =
|
|
156
|
-
const pName =
|
|
153
|
+
const pAlias = decodeUriComponent(alias);
|
|
154
|
+
const pName = decodeUriComponent(name);
|
|
157
155
|
|
|
158
156
|
try {
|
|
159
157
|
validators.alias(pAlias);
|
|
@@ -208,4 +206,4 @@ const AliasPost = class AliasPost {
|
|
|
208
206
|
return outgoing;
|
|
209
207
|
}
|
|
210
208
|
};
|
|
211
|
-
|
|
209
|
+
export default AliasPost;
|
|
@@ -1,23 +1,21 @@
|
|
|
1
|
-
|
|
1
|
+
import { validators } from '@eik/common';
|
|
2
|
+
import originalUrl from 'original-url';
|
|
3
|
+
import HttpError from 'http-errors';
|
|
4
|
+
import abslog from 'abslog';
|
|
5
|
+
import Metrics from '@metrics/client';
|
|
2
6
|
|
|
3
|
-
|
|
4
|
-
const originalUrl = require('original-url');
|
|
5
|
-
const HttpError = require('http-errors');
|
|
6
|
-
const abslog = require('abslog');
|
|
7
|
-
const Metrics = require('@metrics/client');
|
|
8
|
-
|
|
9
|
-
const {
|
|
7
|
+
import {
|
|
10
8
|
createFilePathToAlias,
|
|
11
9
|
createFilePathToAliasOrigin
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
10
|
+
} from '../utils/path-builders-fs.js';
|
|
11
|
+
import { decodeUriComponent, writeJSON } from '../utils/utils.js';
|
|
12
|
+
import { createURIToAlias } from '../utils/path-builders-uri.js';
|
|
13
|
+
import MultipartParser from '../multipart/parser.js';
|
|
14
|
+
import HttpIncoming from '../classes/http-incoming.js';
|
|
15
|
+
import HttpOutgoing from '../classes/http-outgoing.js';
|
|
16
|
+
import Author from '../classes/author.js';
|
|
17
|
+
import Alias from '../classes/alias.js';
|
|
18
|
+
import config from '../utils/defaults.js';
|
|
21
19
|
|
|
22
20
|
const AliasPut = class AliasPut {
|
|
23
21
|
constructor({
|
|
@@ -112,7 +110,7 @@ const AliasPut = class AliasPut {
|
|
|
112
110
|
);
|
|
113
111
|
|
|
114
112
|
try {
|
|
115
|
-
await
|
|
113
|
+
await writeJSON(
|
|
116
114
|
this._sink,
|
|
117
115
|
path,
|
|
118
116
|
alias,
|
|
@@ -151,8 +149,8 @@ const AliasPut = class AliasPut {
|
|
|
151
149
|
async handler(req, user, type, name, alias) {
|
|
152
150
|
const end = this._histogram.timer();
|
|
153
151
|
|
|
154
|
-
const pAlias =
|
|
155
|
-
const pName =
|
|
152
|
+
const pAlias = decodeUriComponent(alias);
|
|
153
|
+
const pName = decodeUriComponent(name);
|
|
156
154
|
|
|
157
155
|
try {
|
|
158
156
|
validators.alias(pAlias);
|
|
@@ -207,4 +205,4 @@ const AliasPut = class AliasPut {
|
|
|
207
205
|
return outgoing;
|
|
208
206
|
}
|
|
209
207
|
};
|
|
210
|
-
|
|
208
|
+
export default AliasPut;
|
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
import originalUrl from 'original-url';
|
|
2
|
+
import HttpError from 'http-errors';
|
|
3
|
+
import Metrics from '@metrics/client';
|
|
4
|
+
import abslog from 'abslog';
|
|
2
5
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const MultipartParser = require('../multipart/parser');
|
|
9
|
-
const HttpIncoming = require('../classes/http-incoming');
|
|
10
|
-
const HttpOutgoing = require('../classes/http-outgoing');
|
|
11
|
-
const Author = require('../classes/author');
|
|
12
|
-
const config = require('../utils/defaults');
|
|
6
|
+
import MultipartParser from '../multipart/parser.js';
|
|
7
|
+
import HttpIncoming from '../classes/http-incoming.js';
|
|
8
|
+
import HttpOutgoing from '../classes/http-outgoing.js';
|
|
9
|
+
import Author from '../classes/author.js';
|
|
10
|
+
import config from '../utils/defaults.js';
|
|
13
11
|
|
|
14
12
|
const AuthPost = class AuthPost {
|
|
15
13
|
constructor({
|
|
@@ -108,4 +106,4 @@ const AuthPost = class AuthPost {
|
|
|
108
106
|
return outgoing;
|
|
109
107
|
}
|
|
110
108
|
};
|
|
111
|
-
|
|
109
|
+
export default AuthPost;
|
package/lib/handlers/map.get.js
CHANGED
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
import { validators } from '@eik/common';
|
|
2
|
+
import originalUrl from 'original-url';
|
|
3
|
+
import HttpError from 'http-errors';
|
|
4
|
+
import abslog from 'abslog';
|
|
5
|
+
import Metrics from '@metrics/client';
|
|
2
6
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const Metrics = require('@metrics/client');
|
|
8
|
-
|
|
9
|
-
const { createFilePathToImportMap } = require('../utils/path-builders-fs');
|
|
10
|
-
const HttpOutgoing = require('../classes/http-outgoing');
|
|
11
|
-
const config = require('../utils/defaults');
|
|
12
|
-
const utils = require('../utils/utils');
|
|
7
|
+
import { createFilePathToImportMap } from '../utils/path-builders-fs.js';
|
|
8
|
+
import HttpOutgoing from '../classes/http-outgoing.js';
|
|
9
|
+
import config from '../utils/defaults.js';
|
|
10
|
+
import { decodeUriComponent } from '../utils/utils.js';
|
|
13
11
|
|
|
14
12
|
const MapGet = class MapGet {
|
|
15
13
|
constructor({
|
|
@@ -55,8 +53,8 @@ const MapGet = class MapGet {
|
|
|
55
53
|
async handler(req, name, version) {
|
|
56
54
|
const end = this._histogram.timer();
|
|
57
55
|
|
|
58
|
-
const pVersion =
|
|
59
|
-
const pName =
|
|
56
|
+
const pVersion = decodeUriComponent(version);
|
|
57
|
+
const pName = decodeUriComponent(name);
|
|
60
58
|
|
|
61
59
|
try {
|
|
62
60
|
validators.version(pVersion);
|
|
@@ -116,4 +114,4 @@ const MapGet = class MapGet {
|
|
|
116
114
|
}
|
|
117
115
|
}
|
|
118
116
|
};
|
|
119
|
-
|
|
117
|
+
export default MapGet;
|
package/lib/handlers/map.put.js
CHANGED
|
@@ -1,24 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const {
|
|
1
|
+
import { validators } from '@eik/common';
|
|
2
|
+
import originalUrl from 'original-url';
|
|
3
|
+
import HttpError from 'http-errors';
|
|
4
|
+
import Busboy from 'busboy';
|
|
5
|
+
import crypto from 'node:crypto';
|
|
6
|
+
import abslog from 'abslog';
|
|
7
|
+
import Metrics from '@metrics/client';
|
|
8
|
+
|
|
9
|
+
import {
|
|
12
10
|
createFilePathToImportMap,
|
|
13
11
|
createFilePathToVersion,
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
12
|
+
} from '../utils/path-builders-fs.js';
|
|
13
|
+
import { createURIPathToImportMap } from '../utils/path-builders-uri.js';
|
|
14
|
+
import HttpIncoming from '../classes/http-incoming.js';
|
|
15
|
+
import HttpOutgoing from '../classes/http-outgoing.js';
|
|
16
|
+
import Versions from '../classes/versions.js';
|
|
17
|
+
import Author from '../classes/author.js';
|
|
18
|
+
import config from '../utils/defaults.js';
|
|
19
|
+
import { decodeUriComponent, streamCollector, writeJSON, readJSON, } from '../utils/utils.js';
|
|
22
20
|
|
|
23
21
|
const MapPut = class MapPut {
|
|
24
22
|
constructor({
|
|
@@ -118,7 +116,7 @@ const MapPut = class MapPut {
|
|
|
118
116
|
// parse it as JSON or not.
|
|
119
117
|
let obj = {};
|
|
120
118
|
try {
|
|
121
|
-
const str = await
|
|
119
|
+
const str = await streamCollector(file);
|
|
122
120
|
hasher.update(str);
|
|
123
121
|
obj = JSON.parse(str);
|
|
124
122
|
} catch (error) {
|
|
@@ -130,7 +128,7 @@ const MapPut = class MapPut {
|
|
|
130
128
|
// Write file to storage.
|
|
131
129
|
try {
|
|
132
130
|
this._log.info(`map:put - Start writing import map to sink - Pathname: ${path}`);
|
|
133
|
-
await
|
|
131
|
+
await writeJSON(this._sink, path, obj, 'application/json');
|
|
134
132
|
} catch (error) {
|
|
135
133
|
this._log.error(`map:put - Failed writing import map to sink - Pathname: ${path}`);
|
|
136
134
|
this._log.trace(error);
|
|
@@ -146,7 +144,7 @@ const MapPut = class MapPut {
|
|
|
146
144
|
const path = createFilePathToVersion(incoming);
|
|
147
145
|
let versions;
|
|
148
146
|
try {
|
|
149
|
-
const obj = await
|
|
147
|
+
const obj = await readJSON(this._sink, path);
|
|
150
148
|
versions = new Versions(obj);
|
|
151
149
|
this._log.info(
|
|
152
150
|
`map:put - Successfully read version meta file from sink - Pathname: ${path}`,
|
|
@@ -163,7 +161,7 @@ const MapPut = class MapPut {
|
|
|
163
161
|
|
|
164
162
|
async _writeVersions(incoming, versions) {
|
|
165
163
|
const path = createFilePathToVersion(incoming);
|
|
166
|
-
await
|
|
164
|
+
await writeJSON(this._sink, path, versions, 'application/json');
|
|
167
165
|
this._log.info(
|
|
168
166
|
`map:put - Successfully wrote version meta file to sink - Pathname: ${path}`,
|
|
169
167
|
);
|
|
@@ -172,8 +170,8 @@ const MapPut = class MapPut {
|
|
|
172
170
|
async handler(req, user, name, version) {
|
|
173
171
|
const end = this._histogram.timer();
|
|
174
172
|
|
|
175
|
-
const pVersion =
|
|
176
|
-
const pName =
|
|
173
|
+
const pVersion = decodeUriComponent(version);
|
|
174
|
+
const pName = decodeUriComponent(name);
|
|
177
175
|
|
|
178
176
|
try {
|
|
179
177
|
validators.version(pVersion);
|
|
@@ -237,4 +235,4 @@ const MapPut = class MapPut {
|
|
|
237
235
|
return outgoing;
|
|
238
236
|
}
|
|
239
237
|
};
|
|
240
|
-
|
|
238
|
+
export default MapPut;
|
package/lib/handlers/pkg.get.js
CHANGED
|
@@ -1,16 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const config = require('../utils/defaults');
|
|
13
|
-
const utils = require('../utils/utils');
|
|
1
|
+
import { validators } from '@eik/common';
|
|
2
|
+
import originalUrl from 'original-url';
|
|
3
|
+
import HttpError from 'http-errors';
|
|
4
|
+
import abslog from 'abslog';
|
|
5
|
+
import Metrics from '@metrics/client';
|
|
6
|
+
|
|
7
|
+
import { createFilePathToAsset } from '../utils/path-builders-fs.js';
|
|
8
|
+
import { decodeUriComponent } from '../utils/utils.js';
|
|
9
|
+
import HttpOutgoing from '../classes/http-outgoing.js';
|
|
10
|
+
import Asset from '../classes/asset.js';
|
|
11
|
+
import config from '../utils/defaults.js';
|
|
14
12
|
|
|
15
13
|
const PkgGet = class PkgGet {
|
|
16
14
|
constructor({
|
|
@@ -56,9 +54,9 @@ const PkgGet = class PkgGet {
|
|
|
56
54
|
async handler(req, type, name, version, extra) {
|
|
57
55
|
const end = this._histogram.timer();
|
|
58
56
|
|
|
59
|
-
const pVersion =
|
|
60
|
-
const pExtra =
|
|
61
|
-
const pName =
|
|
57
|
+
const pVersion = decodeUriComponent(version);
|
|
58
|
+
const pExtra = decodeUriComponent(extra);
|
|
59
|
+
const pName = decodeUriComponent(name);
|
|
62
60
|
|
|
63
61
|
try {
|
|
64
62
|
validators.version(pVersion);
|
|
@@ -126,4 +124,4 @@ const PkgGet = class PkgGet {
|
|
|
126
124
|
}
|
|
127
125
|
}
|
|
128
126
|
};
|
|
129
|
-
|
|
127
|
+
export default PkgGet;
|
package/lib/handlers/pkg.log.js
CHANGED
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
import { validators } from '@eik/common';
|
|
2
|
+
import originalUrl from 'original-url';
|
|
3
|
+
import HttpError from 'http-errors';
|
|
4
|
+
import abslog from 'abslog';
|
|
5
|
+
import Metrics from '@metrics/client';
|
|
2
6
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const Metrics = require('@metrics/client');
|
|
8
|
-
|
|
9
|
-
const { createFilePathToPackage } = require('../utils/path-builders-fs');
|
|
10
|
-
const HttpOutgoing = require('../classes/http-outgoing');
|
|
11
|
-
const config = require('../utils/defaults');
|
|
12
|
-
const utils = require('../utils/utils');
|
|
7
|
+
import { createFilePathToPackage } from '../utils/path-builders-fs.js';
|
|
8
|
+
import { decodeUriComponent } from '../utils/utils.js';
|
|
9
|
+
import HttpOutgoing from '../classes/http-outgoing.js';
|
|
10
|
+
import config from '../utils/defaults.js';
|
|
13
11
|
|
|
14
12
|
const PkgLog = class PkgLog {
|
|
15
13
|
constructor({
|
|
@@ -54,8 +52,8 @@ const PkgLog = class PkgLog {
|
|
|
54
52
|
async handler(req, type, name, version) {
|
|
55
53
|
const end = this._histogram.timer();
|
|
56
54
|
|
|
57
|
-
const pVersion =
|
|
58
|
-
const pName =
|
|
55
|
+
const pVersion = decodeUriComponent(version);
|
|
56
|
+
const pName = decodeUriComponent(name);
|
|
59
57
|
|
|
60
58
|
try {
|
|
61
59
|
validators.version(pVersion);
|
|
@@ -114,4 +112,4 @@ const PkgLog = class PkgLog {
|
|
|
114
112
|
}
|
|
115
113
|
}
|
|
116
114
|
};
|
|
117
|
-
|
|
115
|
+
export default PkgLog;
|
package/lib/handlers/pkg.put.js
CHANGED
|
@@ -1,25 +1,22 @@
|
|
|
1
|
-
|
|
1
|
+
import { validators } from '@eik/common';
|
|
2
|
+
import originalUrl from 'original-url';
|
|
3
|
+
import HttpError from 'http-errors';
|
|
4
|
+
import Metrics from '@metrics/client';
|
|
5
|
+
import abslog from 'abslog';
|
|
2
6
|
|
|
3
|
-
|
|
4
|
-
const originalUrl = require('original-url');
|
|
5
|
-
const HttpError = require('http-errors');
|
|
6
|
-
const Metrics = require('@metrics/client');
|
|
7
|
-
const abslog = require('abslog');
|
|
8
|
-
|
|
9
|
-
const {
|
|
7
|
+
import {
|
|
10
8
|
createFilePathToPackage,
|
|
11
9
|
createFilePathToVersion,
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
const MultipartParser = require('../multipart/parser');
|
|
10
|
+
} from '../utils/path-builders-fs.js';
|
|
11
|
+
import { decodeUriComponent, writeJSON, readJSON } from '../utils/utils.js';
|
|
12
|
+
import { createURIPathToPkgLog } from '../utils/path-builders-uri.js';
|
|
13
|
+
import MultipartParser from '../multipart/parser.js';
|
|
14
|
+
import HttpIncoming from '../classes/http-incoming.js';
|
|
15
|
+
import HttpOutgoing from '../classes/http-outgoing.js';
|
|
16
|
+
import Versions from '../classes/versions.js';
|
|
17
|
+
import Package from '../classes/package.js';
|
|
18
|
+
import Author from '../classes/author.js';
|
|
19
|
+
import config from '../utils/defaults.js';
|
|
23
20
|
|
|
24
21
|
const PkgPut = class PkgPut {
|
|
25
22
|
constructor({
|
|
@@ -84,7 +81,7 @@ const PkgPut = class PkgPut {
|
|
|
84
81
|
return pkg;
|
|
85
82
|
}).then(async (pkg) => {
|
|
86
83
|
const path = createFilePathToPackage(pkg);
|
|
87
|
-
await
|
|
84
|
+
await writeJSON(
|
|
88
85
|
this._sink,
|
|
89
86
|
path,
|
|
90
87
|
pkg,
|
|
@@ -106,7 +103,7 @@ const PkgPut = class PkgPut {
|
|
|
106
103
|
const path = createFilePathToVersion(incoming);
|
|
107
104
|
let versions;
|
|
108
105
|
try {
|
|
109
|
-
const obj = await
|
|
106
|
+
const obj = await readJSON(this._sink, path);
|
|
110
107
|
versions = new Versions(obj);
|
|
111
108
|
this._log.info(
|
|
112
109
|
`pkg:put - Successfully read version meta file from sink - Pathname: ${path}`,
|
|
@@ -123,7 +120,7 @@ const PkgPut = class PkgPut {
|
|
|
123
120
|
|
|
124
121
|
async _writeVersions(incoming, versions) {
|
|
125
122
|
const path = createFilePathToVersion(incoming);
|
|
126
|
-
await
|
|
123
|
+
await writeJSON(this._sink, path, versions, 'application/json');
|
|
127
124
|
this._log.info(
|
|
128
125
|
`pkg:put - Successfully wrote version meta file to sink - Pathname: ${path}`,
|
|
129
126
|
);
|
|
@@ -132,8 +129,8 @@ const PkgPut = class PkgPut {
|
|
|
132
129
|
async handler(req, user, type, name, version) {
|
|
133
130
|
const end = this._histogram.timer();
|
|
134
131
|
|
|
135
|
-
const pVersion =
|
|
136
|
-
const pName =
|
|
132
|
+
const pVersion = decodeUriComponent(version);
|
|
133
|
+
const pName = decodeUriComponent(name);
|
|
137
134
|
|
|
138
135
|
try {
|
|
139
136
|
validators.version(pVersion);
|
|
@@ -198,4 +195,4 @@ const PkgPut = class PkgPut {
|
|
|
198
195
|
return outgoing;
|
|
199
196
|
}
|
|
200
197
|
};
|
|
201
|
-
|
|
198
|
+
export default PkgPut;
|
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
import { validators } from '@eik/common';
|
|
2
|
+
import originalUrl from 'original-url';
|
|
3
|
+
import HttpError from 'http-errors';
|
|
4
|
+
import Metrics from '@metrics/client';
|
|
5
|
+
import abslog from 'abslog';
|
|
2
6
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const abslog = require('abslog');
|
|
8
|
-
|
|
9
|
-
const { createFilePathToVersion } = require('../utils/path-builders-fs');
|
|
10
|
-
const HttpOutgoing = require('../classes/http-outgoing');
|
|
11
|
-
const config = require('../utils/defaults');
|
|
12
|
-
const utils = require('../utils/utils');
|
|
7
|
+
import { createFilePathToVersion } from '../utils/path-builders-fs.js';
|
|
8
|
+
import { decodeUriComponent } from '../utils/utils.js';
|
|
9
|
+
import HttpOutgoing from '../classes/http-outgoing.js';
|
|
10
|
+
import config from '../utils/defaults.js';
|
|
13
11
|
|
|
14
12
|
const VersionsGet = class VersionsGet {
|
|
15
13
|
constructor({
|
|
@@ -55,7 +53,7 @@ const VersionsGet = class VersionsGet {
|
|
|
55
53
|
async handler(req, type, name) {
|
|
56
54
|
const end = this._histogram.timer();
|
|
57
55
|
|
|
58
|
-
const pName =
|
|
56
|
+
const pName = decodeUriComponent(name);
|
|
59
57
|
|
|
60
58
|
try {
|
|
61
59
|
validators.name(pName);
|
|
@@ -118,4 +116,4 @@ const VersionsGet = class VersionsGet {
|
|
|
118
116
|
}
|
|
119
117
|
}
|
|
120
118
|
};
|
|
121
|
-
|
|
119
|
+
export default VersionsGet;
|
package/lib/main.js
CHANGED
|
@@ -1,26 +1,22 @@
|
|
|
1
|
-
|
|
1
|
+
import VersionsGet from './handlers/versions.get.js';
|
|
2
|
+
import AliasPost from './handlers/alias.post.js';
|
|
3
|
+
import AliasPut from './handlers/alias.put.js';
|
|
4
|
+
import AliasGet from './handlers/alias.get.js';
|
|
5
|
+
import AliasDel from './handlers/alias.delete.js';
|
|
6
|
+
import AuthPost from './handlers/auth.post.js';
|
|
7
|
+
import PkgLog from './handlers/pkg.log.js';
|
|
8
|
+
import PkgGet from './handlers/pkg.get.js';
|
|
9
|
+
import PkgPut from './handlers/pkg.put.js';
|
|
10
|
+
import MapGet from './handlers/map.get.js';
|
|
11
|
+
import MapPut from './handlers/map.put.js';
|
|
2
12
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const AliasPut = require('./handlers/alias.put');
|
|
6
|
-
const AliasGet = require('./handlers/alias.get');
|
|
7
|
-
const AliasDel = require('./handlers/alias.delete');
|
|
8
|
-
const AuthPost = require('./handlers/auth.post');
|
|
9
|
-
const PkgLog = require('./handlers/pkg.log');
|
|
10
|
-
const PkgGet = require('./handlers/pkg.get');
|
|
11
|
-
const PkgPut = require('./handlers/pkg.put');
|
|
12
|
-
const MapGet = require('./handlers/map.get');
|
|
13
|
-
const MapPut = require('./handlers/map.put');
|
|
13
|
+
import MEM from './sinks/mem.js';
|
|
14
|
+
import FS from './sinks/fs.js';
|
|
14
15
|
|
|
15
|
-
|
|
16
|
-
|
|
16
|
+
import HealthCheck from './utils/healthcheck.js';
|
|
17
|
+
import globals from './utils/globals.js';
|
|
17
18
|
|
|
18
|
-
const
|
|
19
|
-
const globals = require('./utils/globals');
|
|
20
|
-
|
|
21
|
-
module.exports.HealthCheck = HealthCheck;
|
|
22
|
-
|
|
23
|
-
module.exports.http = {
|
|
19
|
+
const http = {
|
|
24
20
|
VersionsGet,
|
|
25
21
|
AliasPost,
|
|
26
22
|
AliasPut,
|
|
@@ -34,14 +30,21 @@ module.exports.http = {
|
|
|
34
30
|
MapPut,
|
|
35
31
|
};
|
|
36
32
|
|
|
37
|
-
|
|
33
|
+
const sink = {
|
|
38
34
|
MEM,
|
|
39
35
|
FS,
|
|
40
36
|
};
|
|
41
37
|
|
|
42
|
-
|
|
38
|
+
const prop = {
|
|
43
39
|
base_auth: globals.BASE_AUTHENTICATION,
|
|
44
40
|
base_map: globals.BASE_IMPORT_MAPS,
|
|
45
41
|
base_pkg: globals.BASE_PACKAGES,
|
|
46
42
|
base_npm: globals.BASE_NPM,
|
|
47
43
|
};
|
|
44
|
+
|
|
45
|
+
export default {
|
|
46
|
+
HealthCheck,
|
|
47
|
+
http,
|
|
48
|
+
sink,
|
|
49
|
+
prop,
|
|
50
|
+
}
|
package/lib/multipart/parser.js
CHANGED
|
@@ -1,16 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const FormFile = require('./form-file');
|
|
13
|
-
const Asset = require('../classes/asset');
|
|
1
|
+
import { pipeline } from 'node:stream';
|
|
2
|
+
import HttpError from 'http-errors';
|
|
3
|
+
import Busboy from 'busboy';
|
|
4
|
+
import abslog from 'abslog';
|
|
5
|
+
import ssri from 'ssri';
|
|
6
|
+
import tar from 'tar';
|
|
7
|
+
|
|
8
|
+
import { createFilePathToAsset } from '../utils/path-builders-fs.js';
|
|
9
|
+
import FormField from './form-field.js';
|
|
10
|
+
import FormFile from './form-file.js';
|
|
11
|
+
import Asset from '../classes/asset.js';
|
|
14
12
|
|
|
15
13
|
const MultipartParser = class MultipartParser {
|
|
16
14
|
constructor({
|
|
@@ -216,4 +214,4 @@ const MultipartParser = class MultipartParser {
|
|
|
216
214
|
});
|
|
217
215
|
}
|
|
218
216
|
}
|
|
219
|
-
|
|
217
|
+
export default MultipartParser;
|
package/lib/sinks/fs.js
CHANGED
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
import { ReadFile } from '@eik/common';
|
|
2
|
+
import Metrics from '@metrics/client';
|
|
3
|
+
import rimraf from 'rimraf';
|
|
4
|
+
import Sink from '@eik/sink';
|
|
5
|
+
import mime from 'mime';
|
|
6
|
+
import path from 'node:path';
|
|
7
|
+
import fs from 'node:fs';
|
|
2
8
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const rimraf = require('rimraf');
|
|
6
|
-
const Sink = require('@eik/sink');
|
|
7
|
-
const mime = require('mime/lite');
|
|
8
|
-
const path = require('path');
|
|
9
|
-
const fs = require('fs');
|
|
10
|
-
|
|
11
|
-
const { etagFromFsStat } = require('../utils/utils');
|
|
12
|
-
const conf = require('../utils/defaults');
|
|
9
|
+
import { etagFromFsStat } from '../utils/utils.js';
|
|
10
|
+
import conf from '../utils/defaults.js';
|
|
13
11
|
|
|
14
12
|
/**
|
|
15
13
|
* A sink for persisting files to local file system
|
|
@@ -263,4 +261,4 @@ const SinkFS = class SinkFS extends Sink {
|
|
|
263
261
|
return 'SinkFS';
|
|
264
262
|
}
|
|
265
263
|
}
|
|
266
|
-
|
|
264
|
+
export default SinkFS;
|
package/lib/sinks/mem-entry.js
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const crypto = require('crypto');
|
|
1
|
+
import crypto from 'node:crypto';
|
|
4
2
|
|
|
5
3
|
const Entry = class Entry {
|
|
6
4
|
constructor({
|
|
@@ -38,4 +36,5 @@ const Entry = class Entry {
|
|
|
38
36
|
return 'Entry';
|
|
39
37
|
}
|
|
40
38
|
}
|
|
41
|
-
|
|
39
|
+
|
|
40
|
+
export default Entry;
|
package/lib/sinks/mem.js
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
import { Writable, Readable } from 'node:stream';
|
|
2
|
+
import { ReadFile } from '@eik/common';
|
|
3
|
+
import { join } from 'node:path';
|
|
4
|
+
import Metrics from '@metrics/client';
|
|
5
|
+
import Sink from '@eik/sink';
|
|
2
6
|
|
|
3
|
-
|
|
4
|
-
const { ReadFile } = require('@eik/common');
|
|
5
|
-
const { join } = require('path');
|
|
6
|
-
const Metrics = require('@metrics/client');
|
|
7
|
-
const Sink = require('@eik/sink');
|
|
8
|
-
|
|
9
|
-
const Entry = require('./mem-entry');
|
|
7
|
+
import Entry from './mem-entry.js';
|
|
10
8
|
|
|
11
9
|
const DEFAULT_ROOT_PATH = '/eik';
|
|
12
10
|
|
|
@@ -209,4 +207,4 @@ const SinkMem = class SinkMem extends Sink {
|
|
|
209
207
|
return 'SinkMEM';
|
|
210
208
|
}
|
|
211
209
|
}
|
|
212
|
-
|
|
210
|
+
export default SinkMem;
|
package/lib/sinks/test.js
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
import { Writable, Readable } from 'node:stream';
|
|
2
|
+
import { ReadFile } from '@eik/common';
|
|
3
|
+
import Metrics from '@metrics/client';
|
|
4
|
+
import Sink from '@eik/sink';
|
|
5
|
+
import mime from 'mime';
|
|
6
|
+
import path from 'node:path';
|
|
2
7
|
|
|
3
|
-
|
|
4
|
-
const { ReadFile } = require('@eik/common');
|
|
5
|
-
const Metrics = require('@metrics/client');
|
|
6
|
-
const Sink = require('@eik/sink');
|
|
7
|
-
const mime = require('mime/lite');
|
|
8
|
-
const path = require('path');
|
|
9
|
-
|
|
10
|
-
const Entry = require('./mem-entry');
|
|
8
|
+
import Entry from './mem-entry.js';
|
|
11
9
|
|
|
12
10
|
const DEFAULT_ROOT_PATH = '/eik';
|
|
13
11
|
|
|
@@ -278,4 +276,5 @@ const SinkTest = class SinkTest extends Sink {
|
|
|
278
276
|
return 'SinkTest';
|
|
279
277
|
}
|
|
280
278
|
}
|
|
281
|
-
|
|
279
|
+
|
|
280
|
+
export default SinkTest;
|
package/lib/utils/defaults.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const path = require('path');
|
|
4
|
-
const os = require('os');
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import os from 'node:os';
|
|
5
3
|
|
|
6
4
|
const config = {
|
|
7
5
|
authKey: 'change_me',
|
|
@@ -14,4 +12,5 @@ const config = {
|
|
|
14
12
|
['127.0.0.1', 'local'],
|
|
15
13
|
],
|
|
16
14
|
};
|
|
17
|
-
|
|
15
|
+
|
|
16
|
+
export default config;
|
package/lib/utils/globals.js
CHANGED
package/lib/utils/healthcheck.js
CHANGED
|
@@ -1,15 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
import { Writable, pipeline } from 'node:stream';
|
|
2
|
+
import { URL } from 'node:url';
|
|
3
|
+
import abslog from 'abslog';
|
|
4
|
+
import slug from 'unique-slug';
|
|
5
|
+
import fs from 'node:fs';
|
|
2
6
|
|
|
3
|
-
const
|
|
4
|
-
const abslog = require('abslog');
|
|
5
|
-
const slug = require('unique-slug');
|
|
6
|
-
const path = require('path');
|
|
7
|
-
const fs = require('fs');
|
|
8
|
-
|
|
9
|
-
const fileReader = (file = '../../README.md') => {
|
|
10
|
-
const pathname = path.join(__dirname, file);
|
|
11
|
-
return fs.createReadStream(pathname);
|
|
12
|
-
};
|
|
7
|
+
const fileReader = (file = '../../README.md') => fs.createReadStream(new URL(file, import.meta.url));
|
|
13
8
|
|
|
14
9
|
const HealthCheck = class HealthCheck {
|
|
15
10
|
constructor({ sink, logger } = {}) {
|
|
@@ -112,4 +107,5 @@ const HealthCheck = class HealthCheck {
|
|
|
112
107
|
return 'HealthCheck';
|
|
113
108
|
}
|
|
114
109
|
}
|
|
115
|
-
|
|
110
|
+
|
|
111
|
+
export default HealthCheck;
|
|
@@ -1,37 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const path = require('path');
|
|
4
|
-
const { BASE_IMPORT_MAPS, ROOT } = require("./globals");
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import globals from './globals.js';
|
|
5
3
|
|
|
6
4
|
|
|
7
5
|
// Build file system path to a package file
|
|
8
6
|
|
|
9
|
-
const createFilePathToPackage = ({ org = '', type = '', name = '', version = '' } = {}) => path.join(ROOT, org, type, name, `${version}.package.json`)
|
|
10
|
-
module.exports.createFilePathToPackage = createFilePathToPackage;
|
|
7
|
+
const createFilePathToPackage = ({ org = '', type = '', name = '', version = '' } = {}) => path.join(globals.ROOT, org, type, name, `${version}.package.json`)
|
|
11
8
|
|
|
12
9
|
|
|
13
10
|
// Build file system path to an asset in a package
|
|
14
11
|
// pkgAsset
|
|
15
|
-
const createFilePathToAsset = ({ org = '', type = '', name = '', version = '', asset = '' } = {}) => path.join(ROOT, org, type, name, version, asset)
|
|
16
|
-
module.exports.createFilePathToAsset = createFilePathToAsset;
|
|
12
|
+
const createFilePathToAsset = ({ org = '', type = '', name = '', version = '', asset = '' } = {}) => path.join(globals.ROOT, org, type, name, version, asset)
|
|
17
13
|
|
|
18
14
|
|
|
19
15
|
// Build file system path to an import map
|
|
20
16
|
|
|
21
|
-
const createFilePathToImportMap = ({ org = '', name = '', version = '' } = {}) => path.join(ROOT, org, BASE_IMPORT_MAPS, name, `${version}.import-map.json`)
|
|
22
|
-
module.exports.createFilePathToImportMap = createFilePathToImportMap;
|
|
17
|
+
const createFilePathToImportMap = ({ org = '', name = '', version = '' } = {}) => path.join(globals.ROOT, org, globals.BASE_IMPORT_MAPS, name, `${version}.import-map.json`)
|
|
23
18
|
|
|
24
19
|
|
|
25
20
|
// Build file system path to an alias file
|
|
26
21
|
|
|
27
|
-
const createFilePathToAlias = ({ org = '', type = '', name = '', alias = '' } = {}) => path.join(ROOT, org, type, name, `${alias}.alias.json`)
|
|
28
|
-
module.exports.createFilePathToAlias = createFilePathToAlias;
|
|
22
|
+
const createFilePathToAlias = ({ org = '', type = '', name = '', alias = '' } = {}) => path.join(globals.ROOT, org, type, name, `${alias}.alias.json`)
|
|
29
23
|
|
|
30
24
|
|
|
31
25
|
// Build file system path to an version file
|
|
32
26
|
|
|
33
|
-
const createFilePathToVersion = ({ org = '', type = '', name = '' } = {}) => path.join(ROOT, org, type, name, 'versions.json')
|
|
34
|
-
module.exports.createFilePathToVersion = createFilePathToVersion;
|
|
27
|
+
const createFilePathToVersion = ({ org = '', type = '', name = '' } = {}) => path.join(globals.ROOT, org, type, name, 'versions.json')
|
|
35
28
|
|
|
36
29
|
const createFilePathToAliasOrigin = ({org = '', type = '', name = '', version = '',} = {}) => {
|
|
37
30
|
if(type === 'map') {
|
|
@@ -39,4 +32,13 @@ const createFilePathToAliasOrigin = ({org = '', type = '', name = '', version =
|
|
|
39
32
|
}
|
|
40
33
|
return createFilePathToPackage({org, type, name, version})
|
|
41
34
|
};
|
|
42
|
-
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
export {
|
|
38
|
+
createFilePathToPackage,
|
|
39
|
+
createFilePathToAsset,
|
|
40
|
+
createFilePathToImportMap,
|
|
41
|
+
createFilePathToAlias,
|
|
42
|
+
createFilePathToVersion,
|
|
43
|
+
createFilePathToAliasOrigin,
|
|
44
|
+
}
|
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const path = require('path');
|
|
4
|
-
const { BASE_IMPORT_MAPS, ROOT } = require("./globals");
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import globals from './globals.js';
|
|
5
3
|
|
|
6
4
|
|
|
7
5
|
// Build URL pathname to a package log file
|
|
8
6
|
|
|
9
|
-
const createURIPathToPkgLog = ({ type = '', name = '', version = '' } = {}) => path.join(ROOT, type, name, version)
|
|
10
|
-
module.exports.createURIPathToPkgLog = createURIPathToPkgLog;
|
|
7
|
+
const createURIPathToPkgLog = ({ type = '', name = '', version = '' } = {}) => path.join(globals.ROOT, type, name, version)
|
|
11
8
|
|
|
12
9
|
|
|
13
10
|
// Build URL pathname to an asset in a package
|
|
14
11
|
|
|
15
|
-
const createURIPathToAsset = ({ type = '', name = '', version = '', asset = '' } = {}) => path.join(ROOT, type, name, version, asset)
|
|
16
|
-
module.exports.createURIPathToAsset = createURIPathToAsset;
|
|
12
|
+
const createURIPathToAsset = ({ type = '', name = '', version = '', asset = '' } = {}) => path.join(globals.ROOT, type, name, version, asset)
|
|
17
13
|
|
|
18
14
|
|
|
19
15
|
// Build URL pathname to an import map
|
|
20
16
|
|
|
21
|
-
const createURIPathToImportMap = ({ name = '', version = '' } = {}) => path.join(ROOT, BASE_IMPORT_MAPS, name, version)
|
|
22
|
-
module.exports.createURIPathToImportMap = createURIPathToImportMap;
|
|
17
|
+
const createURIPathToImportMap = ({ name = '', version = '' } = {}) => path.join(globals.ROOT, globals.BASE_IMPORT_MAPS, name, version)
|
|
23
18
|
|
|
24
19
|
|
|
25
20
|
// Build URL pathname to an alias source
|
|
26
21
|
|
|
27
|
-
const createURIToAlias = ({ type = '', name = '', alias = '' } = {}) => path.join(ROOT, type, name, `v${alias}`)
|
|
28
|
-
module.exports.createURIToAlias = createURIToAlias;
|
|
22
|
+
const createURIToAlias = ({ type = '', name = '', alias = '' } = {}) => path.join(globals.ROOT, type, name, `v${alias}`)
|
|
29
23
|
|
|
30
24
|
|
|
31
25
|
// Build URL pathname to an alias target destination
|
|
32
26
|
|
|
33
|
-
const createURIToTargetOfAlias = ({ type = '', name = '', version = '', extra = '' } = {}) => path.join(ROOT, type, name, version, extra)
|
|
34
|
-
module.exports.createURIToTargetOfAlias = createURIToTargetOfAlias;
|
|
27
|
+
const createURIToTargetOfAlias = ({ type = '', name = '', version = '', extra = '' } = {}) => path.join(globals.ROOT, type, name, version, extra)
|
|
35
28
|
|
|
29
|
+
export {
|
|
30
|
+
createURIPathToPkgLog,
|
|
31
|
+
createURIPathToAsset,
|
|
32
|
+
createURIPathToImportMap,
|
|
33
|
+
createURIToAlias,
|
|
34
|
+
createURIToTargetOfAlias,
|
|
35
|
+
}
|
package/lib/utils/utils.js
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const { Writable, Readable, pipeline } = require('stream');
|
|
1
|
+
import { Writable, Readable, pipeline } from 'node:stream';
|
|
4
2
|
|
|
5
3
|
const readJSON = (sink, path) =>
|
|
6
4
|
// eslint-disable-next-line no-async-promise-executor
|
|
@@ -32,7 +30,6 @@ const readJSON = (sink, path) =>
|
|
|
32
30
|
}
|
|
33
31
|
})
|
|
34
32
|
;
|
|
35
|
-
module.exports.readJSON = readJSON;
|
|
36
33
|
|
|
37
34
|
const writeJSON = (sink, path, obj, contentType) =>
|
|
38
35
|
// eslint-disable-next-line no-async-promise-executor
|
|
@@ -59,7 +56,6 @@ const writeJSON = (sink, path, obj, contentType) =>
|
|
|
59
56
|
}
|
|
60
57
|
})
|
|
61
58
|
;
|
|
62
|
-
module.exports.writeJSON = writeJSON;
|
|
63
59
|
|
|
64
60
|
const streamCollector = (from) => new Promise((resolve, reject) => {
|
|
65
61
|
const buffer = [];
|
|
@@ -75,18 +71,22 @@ const streamCollector = (from) => new Promise((resolve, reject) => {
|
|
|
75
71
|
return resolve(buffer.join('').toString());
|
|
76
72
|
});
|
|
77
73
|
});
|
|
78
|
-
module.exports.streamCollector = streamCollector;
|
|
79
74
|
|
|
80
75
|
const etagFromFsStat = (stat) => {
|
|
81
76
|
const mtime = stat.mtime.getTime().toString(16)
|
|
82
77
|
const size = stat.size.toString(16)
|
|
83
78
|
return `W/"${size}-${mtime}"`;
|
|
84
79
|
};
|
|
85
|
-
module.exports.etagFromFsStat = etagFromFsStat;
|
|
86
|
-
|
|
87
80
|
|
|
88
81
|
const decodeUriComponent = (value) => {
|
|
89
82
|
if (value === null || value === undefined) return value;
|
|
90
83
|
return decodeURIComponent(value);
|
|
91
84
|
}
|
|
92
|
-
|
|
85
|
+
|
|
86
|
+
export {
|
|
87
|
+
readJSON,
|
|
88
|
+
writeJSON,
|
|
89
|
+
streamCollector,
|
|
90
|
+
etagFromFsStat,
|
|
91
|
+
decodeUriComponent,
|
|
92
|
+
}
|
package/package.json
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eik/core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "Core server package",
|
|
5
5
|
"main": "lib/main.js",
|
|
6
|
+
"type": "module",
|
|
6
7
|
"files": [
|
|
7
8
|
"CHANGELOG.md",
|
|
8
9
|
"package.json",
|
|
@@ -33,6 +34,7 @@
|
|
|
33
34
|
"unique-slug": "2.0.2"
|
|
34
35
|
},
|
|
35
36
|
"devDependencies": {
|
|
37
|
+
"@babel/eslint-parser": "7.16.5",
|
|
36
38
|
"@semantic-release/changelog": "6.0.1",
|
|
37
39
|
"@semantic-release/git": "10.0.1",
|
|
38
40
|
"eslint": "8.6.0",
|
|
@@ -42,7 +44,7 @@
|
|
|
42
44
|
"eslint-plugin-prettier": "4.0.0",
|
|
43
45
|
"form-data": "4.0.0",
|
|
44
46
|
"mkdirp": "1.0.4",
|
|
45
|
-
"node-fetch": "
|
|
47
|
+
"node-fetch": "3.1.0",
|
|
46
48
|
"prettier": "2.5.1",
|
|
47
49
|
"semantic-release": "18.0.1",
|
|
48
50
|
"tap": "15.1.6"
|