odesli.js 1.3.9 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +97 -85
- package/lib/index.d.ts +114 -17
- package/lib/index.js +941 -201
- package/lib/index.mjs +6 -3
- package/lib/metrics.js +1 -1
- package/lib/rate-limiter.js +12 -8
- package/package.json +24 -5
- package/.eslintrc.js +0 -33
- package/.gitattributes +0 -1
- package/.github/dependabot.yml +0 -56
- package/.github/workflows/ci.yml +0 -94
- package/.github/workflows/dependabot-auto-merge.yml +0 -137
- package/.github/workflows/publish-github-packages.yml +0 -46
- package/.github/workflows/publish-npm.yml +0 -133
- package/.prettierignore +0 -31
- package/.prettierrc +0 -11
- package/API_IMPROVEMENTS.md +0 -318
- package/CHANGELOG.md +0 -256
- package/CODE_OF_CONDUCT.md +0 -125
- package/CONTRIBUTING.md +0 -104
- package/RELEASE_NOTES_1.1.0.md +0 -84
- package/SECURITY.md +0 -112
- package/examples/README.md +0 -442
- package/examples/advanced-features-example.js +0 -205
- package/examples/advanced-usage.js +0 -247
- package/examples/basic-usage.js +0 -100
- package/examples/cache-test.js +0 -119
- package/examples/rate-limiter-strategies.js +0 -83
- package/examples/test-apple-music-extraction.js +0 -60
- package/examples/user-agent-example.js +0 -46
- package/jest.config.js +0 -14
- package/jsdoc.json +0 -24
- package/scripts/version-bump.js +0 -41
- package/tests/advanced-features.test.js +0 -423
- package/tests/odesli.test.js +0 -742
- package/tests/setup.js +0 -22
- package/tsconfig.json +0 -21
package/lib/index.mjs
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
-
import cjs from './index.js'
|
|
2
|
-
|
|
3
|
-
export
|
|
1
|
+
import cjs from './index.js'
|
|
2
|
+
|
|
3
|
+
export const Odesli = cjs
|
|
4
|
+
export const OdesliError = cjs.OdesliError
|
|
5
|
+
export const SUNSET_DOCS_URL = cjs.SUNSET_DOCS_URL
|
|
6
|
+
export default cjs
|
package/lib/metrics.js
CHANGED
|
@@ -96,7 +96,7 @@ class MetricsCollector {
|
|
|
96
96
|
}
|
|
97
97
|
|
|
98
98
|
// Record performance metrics
|
|
99
|
-
if (request.responseTime) {
|
|
99
|
+
if (typeof request.responseTime === 'number') {
|
|
100
100
|
this.metrics.performance.responseTimes.push({
|
|
101
101
|
timestamp: startTime,
|
|
102
102
|
responseTime: request.responseTime
|
package/lib/rate-limiter.js
CHANGED
|
@@ -30,19 +30,23 @@ class RateLimiter {
|
|
|
30
30
|
while (true) {
|
|
31
31
|
const now = Date.now()
|
|
32
32
|
const timePassed = now - this.lastRefill
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
33
|
+
const windowsElapsed = Math.floor(timePassed / this.windowMs)
|
|
34
|
+
const tokensToAdd = windowsElapsed * this.maxRequests
|
|
35
|
+
|
|
36
|
+
// Only advance lastRefill when tokens are actually refilled. Resetting it
|
|
37
|
+
// on every check with tokensToAdd === 0 permanently stalls the bucket.
|
|
38
|
+
if (tokensToAdd > 0) {
|
|
39
|
+
this.tokens = Math.min(this.maxRequests, this.tokens + tokensToAdd)
|
|
40
|
+
this.lastRefill += windowsElapsed * this.windowMs
|
|
41
|
+
}
|
|
42
|
+
|
|
38
43
|
if (this.tokens >= 1) {
|
|
39
44
|
this.tokens--
|
|
40
45
|
return true
|
|
41
46
|
}
|
|
42
|
-
|
|
43
|
-
// Calculate wait time
|
|
47
|
+
|
|
44
48
|
const waitTime = this.windowMs - (timePassed % this.windowMs)
|
|
45
|
-
await new Promise(resolve => setTimeout(resolve, waitTime))
|
|
49
|
+
await new Promise(resolve => setTimeout(resolve, Math.max(waitTime, 1)))
|
|
46
50
|
}
|
|
47
51
|
}
|
|
48
52
|
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "odesli.js",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "Node.js
|
|
3
|
+
"version": "2.0.1",
|
|
4
|
+
"description": "Node.js/TypeScript client for the Songlink/Odesli API (requires allowlisted API key; public API retired July 2026)",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
|
-
"module": "lib/index.
|
|
6
|
+
"module": "lib/index.mjs",
|
|
7
7
|
"types": "lib/index.d.ts",
|
|
8
8
|
"exports": {
|
|
9
9
|
".": {
|
|
10
10
|
"types": "./lib/index.d.ts",
|
|
11
|
-
"import": "./lib/index.
|
|
11
|
+
"import": "./lib/index.mjs",
|
|
12
12
|
"require": "./lib/index.js"
|
|
13
13
|
},
|
|
14
14
|
"./rate-limiter": {
|
|
@@ -27,6 +27,11 @@
|
|
|
27
27
|
"engines": {
|
|
28
28
|
"node": ">=14.0.0"
|
|
29
29
|
},
|
|
30
|
+
"files": [
|
|
31
|
+
"lib/",
|
|
32
|
+
"README.md",
|
|
33
|
+
"LICENSE"
|
|
34
|
+
],
|
|
30
35
|
"scripts": {
|
|
31
36
|
"build": "tsc",
|
|
32
37
|
"format": "prettier --write .",
|
|
@@ -36,6 +41,7 @@
|
|
|
36
41
|
"test": "jest",
|
|
37
42
|
"test:watch": "jest --watch",
|
|
38
43
|
"test:coverage": "jest --coverage",
|
|
44
|
+
"test:live": "jest tests/live-api.test.js",
|
|
39
45
|
"docs": "jsdoc lib/index.js -d docs",
|
|
40
46
|
"audit": "npm audit",
|
|
41
47
|
"audit:fix": "npm audit fix",
|
|
@@ -91,7 +97,20 @@
|
|
|
91
97
|
"typescript": "^5.9.3"
|
|
92
98
|
},
|
|
93
99
|
"overrides": {
|
|
94
|
-
"js-yaml": "^4.1.1"
|
|
100
|
+
"js-yaml": "^4.1.1",
|
|
101
|
+
"@jest/reporters": {
|
|
102
|
+
"glob": "^14.0.6"
|
|
103
|
+
},
|
|
104
|
+
"jest-config": {
|
|
105
|
+
"glob": "^14.0.6"
|
|
106
|
+
},
|
|
107
|
+
"jest-runtime": {
|
|
108
|
+
"glob": "^14.0.6"
|
|
109
|
+
},
|
|
110
|
+
"test-exclude": {
|
|
111
|
+
"glob": "^14.0.6",
|
|
112
|
+
"minimatch": "^11.0.9"
|
|
113
|
+
}
|
|
95
114
|
},
|
|
96
115
|
"homepage": "https://github.com/MattrAus/odesli.js#readme"
|
|
97
116
|
}
|
package/.eslintrc.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
env: {
|
|
3
|
-
node: true,
|
|
4
|
-
es2021: true,
|
|
5
|
-
jest: true,
|
|
6
|
-
},
|
|
7
|
-
extends: ['standard', 'plugin:jest/recommended', 'prettier'],
|
|
8
|
-
parserOptions: {
|
|
9
|
-
ecmaVersion: 'latest',
|
|
10
|
-
sourceType: 'module',
|
|
11
|
-
},
|
|
12
|
-
plugins: ['jest', 'prettier'],
|
|
13
|
-
rules: {
|
|
14
|
-
'jest/no-focused-tests': 'error',
|
|
15
|
-
'jest/no-identical-title': 'error',
|
|
16
|
-
'jest/prefer-to-have-length': 'warn',
|
|
17
|
-
'jest/valid-expect': 'error',
|
|
18
|
-
'no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
|
|
19
|
-
'prefer-const': 'error',
|
|
20
|
-
'no-var': 'error',
|
|
21
|
-
'prettier/prettier': 'error',
|
|
22
|
-
'comma-dangle': 'off',
|
|
23
|
-
semi: 'off',
|
|
24
|
-
},
|
|
25
|
-
overrides: [
|
|
26
|
-
{
|
|
27
|
-
files: ['tests/**/*.js'],
|
|
28
|
-
env: {
|
|
29
|
-
jest: true,
|
|
30
|
-
},
|
|
31
|
-
},
|
|
32
|
-
],
|
|
33
|
-
};
|
package/.gitattributes
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
* text=auto eol=lf
|
package/.github/dependabot.yml
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
version: 2
|
|
2
|
-
updates:
|
|
3
|
-
# Enable version updates for npm
|
|
4
|
-
- package-ecosystem: 'npm'
|
|
5
|
-
directory: '/'
|
|
6
|
-
schedule:
|
|
7
|
-
interval: 'weekly'
|
|
8
|
-
day: 'monday'
|
|
9
|
-
time: '09:00'
|
|
10
|
-
timezone: 'America/New_York'
|
|
11
|
-
|
|
12
|
-
# Group minor and patch updates together
|
|
13
|
-
groups:
|
|
14
|
-
minor-and-patch:
|
|
15
|
-
patterns:
|
|
16
|
-
- '*'
|
|
17
|
-
update-types:
|
|
18
|
-
- 'minor'
|
|
19
|
-
- 'patch'
|
|
20
|
-
|
|
21
|
-
# Commit message format
|
|
22
|
-
commit-message:
|
|
23
|
-
prefix: 'chore'
|
|
24
|
-
prefix-development: 'chore'
|
|
25
|
-
include: 'scope'
|
|
26
|
-
|
|
27
|
-
# PR settings
|
|
28
|
-
open-pull-requests-limit: 10
|
|
29
|
-
reviewers:
|
|
30
|
-
- 'MattrAus'
|
|
31
|
-
assignees:
|
|
32
|
-
- 'MattrAus'
|
|
33
|
-
labels:
|
|
34
|
-
- 'dependencies'
|
|
35
|
-
- 'automated'
|
|
36
|
-
|
|
37
|
-
# Ignore certain updates
|
|
38
|
-
ignore:
|
|
39
|
-
# Ignore major version updates for critical dependencies
|
|
40
|
-
- dependency-name: 'typescript'
|
|
41
|
-
update-types: ['version-update:semver-major']
|
|
42
|
-
- dependency-name: 'jest'
|
|
43
|
-
update-types: ['version-update:semver-major']
|
|
44
|
-
- dependency-name: 'eslint'
|
|
45
|
-
update-types: ['version-update:semver-major']
|
|
46
|
-
# Ignore major updates that break compatibility
|
|
47
|
-
- dependency-name: 'eslint-plugin-promise'
|
|
48
|
-
update-types: ['version-update:semver-major']
|
|
49
|
-
- dependency-name: 'node-fetch'
|
|
50
|
-
update-types: ['version-update:semver-major']
|
|
51
|
-
|
|
52
|
-
# Rebase strategy
|
|
53
|
-
rebase-strategy: 'auto'
|
|
54
|
-
|
|
55
|
-
# Versioning strategy
|
|
56
|
-
versioning-strategy: 'auto'
|
package/.github/workflows/ci.yml
DELETED
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
name: CI
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
push:
|
|
5
|
-
branches: [master]
|
|
6
|
-
pull_request:
|
|
7
|
-
branches: [master]
|
|
8
|
-
|
|
9
|
-
permissions:
|
|
10
|
-
contents: read
|
|
11
|
-
|
|
12
|
-
jobs:
|
|
13
|
-
test:
|
|
14
|
-
runs-on: ubuntu-latest
|
|
15
|
-
|
|
16
|
-
strategy:
|
|
17
|
-
matrix:
|
|
18
|
-
node-version: [18.x, 20.x, 22.x]
|
|
19
|
-
|
|
20
|
-
steps:
|
|
21
|
-
- name: Checkout code
|
|
22
|
-
uses: actions/checkout@v4
|
|
23
|
-
|
|
24
|
-
- name: Use Node.js ${{ matrix.node-version }}
|
|
25
|
-
uses: actions/setup-node@v4
|
|
26
|
-
with:
|
|
27
|
-
node-version: ${{ matrix.node-version }}
|
|
28
|
-
cache: 'npm'
|
|
29
|
-
|
|
30
|
-
- name: Install dependencies
|
|
31
|
-
run: npm ci
|
|
32
|
-
|
|
33
|
-
- name: Run linting
|
|
34
|
-
run: npm run lint
|
|
35
|
-
|
|
36
|
-
- name: Check formatting
|
|
37
|
-
run: npm run format:check
|
|
38
|
-
|
|
39
|
-
- name: Run tests
|
|
40
|
-
run: npm test
|
|
41
|
-
|
|
42
|
-
- name: Run tests with coverage
|
|
43
|
-
run: npm run test:coverage
|
|
44
|
-
|
|
45
|
-
- name: Upload coverage to Codecov
|
|
46
|
-
uses: codecov/codecov-action@v3
|
|
47
|
-
with:
|
|
48
|
-
file: ./coverage/lcov.info
|
|
49
|
-
flags: unittests
|
|
50
|
-
name: codecov-umbrella
|
|
51
|
-
fail_ci_if_error: false
|
|
52
|
-
|
|
53
|
-
security:
|
|
54
|
-
runs-on: ubuntu-latest
|
|
55
|
-
needs: test
|
|
56
|
-
|
|
57
|
-
steps:
|
|
58
|
-
- name: Checkout code
|
|
59
|
-
uses: actions/checkout@v4
|
|
60
|
-
|
|
61
|
-
- name: Use Node.js
|
|
62
|
-
uses: actions/setup-node@v4
|
|
63
|
-
with:
|
|
64
|
-
node-version: '20.x'
|
|
65
|
-
cache: 'npm'
|
|
66
|
-
|
|
67
|
-
- name: Install dependencies
|
|
68
|
-
run: npm ci
|
|
69
|
-
|
|
70
|
-
- name: Run security audit
|
|
71
|
-
run: npm audit --audit-level=moderate
|
|
72
|
-
|
|
73
|
-
build:
|
|
74
|
-
runs-on: ubuntu-latest
|
|
75
|
-
needs: test
|
|
76
|
-
|
|
77
|
-
steps:
|
|
78
|
-
- name: Checkout code
|
|
79
|
-
uses: actions/checkout@v4
|
|
80
|
-
|
|
81
|
-
- name: Use Node.js
|
|
82
|
-
uses: actions/setup-node@v4
|
|
83
|
-
with:
|
|
84
|
-
node-version: '20.x'
|
|
85
|
-
cache: 'npm'
|
|
86
|
-
|
|
87
|
-
- name: Install dependencies
|
|
88
|
-
run: npm ci
|
|
89
|
-
|
|
90
|
-
- name: Build project
|
|
91
|
-
run: npm run build
|
|
92
|
-
|
|
93
|
-
- name: Verify TypeScript compilation
|
|
94
|
-
run: npx tsc --noEmit
|
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
name: Dependabot Auto Merge
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
pull_request:
|
|
5
|
-
types: [opened, synchronize, reopened, ready_for_review]
|
|
6
|
-
branches: [master]
|
|
7
|
-
|
|
8
|
-
permissions:
|
|
9
|
-
contents: write
|
|
10
|
-
pull-requests: write
|
|
11
|
-
packages: write
|
|
12
|
-
|
|
13
|
-
jobs:
|
|
14
|
-
dependabot-auto-merge:
|
|
15
|
-
runs-on: ubuntu-latest
|
|
16
|
-
if: github.actor == 'dependabot[bot]'
|
|
17
|
-
|
|
18
|
-
steps:
|
|
19
|
-
- name: Checkout code
|
|
20
|
-
uses: actions/checkout@v4
|
|
21
|
-
with:
|
|
22
|
-
ref: ${{ github.head_ref }}
|
|
23
|
-
token: ${{ secrets.GITHUB_TOKEN }}
|
|
24
|
-
|
|
25
|
-
- name: Use Node.js
|
|
26
|
-
uses: actions/setup-node@v4
|
|
27
|
-
with:
|
|
28
|
-
node-version: '20.x'
|
|
29
|
-
cache: 'npm'
|
|
30
|
-
|
|
31
|
-
- name: Install dependencies
|
|
32
|
-
run: npm ci
|
|
33
|
-
|
|
34
|
-
- name: Run linting
|
|
35
|
-
run: npm run lint
|
|
36
|
-
|
|
37
|
-
- name: Check formatting
|
|
38
|
-
run: npm run format:check
|
|
39
|
-
|
|
40
|
-
- name: Run tests
|
|
41
|
-
run: npm test
|
|
42
|
-
|
|
43
|
-
- name: Run security audit
|
|
44
|
-
run: npm audit --audit-level=moderate
|
|
45
|
-
|
|
46
|
-
- name: Build project
|
|
47
|
-
run: npm run build
|
|
48
|
-
|
|
49
|
-
- name: Auto-approve PR
|
|
50
|
-
uses: actions/github-script@v7
|
|
51
|
-
with:
|
|
52
|
-
script: |
|
|
53
|
-
github.rest.pulls.createReview({
|
|
54
|
-
owner: context.repo.owner,
|
|
55
|
-
repo: context.repo.repo,
|
|
56
|
-
pull_number: context.issue.number,
|
|
57
|
-
event: 'APPROVE',
|
|
58
|
-
body: '✅ Automated approval: All tests passed successfully!'
|
|
59
|
-
})
|
|
60
|
-
|
|
61
|
-
- name: Comment on PR
|
|
62
|
-
uses: actions/github-script@v7
|
|
63
|
-
with:
|
|
64
|
-
script: |
|
|
65
|
-
github.rest.issues.createComment({
|
|
66
|
-
owner: context.repo.owner,
|
|
67
|
-
repo: context.repo.repo,
|
|
68
|
-
issue_number: context.issue.number,
|
|
69
|
-
body: '✅ All tests passed! This PR is ready for merge.'
|
|
70
|
-
})
|
|
71
|
-
|
|
72
|
-
# Auto-release after Dependabot PR is merged
|
|
73
|
-
auto-release:
|
|
74
|
-
runs-on: ubuntu-latest
|
|
75
|
-
needs: dependabot-auto-merge
|
|
76
|
-
if: github.actor == 'dependabot[bot]' && github.event.pull_request.merged == true
|
|
77
|
-
|
|
78
|
-
steps:
|
|
79
|
-
- name: Checkout code
|
|
80
|
-
uses: actions/checkout@v4
|
|
81
|
-
with:
|
|
82
|
-
token: ${{ secrets.GITHUB_TOKEN }}
|
|
83
|
-
|
|
84
|
-
- name: Use Node.js
|
|
85
|
-
uses: actions/setup-node@v4
|
|
86
|
-
with:
|
|
87
|
-
node-version: '20.x'
|
|
88
|
-
cache: 'npm'
|
|
89
|
-
|
|
90
|
-
- name: Install dependencies
|
|
91
|
-
run: npm ci
|
|
92
|
-
|
|
93
|
-
- name: Bump version
|
|
94
|
-
id: version
|
|
95
|
-
run: |
|
|
96
|
-
npm run version:patch
|
|
97
|
-
VERSION=$(node -p "require('./package.json').version")
|
|
98
|
-
echo "version=$VERSION" >> $GITHUB_OUTPUT
|
|
99
|
-
|
|
100
|
-
- name: Create git tag
|
|
101
|
-
run: |
|
|
102
|
-
VERSION=$(node -p "require('./package.json').version")
|
|
103
|
-
git config --local user.email "action@github.com"
|
|
104
|
-
git config --local user.name "GitHub Action"
|
|
105
|
-
git add package.json
|
|
106
|
-
git commit -m "chore: bump version to $VERSION"
|
|
107
|
-
git tag "v$VERSION"
|
|
108
|
-
git push origin HEAD:master --tags
|
|
109
|
-
|
|
110
|
-
- name: Create Release
|
|
111
|
-
uses: actions/create-release@v1
|
|
112
|
-
env:
|
|
113
|
-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
114
|
-
with:
|
|
115
|
-
tag_name: v${{ steps.version.outputs.version }}
|
|
116
|
-
release_name: Release v${{ steps.version.outputs.version }}
|
|
117
|
-
body: |
|
|
118
|
-
## 🔄 Dependabot Update
|
|
119
|
-
|
|
120
|
-
This release includes dependency updates from Dependabot.
|
|
121
|
-
|
|
122
|
-
### Changes
|
|
123
|
-
- Updated dependencies to latest versions
|
|
124
|
-
- All tests passing ✅
|
|
125
|
-
- Security audit passed ✅
|
|
126
|
-
|
|
127
|
-
### Updated Dependencies
|
|
128
|
-
${{ github.event.pull_request.body }}
|
|
129
|
-
draft: false
|
|
130
|
-
prerelease: false
|
|
131
|
-
|
|
132
|
-
- name: Publish to NPM
|
|
133
|
-
run: |
|
|
134
|
-
npm pkg set name="odesli.js"
|
|
135
|
-
npm publish --access public
|
|
136
|
-
env:
|
|
137
|
-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
name: Publish to GitHub Packages
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
release:
|
|
5
|
-
types: [published]
|
|
6
|
-
workflow_dispatch:
|
|
7
|
-
|
|
8
|
-
jobs:
|
|
9
|
-
publish-github:
|
|
10
|
-
runs-on: ubuntu-latest
|
|
11
|
-
permissions:
|
|
12
|
-
contents: read
|
|
13
|
-
packages: write
|
|
14
|
-
|
|
15
|
-
steps:
|
|
16
|
-
- name: Checkout code
|
|
17
|
-
uses: actions/checkout@v4
|
|
18
|
-
|
|
19
|
-
- name: Setup Node.js
|
|
20
|
-
uses: actions/setup-node@v4
|
|
21
|
-
with:
|
|
22
|
-
node-version: '20.x'
|
|
23
|
-
cache: 'npm'
|
|
24
|
-
registry-url: 'https://npm.pkg.github.com'
|
|
25
|
-
|
|
26
|
-
- name: Install dependencies
|
|
27
|
-
run: npm ci
|
|
28
|
-
|
|
29
|
-
- name: Run tests
|
|
30
|
-
run: npm test
|
|
31
|
-
|
|
32
|
-
- name: Build project
|
|
33
|
-
run: npm run build
|
|
34
|
-
|
|
35
|
-
- name: Setup GitHub Packages Registry
|
|
36
|
-
run: |
|
|
37
|
-
echo "@mattraus:registry=https://npm.pkg.github.com" >> .npmrc
|
|
38
|
-
echo "//npm.pkg.github.com/:_authToken=${{ secrets.GITHUB_TOKEN }}" >> .npmrc
|
|
39
|
-
|
|
40
|
-
- name: Update package name
|
|
41
|
-
run: npm pkg set name="@mattraus/odesli.js"
|
|
42
|
-
|
|
43
|
-
- name: Publish to GitHub Packages
|
|
44
|
-
run: npm publish
|
|
45
|
-
env:
|
|
46
|
-
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
name: Publish to NPM
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
release:
|
|
5
|
-
types: [published]
|
|
6
|
-
workflow_dispatch:
|
|
7
|
-
|
|
8
|
-
jobs:
|
|
9
|
-
publish-npm:
|
|
10
|
-
runs-on: ubuntu-latest
|
|
11
|
-
permissions:
|
|
12
|
-
contents: read
|
|
13
|
-
id-token: write
|
|
14
|
-
|
|
15
|
-
steps:
|
|
16
|
-
- name: Checkout code
|
|
17
|
-
uses: actions/checkout@v4
|
|
18
|
-
with:
|
|
19
|
-
ref: master
|
|
20
|
-
|
|
21
|
-
- name: Use Node.js
|
|
22
|
-
uses: actions/setup-node@v4
|
|
23
|
-
with:
|
|
24
|
-
node-version: '20.x'
|
|
25
|
-
cache: 'npm'
|
|
26
|
-
registry-url: 'https://registry.npmjs.org'
|
|
27
|
-
# OIDC is automatically used when id-token: write permission is set
|
|
28
|
-
|
|
29
|
-
# #region agent log
|
|
30
|
-
- name: Debug - Check npm version (Trusted Publishing requires npm 11.5.1+)
|
|
31
|
-
run: |
|
|
32
|
-
echo "HYPOTHESIS_G: Checking npm version for Trusted Publishing compatibility"
|
|
33
|
-
npm --version
|
|
34
|
-
echo "Required: npm >= 11.5.1 for Trusted Publishing"
|
|
35
|
-
NPM_VERSION=$(npm --version)
|
|
36
|
-
if [ "$(printf '%s\n' "11.5.1" "$NPM_VERSION" | sort -V | head -n1)" != "11.5.1" ]; then
|
|
37
|
-
echo "npm version is too old, upgrading to latest..."
|
|
38
|
-
npm install -g npm@latest
|
|
39
|
-
npm --version
|
|
40
|
-
else
|
|
41
|
-
echo "npm version is compatible"
|
|
42
|
-
fi
|
|
43
|
-
# #endregion
|
|
44
|
-
# #region agent log
|
|
45
|
-
- name: Debug - Check OIDC token availability and workflow context
|
|
46
|
-
run: |
|
|
47
|
-
echo "HYPOTHESIS_A_B_C: Checking OIDC and workflow context"
|
|
48
|
-
echo "Repository: ${{ github.repository }}"
|
|
49
|
-
echo "Expected: MattrAus/odesli.js"
|
|
50
|
-
echo "Workflow ref: ${{ github.workflow_ref }}"
|
|
51
|
-
echo "Workflow file path: .github/workflows/publish-npm.yml"
|
|
52
|
-
echo "Workflow name: ${{ github.workflow }}"
|
|
53
|
-
if [ -n "$ACTIONS_ID_TOKEN_REQUEST_TOKEN" ]; then
|
|
54
|
-
echo "OIDC token request token: SET (length: ${#ACTIONS_ID_TOKEN_REQUEST_TOKEN})"
|
|
55
|
-
else
|
|
56
|
-
echo "OIDC token request token: NOT SET"
|
|
57
|
-
fi
|
|
58
|
-
if [ -n "$ACTIONS_ID_TOKEN_REQUEST_URL" ]; then
|
|
59
|
-
echo "OIDC token request URL: SET"
|
|
60
|
-
else
|
|
61
|
-
echo "OIDC token request URL: NOT SET"
|
|
62
|
-
fi
|
|
63
|
-
# #endregion
|
|
64
|
-
- name: Install dependencies
|
|
65
|
-
run: npm ci
|
|
66
|
-
|
|
67
|
-
- name: Run tests
|
|
68
|
-
run: npm test
|
|
69
|
-
|
|
70
|
-
- name: Run linting
|
|
71
|
-
run: npm run lint
|
|
72
|
-
|
|
73
|
-
- name: Check formatting
|
|
74
|
-
run: npm run format:check
|
|
75
|
-
|
|
76
|
-
- name: Build project
|
|
77
|
-
run: npm run build
|
|
78
|
-
|
|
79
|
-
- name: Update package name for npm
|
|
80
|
-
run: npm pkg set name="odesli.js"
|
|
81
|
-
|
|
82
|
-
# #region agent log
|
|
83
|
-
- name: Debug - Check npm configuration before publish
|
|
84
|
-
run: |
|
|
85
|
-
echo "HYPOTHESIS_D_F: Checking npm configuration and authentication"
|
|
86
|
-
echo "NPM_CONFIG_REGISTRY: ${NPM_CONFIG_REGISTRY:-not set}"
|
|
87
|
-
echo "NPM_CONFIG_USERCONFIG: ${NPM_CONFIG_USERCONFIG:-not set}"
|
|
88
|
-
if [ -f .npmrc ]; then
|
|
89
|
-
echo ".npmrc file exists in repo:"
|
|
90
|
-
cat .npmrc | sed 's/\(.*auth.*\)/REDACTED/'
|
|
91
|
-
else
|
|
92
|
-
echo ".npmrc file does NOT exist in repo"
|
|
93
|
-
fi
|
|
94
|
-
if [ -f "${NPM_CONFIG_USERCONFIG:-/home/runner/work/_temp/.npmrc}" ]; then
|
|
95
|
-
echo ".npmrc file from setup-node exists:"
|
|
96
|
-
cat "${NPM_CONFIG_USERCONFIG:-/home/runner/work/_temp/.npmrc}" | sed 's/\(.*auth.*\)/REDACTED/'
|
|
97
|
-
else
|
|
98
|
-
echo ".npmrc file from setup-node does NOT exist"
|
|
99
|
-
fi
|
|
100
|
-
echo "NODE_AUTH_TOKEN length: ${#NODE_AUTH_TOKEN}"
|
|
101
|
-
echo "Package name: $(node -p "require('./package.json').name")"
|
|
102
|
-
echo "Package version: $(node -p "require('./package.json').version")"
|
|
103
|
-
echo "Checking npm config:"
|
|
104
|
-
npm config list 2>&1 | grep -E "(registry|auth|token)" || echo "No auth config found"
|
|
105
|
-
npm whoami 2>&1 || echo "npm whoami failed (expected if not authenticated)"
|
|
106
|
-
# #endregion
|
|
107
|
-
# #region agent log
|
|
108
|
-
- name: Debug - Verify Trusted Publisher match
|
|
109
|
-
run: |
|
|
110
|
-
echo "HYPOTHESIS_A: Verifying Trusted Publisher configuration match"
|
|
111
|
-
echo "GitHub Repository: ${{ github.repository }}"
|
|
112
|
-
echo "GitHub Workflow: ${{ github.workflow }}"
|
|
113
|
-
echo "GitHub Workflow Ref: ${{ github.workflow_ref }}"
|
|
114
|
-
echo "Expected npm config:"
|
|
115
|
-
echo " Repository: MattrAus/odesli.js"
|
|
116
|
-
echo " Workflow file: publish-npm.yml (or .github/workflows/publish-npm.yml)"
|
|
117
|
-
echo "Actual GitHub values:"
|
|
118
|
-
echo " Repository: ${{ github.repository }}"
|
|
119
|
-
echo " Workflow file path: .github/workflows/publish-npm.yml"
|
|
120
|
-
echo " Workflow name: ${{ github.workflow }}"
|
|
121
|
-
# #endregion
|
|
122
|
-
- name: Publish to NPM
|
|
123
|
-
run: |
|
|
124
|
-
echo "HYPOTHESIS_E_FIX: Attempting npm publish with --provenance flag"
|
|
125
|
-
echo "Final npm config check:"
|
|
126
|
-
npm config get registry
|
|
127
|
-
npm config get //registry.npmjs.org/:_authToken 2>&1 | head -c 20 || echo "No auth token in config"
|
|
128
|
-
npm publish --provenance --access public 2>&1 || {
|
|
129
|
-
EXIT_CODE=$?
|
|
130
|
-
echo "npm publish failed with exit code: $EXIT_CODE"
|
|
131
|
-
echo "Error details above"
|
|
132
|
-
exit $EXIT_CODE
|
|
133
|
-
}
|
package/.prettierignore
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
# Dependencies
|
|
2
|
-
node_modules/
|
|
3
|
-
|
|
4
|
-
# Build outputs
|
|
5
|
-
lib/
|
|
6
|
-
dist/
|
|
7
|
-
build/
|
|
8
|
-
|
|
9
|
-
# Coverage reports
|
|
10
|
-
coverage/
|
|
11
|
-
|
|
12
|
-
# Logs
|
|
13
|
-
*.log
|
|
14
|
-
|
|
15
|
-
# Environment files
|
|
16
|
-
.env*
|
|
17
|
-
|
|
18
|
-
# Package files
|
|
19
|
-
package-lock.json
|
|
20
|
-
yarn.lock
|
|
21
|
-
|
|
22
|
-
# Git
|
|
23
|
-
.git/
|
|
24
|
-
|
|
25
|
-
# IDE
|
|
26
|
-
.vscode/
|
|
27
|
-
.idea/
|
|
28
|
-
|
|
29
|
-
# OS
|
|
30
|
-
.DS_Store
|
|
31
|
-
Thumbs.db
|