-
Notifications
You must be signed in to change notification settings - Fork 628
feat: create gapic-node-processing library #6604
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
Conversation
packages/gapic-node-templating/src/commands/generate-combined-library.ts
Outdated
Show resolved
Hide resolved
* default-version: what is the default version of the library (default is highest) | ||
*/ | ||
async handler(argv: CliArgs) { | ||
const writeDestination = argv['destination-path'] || argv['library-path']; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add type. change variable name to destinationPath?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also I would explicitly ask for the destination-path, if not defined return error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See other comment re: user experience vs. our use case, but I think I'll leave it as is since that is the default behavior we want! I guess I'm thinking, I just want a "black-box" that just takes multiple versions of a library, and returns a single combined library in that same place. The real reason I added a destinationPath is just so that we could test it more easily.
try { | ||
await combineLibraries(argv['library-path'], writeDestination); | ||
} catch (err) { | ||
if (!(err as any).message.includes('Unexpected library format')) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not throw an error always?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm thinking about cases where we've run the tool twice (once the library is well-formed). If that's the case, it won't have only top-level directories, it will also have files. The traverseDirectories
function should fail, since it will encounter files. In that case, I don't think we should error, but just say that the library wasn't in the format we were expecting. I've updated it so that we're warning the user that we ran into this error.
* @param {Array<{filePath: string; content: string}>} files An array of objects, where each object has a file path and its content. | ||
* @returns {Promise<void>} A promise that resolves when all files are written. | ||
*/ | ||
export async function createDirectoryAndWriteFiles( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would split the directory creation and the files creation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think actually this is a misnomer of a function. Really what we're doing is creating any directories that are required along the way to create a file. I've renamed the function to writeFilesToGivenLocation
Now this is a huge PR because I renamed the library >.< |
need to merge: googleapis/repo-automation-bots#5922 first (or we can admin-merge, it's just to ignore owlbot) |
…cloud-node into createCombinedLibrary
Owlbot is failing because it's trying to check the template file:
so this is safe to ignore |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A lot of pedantic style stuff ^^; But hopefully there's something useful in there.
packages/gapic-node-processing/src/commands/generate-combined-library.ts
Show resolved
Hide resolved
@feywind thank you so much for the indepth review, I really appreciate it! PTAL :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Re-approving!
see https://docs.google.com/document/d/1hxAtt0FaMp6vZX3Z57E62qqzvzsP3EzRE56N4ye7fzo/edit?tab=t.0#heading=h.xzptrog8pyxf
This library generates a combined gapic package from a CLI tool vs. as an owlbot function