-
Notifications
You must be signed in to change notification settings - Fork 30
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
WIP: Add version-tracker #134
Conversation
Yes. Linux uses Clang 9. See this: https://github.com/atom-ide-community/atom/blob/master/script/vsts/platforms/templates/preparation.yml |
I would recommend making a backup of this branch and reset --hard against our master, and then cherry-pick the commits from your backup. Sorry about this. I just updated our master now. |
package.json
Outdated
{ | ||
"name": "visual studio", | ||
"versionCommand": [ | ||
"C:\\Program Files (x86)\\Microsoft Visual Studio\\Installer\\vswhere.exe" |
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.
vswhere
does not give the version of the installed visual studio.
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.
Do you know of a global command for Visual Studio?
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.
Yes, but it is not that straight forward.
vswhere -products * -find **/Hostx64/x64/*
gives the list of all installed visual studio installations. Then we should find 2017
from the given 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.
OK here is a one liner in PowerShell
❯ (vswhere -products * -find **/Hostx86/x86/* | select-string '(\\MSVC\\)(.*)(\\bin)').matches.groups[2].value
14.16.27023
Works for both x64 and x86
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.
Thanks! that helps me out a ton.
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.
Do you install vswhere
in your script? Since this is not available on Windows by default.
Nothing like a good force push to fix everything haha |
Can we log the results in another file than And perhaps we can set the configuration for this in a file other than |
script/build
Outdated
}).then(()=>{ | ||
// record the versions of binaries that were used to create the successful build | ||
generatePackageJsonWithTracking() |
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.
If we do this in script/build
, it will update package.json
and invalidate all the caches. It's tricky for our CI.
See my comment above in this thread, but to reiterate: Can this config/logging go in a file other than package.json
?
Yeah @DeeDeeG I'll make a new file for it. Does I prefer having all config info (babel config, browser list, etc) in the package.json. But that's just a preference, so I'm fine to put also put the version-tracker config into to the versions.log. For merges and CI though I do want to point out; I think it makes sense to split up the config and the log though. Basically changes to the version log are always ignored because they're fully auto-generated, but changed to the config (e.g. package.json) would be hand-done (only updated if binary dependencies were added/removed) |
Also FYI It'll probably be Sunday before I update the PR. |
No problem!
That's fine. It can be anything. If you have something else in mind that would work well if your module is used for lots of projects, I don't mind what you call it.
I don't quite understand? If it's written to disk, git will see the change, and folks will tend to accidentally commit it in their PRs. Maybe we can add the
Fine by me. Given that they're both in As a design philosophy thing: I personally think if the logged versions are read by our code and used for something by our code then they could logically go in This seems like info that's only relevant when developing and maybe when building (for example: if we follow up after this by somehow installing these exact versions in CI), so it should ideally not be shipped with the app if possible; Recapping the caching issue: If logging output has to be in |
Sounds good, thats good philosophy to know about for the package.json. And sorry about the "ignore" confusion. I only meant humans basically ignoring it in PR's, not gitignore. I think is should be auto-generated with every build, but not every PR. I'll add a limiter to the length so it doesn't become absurdly long (it'll delete old build info when new ones roll in). It'll just be like the package-lock.json where nobody pays attention to it except for special debugging cases. |
I have a tool for the files that should be ignored most of the time but should be committed in some cases. I think this version-log is the same. We can commit it only in our release CI. That's what the organization uses for using TypeScript, Parcel, etc in Atom packages. |
@jeff-hykin I cannot push to your branch. If you can rebase this. In package.json ripgrep is updated. About the lock just accept the changes and bootstrap again. |
@aminya I'm having some trouble with windows. Any idea why
I was just going to test if node would automatically convert Here's the more general thing I'm trying to get working I've got a powershell script that runs fine > .\Desktop\file.ps1
hello world But it fails when running it in node const { spawnSync } = require('child_process')
const { existsSync } = require("fs")
console.log(existsSync(".\Desktop\file.ps1")) // true
let result = spawnSync(".\Desktop\file.ps1",[])
console.log(result) // non-descript failure |
https://nodejs.org/api/child_process.html#child_process_spawning_bat_and_cmd_files_on_windows
I think "echo" might be a shell utility from So you might have to provide the shell as the command, then have your script be an argument to that command. |
echo is not a binary or file in Windows while it is in Linux. I recommend using shelljs which works independently from the operating system. Its CLI app is called Example of shelljs Otherwise, you can spawn a shell instead specifically (like PowerShell or cmd). |
Thanks for the input
Thanks to I like shelljs (actually last time I used it I think it was in an alpha/beta state), but I was hoping not to have it as a dependency for such a simple version tracking tool. I may end up needing it though.
Thanks. I was aware most the short powershell commands (echo, pwd, ls) were aliases, but I thought it was linking to a cmd executable. I did a lot of this stuff in the past (using shelljs) but I guess its been about 4 years. I was thinking Microsoft added execution support for powershell, but it looks like spawns only works for .exe and .bat files. Sadly, while node converts paths for things like |
Why don't you use shelljs as I mentioned? It is a cross-platform solution for writing shell applications. There is also this WIP node-shell, but I prefer shell.js which does not rely on Bash or Powershell. If you can point to a specific code in your repository, I can help you with that.
For paths, you can use |
Here I found another great package for execution: https://github.com/sindresorhus/execa |
87c664d
to
67dcaef
Compare
^
Cool! I never knew. Sadly it still fails for spawn since I believe it doesn't invoke a shell |
d5b2b31
to
1808785
Compare
I have made the build script parallel + async in other pull requests. So, I moved the version tracker call: package-lock needs to be updated. |
Version tracker was updated to handle issues (like |
Okay, PR should be ready for review. @aminya I'm not sure what you mean by moving the version tracker call, it looks like its in the same place to me in that linked code. package-lock was updated. Last step I need to do is test the build on mac/windows (Not sure when I'll get that done) |
Awesome! I'll review and merge this soon. |
@@ -0,0 +1 @@ | |||
(vswhere -products * -find **/Hostx86/x86/* | select-string '(\\MSVC\\)(.*)(\\bin)').matches.groups[2].value |
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 requires vswhere which may not be installed. I was recently involved with a project that uses some manual code to find Visual Studio in case vswhere
is not installed.
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.
Another possibility is to bundle vswhere
with version tracker (or Atom itself). It is a tiny exe file:
https://github.com/microsoft/vswhere/releases/download/2.8.4/vswhere.exe
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.
dang, all that is needed just to check the version? 😬 I guess storing the exe in the atom repo is the best option
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'd suggest that you add this to the version tracker itself. It makes sense that you right a little script that downloads it and runs it. That would be useful for anyone who uses the version tracker (not just Atom).
Here is a sketch. Should I make a PR??
const fs = require('fs');
const path = require('path');
const download = require('download');
const childProcess = require('child_process');
const vswhereVersion = '2.8.4';
const PROGRAM_FILES_X86 = process.env['ProgramFiles(x86)'] || 'ProgramFiles(x86)'
const vswhereDir = `${PROGRAM_FILES_X86}\\Microsoft Visual Studio\\Installer`
const vswherePath = `${vswhereDir}\\vswhere.exe`
async function downloadVsWhere() {
if (!fs.existsSync(vswherePath)) {
await download(
`https://github.com/microsoft/vswhere/releases/download/${vswhereVersion}/vswhere.exe`,
vswherePath,
);
}
}
function findWithVswhere(pattern) {
// if already installed and on PATH
try {
let installationPath = child_process.execSync(`vswhere -products * -latest -prerelease -property installationPath`).toString().trim()
return installationPath + '\\' + pattern
} catch (e) {
console.warn(`vswhere failed: ${e}`)
}
// download
await downloadVsWhere()
try {
let installationPath = child_process.execSync(`${vswherePath} -products * -latest -prerelease -property installationPath`).toString().trim()
return installationPath + '\\' + pattern
} catch (e) {
console.warn(`vswhere failed: ${e}`)
}
return null
}
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 can make another repo that wraps that up, but I don't want to hardcode anything for version-tracker. I'm looking for it to be a one-and-done generic tool; no maintenance, security updates, urls that can go out-of-date, or broken node dependencies. Which is also why I didn't use shelljs
Actually it might be best to just wrap up vs-where and make it a commandline npm package.
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.
how can node use Visual Studio without knowing what version it is?
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 also kinda think the version tracking would be useful as-is (its just a debugging tool for people who build atom). We can mention the vswhere check+download in the docs, and create an issue to keep track of it, but the optional dependency of Visual Studio is kinda blocking/slowing an otherwise straightforward improvement.
If vswhere is included in all Visual Studio versions after 2017, I say we just require Visual Studio ≥ 2017
package.json
Outdated
[ | ||
"pwsh", | ||
".\\script\\get-visual-studio-verion.ps1" | ||
], |
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 do have two versions of this? The forward slash one is enough for all the operating systems.
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.
If its tested and works without the extra's that would be great. The code is still using spawn which doesn't invoke a shell, but I guess since its calling powershell the argument will get converted
This is all of the executables I'm aware of
Visual Studio command still needs to be added, but that can be done after the PR