Skip to content

Commit

Permalink
add build and publish scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
Armin Jazi committed Jun 11, 2024
1 parent f369e2f commit 0b26c00
Show file tree
Hide file tree
Showing 6 changed files with 97 additions and 44 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/npm-publish-github-packages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Node.js Package

on:
release:
types: [created]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 20
- run: npm ci
- run: npm run test:unit
- run: npm run build
- run: npm run build:types
- uses: actions/upload-artifact@v3
with:
name: build-artifacts
path: dist

publish-gpr:
needs: build
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 20
registry-url: https://npm.pkg.github.com/
scope: '@openreplyde'
- run: npm ci
- uses: actions/download-artifact@v3
with:
name: build-artifacts
path: dist
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
41 changes: 0 additions & 41 deletions .gitlab-ci.yml

This file was deleted.

16 changes: 14 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
{
"name": "@openreply/query-cache",
"private": true,
"version": "0.0.0",
"version": "1.0.0-alpha.1",
"type": "module",
"files": [
"dist"
],
"main": "./dist/index.umd.js",
"types": "./dist/index.d.ts",
"module": "./dist/index.js",
"exports": {
".": {
"import": "./dist/index.js",
"require": "./dist/index.umd.cjs"
}
},
"scripts": {
"dev:app": "vite --host",
"build": "tsc && vite build",
"build:types": "tsc --emitDeclarationOnly --declaration --declarationMap --project ./tsconfig.lib.json",
"preview": "vite preview",
"lint": "eslint --ext .js,.ts",
"test:unit": "vitest",
Expand Down
5 changes: 5 additions & 0 deletions src/core/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
import GlobalSyncEvent, { GlobalSyncEventType } from "~/core/global-sync-event";
import useQuery from "~/core/use-query";
import { DefaultCache } from "~/core/default-cache";
import { DefaultCacheSync } from "~/core/default-cache-sync";

declare global {
interface WindowEventMap {
[GlobalSyncEventType]: GlobalSyncEvent<unknown>;
}
}

export { GlobalSyncEvent, GlobalSyncEventType, useQuery, DefaultCache, DefaultCacheSync };

25 changes: 25 additions & 0 deletions tsconfig.lib.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"compilerOptions": {
"allowJs": true,
"target": "ESNext",
"useDefineForClassFields": true,
"module": "ESNext",
"moduleResolution": "Node",
"noImplicitAny": true,
"declaration": true,
"strict": true,
"jsx": "preserve",
"sourceMap": true,
"resolveJsonModule": true,
"isolatedModules": true,
"esModuleInterop": true,
"lib": ["ESNext", "DOM"],
"skipLibCheck": true,
"outDir": "./dist",
"paths": {
"~/*": ["./src/*"]
}
},
"include": ["./src/core/**/*"],
"exclude": ["./src/app*", "./src/test-server", "./src/testing", "./src/**/*.spec.ts"]
}
10 changes: 9 additions & 1 deletion vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { defineConfig } from "vitest/config";
import { fileURLToPath, URL } from "url";
import { resolve } from "path";

export default defineConfig({

resolve: {
alias: {
"~": fileURLToPath(new URL("./src", import.meta.url)),
Expand All @@ -11,4 +11,12 @@ export default defineConfig({
test: {
environment: "happy-dom",
},
build: {
lib: {
entry: resolve(__dirname, "src/core/index.ts"),
name: "CacheQuery",
fileName: "index",
},
outDir: "dist",
}
});

0 comments on commit 0b26c00

Please sign in to comment.