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

Mono-manifest #256

Closed
wants to merge 60 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
0599159
🚧 Initial support for mono-manifest themes (no stars yet)
theRealPadster Jun 25, 2022
8fb8e5f
Merge branch 'main' into feat/mono-manifest
theRealPadster Jun 25, 2022
711695d
Fix some linting
theRealPadster Jun 25, 2022
f2595ae
🚧 Initial mono-manifest support for custom apps
theRealPadster Jun 25, 2022
1f1f8a2
Fix some type errors
theRealPadster Jun 25, 2022
e39df53
Naming
theRealPadster Jun 25, 2022
256254f
Fix type errors
theRealPadster Jun 25, 2022
74ed0d7
More type fixes
theRealPadster Jun 25, 2022
b72291c
Merge branch 'main' into feat/mono-manifest
theRealPadster Jun 25, 2022
ea7b22a
Change to use ES2021
CharlieS1103 Jun 25, 2022
73498af
Begin implementing github topic fetch option
CharlieS1103 Jun 25, 2022
316ba74
Resolve linting errors
CharlieS1103 Jun 25, 2022
41827f7
Finish implementing optionality for themes
CharlieS1103 Jun 25, 2022
f5c90e8
Change card type
CharlieS1103 Jun 25, 2022
96d65df
Add logic to check if enabled before calling loadPageRecursive()
CharlieS1103 Jun 25, 2022
d8565c6
Fill in documentation links
CharlieS1103 Jun 25, 2022
f0a6acd
Remove unnecessary conditional
CharlieS1103 Jun 25, 2022
86e5c7a
Remove unnecessary imports
CharlieS1103 Jun 25, 2022
be885d4
Patch multimanifest support
CharlieS1103 Jun 25, 2022
451e2f2
🔥 ♻️ Remove some duplicated code and do some cleanup
theRealPadster Jun 26, 2022
f0573d1
♻️ Use `buildThemeCardData` for topic and mono-manifest flow
theRealPadster Jun 26, 2022
7cb545a
♻️ Code deduplication for `buildAppCardData`
theRealPadster Jun 26, 2022
7cc8bae
♻️ Consolidate getMonoManifest functions
theRealPadster Jun 26, 2022
cf09e54
Add `buildExtensionCardData`
theRealPadster Jun 26, 2022
c186d61
🚧 Add extension mono-manifest handling (not implemented)
theRealPadster Jun 26, 2022
aa04101
Normalize the marketplace controls colors
CharlieS1103 Jun 28, 2022
f0ce736
refactor(FetchRemotes): use lookups
kyrie25 Jun 28, 2022
798e6d4
feat(Settings): add annotation
kyrie25 Jun 28, 2022
c225f80
feat(Grid): allow switching fetch method for Apps
kyrie25 Jun 28, 2022
1538241
refactor(Grid): merge duplicate functions
kyrie25 Jun 28, 2022
337bb25
Make order of extension/theme/app functions consistent with tabs
theRealPadster Jun 28, 2022
531bc66
♻️ 🚧 Refactor `fetchMonoManifest` temporarily to be more efficient
theRealPadster Jun 28, 2022
3f5fb6f
Use same spice-text var for dropdown hover
theRealPadster Jun 29, 2022
a284f93
Add arrow-parens rule, Rearrange extensions/themes/apps to line up wi…
theRealPadster Jun 29, 2022
4de06a4
Forgot the rule
theRealPadster Jun 29, 2022
0c9e261
Make really long function params more readable, arrow-parens
theRealPadster Jun 29, 2022
3869c57
Add classes for some inline css
theRealPadster Jun 29, 2022
ed14b2a
Missed an arrow-parens
theRealPadster Jun 29, 2022
d0f4dc1
♻️ Move icons to single file
theRealPadster Jun 29, 2022
e34d368
feat: use synchronous fetch method & assert type
kyrie25 Jun 29, 2022
a9ead9a
chore: remove unnecessary type assertion
kyrie25 Jun 29, 2022
6791dd9
fix: wait until item is fetched completely
kyrie25 Jun 29, 2022
97d882d
🔀 Merge branch 'main' into feat/mono-manifest
theRealPadster Jun 30, 2022
80bb41b
Merge branch 'main' into feat/mono-manifest
theRealPadster Jun 30, 2022
6ab8049
Merge branch 'main' into feat/mono-manifest
theRealPadster Jun 30, 2022
ba6659f
For some reason it didn't put this in
theRealPadster Jun 30, 2022
cf6eb53
🔧 Add EOF ESLint rule
theRealPadster Jun 30, 2022
a70a362
Revert "For some reason it didn't put this in"
theRealPadster Jun 30, 2022
0fed49c
Merge branch 'main' into feat/mono-manifest
kyrie25 Jul 2, 2022
fe45603
Merge branch 'main' into feat/mono-manifest
kyrie25 Jul 4, 2022
4631df1
Merge branch 'main' into feat/mono-manifest
kyrie25 Jul 11, 2022
7188a54
refactor(utils)
kyrie25 Jul 11, 2022
15a07d6
Merge branch 'main' into feat/mono-manifest
kyrie25 Jul 14, 2022
494c322
Merge branch 'main' into feat/mono-manifest
kyrie25 Aug 4, 2022
4bddf46
chore: remove duplicate identifier
kyrie25 Aug 4, 2022
71035c2
Merge branch 'main' into feat/mono-manifest
kyrie25 Aug 4, 2022
f2d5bda
🔀 Merge branch 'main' into feat/mono-manifest
theRealPadster Nov 21, 2022
bffac96
Fix some types/merge stuff
theRealPadster Nov 21, 2022
5c2e628
Linting
theRealPadster Nov 21, 2022
e403d60
🚧 Start fetch-stars script
theRealPadster Dec 3, 2022
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
40 changes: 40 additions & 0 deletions .github/scripts/fetch-stars.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import fetch from "node-fetch";

const MANIFEST_URL = "https://raw.githubusercontent.com/spicetify/spicetify-themes/generated-manifest/manifest.json";

/**
* Get user, repo, and branch from a GitHub raw URL
* @param {string} url Github Raw URL
* @returns { { user: string, repo: string } }
*/
const getParamsFromGithubRaw = (url) => {
const regex_result = url.match(/https:\/\/github\.com\/(?<user>[^/]+)\/(?<repo>[^/]+)/);
// e.g. https://github.com/nimsandu/spicetify-bloom

const obj = {
user: regex_result ? regex_result.groups?.user : null,
repo: regex_result ? regex_result.groups?.repo : null,
};

return obj;
};

const fetchStars = async () => {
const manifest = await fetch(MANIFEST_URL).then((res) => res.json());

const stars = await Promise.all(manifest.map(async (theme) => {
if (!theme.repository) return 'Missing user or repo';

const { user, repo } = getParamsFromGithubRaw(theme.repository);
console.log(`Fetching stars for ${user}/${repo}`);

const url = `https://api.github.com/repos/${user}/${repo}`;
const response = await fetch(url).then((res) => res.json());
return response.stargazers_count;
}));

return stars;
};

const stars = await fetchStars();
console.log(stars);
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ All types of contributions are encouraged and valued. See the [Table of Contents

## I Have a Question

> If you want to ask a question, we assume that you have read the available [Documentation]().
> If you want to ask a question, we assume that you have read the available [Documentation](https://github.com/spicetify/spicetify-marketplace/wiki).

Before you ask a question, it is best to search for existing [Issues](https://github.com/spicetify/spicetify-marketplaceissues) that might help you. In case you have found a suitable issue and still need clarification, you can write your question in this issue. It is also advisable to search the internet for answers first.

Expand Down Expand Up @@ -68,7 +68,7 @@ Depending on how large the project is, you may want to outsource the questioning
A good bug report shouldn't leave others needing to chase you up for more information. Therefore, we ask you to investigate carefully, collect information and describe the issue in detail in your report. Please complete the following steps in advance to help us fix any potential bug as fast as possible.

- Make sure that you are using the latest version.
- Determine if your bug is really a bug and not an error on your side e.g. using incompatible environment components/versions (Make sure that you have read the [documentation](). If you are looking for support, you might want to check [this section](#i-have-a-question)).
- Determine if your bug is really a bug and not an error on your side e.g. using incompatible environment components/versions (Make sure that you have read the [documentation](https://github.com/spicetify/spicetify-marketplace/wiki). If you are looking for support, you might want to check [this section](#i-have-a-question)).
- To see if other users have experienced (and potentially already solved) the same issue you are having, check if there is not already a bug report existing for your bug or error in the [bug tracker](https://github.com/spicetify/spicetify-marketplaceissues?q=label%3Abug).
- Also make sure to search the internet (including Stack Overflow) to see if users outside of the GitHub community have discussed the issue.
- Collect information about the bug:
Expand Down Expand Up @@ -108,7 +108,7 @@ This section guides you through submitting an enhancement suggestion for Spiceti
#### Before Submitting an Enhancement

- Make sure that you are using the latest version.
- Read the [documentation]() carefully and find out if the functionality is already covered, maybe by an individual configuration.
- Read the [documentation](https://github.com/spicetify/spicetify-marketplace/wiki) carefully and find out if the functionality is already covered, maybe by an individual configuration.
- Perform a [search](https://github.com/spicetify/spicetify-marketplaceissues) to see if the enhancement has already been suggested. If it has, add a comment to the existing issue instead of opening a new one.
- Find out whether your idea fits with the scope and aims of the project. It's up to you to make a strong case to convince the project's developers of the merits of this feature. Keep in mind that we want features that will be useful to the majority of our users and not just a small subset. If you're just targeting a minority of users, consider writing an add-on/plugin library.

Expand Down
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,8 @@
"packageManager": "[email protected]",
"devDependencies": {
"husky": "^8.0.1"
},
"dependencies": {
"node-fetch": "^3.3.0"
}
}
6 changes: 6 additions & 0 deletions packages/marketplace/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,13 @@ module.exports = {
"comma-spacing": [
"error", { "before": false, "after": true },
],
"arrow-parens": [
"error", "always",
],
"no-trailing-spaces": "error",
"eol-last": [
"error", "always",
],
"keyword-spacing": "error",
"no-multiple-empty-lines": [
"error", { "max": 1 },
Expand Down
5 changes: 3 additions & 2 deletions packages/marketplace/src/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class App extends React.Component<{
throw new Error("Could not parse marketplace tabs key");
} else if (tabs.length === 0) {
throw new Error("Empty marketplace tabs key");
} else if (tabs.filter(tab => !tab).length > 0) {
} else if (tabs.filter((tab) => !tab).length > 0) {
throw new Error("Falsey marketplace tabs key");
}
} catch {
Expand Down Expand Up @@ -120,6 +120,7 @@ class App extends React.Component<{
// of stargazers, and the subscribers_count isn't returned in the main API call we make
// https://github.community/t/bug-watchers-count-is-the-duplicate-of-stargazers-count/140865/4
followers: JSON.parse(getLocalStorageDataFromKey("marketplace:followers", false)),
githubTopics: JSON.parse(getLocalStorageDataFromKey("marketplace:githubTopics", false)),
},
tabs,
activeTab: getLocalStorageDataFromKey(LOCALSTORAGE_KEYS.activeTab, tabs[0]),
Expand All @@ -130,7 +131,7 @@ class App extends React.Component<{
},
};

if (!this.CONFIG.activeTab || !this.CONFIG.tabs.filter(tab => tab.name === this.CONFIG.activeTab).length) {
if (!this.CONFIG.activeTab || !this.CONFIG.tabs.filter((tab) => tab.name === this.CONFIG.activeTab).length) {
this.CONFIG.activeTab = this.CONFIG.tabs[0].name;
}
}
Expand Down
6 changes: 2 additions & 4 deletions packages/marketplace/src/components/Card/Card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ import {
injectUserCSS,
generateKey,
} from "../../logic/Utils";
import TrashIcon from "../Icons/TrashIcon";
import DownloadIcon from "../Icons/DownloadIcon";
import GitHubIcon from "../Icons/GitHubIcon";
import { DownloadIcon, GitHubIcon, TrashIcon } from "../Icons";
import { openModal } from "../../logic/LaunchModals";
import AuthorsDiv from "./AuthorsDiv";
import TagsDiv from "./TagsDiv";
Expand Down Expand Up @@ -97,7 +95,7 @@ class Card extends React.Component<CardProps, {
const url = `https://api.github.com/repos/${this.props.item.user}/${this.props.item.repo}`;
// TODO: This implementation could probably be improved.
// It might have issues when quickly switching between tabs.
const repoData = await fetch(url).then(res => res.json());
const repoData = await fetch(url).then((res) => res.json());
const { stargazers_count, pushed_at } = repoData;

const stateUpdate = { stars: 0, lastUpdated: undefined };
Expand Down
Loading