@hubspot/project-parsing-lib 0.4.0 → 0.5.1
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.js +12 -1
- package/src/lib/constants.d.ts +2 -0
- package/src/lib/constants.js +3 -1
- package/src/lib/types.d.ts +3 -1
- package/src/lib/utils.d.ts +1 -0
- package/src/lib/utils.js +29 -0
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -10,6 +10,7 @@ const files_1 = require("./lib/files");
|
|
|
10
10
|
const validation_1 = require("./lib/validation");
|
|
11
11
|
const transform_1 = require("./lib/transform");
|
|
12
12
|
const copy_1 = require("./lang/copy");
|
|
13
|
+
const utils_1 = require("./lib/utils");
|
|
13
14
|
const path_1 = __importDefault(require("path"));
|
|
14
15
|
const defaultOptions = {
|
|
15
16
|
skipValidation: false,
|
|
@@ -43,7 +44,17 @@ async function translateForLocalDev(translationContext, translationOptions) {
|
|
|
43
44
|
Object.entries(IR.intermediateNodesIndexedByUid).forEach(([uid, node]) => {
|
|
44
45
|
const component = IR.intermediateNodesIndexedByUid[uid];
|
|
45
46
|
const componentConfigPath = path_1.default.join(translationContext.projectSourceDir, component.metaFilePath);
|
|
46
|
-
|
|
47
|
+
let configUpdatedSinceLastUpload = false;
|
|
48
|
+
if (translationOptions?.projectNodesAtLastUpload) {
|
|
49
|
+
const componentAtLastUpload = translationOptions.projectNodesAtLastUpload[uid];
|
|
50
|
+
if (componentAtLastUpload) {
|
|
51
|
+
configUpdatedSinceLastUpload = !(0, utils_1.isDeepEqual)(component.config, componentAtLastUpload.config);
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
// Component is net new
|
|
55
|
+
configUpdatedSinceLastUpload = true;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
47
58
|
localDevIr.intermediateNodesIndexedByUid[uid] = {
|
|
48
59
|
...node,
|
|
49
60
|
localDev: {
|
package/src/lib/constants.d.ts
CHANGED
|
@@ -36,9 +36,11 @@ export declare const packageJson = "package.json";
|
|
|
36
36
|
export declare const packageLockJson = "package-lock.json";
|
|
37
37
|
export declare const allowedAppSubComponentsDirs: string[];
|
|
38
38
|
export declare const allowedThemeSubComponentsDirs: string[];
|
|
39
|
+
export declare const allowedReactThemeSubComponentsDirs: string[];
|
|
39
40
|
export declare const ProjectStructure: {
|
|
40
41
|
readonly app: string[];
|
|
41
42
|
readonly theme: string[];
|
|
43
|
+
readonly "react-theme": string[];
|
|
42
44
|
};
|
|
43
45
|
export declare const allowedComponentDirectories: string[];
|
|
44
46
|
export declare const allowedSubComponentDirectories: string[];
|
package/src/lib/constants.js
CHANGED
|
@@ -33,7 +33,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.allowedSubComponentDirectories = exports.allowedComponentDirectories = exports.ProjectStructure = exports.allowedThemeSubComponentsDirs = exports.allowedAppSubComponentsDirs = exports.packageLockJson = exports.packageJson = exports.hsProjectJsonFilename = exports.profileFilePrefix = exports.metafileExtension = exports.internalTypeToUserFacing = exports.userFacingToInternalType = exports.Components = exports.AutoGeneratedComponentTypes = exports.AppFunctionsPackageKey = exports.WorkflowActionsKey = exports.WebhooksKey = exports.VideoConferencingKey = exports.TelemetryKey = exports.SettingsKey = exports.MediaBridgeKey = exports.MarketingEventsKey = exports.SCIMKey = exports.CardsKey = exports.CallingKey = exports.AppObjectAssociationKey = exports.AppObjectKey = exports.AppFunctionsKey = exports.AppEventsKey = exports.ReactThemeKey = exports.ThemeKey = exports.AppKey = void 0;
|
|
36
|
+
exports.allowedSubComponentDirectories = exports.allowedComponentDirectories = exports.ProjectStructure = exports.allowedReactThemeSubComponentsDirs = exports.allowedThemeSubComponentsDirs = exports.allowedAppSubComponentsDirs = exports.packageLockJson = exports.packageJson = exports.hsProjectJsonFilename = exports.profileFilePrefix = exports.metafileExtension = exports.internalTypeToUserFacing = exports.userFacingToInternalType = exports.Components = exports.AutoGeneratedComponentTypes = exports.AppFunctionsPackageKey = exports.WorkflowActionsKey = exports.WebhooksKey = exports.VideoConferencingKey = exports.TelemetryKey = exports.SettingsKey = exports.MediaBridgeKey = exports.MarketingEventsKey = exports.SCIMKey = exports.CardsKey = exports.CallingKey = exports.AppObjectAssociationKey = exports.AppObjectKey = exports.AppFunctionsKey = exports.AppEventsKey = exports.ReactThemeKey = exports.ThemeKey = exports.AppKey = void 0;
|
|
37
37
|
// Top Level Component types
|
|
38
38
|
const path = __importStar(require("path"));
|
|
39
39
|
// Component types
|
|
@@ -196,9 +196,11 @@ function getSubComponentDirsForParentType(parentComponent) {
|
|
|
196
196
|
}
|
|
197
197
|
exports.allowedAppSubComponentsDirs = getSubComponentDirsForParentType(exports.AppKey);
|
|
198
198
|
exports.allowedThemeSubComponentsDirs = getSubComponentDirsForParentType(exports.ThemeKey);
|
|
199
|
+
exports.allowedReactThemeSubComponentsDirs = getSubComponentDirsForParentType(exports.ReactThemeKey);
|
|
199
200
|
exports.ProjectStructure = {
|
|
200
201
|
[exports.AppKey]: exports.allowedAppSubComponentsDirs,
|
|
201
202
|
[exports.ThemeKey]: exports.allowedThemeSubComponentsDirs,
|
|
203
|
+
[exports.ReactThemeKey]: exports.allowedReactThemeSubComponentsDirs,
|
|
202
204
|
};
|
|
203
205
|
exports.allowedComponentDirectories = Object.keys(exports.ProjectStructure);
|
|
204
206
|
exports.allowedSubComponentDirectories = Object.entries(exports.ProjectStructure)
|
package/src/lib/types.d.ts
CHANGED
|
@@ -60,7 +60,9 @@ export interface TranslationOptions {
|
|
|
60
60
|
profile?: string;
|
|
61
61
|
}
|
|
62
62
|
export interface TranslationOptionsLocalDev extends TranslationOptions {
|
|
63
|
-
|
|
63
|
+
projectNodesAtLastUpload?: {
|
|
64
|
+
[key: string]: IntermediateRepresentationNodeLocalDev;
|
|
65
|
+
};
|
|
64
66
|
}
|
|
65
67
|
export interface HsProfileFile {
|
|
66
68
|
accountId: number;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isDeepEqual(object1: unknown, object2: unknown): boolean;
|
package/src/lib/utils.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isDeepEqual = isDeepEqual;
|
|
4
|
+
function isDeepEqual(object1, object2) {
|
|
5
|
+
if (object1 === object2) {
|
|
6
|
+
return true;
|
|
7
|
+
}
|
|
8
|
+
if (object1 === null ||
|
|
9
|
+
object2 === null ||
|
|
10
|
+
typeof object1 !== 'object' ||
|
|
11
|
+
typeof object2 !== 'object') {
|
|
12
|
+
return object1 === object2;
|
|
13
|
+
}
|
|
14
|
+
if (typeof object1 !== typeof object2) {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
const objKeys1 = Object.keys(object1);
|
|
18
|
+
const objKeys2 = Object.keys(object2);
|
|
19
|
+
if (objKeys1.length !== objKeys2.length)
|
|
20
|
+
return false;
|
|
21
|
+
for (const key of objKeys1) {
|
|
22
|
+
const value1 = object1[key];
|
|
23
|
+
const value2 = object2[key];
|
|
24
|
+
if (!isDeepEqual(value1, value2)) {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return true;
|
|
29
|
+
}
|