@eik/common 4.0.6 → 4.0.8
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 +15 -0
- package/eikjson.d.ts +1 -0
- package/lib/classes/eik-config.js +1 -1
- package/lib/helpers/config-store.js +2 -1
- package/lib/helpers/get-defaults.js +1 -5
- package/lib/schemas/eikjson.schema.json +5 -1
- package/lib/schemas/validate.js +2 -4
- package/package.json +10 -7
- package/types/classes/eik-config.d.ts +3 -3
- package/types/classes/read-file.d.ts +2 -2
- package/types/helpers/config-store.d.ts +2 -2
- package/types/helpers/get-defaults.d.ts +2 -2
- package/types/schemas/validate.d.ts +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
## [4.0.8](https://github.com/eik-lib/common/compare/v4.0.7...v4.0.8) (2024-08-12)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* allow specifying $schema ([bfc6b0f](https://github.com/eik-lib/common/commit/bfc6b0f5c878f14a7e3d78c4555779247e96a766))
|
|
7
|
+
* use the correct upstream schema link for ajv ([90ca025](https://github.com/eik-lib/common/commit/90ca025d67a9b8f2cf900ead23f1cfb1cddb0c2a)), closes [/ajv.js.org/guide/schema-language.html#draft-07-and-draft-06](https://github.com//ajv.js.org/guide/schema-language.html/issues/draft-07-and-draft-06)
|
|
8
|
+
|
|
9
|
+
## [4.0.7](https://github.com/eik-lib/common/compare/v4.0.6...v4.0.7) (2024-08-09)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
### Bug Fixes
|
|
13
|
+
|
|
14
|
+
* type issue with helpers.getDefaults ([9b29d63](https://github.com/eik-lib/common/commit/9b29d63ca9834a2a33222d03eade925f33cef91a))
|
|
15
|
+
|
|
1
16
|
## [4.0.6](https://github.com/eik-lib/common/compare/v4.0.5...v4.0.6) (2024-08-07)
|
|
2
17
|
|
|
3
18
|
|
package/eikjson.d.ts
CHANGED
|
@@ -26,7 +26,7 @@ const normalizeFilesDefinition = (files) =>
|
|
|
26
26
|
typeof files === 'string' ? { '/': files } : files;
|
|
27
27
|
|
|
28
28
|
/**
|
|
29
|
-
* @typedef {import ("../../eikjson").EikjsonSchema} EikjsonSchema
|
|
29
|
+
* @typedef {import ("../../eikjson.js").EikjsonSchema} EikjsonSchema
|
|
30
30
|
*/
|
|
31
31
|
|
|
32
32
|
export default class EikConfig {
|
|
@@ -19,6 +19,7 @@ function readJSONFromDisk(path) {
|
|
|
19
19
|
let fileData;
|
|
20
20
|
try {
|
|
21
21
|
fileData = readFileSync(path, { encoding: 'utf8' });
|
|
22
|
+
// eslint-disable-next-line no-unused-vars
|
|
22
23
|
} catch (e) {
|
|
23
24
|
// @ts-ignore
|
|
24
25
|
return null;
|
|
@@ -99,7 +100,7 @@ export default {
|
|
|
99
100
|
/**
|
|
100
101
|
* Persist config changes to disk as <cwd>/eik.json
|
|
101
102
|
*
|
|
102
|
-
* @param {import('../classes/eik-config')} config
|
|
103
|
+
* @param {import('../classes/eik-config.js')} config
|
|
103
104
|
*/
|
|
104
105
|
persistToDisk(config) {
|
|
105
106
|
try {
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// @ts-check
|
|
2
1
|
import fs from 'node:fs';
|
|
3
2
|
import path from 'node:path';
|
|
4
3
|
import configStore from './config-store.js';
|
|
@@ -9,16 +8,14 @@ import EikConfig from '../classes/eik-config.js';
|
|
|
9
8
|
*
|
|
10
9
|
* @param {string} directoryOrFilepath The directory to search for eik.json or package.json or an exact path to an eik.json or package.json file
|
|
11
10
|
*
|
|
12
|
-
* @returns {import("../classes/eik-config")} EikConfig
|
|
11
|
+
* @returns {import("../classes/eik-config.js").default} EikConfig
|
|
13
12
|
*/
|
|
14
13
|
export default function getDefaults(directoryOrFilepath) {
|
|
15
14
|
try {
|
|
16
15
|
const stats = fs.statSync(directoryOrFilepath);
|
|
17
16
|
if (stats.isDirectory()) {
|
|
18
|
-
// @ts-expect-error
|
|
19
17
|
return configStore.findInDirectory(directoryOrFilepath);
|
|
20
18
|
} else {
|
|
21
|
-
// @ts-expect-error
|
|
22
19
|
return configStore.loadFromPath(directoryOrFilepath);
|
|
23
20
|
}
|
|
24
21
|
} catch (error) {
|
|
@@ -30,7 +27,6 @@ export default function getDefaults(directoryOrFilepath) {
|
|
|
30
27
|
if (path.extname(directoryOrFilepath)) {
|
|
31
28
|
cwd = path.dirname(directoryOrFilepath);
|
|
32
29
|
}
|
|
33
|
-
// @ts-expect-error
|
|
34
30
|
return new EikConfig(null, [], cwd);
|
|
35
31
|
}
|
|
36
32
|
throw e;
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
{
|
|
2
|
-
"$schema": "http://json-schema.org/schema#",
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
3
|
"additionalProperties": false,
|
|
4
4
|
"type": "object",
|
|
5
5
|
"properties": {
|
|
6
|
+
"$schema": {
|
|
7
|
+
"type": "string",
|
|
8
|
+
"format": "uri"
|
|
9
|
+
},
|
|
6
10
|
"server": {
|
|
7
11
|
"description": "The URL address of the Eik server where packages are published to.",
|
|
8
12
|
"type": "string",
|
package/lib/schemas/validate.js
CHANGED
|
@@ -15,13 +15,11 @@ const eikJSONSchema = JSON.parse(
|
|
|
15
15
|
|
|
16
16
|
// @ts-ignore
|
|
17
17
|
const createValidator = (schema, ajvOptions) => {
|
|
18
|
+
// @ts-ignore
|
|
18
19
|
const ajv = new Ajv(ajvOptions);
|
|
19
20
|
// @ts-ignore
|
|
20
21
|
formats(ajv); // Needed to support "uri"
|
|
21
|
-
const validate = ajv.compile(
|
|
22
|
-
$schema: 'http://json-schema.org/schema#',
|
|
23
|
-
...schema,
|
|
24
|
-
});
|
|
22
|
+
const validate = ajv.compile(schema);
|
|
25
23
|
|
|
26
24
|
// @ts-ignore
|
|
27
25
|
return (data) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eik/common",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.8",
|
|
4
4
|
"description": "Common utilities for Eik modules",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "types/index.d.ts",
|
|
@@ -13,12 +13,15 @@
|
|
|
13
13
|
"eikjson.d.ts"
|
|
14
14
|
],
|
|
15
15
|
"scripts": {
|
|
16
|
+
"clean": "rimraf .tap node_modules types",
|
|
16
17
|
"lint": "eslint .",
|
|
17
18
|
"lint:fix": "eslint --fix .",
|
|
18
19
|
"schema:types": "json2ts lib/schemas/eikjson.schema.json > eikjson.d.ts",
|
|
19
20
|
"schema:outdated": "npm run schema:types && git diff --exit-code HEAD:eikjson.d.ts eikjson.d.ts",
|
|
20
21
|
"test": "tap --disable-coverage --allow-empty-coverage",
|
|
21
|
-
"types": "
|
|
22
|
+
"types": "run-s types:module types:test",
|
|
23
|
+
"types:module": "tsc",
|
|
24
|
+
"types:test": "tsc --project tsconfig.test.json"
|
|
22
25
|
},
|
|
23
26
|
"repository": {
|
|
24
27
|
"type": "git",
|
|
@@ -41,9 +44,10 @@
|
|
|
41
44
|
"validate-npm-package-name": "5.0.1"
|
|
42
45
|
},
|
|
43
46
|
"devDependencies": {
|
|
44
|
-
"@babel/eslint-parser": "7.25.1",
|
|
45
47
|
"@babel/plugin-syntax-import-assertions": "7.24.7",
|
|
46
|
-
"@eslint
|
|
48
|
+
"@eik/eslint-config": "1.0.2",
|
|
49
|
+
"@eik/semantic-release-config": "1.0.0",
|
|
50
|
+
"@eik/typescript-config": "1.0.0",
|
|
47
51
|
"@hapi/hapi": "21.3.10",
|
|
48
52
|
"@semantic-release/changelog": "6.0.3",
|
|
49
53
|
"@semantic-release/git": "10.0.1",
|
|
@@ -52,13 +56,12 @@
|
|
|
52
56
|
"@types/semver": "7.5.8",
|
|
53
57
|
"@types/validate-npm-package-name": "4.0.2",
|
|
54
58
|
"eslint": "9.8.0",
|
|
55
|
-
"eslint-config-prettier": "9.1.0",
|
|
56
|
-
"eslint-plugin-prettier": "5.2.1",
|
|
57
59
|
"express": "4.19.2",
|
|
58
60
|
"fastify": "4.28.1",
|
|
59
|
-
"globals": "15.9.0",
|
|
60
61
|
"json-schema-to-typescript": "15.0.0",
|
|
62
|
+
"npm-run-all": "4.1.5",
|
|
61
63
|
"prettier": "3.3.3",
|
|
64
|
+
"rimraf": "6.0.1",
|
|
62
65
|
"semantic-release": "24.0.0",
|
|
63
66
|
"stoppable": "1.1.0",
|
|
64
67
|
"tap": "21.0.0",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @typedef {import ("../../eikjson").EikjsonSchema} EikjsonSchema
|
|
2
|
+
* @typedef {import ("../../eikjson.js").EikjsonSchema} EikjsonSchema
|
|
3
3
|
*/
|
|
4
4
|
export default class EikConfig {
|
|
5
5
|
/**
|
|
@@ -17,7 +17,7 @@ export default class EikConfig {
|
|
|
17
17
|
/** @type {EikjsonSchema["version"]} */
|
|
18
18
|
get version(): string;
|
|
19
19
|
/** @type {EikjsonSchema["type"]} */
|
|
20
|
-
get type(): "map" | "npm" | "package"
|
|
20
|
+
get type(): "map" | "npm" | "package";
|
|
21
21
|
/** @type {string} */
|
|
22
22
|
get server(): string;
|
|
23
23
|
/** @type {[string, string][]} */
|
|
@@ -56,7 +56,7 @@ export default class EikConfig {
|
|
|
56
56
|
[_config]: EikjsonSchema;
|
|
57
57
|
[_tokens]: Map<string, string>;
|
|
58
58
|
}
|
|
59
|
-
export type EikjsonSchema = import("../../eikjson").EikjsonSchema;
|
|
59
|
+
export type EikjsonSchema = import("../../eikjson.js").EikjsonSchema;
|
|
60
60
|
import FileMapping from './file-mapping.js';
|
|
61
61
|
declare const _config: unique symbol;
|
|
62
62
|
declare const _tokens: unique symbol;
|
|
@@ -16,11 +16,11 @@ declare namespace _default {
|
|
|
16
16
|
*
|
|
17
17
|
* @returns {EikConfig}
|
|
18
18
|
*/
|
|
19
|
-
function findInDirectory(configRootDir: string, loadJSONFromDisk?: Function
|
|
19
|
+
function findInDirectory(configRootDir: string, loadJSONFromDisk?: Function): EikConfig;
|
|
20
20
|
/**
|
|
21
21
|
* Persist config changes to disk as <cwd>/eik.json
|
|
22
22
|
*
|
|
23
|
-
* @param {import('../classes/eik-config')} config
|
|
23
|
+
* @param {import('../classes/eik-config.js')} config
|
|
24
24
|
*/
|
|
25
25
|
function persistToDisk(config: typeof import("../classes/eik-config.js")): void;
|
|
26
26
|
}
|
|
@@ -4,6 +4,6 @@
|
|
|
4
4
|
*
|
|
5
5
|
* @param {string} directoryOrFilepath The directory to search for eik.json or package.json or an exact path to an eik.json or package.json file
|
|
6
6
|
*
|
|
7
|
-
* @returns {import("../classes/eik-config")} EikConfig
|
|
7
|
+
* @returns {import("../classes/eik-config.js").default} EikConfig
|
|
8
8
|
*/
|
|
9
|
-
export default function getDefaults(directoryOrFilepath: string):
|
|
9
|
+
export default function getDefaults(directoryOrFilepath: string): import("../classes/eik-config.js").default;
|
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
export function eikJSON(data: any): {
|
|
2
2
|
value: any;
|
|
3
|
-
error:
|
|
3
|
+
error: any;
|
|
4
4
|
};
|
|
5
5
|
export function name(value: any): any;
|
|
6
6
|
export function version(value: any): any;
|
|
7
7
|
export function type(data: any): {
|
|
8
8
|
value: any;
|
|
9
|
-
error:
|
|
9
|
+
error: any;
|
|
10
10
|
};
|
|
11
11
|
export function server(data: any): {
|
|
12
12
|
value: any;
|
|
13
|
-
error:
|
|
13
|
+
error: any;
|
|
14
14
|
};
|
|
15
15
|
export function files(data: any): {
|
|
16
16
|
value: any;
|
|
17
|
-
error:
|
|
17
|
+
error: any;
|
|
18
18
|
};
|
|
19
19
|
export function importMap(data: any): {
|
|
20
20
|
value: any;
|
|
21
|
-
error:
|
|
21
|
+
error: any;
|
|
22
22
|
};
|
|
23
23
|
export function out(data: any): {
|
|
24
24
|
value: any;
|
|
25
|
-
error:
|
|
25
|
+
error: any;
|
|
26
26
|
};
|