@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
@@ -0,0 +1,34 @@
1
+ {
2
+ "name": "@eik/common-validators",
3
+ "version": "1.0.0",
4
+ "description": "Shared validators for all Eik packages",
5
+ "main": "src/index.js",
6
+ "scripts": {
7
+ "test": "tap --no-check-coverage",
8
+ "test:snapshots:update": "tap --snapshot",
9
+ "lint:fix": "eslint --fix .",
10
+ "lint": "eslint .",
11
+ "style:check": "prettier -c .",
12
+ "style:format": "prettier -w .",
13
+ "typecheck": "tsc"
14
+ },
15
+ "license": "ISC",
16
+ "dependencies": {
17
+ "semver": "7.3.7",
18
+ "tap": "15.2.3",
19
+ "validate-npm-package-name": "4.0.0"
20
+ },
21
+ "devDependencies": {
22
+ "@babel/eslint-parser": "7.16.5",
23
+ "@semantic-release/changelog": "^6.0.1",
24
+ "@semantic-release/git": "^10.0.1",
25
+ "@types/node": "18.0.6",
26
+ "eslint": "7.32.0",
27
+ "eslint-config-airbnb-base": "14.2.1",
28
+ "eslint-config-prettier": "8.5.0",
29
+ "eslint-plugin-import": "2.26.0",
30
+ "eslint-plugin-prettier": "4.2.1",
31
+ "prettier": "2.5.1",
32
+ "typescript": "4.7.4"
33
+ }
34
+ }
@@ -0,0 +1,53 @@
1
+ const semver = require('semver');
2
+ const npmPkg = require('validate-npm-package-name');
3
+
4
+ module.exports = {
5
+ origin: (value) => {
6
+ if (new RegExp('^https?://[a-zA-Z0-9-_./]+(:[0-9]+)?').test(value)) {
7
+ return value.toLowerCase();
8
+ }
9
+ throw new Error('Parameter "origin" is not valid');
10
+ },
11
+ org: (value) => {
12
+ if (/^[a-zA-Z0-9_-]+$/.test(value)) {
13
+ return value.toLowerCase();
14
+ }
15
+ throw new Error(`Parameter "org" is not valid - Value: ${value}`);
16
+ },
17
+ name: (value) => {
18
+ const result = npmPkg(value);
19
+ if (result.validForNewPackages || result.validForOldPackages) {
20
+ return value.toLowerCase();
21
+ }
22
+ throw new Error(`Parameter "name" is not valid - Value: ${value}`);
23
+ },
24
+ version: (value) => {
25
+ const result = semver.valid(value);
26
+ if (result) {
27
+ return result;
28
+ }
29
+ throw new Error(`Parameter "version" is not valid - Value: ${value}`);
30
+ },
31
+ alias: (value) => {
32
+ if (/^[0-9]+$/.test(value)) {
33
+ return value;
34
+ }
35
+ throw new Error(`Parameter "alias" is not valid - Value: ${value}`);
36
+ },
37
+ type: (value) => {
38
+ if (value === 'pkg' || value === 'map' || value === 'npm') {
39
+ return value;
40
+ }
41
+ throw new Error(`Parameter "type" is not valid - Value: ${value}`);
42
+ },
43
+ semverType: (value) => {
44
+ if (value === 'major' || value === 'minor' || value === 'patch') {
45
+ return value;
46
+ }
47
+ throw new Error(
48
+ `Parameter "semverType" is not valid - Value: ${value}`,
49
+ );
50
+ },
51
+ // TODO; https://github.com/asset-pipe/core/issues/12
52
+ extra: (value) => value,
53
+ };
@@ -0,0 +1,238 @@
1
+ const tap = require('tap');
2
+ const validators = require('../src/index.js');
3
+
4
+ //
5
+ // .origin()
6
+ //
7
+
8
+ tap.test('.origin() - valid values - should return value', (t) => {
9
+ t.equal(validators.origin('http://origin.com'), 'http://origin.com');
10
+ t.equal(
11
+ validators.origin('http://origin.com/one/two'),
12
+ 'http://origin.com/one/two',
13
+ );
14
+ t.equal(validators.origin('http://s'), 'http://s');
15
+ t.equal(validators.origin('https://s'), 'https://s');
16
+ t.equal(
17
+ validators.origin('http://localhost:4001'),
18
+ 'http://localhost:4001',
19
+ );
20
+ t.equal(
21
+ validators.origin('http://127.0.0.1:4001'),
22
+ 'http://127.0.0.1:4001',
23
+ );
24
+ t.end();
25
+ });
26
+
27
+ tap.test('.origin() - invalid values - should throw', (t) => {
28
+ t.throws(() => {
29
+ validators.origin('!name');
30
+ }, new Error('Parameter "origin" is not valid'));
31
+ t.end();
32
+ });
33
+
34
+ tap.test(
35
+ '.origin() - upper case valid value - should convert to lower case value',
36
+ (t) => {
37
+ t.equal(validators.origin('http://some-origin'), 'http://some-origin');
38
+ t.equal(validators.origin('http://SOME_origin'), 'http://some_origin');
39
+ t.end();
40
+ },
41
+ );
42
+
43
+ //
44
+ // .org()
45
+ //
46
+
47
+ tap.test('.org() - valid values - should return value', (t) => {
48
+ t.equal(validators.org('someorg'), 'someorg');
49
+ t.equal(validators.org('some-org'), 'some-org');
50
+ t.equal(validators.org('some_org'), 'some_org');
51
+ t.equal(validators.org('123'), '123');
52
+ t.end();
53
+ });
54
+
55
+ tap.test('.org() - invalid values - should throw', (t) => {
56
+ t.throws(() => {
57
+ validators.org('!name');
58
+ }, new Error('Parameter "org" is not valid'));
59
+ t.end();
60
+ });
61
+
62
+ tap.test(
63
+ '.org() - upper case valid value - should convert to lower case value',
64
+ (t) => {
65
+ t.equal(validators.org('SOMEorg'), 'someorg');
66
+ t.equal(validators.org('some-ORG'), 'some-org');
67
+ t.equal(validators.org('SOME_ORG'), 'some_org');
68
+ t.equal(validators.org('123'), '123');
69
+ t.end();
70
+ },
71
+ );
72
+
73
+ //
74
+ // .name()
75
+ //
76
+
77
+ tap.test('.name() - valid values - should return value', (t) => {
78
+ t.equal(validators.name('some-package'), 'some-package');
79
+ t.equal(validators.name('example.com'), 'example.com');
80
+ t.equal(validators.name('under_score'), 'under_score');
81
+ t.equal(validators.name('123numeric'), '123numeric');
82
+ t.equal(validators.name('@npm/thingy'), '@npm/thingy');
83
+ t.equal(validators.name('@jane/foo.js'), '@jane/foo.js');
84
+ t.end();
85
+ });
86
+
87
+ tap.test('.name() - invalid values - should throw', (t) => {
88
+ t.throws(() => {
89
+ validators.name(' leading-space:and:weirdchars');
90
+ }, new Error('Parameter "name" is not valid'));
91
+ t.end();
92
+ });
93
+
94
+ //
95
+ // .version()
96
+ //
97
+
98
+ tap.test('.version() - valid values - should return value', (t) => {
99
+ t.equal(validators.version('2.3.4'), '2.3.4');
100
+ t.equal(validators.version('1.2.4-beta.0'), '1.2.4-beta.0');
101
+ t.end();
102
+ });
103
+
104
+ tap.test('.version() - invalid values - should throw', (t) => {
105
+ t.throws(() => {
106
+ validators.version(' 1.and:weirdchars~5');
107
+ }, new Error('Parameter "version" is not valid'));
108
+ t.end();
109
+ });
110
+
111
+ tap.test('.version() - caret range - should throw', (t) => {
112
+ t.throws(() => {
113
+ validators.version('^1.2.4');
114
+ }, new Error('Parameter "version" is not valid'));
115
+ t.end();
116
+ });
117
+
118
+ tap.test('.version() - tilde range - should throw', (t) => {
119
+ t.throws(() => {
120
+ validators.version('~1.2.4');
121
+ }, new Error('Parameter "version" is not valid'));
122
+ t.end();
123
+ });
124
+
125
+ tap.test('.version() - X-range - should throw', (t) => {
126
+ t.throws(() => {
127
+ validators.version('1.x');
128
+ }, new Error('Parameter "version" is not valid'));
129
+ t.end();
130
+ });
131
+
132
+ tap.test('.version() - * - should throw', (t) => {
133
+ t.throws(() => {
134
+ validators.version('*');
135
+ }, new Error('Parameter "version" is not valid'));
136
+ t.end();
137
+ });
138
+
139
+ tap.test('.version() - latest - should throw', (t) => {
140
+ t.throws(() => {
141
+ validators.version('latest');
142
+ }, new Error('Parameter "version" is not valid'));
143
+ t.end();
144
+ });
145
+
146
+ //
147
+ // .alias()
148
+ //
149
+
150
+ tap.test('.alias() - valid values - should return value', (t) => {
151
+ t.equal(validators.alias('8'), '8');
152
+ t.equal(validators.alias('10'), '10');
153
+ t.equal(validators.alias('10893475983749384'), '10893475983749384');
154
+ t.end();
155
+ });
156
+
157
+ tap.test('.name() - invalid value - semver patch - should throw', (t) => {
158
+ t.throws(() => {
159
+ validators.alias('1.2.4');
160
+ }, new Error('Parameter "alias" is not valid'));
161
+ t.end();
162
+ });
163
+
164
+ tap.test('.name() - invalid value - semver minor - should throw', (t) => {
165
+ t.throws(() => {
166
+ validators.alias('1.2');
167
+ }, new Error('Parameter "alias" is not valid'));
168
+ t.end();
169
+ });
170
+
171
+ tap.test('.name() - invalid value - semver latest - should throw', (t) => {
172
+ t.throws(() => {
173
+ validators.alias('latest');
174
+ }, new Error('Parameter "alias" is not valid'));
175
+ t.end();
176
+ });
177
+
178
+ //
179
+ // .type()
180
+ //
181
+
182
+ tap.test('.type() - valid values - should return value', (t) => {
183
+ t.equal(validators.type('pkg'), 'pkg');
184
+ t.equal(validators.type('map'), 'map');
185
+ t.equal(validators.type('npm'), 'npm');
186
+ t.end();
187
+ });
188
+
189
+ tap.test('.type() - invalid value - should throw', (t) => {
190
+ t.throws(() => {
191
+ validators.type('foo');
192
+ }, new Error('Parameter "type" is not valid'));
193
+ t.end();
194
+ });
195
+
196
+ tap.test('.type() - invalid value - upper case - should throw', (t) => {
197
+ t.throws(() => {
198
+ validators.type('PKG');
199
+ }, new Error('Parameter "type" is not valid'));
200
+ t.end();
201
+ });
202
+
203
+ //
204
+ // .extra()
205
+ //
206
+
207
+ tap.test('.extra() - valid values - should return value', (t) => {
208
+ t.equal(validators.extra('/foo/bar/index.js'), '/foo/bar/index.js');
209
+ t.equal(validators.extra('/foo/a9-8_3/index.js'), '/foo/a9-8_3/index.js');
210
+ t.equal(validators.extra('/foo/bar'), '/foo/bar');
211
+ t.equal(validators.extra('index.js'), 'index.js');
212
+ t.end();
213
+ });
214
+
215
+ //
216
+ // .semverType()
217
+ //
218
+
219
+ tap.test('.semverType() - valid values - should return value', (t) => {
220
+ t.equal(validators.semverType('major'), 'major');
221
+ t.equal(validators.semverType('minor'), 'minor');
222
+ t.equal(validators.semverType('patch'), 'patch');
223
+ t.end();
224
+ });
225
+
226
+ tap.test('.semverType() - invalid value - should throw', (t) => {
227
+ t.throws(() => {
228
+ validators.semverType('foo');
229
+ }, new Error('Parameter "semverType" is not valid'));
230
+ t.end();
231
+ });
232
+
233
+ tap.test('.semverType() - invalid value - upper case - should throw', (t) => {
234
+ t.throws(() => {
235
+ validators.semverType('MAJOR');
236
+ }, new Error('Parameter "semverType" is not valid'));
237
+ t.end();
238
+ });
@@ -0,0 +1,27 @@
1
+ module.exports = {
2
+ plugins: [
3
+ '@semantic-release/commit-analyzer',
4
+ '@semantic-release/release-notes-generator',
5
+ '@semantic-release/changelog',
6
+ [
7
+ '@semantic-release/npm',
8
+ {
9
+ tarballDir: 'release',
10
+ },
11
+ ],
12
+ [
13
+ '@semantic-release/github',
14
+ {
15
+ assets: 'release/*.tgz',
16
+ },
17
+ ],
18
+ '@semantic-release/git',
19
+ ],
20
+ preset: 'angular',
21
+ branches: [
22
+ { name: 'master' },
23
+ { name: 'alpha', prerelease: true },
24
+ { name: 'beta', prerelease: true },
25
+ { name: 'next', prerelease: true },
26
+ ],
27
+ };
package/renovate.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "$schema": "https://docs.renovatebot.com/renovate-schema.json",
3
+ "extends": [
4
+ "github>eik-lib/renovate-presets:sub-level-module"
5
+ ]
6
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,30 @@
1
+ {
2
+ "compilerOptions": {
3
+ "lib": [
4
+ "es2020",
5
+ "dom"
6
+ ],
7
+ "module": "es2020",
8
+ "target": "es2020",
9
+ "resolveJsonModule": true,
10
+ "checkJs": true,
11
+ "allowJs": true,
12
+ "moduleResolution": "node",
13
+ "noEmit": false,
14
+ "declaration": true,
15
+ "emitDeclarationOnly": true,
16
+ "outDir": "types"
17
+ },
18
+ "include": [
19
+ "lib",
20
+ "packages/validators/index.js",
21
+ "packages/helpers/src/type-slug.js",
22
+ "packages/helpers/src/config-store.js",
23
+ "packages/schemas/src/validation-error.js",
24
+ "packages/schemas/src/validate.js",
25
+ "packages/schemas/index.js",
26
+ "packages/schemas/src/assert.js",
27
+ "packages/shared/src/stream.js",
28
+ "packages/config-loader/src/custom-error.js"
29
+ ]
30
+ }
@@ -1,25 +0,0 @@
1
- const localAssets = require('./local-assets');
2
- const getDefaults = require('./get-defaults');
3
- const configStore = require('./config-store');
4
- const typeSlug = require('./type-slug');
5
- const typeTitle = require('./type-title');
6
- const resolveFiles = require('./resolve-files');
7
- const {
8
- addTrailingSlash,
9
- removeTrailingSlash,
10
- addLeadingSlash,
11
- removeLeadingSlash,
12
- } = require('./path-slashes');
13
-
14
- module.exports = {
15
- localAssets,
16
- getDefaults,
17
- configStore,
18
- typeSlug,
19
- typeTitle,
20
- addTrailingSlash,
21
- removeTrailingSlash,
22
- addLeadingSlash,
23
- removeLeadingSlash,
24
- resolveFiles,
25
- };
package/lib/index.js DELETED
@@ -1,17 +0,0 @@
1
- 'use strict';
2
-
3
- const validators = require('./validators');
4
- const ReadFile = require('./classes/read-file');
5
- const EikConfig = require('./classes/eik-config');
6
- const schemas = require('./schemas');
7
- const stream = require('./stream');
8
- const helpers = require('./helpers');
9
-
10
- module.exports = {
11
- validators,
12
- ReadFile,
13
- EikConfig,
14
- schemas,
15
- stream,
16
- helpers,
17
- };
@@ -1,8 +0,0 @@
1
- // @ts-check
2
-
3
- const schema = require('./eikjson.schema.json');
4
- const validate = require('./validate');
5
- const assert = require('./assert');
6
- const ValidationError = require('./validation-error');
7
-
8
- module.exports = { schema, validate, assert, ValidationError };
package/lib/stream.js DELETED
@@ -1,14 +0,0 @@
1
- 'use strict';
2
-
3
- const isStream = (stream) =>
4
- stream !== null &&
5
- typeof stream === 'object' &&
6
- typeof stream.pipe === 'function';
7
- module.exports.isStream = isStream;
8
-
9
- const isReadableStream = (stream) =>
10
- isStream(stream) &&
11
- stream.readable !== false &&
12
- typeof stream._read === 'function' &&
13
- typeof stream._readableState === 'object';
14
- module.exports.isReadableStream = isReadableStream;
@@ -1,66 +0,0 @@
1
- 'use strict';
2
-
3
- const semver = require('semver');
4
- const npmPkg = require('validate-npm-package-name');
5
-
6
- const origin = (value) => {
7
- if (new RegExp('^https?://[a-zA-Z0-9-_./]+(:[0-9]+)?').test(value)) {
8
- return value.toLowerCase();
9
- }
10
- throw new Error('Parameter "origin" is not valid');
11
- };
12
- module.exports.origin = origin;
13
-
14
- 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
- module.exports.org = org;
21
-
22
- 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
- module.exports.name = name;
30
-
31
- 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
- module.exports.version = version;
39
-
40
- 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
- module.exports.alias = alias;
47
-
48
- 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
- module.exports.type = type;
55
-
56
- // TODO; https://github.com/asset-pipe/core/issues/12
57
- const extra = (value) => value;
58
- module.exports.extra = extra;
59
-
60
- 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
- };
66
- module.exports.semverType = semverType;
@@ -1,7 +0,0 @@
1
- export = CustomError;
2
- declare class CustomError extends Error {
3
- /**
4
- * @param {string} message
5
- */
6
- constructor(message: string);
7
- }
@@ -1,57 +0,0 @@
1
- export = EikConfig;
2
- declare class EikConfig {
3
- /**
4
- * @param {EikjsonSchema?} configHash
5
- * @param {[string, string][]?} tokens
6
- * @param {string?} configRootDir
7
- */
8
- constructor(configHash: EikjsonSchema | null, tokens?: [string, string][] | null, configRootDir?: string | null);
9
- cwd: string;
10
- /** @type {string[]} */
11
- map: string[];
12
- /** @type {EikjsonSchema["name"]} */
13
- get name(): string;
14
- set version(arg: string);
15
- /** @type {EikjsonSchema["version"]} */
16
- get version(): string;
17
- /** @type {EikjsonSchema["type"]} */
18
- get type(): "map" | "npm" | "package";
19
- /** @type {string} */
20
- get server(): string;
21
- /** @type {[string, string][]} */
22
- get token(): [string, string][];
23
- /** @type {EikjsonSchema["files"]} */
24
- get files(): string | {
25
- [k: string]: string;
26
- };
27
- /**
28
- * Normalized relative directory path with any leading ./ or
29
- * trailing / characters stripped. Defaults to .eik
30
- *
31
- * @returns {string} out path string
32
- */
33
- get out(): string;
34
- /**
35
- * Serializes internal values to an object
36
- *
37
- * @returns {EikjsonSchema} object consistent with EikjsonSchema
38
- */
39
- toJSON(): EikjsonSchema;
40
- /**
41
- * Validates config values against the eik JSON schema
42
- *
43
- * @return {void}
44
- */
45
- validate(): void;
46
- /**
47
- * Resolves file locations on disk based on values defined in files property
48
- * of config object.
49
- *
50
- * @returns {Promise<FileMapping[]>}
51
- */
52
- mappings(): Promise<import("./file-mapping")[]>;
53
- }
54
- declare namespace EikConfig {
55
- export { EikjsonSchema };
56
- }
57
- type EikjsonSchema = import("../../eikjson").EikjsonSchema;
@@ -1,19 +0,0 @@
1
- export = 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: import("./local-file-location"), destination: import("./remote-file-location"));
11
- /**
12
- * @type {LocalFileLocation} source
13
- */
14
- source: import("./local-file-location");
15
- /**
16
- * @type {RemoteFileLocation} destination
17
- */
18
- destination: import("./remote-file-location");
19
- }
@@ -1,13 +0,0 @@
1
- export = InvalidConfigError;
2
- declare const InvalidConfigError_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 InvalidConfigError extends InvalidConfigError_base {
9
- /**
10
- * @param {string} msg
11
- */
12
- constructor(msg: string);
13
- }
@@ -1,36 +0,0 @@
1
- export = 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
- }
@@ -1,13 +0,0 @@
1
- export = MissingConfigError;
2
- declare const MissingConfigError_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 MissingConfigError extends MissingConfigError_base {
9
- /**
10
- * @param {string} dir
11
- */
12
- constructor(dir: string);
13
- }