-
-
Notifications
You must be signed in to change notification settings - Fork 1
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
update unversioned binaries #97
Comments
I have this done locally but it requires changes to deno-udd (to handle unspecified version)
|
It would be good if you could enable this feature with an option flag. We might migrate to https://github.com/deaddeno/update or find a way to use https://github.com/hasundue/deno-molt ? |
I feel like molt doesn't really fit, since the whole keypoint which is deno graph doesn't work here, unless maybe you expose some useful utilities Does this really need a dependency can't we just regex search and replace deno urls ? |
True. |
I'm using this script for now import homeDir from "https://deno.land/x/dir@1.5.1/home_dir/mod.ts";
import * as stdPath from "https://deno.land/std@0.204.0/path/mod.ts";
import * as infer from "npm:deno-infer@1.0.8";
function* getPrograms() {
const homeDirPath = homeDir();
if (!homeDirPath) throw "home dir not found";
const programsDir = Deno.readDirSync(
stdPath.join(homeDirPath, ".deno", "bin"),
);
for (const entry of programsDir) {
if (!entry.isFile) continue;
const path = stdPath.join(homeDirPath, ".deno", "bin", entry.name);
//FIXME: windows have a different extension
if (infer.getFromPath(path)?.extension() !== "sh") continue;
yield {
name: entry.name,
path,
};
}
}
async function update(text: string) {
let newText = text;
for (
const match of text.matchAll(
/https:\/\/deno.land\/x\/([^@/]+)(@[^/]+)*\//g,
)
) {
let [_url, name, version] = match;
// remove the @
if (version) version = version.slice(1);
const latestVersion: string | undefined = await fetch(
`https://cdn.deno.land/${name}/meta/versions.json`,
).then((r) => r.json()).then((r) => r.latest);
if (latestVersion === undefined) {
console.error(
"Could not determine package latest version, name: " + name,
);
return;
}
if (version !== latestVersion) {
console.log(
`${name} version: '${version}' remote-version: '${latestVersion}'`,
);
const oldUrl = version
? `https://deno.land/x/${name}@${version}/`
: `https://deno.land/x/${name}/`;
newText = newText.replace(
oldUrl,
`https://deno.land/x/${name}@${latestVersion}/`,
);
}
}
if (newText === text) return;
return newText;
}
if (import.meta.main) {
for (const program of getPrograms()) {
const text = Deno.readTextFileSync(program.path);
const newText = await update(text);
if (newText !== undefined) {
if (confirm(`Update ${program.name} ?`)) {
Deno.writeTextFileSync(program.path, newText);
}
}
}
} |
Thanks. Looks good, very clean. |
Ah maybe I can just use a routine in molt with a little work. Let me try. |
It's cool there is nothing to copyright there, Iits better if nublar gets more features |
Now fixing molt for this |
Done but not tested extensively. Bug reports would be very helpful. |
thanks awesome |
I think a cool feature would be to update unversioned binaries to their latest version
I have stuff like
with this feature I expect an update form
unversioned
tox.x.x
(whatver the latest is)This will make suddenly most of my binaries compatible with nublar with no effort of my part as the user
The text was updated successfully, but these errors were encountered: