@eik/common 4.0.0-next.5 → 4.0.0-next.6

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 +7 -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 -60
  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.6.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 -58
  96. package/types/classes/file-mapping.d.ts +0 -21
  97. package/types/classes/invalid-config-error.d.ts +0 -4
  98. package/types/classes/local-file-location.d.ts +0 -36
  99. package/types/classes/missing-config-error.d.ts +0 -4
  100. package/types/classes/multiple-config-sources-error.d.ts +0 -5
  101. package/types/classes/no-files-matched-error.d.ts +0 -4
  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 -20
  105. package/types/classes/single-dest-multiple-source-error.d.ts +0 -4
  106. package/types/helpers/config-store.d.ts +0 -31
  107. package/types/helpers/get-defaults.d.ts +0 -2
  108. package/types/helpers/index.d.ts +0 -11
  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 -13
  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 -7
  115. package/types/schemas/assert.d.ts +0 -8
  116. package/types/schemas/index.d.ts +0 -71
  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,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,20 +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<LocalFileLocation, void, unknown>;
17
- [originalFiles]: string[];
18
- }
19
- import LocalFileLocation = require("./local-file-location");
20
- declare const originalFiles: unique symbol;
@@ -1,4 +0,0 @@
1
- export = SingleDestMultipleSourcesError;
2
- declare class SingleDestMultipleSourcesError extends CustomError {
3
- }
4
- import CustomError = require("./custom-error");
@@ -1,31 +0,0 @@
1
- import EikConfig = require("../classes/eik-config");
2
- /**
3
- * Tries to find the configuration for eik in the provided directory.
4
- *
5
- * @param {string} configRootDir The base directory for the eik project.
6
- * @param {function} [loadJSONFromDisk] The function to use to load the file from disk.
7
- *
8
- * @returns {EikConfig}
9
- */
10
- export function findInDirectory(configRootDir: string, loadJSONFromDisk?: Function): EikConfig;
11
- /**
12
- * Tries to find the configuration for eik in the provided directory.
13
- *
14
- * @param {string} configRootDir The base directory for the eik project.
15
- * @param {function} [loadJSONFromDisk] The function to use to load the file from disk.
16
- *
17
- * @returns {EikConfig}
18
- */
19
- export function findInDirectory(configRootDir: string, loadJSONFromDisk?: Function): EikConfig;
20
- /**
21
- * Persist config changes to disk as <cwd>/eik.json
22
- *
23
- * @param {import('../classes/eik-config')} config
24
- */
25
- export function persistToDisk(config: EikConfig): void;
26
- /**
27
- * Persist config changes to disk as <cwd>/eik.json
28
- *
29
- * @param {import('../classes/eik-config')} config
30
- */
31
- export function persistToDisk(config: EikConfig): void;
@@ -1,2 +0,0 @@
1
- declare function _exports(cwd: string): import("../classes/eik-config");
2
- export = _exports;
@@ -1,11 +0,0 @@
1
- import localAssets = require("./local-assets");
2
- import getDefaults = require("./get-defaults");
3
- import configStore = require("./config-store");
4
- import typeSlug = require("./type-slug");
5
- import typeTitle = require("./type-title");
6
- import { addTrailingSlash } from "./path-slashes";
7
- import { removeTrailingSlash } from "./path-slashes";
8
- import { addLeadingSlash } from "./path-slashes";
9
- import { removeLeadingSlash } from "./path-slashes";
10
- import resolveFiles = require("./resolve-files");
11
- export { localAssets, getDefaults, configStore, typeSlug, typeTitle, addTrailingSlash, removeTrailingSlash, addLeadingSlash, removeLeadingSlash, resolveFiles };
@@ -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,13 +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<ResolvedFiles[]>;
13
- import ResolvedFiles = require("../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,7 +0,0 @@
1
- import validators = require("./validators");
2
- import ReadFile = require("./classes/read-file");
3
- import EikConfig = require("./classes/eik-config");
4
- import schemas = require("./schemas");
5
- import stream = require("./stream");
6
- import helpers = require("./helpers");
7
- export { validators, ReadFile, EikConfig, schemas, stream, helpers };
@@ -1,8 +0,0 @@
1
- export function eikJSON(value: any): void;
2
- export function name(value: any): void;
3
- export function type(value: any): void;
4
- export function version(value: any): void;
5
- export function server(value: any): void;
6
- export function files(value: any): void;
7
- export function importMap(value: any): void;
8
- export function out(value: any): void;
@@ -1,71 +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
- import validate = require("./validate");
69
- import assert = require("./assert");
70
- import ValidationError = require("./validation-error");
71
- export { validate, assert, ValidationError };
@@ -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;