Skip to content
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

Stop Handling Bundled Packages on the Frontend #134

Merged
merged 1 commit into from
Feb 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ejs-views/partials/package_listing.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@
</div>
</div>
<% } %>
<% if (!pack.isBundled) { %>
<% if (!pack.is_bundled) { %>
<a href="<%=pack.install%>" class="hidden sm:flex items-center justify-center mt-3 md:mt-0">
<button class="w-full md:w-auto">
<i class="fas fa-download mr-2"></i>
Expand Down
56 changes: 2 additions & 54 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,23 +197,14 @@ function prepareForListing(obj) {
pack.downloads = obj[i].downloads ? obj[i].downloads : 0;
pack.stars = obj[i].stargazers_count ? obj[i].stargazers_count : 0;
pack.install = `atom://settings-view/show-package?package=${pack.name}`;
pack.is_bundled = obj[i].is_bundled ?? false;

// Cleanup the data
pack.stars = Number(pack.stars).toLocaleString();
pack.downloads = Number(pack.downloads).toLocaleString();

pack.badges = obj[i].badges ?? [];

// Apply any bundled package logic
if (isBundledPackage(pack.name)) {
pack.isBundled = true;
pack.badges.push({
type: "info",
title: "Bundled",
link: "https://github.com/pulsar-edit/package-backend/blob/main/docs/reference/badge_spec.md#bundled"
});
}

packList.push(pack);
} catch(err) {
console.log(err);
Expand Down Expand Up @@ -255,6 +246,7 @@ function prepareForDetail(obj) {
pack.repoLink = findRepoField(obj);
pack.bugLink = obj.metadata.bugs ? obj.metadata.bugs.url : "";
pack.install = `atom://settings-view/show-package?package=${pack.name}`;
pack.is_bundled = obj.is_bundled ?? false;

pack.providedServices = obj.metadata.providedServices ?? null;
pack.consumedServices = obj.metadata.consumedServices ?? null;
Expand Down Expand Up @@ -287,16 +279,6 @@ function prepareForDetail(obj) {

pack.badges = obj.badges ?? [];

// Apply any bundled package logic
if (isBundledPackage(pack.name)) {
pack.isBundled = true;
pack.badges.push({
type: "info",
title: "Bundled",
link: "https://github.com/pulsar-edit/package-backend/blob/main/docs/reference/badge_spec.md#bundled"
});
}

resolve(pack);
});
}
Expand Down Expand Up @@ -448,40 +430,6 @@ function getPagination(req, api) {
}
}

function isBundledPackage(name) {
// Takes the name of a package and returns true if that package is bundled
// within the Pulsar editor
const bundledPackages = [
"about", "archive-view", "atom-dark-syntax", "atom-dark-ui", "atom-light-syntax",
"atom-light-ui", "autocomplete-atom-api", "autocomplete-css", "autocomplete-html",
"autocomplete-plus", "autocomplete-snippets", "autoflow", "autosave", "background-tips",
"base16-tomorrow-dark-theme", "base16-tomorrow-light-theme", "bookmarks",
"bracket-matcher", "command-palette", "dalek", "deprecation-cop", "dev-live-reload",
"encoding-selector", "exception-reporting", "find-and-replace", "fuzzy-finder",
"git-diff", "go-to-line", "grammar-selector", "image-view", "incompatible-packages",
"keybinding-resolver", "language-c", "language-clojure", "language-coffee-script",
"language-csharp", "language-css", "language-gfm", "language-git", "language-go",
"language-html", "language-hyperlink", "language-java", "language-javascript",
"language-json", "language-less", "language-make", "language-mustache",
"language-objective-c", "language-perl", "language-php", "language-property-list",
"language-python", "language-ruby-on-rails", "language-ruby", "language-rust-bundled",
"language-sass", "language-shellscript", "language-source", "language-sql",
"language-text", "language-todo", "language-toml", "language-typescript",
"language-xml", "language-yaml", "line-ending-selector", "link", "markdown-preview",
"notifications", "one-dark-syntax", "one-dark-ui", "one-light-syntax", "one-light-ui",
"open-on-github", "package-generator", "settings-view", "solarized-dark-syntax",
"solarized-light-syntax", "status-bar", "styleguide", "tabs", "timecop", "tree-view",
"update-package-dependencies", "welcome", "whitespace", "wrap-guide",
"snippets", "symbols-view", "github", "spell-check"
];

if (bundledPackages.includes(name)) {
return true;
} else {
return false;
}
}

class Timecop {
constructor() {
this.timetable = {};
Expand Down
Loading