Skip to content

Commit

Permalink
remove mod.json requirement and make it an activation event instead
Browse files Browse the repository at this point in the history
also removes the publish command
  • Loading branch information
HJfod committed Nov 17, 2024
1 parent a8fbd93 commit 6acfd13
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 67 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Geode for VS Code Changelog

## [v1.16.0]
- Remove the `Geode: Publish` command as it no longer works

## [v1.15.2]
- Disable extension if no mod.json is found within workspace
- Fix linter triggering on comments
Expand Down
14 changes: 3 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"url": "https://github.com/geode-sdk/vscode"
},
"activationEvents": [
"onLanguage:cpp",
"workspaceContains:**/loader/",
"workspaceContains:**/mod.json"
],
"galleryBanner": {
Expand All @@ -50,10 +50,6 @@
{
"title": "Geode: Open Sprite Browser",
"command": "geode.openSpriteBrowser"
},
{
"title": "Geode: Publish Mod",
"command": "geode.publishMod"
}
],
"keybindings": [
Expand All @@ -65,12 +61,8 @@
"languages": [
{
"id": "bro",
"aliases": [
"Bro"
],
"extensions": [
".bro"
],
"aliases": ["Broma"],
"extensions": [".bro"],
"configuration": "./src/broma/language-configuration.json"
}
],
Expand Down
51 changes: 0 additions & 51 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@ import { SpriteHoverPreview } from "./project/hover";
import { registerLinters } from "./project/lint";

export async function activate(context: ExtensionContext) {
if ((await workspace.findFiles("mod.json")).length == 0) {
return;
}

const channel = window.createOutputChannel("Geode");

// store globals
Expand Down Expand Up @@ -71,53 +67,6 @@ export async function activate(context: ExtensionContext) {
}),
);

context.subscriptions.push(
commands.registerCommand("geode.publishMod", async () => {
const res = geode.cli.runCLICmdInProject(`project publish`);
if (res.isError()) {
window.showErrorMessage(
`Unable to publish mod: ${res.unwrapErr()}`,
);
return;
}
const value = res.unwrap();
getOutputChannel().append(value);
// Check if unable to automatically push
let pushCmd = value.match(/`git.*`/g)?.[0];
pushCmd = pushCmd?.substring(1, pushCmd.length - 1);
if (pushCmd) {
try {
getOutputChannel().appendLine(`Running ${pushCmd}`);
execSync(pushCmd, {
encoding: "utf-8",
cwd: getActiveProject()?.path,
});
} catch (err) {
window.showErrorMessage(`Syncing publish failed: ${err}`);
}
}
let prURL = value.match(/https:\/\/.*?\.\.\.[a-zA-Z0-9]+/g)?.[0];
if (!prURL) {
window.showErrorMessage(
`Unable to find Github pull request URL from command output - see output panel for details`,
);
getOutputChannel().append(value);
getOutputChannel().show();
return;
}
window
.showInformationMessage(
`To complete the publish, please open a Pull Request in your indexer: ${prURL}`,
"Open URL",
)
.then((btn) => {
if (btn === "Open URL" && prURL) {
env.openExternal(Uri.parse(prURL));
}
});
}),
);

context.subscriptions.push(
languages.registerColorProvider(
{ language: "cpp" },
Expand Down
10 changes: 5 additions & 5 deletions src/project/lint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ function lint(
for (const match of document.data.matchAll(
new RegExp(`(?:\\/\\/\\s*@geode-begin-ignore\\(${code}\\).*?$)(?:(?!\\/\\/\\s*@geode-end-ignore\\(${code}\\))(?:\\s|.))*|\\/\\*(?:(?!\\*\\/)(?:\\s|.))*`, "gm")
)) {
if (match.index != undefined) {
if (match.index !== undefined) {
ignoreRanges.push({ from: match.index, to: match.index + match[0].length });
}
}
Expand All @@ -65,7 +65,7 @@ function lint(
`(?<ignore>\\/\\/\\s*@geode-ignore\\(${code}\\).*?$\\r?\\n^.*?|\\/\\/.*?)?${regex.source}`,
regex.flags.includes("m") ? regex.flags : regex.flags + "m"
))) {
if (match.index == undefined || match.groups?.ignore || ignoreRanges.some(range => range.from <= match.index! && range.to >= match.index!)) {
if (match.index === undefined || match.groups?.ignore || ignoreRanges.some(range => range.from <= match.index! && range.to >= match.index!)) {
continue;
}

Expand All @@ -77,7 +77,7 @@ function lint(
const result = condition({ text: match[0], groups: match.groups, range });

if (result !== undefined) {
const isString = typeof result == "string";
const isString = typeof result === "string";
const diagnostic = new Diagnostic(range, isString ? result : result.msg, isString ? DiagnosticSeverity.Warning : result.level);
diagnostic.code = code;
diagnostic.source = "geode";
Expand Down Expand Up @@ -107,9 +107,9 @@ function lintSettings(document: MaybeDocument, diagnostics: Diagnostic[]) {

if (!setting) {
return `Unknown setting ${groups!.name}`;
} else if (setting.type == "title") {
} else if (setting.type === "title") {
return "Titles can't be used as a setting value";
} else if (!setting.type.startsWith("custom:") && !groups!.type.split("::").reverse().every((part, i) => part.trim() == types?.[i])) {
} else if (!setting.type.startsWith("custom:") && !groups!.type.split("::").reverse().every((part, i) => part.trim() === types?.[i])) {
return `Setting ${groups!.name} is of type ${setting.type}, not ${groups!.type}`;
}

Expand Down

0 comments on commit 6acfd13

Please sign in to comment.