@eik/common 4.0.0-next.7 → 4.0.1

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 (123) hide show
  1. package/CHANGELOG.md +110 -5
  2. package/README.md +9 -5
  3. package/eikjson.d.ts +1 -1
  4. package/{packages/config-loader/src/errors → lib/classes}/custom-error.js +1 -3
  5. package/{packages/config-loader/src → lib/classes}/eik-config.js +19 -17
  6. package/{packages/config-loader/src → lib}/classes/file-mapping.js +4 -6
  7. package/{packages/config-loader/src/errors → lib/classes}/invalid-config-error.js +2 -4
  8. package/{packages/config-loader/src → lib}/classes/local-file-location.js +5 -4
  9. package/{packages/config-loader/src/errors → lib/classes}/missing-config-error.js +2 -4
  10. package/{packages/config-loader/src/errors → lib/classes}/multiple-config-sources-error.js +2 -4
  11. package/{packages/config-loader/src/errors → lib/classes}/no-files-matched-error.js +2 -4
  12. package/{packages/config-loader/src → lib}/classes/read-file.js +4 -3
  13. package/{packages/config-loader/src → lib}/classes/remote-file-location.js +3 -3
  14. package/{packages/config-loader/src → lib}/classes/resolved-files.js +5 -6
  15. package/{packages/config-loader/src/errors → lib/classes}/single-dest-multiple-source-error.js +2 -4
  16. package/{packages/config-loader/src → lib/helpers}/config-store.js +39 -8
  17. package/lib/helpers/get-defaults.js +38 -0
  18. package/lib/helpers/index.js +25 -0
  19. package/{packages/config-loader/src → lib/helpers}/local-assets.js +9 -7
  20. package/{packages/utils/src → lib/helpers}/path-slashes.js +1 -1
  21. package/{packages/config-loader/src/utils → lib/helpers}/resolve-files.js +7 -11
  22. package/{packages/utils/src → lib/helpers}/type-slug.js +4 -1
  23. package/{packages/utils/src → lib/helpers}/type-title.js +4 -1
  24. package/lib/index.js +16 -0
  25. package/{packages/schemas/src → lib/schemas}/assert.js +6 -6
  26. package/lib/schemas/index.js +15 -0
  27. package/{packages/schemas/src → lib/schemas}/validate.js +18 -17
  28. package/{packages/schemas/src → lib/schemas}/validation-error.js +2 -2
  29. package/lib/stream.js +12 -0
  30. package/lib/validators/index.js +65 -0
  31. package/package.json +63 -6
  32. package/types/classes/custom-error.d.ts +6 -0
  33. package/types/classes/eik-config.d.ts +63 -0
  34. package/types/classes/file-mapping.d.ts +21 -0
  35. package/types/classes/invalid-config-error.d.ts +3 -0
  36. package/types/classes/local-file-location.d.ts +36 -0
  37. package/types/classes/missing-config-error.d.ts +3 -0
  38. package/types/classes/multiple-config-sources-error.d.ts +4 -0
  39. package/types/classes/no-files-matched-error.d.ts +3 -0
  40. package/types/classes/read-file.d.ts +15 -0
  41. package/types/classes/remote-file-location.d.ts +21 -0
  42. package/types/classes/resolved-files.d.ts +20 -0
  43. package/types/classes/single-dest-multiple-source-error.d.ts +3 -0
  44. package/types/helpers/config-store.d.ts +28 -0
  45. package/types/helpers/get-defaults.d.ts +9 -0
  46. package/types/helpers/index.d.ts +23 -0
  47. package/types/helpers/local-assets.d.ts +8 -0
  48. package/types/helpers/path-slashes.d.ts +32 -0
  49. package/types/helpers/resolve-files.d.ts +13 -0
  50. package/types/helpers/type-slug.d.ts +2 -0
  51. package/types/helpers/type-title.d.ts +2 -0
  52. package/types/index.d.ts +16 -0
  53. package/types/schemas/assert.d.ts +11 -0
  54. package/types/schemas/index.d.ts +11 -0
  55. package/types/schemas/validate.d.ts +26 -0
  56. package/types/schemas/validation-error.d.ts +8 -0
  57. package/types/stream.d.ts +2 -0
  58. package/types/validators/index.d.ts +8 -0
  59. package/.eslintignore +0 -2
  60. package/.eslintrc +0 -34
  61. package/.github/workflows/publish.yml +0 -69
  62. package/.github/workflows/test.yml +0 -45
  63. package/.prettierignore +0 -17
  64. package/.prettierrc +0 -20
  65. package/fixtures/client-with-bare-imports.js +0 -16
  66. package/fixtures/client.js +0 -6
  67. package/fixtures/client.js.map +0 -0
  68. package/fixtures/folder/client.js +0 -6
  69. package/fixtures/folder/styles.css +0 -0
  70. package/fixtures/icons/checkbox-sprite.svg +0 -46
  71. package/fixtures/nested/client.js.map +0 -0
  72. package/fixtures/nested/styles.css.map +0 -0
  73. package/fixtures/styles.css +0 -0
  74. package/fixtures/styles.css.map +0 -0
  75. package/packages/config-loader/.prettierignore +0 -17
  76. package/packages/config-loader/index.js +0 -13
  77. package/packages/config-loader/package.json +0 -42
  78. package/packages/config-loader/src/get-defaults.js +0 -25
  79. package/packages/config-loader/test/assets/esm.css +0 -0
  80. package/packages/config-loader/test/assets/esm.css.map +0 -0
  81. package/packages/config-loader/test/assets/esm.js +0 -0
  82. package/packages/config-loader/test/assets/esm.js.map +0 -0
  83. package/packages/config-loader/test/config-store.test.js +0 -231
  84. package/packages/config-loader/test/eik-config/cwd.test.js +0 -35
  85. package/packages/config-loader/test/eik-config/map.test.js +0 -31
  86. package/packages/config-loader/test/eik-config/mappings.test.js +0 -507
  87. package/packages/config-loader/test/eik-config/out.test.js +0 -54
  88. package/packages/config-loader/test/eik-config/server.test.js +0 -32
  89. package/packages/config-loader/test/eik-config/toJSON.test.js +0 -19
  90. package/packages/config-loader/test/eik-config/token.test.js +0 -49
  91. package/packages/config-loader/test/eik-config/type.test.js +0 -22
  92. package/packages/config-loader/test/eik-config/validate.test.js +0 -31
  93. package/packages/config-loader/test/eik-config/version.test.js +0 -22
  94. package/packages/config-loader/test/eik.json +0 -10
  95. package/packages/config-loader/test/local-assets.test.js +0 -125
  96. package/packages/config-loader/test/local-file-location/absolute.test.js +0 -35
  97. package/packages/config-loader/test/local-file-location/contentType.test.js +0 -55
  98. package/packages/config-loader/test/local-file-location/extension.test.js +0 -20
  99. package/packages/config-loader/test/local-file-location/mimeType.test.js +0 -43
  100. package/packages/config-loader/test/read-file.test.js +0 -60
  101. package/packages/config-loader/test/resolve-files.test.js +0 -257
  102. package/packages/config-loader/test/resolved-files/iterator.test.js +0 -17
  103. package/packages/config-loader/test/tmp/.gitkeep +0 -0
  104. package/packages/schemas/.prettierignore +0 -17
  105. package/packages/schemas/eikjson.d.ts +0 -41
  106. package/packages/schemas/index.js +0 -7
  107. package/packages/schemas/package.json +0 -40
  108. package/packages/schemas/test/assert.js +0 -207
  109. package/packages/schemas/test/index.js +0 -182
  110. package/packages/utils/.prettierignore +0 -17
  111. package/packages/utils/index.js +0 -20
  112. package/packages/utils/package.json +0 -29
  113. package/packages/utils/src/stream.js +0 -21
  114. package/packages/utils/tests/eik.json +0 -10
  115. package/packages/validators/.prettierignore +0 -17
  116. package/packages/validators/package.json +0 -34
  117. package/packages/validators/src/index.js +0 -53
  118. package/packages/validators/test/index.js +0 -238
  119. package/release/eik-common-4.0.0-next.7.tgz +0 -0
  120. package/release.config.js +0 -27
  121. package/renovate.json +0 -6
  122. package/tsconfig.json +0 -30
  123. /package/{packages/schemas/src → lib/schemas}/eikjson.schema.json +0 -0
@@ -1,11 +1,9 @@
1
- /* eslint-disable no-await-in-loop */
2
-
3
1
  /**
4
2
  * @type {(value: unknown, message?: string) => asserts value}
5
3
  */
6
- const assert = require('assert');
7
- const fs = require('fs');
8
- const configStore = require('./config-store.js');
4
+ import assert from 'node:assert';
5
+ import fs from 'node:fs';
6
+ import configStore from './config-store.js';
9
7
 
10
8
  /**
11
9
  * Sets up asset routes for local development. Mounted paths match those on Eik server and values are read from projects eik.json file.
@@ -15,6 +13,7 @@ const configStore = require('./config-store.js');
15
13
  */
16
14
  async function localAssets(app, rootEikDirectory = process.cwd()) {
17
15
  assert(
16
+ // @ts-ignore
18
17
  app.decorateReply || app.name === 'app' || app.route,
19
18
  'App must be an Express, Fastify or Hapi app instance',
20
19
  );
@@ -28,7 +27,9 @@ async function localAssets(app, rootEikDirectory = process.cwd()) {
28
27
  (await eik.mappings()).forEach((mapping) => {
29
28
  const { pathname } = mapping.destination.url;
30
29
  const { contentType, absolute: path } = mapping.source;
30
+ // @ts-ignore
31
31
  if (app.get) {
32
+ // @ts-ignore
32
33
  app.get(pathname, (req, res) => {
33
34
  if (res.set) {
34
35
  // express
@@ -44,9 +45,11 @@ async function localAssets(app, rootEikDirectory = process.cwd()) {
44
45
  });
45
46
  } else {
46
47
  // hapi
48
+ // @ts-ignore
47
49
  app.route({
48
50
  method: 'GET',
49
51
  path: pathname,
52
+ // @ts-ignore
50
53
  handler(req, h) {
51
54
  return h
52
55
  .response(fs.createReadStream(path))
@@ -57,5 +60,4 @@ async function localAssets(app, rootEikDirectory = process.cwd()) {
57
60
  }
58
61
  });
59
62
  }
60
-
61
- module.exports = localAssets;
63
+ export default localAssets;
@@ -35,7 +35,7 @@ const addLeadingSlash = (val) => (val.startsWith('/') ? val : `/${val}`);
35
35
  */
36
36
  const removeLeadingSlash = (val) => (val.startsWith('/') ? val.substr(1) : val);
37
37
 
38
- module.exports = {
38
+ export {
39
39
  addTrailingSlash,
40
40
  removeTrailingSlash,
41
41
  addLeadingSlash,
@@ -1,16 +1,12 @@
1
- /* eslint-disable no-continue */
2
-
3
- const { promisify } = require('util');
4
- const { extname, join, isAbsolute, basename, sep, normalize } = require('path');
5
- const isGlob = require('is-glob');
6
- const glob = promisify(require('glob'));
7
- // const { ResolvedFiles } = require('../index.js');
8
- const {
1
+ import { extname, join, isAbsolute, basename, sep, normalize } from 'node:path';
2
+ import isGlob from 'is-glob';
3
+ import { glob } from 'glob';
4
+ import {
9
5
  removeTrailingSlash,
10
6
  addLeadingSlash,
11
7
  removeLeadingSlash,
12
- } = require('@eik/common-utils');
13
- const ResolvedFiles = require('../classes/resolved-files.js');
8
+ } from './path-slashes.js';
9
+ import ResolvedFiles from '../classes/resolved-files.js';
14
10
 
15
11
  /**
16
12
  * Create a new path from a path string preceeding a glob or the whole path if no glob is found
@@ -79,4 +75,4 @@ const resolveFiles = async (files, cwd) =>
79
75
  }),
80
76
  );
81
77
 
82
- module.exports = resolveFiles;
78
+ export default resolveFiles;
@@ -1,6 +1,9 @@
1
1
  // @ts-check
2
2
 
3
- module.exports = (type) => {
3
+ /**
4
+ * @type {(type: string) => string}
5
+ */
6
+ export default (type) => {
4
7
  if (type === 'package') return 'pkg';
5
8
  return type;
6
9
  };
@@ -1,6 +1,9 @@
1
1
  // @ts-check
2
2
 
3
- module.exports = (type) => {
3
+ /**
4
+ * @type {(type: string) => string}
5
+ */
6
+ export default (type) => {
4
7
  if (type === 'package') return 'PACKAGE';
5
8
  if (type === 'npm') return 'NPM';
6
9
  return 'MAP';
package/lib/index.js ADDED
@@ -0,0 +1,16 @@
1
+ import * as validators from './validators/index.js';
2
+ import ReadFile from './classes/read-file.js';
3
+ import EikConfig from './classes/eik-config.js';
4
+ import schemas from './schemas/index.js';
5
+ import * as stream from './stream.js';
6
+ import helpers from './helpers/index.js';
7
+
8
+ export default {
9
+ validators,
10
+ ReadFile,
11
+ EikConfig,
12
+ schemas,
13
+ stream,
14
+ helpers,
15
+ };
16
+ export { validators, ReadFile, EikConfig, schemas, stream, helpers };
@@ -1,6 +1,5 @@
1
1
  // @ts-check
2
-
3
- const {
2
+ import {
4
3
  eikJSON,
5
4
  name,
6
5
  version,
@@ -9,14 +8,15 @@ const {
9
8
  files,
10
9
  importMap,
11
10
  out,
12
- } = require('./validate.js');
13
-
14
- const ValidationError = require('./validation-error.js');
11
+ } from './validate.js';
12
+ import ValidationError from './validation-error.js';
15
13
 
14
+ // @ts-ignore
16
15
  const assert = (validate, message) => (value) => {
17
16
  const valid = validate(value);
18
17
  if (valid.error) {
19
18
  const errorMessage = valid.error
19
+ // @ts-ignore
20
20
  .map((err) => {
21
21
  let msg = err.message;
22
22
  if (err.params && err.params.allowedValues) {
@@ -29,7 +29,7 @@ const assert = (validate, message) => (value) => {
29
29
  }
30
30
  };
31
31
 
32
- module.exports = {
32
+ export default {
33
33
  eikJSON: assert(eikJSON, 'Invalid eik.json schema'),
34
34
  name: assert(name, 'Parameter "name" is not valid'),
35
35
  type: assert(type, 'Parameter "type" is not valid'),
@@ -0,0 +1,15 @@
1
+ import { readFileSync } from 'node:fs';
2
+ import { join, dirname } from 'node:path';
3
+ import * as validate from './validate.js';
4
+ import assert from './assert.js';
5
+ import ValidationError from './validation-error.js';
6
+ import { fileURLToPath } from 'node:url';
7
+
8
+ const __filename = fileURLToPath(import.meta.url);
9
+ const __dirname = dirname(__filename);
10
+
11
+ const schema = JSON.parse(
12
+ readFileSync(join(__dirname, './eikjson.schema.json'), 'utf8'),
13
+ );
14
+
15
+ export default { schema, validate, assert, ValidationError };
@@ -1,10 +1,19 @@
1
- const formats = require('ajv-formats');
2
- const semver = require('semver');
3
- const npmPkg = require('validate-npm-package-name');
4
- const Ajv = require('ajv').default;
1
+ import { readFileSync } from 'node:fs';
2
+ import { join, dirname } from 'node:path';
3
+ import formats from 'ajv-formats';
4
+ import semver from 'semver';
5
+ import npmPkg from 'validate-npm-package-name';
6
+ import Ajv from 'ajv';
7
+ import { fileURLToPath } from 'node:url';
5
8
 
6
- const eikJSONSchema = require('./eikjson.schema.json');
9
+ const __filename = fileURLToPath(import.meta.url);
10
+ const __dirname = dirname(__filename);
7
11
 
12
+ const eikJSONSchema = JSON.parse(
13
+ readFileSync(join(__dirname, './eikjson.schema.json'), 'utf8'),
14
+ );
15
+
16
+ // @ts-ignore
8
17
  const createValidator = (schema, ajvOptions) => {
9
18
  const ajv = new Ajv(ajvOptions);
10
19
  // @ts-ignore
@@ -14,6 +23,7 @@ const createValidator = (schema, ajvOptions) => {
14
23
  ...schema,
15
24
  });
16
25
 
26
+ // @ts-ignore
17
27
  return (data) => {
18
28
  const cloned = JSON.parse(JSON.stringify(data));
19
29
  const valid = validate(cloned);
@@ -25,7 +35,7 @@ const eikJSON = createValidator(eikJSONSchema, {
25
35
  removeAdditional: true,
26
36
  useDefaults: true,
27
37
  });
28
-
38
+ // @ts-ignore
29
39
  const createNameValidator = (jsonSchemaValidator) => (value) => {
30
40
  const result = jsonSchemaValidator(value);
31
41
  if (!result.error) {
@@ -46,7 +56,7 @@ const createNameValidator = (jsonSchemaValidator) => (value) => {
46
56
  }
47
57
  return result;
48
58
  };
49
-
59
+ // @ts-ignore
50
60
  const createVersionValidator = (jsonSchemaValidator) => (value) => {
51
61
  const result = jsonSchemaValidator(value);
52
62
  if (!result.error) {
@@ -80,13 +90,4 @@ const files = createValidator(eikJSONSchema.properties.files);
80
90
  const importMap = createValidator(eikJSONSchema.properties['import-map']);
81
91
  const out = createValidator(eikJSONSchema.properties.out);
82
92
 
83
- module.exports = {
84
- eikJSON,
85
- name,
86
- version,
87
- type,
88
- server,
89
- files,
90
- importMap,
91
- out,
92
- };
93
+ export { eikJSON, name, version, type, server, files, importMap, out };
@@ -1,4 +1,5 @@
1
1
  // @ts-check
2
+
2
3
  class ValidationError extends Error {
3
4
  /**
4
5
  * @param {string} message
@@ -12,5 +13,4 @@ class ValidationError extends Error {
12
13
  Error.captureStackTrace(this, this.constructor);
13
14
  }
14
15
  }
15
-
16
- module.exports = ValidationError;
16
+ export default ValidationError;
package/lib/stream.js ADDED
@@ -0,0 +1,12 @@
1
+ // @ts-ignore
2
+ export const isStream = (stream) =>
3
+ stream !== null &&
4
+ typeof stream === 'object' &&
5
+ typeof stream.pipe === 'function';
6
+
7
+ // @ts-ignore
8
+ export const isReadableStream = (stream) =>
9
+ isStream(stream) &&
10
+ stream.readable !== false &&
11
+ typeof stream._read === 'function' &&
12
+ typeof stream._readableState === 'object';
@@ -0,0 +1,65 @@
1
+ import semver from 'semver';
2
+ import npmPkg from 'validate-npm-package-name';
3
+
4
+ const urlIsh = /^https?:\/\/[a-zA-Z0-9-_./]+(:[0-9]+)?/;
5
+ // @ts-ignore
6
+ export const origin = (value) => {
7
+ if (urlIsh.test(value)) {
8
+ return value.toLowerCase();
9
+ }
10
+ throw new Error('Parameter "origin" is not valid');
11
+ };
12
+
13
+ // @ts-ignore
14
+ export const org = (value) => {
15
+ if (/^[a-zA-Z0-9_-]+$/.test(value)) {
16
+ return value.toLowerCase();
17
+ }
18
+ throw new Error(`Parameter "org" is not valid - Value: ${value}`);
19
+ };
20
+
21
+ // @ts-ignore
22
+ export const name = (value) => {
23
+ const result = npmPkg(value);
24
+ if (result.validForNewPackages || result.validForOldPackages) {
25
+ return value.toLowerCase();
26
+ }
27
+ throw new Error(`Parameter "name" is not valid - Value: ${value}`);
28
+ };
29
+
30
+ // @ts-ignore
31
+ export const version = (value) => {
32
+ const result = semver.valid(value);
33
+ if (result) {
34
+ return result;
35
+ }
36
+ throw new Error(`Parameter "version" is not valid - Value: ${value}`);
37
+ };
38
+
39
+ // @ts-ignore
40
+ export const alias = (value) => {
41
+ if (/^[0-9]+$/.test(value)) {
42
+ return value;
43
+ }
44
+ throw new Error(`Parameter "alias" is not valid - Value: ${value}`);
45
+ };
46
+
47
+ // @ts-ignore
48
+ export const type = (value) => {
49
+ if (value === 'pkg' || value === 'map' || value === 'npm') {
50
+ return value;
51
+ }
52
+ throw new Error(`Parameter "type" is not valid - Value: ${value}`);
53
+ };
54
+
55
+ // TODO; https://github.com/asset-pipe/core/issues/12
56
+ // @ts-ignore
57
+ export const extra = (value) => value;
58
+
59
+ // @ts-ignore
60
+ export const semverType = (value) => {
61
+ if (value === 'major' || value === 'minor' || value === 'patch') {
62
+ return value;
63
+ }
64
+ throw new Error(`Parameter "semverType" is not valid - Value: ${value}`);
65
+ };
package/package.json CHANGED
@@ -1,10 +1,67 @@
1
1
  {
2
2
  "name": "@eik/common",
3
- "workspaces": [
4
- "packages/config-loader",
5
- "packages/utils",
6
- "packages/schemas",
7
- "packages/validators"
3
+ "version": "4.0.1",
4
+ "description": "Common utilities for Eik modules",
5
+ "main": "lib/index.js",
6
+ "types": "types/index.d.ts",
7
+ "type": "module",
8
+ "files": [
9
+ "CHANGELOG.md",
10
+ "package.json",
11
+ "lib",
12
+ "types",
13
+ "eikjson.d.ts"
8
14
  ],
9
- "version": "4.0.0-next.7"
15
+ "scripts": {
16
+ "lint": "eslint .",
17
+ "lint:fix": "eslint --fix .",
18
+ "schema:types": "json2ts lib/schemas/eikjson.schema.json > eikjson.d.ts",
19
+ "schema:outdated": "npm run schema:types && git diff --exit-code HEAD:eikjson.d.ts eikjson.d.ts",
20
+ "test": "tap --disable-coverage --allow-empty-coverage",
21
+ "types": "tsc"
22
+ },
23
+ "repository": {
24
+ "type": "git",
25
+ "url": "git+https://github.com/eik-lib/common.git"
26
+ },
27
+ "keywords": [],
28
+ "author": "",
29
+ "license": "ISC",
30
+ "bugs": {
31
+ "url": "https://github.com/eik-lib/common/issues"
32
+ },
33
+ "homepage": "https://github.com/eik-lib/common#readme",
34
+ "dependencies": {
35
+ "ajv": "8.6.2",
36
+ "ajv-formats": "3.0.1",
37
+ "glob": "11.0.0",
38
+ "is-glob": "4.0.1",
39
+ "mime-types": "2.1.29",
40
+ "semver": "7.0.0",
41
+ "validate-npm-package-name": "5.0.1"
42
+ },
43
+ "devDependencies": {
44
+ "@babel/eslint-parser": "7.25.1",
45
+ "@babel/plugin-syntax-import-assertions": "7.24.7",
46
+ "@eslint/js": "9.8.0",
47
+ "@hapi/hapi": "21.3.10",
48
+ "@semantic-release/changelog": "6.0.3",
49
+ "@semantic-release/git": "10.0.1",
50
+ "@types/glob": "8.1.0",
51
+ "@types/is-glob": "4.0.4",
52
+ "@types/semver": "7.5.8",
53
+ "@types/validate-npm-package-name": "4.0.2",
54
+ "eslint": "9.8.0",
55
+ "eslint-config-prettier": "9.1.0",
56
+ "eslint-plugin-prettier": "5.2.1",
57
+ "express": "4.19.2",
58
+ "fastify": "4.28.1",
59
+ "globals": "15.9.0",
60
+ "json-schema-to-typescript": "15.0.0",
61
+ "prettier": "3.3.3",
62
+ "semantic-release": "24.0.0",
63
+ "stoppable": "1.1.0",
64
+ "tap": "21.0.0",
65
+ "typescript": "5.5.4"
66
+ }
10
67
  }
@@ -0,0 +1,6 @@
1
+ export default class CustomError extends Error {
2
+ /**
3
+ * @param {string} message
4
+ */
5
+ constructor(message: string);
6
+ }
@@ -0,0 +1,63 @@
1
+ /**
2
+ * @typedef {import ("../../eikjson").EikjsonSchema} EikjsonSchema
3
+ */
4
+ export default class EikConfig {
5
+ /**
6
+ * @param {EikjsonSchema?} configHash
7
+ * @param {[string, string][]?} tokens
8
+ * @param {string?} configRootDir
9
+ */
10
+ constructor(configHash: EikjsonSchema | null, tokens?: [string, string][] | null, configRootDir?: string | null);
11
+ cwd: string;
12
+ /** @type {string[]} */
13
+ map: string[];
14
+ /** @type {EikjsonSchema["name"]} */
15
+ get name(): string;
16
+ set version(newVersion: string);
17
+ /** @type {EikjsonSchema["version"]} */
18
+ get version(): string;
19
+ /** @type {EikjsonSchema["type"]} */
20
+ get type(): "map" | "npm" | "package" | undefined;
21
+ /** @type {string} */
22
+ get server(): string;
23
+ /** @type {[string, string][]} */
24
+ get token(): [string, string][];
25
+ /** @type {EikjsonSchema["files"]} */
26
+ get files(): string | {
27
+ [k: string]: string;
28
+ };
29
+ /**
30
+ * Normalized relative directory path with any leading ./ or
31
+ * trailing / characters stripped. Defaults to .eik
32
+ *
33
+ * @returns {string} out path string
34
+ */
35
+ get out(): string;
36
+ /**
37
+ * Serializes internal values to an object
38
+ *
39
+ * @returns {EikjsonSchema} object consistent with EikjsonSchema
40
+ */
41
+ toJSON(): EikjsonSchema;
42
+ /**
43
+ * Validates config values against the eik JSON schema
44
+ *
45
+ * @return {void}
46
+ */
47
+ validate(): void;
48
+ /**
49
+ * Resolves file locations on disk based on values defined in files property
50
+ * of config object.
51
+ *
52
+ * @returns {Promise<FileMapping[]>}
53
+ */
54
+ mappings(): Promise<FileMapping[]>;
55
+ /** @type EikjsonSchema */
56
+ [_config]: EikjsonSchema;
57
+ [_tokens]: Map<string, string>;
58
+ }
59
+ export type EikjsonSchema = import("../../eikjson").EikjsonSchema;
60
+ import FileMapping from './file-mapping.js';
61
+ declare const _config: unique symbol;
62
+ declare const _tokens: unique symbol;
63
+ export {};
@@ -0,0 +1,21 @@
1
+ export default FileMapping;
2
+ /**
3
+ * Class containing a local file system source location and remote server destination location for a file.
4
+ */
5
+ declare class FileMapping {
6
+ /**
7
+ * @param {LocalFileLocation} source
8
+ * @param {RemoteFileLocation} destination
9
+ */
10
+ constructor(source: LocalFileLocation, destination: RemoteFileLocation);
11
+ /**
12
+ * @type {LocalFileLocation} source
13
+ */
14
+ source: LocalFileLocation;
15
+ /**
16
+ * @type {RemoteFileLocation} destination
17
+ */
18
+ destination: RemoteFileLocation;
19
+ }
20
+ import LocalFileLocation from './local-file-location.js';
21
+ import RemoteFileLocation from './remote-file-location.js';
@@ -0,0 +1,3 @@
1
+ export default class InvalidConfigError extends CustomError {
2
+ }
3
+ import CustomError from './custom-error.js';
@@ -0,0 +1,36 @@
1
+ export default LocalFileLocation;
2
+ /**
3
+ * Class containing information about a local file
4
+ */
5
+ declare class LocalFileLocation {
6
+ /**
7
+ * @param {string} path path to file on disk relative to basePath
8
+ * @param {string} basePath basePath to the file's location on disk
9
+ */
10
+ constructor(path: string, basePath: string);
11
+ /**
12
+ * @type {string} path to file on disk relative to this.basePath
13
+ */
14
+ relative: string;
15
+ /**
16
+ * @type {string} absolute path to root files location on disk
17
+ */
18
+ basePath: string;
19
+ /**
20
+ * @type {string} absolute path to file on disk,
21
+ * this is a concatentation of this.basePath and this.relative
22
+ */
23
+ absolute: string;
24
+ /**
25
+ * @type {string} file extension with "." character included. (eg. ".json")
26
+ */
27
+ extension: string;
28
+ /**
29
+ * @type {string} full content-type header value for file
30
+ */
31
+ contentType: string;
32
+ /**
33
+ * @type {string} mime type of file
34
+ */
35
+ mimeType: string;
36
+ }
@@ -0,0 +1,3 @@
1
+ export default class MissingConfigError extends CustomError {
2
+ }
3
+ import CustomError from './custom-error.js';
@@ -0,0 +1,4 @@
1
+ export default class MultipleConfigSourcesError extends CustomError {
2
+ constructor();
3
+ }
4
+ import CustomError from './custom-error.js';
@@ -0,0 +1,3 @@
1
+ export default class NoFilesMatchedError extends CustomError {
2
+ }
3
+ import CustomError from './custom-error.js';
@@ -0,0 +1,15 @@
1
+ export default ReadFile;
2
+ declare const ReadFile: {
3
+ new ({ mimeType, etag }?: {
4
+ mimeType?: string | undefined;
5
+ etag?: string | undefined;
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
+ };
@@ -0,0 +1,21 @@
1
+ export default 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
+ }
@@ -0,0 +1,20 @@
1
+ export default 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 from './local-file-location.js';
20
+ declare const originalFiles: unique symbol;
@@ -0,0 +1,3 @@
1
+ export default class SingleDestMultipleSourcesError extends CustomError {
2
+ }
3
+ import CustomError from './custom-error.js';
@@ -0,0 +1,28 @@
1
+ declare namespace _default {
2
+ /**
3
+ * Load the configuration from an exact path and return an EikConfig object
4
+ *
5
+ * @param {string} configFilePathname
6
+ * @param {function} loadJSONFromDisk
7
+ *
8
+ * @returns {EikConfig}
9
+ */
10
+ function loadFromPath(configFilePathname: 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
+ function findInDirectory(configRootDir: string, loadJSONFromDisk?: Function | undefined): EikConfig;
20
+ /**
21
+ * Persist config changes to disk as <cwd>/eik.json
22
+ *
23
+ * @param {import('../classes/eik-config')} config
24
+ */
25
+ function persistToDisk(config: typeof import("../classes/eik-config.js")): void;
26
+ }
27
+ export default _default;
28
+ import EikConfig from '../classes/eik-config.js';