vscode-extension v0.0.6: v0.2 grammar, embedded stdlib detection, update check.
Min CLI 0.1.2. See main doc/design/vscode-extension-commit.md for branch workflow. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
d1b75d88c5
commit
9361992d11
5 files changed
+125
-11
No files matched your search
@@ -2,7 +2,7 @@
|
||||
"name": "marqdo",
|
||||
"displayName": "Marqdo",
|
||||
"description": "Language support for Marqdo (.mq.md) — code as documentation.",
|
||||
"version": "0.0.5",
|
||||
"version": "0.0.6",
|
||||
"publisher": "cflmy",
|
||||
"icon": "media/icon.png",
|
||||
"repository": {
|
||||
@@ -12,7 +12,7 @@
|
||||
"bugs": {
|
||||
"url": "https://github.com/cflmy/marqdo/issues"
|
||||
},
|
||||
"homepage": "https://github.com/cflmy/marqdo/tree/vscode-extension/vscode-extension",
|
||||
"homepage": "https://github.com/cflmy/marqdo/tree/main/vscode-extension",
|
||||
"engines": {
|
||||
"vscode": "^1.85.0"
|
||||
},
|
||||
@@ -179,9 +179,14 @@
|
||||
},
|
||||
"marqdo.minCliVersion": {
|
||||
"type": "string",
|
||||
"default": "0.1.0",
|
||||
"default": "0.1.2",
|
||||
"description": "Minimum required Marqdo CLI version (semver). Older installs trigger an upgrade prompt."
|
||||
},
|
||||
"marqdo.autoInstall.checkUpdates": {
|
||||
"type": "boolean",
|
||||
"default": true,
|
||||
"description": "Periodically check GitHub Releases for newer CLI / extension versions."
|
||||
},
|
||||
"marqdo.diagnoseOnSave": {
|
||||
"type": "boolean",
|
||||
"default": false,
|
||||
|
||||
@@ -9,6 +9,7 @@ import {
|
||||
resolveCliPath,
|
||||
resolveLibEnv,
|
||||
} from "./install";
|
||||
import { checkForUpdates } from "./updateCheck";
|
||||
|
||||
let output: vscode.OutputChannel;
|
||||
let diagnostics: DiagnosticBag;
|
||||
@@ -51,7 +52,11 @@ export function activate(context: vscode.ExtensionContext): void {
|
||||
})
|
||||
);
|
||||
|
||||
void promptIfNeeded(context, output);
|
||||
void (async () => {
|
||||
await promptIfNeeded(context, output);
|
||||
const status = checkInstallStatus(context);
|
||||
await checkForUpdates(context, output, status.version);
|
||||
})();
|
||||
}
|
||||
|
||||
export function deactivate(): void {
|
||||
|
||||
@@ -8,6 +8,8 @@ import { probeMarqdo } from "./cli";
|
||||
const REPO = "cflmy/marqdo";
|
||||
const SKIP_KEY = "marqdo.skipInstallPrompt";
|
||||
const MANAGED_DIR = "cli";
|
||||
/** CLI builds from this version ship stdlib inside the binary. */
|
||||
export const EMBEDDED_STDLIB_SINCE = "0.1.2";
|
||||
|
||||
export type InstallStatus = {
|
||||
cliOk: boolean;
|
||||
@@ -175,7 +177,14 @@ export function checkInstallStatus(context: vscode.ExtensionContext): InstallSta
|
||||
}
|
||||
const parsed = parseCliVersion(probe.version ?? "");
|
||||
const versionOk = parsed !== undefined && compareSemver(parsed, need) >= 0;
|
||||
const lib = stdlibPresent(cliPath, context);
|
||||
let lib = stdlibPresent(cliPath, context);
|
||||
if (
|
||||
parsed &&
|
||||
compareSemver(parsed, EMBEDDED_STDLIB_SINCE) >= 0 &&
|
||||
!lib.ok
|
||||
) {
|
||||
lib = { ok: true, root: "(embedded in binary)" };
|
||||
}
|
||||
|
||||
let suggestedMode: "bundle" | "stdlib" | undefined;
|
||||
if (!versionOk) {
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
import * as vscode from "vscode";
|
||||
import { compareSemver, parseCliVersion } from "./install";
|
||||
|
||||
const REPO = "cflmy/marqdo";
|
||||
const LAST_CHECK_KEY = "marqdo.lastUpdateCheck";
|
||||
const CHECK_INTERVAL_MS = 24 * 60 * 60 * 1000;
|
||||
|
||||
type GhRelease = {
|
||||
tag_name: string;
|
||||
html_url: string;
|
||||
assets: { name: string }[];
|
||||
};
|
||||
|
||||
async function fetchLatestRelease(): Promise<GhRelease> {
|
||||
const res = await fetch(`https://api.github.com/repos/${REPO}/releases/latest`, {
|
||||
headers: {
|
||||
Accept: "application/vnd.github+json",
|
||||
"User-Agent": "marqdo-vscode-extension",
|
||||
},
|
||||
});
|
||||
if (!res.ok) {
|
||||
throw new Error(`GitHub releases/latest HTTP ${res.status}`);
|
||||
}
|
||||
return (await res.json()) as GhRelease;
|
||||
}
|
||||
|
||||
function extensionVersion(): string {
|
||||
return vscode.extensions.getExtension("cflmy.marqdo")?.packageJSON?.version ?? "0.0.0";
|
||||
}
|
||||
|
||||
function pickVsixAsset(release: GhRelease): string | undefined {
|
||||
const mine = extensionVersion();
|
||||
const exact = release.assets.find((a) => a.name === `marqdo-${mine}.vsix`);
|
||||
if (exact) {
|
||||
return undefined;
|
||||
}
|
||||
return release.assets.find((a) => a.name.endsWith(".vsix"))?.name;
|
||||
}
|
||||
|
||||
/** Notify when a newer CLI or extension release exists on GitHub. */
|
||||
export async function checkForUpdates(
|
||||
context: vscode.ExtensionContext,
|
||||
output: vscode.OutputChannel,
|
||||
installedCliVersion?: string
|
||||
): Promise<void> {
|
||||
if (vscode.workspace.getConfiguration("marqdo").get<boolean>("autoInstall.checkUpdates") === false) {
|
||||
return;
|
||||
}
|
||||
const last = context.globalState.get<number>(LAST_CHECK_KEY) ?? 0;
|
||||
if (Date.now() - last < CHECK_INTERVAL_MS) {
|
||||
return;
|
||||
}
|
||||
await context.globalState.update(LAST_CHECK_KEY, Date.now());
|
||||
|
||||
try {
|
||||
const release = await fetchLatestRelease();
|
||||
const latestTag = release.tag_name.replace(/^v/, "");
|
||||
const extVer = extensionVersion();
|
||||
const messages: string[] = [];
|
||||
|
||||
if (compareSemver(latestTag, extVer) > 0 || pickVsixAsset(release)) {
|
||||
messages.push(`extension ${extVer} → ${release.tag_name}`);
|
||||
}
|
||||
const parsedCli = installedCliVersion ? parseCliVersion(installedCliVersion) : undefined;
|
||||
if (parsedCli && compareSemver(latestTag, parsedCli) > 0) {
|
||||
messages.push(`CLI ${parsedCli} → ${release.tag_name}`);
|
||||
}
|
||||
if (messages.length === 0) {
|
||||
output.appendLine(`[update] up to date (${release.tag_name})`);
|
||||
return;
|
||||
}
|
||||
output.appendLine(`[update] newer release: ${messages.join("; ")}`);
|
||||
const choice = await vscode.window.showInformationMessage(
|
||||
`Marqdo ${release.tag_name} is available (${messages.join(", ")}).`,
|
||||
"Open Releases",
|
||||
"Later"
|
||||
);
|
||||
if (choice === "Open Releases") {
|
||||
await vscode.env.openExternal(vscode.Uri.parse(release.html_url));
|
||||
}
|
||||
} catch (e) {
|
||||
output.appendLine(
|
||||
`[update] check skipped: ${e instanceof Error ? e.message : String(e)}`
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,8 @@
|
||||
{ "include": "#else-arm" },
|
||||
{ "include": "#return-line" },
|
||||
{ "include": "#statement-line" },
|
||||
{ "include": "#param-or-loop" },
|
||||
{ "include": "#param-line" },
|
||||
{ "include": "#loop-line" },
|
||||
{ "include": "#branch" },
|
||||
{ "include": "#table" },
|
||||
{ "include": "#inline-code" },
|
||||
@@ -118,17 +119,25 @@
|
||||
"3": { "name": "entity.name.function.call.marqdo" }
|
||||
}
|
||||
},
|
||||
"param-or-loop": {
|
||||
"name": "meta.list.structure.marqdo",
|
||||
"param-line": {
|
||||
"name": "meta.param.marqdo",
|
||||
"match": "^(\\s*)(\\+)(\\s+)(.+)$",
|
||||
"captures": {
|
||||
"2": { "name": "keyword.other.param.marqdo" },
|
||||
"4": { "name": "variable.parameter.marqdo" }
|
||||
}
|
||||
},
|
||||
"loop-line": {
|
||||
"name": "meta.loop.marqdo",
|
||||
"match": "^(\\s*)(-)(\\s+)(.+)$",
|
||||
"captures": {
|
||||
"2": { "name": "punctuation.definition.list.marqdo" },
|
||||
"4": { "name": "variable.parameter.marqdo" }
|
||||
"2": { "name": "keyword.control.loop.marqdo" },
|
||||
"4": { "name": "meta.loop.body.marqdo" }
|
||||
}
|
||||
},
|
||||
"branch": {
|
||||
"name": "meta.branch.marqdo",
|
||||
"match": "^(\\s*)([+]|\\d+\\.)(\\s+)(.*)$",
|
||||
"match": "^(\\s*)(\\d+\\.)(\\s+)(.*)$",
|
||||
"captures": {
|
||||
"2": { "name": "keyword.control.conditional.marqdo" },
|
||||
"4": { "name": "meta.branch.condition.marqdo" }
|
||||
|
||||
Reference in new issue
Block a user