@eik/node-client 2.0.0-next.3 → 2.0.0-next.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,24 @@
1
+ # [2.0.0-next.4](https://github.com/eik-lib/node-client/compare/v2.0.0-next.3...v2.0.0-next.4) (2022-08-22)
2
+
3
+
4
+ ### Features
5
+
6
+ * Remove support for CJS. ESM only ([#106](https://github.com/eik-lib/node-client/issues/106)) ([d74f8c8](https://github.com/eik-lib/node-client/commit/d74f8c8266b67119d8d110524533a0bd7ce19e7d))
7
+
8
+
9
+ ### BREAKING CHANGES
10
+
11
+ * This PR removes the support for CJS in this module. This module is now ESM only.
12
+
13
+ * feat: Remove CJS support. ESM only.
14
+ * Support for CJS is now removed in this module. It is ESM only.
15
+
16
+ * ci: use 0.0.0.0 instead of localhost
17
+
18
+ * fix: remove console.log() statement
19
+
20
+ Co-authored-by: Trygve Lie <trygve.lie@finn.no>
21
+
1
22
  # [2.0.0-next.3](https://github.com/eik-lib/node-client/compare/v2.0.0-next.2...v2.0.0-next.3) (2022-08-18)
2
23
 
3
24
 
package/package.json CHANGED
@@ -1,26 +1,19 @@
1
1
  {
2
2
  "name": "@eik/node-client",
3
- "version": "2.0.0-next.3",
3
+ "version": "2.0.0-next.4",
4
4
  "description": "A node.js client for interacting with a Eik server.",
5
5
  "type": "module",
6
- "main": "./dist/index.cjs",
7
- "exports": {
8
- "import": "./src/index.js",
9
- "require": "./dist/index.cjs"
10
- },
6
+ "main": "./src/index.js",
11
7
  "files": [
12
8
  "CHANGELOG.md",
13
9
  "package.json",
14
10
  "LICENSE",
15
- "dist",
16
11
  "src"
17
12
  ],
18
13
  "scripts": {
19
14
  "test": "tap --no-coverage",
20
15
  "lint:fix": "eslint --fix .",
21
- "lint": "eslint .",
22
- "prepare": "npm run -s build",
23
- "build": "rollup -c"
16
+ "lint": "eslint ."
24
17
  },
25
18
  "repository": {
26
19
  "type": "git",
@@ -50,7 +43,6 @@
50
43
  "eslint-plugin-import": "2.26.0",
51
44
  "eslint-plugin-prettier": "4.2.1",
52
45
  "prettier": "2.7.1",
53
- "rollup": "2.77.2",
54
46
  "semantic-release": "19.0.3",
55
47
  "tap": "16.3.0",
56
48
  "@babel/eslint-parser": "7.18.9"
package/dist/index.cjs DELETED
@@ -1,122 +0,0 @@
1
- 'use strict';
2
-
3
- var undici = require('undici');
4
- var path = require('path');
5
- var loader = require('@eik/common-config-loader');
6
-
7
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
-
9
- var loader__default = /*#__PURE__*/_interopDefaultLegacy(loader);
10
-
11
- class Asset {
12
- constructor({
13
- value = '',
14
- } = {}) {
15
- this.integrity = undefined;
16
- this.value = value;
17
- }
18
- }
19
-
20
- const trimSlash = (value = '') => {
21
- if (value.endsWith('/')) return value.substring(0, value.length - 1);
22
- return value;
23
- };
24
-
25
- const fetchImportMaps = async (urls = []) => {
26
- try{
27
- const maps = urls.map(async (map) => {
28
- const {
29
- statusCode,
30
- body
31
- } = await undici.request(map, { maxRedirections: 2 });
32
-
33
- if (statusCode === 404) {
34
- throw new Error('Import map could not be found on server');
35
- } else if (statusCode >= 400 && statusCode < 500) {
36
- throw new Error('Server rejected client request');
37
- } else if (statusCode >= 500) {
38
- throw new Error('Server error');
39
- }
40
- return body.json();
41
- });
42
- return await Promise.all(maps);
43
- } catch (err) {
44
- throw new Error(
45
- `Unable to load import map file from server: ${err.message}`,
46
- );
47
- }
48
- };
49
-
50
- class NodeClient {
51
- #development;
52
- #loadMaps;
53
- #config;
54
- #path;
55
- #base;
56
- #maps;
57
- constructor({
58
- development = false,
59
- loadMaps = false,
60
- base = '',
61
- path = process.cwd(),
62
- } = {}) {
63
- this.#development = development;
64
- this.#loadMaps = loadMaps;
65
- this.#config = {};
66
- this.#path = path;
67
- this.#base = trimSlash(base);
68
- this.#maps = [];
69
- }
70
-
71
- async load() {
72
- this.#config = await loader__default["default"].getDefaults(this.#path);
73
- if (this.#loadMaps) {
74
- this.#maps = await fetchImportMaps(this.#config.map);
75
- }
76
- }
77
-
78
- get name() {
79
- if (this.#config.name) return this.#config.name;
80
- throw new Error('Eik config was not loaded before calling .name');
81
- }
82
-
83
- get version() {
84
- if (this.#config.version) return this.#config.version;
85
- throw new Error('Eik config was not loaded before calling .version');
86
- }
87
-
88
- get type() {
89
- if (this.#config.type && this.#config.type === 'package') return 'pkg';
90
- if (this.#config.type) return this.#config.type;
91
- throw new Error('Eik config was not loaded before calling .type');
92
- }
93
-
94
- get server() {
95
- if (this.#config.server) return this.#config.server;
96
- throw new Error('Eik config was not loaded before calling .server');
97
- }
98
-
99
- get pathname() {
100
- if (this.#config.type && this.#config.name && this.#config.version) return path.join('/', this.type, this.name, this.version);
101
- throw new Error('Eik config was not loaded before calling .pathname');
102
- }
103
-
104
- base() {
105
- if (this.#development) return this.#base;
106
- return `${this.server}${this.pathname}`;
107
- }
108
-
109
- file(file = '') {
110
- const base = this.base();
111
- return new Asset({
112
- value: `${base}${file}`,
113
- });
114
- }
115
-
116
- maps() {
117
- if (this.#config.version && this.#loadMaps) return this.#maps;
118
- throw new Error('Eik config was not loaded or "loadMaps" is "false" when calling .maps()');
119
- }
120
- }
121
-
122
- module.exports = NodeClient;