Skip to content

Commit

Permalink
Major alpha update to node 20 and Typescript 5.5, rewrite dockerfile …
Browse files Browse the repository at this point in the history
…for pnpm

Patch required for better-ajv-errors as they declare their types incorrectly. See atlassian/better-ajv-errors#176, fix based on atlassian/better-ajv-errors#177

Updates tsconfig
Bumps dependency versions
  • Loading branch information
khakers committed Jul 12, 2024
1 parent dd8fb29 commit 42e9ecb
Show file tree
Hide file tree
Showing 8 changed files with 374 additions and 433 deletions.
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
node_modules
npm-debug.log
.git
.gitignore
*.md
dist
3 changes: 2 additions & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ on:
jobs:
docker-publish:
name: Publish to Docker Hub
if: "!contains(github.event.head_commit.message, '[ci skip]')"
if: |
!contains(github.event.head_commit.message, '[ci skip]')
runs-on: ubuntu-latest
permissions:
contents: read
Expand Down
33 changes: 15 additions & 18 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,25 +1,22 @@
FROM node:16-alpine AS base
FROM base as builder

FROM node:22-alpine AS base
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable
COPY . /app
WORKDIR /app

COPY package.json /app
COPY yarn.lock /app
COPY tsconfig.json /app
COPY src /app/src

RUN yarn install --frozen-lockfile
RUN yarn build
FROM base AS prod-deps
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --prod --frozen-lockfile

RUN mv /app/node_modules /app/node_modules_dev
RUN yarn install --frozen-lockfile --production
FROM base AS build
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile
RUN pnpm run build

FROM base
COPY --from=prod-deps /app/node_modules /app/node_modules
COPY --from=build /app/dist /app/dist
EXPOSE 8000
STOPSIGNAL SIGINT
WORKDIR /app

COPY --from=builder /app/node_modules /app/node_modules
COPY --from=builder /app/dist /app/dist
COPY --from=builder /app/package.json /app/package.json
ENV NODE_ENV=production

CMD [ "node", "/app/dist/index.js" ]
CMD [ "node", "/app/dist/index.js" ]
34 changes: 20 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,34 @@
},
"author": "Daniel Chesterton",
"dependencies": {
"ajv": "^8.8.2",
"async-mqtt": "^2.6.1",
"better-ajv-errors": "^1.1.2",
"ajv": "^8.16.0",
"async-mqtt": "^2.6.3",
"better-ajv-errors": "^1.2.0",
"bigint-buffer": "^1.1.5",
"js-yaml": "^4.1.0",
"luxon": "^2.3.0",
"net-snmp": "^3.5.8",
"slugify": "^1.6.5"
"luxon": "^2.5.2",
"net-snmp": "^3.12.0",
"slugify": "^1.6.6"
},
"devDependencies": {
"@tsconfig/node16": "^1.0.2",
"@types/js-yaml": "^4.0.5",
"@types/luxon": "^2.0.8",
"@types/node": "^14.14.27",
"prettier": "^2.5.1",
"ts-node": "^10.4.0",
"typescript": "^4.5.4"
"@tsconfig/node20": "^20.1.4",
"@types/js-yaml": "^4.0.9",
"@types/luxon": "^2.4.0",
"@types/node": "^20.14.10",
"prettier": "^2.8.8",
"ts-node": "^10.9.2",
"typescript": "^5.5.3"
},
"scripts": {
"build": "rm -rf dist && tsc",
"start": "ts-node --files src/index.ts",
"dev": "ts-node --files src/index.ts",
"prettier:write": "prettier src --write"
},
"packageManager": "[email protected]+sha512.140036830124618d624a2187b50d04289d5a087f326c9edfc0ccd733d76c4f52c3a313d4fc148794a2a9d81553016004e6742e8cf850670268a7387fc220c903"
"packageManager": "[email protected]+sha512.140036830124618d624a2187b50d04289d5a087f326c9edfc0ccd733d76c4f52c3a313d4fc148794a2a9d81553016004e6742e8cf850670268a7387fc220c903",
"pnpm": {
"patchedDependencies": {
"[email protected]": "patches/[email protected]"
}
}
}
71 changes: 71 additions & 0 deletions patches/[email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
diff --git a/CHANGELOG.md b/CHANGELOG.md
deleted file mode 100644
index 14b6dfaa73957a7832335206511e764cdd2ea730..0000000000000000000000000000000000000000
diff --git a/typings.d.ts b/lib/cjs/typings.d.ts
similarity index 100%
rename from typings.d.ts
rename to lib/cjs/typings.d.ts
diff --git a/lib/esm/typings.d.mts b/lib/esm/typings.d.mts
new file mode 100644
index 0000000000000000000000000000000000000000..580c56f4397ad8d7ba8a9527e95bbe3e973802b8
--- /dev/null
+++ b/lib/esm/typings.d.mts
@@ -0,0 +1,24 @@
+import type { ErrorObject } from 'ajv';
+
+export interface IOutputError {
+ start: { line: number; column: number; offset: number };
+ // Optional for required
+ end?: { line: number; column: number; offset: number };
+ error: string;
+ suggestion?: string;
+}
+
+export interface IInputOptions {
+ format?: 'cli' | 'js';
+ indent?: number | null;
+
+ /** Raw JSON used when highlighting error location */
+ json?: string | null;
+}
+
+export default function <S, T, Options extends IInputOptions>(
+ schema: S,
+ data: T,
+ errors: Array<ErrorObject>,
+ options?: Options
+): Options extends { format: 'js' } ? Array<IOutputError> : string;
diff --git a/package.json b/package.json
index baaa5940665ea50aebee3b93b822d79c62772b6b..7608634ec7c25e99586b4d39e5356eecc8bf7edc 100644
--- a/package.json
+++ b/package.json
@@ -6,8 +6,14 @@
"main": "./lib/cjs/index.js",
"exports": {
".": {
- "require": "./lib/cjs/index.js",
- "default": "./lib/esm/index.mjs"
+ "import": {
+ "types": "./lib/esm/typings.d.mts",
+ "default": "./lib/esm/index.mjs"
+ },
+ "require": {
+ "types": "./lib/cjs/typings.d.ts",
+ "default": "./lib/cjs/index.js"
+ }
}
},
"module": "./lib/esm/index.mjs",
@@ -26,10 +32,9 @@
"Tong Li"
],
"license": "Apache-2.0",
- "types": "./typings.d.ts",
+ "types": "./lib/cjs/typings.d.ts",
"files": [
- "lib",
- "typings.d.ts"
+ "lib"
],
"scripts": {
"prebuild": "rm -rf lib",
Loading

0 comments on commit 42e9ecb

Please sign in to comment.