@hubspot/project-parsing-lib 0.8.5 → 0.8.6-beta.0
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/lib/files.d.ts +1 -0
- package/src/lib/files.js +4 -0
- package/src/lib/transform.js +13 -9
package/package.json
CHANGED
package/src/lib/files.d.ts
CHANGED
|
@@ -10,3 +10,4 @@ export declare function locateHsMetaFiles(projectSourceDir: string, options?: {
|
|
|
10
10
|
silent: boolean;
|
|
11
11
|
}): Promise<MetaFileLocation[]>;
|
|
12
12
|
export declare function projectContainsHsMetaFiles(projectSourceDir: string): Promise<boolean>;
|
|
13
|
+
export declare function convertPathToPosixPath(filepath: string): string;
|
package/src/lib/files.js
CHANGED
|
@@ -8,6 +8,7 @@ exports.getAllHsProfiles = getAllHsProfiles;
|
|
|
8
8
|
exports.loadHsMetaFiles = loadHsMetaFiles;
|
|
9
9
|
exports.locateHsMetaFiles = locateHsMetaFiles;
|
|
10
10
|
exports.projectContainsHsMetaFiles = projectContainsHsMetaFiles;
|
|
11
|
+
exports.convertPathToPosixPath = convertPathToPosixPath;
|
|
11
12
|
const fs_1 = __importDefault(require("fs"));
|
|
12
13
|
const path_1 = __importDefault(require("path"));
|
|
13
14
|
const fs_2 = require("@hubspot/local-dev-lib/fs");
|
|
@@ -112,3 +113,6 @@ async function projectContainsHsMetaFiles(projectSourceDir) {
|
|
|
112
113
|
const hsMetaFiles = (await (0, fs_2.walk)(projectSourceDir, ['node_modules'])).filter(file => file.endsWith(constants_1.metafileExtension));
|
|
113
114
|
return hsMetaFiles.length > 0;
|
|
114
115
|
}
|
|
116
|
+
function convertPathToPosixPath(filepath) {
|
|
117
|
+
return filepath.replaceAll(path_1.default.win32.sep, path_1.default.posix.sep);
|
|
118
|
+
}
|
package/src/lib/transform.js
CHANGED
|
@@ -16,6 +16,7 @@ const profiles_1 = require("./profiles");
|
|
|
16
16
|
const constants_1 = require("./constants");
|
|
17
17
|
const copy_1 = require("../lang/copy");
|
|
18
18
|
const utils_1 = require("./utils");
|
|
19
|
+
const files_1 = require("./files");
|
|
19
20
|
function calculateComponentDeps(fileValidationResult, parentComponents, appObjects, appFunctionsPackageUid) {
|
|
20
21
|
let dependencies = {};
|
|
21
22
|
// If there are dependencies in the config file, pass them through
|
|
@@ -113,7 +114,7 @@ function transform(fileParseResults, translationContext, hsProfileContents) {
|
|
|
113
114
|
config,
|
|
114
115
|
componentType: mapToInternalType(type),
|
|
115
116
|
componentDeps: dependencies,
|
|
116
|
-
metaFilePath: currentFile.file,
|
|
117
|
+
metaFilePath: (0, files_1.convertPathToPosixPath)(currentFile.file),
|
|
117
118
|
files: {},
|
|
118
119
|
},
|
|
119
120
|
fileParseResult: currentFile,
|
|
@@ -184,10 +185,11 @@ function getProfileData(hsProfileContents) {
|
|
|
184
185
|
return { vars: { profileVariables: profileVariablesForBE } };
|
|
185
186
|
}
|
|
186
187
|
function generateServerlessPackageComponent(appFunctionsDirectory, translationContext, componentDeps) {
|
|
187
|
-
const
|
|
188
|
-
const
|
|
189
|
-
const
|
|
190
|
-
const
|
|
188
|
+
const appFunctionsPosix = (0, files_1.convertPathToPosixPath)(appFunctionsDirectory);
|
|
189
|
+
const packageFilePosix = path_1.default.posix.join(appFunctionsPosix, constants_1.packageJson);
|
|
190
|
+
const packageLockFilePosix = path_1.default.posix.join(appFunctionsPosix, constants_1.packageLockJson);
|
|
191
|
+
const projectSourceDirPosix = (0, files_1.convertPathToPosixPath)(translationContext.projectSourceDir);
|
|
192
|
+
const appFunctionsPackageFile = path_1.default.posix.join(projectSourceDirPosix, packageFilePosix);
|
|
191
193
|
if (!fs_1.default.existsSync(appFunctionsPackageFile)) {
|
|
192
194
|
throw new Error(copy_1.errorMessages.project.noPackageJsonForServerless(appFunctionsPackageFile));
|
|
193
195
|
}
|
|
@@ -203,13 +205,15 @@ function generateServerlessPackageComponent(appFunctionsDirectory, translationCo
|
|
|
203
205
|
uid,
|
|
204
206
|
componentType: mapToInternalType(constants_1.AppFunctionsPackageKey),
|
|
205
207
|
config: {
|
|
206
|
-
packageFile,
|
|
207
|
-
packageLockfile: fs_1.default.existsSync(
|
|
208
|
-
|
|
208
|
+
packageFile: packageFilePosix,
|
|
209
|
+
packageLockfile: fs_1.default.existsSync(
|
|
210
|
+
// Don't use posix here because we are checking the file system
|
|
211
|
+
path_1.default.join(translationContext.projectSourceDir, path_1.default.join(appFunctionsDirectory, constants_1.packageLockJson)))
|
|
212
|
+
? packageLockFilePosix
|
|
209
213
|
: undefined,
|
|
210
214
|
},
|
|
211
215
|
componentDeps,
|
|
212
|
-
metaFilePath:
|
|
216
|
+
metaFilePath: packageFilePosix,
|
|
213
217
|
files: {},
|
|
214
218
|
},
|
|
215
219
|
},
|