diff --git a/.eslintrc b/.eslintrc index 213b7eff..04e3e07c 100644 --- a/.eslintrc +++ b/.eslintrc @@ -4,15 +4,11 @@ "jsx": true, "sourceType": "module", "ecmaFeatures": { - "jsx": true, - "experimentalObjectRestSpread": true + "jsx": true } }, - "plugins": ["prettier"], + "plugins": ["prettier", "@typescript-eslint"], "settings": { - "react": { - "version": "15.2" - }, "import/resolver": { "node": { "extensions": [".js", ".ts", ".tsx"] @@ -21,27 +17,85 @@ }, "env": { "node": true, - "amd": true, "es6": true, "jest": true }, - "globals": { - "window": true, - "document": true, - "console": true, - "navigator": true, - "alert": true, - "Blob": true, - "fetch": true, - "FileReader": true, - "Element": true, - "AudioNode": true, - "MutationObserver": true, - "Image": true, - "location": true - }, "rules": { "prettier/prettier": "error", - "no-constant-binary-expression": "error" + "no-constant-binary-expression": "error", + "array-callback-return": "error", + "no-template-curly-in-string": "error", + "no-promise-executor-return": "error", + "no-constructor-return": "error", + "no-unsafe-optional-chaining": "error", + "block-scoped-var": "warn", + "camelcase": "error", + "constructor-super": "error", + "dot-notation": "error", + "eqeqeq": ["error", "smart"], + "guard-for-in": "error", + "max-depth": ["warn", 4], + "new-cap": "error", + "no-caller": "error", + "no-const-assign": "error", + "no-debugger": "error", + "no-delete-var": "error", + "no-div-regex": "warn", + "no-dupe-args": "error", + "no-dupe-class-members": "error", + "no-dupe-keys": "error", + "no-duplicate-case": "error", + "no-duplicate-imports": "error", + "no-else-return": "error", + "no-empty-character-class": "error", + "no-eval": "error", + "no-ex-assign": "error", + "no-extend-native": "warn", + "no-extra-boolean-cast": "error", + "no-extra-semi": "error", + "no-fallthrough": "error", + "no-func-assign": "error", + "no-implied-eval": "error", + "no-inner-declarations": "error", + "no-irregular-whitespace": "error", + "no-label-var": "error", + "no-labels": "error", + "no-lone-blocks": "error", + "no-lonely-if": "error", + "no-multi-str": "error", + "no-nested-ternary": "warn", + "no-new-object": "error", + "no-new-symbol": "error", + "no-new-wrappers": "error", + "no-obj-calls": "error", + "no-octal": "error", + "no-octal-escape": "error", + "no-proto": "error", + "no-redeclare": "error", + "no-shadow": "warn", + "no-this-before-super": "error", + "no-throw-literal": "error", + "no-undef-init": "error", + "no-unneeded-ternary": "error", + "no-unreachable": "error", + "no-unused-expressions": "error", + "no-useless-rename": "error", + "no-var": "error", + "no-with": "error", + "prefer-arrow-callback": "warn", + "prefer-const": "error", + "prefer-spread": "error", + "prefer-template": "warn", + "radix": "error", + "use-isnan": "error", + "valid-typeof": "error", + "@typescript-eslint/no-unused-vars": [ + "warn", + { + "argsIgnorePattern": "^_", + "varsIgnorePattern": "^_", + "caughtErrorsIgnorePattern": "^_" + } + ] } } diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 28e61a06..5d6a8a2e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -50,6 +50,9 @@ jobs: runs-on: ubuntu-latest if: github.event_name == 'push' && github.repository == 'captbaritone/webamp' needs: [ci] + permissions: + contents: read + id-token: write # Required for OIDC trusted publishing steps: - uses: actions/checkout@v4 - name: Install pnpm @@ -61,6 +64,8 @@ jobs: node-version: 20.x registry-url: https://registry.npmjs.org/ cache: "pnpm" + - name: Update npm to latest version + run: npm install -g npm@latest - name: Install dependencies run: pnpm install --frozen-lockfile - name: Restore build artifacts @@ -81,31 +86,40 @@ jobs: cd ../winamp-eqf && npm version 0.0.0-next-${RELEASE_COMMIT_SHA::7} --no-git-tag-version env: RELEASE_COMMIT_SHA: ${{ github.sha }} - - name: Build release version + - name: Set version for tagged release if: github.ref_type == 'tag' && startsWith(github.ref_name, 'v') - run: exit 1 # TODO: Script to update version number in webampLazy.tsx + run: | + VERSION=${GITHUB_REF_NAME#v} + echo "Setting version to $VERSION for tagged release" + cd packages/webamp && npm version $VERSION --no-git-tag-version + cd ../ani-cursor && npm version $VERSION --no-git-tag-version + cd ../winamp-eqf && npm version $VERSION --no-git-tag-version + # TODO: Update version number in webampLazy.tsx if needed - name: Publish ani-cursor to npm working-directory: ./packages/ani-cursor - if: github.ref == 'refs/heads/master' || github.ref_type == 'tag' && startsWith(github.ref_name, 'v') + if: github.ref == 'refs/heads/master' || (github.ref_type == 'tag' && startsWith(github.ref_name, 'v')) run: | - npm publish ${TAG} --ignore-scripts - env: - TAG: ${{ github.ref == 'refs/heads/master' && '--tag=next' || ''}} - NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} + if [ "${{ github.ref }}" = "refs/heads/master" ]; then + npm publish --tag=next --ignore-scripts --provenance + else + npm publish --ignore-scripts --provenance + fi - name: Publish winamp-eqf to npm working-directory: ./packages/winamp-eqf - if: github.ref == 'refs/heads/master' || github.ref_type == 'tag' && startsWith(github.ref_name, 'v') + if: github.ref == 'refs/heads/master' || (github.ref_type == 'tag' && startsWith(github.ref_name, 'v')) run: | - npm publish ${TAG} --ignore-scripts - env: - TAG: ${{ github.ref == 'refs/heads/master' && '--tag=next' || ''}} - NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} + if [ "${{ github.ref }}" = "refs/heads/master" ]; then + npm publish --tag=next --ignore-scripts --provenance + else + npm publish --ignore-scripts --provenance + fi - name: Publish webamp to npm working-directory: ./packages/webamp - if: github.ref == 'refs/heads/master' || github.ref_type == 'tag' && startsWith(github.ref_name, 'v') + if: github.ref == 'refs/heads/master' || (github.ref_type == 'tag' && startsWith(github.ref_name, 'v')) # Use pre-built artifacts instead of rebuilding run: | - npm publish ${TAG} --ignore-scripts - env: - TAG: ${{ github.ref == 'refs/heads/master' && '--tag=next' || ''}} - NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} + if [ "${{ github.ref }}" = "refs/heads/master" ]; then + npm publish --tag=next --ignore-scripts --provenance + else + npm publish --ignore-scripts --provenance + fi diff --git a/.gitignore b/.gitignore index 829ecf68..0f1fe805 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ node_modules .vscode +.idea dist # Turborepo cache diff --git a/README.md b/README.md index 42057cff..50aa0ede 100755 --- a/README.md +++ b/README.md @@ -20,9 +20,9 @@ Webamp uses a [monorepo](https://en.wikipedia.org/wiki/Monorepo) approach, so in - [`packages/webamp`](https://github.com/captbaritone/webamp/tree/master/packages/webamp): The [Webamp NPM module](https://www.npmjs.com/package/webamp) - [`packages/webamp/demo`](https://github.com/captbaritone/webamp/tree/master/packages/webamp/demo): The demo site which lives at [webamp.org](https://webamp.org) +- [`packages/webamp-docs`](https://github.com/captbaritone/webamp/tree/master/packages/webamp-docs): The documentation site for Webamp the NPM library which lives at [docs.webamp.org](https://docs.webamp.org) - [`packages/ani-cursor`](https://github.com/captbaritone/webamp/tree/master/packages/ani-cursor): An NPM module for rendering animiated `.ani` cursors as CSS animations - [`packages/skin-database`](https://github.com/captbaritone/webamp/tree/master/packages/skin-database): The server component of https://skins.webamp.org which also runs our [Twitter bot](https://twitter.com/winampskins), and a Discord bot for our community chat -- [`packages/skin-museum-client`](https://github.com/captbaritone/webamp/tree/master/packages/skin-museum-client): The front-end component of https://skins.webamp.org. - [`packages/winamp-eqf`](https://github.com/captbaritone/webamp/tree/master/packages/winamp-eqf): An NPM module for parsing and constructing Winamp equalizer preset files (`.eqf`) - [`packages/webamp-modern`](https://github.com/captbaritone/webamp/tree/master/packages/webamp-modern): A prototype exploring rendering "modern" Winamp skins in the browser - [`examples`](https://github.com/captbaritone/webamp/tree/master/examples): A few examples showing how to use the NPM module diff --git a/deploy.sh b/deploy.sh deleted file mode 100755 index 6cba5378..00000000 --- a/deploy.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash -pnpm --filter ani-cursor build -pnpm --filter webamp build -pnpm --filter webamp build-library -pnpm --filter webamp-modern build -mv packages/webamp-modern/build packages/webamp/dist/demo-site/modern \ No newline at end of file diff --git a/examples/lazy/.gitignore b/examples/lazy/.gitignore new file mode 100644 index 00000000..a547bf36 --- /dev/null +++ b/examples/lazy/.gitignore @@ -0,0 +1,24 @@ +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +pnpm-debug.log* +lerna-debug.log* + +node_modules +dist +dist-ssr +*.local + +# Editor directories and files +.vscode/* +!.vscode/extensions.json +.idea +.DS_Store +*.suo +*.ntvs* +*.njsproj +*.sln +*.sw? diff --git a/examples/lazy/README.md b/examples/lazy/README.md new file mode 100644 index 00000000..2e22adf4 --- /dev/null +++ b/examples/lazy/README.md @@ -0,0 +1,5 @@ +# `webamp/lazy` Example + +Shows how it's possible to use Webamp with lazy loading and TypeScript. Uses [Vite](https://vitejs.dev/) for development and bundling. + +Pay special attention to the versions used in `package.json` since some beta versions are required for this to work. diff --git a/examples/lazy/index.html b/examples/lazy/index.html new file mode 100644 index 00000000..e6da3966 --- /dev/null +++ b/examples/lazy/index.html @@ -0,0 +1,13 @@ + + +
+ + + +