Repository navigation
Add --resource-tool-version flag to pin ResourceTool (#251) #256
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -32,6 +32,8 @@ export interface ResourceToolArgs { | |
| prefabsFolder?: string; | ||
| config?: string; | ||
| ignoreStdio?: boolean; | ||
| /** npm version or dist-tag of the ResourceTool package (default: "latest") */ | ||
| version?: string; | ||
| } | ||
|
|
||
| function splitCommand(input: string): string[] { | ||
|
|
@@ -80,6 +82,7 @@ export async function callResourceTool( | |
| prefabsFolder, | ||
| config, | ||
| ignoreStdio, | ||
| version = "latest", | ||
| }: ResourceToolArgs, | ||
| ): Promise<void> { | ||
| const command = modeToArgs(run); | ||
|
|
@@ -92,7 +95,7 @@ export async function callResourceTool( | |
| ...(config ? [`config=${config}`] : []), | ||
| ]; | ||
| const platformSuffix = getPlatformSuffix(ctx); | ||
| const packageName = `@gm-tools/resource-tool-${platformSuffix}@latest`; | ||
| const packageName = `@gm-tools/resource-tool-${platformSuffix}@${version}`; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: The version goes straight into the npx argument list, and on Windows
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep, good catch, thanks. I went with the first option: the flag's parse now rejects anything that isn't [A-Za-z0-9._-]+ with a clear error, so ranges never reach npx/cmd.exe. The brief also says "exact version or dist-tag" now. |
||
| try { | ||
| await npmExec(ctx, { | ||
| packageName, | ||
|
|
||
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.
Reviewed at d64292e.
My earlier point is addressed.
resourceToolVersion.parseincommand.tsnow rejects anything that doesn't match^[A-Za-z0-9._-]+$and gives a clear error, so ranges with>or^never reach npx or cmd.exe. The brief now says "Exact ResourceTool version or dist-tag". All four subcommands (mcp,eval,repl,script) sharecommonFlags, so the flag reaches each of them. If the flag is left out,callResourceToolstill useslatest, so default behaviour doesn't change.initstill calls ResourceTool atlatestwith no way to pin it. That's fine for this PR, but LTS users may want it there later. Looks good to me.