Skip to content

Commit

Permalink
Ignore incompatible demos
Browse files Browse the repository at this point in the history
  • Loading branch information
sonnyp committed Apr 27, 2024
1 parent fae77d8 commit 16f4f12
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 4 deletions.
33 changes: 30 additions & 3 deletions build-aux/library.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ const demos = [];
const demo = JSON.parse(str);
demo.name = file_info.get_name();

if (!isDemoCompatible(demo)) {
continue;
}

const languages = [];
if (demo_dir.get_child("main.js").query_exists(null)) {
languages.push("javascript");
Expand Down Expand Up @@ -107,8 +111,6 @@ const demos = [];
loop.quit();
});

loop.run();

async function copyDemo(source, destination) {
try {
destination.make_directory_with_parents(null);
Expand Down Expand Up @@ -171,7 +173,7 @@ async function copyDemo(source, destination) {
}
}

export async function copyDirectory(source, destination) {
async function copyDirectory(source, destination) {
const enumerator = await source.enumerate_children_async(
`${Gio.FILE_ATTRIBUTE_STANDARD_NAME},${Gio.FILE_ATTRIBUTE_STANDARD_IS_HIDDEN}`,
Gio.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,
Expand Down Expand Up @@ -206,3 +208,28 @@ export async function copyDirectory(source, destination) {
}
}
}

const keyFile = new GLib.KeyFile();
keyFile.load_from_file("/.flatpak-info", GLib.KeyFileFlags.NONE);
// runtime/org.gnome.Sdk/x86_64/master
const [, , , runtime_version] = keyFile
.get_string("Application", "runtime")
.split("/");

function isDemoCompatible(demo) {
const demo_runtime_version = demo["runtime-version"];

if (demo_runtime_version === "master") {
return runtime_version === "master";
} else if (runtime_version === "master") {
return true;
} else if (!demo_runtime_version) {
return true;
}

console.log(+runtime_version, +demo_runtime_version);

return +runtime_version >= +demo_runtime_version;
}

loop.run();
2 changes: 1 addition & 1 deletion demos
1 change: 1 addition & 0 deletions src/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import "./icons/re.sonny.Workbench-larger-brush-symbolic.svg" with { type: "icon
import "./icons/re.sonny.Workbench-terminal-symbolic.svg" with { type: "icon" };
import "./icons/re.sonny.Workbench-test-pass-symbolic.svg" with { type: "icon" };
import "./icons/re.sonny.Workbench-up-symbolic.svg" with { type: "icon" };
import "./icons/re.sonny.Workbench-library-symbolic.svg" with { type: "icon" };

ensureDir(data_dir);

Expand Down

0 comments on commit 16f4f12

Please sign in to comment.