@eik/common 4.0.0-next.4 → 4.0.0-next.7

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.
Files changed (120) hide show
  1. package/.eslintignore +2 -0
  2. package/.eslintrc +34 -0
  3. package/.github/workflows/publish.yml +69 -0
  4. package/.github/workflows/test.yml +45 -0
  5. package/.prettierignore +17 -0
  6. package/.prettierrc +20 -0
  7. package/CHANGELOG.md +60 -0
  8. package/fixtures/client-with-bare-imports.js +16 -0
  9. package/fixtures/client.js +6 -0
  10. package/fixtures/client.js.map +0 -0
  11. package/fixtures/folder/client.js +6 -0
  12. package/fixtures/folder/styles.css +0 -0
  13. package/fixtures/icons/checkbox-sprite.svg +46 -0
  14. package/fixtures/nested/client.js.map +0 -0
  15. package/fixtures/nested/styles.css.map +0 -0
  16. package/fixtures/styles.css +0 -0
  17. package/fixtures/styles.css.map +0 -0
  18. package/package.json +6 -63
  19. package/packages/config-loader/.prettierignore +17 -0
  20. package/packages/config-loader/index.js +13 -0
  21. package/packages/config-loader/package.json +42 -0
  22. package/{lib → packages/config-loader/src}/classes/file-mapping.js +2 -2
  23. package/{lib → packages/config-loader/src}/classes/local-file-location.js +0 -0
  24. package/{lib → packages/config-loader/src}/classes/read-file.js +2 -1
  25. package/{lib → packages/config-loader/src}/classes/remote-file-location.js +0 -0
  26. package/{lib → packages/config-loader/src}/classes/resolved-files.js +3 -2
  27. package/{lib/helpers → packages/config-loader/src}/config-store.js +4 -4
  28. package/{lib/classes → packages/config-loader/src}/eik-config.js +14 -10
  29. package/{lib/classes → packages/config-loader/src/errors}/custom-error.js +4 -2
  30. package/{lib/classes → packages/config-loader/src/errors}/invalid-config-error.js +4 -2
  31. package/{lib/classes → packages/config-loader/src/errors}/missing-config-error.js +4 -2
  32. package/{lib/classes → packages/config-loader/src/errors}/multiple-config-sources-error.js +4 -2
  33. package/{lib/classes → packages/config-loader/src/errors}/no-files-matched-error.js +5 -3
  34. package/{lib/classes → packages/config-loader/src/errors}/single-dest-multiple-source-error.js +4 -2
  35. package/{lib/helpers → packages/config-loader/src}/get-defaults.js +7 -6
  36. package/{lib/helpers → packages/config-loader/src}/local-assets.js +2 -1
  37. package/{lib/helpers → packages/config-loader/src/utils}/resolve-files.js +3 -2
  38. package/packages/config-loader/test/assets/esm.css +0 -0
  39. package/packages/config-loader/test/assets/esm.css.map +0 -0
  40. package/packages/config-loader/test/assets/esm.js +0 -0
  41. package/packages/config-loader/test/assets/esm.js.map +0 -0
  42. package/packages/config-loader/test/config-store.test.js +231 -0
  43. package/packages/config-loader/test/eik-config/cwd.test.js +35 -0
  44. package/packages/config-loader/test/eik-config/map.test.js +31 -0
  45. package/packages/config-loader/test/eik-config/mappings.test.js +507 -0
  46. package/packages/config-loader/test/eik-config/out.test.js +54 -0
  47. package/packages/config-loader/test/eik-config/server.test.js +32 -0
  48. package/packages/config-loader/test/eik-config/toJSON.test.js +19 -0
  49. package/packages/config-loader/test/eik-config/token.test.js +49 -0
  50. package/packages/config-loader/test/eik-config/type.test.js +22 -0
  51. package/packages/config-loader/test/eik-config/validate.test.js +31 -0
  52. package/packages/config-loader/test/eik-config/version.test.js +22 -0
  53. package/packages/config-loader/test/eik.json +10 -0
  54. package/packages/config-loader/test/local-assets.test.js +125 -0
  55. package/packages/config-loader/test/local-file-location/absolute.test.js +35 -0
  56. package/packages/config-loader/test/local-file-location/contentType.test.js +55 -0
  57. package/packages/config-loader/test/local-file-location/extension.test.js +20 -0
  58. package/packages/config-loader/test/local-file-location/mimeType.test.js +43 -0
  59. package/packages/config-loader/test/read-file.test.js +60 -0
  60. package/packages/config-loader/test/resolve-files.test.js +257 -0
  61. package/packages/config-loader/test/resolved-files/iterator.test.js +17 -0
  62. package/packages/config-loader/test/tmp/.gitkeep +0 -0
  63. package/packages/schemas/.prettierignore +17 -0
  64. package/packages/schemas/eikjson.d.ts +41 -0
  65. package/packages/schemas/index.js +7 -0
  66. package/packages/schemas/package.json +40 -0
  67. package/{lib/schemas → packages/schemas/src}/assert.js +3 -2
  68. package/{lib/schemas → packages/schemas/src}/eikjson.schema.json +0 -0
  69. package/{lib/schemas → packages/schemas/src}/validate.js +12 -8
  70. package/{lib/schemas → packages/schemas/src}/validation-error.js +1 -1
  71. package/packages/schemas/test/assert.js +207 -0
  72. package/packages/schemas/test/index.js +182 -0
  73. package/packages/utils/.prettierignore +17 -0
  74. package/packages/utils/index.js +20 -0
  75. package/packages/utils/package.json +29 -0
  76. package/{lib/helpers → packages/utils/src}/path-slashes.js +0 -0
  77. package/packages/utils/src/stream.js +21 -0
  78. package/{lib/helpers → packages/utils/src}/type-slug.js +0 -0
  79. package/{lib/helpers → packages/utils/src}/type-title.js +0 -0
  80. package/packages/utils/tests/eik.json +10 -0
  81. package/packages/validators/.prettierignore +17 -0
  82. package/packages/validators/package.json +34 -0
  83. package/packages/validators/src/index.js +53 -0
  84. package/packages/validators/test/index.js +238 -0
  85. package/release/eik-common-4.0.0-next.7.tgz +0 -0
  86. package/release.config.js +27 -0
  87. package/renovate.json +6 -0
  88. package/tsconfig.json +30 -0
  89. package/lib/helpers/index.js +0 -25
  90. package/lib/index.js +0 -17
  91. package/lib/schemas/index.js +0 -8
  92. package/lib/stream.js +0 -14
  93. package/lib/validators/index.js +0 -66
  94. package/types/classes/custom-error.d.ts +0 -7
  95. package/types/classes/eik-config.d.ts +0 -57
  96. package/types/classes/file-mapping.d.ts +0 -19
  97. package/types/classes/invalid-config-error.d.ts +0 -13
  98. package/types/classes/local-file-location.d.ts +0 -36
  99. package/types/classes/missing-config-error.d.ts +0 -13
  100. package/types/classes/multiple-config-sources-error.d.ts +0 -9
  101. package/types/classes/no-files-matched-error.d.ts +0 -13
  102. package/types/classes/read-file.d.ts +0 -15
  103. package/types/classes/remote-file-location.d.ts +0 -21
  104. package/types/classes/resolved-files.d.ts +0 -19
  105. package/types/classes/single-dest-multiple-source-error.d.ts +0 -13
  106. package/types/helpers/config-store.d.ts +0 -30
  107. package/types/helpers/get-defaults.d.ts +0 -2
  108. package/types/helpers/index.d.ts +0 -15
  109. package/types/helpers/local-assets.d.ts +0 -8
  110. package/types/helpers/path-slashes.d.ts +0 -32
  111. package/types/helpers/resolve-files.d.ts +0 -12
  112. package/types/helpers/type-slug.d.ts +0 -2
  113. package/types/helpers/type-title.d.ts +0 -2
  114. package/types/index.d.ts +0 -115
  115. package/types/schemas/assert.d.ts +0 -11
  116. package/types/schemas/index.d.ts +0 -79
  117. package/types/schemas/validate.d.ts +0 -26
  118. package/types/schemas/validation-error.d.ts +0 -8
  119. package/types/stream.d.ts +0 -2
  120. package/types/validators/index.d.ts +0 -8
@@ -1,9 +0,0 @@
1
- export = MultipleConfigSourcesError;
2
- declare const MultipleConfigSourcesError_base: {
3
- new (message: string): import("./custom-error");
4
- captureStackTrace(targetObject: object, constructorOpt?: Function): void;
5
- prepareStackTrace?: (err: Error, stackTraces: NodeJS.CallSite[]) => any;
6
- stackTraceLimit: number;
7
- };
8
- declare class MultipleConfigSourcesError extends MultipleConfigSourcesError_base {
9
- }
@@ -1,13 +0,0 @@
1
- export = NoFilesMatchedError;
2
- declare const NoFilesMatchedError_base: {
3
- new (message: string): import("./custom-error");
4
- captureStackTrace(targetObject: object, constructorOpt?: Function): void;
5
- prepareStackTrace?: (err: Error, stackTraces: NodeJS.CallSite[]) => any;
6
- stackTraceLimit: number;
7
- };
8
- declare class NoFilesMatchedError extends NoFilesMatchedError_base {
9
- /**
10
- * @param {string} file
11
- */
12
- constructor(file: string);
13
- }
@@ -1,15 +0,0 @@
1
- export = ReadFile;
2
- declare const ReadFile: {
3
- new ({ mimeType, etag }?: {
4
- mimeType?: string;
5
- etag?: string;
6
- }): {
7
- _mimeType: string;
8
- _stream: any;
9
- _etag: string;
10
- readonly mimeType: string;
11
- stream: any;
12
- readonly etag: string;
13
- readonly [Symbol.toStringTag]: string;
14
- };
15
- };
@@ -1,21 +0,0 @@
1
- export = RemoteFileLocation;
2
- declare class RemoteFileLocation {
3
- /**
4
- * @param {string} filePathname pathname for file relative to package root eg. /folder/client.js
5
- * @param {string} packagePathname pathname for package root eg. /pkg/my-pack/1.0.0
6
- * @param {string} origin server origin eg. https://server.com
7
- */
8
- constructor(filePathname: string, packagePathname: string, origin: string);
9
- /**
10
- * @type {string} pathname to package root
11
- */
12
- packagePathname: string;
13
- /**
14
- * @type {string} pathname to file relative to package root
15
- */
16
- filePathname: string;
17
- /**
18
- * @type {URL} WHATWG URL object containing the full remote URL for the file
19
- */
20
- url: URL;
21
- }
@@ -1,19 +0,0 @@
1
- export = ResolvedFiles;
2
- declare class ResolvedFiles {
3
- /**
4
- * @param {string[]} files
5
- * @param {{definition: [string, string], basePath: string, pattern: string}} meta
6
- */
7
- constructor(files: string[], meta: {
8
- definition: [string, string];
9
- basePath: string;
10
- pattern: string;
11
- });
12
- destination: string;
13
- source: string;
14
- basePath: string;
15
- pattern: string;
16
- [Symbol.iterator](): Generator<import("./local-file-location"), void, unknown>;
17
- [originalFiles]: string[];
18
- }
19
- declare const originalFiles: unique symbol;
@@ -1,13 +0,0 @@
1
- export = SingleDestMultipleSourcesError;
2
- declare const SingleDestMultipleSourcesError_base: {
3
- new (message: string): import("./custom-error");
4
- captureStackTrace(targetObject: object, constructorOpt?: Function): void;
5
- prepareStackTrace?: (err: Error, stackTraces: NodeJS.CallSite[]) => any;
6
- stackTraceLimit: number;
7
- };
8
- declare class SingleDestMultipleSourcesError extends SingleDestMultipleSourcesError_base {
9
- /**
10
- * @param {string} destFilePath
11
- */
12
- constructor(destFilePath: string);
13
- }
@@ -1,30 +0,0 @@
1
- /**
2
- * Tries to find the configuration for eik in the provided directory.
3
- *
4
- * @param {string} configRootDir The base directory for the eik project.
5
- * @param {function} [loadJSONFromDisk] The function to use to load the file from disk.
6
- *
7
- * @returns {EikConfig}
8
- */
9
- export declare function findInDirectory(configRootDir: string, loadJSONFromDisk?: Function): import("../classes/eik-config");
10
- /**
11
- * Tries to find the configuration for eik in the provided directory.
12
- *
13
- * @param {string} configRootDir The base directory for the eik project.
14
- * @param {function} [loadJSONFromDisk] The function to use to load the file from disk.
15
- *
16
- * @returns {EikConfig}
17
- */
18
- export declare function findInDirectory(configRootDir: string, loadJSONFromDisk?: Function): import("../classes/eik-config");
19
- /**
20
- * Persist config changes to disk as <cwd>/eik.json
21
- *
22
- * @param {import('../classes/eik-config')} config
23
- */
24
- export declare function persistToDisk(config: import("../classes/eik-config")): void;
25
- /**
26
- * Persist config changes to disk as <cwd>/eik.json
27
- *
28
- * @param {import('../classes/eik-config')} config
29
- */
30
- export declare function persistToDisk(config: import("../classes/eik-config")): void;
@@ -1,2 +0,0 @@
1
- declare function _exports(cwd: string): import("../classes/eik-config");
2
- export = _exports;
@@ -1,15 +0,0 @@
1
- export const localAssets: typeof import("./local-assets");
2
- export const getDefaults: (cwd: string) => import("../classes/eik-config");
3
- export const configStore: {
4
- findInDirectory(configRootDir: string, loadJSONFromDisk?: Function): import("../classes/eik-config");
5
- persistToDisk(config: import("../classes/eik-config")): void;
6
- };
7
- export const typeSlug: (type: any) => any;
8
- export const typeTitle: (type: any) => "PACKAGE" | "NPM" | "MAP";
9
- export const addTrailingSlash: (val: string) => string;
10
- export const removeTrailingSlash: (val: string) => string;
11
- export const addLeadingSlash: (val: string) => string;
12
- export const removeLeadingSlash: (val: string) => string;
13
- export const resolveFiles: (files: {
14
- [k: string]: string;
15
- }, cwd: string) => Promise<import("../classes/resolved-files")[]>;
@@ -1,8 +0,0 @@
1
- export = localAssets;
2
- /**
3
- * Sets up asset routes for local development. Mounted paths match those on Eik server and values are read from projects eik.json file.
4
- *
5
- * @param {object} app - express js or fastify app instance
6
- * @param {string} rootEikDirectory - (optional) path to folder where eik configuration file can be found
7
- */
8
- declare function localAssets(app: object, rootEikDirectory?: string): Promise<void>;
@@ -1,32 +0,0 @@
1
- /**
2
- * Add a trailing slash to a path if necessary
3
- *
4
- * @param {string} val
5
- *
6
- * @returns {string}
7
- */
8
- export function addTrailingSlash(val: string): string;
9
- /**
10
- * Remove a trailing slash from a path if necessary
11
- *
12
- * @param {string} val
13
- *
14
- * @returns {string}
15
- */
16
- export function removeTrailingSlash(val: string): string;
17
- /**
18
- * Add a leading slash to a path if necessary
19
- *
20
- * @param {string} val
21
- *
22
- * @returns {string}
23
- */
24
- export function addLeadingSlash(val: string): string;
25
- /**
26
- * Remove a leading slash from a path if necessary
27
- *
28
- * @param {string} val
29
- *
30
- * @returns {string}
31
- */
32
- export function removeLeadingSlash(val: string): string;
@@ -1,12 +0,0 @@
1
- export = resolveFiles;
2
- /**
3
- * Uses an Eik JSON "files" definition to resolve files on disk into a data structure
4
- *
5
- * @param {{[k: string]: string;}} files
6
- * @param {string} cwd
7
- *
8
- * @returns {Promise<ResolvedFiles[]>}
9
- */
10
- declare function resolveFiles(files: {
11
- [k: string]: string;
12
- }, cwd: string): Promise<import("../classes/resolved-files")[]>;
@@ -1,2 +0,0 @@
1
- declare function _exports(type: any): any;
2
- export = _exports;
@@ -1,2 +0,0 @@
1
- declare function _exports(type: any): "PACKAGE" | "NPM" | "MAP";
2
- export = _exports;
package/types/index.d.ts DELETED
@@ -1,115 +0,0 @@
1
- export const validators: typeof import("./validators");
2
- export const ReadFile: {
3
- new ({ mimeType, etag }?: {
4
- mimeType?: string;
5
- etag?: string;
6
- }): {
7
- _mimeType: string;
8
- _stream: any;
9
- _etag: string;
10
- readonly mimeType: string;
11
- stream: any;
12
- readonly etag: string;
13
- readonly [Symbol.toStringTag]: string;
14
- };
15
- };
16
- export const EikConfig: typeof import("./classes/eik-config");
17
- export const schemas: {
18
- schema: {
19
- $schema: string;
20
- additionalProperties: boolean;
21
- type: string;
22
- properties: {
23
- server: {
24
- description: string;
25
- type: string;
26
- format: string;
27
- };
28
- name: {
29
- description: string;
30
- type: string;
31
- maxLength: number;
32
- minLength: number;
33
- };
34
- version: {
35
- description: string;
36
- type: string;
37
- minLength: number;
38
- };
39
- type: {
40
- description: string;
41
- type: string;
42
- enum: string[];
43
- default: string;
44
- };
45
- files: {
46
- description: string;
47
- oneOf: ({
48
- type: string;
49
- minProperties: number;
50
- additionalProperties: {
51
- type: string;
52
- };
53
- minLength?: undefined;
54
- } | {
55
- type: string;
56
- minLength: number;
57
- minProperties?: undefined;
58
- additionalProperties?: undefined;
59
- })[];
60
- };
61
- "import-map": {
62
- description: string;
63
- oneOf: ({
64
- type: string;
65
- format: string;
66
- items?: undefined;
67
- } | {
68
- type: string;
69
- items: {
70
- type: string;
71
- format: string;
72
- };
73
- format?: undefined;
74
- })[];
75
- };
76
- out: {
77
- description: string;
78
- type: string;
79
- format: string;
80
- minLength: number;
81
- };
82
- };
83
- required: string[];
84
- };
85
- validate: typeof import("./schemas/validate");
86
- assert: {
87
- eikJSON: (value: any) => void;
88
- name: (value: any) => void;
89
- type: (value: any) => void;
90
- version: (value: any) => void;
91
- server: (value: any) => void;
92
- files: (value: any) => void;
93
- importMap: (value: any) => void;
94
- out: (value: any) => void;
95
- };
96
- ValidationError: typeof import("./schemas/validation-error");
97
- };
98
- export const stream: typeof import("./stream");
99
- export const helpers: {
100
- localAssets: typeof import("./helpers/local-assets");
101
- getDefaults: (cwd: string) => import("./classes/eik-config");
102
- configStore: {
103
- findInDirectory(configRootDir: string, loadJSONFromDisk?: Function): import("./classes/eik-config");
104
- persistToDisk(config: import("./classes/eik-config")): void;
105
- };
106
- typeSlug: (type: any) => any;
107
- typeTitle: (type: any) => "PACKAGE" | "NPM" | "MAP";
108
- addTrailingSlash: (val: string) => string;
109
- removeTrailingSlash: (val: string) => string;
110
- addLeadingSlash: (val: string) => string;
111
- removeLeadingSlash: (val: string) => string;
112
- resolveFiles: (files: {
113
- [k: string]: string;
114
- }, cwd: string) => Promise<import("./classes/resolved-files")[]>;
115
- };
@@ -1,11 +0,0 @@
1
- declare const _exports: {
2
- eikJSON: (value: any) => void;
3
- name: (value: any) => void;
4
- type: (value: any) => void;
5
- version: (value: any) => void;
6
- server: (value: any) => void;
7
- files: (value: any) => void;
8
- importMap: (value: any) => void;
9
- out: (value: any) => void;
10
- };
11
- export = _exports;
@@ -1,79 +0,0 @@
1
- export const schema: {
2
- $schema: string;
3
- additionalProperties: boolean;
4
- type: string;
5
- properties: {
6
- server: {
7
- description: string;
8
- type: string;
9
- format: string;
10
- };
11
- name: {
12
- description: string;
13
- type: string;
14
- maxLength: number;
15
- minLength: number;
16
- };
17
- version: {
18
- description: string;
19
- type: string;
20
- minLength: number;
21
- };
22
- type: {
23
- description: string;
24
- type: string;
25
- enum: string[];
26
- default: string;
27
- };
28
- files: {
29
- description: string;
30
- oneOf: ({
31
- type: string;
32
- minProperties: number;
33
- additionalProperties: {
34
- type: string;
35
- };
36
- minLength?: undefined;
37
- } | {
38
- type: string;
39
- minLength: number;
40
- minProperties?: undefined;
41
- additionalProperties?: undefined;
42
- })[];
43
- };
44
- "import-map": {
45
- description: string;
46
- oneOf: ({
47
- type: string;
48
- format: string;
49
- items?: undefined;
50
- } | {
51
- type: string;
52
- items: {
53
- type: string;
54
- format: string;
55
- };
56
- format?: undefined;
57
- })[];
58
- };
59
- out: {
60
- description: string;
61
- type: string;
62
- format: string;
63
- minLength: number;
64
- };
65
- };
66
- required: string[];
67
- };
68
- export const validate: typeof import("./validate");
69
- export const assert: {
70
- eikJSON: (value: any) => void;
71
- name: (value: any) => void;
72
- type: (value: any) => void;
73
- version: (value: any) => void;
74
- server: (value: any) => void;
75
- files: (value: any) => void;
76
- importMap: (value: any) => void;
77
- out: (value: any) => void;
78
- };
79
- export const ValidationError: typeof import("./validation-error");
@@ -1,26 +0,0 @@
1
- export function eikJSON(data: any): {
2
- value: any;
3
- error: import("ajv").ErrorObject<string, Record<string, any>, unknown>[];
4
- };
5
- export function name(value: any): any;
6
- export function version(value: any): any;
7
- export function type(data: any): {
8
- value: any;
9
- error: import("ajv").ErrorObject<string, Record<string, any>, unknown>[];
10
- };
11
- export function server(data: any): {
12
- value: any;
13
- error: import("ajv").ErrorObject<string, Record<string, any>, unknown>[];
14
- };
15
- export function files(data: any): {
16
- value: any;
17
- error: import("ajv").ErrorObject<string, Record<string, any>, unknown>[];
18
- };
19
- export function importMap(data: any): {
20
- value: any;
21
- error: import("ajv").ErrorObject<string, Record<string, any>, unknown>[];
22
- };
23
- export function out(data: any): {
24
- value: any;
25
- error: import("ajv").ErrorObject<string, Record<string, any>, unknown>[];
26
- };
@@ -1,8 +0,0 @@
1
- export = ValidationError;
2
- declare class ValidationError extends Error {
3
- /**
4
- * @param {string} message
5
- * @param {Error} err
6
- */
7
- constructor(message: string, err: Error);
8
- }
package/types/stream.d.ts DELETED
@@ -1,2 +0,0 @@
1
- export function isStream(stream: any): boolean;
2
- export function isReadableStream(stream: any): boolean;
@@ -1,8 +0,0 @@
1
- export function origin(value: any): any;
2
- export function org(value: any): any;
3
- export function name(value: any): any;
4
- export function version(value: any): any;
5
- export function alias(value: any): any;
6
- export function type(value: any): any;
7
- export function extra(value: any): any;
8
- export function semverType(value: any): any;