Skip to content

Commit 5c3359d

Browse files
metowolfclaude
andcommitted
feat: migrate from Travis CI to GitHub Actions
- Remove .travis.yml configuration - Add GitHub Actions workflows for CI and release - Update CI badge in README to use GitHub Actions - Configure automatic npm publishing on tag push - Add proper tag handling to avoid duplicate CI runs 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent fd53940 commit 5c3359d

12 files changed

Lines changed: 3454 additions & 32 deletions

File tree

.babelrc

Lines changed: 0 additions & 18 deletions
This file was deleted.

.eslintrc.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ module.exports = {
88
"parserOptions": {
99
"ecmaVersion": 2018
1010
},
11+
"globals": {
12+
"APlayer": "readonly",
13+
"fetch": "readonly"
14+
},
1115
"rules": {
1216
"indent": [
1317
"error",

.github/workflows/ci.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
tags-ignore:
7+
- '**'
8+
pull_request:
9+
branches: [ master ]
10+
11+
jobs:
12+
test:
13+
runs-on: ubuntu-latest
14+
15+
strategy:
16+
matrix:
17+
node-version: [18, 20, 22]
18+
19+
steps:
20+
- uses: actions/checkout@v4
21+
22+
- name: Use Node.js ${{ matrix.node-version }}
23+
uses: actions/setup-node@v4
24+
with:
25+
node-version: ${{ matrix.node-version }}
26+
cache: 'npm'
27+
28+
- name: Install dependencies
29+
run: npm ci
30+
31+
- name: Run linter
32+
run: npm run lint
33+
34+
- name: Run tests
35+
run: npm test
36+
37+
- name: Build project
38+
run: npm run build

.github/workflows/release.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
jobs:
9+
release:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- uses: actions/checkout@v4
14+
15+
- name: Use Node.js
16+
uses: actions/setup-node@v4
17+
with:
18+
node-version: '20'
19+
cache: 'npm'
20+
registry-url: 'https://registry.npmjs.org'
21+
22+
- name: Install dependencies
23+
run: npm ci
24+
25+
- name: Run linter
26+
run: npm run lint
27+
28+
- name: Run tests
29+
run: npm test
30+
31+
- name: Build project
32+
run: npm run build
33+
34+
- name: Publish to npm
35+
run: npm publish
36+
env:
37+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
38+
39+
- name: Create GitHub Release
40+
uses: actions/create-release@v1
41+
env:
42+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
43+
with:
44+
tag_name: ${{ github.ref }}
45+
release_name: Release ${{ github.ref }}
46+
draft: false
47+
prerelease: false

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
node_modules
22
yarn.lock
3+
4+
dist/

.travis.yml

Lines changed: 0 additions & 2 deletions
This file was deleted.

CLAUDE.md

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Project Overview
6+
7+
MetingJS is a JavaScript library that creates a custom HTML element `<meting-js>` for embedding music players using the APlayer HTML5 music player. It integrates with various music platforms (Netease, Tencent QQ Music, Xiami, etc.) through the Meting API to fetch music metadata and create beautiful music players in web pages.
8+
9+
## Architecture
10+
11+
### Core Architecture
12+
- **Custom Web Component**: Built as a Web Components custom element (`MetingJSElement` extending `HTMLElement`)
13+
- **Single Source File**: All functionality is contained in `src/Meting.js`
14+
- **External Dependencies**: Relies on APlayer for the actual music player UI and functionality
15+
- **API Integration**: Connects to Meting API endpoints to fetch music metadata from various platforms
16+
17+
### Key Components
18+
- **MetingJSElement Class**: The main custom element that handles:
19+
- Attribute parsing and configuration
20+
- URL pattern matching for auto-detection of music links
21+
- API communication with Meting servers
22+
- APlayer instance creation and management
23+
- Lifecycle management (connect/disconnect callbacks)
24+
25+
### Data Flow
26+
1. HTML `<meting-js>` element with attributes (server, type, id, etc.)
27+
2. Element initialization parses attributes into config and metadata
28+
3. For external music: API call to Meting service to fetch track data
29+
4. For self-hosted: Direct use of provided URL, name, artist, cover
30+
5. APlayer instance created with the processed audio data
31+
6. Music player rendered in the DOM
32+
33+
## Development Commands
34+
35+
### Build System
36+
```bash
37+
# Build the minified distribution file
38+
npm run build
39+
40+
# Clean and rebuild (used by build)
41+
del dist && mkdir dist && rollup -c
42+
```
43+
44+
### Code Quality
45+
```bash
46+
# Lint JavaScript code
47+
npm run lint
48+
49+
# Run ESLint on src directory
50+
eslint src
51+
```
52+
53+
### Testing
54+
```bash
55+
# Run tests (currently just builds the project)
56+
npm test
57+
```
58+
59+
### Release Process
60+
```bash
61+
# Build before publishing to npm
62+
npm run prepublishOnly
63+
```
64+
65+
## Build Configuration
66+
67+
### Rollup Configuration (`rollup.config.js`)
68+
- **Input**: `src/Meting.js`
69+
- **Output**: Single minified IIFE file `dist/Meting.min.js`
70+
- **Plugins**: Version replacement and Terser minification
71+
- **Format**: Immediately Invoked Function Expression (IIFE) for browser compatibility
72+
73+
### ESLint Rules (`.eslintrc.js`)
74+
- **Environment**: Browser, CommonJS, ES6
75+
- **Style**: 2-space indentation, single quotes, no semicolons, Unix line breaks
76+
- **Configuration**: `eslint:recommended` extended
77+
78+
## File Structure
79+
```
80+
/
81+
├── src/
82+
│ └── Meting.js # Main source file with MetingJSElement class
83+
├── dist/ # Built distribution files (generated)
84+
├── package.json # NPM configuration and build scripts
85+
├── rollup.config.js # Rollup build configuration
86+
├── .eslintrc.js # ESLint code style configuration
87+
└── README.md # Project documentation and usage examples
88+
```
89+
90+
## Code Style Guidelines
91+
- Use 2-space indentation
92+
- Single quotes for strings
93+
- No semicolons
94+
- Unix line breaks
95+
- ES6+ features with Rollup/Terser minification for browser distribution
96+
- Console logging allowed (ESLint rule: `"no-console": "off"`)
97+
98+
## Integration Notes
99+
- Requires APlayer library to be loaded before MetingJS
100+
- Uses `window.customElements.define()` to register the custom element
101+
- Supports custom API endpoints via `window.meting_api` global variable
102+
- Implements Web Components lifecycle callbacks for proper cleanup

README.md

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<p align="center">
66
<a href="https://i-meto.com"><img alt="Author" src="https://img.shields.io/badge/Author-METO-blue.svg?style=flat-square"/></a>
77
<a href="https://www.npmjs.com/package/meting"><img alt="Version" src="https://img.shields.io/npm/v/meting.svg?style=flat-square"/></a>
8-
<a href="https://travis-ci.org/metowolf/MetingJS"><img alt="Travis" src="https://img.shields.io/travis/metowolf/MetingJS.svg?style=flat-square"></a>
8+
<a href="https://github.com/metowolf/MetingJS/actions"><img alt="CI" src="https://img.shields.io/github/actions/workflow/status/metowolf/MetingJS/ci.yml?style=flat-square"></a>
99
<img alt="License" src="https://img.shields.io/npm/l/meting.svg?style=flat-square"/>
1010
</p>
1111

@@ -19,8 +19,8 @@ https://github.com/MoePlayer/APlayer
1919
|2.0.x|Latest|[![](https://img.shields.io/badge/APlayer-^1.10.0-green.svg?longCache=true&style=for-the-badge)](https://github.com/MoePlayer/APlayer)|
2020

2121
## CDN
22-
- https://cdn.jsdelivr.net/npm/meting@2.0.1/dist/Meting.min.js
23-
- https://unpkg.com/meting@2.0.1/dist/Meting.min.js
22+
- https://cdn.jsdelivr.net/npm/meting@2/dist/Meting.min.js
23+
- https://unpkg.com/meting@2/dist/Meting.min.js
2424

2525
## Quick Start
2626
```html
@@ -80,6 +80,7 @@ Fixed mode with Lyric text
8080
|server |**require** |music platform: `netease`, `tencent`, `kugou`, `xiami`, `baidu`|
8181
|type |**require** |`song`, `playlist`, `album`, `search`, `artist`|
8282
|auto |options |music link, support: `netease`, `tencent`, `xiami`|
83+
|api |options |custom api url, support self-hosted [Meting API](https://github.com/metowolf/Meting)|
8384
|fixed |`false` |enable fixed mode|
8485
|mini |`false` |enable mini mode|
8586
|autoplay |`false` |audio autoplay|
@@ -100,6 +101,8 @@ Documentation for APlayer can be found at https://aplayer.js.org/#/home?id=optio
100101

101102
MetingJS allow you to use self-hosted API, [more information about Meting](https://github.com/metowolf/Meting).
102103

104+
### Global API Configuration
105+
103106
```html
104107
<script>
105108
var meting_api='http://example.com/api.php?server=:server&type=:type&id=:id&auth=:auth&r=:r';
@@ -108,6 +111,26 @@ var meting_api='http://example.com/api.php?server=:server&type=:type&id=:id&auth
108111
<script src="dist/Meting.min.js"></script>
109112
```
110113

114+
### Per-Element API Configuration
115+
116+
You can also set a custom API for individual `<meting-js>` elements using the `api` attribute:
117+
118+
```html
119+
<meting-js
120+
server="netease"
121+
type="song"
122+
id="28391863"
123+
api="https://your-custom-api.com/meting?server=:server&type=:type&id=:id&r=:r">
124+
</meting-js>
125+
```
126+
127+
### API Priority
128+
129+
The API selection follows this priority order:
130+
1. **Element `api` attribute** (highest priority)
131+
2. **Global `window.meting_api` variable**
132+
3. **Built-in default API** (lowest priority)
133+
111134
## Browser support
112135

113136
Browsers without [native custom element support](https://caniuse.com/#feat=custom-elementsv1) require a [polyfill](https://github.com/webcomponents/custom-elements).

0 commit comments

Comments
 (0)