Skip to content

Commit

Permalink
header for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
pyramation committed Mar 30, 2024
1 parent 598490c commit 2fabc24
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 16 deletions.
2 changes: 1 addition & 1 deletion __fixtures__/output/parser/enums.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* This file was automatically generated by pg-proto-parser@1.5.0.
* This file was automatically generated by pg-proto-parser@latest.
* DO NOT MODIFY IT BY HAND. Instead, modify the source proto file,
* and run the pg-proto-parser generate command to regenerate this file.
*/
Expand Down
2 changes: 1 addition & 1 deletion __fixtures__/output/parser/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* This file was automatically generated by pg-proto-parser@1.5.0.
* This file was automatically generated by pg-proto-parser@latest.
* DO NOT MODIFY IT BY HAND. Instead, modify the source proto file,
* and run the pg-proto-parser generate command to regenerate this file.
*/
Expand Down
2 changes: 1 addition & 1 deletion __fixtures__/output/parser/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* This file was automatically generated by pg-proto-parser@1.5.0.
* This file was automatically generated by pg-proto-parser@latest.
* DO NOT MODIFY IT BY HAND. Instead, modify the source proto file,
* and run the pg-proto-parser generate command to regenerate this file.
*/
Expand Down
2 changes: 1 addition & 1 deletion __fixtures__/output/undef/enums.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* This file was automatically generated by pg-proto-parser@1.5.0.
* This file was automatically generated by pg-proto-parser@latest.
* DO NOT MODIFY IT BY HAND. Instead, modify the source proto file,
* and run the pg-proto-parser generate command to regenerate this file.
*/
Expand Down
2 changes: 1 addition & 1 deletion __fixtures__/output/undef/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* This file was automatically generated by pg-proto-parser@1.5.0.
* This file was automatically generated by pg-proto-parser@latest.
* DO NOT MODIFY IT BY HAND. Instead, modify the source proto file,
* and run the pg-proto-parser generate command to regenerate this file.
*/
Expand Down
2 changes: 1 addition & 1 deletion __fixtures__/output/undef/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* This file was automatically generated by pg-proto-parser@1.5.0.
* This file was automatically generated by pg-proto-parser@latest.
* DO NOT MODIFY IT BY HAND. Instead, modify the source proto file,
* and run the pg-proto-parser generate command to regenerate this file.
*/
Expand Down
12 changes: 6 additions & 6 deletions packages/parser/__tests__/__snapshots__/parser.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ exports[`keep undefined 1`] = `
[
{
"code": "/**
* This file was automatically generated by pg-proto-parser@1.5.0.
* This file was automatically generated by pg-proto-parser@latest.
* DO NOT MODIFY IT BY HAND. Instead, modify the source proto file,
* and run the pg-proto-parser generate command to regenerate this file.
*/
Expand Down Expand Up @@ -3421,7 +3421,7 @@ export enum Token {
},
{
"code": "/**
* This file was automatically generated by pg-proto-parser@1.5.0.
* This file was automatically generated by pg-proto-parser@latest.
* DO NOT MODIFY IT BY HAND. Instead, modify the source proto file,
* and run the pg-proto-parser generate command to regenerate this file.
*/
Expand Down Expand Up @@ -5556,7 +5556,7 @@ export interface ScanToken {
},
{
"code": "/**
* This file was automatically generated by pg-proto-parser@1.5.0.
* This file was automatically generated by pg-proto-parser@latest.
* DO NOT MODIFY IT BY HAND. Instead, modify the source proto file,
* and run the pg-proto-parser generate command to regenerate this file.
*/
Expand Down Expand Up @@ -10044,7 +10044,7 @@ exports[`parser 1`] = `
[
{
"code": "/**
* This file was automatically generated by pg-proto-parser@1.5.0.
* This file was automatically generated by pg-proto-parser@latest.
* DO NOT MODIFY IT BY HAND. Instead, modify the source proto file,
* and run the pg-proto-parser generate command to regenerate this file.
*/
Expand Down Expand Up @@ -13275,7 +13275,7 @@ export enum Token {
},
{
"code": "/**
* This file was automatically generated by pg-proto-parser@1.5.0.
* This file was automatically generated by pg-proto-parser@latest.
* DO NOT MODIFY IT BY HAND. Instead, modify the source proto file,
* and run the pg-proto-parser generate command to regenerate this file.
*/
Expand Down Expand Up @@ -15410,7 +15410,7 @@ export interface ScanToken {
},
{
"code": "/**
* This file was automatically generated by pg-proto-parser@1.5.0.
* This file was automatically generated by pg-proto-parser@latest.
* DO NOT MODIFY IT BY HAND. Instead, modify the source proto file,
* and run the pg-proto-parser generate command to regenerate this file.
*/
Expand Down
9 changes: 6 additions & 3 deletions packages/parser/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,15 @@ export const getFieldName = (field: Field, fallbackName: string) => {
return field.options?.json_name ? field.options.json_name : fallbackName;
}

export const getHeader = () => (`/**
* This file was automatically generated by pg-proto-parser@${pkg.version}.
export const getHeader = () => {
const version = process.env.NODE_ENV === 'test' ? 'latest' : pkg.version;
return `/**
* This file was automatically generated by pg-proto-parser@${version}.
* DO NOT MODIFY IT BY HAND. Instead, modify the source proto file,
* and run the pg-proto-parser generate command to regenerate this file.
*/
`);
`;
};

export const writeFileToDisk = (path: string, contents: string, options: PgProtoParserOptions) => {
const c = (options.includeHeader && extname(path) === '.ts') ? `${getHeader()}${contents}` : contents;
Expand Down
1 change: 1 addition & 0 deletions packages/parser/types/store.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@ export declare class ProtoStore implements IProtoStore {
_parse(node: ReflectionObject, name?: string): void;
_processEnum(enumNode: Enum): Enum;
write(): void;
writeFile(filename: string, content: string): void;
}
export {};
6 changes: 5 additions & 1 deletion packages/parser/types/utils.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import { Enum, Field } from '@launchql/protobufjs';
import { Enum, Field, ReflectionObject } from '@launchql/protobufjs';
import { PgProtoParserOptions } from './types';
export declare const getUndefinedKey: (enumName: any) => string;
export declare const hasUndefinedInitialValue: (enumData: Enum) => boolean;
export declare const cloneAndNameNode: (node: ReflectionObject, name: string) => any;
export declare const getFieldName: (field: Field, fallbackName: string) => any;
export declare const getHeader: () => string;
export declare const writeFileToDisk: (path: string, contents: string, options: PgProtoParserOptions) => void;

0 comments on commit 2fabc24

Please sign in to comment.