@atlaspack/core 2.12.1-canary.3377 → 2.12.1-canary.3379
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/AtlaspackConfig.schema.js +10 -36
- package/package.json +16 -16
- package/src/AtlaspackConfig.schema.js +13 -36
- package/test/AtlaspackConfigRequest.test.js +0 -161
|
@@ -5,42 +5,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
exports.validatePackageName = validatePackageName;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
//
|
|
17
|
-
|
|
18
|
-
function validatePackageName(pkg, pluginType, key) {
|
|
19
|
-
// $FlowFixMe
|
|
20
|
-
if (!pkg) {
|
|
21
|
-
return;
|
|
22
|
-
}
|
|
23
|
-
(0, _assert().default)(typeof pkg === 'string', `"${key}" must be a string`);
|
|
24
|
-
|
|
25
|
-
// Probably all of these need to be removed
|
|
26
|
-
if (pkg.startsWith('@atlaspack') || pkg.startsWith('@parcel')) {
|
|
27
|
-
(0, _assert().default)(pkg.replace(/^@(atlaspack|parcel)\//, '').startsWith(`${pluginType}-`), `Official atlaspack ${pluginType} packages must be named according to "@atlaspack/${pluginType}-{name}"`);
|
|
28
|
-
} else if (pkg.startsWith('@')) {
|
|
29
|
-
// Disabling this validation to allow for migration to parcel
|
|
30
|
-
// let [scope, name] = pkg.split('/');
|
|
31
|
-
// assert(
|
|
32
|
-
// name.startsWith(`parcel-${pluginType}-`) ||
|
|
33
|
-
// name === `parcel-${pluginType}` ||
|
|
34
|
-
// name.startsWith(`parcel-${pluginType}-`) ||
|
|
35
|
-
// name === `parcel-${pluginType}`,
|
|
36
|
-
// `Scoped parcel ${pluginType} packages must be named according to "${scope}/parcel-${pluginType}[-{name}]"`,
|
|
37
|
-
// );
|
|
38
|
-
} else if (!pkg.startsWith('.')) {
|
|
39
|
-
(0, _assert().default)(pkg.startsWith(`parcel-${pluginType}-`) || pkg.startsWith(`atlaspack-${pluginType}`),
|
|
40
|
-
// let the error message be wrong for now
|
|
41
|
-
`Atlaspack ${pluginType} packages must be named according to "parcel-${pluginType}-{name}"`);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
8
|
+
// Parcel validates plugin package names due to:
|
|
9
|
+
//
|
|
10
|
+
// * https://github.com/parcel-bundler/parcel/issues/3397#issuecomment-521353931
|
|
11
|
+
//
|
|
12
|
+
// Ultimately:
|
|
13
|
+
//
|
|
14
|
+
// * We do not care about package names
|
|
15
|
+
// * Validation makes interop between parcel/atlaspack confusing.
|
|
16
|
+
//
|
|
17
|
+
function validatePackageName() {}
|
|
44
18
|
const validatePluginName = (pluginType, key) => {
|
|
45
19
|
return val => {
|
|
46
20
|
// allow plugin spread...
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaspack/core",
|
|
3
|
-
"version": "2.12.1-canary.
|
|
3
|
+
"version": "2.12.1-canary.3379+e4dbdd5c5",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -20,20 +20,20 @@
|
|
|
20
20
|
"check-ts": "tsc --noEmit index.d.ts"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@atlaspack/cache": "2.12.1-canary.
|
|
24
|
-
"@atlaspack/diagnostic": "2.12.1-canary.
|
|
25
|
-
"@atlaspack/events": "2.12.1-canary.
|
|
26
|
-
"@atlaspack/feature-flags": "2.12.1-canary.
|
|
27
|
-
"@atlaspack/fs": "2.12.1-canary.
|
|
28
|
-
"@atlaspack/graph": "3.2.1-canary.
|
|
29
|
-
"@atlaspack/logger": "2.12.1-canary.
|
|
30
|
-
"@atlaspack/package-manager": "2.12.1-canary.
|
|
31
|
-
"@atlaspack/plugin": "2.12.1-canary.
|
|
32
|
-
"@atlaspack/profiler": "2.12.1-canary.
|
|
33
|
-
"@atlaspack/rust": "2.12.1-canary.
|
|
34
|
-
"@atlaspack/types": "2.12.1-canary.
|
|
35
|
-
"@atlaspack/utils": "2.12.1-canary.
|
|
36
|
-
"@atlaspack/workers": "2.12.1-canary.
|
|
23
|
+
"@atlaspack/cache": "2.12.1-canary.3379+e4dbdd5c5",
|
|
24
|
+
"@atlaspack/diagnostic": "2.12.1-canary.3379+e4dbdd5c5",
|
|
25
|
+
"@atlaspack/events": "2.12.1-canary.3379+e4dbdd5c5",
|
|
26
|
+
"@atlaspack/feature-flags": "2.12.1-canary.3379+e4dbdd5c5",
|
|
27
|
+
"@atlaspack/fs": "2.12.1-canary.3379+e4dbdd5c5",
|
|
28
|
+
"@atlaspack/graph": "3.2.1-canary.3379+e4dbdd5c5",
|
|
29
|
+
"@atlaspack/logger": "2.12.1-canary.3379+e4dbdd5c5",
|
|
30
|
+
"@atlaspack/package-manager": "2.12.1-canary.3379+e4dbdd5c5",
|
|
31
|
+
"@atlaspack/plugin": "2.12.1-canary.3379+e4dbdd5c5",
|
|
32
|
+
"@atlaspack/profiler": "2.12.1-canary.3379+e4dbdd5c5",
|
|
33
|
+
"@atlaspack/rust": "2.12.1-canary.3379+e4dbdd5c5",
|
|
34
|
+
"@atlaspack/types": "2.12.1-canary.3379+e4dbdd5c5",
|
|
35
|
+
"@atlaspack/utils": "2.12.1-canary.3379+e4dbdd5c5",
|
|
36
|
+
"@atlaspack/workers": "2.12.1-canary.3379+e4dbdd5c5",
|
|
37
37
|
"@mischnic/json-sourcemap": "^0.1.0",
|
|
38
38
|
"@parcel/source-map": "^2.1.1",
|
|
39
39
|
"base-x": "^3.0.8",
|
|
@@ -55,5 +55,5 @@
|
|
|
55
55
|
"browser": {
|
|
56
56
|
"./src/serializerCore.js": "./src/serializerCore.browser.js"
|
|
57
57
|
},
|
|
58
|
-
"gitHead": "
|
|
58
|
+
"gitHead": "e4dbdd5c542a6dc690329839dc2bec8c797b72ba"
|
|
59
59
|
}
|
|
@@ -1,47 +1,24 @@
|
|
|
1
1
|
// @flow strict-local
|
|
2
2
|
import type {PackageName} from '@atlaspack/types';
|
|
3
3
|
import type {SchemaEntity} from '@atlaspack/utils';
|
|
4
|
-
import assert from 'assert';
|
|
5
4
|
|
|
6
|
-
//
|
|
7
|
-
//
|
|
5
|
+
// Parcel validates plugin package names due to:
|
|
6
|
+
//
|
|
7
|
+
// * https://github.com/parcel-bundler/parcel/issues/3397#issuecomment-521353931
|
|
8
|
+
//
|
|
9
|
+
// Ultimately:
|
|
10
|
+
//
|
|
11
|
+
// * We do not care about package names
|
|
12
|
+
// * Validation makes interop between parcel/atlaspack confusing.
|
|
13
|
+
//
|
|
8
14
|
export function validatePackageName(
|
|
15
|
+
// eslint-disable-next-line no-unused-vars
|
|
9
16
|
pkg: ?PackageName,
|
|
17
|
+
// eslint-disable-next-line no-unused-vars
|
|
10
18
|
pluginType: string,
|
|
19
|
+
// eslint-disable-next-line no-unused-vars
|
|
11
20
|
key: string,
|
|
12
|
-
) {
|
|
13
|
-
// $FlowFixMe
|
|
14
|
-
if (!pkg) {
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
assert(typeof pkg === 'string', `"${key}" must be a string`);
|
|
19
|
-
|
|
20
|
-
// Probably all of these need to be removed
|
|
21
|
-
if (pkg.startsWith('@atlaspack') || pkg.startsWith('@parcel')) {
|
|
22
|
-
assert(
|
|
23
|
-
pkg.replace(/^@(atlaspack|parcel)\//, '').startsWith(`${pluginType}-`),
|
|
24
|
-
`Official atlaspack ${pluginType} packages must be named according to "@atlaspack/${pluginType}-{name}"`,
|
|
25
|
-
);
|
|
26
|
-
} else if (pkg.startsWith('@')) {
|
|
27
|
-
// Disabling this validation to allow for migration to parcel
|
|
28
|
-
// let [scope, name] = pkg.split('/');
|
|
29
|
-
// assert(
|
|
30
|
-
// name.startsWith(`parcel-${pluginType}-`) ||
|
|
31
|
-
// name === `parcel-${pluginType}` ||
|
|
32
|
-
// name.startsWith(`parcel-${pluginType}-`) ||
|
|
33
|
-
// name === `parcel-${pluginType}`,
|
|
34
|
-
// `Scoped parcel ${pluginType} packages must be named according to "${scope}/parcel-${pluginType}[-{name}]"`,
|
|
35
|
-
// );
|
|
36
|
-
} else if (!pkg.startsWith('.')) {
|
|
37
|
-
assert(
|
|
38
|
-
pkg.startsWith(`parcel-${pluginType}-`) ||
|
|
39
|
-
pkg.startsWith(`atlaspack-${pluginType}`),
|
|
40
|
-
// let the error message be wrong for now
|
|
41
|
-
`Atlaspack ${pluginType} packages must be named according to "parcel-${pluginType}-{name}"`,
|
|
42
|
-
);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
21
|
+
) {}
|
|
45
22
|
|
|
46
23
|
const validatePluginName = (pluginType: string, key: string) => {
|
|
47
24
|
return (val: string) => {
|
|
@@ -13,107 +13,11 @@ import {
|
|
|
13
13
|
resolveAtlaspackConfig,
|
|
14
14
|
processConfig,
|
|
15
15
|
} from '../src/requests/AtlaspackConfigRequest';
|
|
16
|
-
import {validatePackageName} from '../src/AtlaspackConfig.schema';
|
|
17
16
|
import {DEFAULT_OPTIONS, relative} from './test-utils';
|
|
18
17
|
import {toProjectPath} from '../src/projectPath';
|
|
19
18
|
|
|
20
19
|
describe('AtlaspackConfigRequest', () => {
|
|
21
|
-
describe('validatePackageName', () => {
|
|
22
|
-
it('should error on an invalid official package', () => {
|
|
23
|
-
assert.throws(() => {
|
|
24
|
-
validatePackageName('@atlaspack/foo-bar', 'transform', 'transformers');
|
|
25
|
-
}, /Official atlaspack transform packages must be named according to "@atlaspack\/transform-{name}"/);
|
|
26
|
-
|
|
27
|
-
assert.throws(() => {
|
|
28
|
-
validatePackageName(
|
|
29
|
-
'@atlaspack/transformer',
|
|
30
|
-
'transform',
|
|
31
|
-
'transformers',
|
|
32
|
-
);
|
|
33
|
-
}, /Official atlaspack transform packages must be named according to "@atlaspack\/transform-{name}"/);
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
it('should succeed on a valid official package', () => {
|
|
37
|
-
validatePackageName(
|
|
38
|
-
'@atlaspack/transform-bar',
|
|
39
|
-
'transform',
|
|
40
|
-
'transformers',
|
|
41
|
-
);
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
it('should error on an invalid community package', () => {
|
|
45
|
-
assert.throws(() => {
|
|
46
|
-
validatePackageName('foo-bar', 'transform', 'transformers');
|
|
47
|
-
}, /Atlaspack transform packages must be named according to "parcel-transform-{name}"/);
|
|
48
|
-
|
|
49
|
-
assert.throws(() => {
|
|
50
|
-
validatePackageName('parcel-foo-bar', 'transform', 'transformers');
|
|
51
|
-
}, /Atlaspack transform packages must be named according to "parcel-transform-{name}"/);
|
|
52
|
-
|
|
53
|
-
assert.throws(() => {
|
|
54
|
-
validatePackageName('parcel-transform', 'transform', 'transformers');
|
|
55
|
-
}, /Atlaspack transform packages must be named according to "parcel-transform-{name}"/);
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
it('should succeed on a valid community package', () => {
|
|
59
|
-
validatePackageName('parcel-transform-bar', 'transform', 'transformers');
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
// Skipping this while the migration to parcel occurs
|
|
63
|
-
it.skip('should error on an invalid scoped package', () => {
|
|
64
|
-
assert.throws(() => {
|
|
65
|
-
validatePackageName('@test/foo-bar', 'transform', 'transformers');
|
|
66
|
-
}, /Scoped atlaspack transform packages must be named according to "@test\/parcel-transform\[-{name}\]"/);
|
|
67
|
-
|
|
68
|
-
assert.throws(() => {
|
|
69
|
-
validatePackageName(
|
|
70
|
-
'@test/atlaspack-foo-bar',
|
|
71
|
-
'transform',
|
|
72
|
-
'transformers',
|
|
73
|
-
);
|
|
74
|
-
}, /Scoped atlaspack transform packages must be named according to "@test\/parcel-transform\[-{name}\]"/);
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
it('should succeed on a valid scoped package', () => {
|
|
78
|
-
validatePackageName(
|
|
79
|
-
'@test/atlaspack-transform-bar',
|
|
80
|
-
'transform',
|
|
81
|
-
'transformers',
|
|
82
|
-
);
|
|
83
|
-
|
|
84
|
-
validatePackageName(
|
|
85
|
-
'@test/atlaspack-transform',
|
|
86
|
-
'transform',
|
|
87
|
-
'transformers',
|
|
88
|
-
);
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
it('should succeed on a local package', () => {
|
|
92
|
-
validatePackageName(
|
|
93
|
-
'./atlaspack-transform-bar',
|
|
94
|
-
'transform',
|
|
95
|
-
'transformers',
|
|
96
|
-
);
|
|
97
|
-
validatePackageName('./bar', 'transform', 'transformers');
|
|
98
|
-
});
|
|
99
|
-
});
|
|
100
|
-
|
|
101
20
|
describe('validateConfigFile', () => {
|
|
102
|
-
it('should throw on invalid config', () => {
|
|
103
|
-
assert.throws(() => {
|
|
104
|
-
validateConfigFile(
|
|
105
|
-
{
|
|
106
|
-
filePath: '.parcelrc',
|
|
107
|
-
extends: 'parcel-config-foo',
|
|
108
|
-
transformers: {
|
|
109
|
-
'*.js': ['parcel-invalid-plugin'],
|
|
110
|
-
},
|
|
111
|
-
},
|
|
112
|
-
'.parcelrc',
|
|
113
|
-
);
|
|
114
|
-
});
|
|
115
|
-
});
|
|
116
|
-
|
|
117
21
|
it('should require pipeline to be an array', () => {
|
|
118
22
|
assert.throws(() => {
|
|
119
23
|
validateConfigFile(
|
|
@@ -140,18 +44,6 @@ describe('AtlaspackConfigRequest', () => {
|
|
|
140
44
|
});
|
|
141
45
|
});
|
|
142
46
|
|
|
143
|
-
it('should require package names to be valid', () => {
|
|
144
|
-
assert.throws(() => {
|
|
145
|
-
validateConfigFile(
|
|
146
|
-
{
|
|
147
|
-
filePath: '.parcelrc',
|
|
148
|
-
resolvers: ['parcel-foo-bar'],
|
|
149
|
-
},
|
|
150
|
-
'.parcelrc',
|
|
151
|
-
);
|
|
152
|
-
});
|
|
153
|
-
});
|
|
154
|
-
|
|
155
47
|
it('should succeed with an array of valid package names', () => {
|
|
156
48
|
validateConfigFile(
|
|
157
49
|
{
|
|
@@ -185,21 +77,6 @@ describe('AtlaspackConfigRequest', () => {
|
|
|
185
77
|
});
|
|
186
78
|
});
|
|
187
79
|
|
|
188
|
-
it('should trigger the validator function for each key', () => {
|
|
189
|
-
assert.throws(() => {
|
|
190
|
-
validateConfigFile(
|
|
191
|
-
{
|
|
192
|
-
filePath: '.parcelrc',
|
|
193
|
-
transformers: {
|
|
194
|
-
'types:*.{ts,tsx}': ['@atlaspack/transformer-typescript-types'],
|
|
195
|
-
'bundle-text:*': ['-inline-string', '...'],
|
|
196
|
-
},
|
|
197
|
-
},
|
|
198
|
-
'.parcelrc',
|
|
199
|
-
);
|
|
200
|
-
});
|
|
201
|
-
});
|
|
202
|
-
|
|
203
80
|
it('should require extends to be a string or array of strings', () => {
|
|
204
81
|
assert.throws(() => {
|
|
205
82
|
validateConfigFile(
|
|
@@ -242,44 +119,6 @@ describe('AtlaspackConfigRequest', () => {
|
|
|
242
119
|
);
|
|
243
120
|
});
|
|
244
121
|
|
|
245
|
-
it('should validate package names', () => {
|
|
246
|
-
assert.throws(() => {
|
|
247
|
-
validateConfigFile(
|
|
248
|
-
{
|
|
249
|
-
filePath: '.parcelrc',
|
|
250
|
-
extends: 'foo',
|
|
251
|
-
},
|
|
252
|
-
'.parcelrc',
|
|
253
|
-
);
|
|
254
|
-
});
|
|
255
|
-
|
|
256
|
-
assert.throws(() => {
|
|
257
|
-
validateConfigFile(
|
|
258
|
-
{
|
|
259
|
-
filePath: '.parcelrc',
|
|
260
|
-
extends: ['foo', 'bar'],
|
|
261
|
-
},
|
|
262
|
-
'.parcelrc',
|
|
263
|
-
);
|
|
264
|
-
});
|
|
265
|
-
|
|
266
|
-
validateConfigFile(
|
|
267
|
-
{
|
|
268
|
-
filePath: '.parcelrc',
|
|
269
|
-
extends: 'parcel-config-foo',
|
|
270
|
-
},
|
|
271
|
-
'.parcelrc',
|
|
272
|
-
);
|
|
273
|
-
|
|
274
|
-
validateConfigFile(
|
|
275
|
-
{
|
|
276
|
-
filePath: '.parcelrc',
|
|
277
|
-
extends: ['parcel-config-foo', 'parcel-config-bar'],
|
|
278
|
-
},
|
|
279
|
-
'.parcelrc',
|
|
280
|
-
);
|
|
281
|
-
});
|
|
282
|
-
|
|
283
122
|
it('should throw for invalid top level keys', () => {
|
|
284
123
|
assert.throws(
|
|
285
124
|
() => {
|