Skip to content

Commit 00474d0

Browse files
committed
Prepare for npm
1 parent 72dcea8 commit 00474d0

File tree

8 files changed

+226
-7
lines changed

8 files changed

+226
-7
lines changed

.github/workflows/ci.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
concurrency:
10+
group: ${{ github.ref }}
11+
cancel-in-progress: true
12+
13+
jobs:
14+
lint:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- uses: denoland/setup-deno@v2
20+
21+
- run: deno lint
22+
23+
fmt:
24+
runs-on: ubuntu-latest
25+
steps:
26+
- uses: actions/checkout@v4
27+
28+
- uses: denoland/setup-deno@v2
29+
30+
- run: deno fmt --check
31+
32+
check:
33+
runs-on: ubuntu-latest
34+
steps:
35+
- uses: actions/checkout@v4
36+
37+
- uses: denoland/setup-deno@v2
38+
39+
- run: deno check main.ts
40+
41+
publish:
42+
runs-on: ubuntu-latest
43+
steps:
44+
- uses: actions/checkout@v4
45+
46+
- uses: denoland/setup-deno@v2
47+
48+
- run: deno fmt --check
49+
50+
transform:
51+
runs-on: ubuntu-latest
52+
steps:
53+
- uses: actions/checkout@v4
54+
55+
- uses: denoland/setup-deno@v2
56+
57+
- run: deno task transform

.github/workflows/release.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- "*"
7+
8+
permissions:
9+
contents: write
10+
id-token: write
11+
12+
jobs:
13+
publish-jsr:
14+
name: Publish to JSR
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- uses: denoland/setup-deno@v2
20+
21+
- run: deno publish
22+
23+
publish-npm:
24+
name: Publish to npm
25+
runs-on: ubuntu-latest
26+
steps:
27+
- uses: actions/checkout@v4
28+
29+
- uses: denoland/setup-deno@v2
30+
31+
- uses: actions/setup-node@v3
32+
with:
33+
node-version: 24.x
34+
registry-url: https://registry.npmjs.org
35+
36+
- uses: pnpm/action-setup@v4
37+
with:
38+
version: 8
39+
40+
- name: Transform and Publish
41+
run: |
42+
deno task trasnform
43+
cd dist
44+
npm publish --access public
45+
env:
46+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
47+
48+
create-release:
49+
name: Create Release
50+
needs: publish-npm
51+
runs-on: ubuntu-latest
52+
steps:
53+
- uses: actions/checkout@v4
54+
55+
- uses: softprops/action-gh-release@v1
56+
with:
57+
generate_release_notes: true

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/dist/

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# @mtkruto/auth-string
22

3-
Generate an [MTKruto auth string](https://mtkru.to/auth-strings/) just by running:
3+
Generate an [MTKruto auth string](https://mtkru.to/auth-strings/) just by
4+
running:
45

56
```shell
67
deno run -A jsr:@mtkruto/auth-string

_transform.ts

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import { build, emptyDir } from "@deno/dnt";
2+
import denoJson from "./deno.json" with { type: "json" };
3+
4+
const { imports, version } = denoJson;
5+
const mtkrutoSpecifier = imports["@mtkruto/mtkruto"];
6+
const mtkrutoVersion = mtkrutoSpecifier.split("^")[1];
7+
8+
await emptyDir("./dist");
9+
10+
await build({
11+
entryPoints: [
12+
{
13+
kind: "bin",
14+
name: "create-auth-string",
15+
path: "./main.ts",
16+
},
17+
],
18+
outDir: "./dist",
19+
typeCheck: false,
20+
test: false,
21+
scriptModule: false,
22+
compilerOptions: {
23+
target: "ES2023",
24+
lib: ["ESNext", "DOM", "ESNext.AsyncIterable"],
25+
},
26+
shims: {
27+
custom: [
28+
{
29+
package: {
30+
name: "@mtkruto/node",
31+
version: mtkrutoVersion,
32+
},
33+
globalNames: ["Client"],
34+
},
35+
],
36+
},
37+
packageManager: "pnpm",
38+
package: {
39+
name: "@mtkruto/create-auth-string",
40+
version,
41+
license: "MIT",
42+
repository: {
43+
type: "git",
44+
url: "git+https://github.com/MTKruto/create-auth-string.git",
45+
},
46+
},
47+
postBuild() {
48+
Deno.copyFileSync("LICENSE", "dist/LICENSE");
49+
Deno.copyFileSync("README.md", "dist/README.md");
50+
},
51+
});

deno.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,17 @@
22
"name": "@mtkruto/auth-string",
33
"version": "0.0.0",
44
"tasks": {
5-
"dev": "deno run --watch main.ts"
5+
"dev": "deno run --watch main.ts",
6+
"transform": "deno --allow-env --allow-read --allow-run --allow-write=. _transform.ts"
67
},
78
"exports": {
89
".": "./main.ts"
910
},
1011
"imports": {
12+
"@deno/dnt": "jsr:@deno/dnt@^0.42.3",
1113
"@mtkruto/mtkruto": "jsr:@mtkruto/mtkruto@^0.75.1"
12-
}
14+
},
15+
"exclude": [
16+
"/dist/"
17+
]
1318
}

deno.lock

Lines changed: 50 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

main.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,4 +69,5 @@ const authString = await client.exportAuthString();
6969
console.log();
7070
console.log("The auth string for the current session is:");
7171
console.log(authString);
72+
console.log();
7273
await client.disconnect();

0 commit comments

Comments
 (0)