Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Add file name suffix option #61

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 17, 2024
Merged

Conversation

victorbush
Copy link
Contributor

Allows appending a custom suffix to generated file names before the extension. For example, if the suffix is .g, the generated client file name would be moduleName.g.js (or moduleName.g.ts when using TypeScript).

We want to use .g to make it easier to identify these as auto-generated files, specifically in .gitattributes without explicitly listing each file. This is a very minor inconvenience, so we're not hard pressed to find a solution. If adding a suffix option here isn't a good idea, just let me know.

Allows appending a custom suffix to generated file names before the extension. For example, if the suffix is `.g`, the generated client file name would be `moduleName.g.js` (or `moduleName.g.ts` when using TypeScript).
@victorbush victorbush requested a review from ejball May 17, 2024 16:43
@ejball
Copy link
Contributor

ejball commented May 17, 2024

It's fine by me! It's been a while, but I think I imagined that it would uglify imports.

import { ILibrarySearchApi } from './librarySearchApiTypes';

would have to be

import { ILibrarySearchApi } from './librarySearchApiTypes.g';

or

import { ILibrarySearchApi } from './librarySearchApiTypes.g.ts';

presumably? Or maybe everything has changed again and import statements aren't used or necessary? :-)

@victorbush
Copy link
Contributor Author

I hadn't considered that, but I think you're right. Usually we add an index.ts to the directory containing the generated output and reference that within our consuming project:

librarySearchApi/index.ts

export * from './librarySearchApiTypes.g`

Usage

import { ILibrarySearchApi } from './librarySearchApi'

# Conflicts:
#	src/fsdgenjs/FsdGenJavaScriptApp.cs
var service = parser.ParseDefinition(new ServiceDefinitionText("TestApi.fsd", definition));
var generator = new JavaScriptGenerator { GeneratorName = "JavaScriptGeneratorTests", TypeScript = isTypeScript, Express = true, FileNameSuffix = suffix };
var result = generator.GenerateOutput(service);
Assert.IsNotNull(result);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NUnit 4 does asserts differently; see above for examples.

@victorbush victorbush merged commit de9699f into FacilityApi:master May 17, 2024
@victorbush victorbush deleted the file-name-ext branch May 17, 2024 21:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants