Skip to content

Commit

Permalink
Merge pull request ubiquity-os#25 from ubq-testing/improvements
Browse files Browse the repository at this point in the history
Improvements
  • Loading branch information
rndquu authored Nov 28, 2024
2 parents cf8e6da + 1ac5807 commit b52f2db
Show file tree
Hide file tree
Showing 26 changed files with 1,260 additions and 764 deletions.
2 changes: 1 addition & 1 deletion .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
"dictionaries": ["typescript", "node", "software-terms"],
"import": ["@cspell/dict-typescript/cspell-ext.json", "@cspell/dict-node/cspell-ext.json", "@cspell/dict-software-terms"],
"ignoreRegExpList": ["[0-9a-fA-F]{6}"],
"ignoreWords": ["ubiquibot", "Supabase", "supabase", "SUPABASE", "sonarjs", "mischeck"]
"ignoreWords": ["ubiquibot", "Supabase", "supabase", "SUPABASE", "sonarjs", "mischeck", "Typebox"]
}
2 changes: 2 additions & 0 deletions .github/knip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ const config: KnipConfig = {
"@actions/core",
"esbuild",
"@ubiquity-os/plugin-sdk",
"markdown-it",
"@types/markdown-it",
],
eslint: true,
};
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"@ubiquity-os/ubiquity-os-kernel": "^2.5.3",
"ajv": "^8.17.1",
"dotenv": "^16.4.4",
"markdown-it": "^14.1.0",
"yaml": "^2.6.0"
},
"devDependencies": {
Expand All @@ -51,6 +52,7 @@
"@jest/globals": "29.7.0",
"@mswjs/data": "0.16.1",
"@types/jest": "^29.5.12",
"@types/markdown-it": "^14.1.2",
"@types/node": "20.14.5",
"cspell": "8.14.4",
"cypress": "13.6.6",
Expand Down
2 changes: 1 addition & 1 deletion static/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<tbody id="manifest-gui-body"></tbody>
<tfoot
><tr
><td></td><td><button id="remove"></button><button id="add"></button></td></tr
><td></td><td><button id="reset-to-default"></button><button id="remove"></button><button id="add"></button></td></tr
></tfoot>
</table>
</section>
Expand Down
37 changes: 16 additions & 21 deletions static/main.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { AuthService } from "./scripts/authentication";
import { ManifestDecoder } from "./scripts/decode-manifest";
import { ManifestFetcher } from "./scripts/fetch-manifest";
import { ManifestRenderer } from "./scripts/render-manifest";
import { renderOrgPicker } from "./scripts/rendering/org-select";
import { toastNotification } from "./utils/toaster";

async function handleAuth() {
Expand All @@ -12,30 +12,31 @@ async function handleAuth() {

export async function mainModule() {
const auth = await handleAuth();
const decoder = new ManifestDecoder();
const renderer = new ManifestRenderer(auth);
const search = window.location.search.substring(1);

if (search) {
const decodedManifest = await decoder.decodeManifestFromSearch(search);
return renderer.renderManifest(decodedManifest);
}
renderer.manifestGuiBody.dataset.loading = "false";

try {
const ubiquityOrgsToFetchOfficialConfigFrom = ["ubiquity-os"];
const fetcher = new ManifestFetcher(ubiquityOrgsToFetchOfficialConfigFrom, auth.octokit, decoder);
const fetcher = new ManifestFetcher(ubiquityOrgsToFetchOfficialConfigFrom, auth.octokit);
const cache = fetcher.checkManifestCache();

if (auth.isActiveSession()) {
const userOrgs = await auth.getGitHubUserOrgs();
renderer.renderOrgPicker(userOrgs);

if (Object.keys(cache).length === 0) {
const manifestCache = await fetcher.fetchMarketplaceManifests();
localStorage.setItem("manifestCache", JSON.stringify(manifestCache));
// this is going to extract URLs from our official config which we'll inject into `- plugin: ...`
renderer.manifestGuiBody.dataset.loading = "true";
const killNotification = toastNotification("Fetching manifest data...", { type: "info", shouldAutoDismiss: true });
renderOrgPicker(renderer, []);

await fetcher.fetchMarketplaceManifests();
await fetcher.fetchOfficialPluginConfig();
killNotification();
renderer.manifestGuiBody.dataset.loading = "false";
}

renderOrgPicker(renderer, userOrgs);
} else {
renderer.renderOrgPicker([]);
renderOrgPicker(renderer, []);
}
} catch (error) {
if (error instanceof Error) {
Expand All @@ -46,10 +47,4 @@ export async function mainModule() {
}
}

mainModule()
.then(() => {
console.log("mainModule loaded");
})
.catch((error) => {
console.error(error);
});
mainModule().catch(console.error);
Loading

0 comments on commit b52f2db

Please sign in to comment.