mirror of https://github.com/miraclx/freyr-js
chore(CI): add super-linter to help lint workspace (#137)
This commit is contained in:
parent
980c9af668
commit
d5a736008c
|
|
@ -19,6 +19,10 @@
|
|||
"plugins": [
|
||||
"prettier"
|
||||
],
|
||||
"ignorePatterns": [
|
||||
"**/*.json",
|
||||
"**/*.json5"
|
||||
],
|
||||
"rules": {
|
||||
"prettier/prettier": [
|
||||
1,
|
||||
|
|
|
|||
|
|
@ -1,4 +1,7 @@
|
|||
custom: ['https://commerce.coinbase.com/checkout/466d703a-fbd7-41c9-8366-9bdd3e240755']
|
||||
---
|
||||
|
||||
custom:
|
||||
- https://commerce.coinbase.com/checkout/466d703a-fbd7-41c9-8366-9bdd3e240755
|
||||
ko_fi: miraclx
|
||||
liberapay: miraclx
|
||||
patreon: miraclx
|
||||
|
|
|
|||
|
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
"threshold": 0,
|
||||
"reporters": [
|
||||
"consoleFull"
|
||||
],
|
||||
"ignore": [
|
||||
"**/.github/workflows/tests.yml"
|
||||
],
|
||||
"absolute": true
|
||||
}
|
||||
|
|
@ -1,6 +1,8 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
RG_SRC="$(which rg)"
|
||||
rg() {
|
||||
printf "rg: pattern: /$*/" > /dev/stderr
|
||||
printf 'rg: pattern: %s' "/$*/" >/dev/stderr
|
||||
if $RG_SRC --fixed-strings --passthru "$@"; then
|
||||
echo " (matched)" >/dev/stderr
|
||||
else
|
||||
|
|
@ -16,7 +18,7 @@ freyr() {
|
|||
i=$($RG_SRC -n '.' .freyr_log | $RG_SRC --fixed-strings '[•] Embedding Metadata' | cut -d':' -f1)
|
||||
if [[ $i ]]; then
|
||||
echo "::group::[$attempts/3] View Download Status"
|
||||
tail +$i .freyr_log
|
||||
tail +"$i" .freyr_log
|
||||
echo "::endgroup::"
|
||||
fi
|
||||
}
|
||||
|
|
@ -36,7 +38,7 @@ exec_retry() {
|
|||
echo "::endgroup::"
|
||||
echo "::group::View Files"
|
||||
STAGE=$(realpath --relative-to=../.. .) && cd ../..
|
||||
tree -sh $STAGE
|
||||
tree -sh "$STAGE"
|
||||
echo "::endgroup::"
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
---
|
||||
name: publish
|
||||
|
||||
on:
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
---
|
||||
name: tests
|
||||
|
||||
on:
|
||||
|
|
@ -238,3 +239,28 @@ jobs:
|
|||
|
||||
- name: Test Docker Build
|
||||
run: docker build -t freyrcli/freyrjs .
|
||||
|
||||
linter:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout Repository
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
# Full git history is needed to get a proper list of changed files within `super-linter`
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Install Dependencies
|
||||
run: npm ci
|
||||
|
||||
- name: Lint Code Base
|
||||
uses: github/super-linter@v4
|
||||
env:
|
||||
VALIDATE_ALL_CODEBASE: false
|
||||
DEFAULT_BRANCH: master
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
LINTER_RULES_PATH: /
|
||||
JAVASCRIPT_ES_CONFIG_FILE: .eslintrc
|
||||
JSCPD_CONFIG_FILE: .github/linters/.jscpd.json
|
||||
VALIDATE_JAVASCRIPT_STANDARD: false
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ LABEL maintainer="Miraculous Owonubi <omiraculous@gmail.com>" \
|
|||
tag="alpine"
|
||||
|
||||
# Install dependencies and clean cache
|
||||
# hadolint ignore=DL3018
|
||||
RUN apk add \
|
||||
--no-cache \
|
||||
git \
|
||||
|
|
@ -26,6 +27,7 @@ RUN mkdir /bins \
|
|||
ENV PATH "/bins:$PATH"
|
||||
|
||||
# Create freyr user and group
|
||||
# hadolint ignore=DL4006
|
||||
RUN addgroup -g 1000 freyr \
|
||||
&& adduser -DG freyr freyr \
|
||||
&& echo freyr:freyr | chpasswd
|
||||
|
|
|
|||
16
README.md
16
README.md
|
|
@ -99,7 +99,9 @@
|
|||
<details>
|
||||
<summary>ffmpeg >= v0.9</summary>
|
||||
|
||||
<!-- textlint-disable -->
|
||||
Download for your individual platforms here <https://ffmpeg.org/download.html>
|
||||
<!-- textlint-enable -->
|
||||
|
||||
- Windows + macOS:
|
||||
- Ensure to extract the `ffmpeg` binary from the compressed file, if it's in one.
|
||||
|
|
@ -209,6 +211,7 @@ Usage: freyr [options] [query...]
|
|||
<details>
|
||||
<summary> <code>freyr get --help</code> </summary>
|
||||
|
||||
<!-- editorconfig-checker-disable -->
|
||||
```console
|
||||
____
|
||||
/ __/_______ __ _______
|
||||
|
|
@ -294,6 +297,7 @@ Info:
|
|||
their respective folders. However, a m3u8 playlist file is generated in
|
||||
the base directory with the name of the playlist that lists the tracks
|
||||
```
|
||||
<!-- editorconfig-checker-enable -->
|
||||
|
||||
</details>
|
||||
|
||||
|
|
@ -302,6 +306,7 @@ Info:
|
|||
<details>
|
||||
<summary> <code>freyr spotify:track:5FNS5Vj69AhRGJWjhrAd01</code> </summary>
|
||||
|
||||
<!-- editorconfig-checker-disable -->
|
||||
```console
|
||||
____
|
||||
/ __/_______ __ _______
|
||||
|
|
@ -353,6 +358,7 @@ Checking directory permissions...[done]
|
|||
[•] Output bitrate: 320k
|
||||
===============================
|
||||
```
|
||||
<!-- editorconfig-checker-enable -->
|
||||
|
||||
</details>
|
||||
|
||||
|
|
@ -361,6 +367,7 @@ Checking directory permissions...[done]
|
|||
<details>
|
||||
<summary> <code> freyr https://music.apple.com/us/album/im-sorry-im-not-sorry-ep/1491795443 </code> </summary>
|
||||
|
||||
<!-- editorconfig-checker-disable -->
|
||||
```console
|
||||
____
|
||||
/ __/_______ __ _______
|
||||
|
|
@ -436,6 +443,7 @@ Checking directory permissions...[done]
|
|||
[•] Output bitrate: 320k
|
||||
===============================
|
||||
```
|
||||
<!-- editorconfig-checker-enable -->
|
||||
|
||||
</details>
|
||||
|
||||
|
|
@ -444,6 +452,7 @@ Checking directory permissions...[done]
|
|||
<details>
|
||||
<summary> <code> freyr https://www.deezer.com/us/artist/14808825 </code> </summary>
|
||||
|
||||
<!-- editorconfig-checker-disable -->
|
||||
```console
|
||||
____
|
||||
/ __/_______ __ _______
|
||||
|
|
@ -503,6 +512,7 @@ Checking directory permissions...[done]
|
|||
[•] Output bitrate: 320k
|
||||
===============================
|
||||
```
|
||||
<!-- editorconfig-checker-enable -->
|
||||
|
||||
</details>
|
||||
|
||||
|
|
@ -752,7 +762,7 @@ An invalid `refreshToken`, when specified, would fallback to requesting account
|
|||
- `storefront`: \<string\>
|
||||
- `developerToken`: \<string\>
|
||||
|
||||
This library already includes a pre-defined developer token that should work at will. This developer token is the default token, extracted off the Apple Music website. While this developer token could expire over time, we'll try to update with the most recent developer token as time goes on.
|
||||
This library already includes a predefined developer token that should work at will. This developer token is the default token, extracted off the Apple Music site. While this developer token could expire over time, we'll try to update with the most recent developer token as time goes on.
|
||||
|
||||
To create a custom developer token, please refer to the Apple Music documentation on this topic.
|
||||
|
||||
|
|
@ -870,7 +880,7 @@ To preview filter rules specification, use the `filter` subcommand.
|
|||
| [Spotify](https://github.com/miraclx/freyr-js/blob/master/src/services/spotify.js) | ✔ | ✔ | ✔ | ✔ | `spotify:` |
|
||||
| [Apple Music](https://github.com/miraclx/freyr-js/blob/master/src/services/apple_music.js) | ✔ | ✔ | ✔ | ✔ | `apple_music:` |
|
||||
| [Deezer](https://github.com/miraclx/freyr-js/blob/master/src/services/deezer.js) | ✔ | ✔ | ✔ | ✔ | `deezer:` |
|
||||
| Youtube Music (See [#6](https://github.com/miraclx/freyr-js/issues/6)) | ✗ | ✗ | ✗ | ✗ | ✗ |
|
||||
| YouTube Music (See [#6](https://github.com/miraclx/freyr-js/issues/6)) | ✗ | ✗ | ✗ | ✗ | ✗ |
|
||||
| Tidal (See [#33](https://github.com/miraclx/freyr-js/issues/33)) | ✗ | ✗ | ✗ | ✗ | ✗ |
|
||||
|
||||
### Metadata Availability
|
||||
|
|
@ -1082,7 +1092,7 @@ Optionally, you can use these interesting flags to customize the experience.
|
|||
|
||||
The freyr source would be available in the `/freyr` directory within the container along with a globally registered command `freyr` for calling the script.
|
||||
|
||||
For more information and documentation about docker, please refer to its official website:
|
||||
For more information and documentation about docker, please refer to its official site:
|
||||
|
||||
- <https://www.docker.com/>
|
||||
- <https://docs.docker.com/>
|
||||
|
|
|
|||
|
|
@ -51,7 +51,6 @@
|
|||
},
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@babel/eslint-parser": "^7.17.0",
|
||||
"@miraclx/apple-music": "^0.4.0",
|
||||
"async": "^3.2.0",
|
||||
"axios": "^0.26.0",
|
||||
|
|
@ -90,6 +89,7 @@
|
|||
"yt-search": "^2.10.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/eslint-parser": "^7.17.0",
|
||||
"eslint": "8.9.0",
|
||||
"eslint-plugin-prettier": "4.0.0",
|
||||
"prettier": "2.5.1"
|
||||
|
|
|
|||
|
|
@ -70,12 +70,14 @@ function initTest() {
|
|||
console.log(parseBlock.parsed);
|
||||
values.forEach(value => console.log(`[${value.toString().padStart(2)}] ${parseBlock.check(value)}`));
|
||||
}
|
||||
// jscpd:ignore-start
|
||||
function test_time(spec, values) {
|
||||
console.log('%j', spec);
|
||||
const parseBlock = parseRange.time(spec);
|
||||
console.log(parseBlock.parsed);
|
||||
values.forEach(value => console.log(`[${value.toString().padStart(2)}] ${parseBlock.check(value)}`));
|
||||
}
|
||||
// jscpd:ignore-end
|
||||
|
||||
test_num(' ', [1, 2, 3]);
|
||||
test_num('7 ', [6, 7, 8]);
|
||||
|
|
|
|||
|
|
@ -290,10 +290,10 @@ class AppleMusic {
|
|||
(await this.getArtist(uris)).albums.map(album => `apple_music:album:${album}`),
|
||||
100,
|
||||
store,
|
||||
async (items, storefront) =>
|
||||
Promise.mapSeries(
|
||||
(await this.#store.core.albums.get(`?ids=${items.map(item => item.refID).join(',')}`, {storefront})).data,
|
||||
album => this.wrapAlbumData(album),
|
||||
(items, storefront) =>
|
||||
this.getAlbum(
|
||||
items.map(item => item.uri),
|
||||
storefront,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,6 +20,18 @@ class YouTubeSearchError extends Error {
|
|||
}
|
||||
}
|
||||
|
||||
function _getSearchArgs(artists, track, duration) {
|
||||
if (typeof track === 'number') [track, duration] = [, track];
|
||||
if (!Array.isArray(artists))
|
||||
if (track && artists) artists = [artists];
|
||||
else [artists, track] = [[], artists || track];
|
||||
if (typeof track !== 'string') throw new Error('<track> must be a valid string');
|
||||
if (artists.some(artist => typeof artist !== 'string'))
|
||||
throw new Error('<artist>, if defined must be a valid array of strings');
|
||||
if (duration && typeof duration !== 'number') throw new Error('<duration>, if defined must be a valid number');
|
||||
return [artists, track, duration];
|
||||
}
|
||||
|
||||
/**
|
||||
* @typedef {(
|
||||
* {
|
||||
|
|
@ -276,14 +288,7 @@ class YouTubeMusic {
|
|||
* @returns {YouTubeSearchResult} YouTubeMusicSearchResults
|
||||
*/
|
||||
async search(artists, track, duration) {
|
||||
if (typeof track === 'number') [track, duration] = [, track];
|
||||
if (!Array.isArray(artists))
|
||||
if (track && artists) artists = [artists];
|
||||
else [artists, track] = [[], artists || track];
|
||||
if (typeof track !== 'string') throw new Error('<track> must be a valid string');
|
||||
if (artists.some(artist => typeof artist !== 'string'))
|
||||
throw new Error('<artist>, if defined must be a valid array of strings');
|
||||
if (duration && typeof duration !== 'number') throw new Error('<duration>, if defined must be a valid number');
|
||||
[artists, track, duration] = _getSearchArgs(artists, track, duration);
|
||||
|
||||
const results = await this.#search({query: [track, ...artists].join(' ')});
|
||||
const strippedMeta = textUtils.stripText([...track.split(' '), ...artists]);
|
||||
|
|
@ -384,14 +389,7 @@ class YouTube {
|
|||
* @returns {YouTubeSearchResult} YouTubeSearchResults
|
||||
*/
|
||||
async search(artists, track, duration) {
|
||||
if (typeof track === 'number') [track, duration] = [, track];
|
||||
if (!Array.isArray(artists))
|
||||
if (track && artists) artists = [artists];
|
||||
else [artists, track] = [[], artists || track];
|
||||
if (typeof track !== 'string') throw new Error('<track> must be a valid string');
|
||||
if (artists.some(artist => typeof artist !== 'string'))
|
||||
throw new Error('<artist>, if defined must be a valid array of strings');
|
||||
if (duration && typeof duration !== 'number') throw new Error('<duration>, if defined must be a valid number');
|
||||
[artists, track, duration] = _getSearchArgs(artists, track, duration);
|
||||
|
||||
const strippedArtists = textUtils.stripText(artists);
|
||||
const strippedMeta = [...textUtils.stripText(track.split(' ')), ...strippedArtists];
|
||||
|
|
|
|||
|
|
@ -182,8 +182,7 @@ class StackLogger {
|
|||
* @param {...any} msgs Messages to write out
|
||||
*/
|
||||
error(...msgs) {
|
||||
this._write(this.getText(this.#store.indent, msgs).concat('\n'), process.stderr, true);
|
||||
return this.#store.autoTick ? this.tick(this.#store.indentSize) : this;
|
||||
return this.warn(...msgs);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in New Issue