@hubspot/project-parsing-lib 0.0.8 → 0.0.9
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 +1 -1
- package/src/index.d.ts +3 -1
- package/src/index.js +24 -0
- package/src/lib/types.d.ts +12 -1
package/package.json
CHANGED
package/src/index.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
import { IntermediateRepresentation, TranslationContext, TranslationOptions } from './lib/types';
|
|
1
|
+
import { IntermediateRepresentation, IntermediateRepresentationNode, IntermediateRepresentationLocalDev, TranslationContext, TranslationOptions, IntermediateRepresentationNodeLocalDev } from './lib/types';
|
|
2
2
|
export declare function translate(translationContext: TranslationContext, translationOptions?: TranslationOptions): Promise<IntermediateRepresentation>;
|
|
3
|
+
export declare function translateForLocalDev(translationContext: TranslationContext): Promise<IntermediateRepresentationLocalDev>;
|
|
3
4
|
export { isTranslationError } from './lib/errors';
|
|
5
|
+
export { IntermediateRepresentation, IntermediateRepresentationNode, IntermediateRepresentationLocalDev, IntermediateRepresentationNodeLocalDev, TranslationContext, };
|
package/src/index.js
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.isTranslationError = void 0;
|
|
4
7
|
exports.translate = translate;
|
|
8
|
+
exports.translateForLocalDev = translateForLocalDev;
|
|
5
9
|
const files_1 = require("./lib/files");
|
|
6
10
|
const validation_1 = require("./lib/validation");
|
|
7
11
|
const transform_1 = require("./lib/transform");
|
|
8
12
|
const copy_1 = require("./lang/copy");
|
|
13
|
+
const path_1 = __importDefault(require("path"));
|
|
9
14
|
const defaultOptions = {
|
|
10
15
|
skipValidation: false,
|
|
11
16
|
};
|
|
@@ -17,10 +22,29 @@ async function translate(translationContext, translationOptions = defaultOptions
|
|
|
17
22
|
}
|
|
18
23
|
const transformation = (0, transform_1.transform)(metafileContents);
|
|
19
24
|
const intermediateRepresentation = (0, transform_1.getIntermediateRepresentation)(transformation);
|
|
25
|
+
// Remove once extensions and serverless functions are supported
|
|
20
26
|
if (!skipValidation) {
|
|
21
27
|
await (0, validation_1.validateIntermediateRepresentation)(intermediateRepresentation, transformation, translationContext);
|
|
22
28
|
}
|
|
23
29
|
return intermediateRepresentation;
|
|
24
30
|
}
|
|
31
|
+
async function translateForLocalDev(translationContext) {
|
|
32
|
+
const IR = await translate(translationContext, { skipValidation: true });
|
|
33
|
+
const localDevIr = {
|
|
34
|
+
intermediateNodesIndexedByUid: {},
|
|
35
|
+
};
|
|
36
|
+
Object.entries(IR.intermediateNodesIndexedByUid).forEach(([uid, node]) => {
|
|
37
|
+
const component = IR.intermediateNodesIndexedByUid[uid];
|
|
38
|
+
const componentConfigPath = path_1.default.join(translationContext.projectSourceDir, component.metaFilePath);
|
|
39
|
+
localDevIr.intermediateNodesIndexedByUid[uid] = {
|
|
40
|
+
...node,
|
|
41
|
+
localDev: {
|
|
42
|
+
componentRoot: path_1.default.dirname(componentConfigPath),
|
|
43
|
+
componentConfigPath,
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
});
|
|
47
|
+
return localDevIr;
|
|
48
|
+
}
|
|
25
49
|
var errors_1 = require("./lib/errors");
|
|
26
50
|
Object.defineProperty(exports, "isTranslationError", { enumerable: true, get: function () { return errors_1.isTranslationError; } });
|
package/src/lib/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export type Dependencies = Record<string, string | string[]>;
|
|
2
1
|
import { ErrorObject } from 'ajv-draft-04';
|
|
2
|
+
export type Dependencies = Record<string, string | string[]>;
|
|
3
3
|
export interface Components {
|
|
4
4
|
uid: string;
|
|
5
5
|
type: string;
|
|
@@ -30,6 +30,17 @@ export interface IntermediateRepresentation {
|
|
|
30
30
|
[key: string]: IntermediateRepresentationNode;
|
|
31
31
|
};
|
|
32
32
|
}
|
|
33
|
+
export interface IntermediateRepresentationNodeLocalDev extends IntermediateRepresentationNode {
|
|
34
|
+
localDev: {
|
|
35
|
+
componentRoot: string;
|
|
36
|
+
componentConfigPath: string;
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
export interface IntermediateRepresentationLocalDev {
|
|
40
|
+
intermediateNodesIndexedByUid: {
|
|
41
|
+
[key: string]: IntermediateRepresentationNodeLocalDev;
|
|
42
|
+
};
|
|
43
|
+
}
|
|
33
44
|
export type Transformation = {
|
|
34
45
|
intermediateRepresentation?: IntermediateRepresentationNode | null;
|
|
35
46
|
fileParseResult: FileParseResult;
|