dotcom-tool-kit 4.3.2 → 4.3.3
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entry-point.d.ts","sourceRoot":"","sources":["../../src/plugin/entry-point.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAA;AACjD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AACzD,OAAO,EAAE,SAAS,EAAW,MAAM,4BAA4B,CAAA;
|
|
1
|
+
{"version":3,"file":"entry-point.d.ts","sourceRoot":"","sources":["../../src/plugin/entry-point.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAA;AACjD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AACzD,OAAO,EAAE,SAAS,EAAW,MAAM,4BAA4B,CAAA;AAS/D,wBAAsB,gBAAgB,CAAC,CAAC,SAAS;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAAC,OAAO,IAAI,EAAE,KAAK,CAAC,EAC1F,IAAI,EAAE,CAAC,EACP,UAAU,EAAE,UAAU,GACrB,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CA0CvB"}
|
|
@@ -4,6 +4,7 @@ exports.importEntryPoint = void 0;
|
|
|
4
4
|
const logger_1 = require("@dotcom-tool-kit/logger");
|
|
5
5
|
const validated_1 = require("@dotcom-tool-kit/validated");
|
|
6
6
|
const lodash_1 = require("lodash");
|
|
7
|
+
const tslib_1 = require("tslib");
|
|
7
8
|
const messages_1 = require("../messages");
|
|
8
9
|
const isPlainObjectGuard = (value) => (0, lodash_1.isPlainObject)(value);
|
|
9
10
|
// the subclasses of Base have different constructor signatures so we need to omit
|
|
@@ -25,20 +26,18 @@ async function importEntryPoint(type, entryPoint) {
|
|
|
25
26
|
`an error was thrown when loading entrypoint ${logger_1.styles.filepath(entryPoint.modulePath)} in plugin ${logger_1.styles.plugin(entryPoint.plugin.id)}:\n ${logger_1.styles.code((0, messages_1.indentReasons)(err.toString()))}`
|
|
26
27
|
]);
|
|
27
28
|
}
|
|
28
|
-
if (isPlainObjectGuard(pluginModule)
|
|
29
|
-
|
|
30
|
-
typeof
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
else {
|
|
39
|
-
return (0, validated_1.invalid)([
|
|
40
|
-
`entrypoint ${logger_1.styles.filepath(entryPoint.modulePath)} in plugin ${logger_1.styles.plugin(entryPoint.plugin.id)} does not have a ${logger_1.styles.code('default')} export`
|
|
41
|
-
]);
|
|
29
|
+
if (isPlainObjectGuard(pluginModule)) {
|
|
30
|
+
const defaultExport = (0, tslib_1.__importDefault)(pluginModule).default;
|
|
31
|
+
if (typeof defaultExport === 'function') {
|
|
32
|
+
return type
|
|
33
|
+
.isCompatible(defaultExport)
|
|
34
|
+
.mapError((reasons) => [
|
|
35
|
+
`the ${type.name.toLowerCase()} ${logger_1.styles.hook(defaultExport.name)} is not a compatible instance of ${logger_1.styles.code(type.name)}:\n - ${reasons.join('\n - ')}`
|
|
36
|
+
]);
|
|
37
|
+
}
|
|
42
38
|
}
|
|
39
|
+
return (0, validated_1.invalid)([
|
|
40
|
+
`entrypoint ${logger_1.styles.filepath(entryPoint.modulePath)} in plugin ${logger_1.styles.plugin(entryPoint.plugin.id)} does not export a class as its ${logger_1.styles.code('default')} export or ${logger_1.styles.code('module.exports')}`
|
|
41
|
+
]);
|
|
43
42
|
}
|
|
44
43
|
exports.importEntryPoint = importEntryPoint;
|
package/package.json
CHANGED