@hubspot/project-parsing-lib 0.8.3 → 0.8.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hubspot/project-parsing-lib",
3
- "version": "0.8.3",
3
+ "version": "0.8.4",
4
4
  "description": "Parsing library for converting projects directory structures to their intermediate representation",
5
5
  "license": "Apache-2.0",
6
6
  "main": "src/index.js",
package/src/lang/copy.js CHANGED
@@ -16,7 +16,7 @@ exports.errorMessages = {
16
16
  accountIdIsRequiredToFetchSchemas: 'Account id is required to fetch schemas',
17
17
  },
18
18
  project: {
19
- mustHaveAppComponent: (componentType) => `No *-hsmeta.json files were found with type '${constants_1.AppKey}'. You must have an '${constants_1.AppKey}' to associate '${componentType}'`,
19
+ mustHaveAppComponent: (componentType) => `This '${componentType}' component must be a child of the '${constants_1.AppKey}' component. No *-hsmeta.json files were found with type '${constants_1.AppKey}'`,
20
20
  noHsMetaFiles: 'No *-hsmeta.json files found in the current directory. Please make sure you are inside the correct project directory.',
21
21
  failedToTranslateProject: 'Project validation failed',
22
22
  duplicateUid: (uid, files) => `Duplicate uid '${uid}' found in:\n- ${files.join('\n- ')}`,
@@ -31,7 +31,10 @@ function calculateComponentDeps(fileValidationResult, parentComponents, appObjec
31
31
  }
32
32
  else {
33
33
  logger_1.logger.debug(parentComponents);
34
- throw new Error(copy_1.errorMessages.project.mustHaveAppComponent(type));
34
+ return {
35
+ dependencies,
36
+ errors: [copy_1.errorMessages.project.mustHaveAppComponent(type)],
37
+ };
35
38
  }
36
39
  if (type !== constants_1.AppObjectKey) {
37
40
  dependencies.allAppObjects = appObjects;
@@ -40,7 +43,7 @@ function calculateComponentDeps(fileValidationResult, parentComponents, appObjec
40
43
  dependencies.serverlessPackage = appFunctionsPackageUid;
41
44
  }
42
45
  }
43
- return dependencies;
46
+ return { dependencies };
44
47
  }
45
48
  function mapToInternalType(type) {
46
49
  const resolvedType = constants_1.userFacingToInternalType[type] || type || '';
@@ -91,19 +94,25 @@ function transform(fileParseResults, translationContext, hsProfileContents) {
91
94
  }
92
95
  const transformations = fileParseResults.map((currentFile) => {
93
96
  if (!currentFile.content) {
94
- currentFile.errors?.push(copy_1.errorMessages.project.fileContentMissingFor(currentFile.file));
97
+ if (!currentFile.errors?.includes(copy_1.errorMessages.validation.invalidJson)) {
98
+ currentFile.errors?.push(copy_1.errorMessages.project.fileContentMissingFor(currentFile.file));
99
+ }
95
100
  return {
96
101
  intermediateRepresentation: null,
97
102
  fileParseResult: currentFile,
98
103
  };
99
104
  }
100
105
  const { config, uid, type } = currentFile.content;
106
+ const { dependencies, errors } = calculateComponentDeps(currentFile, parentComponents, allAppObjects, serverlessPackageUid);
107
+ if (errors) {
108
+ currentFile.errors?.push(...errors);
109
+ }
101
110
  return {
102
111
  intermediateRepresentation: {
103
112
  uid,
104
113
  config,
105
114
  componentType: mapToInternalType(type),
106
- componentDeps: calculateComponentDeps(currentFile, parentComponents, allAppObjects, serverlessPackageUid),
115
+ componentDeps: dependencies,
107
116
  metaFilePath: currentFile.file,
108
117
  files: {},
109
118
  },
@@ -96,6 +96,7 @@ function validateIntermediateRepresentationNode(schema, transformation, irNode,
96
96
  };
97
97
  }
98
98
  async function validateIntermediateRepresentation(intermediateRepresentation, transformation, translationContext) {
99
+ const hasAnyFileParseErrors = transformation.some(t => t.fileParseResult.errors.length > 0);
99
100
  const schema = await (0, schemas_1.getIntermediateRepresentationSchema)(translationContext);
100
101
  const potentialDuplicatesByComponent = {};
101
102
  const results = Object.values(intermediateRepresentation.intermediateNodesIndexedByUid).map((irNode, index) => {
@@ -120,7 +121,9 @@ async function validateIntermediateRepresentation(intermediateRepresentation, tr
120
121
  ?.fileParseResult.errors.push(copy_1.errorMessages.project.duplicateComponent(componentType));
121
122
  });
122
123
  });
123
- const valid = !hasDuplicates && results.every(result => result.valid);
124
+ const valid = !hasAnyFileParseErrors &&
125
+ !hasDuplicates &&
126
+ results.every(result => result.valid);
124
127
  if (valid) {
125
128
  return {
126
129
  valid,