@hubspot/project-parsing-lib 0.1.1 → 0.1.2

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/lib/migrate.js +3 -14
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hubspot/project-parsing-lib",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
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",
@@ -12,7 +12,6 @@ const constants_1 = require("./constants");
12
12
  const IR_FILENAME = 'ir.json';
13
13
  const filesDirectory = 'files';
14
14
  const hsProjectJsonFilename = 'hsproject.json';
15
- const defaultSrcDir = 'src';
16
15
  async function migrate(inputDir, outputDir) {
17
16
  if (!fs_2.default.existsSync(inputDir)) {
18
17
  throw new Error(`Input directory ${inputDir} does not exist`);
@@ -24,16 +23,6 @@ async function migrate(inputDir, outputDir) {
24
23
  const files = await (0, fs_1.walk)(inputDir);
25
24
  // Create the output directory if it doesn't exist
26
25
  ensureDirExists(outputDir);
27
- let hsProjectJson;
28
- try {
29
- hsProjectJson = loadJsonFile(hsProjectJsonPath);
30
- }
31
- catch (e) {
32
- console.error(`Error loading ${hsProjectJsonPath}`, e);
33
- throw e;
34
- }
35
- // Copy the hsproject.json file to the output directory
36
- fs_2.default.writeFileSync(path_1.default.join(outputDir, hsProjectJsonFilename), JSON.stringify(hsProjectJson, null, 2));
37
26
  files.forEach((filename) => {
38
27
  // Skip everything that's not an IR file
39
28
  if (!isIRFile(filename)) {
@@ -43,7 +32,7 @@ async function migrate(inputDir, outputDir) {
43
32
  const IR = loadJsonFile(filename);
44
33
  const { metaFilePath } = IR;
45
34
  const projectConfig = convertIRToProjectConfig(IR);
46
- const fullOutputPath = path_1.default.join(outputDir, getTargetDirectoryFromComponentType(hsProjectJson?.srcDir, projectConfig.type));
35
+ const fullOutputPath = path_1.default.join(outputDir, getTargetDirectoryFromComponentType(projectConfig.type));
47
36
  // Ensure the output directory exists
48
37
  const currentFilesDirectory = path_1.default.join(irDirName, filesDirectory);
49
38
  ensureDirExists(currentFilesDirectory);
@@ -83,7 +72,7 @@ function convertIRToProjectConfig(IR) {
83
72
  dependencies: {},
84
73
  };
85
74
  }
86
- function getTargetDirectoryFromComponentType(projectSourceDir, componentType) {
75
+ function getTargetDirectoryFromComponentType(componentType) {
87
76
  const component = constants_1.Components[componentType];
88
77
  if (!component) {
89
78
  throw Error('Unsupported component type');
@@ -91,5 +80,5 @@ function getTargetDirectoryFromComponentType(projectSourceDir, componentType) {
91
80
  const parentDirectory = component.parentComponent
92
81
  ? constants_1.Components[component.parentComponent].dir
93
82
  : '';
94
- return path_1.default.join(projectSourceDir || defaultSrcDir, parentDirectory, component.dir);
83
+ return path_1.default.join(parentDirectory, component.dir);
95
84
  }