-
Notifications
You must be signed in to change notification settings - Fork 6
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
Extension Features and Implementation #1
Comments
I only have feedback on this: "Feature 3: Download ZIP link on GitHub Repository" |
Right. |
Regarding "Feature 1: CDN link on GitHub repository", what are your thoughts on Proposal 2 and 3? |
Feature 1 - Use Feature 2 - Get name from the URL and the rest from npm API (https://registry.npmjs.org/jquery). Feature 3 - The contents of npm package often differs from the repo so keep this feature. |
We can do this.
Great idea.
Right, npm packages provide build files as well. |
Then it must be clearer I think. First user question will be what's the difference between this zip and the other zip by GitHub |
It will be mentioned in the readme but I don't think any UI changes are necessary. It simply downloads files that are available at the CDN. |
@MartinKolarik I have few doubts in resolving default file name: Doubt 1:
|
|
Yes, we can use our API. |
I think we have to update our approach. While testing this pull request against jQuery repository, I found that its version in package file is New Approach: And to optimise these API calls, we can memoize the APIs result. |
Yes, you are right. I forgot to mention it in my previous comment but it's the same problem as with changed |
Sure. Let's get the version from API itself. |
Is there anything missing from what we discussed or can I test and re-review everything now? |
Everything is done. |
@MartinKolarik I was thinking of making this extension cross-browser compatible using WebExtension API. What do you think? |
👍 I was thinking that could be done at some point. If it's easy enough, you can definitely do it right away. |
Awesome! |
I've used web-ext and webextension-polyfill to make a FF/Chrome/Chromium based extension fairly easily, if that's any help. |
Thank you @frehner , using same libraries. 👍 |
@MartinKolarik Currently nothing happens when a user clicks on extension icon from toolbar, I was thinking of opening jsDelivr website on a new tab instead. |
Maybe a small pretty tooltip explaining what the plugin does? Otherwise it would be too confusing |
True. |
@dutiyesh Hey, how are things going? Do you have time to maintain this addon? |
@jimaek I'm doing fine. And yes, I have time to maintain this addon. |
Great, can you add the missing features, re-test and finalize it please? |
Sure, I will do it. |
@jimaek How is this design for tooltip? |
Looks good but needs an explanation. Maybe something like "Get jsDelivr CDN URLs on npmjs and github project pages." |
Right, statement can be updated. |
This is a discussion on jsDelivr Extension features and how we can implement it.
Features
Implementation
Feature 1: CDN link on GitHub repository
To form a project's CDN link (
https://cdn.jsdelivr.net/npm/package@version/file
) we need 3 parameters:package
version
file
Proposal 1: Get
package
name from repository URLGitHub repository URL has below patterns:
/:user/:repo
/:org/:repo
We can assume that a repository's package name would be same as repository's name and evaluate it from URL.
Example:
For jQuery's GitHub repository with URL -
https://github.com/jquery/jquery
; its package name would bejquery
.Problems
This proposal fails for scoped package names and when package name differ from their repository name.
Example 1:
For Slick Carousel's GitHub repository with URL -
https://github.com/kenwheeler/slick
; we would evaluate its package name asslick
.But its name defined in
package.json
file isslick-carousel
.Example 2:
For a scoped package like -
@sindresorhus/class-names
; we won't be able to correctly evaluate its package name from its GitHub URL -https://github.com/sindresorhus/class-names
Conclusion: Not a good approach.
Proposal 2: Get
package
name by fetching repository'spackage.json
file from jsDelivr CDNWe can fetch repository's
package.json
file from CDN with URL -https://cdn.jsdelivr.net/gh/:user/:repo@:version/package.json
, for which we will requireuser
,repo
andversion
. We can getuser
andrepo
from URL, but notversion
parameter, so we will have to call an API to getversion
and then fetchpackage.json
file.The steps will be:
Step 1: Get
version
fromv1/package/gh/:user/:repo
APIStep 2: Fetch
package.json
fileStep 3: Read
name
,version
and defaultfile
name frompackage.json
fileStep 4: Generate a CDN URL
And if a user wants a specific version of project from GitHub's Release tags, we can skip Step 1 and get
version
from its GitHub URL.Example:
For Slick Carousel version 1.5.8, its GitHub URL is -
https://github.com/kenwheeler/slick/tree/1.5.8
.From this URL we can evaluate
version
parameter to be1.5.8
.Proposal 3: Get
package
name by fetching repository'spackage.json
file from GitHub repositoryWe can fetch a RAW
package.json
file from GitHub repository itself.The steps will be:
Step 1: Fetch RAW
package.json
file fromhttps://raw.githubusercontent.com/:user/:repo/master/package.json
fileStep 2: Read
name
,version
and defaultfile
name frompackage.json
fileStep 3: Generate a CDN URL
And if a user wants a specific version of project from GitHub's Release tags, we can get
version
from its GitHub URL and fetch itspackage.json
file.Example:
For Slick Carousel version 1.5.8, its GitHub URL is -
https://github.com/kenwheeler/slick/tree/1.5.8
.And its RAW
package.json
file URL will be -https://raw.githubusercontent.com/kenwheeler/slick/1.5.8/package.json
.Question: Proposal 2 and 3 provides us with default file name as well. So should we use it and rename it with minified file name convention or call jsDelivr API (
/package/npm/:name@:version/:structure?
) to get the default file name?Note: Both Proposal 2 and 3 fails for repositories that use Lerna tool. Popular repositories using Lerna: React, Babel.
We have to think for an approach to handle such scenario.
Feature 2: CDN link on NPM
To form a project's CDN link (
https://cdn.jsdelivr.net/npm/package@version/file
) we need 3 parameters:package
version
file
Proposal: Get required parameters from NPM URL and HTML page
We can get
package
name from URL andversion
from sidebar under "version" heading.And then get default file name from jsDelivr API -
/package/npm/:name@:version/:structure?
.Feature 3: Download ZIP link on GitHub Repository
To generate a project's download link (
https://registry.npmjs.org/package/-/package-version.tgz
) we need 2 parameters:package
version
We can re-use
package
andversion
parameters which we got while generating CDN link from Feature 1.And then generate a download link.
The difference between this link and GitHub's own download link is that it will not have Git instance.
The text was updated successfully, but these errors were encountered: