From 1e77ca116f781b4bf12861aed37ad1d2b588eb98 Mon Sep 17 00:00:00 2001 From: Lukas Date: Wed, 14 Jan 2026 16:13:44 +0100 Subject: [PATCH 1/4] feat: update package.json scripts for CI testing and add guidelines for package structure --- .../instructions/package-json.instructions.md | 69 +++++++++++++++++++ .github/prompts/beforepush.prompt.md | 15 ++++ .github/prompts/npmrefresh.prompt.md | 20 ++++++ package.json | 3 +- 4 files changed, 106 insertions(+), 1 deletion(-) create mode 100644 .github/instructions/package-json.instructions.md create mode 100644 .github/prompts/beforepush.prompt.md create mode 100644 .github/prompts/npmrefresh.prompt.md diff --git a/.github/instructions/package-json.instructions.md b/.github/instructions/package-json.instructions.md new file mode 100644 index 0000000..aa133a7 --- /dev/null +++ b/.github/instructions/package-json.instructions.md @@ -0,0 +1,69 @@ +--- +applyTo: "package.json" +--- + +# How to structure `package.json` +- As this is a NPM package, use no `dependencies`. Only `peerDependencies` and `devDependencies` are allowed. +- Keep dependencies in `peerDependencies` and `devDependencies` properly separated. Only packages required at runtime should be in `peerDependencies`. +- Ensure that ESLint and its plugins are listed under `devDependencies` since they are only needed during development. + +## NPM Structure Rules +- Type must be set to `module` +- Use `exports` field to define entry points for the package +- Use `files` field to specify which files should be included when the package is published + +## Overall Structure of the `package.json` file +- Should contain at least these fields in this order from top to bottom: + 1. name + 2. version + 3. description + 4. type + +- After this header shold be be `files` definition pointing to `dist` folder + +- After `files` should be `exports` part defining entry points: + + - browser part with name `./browser` contains: + - import entry point: `./dist/index.browser.js` + - default entry point: `./dist/index.browser.js` + - types entry point: `./dist/index.browser.d.ts` + + - nodejs part with name `./node` contains: + - require entry point: `./dist/index.node.cjs` + - default entry point: `./dist/index.node.js` + - types entry point: `./dist/index.node.d.ts` + + - "./package.json": "./package.json" + +- After this header should be: + 1. scripts part + 2. peerDependencies part + 3. devDependencies part + +- Than can be other parts (like repository, keywords, author, license, etc.) + +## PeerDependencies part +Structure of dependencies should be: + 1. Anything starts with `@gisatcz/` (internal packages) + 2. Database related (like `mongoose`, `neo4j`, `ioredis`, etc.) + 3. Security related parts (like `bcrypt`, `jsonwebtoken`, `openid-client` etc.) + 4. Other production dependencies + +## DevDependencies part +Structure of DEV dependencies should be: + 1. All packages starting with `@types/` (TypeScript type definitions) + 2. Anything related to testing (like `vitest`, `jest`, etc.) + 3. Anything related to linting (like `eslint`, `typescript-eslint`, etc.) + 4. Eerything related to building/bundling (like `rollup`, `esbuild`, etc.) + 5. All related with typescript and building (like `typescript`, `tsc-alias`, `tsx`, etc.) + 6. Other development dependencies + +## Scripts part +Scripts part should be structured as: + 1. dev related scripts (like `dev`, `dev:watch`, etc.) + 2. build related scripts (like `build`, `build:prod`, etc.) + 3. lint related scripts (like `lint`, `lint:fix`, etc.) + 4. test related scripts (like `test`, `test:watch`, etc.) + 5. `yalc` related scripts (like `yalc:publish`, `yalc:publish:push`, etc.) + 6. before push script (combination of lint, build and test. Example is `before:push`) + 7. other scripts \ No newline at end of file diff --git a/.github/prompts/beforepush.prompt.md b/.github/prompts/beforepush.prompt.md new file mode 100644 index 0000000..7af9a0d --- /dev/null +++ b/.github/prompts/beforepush.prompt.md @@ -0,0 +1,15 @@ +--- +agent: agent +tools: ['vscode', 'execute', 'read', 'edit', 'search', 'web', 'agent', 'todo'] +description: 'Run all steps needed for clean push to the repository like linting, building, testing, etc.' +--- +Before we push code to the repository, we need to ensure that everything is in order. + +Process: +1. In terminal run `npm run before:push` to check if linting, building, and testing pass successfully. +2. If any of the steps fail, fix the issues: + - For linting issues, refer to ESLint output and fix code style or errors. + - For build issues, check TypeScript errors and fix them. + - For test failures, review test output, identify failing tests, and fix the underlying issues. +3. After fixing issues, repeat step 1 until all steps pass successfully. +4. Once all checks pass, proceed to commit and push the code to the repository. \ No newline at end of file diff --git a/.github/prompts/npmrefresh.prompt.md b/.github/prompts/npmrefresh.prompt.md new file mode 100644 index 0000000..cec3910 --- /dev/null +++ b/.github/prompts/npmrefresh.prompt.md @@ -0,0 +1,20 @@ +--- +agent: agent +tools: ['vscode', 'execute', 'read', 'edit', 'search', 'web', 'agent', 'todo'] +description: 'Refresh all NPM packages to newest major version' +--- +We need to make clean reinstall of all NPM packages. We expect need to solve futher compatibility issues. + +Process: +1. delete `node_modules` folder +2. delete `package-lock.json` file +3. read `package.json` and prepare two CLIs: + - one for installing all dependencies in `peerDependencies` with `npm install --save` + - second for installing all devDependencies in `devDependencies` with `npm install --save-dev` +5. save both CLIs into `docs/npm-refresh-commands.md` file with header "NPM Refresh Commands" and short description of the process +6. execute both CLIs +7. check if `package.json` needs to be restructured according to `.github/instructions/package-json.instructions.md` file, if yes, restructure it +8. run `npm run before:push` to check if everything is fine +9. if there are any issues, fix them (like compatibility issues, missing types, etc.) +10. repeat from step 8 until everything is fine +11. finally create a summary of all changes made in this process, including major version updates and any issues encountered and how they were resolved. \ No newline at end of file diff --git a/package.json b/package.json index 6aaac8a..6a0798e 100644 --- a/package.json +++ b/package.json @@ -31,9 +31,10 @@ "pack:check": "npm pack --dry-run", "lint": "eslint", "test": "vitest --config vitest.config.ts", + "test:ci": "vitest run --config vitest.config.ts", "build:clean": "rm -rf dist .rollup.cache tsconfig.tsbuildinfo", "build": "npm run build:clean && rollup --config", - "before:push": "npm run lint && npm run build && npm run test" + "before:push": "npm run lint && npm run build && npm run test:ci" }, "author": "", "license": "ISC", From 2980c7dd807b314cc2c0579dbdcdf1dad1eefa5e Mon Sep 17 00:00:00 2001 From: Lukas Date: Wed, 14 Jan 2026 16:21:26 +0100 Subject: [PATCH 2/4] feat: add prompt for package.json management with instructions for clean repository push --- .github/prompts/package-json.prompt.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .github/prompts/package-json.prompt.md diff --git a/.github/prompts/package-json.prompt.md b/.github/prompts/package-json.prompt.md new file mode 100644 index 0000000..57f3de2 --- /dev/null +++ b/.github/prompts/package-json.prompt.md @@ -0,0 +1,6 @@ +--- +agent: agent +tools: ['vscode', 'execute', 'read', 'edit', 'search', 'web', 'agent', 'todo'] +description: 'Run all steps needed for clean push to the repository like linting, building, testing, etc.' +--- +Order and clean the `package.json` file according to `.github/instructions/package-json.instructions.md` file. \ No newline at end of file From 621c3572094ea66970ce7765c39883ebb0d09eb2 Mon Sep 17 00:00:00 2001 From: Lukas Date: Wed, 14 Jan 2026 16:28:12 +0100 Subject: [PATCH 3/4] fix: update test scripts for consistency in CI workflow --- package.json | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 6a0798e..31df805 100644 --- a/package.json +++ b/package.json @@ -30,11 +30,10 @@ "dev": "npm run build:clean && rollup --config --watch", "pack:check": "npm pack --dry-run", "lint": "eslint", - "test": "vitest --config vitest.config.ts", - "test:ci": "vitest run --config vitest.config.ts", + "test": "vitest run --config vitest.config.ts", "build:clean": "rm -rf dist .rollup.cache tsconfig.tsbuildinfo", "build": "npm run build:clean && rollup --config", - "before:push": "npm run lint && npm run build && npm run test:ci" + "before:push": "npm run lint && npm run build && npm run test" }, "author": "", "license": "ISC", From 90f1aa3a4d05dd9f14c9e1f55a055a1e2d901523 Mon Sep 17 00:00:00 2001 From: Lukas Date: Wed, 14 Jan 2026 17:14:06 +0100 Subject: [PATCH 4/4] docs: update instructions for clarity and add predefined prompts section --- .github/copilot-instructions.md | 4 +++- AGENTS.md | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index 455daf0..70c512a 100644 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -2,7 +2,9 @@ Shared TypeScript library for backend and frontend applications of the Panther project. ## Important Rule -Read and follow all `.github/instructions/*` files for code and practises clarity. +- Read and follow all `.github/instructions/*` files for code and practises clarity. +- Predefined prompts can be found in `.github/prompts/` + ## Repository Summary - This repo is a shared TypeScript library used by backend and frontend apps. diff --git a/AGENTS.md b/AGENTS.md index 455daf0..70c512a 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -2,7 +2,9 @@ Shared TypeScript library for backend and frontend applications of the Panther project. ## Important Rule -Read and follow all `.github/instructions/*` files for code and practises clarity. +- Read and follow all `.github/instructions/*` files for code and practises clarity. +- Predefined prompts can be found in `.github/prompts/` + ## Repository Summary - This repo is a shared TypeScript library used by backend and frontend apps.