-
Notifications
You must be signed in to change notification settings - Fork 243
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
Init logic bundle the compiler logic instead of shelling out to some random client #6086
base: main
Are you sure you want to change the base?
Conversation
@@ -314,7 +269,8 @@ async function tspInstall( | |||
const TIMEOUT = 600000; // set timeout to 10 minutes which should be enough for tsp install for a new project | |||
try { | |||
const result = await createPromiseWithCancelAndTimeout( | |||
client.runCliCommand(["install"], directory), | |||
// client.runCliCommand(["install"], directory), | |||
Promise.resolve(undefined), // todo: implement tsp install |
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.
todo: deal with tsp install
❌ There is undocummented changes. Run The following packages have changes but are not documented.
Show changes |
); | ||
return false; | ||
} | ||
// if (!result) { |
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.
todo when was this even getting here previously
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.
client.initProject would return false when fails for some reason. This is not needed if calling the function directly.
return false; | ||
} | ||
} | ||
// TODO: Why is this here again? |
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.
call validate in compiler to do further validation (check json schema). you can check validateTemplate in init.ts.
if (info.sourceType === "compiler") { | ||
// no need to validate template from compiler | ||
return true; | ||
} | ||
|
||
const compilerVersion = client.initializeResult?.serverInfo?.version; | ||
const compilerVersion = vscode.extensions.getExtension("typespec.typespec")?.packageJSON.version; |
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.
what if it's a hotfix release that compiler doesn't have the version.
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.
not sure I get what you mean. Believe i was just trying to get the version of the extension here. But also like a lot of this is is more of POC than the final product as its now stuck on permission error(not sure if its due to my vscode or we should use other apis for writing files) and with 1.0 coming not sure I'll have time to finish this
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.
Not a big issue, what I mean is that the vscode extension's version is used as compiler version here, which is fine in most case but when the vscode extension has a hotfix release (i.e. 0.xx.1) but compiler doesn't, the version got here may not exist for compiler (i.e. compile doesn't have 0.xx.1 version).
I think it should be fine to be used here to compare version internally considering the patch version is always larger. But it's better to (maybe cut the patch #) when showing the version to end user which will be confusing if we are showing some non-existing compiler version to them.
I will give it a try to see whether I get the permission error. will let you know. thanks.
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 gave it a try and didn't get any permission issue, but I found the files generated by writePackageJson(), writeConfig(), writeMain(), writeGitignore()
are actually written to VSCode folder because they are using cwd (which is VSCode folder in this case) to write files when only a file name is given. After I pass the config.directory to them and parse absolute path to write files in these method. These files can be generated properly.
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.
Ah that would probably explain the permission issue on osx.
Thanks for finding this.
template: value, | ||
})), | ||
); | ||
} | ||
logger.info("Loading init templates from config..."); |
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.
this log is for the next step.
@@ -0,0 +1,2 @@ | |||
export { NodeSystemHost } from "../core/node-system-host.js"; | |||
export { scaffoldNewProject } from "../init/scaffold.js"; |
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 you also need to export validateTemplate method or template schema for vscode to do all the template validation.
Initial move to fix #6068
Move the logic to init a typespec project to be bundled in vscode instead of shelling to the LSP.