fix: packaging
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
Aravinth Manivannan 2023-09-19 05:24:43 +05:30
parent fa1d7427ab
commit f5fe8a90e5
Signed by: realaravinth
GPG key ID: F8F50389936984FF
3 changed files with 20 additions and 3 deletions

View file

@ -4,7 +4,6 @@
"version": "0.1.0-alpha-1", "version": "0.1.0-alpha-1",
"license": "AGPL-3.0-or-later", "license": "AGPL-3.0-or-later",
"type": "module", "type": "module",
"web": "dist/web.js",
"module": "dist/web.js", "module": "dist/web.js",
"main": "dist/web.js", "main": "dist/web.js",
"keywords": [ "keywords": [
@ -13,7 +12,8 @@
], ],
"homepage": "https://forgejo-notifications-core.docs.forgeflux.org/", "homepage": "https://forgejo-notifications-core.docs.forgeflux.org/",
"files": [ "files": [
"dist/", "dist/web.js",
"dist/web.js.map",
"package.json", "package.json",
"pnpm-lock.yaml" "pnpm-lock.yaml"
], ],
@ -37,7 +37,7 @@
}, },
"name": "forgejo-notifications-core", "name": "forgejo-notifications-core",
"scripts": { "scripts": {
"build": "spack", "build": "swc ./src/index.ts -o ./dist/index.js && spack --config ./spack.config.cjs",
"lint": "prettier --write ./src/*", "lint": "prettier --write ./src/*",
"test": "jest", "test": "jest",
"doc": "typedoc ./src/index.ts" "doc": "typedoc ./src/index.ts"

8
spack.config.cjs Normal file
View file

@ -0,0 +1,8 @@
module.exports = {
entry: {
web: __dirname + "/src/index.ts",
},
output: {
path: __dirname + "/dist",
},
};

View file

@ -57,6 +57,7 @@ class Forgejo {
this.url.pathname = "/api/v1/user"; this.url.pathname = "/api/v1/user";
let res = await fetch(this.url, { let res = await fetch(this.url, {
method: "GET", method: "GET",
credentials: "omit",
headers: this.getTokenAuthHeader(), headers: this.getTokenAuthHeader(),
}); });
return await res.json(); return await res.json();
@ -67,8 +68,11 @@ class Forgejo {
*/ */
async getNotifications(): Promise<Array<Notification>> { async getNotifications(): Promise<Array<Notification>> {
this.url.pathname = "/api/v1/notifications"; this.url.pathname = "/api/v1/notifications";
this.url.pathname = "/api/v1/notifications";
console.log(this.url);
let res = await fetch(this.url, { let res = await fetch(this.url, {
method: "GET", method: "GET",
credentials: "omit",
headers: this.getTokenAuthHeader(), headers: this.getTokenAuthHeader(),
}); });
@ -81,6 +85,7 @@ class Forgejo {
this.url.pathname = "/api/v1/notifications/new"; this.url.pathname = "/api/v1/notifications/new";
let res = await fetch(this.url, { let res = await fetch(this.url, {
method: "GET", method: "GET",
credentials: "omit",
headers: this.getTokenAuthHeader(), headers: this.getTokenAuthHeader(),
}); });
@ -96,6 +101,7 @@ class Forgejo {
this.url.pathname = `/api/v1/notifications/threads/${id}`; this.url.pathname = `/api/v1/notifications/threads/${id}`;
let res = await fetch(this.url, { let res = await fetch(this.url, {
method: "GET", method: "GET",
credentials: "omit",
headers: this.getTokenAuthHeader(), headers: this.getTokenAuthHeader(),
}); });
return await res.json(); return await res.json();
@ -179,6 +185,7 @@ class Forgejo {
this.url.pathname = `/api/v1/repos/${owner}/${repo}/issues/${id}`; this.url.pathname = `/api/v1/repos/${owner}/${repo}/issues/${id}`;
let res = await fetch(this.url, { let res = await fetch(this.url, {
method: "GET", method: "GET",
credentials: "omit",
headers: this.getTokenAuthHeader(), headers: this.getTokenAuthHeader(),
}); });
let issue = await res.json(); let issue = await res.json();
@ -211,6 +218,7 @@ class Forgejo {
this.url.pathname = `/api/v1/repos/${issue.repository.owner}/${issue.repository.name}/issues/${issue.number}/comments`; this.url.pathname = `/api/v1/repos/${issue.repository.owner}/${issue.repository.name}/issues/${issue.number}/comments`;
let res = await fetch(this.url, { let res = await fetch(this.url, {
method: "GET", method: "GET",
credentials: "omit",
headers: this.getTokenAuthHeader(), headers: this.getTokenAuthHeader(),
}); });
let c: Array<Comment> = await res.json(); let c: Array<Comment> = await res.json();
@ -235,3 +243,4 @@ class Forgejo {
} }
export default Forgejo; export default Forgejo;
//export { Notification, Issue, Repository, Comment, User };