From 2b8bfda59c6dc494c9e11134319b470a1836efd5 Mon Sep 17 00:00:00 2001 From: Harley Harris Date: Tue, 21 Nov 2023 15:14:25 +0000 Subject: [PATCH 1/4] update package.json with relevant fields related to npm packaging --- package.json | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 28292bc..115ea5d 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,10 @@ { - "name": "poc_node_logging_tool", + "name": "@co-digital/node-logging", "version": "1.0.0", - "description": "node logging tool", - "main": "dist/index.js", + "description": "A logging library for Node.JS applications in CO Digital.", + "homepage": "https://github.com/cabinetoffice/node-logging/blob/main/README.md", + "main": "./lib/index.js", + "types": "./lib/index.d.ts", "scripts": { "build": "tsc", "start": "node dist/index.js", @@ -12,7 +14,13 @@ "prettier:fix": "prettier --write .", "test": "jest", "coverage": "jest --coverage", - "prepare": "husky install" + "prepare": "husky install", + "prepublish": "[ ! -d node_modules ] && npm ci; tsc", + "postpublish": "rm -rf lib" + }, + "repository": { + "type": "git", + "url": "https://github.com/cabinetoffice/node-logging.git" }, "engines": { "npm": ">=10.0.0", @@ -37,5 +45,8 @@ "dependencies": { "luxon": "^3.4.3", "winston": "^3.11.0" - } + }, + "files": [ + "./lib/**/*" + ] } From 880e5d9676973bfddefb08220c24b0bb92ce49d0 Mon Sep 17 00:00:00 2001 From: Harley Harris Date: Tue, 21 Nov 2023 12:02:51 +0000 Subject: [PATCH 2/4] update tsconfig.json properties to emit transpiled library code --- tsconfig.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tsconfig.json b/tsconfig.json index 7189966..a9744a4 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -15,7 +15,8 @@ /* Emit */ "sourceMap": true, /* Create source map files for emitted JavaScript files. */ - "outDir": "./dist", /* Specify an output folder for all emitted files. */ + "outDir": "./lib", /* Specify an output folder for all emitted files. */ + "declaration": true, /* Interop Constraints */ "esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */ From 0b67c02a67c458c11024d99109b414452a66d2af Mon Sep 17 00:00:00 2001 From: Harley Harris Date: Wed, 22 Nov 2023 13:33:34 +0000 Subject: [PATCH 3/4] update references from dist to lib directory --- .gitignore | 2 ++ .prettierignore | 2 +- Makefile | 2 +- README.md | 2 +- jest.config.js | 2 +- package.json | 2 +- 6 files changed, 7 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 5efbf77..53f0770 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ +lib + # Logs **.log logs diff --git a/.prettierignore b/.prettierignore index e138a19..c027c82 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1,4 +1,4 @@ -dist +lib *.json *.md *.yml \ No newline at end of file diff --git a/Makefile b/Makefile index 18e7769..c9e142a 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ NODE_VERSION_SUPPORTED := >=20.8.0 NODE_VERSION=$(shell node -v) clean: - rm -rf ./dist ./coverage + rm -rf ./lib ./coverage build: $(info Node version supported: $(NODE_VERSION_SUPPORTED)) diff --git a/README.md b/README.md index 82cb240..b3a01d0 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ To integrate the module for testing purposes into your Node.js project, use the ```typescript // logger.ts -import { ApplicationLogger } from "logging/dist/ApplicationLogger"; +import { ApplicationLogger } from "logging/lib/ApplicationLogger"; import { createLogger } from "logging"; import { APPLICATION_NAME } from "../config"; diff --git a/jest.config.js b/jest.config.js index 112b516..1b15123 100644 --- a/jest.config.js +++ b/jest.config.js @@ -1,6 +1,6 @@ module.exports = { roots: ['/src', '/test'], - testPathIgnorePatterns: ['/node_modules/', '/dist/'], + testPathIgnorePatterns: ['/node_modules/', '/lib/'], collectCoverageFrom: ['./src/**/*.ts'], preset: 'ts-jest', testEnvironment: 'node', diff --git a/package.json b/package.json index 115ea5d..bd6804f 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "types": "./lib/index.d.ts", "scripts": { "build": "tsc", - "start": "node dist/index.js", + "start": "node lib/index.js", "lint": "eslint '{src,test}/**/*.ts'", "lint:fix": "eslint '{src,test}/**/*.ts' --fix", "prettier": "prettier --check .", From facbc7d9377a781a7c63b99a2428d6aa6517ba05 Mon Sep 17 00:00:00 2001 From: Harley Harris Date: Wed, 22 Nov 2023 13:34:45 +0000 Subject: [PATCH 4/4] update homepage url --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index bd6804f..19309a7 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "@co-digital/node-logging", "version": "1.0.0", "description": "A logging library for Node.JS applications in CO Digital.", - "homepage": "https://github.com/cabinetoffice/node-logging/blob/main/README.md", + "homepage": "https://github.com/cabinetoffice/node-logging#README.md", "main": "./lib/index.js", "types": "./lib/index.d.ts", "scripts": {