Skip to content

Commit d1f68fe

Browse files
committed
package
1 parent 20f4363 commit d1f68fe

File tree

10 files changed

+44
-9
lines changed

10 files changed

+44
-9
lines changed

packages/enums/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* This file was automatically generated by [email protected].0.
2+
* This file was automatically generated by [email protected].1.
33
* DO NOT MODIFY IT BY HAND. Instead, modify the source proto file,
44
* and run the pg-proto-parser generate command to regenerate this file.
55
*/

packages/proto-parser/src/package.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { existsSync,readFileSync } from "fs";
2+
import { dirname,join } from "path";
3+
4+
// need to search due to the dist/ folder and src/, etc.
5+
function findPackageJson(currentDir: string): string {
6+
const filePath = join(currentDir, 'package.json');
7+
8+
// Check if package.json exists in the current directory
9+
if (existsSync(filePath)) {
10+
return filePath;
11+
}
12+
13+
// Get the parent directory
14+
const parentDir = dirname(currentDir);
15+
16+
// If reached the root directory, package.json is not found
17+
if (parentDir === currentDir) {
18+
throw new Error('package.json not found in any parent directory');
19+
}
20+
21+
// Recursively look in the parent directory
22+
return findPackageJson(parentDir);
23+
}
24+
25+
export function readAndParsePackageJson(): any {
26+
// Start searching from the current directory
27+
const pkgPath = findPackageJson(__dirname);
28+
29+
// Read and parse the package.json
30+
const str = readFileSync(pkgPath, 'utf8');
31+
const pkg = JSON.parse(str);
32+
return pkg;
33+
}

packages/proto-parser/src/utils/utils.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import { Enum, Field, ReflectionObject } from '@launchql/protobufjs';
2-
import pkg from '../../package.json';
32
import { PgProtoParserOptions } from '../options';
43
import { writeFileSync } from 'fs';
54
import { extname, basename } from 'path';
5+
import { readAndParsePackageJson } from '../package';
6+
7+
const pkg = readAndParsePackageJson();
68

79
export const getUndefinedKey = (enumName: string) => {
810
// Split the name into parts where a lowercase letter is followed by an uppercase letter

packages/transform/src/13/enums.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* This file was automatically generated by [email protected].0.
2+
* This file was automatically generated by [email protected].1.
33
* DO NOT MODIFY IT BY HAND. Instead, modify the source proto file,
44
* and run the pg-proto-parser generate command to regenerate this file.
55
*/

packages/transform/src/13/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* This file was automatically generated by [email protected].0.
2+
* This file was automatically generated by [email protected].1.
33
* DO NOT MODIFY IT BY HAND. Instead, modify the source proto file,
44
* and run the pg-proto-parser generate command to regenerate this file.
55
*/

packages/transform/src/17/enums.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* This file was automatically generated by [email protected].0.
2+
* This file was automatically generated by [email protected].1.
33
* DO NOT MODIFY IT BY HAND. Instead, modify the source proto file,
44
* and run the pg-proto-parser generate command to regenerate this file.
55
*/

packages/transform/src/17/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* This file was automatically generated by [email protected].0.
2+
* This file was automatically generated by [email protected].1.
33
* DO NOT MODIFY IT BY HAND. Instead, modify the source proto file,
44
* and run the pg-proto-parser generate command to regenerate this file.
55
*/

packages/types/src/enums.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* This file was automatically generated by [email protected].0.
2+
* This file was automatically generated by [email protected].1.
33
* DO NOT MODIFY IT BY HAND. Instead, modify the source proto file,
44
* and run the pg-proto-parser generate command to regenerate this file.
55
*/

packages/types/src/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* This file was automatically generated by [email protected].0.
2+
* This file was automatically generated by [email protected].1.
33
* DO NOT MODIFY IT BY HAND. Instead, modify the source proto file,
44
* and run the pg-proto-parser generate command to regenerate this file.
55
*/

packages/utils/src/asts.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* This file was automatically generated by [email protected].0.
2+
* This file was automatically generated by [email protected].1.
33
* DO NOT MODIFY IT BY HAND. Instead, modify the source proto file,
44
* and run the pg-proto-parser generate command to regenerate this file.
55
*/

0 commit comments

Comments
 (0)