occam-verify-cli 0.0.443 → 0.0.445

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/src/type.js CHANGED
@@ -119,15 +119,21 @@ export default class Type {
119
119
  return json;
120
120
  }
121
121
 
122
- static fromJSON(json) {
122
+ static fromJSON(json, releaseContext) {
123
123
  const { name } = json;
124
124
 
125
125
  let { superType } = json;
126
126
 
127
127
  if (superType !== null) {
128
- json = superType; ///
128
+ const superTypeJSON = superType; ///
129
129
 
130
- superType = Type.fromJSON(json);
130
+ json = superTypeJSON; ///
131
+
132
+ superType = Type.fromJSON(json, releaseContext);
133
+
134
+ const superTypeName = superType.getName();
135
+
136
+ superType = releaseContext.findTypeByTypeName(superTypeName); ///
131
137
  }
132
138
 
133
139
  const type = new Type(name, superType);
@@ -39,7 +39,7 @@ export function createReleaseContext(dependency, dependentNames, context, callba
39
39
  }, context);
40
40
  }
41
41
 
42
- export function initialiseReleaseContext(dependency, context) {
42
+ export function initialiseReleaseContext(dependency, dependentName, verified, context) {
43
43
  const { releaseContextMap } = context,
44
44
  dependencyName = dependency.getName(),
45
45
  releaseName = dependencyName, ///
@@ -55,10 +55,26 @@ export function initialiseReleaseContext(dependency, context) {
55
55
  return;
56
56
  }
57
57
 
58
+ const releaseContextVerified = releaseContext.isVerified();
59
+
60
+ if (verified) {
61
+ if (!releaseContextVerified) {
62
+ const { log } = context;
63
+
64
+ log .error(`Unable to initialise the '${releaseName}' dependency's context because its '${dependentName}' dependent is a package.`);
65
+
66
+ return;
67
+ }
68
+ }
69
+
70
+ verified = releaseContextVerified; ///
71
+
72
+ dependentName = releaseName; ///
73
+
58
74
  const dependencies = releaseContext.getDependencies();
59
75
 
60
76
  dependencies.forEachDependency((dependency) => {
61
- initialiseReleaseContext(dependency, context);
77
+ initialiseReleaseContext(dependency, dependentName, verified, context);
62
78
  });
63
79
 
64
80
  const dependencyReleaseContexts = retrieveDependencyReleaseContexts(dependency, context);
@@ -5,7 +5,8 @@ import verifyTopLevelDeclaration from "./declaration/topLevel";
5
5
 
6
6
  import { nodesQuery } from "../utilities/query";
7
7
 
8
- const topLevelDeclarationNodesQuery = nodesQuery("/document/topLevelDeclaration");
8
+ const errorNodesQuery = nodesQuery("/document/error"),
9
+ topLevelDeclarationNodesQuery = nodesQuery("/document/topLevelDeclaration");
9
10
 
10
11
  export default function verifyFile(filePath, releaseContext) {
11
12
  let fileVerified = false;
@@ -14,19 +15,26 @@ export default function verifyFile(filePath, releaseContext) {
14
15
 
15
16
  const fileContext = FileContext.fromReleaseContextAndFilePath(releaseContext, filePath),
16
17
  node = fileContext.getNode(),
17
- topLevelDeclarationNodes = topLevelDeclarationNodesQuery(node),
18
- topLevelDeclarationsVerified = topLevelDeclarationNodes.every((topLevelDeclarationNode) => {
19
- const topLevelDeclarationVerified = verifyTopLevelDeclaration(topLevelDeclarationNode, fileContext);
20
-
21
- if (topLevelDeclarationVerified) {
22
- return true;
23
- }
24
- });
25
-
26
- if (topLevelDeclarationsVerified) {
27
- releaseContext.addFileContext(fileContext);
28
-
29
- fileVerified = true;
18
+ errorNodes = errorNodesQuery(node),
19
+ errorNodesLength = errorNodes.length;
20
+
21
+ if (errorNodesLength > 0) {
22
+ releaseContext.error(`The '${filePath}' file cannot be verified because it contains errors.`);
23
+ } else {
24
+ const topLevelDeclarationNodes = topLevelDeclarationNodesQuery(node),
25
+ topLevelDeclarationsVerified = topLevelDeclarationNodes.every((topLevelDeclarationNode) => {
26
+ const topLevelDeclarationVerified = verifyTopLevelDeclaration(topLevelDeclarationNode, fileContext);
27
+
28
+ if (topLevelDeclarationVerified) {
29
+ return true;
30
+ }
31
+ });
32
+
33
+ if (topLevelDeclarationsVerified) {
34
+ releaseContext.addFileContext(fileContext);
35
+
36
+ fileVerified = true;
37
+ }
30
38
  }
31
39
 
32
40
  if (fileVerified) {