From a386e5cd4f575d2a2ad0be357443b50135bf3233 Mon Sep 17 00:00:00 2001 From: Jersey Date: Mon, 5 Aug 2024 18:03:19 -0400 Subject: [PATCH] remove npm support, fix #5 --- .github/workflows/release.ts | 75 ----------------------------------- .github/workflows/release.yml | 9 ----- README.md | 5 +-- deno.json | 1 - src/api/socket.ts | 3 +- 5 files changed, 4 insertions(+), 89 deletions(-) delete mode 100644 .github/workflows/release.ts diff --git a/.github/workflows/release.ts b/.github/workflows/release.ts deleted file mode 100644 index b832ee7..0000000 --- a/.github/workflows/release.ts +++ /dev/null @@ -1,75 +0,0 @@ -import { copy, walk } from 'jsr:@std/fs@1.0.0-rc.3'; - -/** cleanup */ - -try { - await Deno.remove('dist', { recursive: true }); -} catch { - console.log('no dist folder'); -} finally { - await Deno.mkdir('dist'); -} - -/** install dependencies */ - -await (new Deno.Command('npm', { - args: ['i', '-g', 'esbuild'], -})).output(); - -/** copy files */ - -await copy('src', 'dist/src'); -await copy('README.md', 'dist/README.md'); -await copy('LICENSE', 'dist/LICENSE'); - -/** build javascript */ - -await (new Deno.Command('npx', { - args: [ - 'esbuild', - './src/*', - './src/**/*', - '--outdir=dist/dist', - '--target=esnext', - '--platform=node', - ], -})).output(); - -async function transformFile(path: string) { - let content = await Deno.readTextFile(path); - content = content.replaceAll('.ts', '.js'); - content = content.replace('jsr:@denosaurs/event@2.0.2', 'node:events'); - await Deno.writeTextFile(path, content); -} - -for await (const { isDirectory, isFile, path } of walk('dist/dist')) { - if (isFile) await transformFile(path); - if (isDirectory) { - for await (const { isFile, path: newpath } of walk(path)) { - if (isFile) await transformFile(newpath); - } - } -} - -/** copy metadata */ - -const { version } = JSON.parse(Deno.readTextFileSync('deno.json')); - -const pkg = { - 'name': '@meower-media/api-client', - 'version': version, - 'description': 'A Meower API Client written in Typescript', - 'type': 'module', - 'main': 'dist/index.js', - 'types': 'src/index.ts', - 'repository': { - 'type': 'git', - 'url': 'https://github.com/meower-media-co/api-client', - }, - 'scripts': {}, - 'engines': { - 'node': '>=22', - }, -}; - -Deno.writeTextFileSync('dist/package.json', JSON.stringify(pkg, null, 2)); diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4dbddd6..94dc26d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -14,13 +14,4 @@ jobs: - uses: denoland/setup-deno@v1 with: deno-version: v1.44.4 - - uses: actions/setup-node@v4 - with: - node-version: '20.x' - registry-url: 'https://registry.npmjs.org' - run: deno publish - - run: deno run -A .github/workflows/release.ts - - run: npm publish --provenance --access public - working-directory: dist - env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/README.md b/README.md index f585ab7..0c80f08 100644 --- a/README.md +++ b/README.md @@ -6,8 +6,7 @@ A Meower API Client written in Typescript. ## installation -install and import the package from your favorite source of packages: +get the package from your favorite source of packages: -- @meower-media/api-client from npm -- @meower/api-client from jsr +- @meower/api-client on jsr - esm.sh/jsr/@meower/api-client in browsers diff --git a/deno.json b/deno.json index 28042f8..5c5ad3a 100644 --- a/deno.json +++ b/deno.json @@ -25,7 +25,6 @@ ] }, "tasks": { - "build-npm": "deno run -A .github/workflows/release.ts", "test": "deno test -A" }, "test": { diff --git a/src/api/socket.ts b/src/api/socket.ts index 86b049a..b946f1c 100644 --- a/src/api/socket.ts +++ b/src/api/socket.ts @@ -62,7 +62,8 @@ export class socket extends EventEmitter<{ private socket: WebSocket; private opts: socket_connect_opts; - private constructor(socket: WebSocket, opts: socket_connect_opts) { + /** create a socket instance from a given websocket connection */ + constructor(socket: WebSocket, opts: socket_connect_opts) { super(); this.socket = socket; this.opts = opts;