@eik/node-client 2.0.0-next.1 → 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,38 @@
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
+
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)
23
+
24
+
25
+ ### Bug Fixes
26
+
27
+ * **deps:** update dependency undici to v5.8.2 ([652c0af](https://github.com/eik-lib/node-client/commit/652c0af76d4eff970ba8954d8f287703c30acd73))
28
+
29
+ # [2.0.0-next.2](https://github.com/eik-lib/node-client/compare/v2.0.0-next.1...v2.0.0-next.2) (2022-08-18)
30
+
31
+
32
+ ### Features
33
+
34
+ * Use the new @eik/common-config-loader module ([#104](https://github.com/eik-lib/node-client/issues/104)) ([5de927c](https://github.com/eik-lib/node-client/commit/5de927ca74c461be8d6bbd0048a2afc6812cb085))
35
+
1
36
  # [2.0.0-next.1](https://github.com/eik-lib/node-client/compare/v1.1.28...v2.0.0-next.1) (2022-08-08)
2
37
 
3
38
 
package/package.json CHANGED
@@ -1,26 +1,19 @@
1
1
  {
2
2
  "name": "@eik/node-client",
3
- "version": "2.0.0-next.1",
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",
@@ -37,9 +30,9 @@
37
30
  },
38
31
  "homepage": "https://github.com/eik-lib/node-client#readme",
39
32
  "dependencies": {
40
- "@eik/common": "3.0.1",
33
+ "@eik/common-config-loader": "4.0.0-next.8",
41
34
  "abslog": "2.4.0",
42
- "undici": "5.8.1"
35
+ "undici": "5.8.2"
43
36
  },
44
37
  "devDependencies": {
45
38
  "@semantic-release/changelog": "6.0.1",
@@ -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/src/index.js CHANGED
@@ -1,6 +1,6 @@
1
- import { helpers } from '@eik/common';
2
1
  import { request } from 'undici';
3
2
  import { join } from 'path';
3
+ import loader from '@eik/common-config-loader';
4
4
  import Asset from './asset.js';
5
5
 
6
6
  const trimSlash = (value = '') => {
@@ -55,7 +55,7 @@ export default class NodeClient {
55
55
  }
56
56
 
57
57
  async load() {
58
- this.#config = await helpers.getDefaults(this.#path);
58
+ this.#config = await loader.getDefaults(this.#path);
59
59
  if (this.#loadMaps) {
60
60
  this.#maps = await fetchImportMaps(this.#config.map);
61
61
  }
package/dist/index.cjs DELETED
@@ -1,118 +0,0 @@
1
- 'use strict';
2
-
3
- var common = require('@eik/common');
4
- var undici = require('undici');
5
- var path = require('path');
6
-
7
- class Asset {
8
- constructor({
9
- value = '',
10
- } = {}) {
11
- this.integrity = undefined;
12
- this.value = value;
13
- }
14
- }
15
-
16
- const trimSlash = (value = '') => {
17
- if (value.endsWith('/')) return value.substring(0, value.length - 1);
18
- return value;
19
- };
20
-
21
- const fetchImportMaps = async (urls = []) => {
22
- try{
23
- const maps = urls.map(async (map) => {
24
- const {
25
- statusCode,
26
- body
27
- } = await undici.request(map, { maxRedirections: 2 });
28
-
29
- if (statusCode === 404) {
30
- throw new Error('Import map could not be found on server');
31
- } else if (statusCode >= 400 && statusCode < 500) {
32
- throw new Error('Server rejected client request');
33
- } else if (statusCode >= 500) {
34
- throw new Error('Server error');
35
- }
36
- return body.json();
37
- });
38
- return await Promise.all(maps);
39
- } catch (err) {
40
- throw new Error(
41
- `Unable to load import map file from server: ${err.message}`,
42
- );
43
- }
44
- };
45
-
46
- class NodeClient {
47
- #development;
48
- #loadMaps;
49
- #config;
50
- #path;
51
- #base;
52
- #maps;
53
- constructor({
54
- development = false,
55
- loadMaps = false,
56
- base = '',
57
- path = process.cwd(),
58
- } = {}) {
59
- this.#development = development;
60
- this.#loadMaps = loadMaps;
61
- this.#config = {};
62
- this.#path = path;
63
- this.#base = trimSlash(base);
64
- this.#maps = [];
65
- }
66
-
67
- async load() {
68
- this.#config = await common.helpers.getDefaults(this.#path);
69
- if (this.#loadMaps) {
70
- this.#maps = await fetchImportMaps(this.#config.map);
71
- }
72
- }
73
-
74
- get name() {
75
- if (this.#config.name) return this.#config.name;
76
- throw new Error('Eik config was not loaded before calling .name');
77
- }
78
-
79
- get version() {
80
- if (this.#config.version) return this.#config.version;
81
- throw new Error('Eik config was not loaded before calling .version');
82
- }
83
-
84
- get type() {
85
- if (this.#config.type && this.#config.type === 'package') return 'pkg';
86
- if (this.#config.type) return this.#config.type;
87
- throw new Error('Eik config was not loaded before calling .type');
88
- }
89
-
90
- get server() {
91
- if (this.#config.server) return this.#config.server;
92
- throw new Error('Eik config was not loaded before calling .server');
93
- }
94
-
95
- get pathname() {
96
- if (this.#config.type && this.#config.name && this.#config.version) return path.join('/', this.type, this.name, this.version);
97
- throw new Error('Eik config was not loaded before calling .pathname');
98
- }
99
-
100
- base() {
101
- if (this.#development) return this.#base;
102
- return `${this.server}${this.pathname}`;
103
- }
104
-
105
- file(file = '') {
106
- const base = this.base();
107
- return new Asset({
108
- value: `${base}${file}`,
109
- });
110
- }
111
-
112
- maps() {
113
- if (this.#config.version && this.#loadMaps) return this.#maps;
114
- throw new Error('Eik config was not loaded or "loadMaps" is "false" when calling .maps()');
115
- }
116
- }
117
-
118
- module.exports = NodeClient;