Skip to content
Merged

Dev #26

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .npmrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
registry=https://registry.npmjs.org/
//registry.npmjs.org/:_authToken=${NPM_TOKEN}
save-prefix=^
save-prefix=^
35 changes: 27 additions & 8 deletions PACKAGE_MANAGERS.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ The following scripts are available via `npm run <script>` or `pnpm run <script>

The following scripts are available via `npm run <script>` or `pnpm run <script>`:




### 📦 SETUP.md – NPM Token Authentication with .env and CLI
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The section title here is SETUP.md, but this file is PACKAGE_MANAGERS.md. This appears to be a copy-paste error and could be confusing for readers. Please correct the title to be relevant to this file.

Suggested change
### 📦 SETUP.md – NPM Token Authentication with .env and CLI
### 📦 NPM Token Authentication with .env and CLI



| Script | Description |
|--------------------|------------------------------------------------------------------|
| **build** | Compile TypeScript using `tsc` and fix paths using `tsc-alias` |
Expand All @@ -54,17 +60,10 @@ The following scripts are available via `npm run <script>` or `pnpm run <script>
| **add** | *(Your custom script — specify its function if needed)* |


### 🎯 Filter Usage (Workspace Targeting)

````bash
pnpm build --filter @nexgenstudiodev/fastkit-config
pnpm add -D @types/express --filter @nexgenstudiodev/fastkit-config

````

### 🚀 Publishing Workflow


#### Using npm

1. Make your changes
Expand Down Expand Up @@ -125,7 +124,7 @@ If you're working on a new feature or a major update and want users to test it *
```bash
npm run publish:npm -- --tag beta
```

This way, your beta version is available for testing, but users installing your package normally will still get the stable latest version.


Expand Down Expand Up @@ -169,6 +168,26 @@ pnpm run publish:pnpm

---



# Version & Tag Management for `@nexgenstudiodev/fastkit`

| Topic | Command / Info | Description |
|-----------------------------|------------------------------------------------------------|-----------------------------------------------|
| **View all tags** | `npm dist-tag ls @nexgenstudiodev/fastkit` | List all tags and their versions |
| **Set latest tag version** | `npm dist-tag add @nexgenstudiodev/fastkit@1.1.3 latest` | Point `latest` tag to version `1.1.3` |
| **Tag a version as beta** | `npm dist-tag add @nexgenstudiodev/fastkit@2.0.0 beta` | Mark version `2.0.0` as `beta` |
| **Install latest version** | `npm install @nexgenstudiodev/fastkit` | Install version tagged `latest` |
| **Install specific version** | `npm install @nexgenstudiodev/fastkit@1.1.3` | Install exact version `1.1.3` |
| **Install tagged version** | `npm install @nexgenstudiodev/fastkit@beta` | Install version tagged `beta` |
| **Publish with tag** | `npm publish --tag latest` or `npm publish --tag beta` | Publish package with specified tag |
| **Clear npm cache** | `npm cache clean --force` | Fix cache issues when updates don’t appear |

---




## ✅ Best Practices

- Use a single package manager throughout your project
Expand Down
19 changes: 17 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,25 @@
{
"name": "@nexgenstudiodev/fastkit",
"version": "2.4.0",
"description": "A comprehensive FastKit library with auth, database config, and utilities",

"type": "commonjs",
"version": "1.2.0",
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The version has been bumped from 1.0.2 to 1.2.0. Ensure this version bump aligns with the changes made and follows semantic versioning principles.

"description": "A modular, class-based toolkit for fast API development with TypeScript and Express.",
"main": "dist/FastKit.js",
"types": "dist/FastKit.d.ts",
"files": [
"dist"
],

"scripts": {
"format": "prettier --write 'src/**/*.{ts,tsx,js,json,md}'",
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The format script is present, but there's no corresponding script to check formatting without writing changes. Consider adding a format:check script that uses prettier --check to verify formatting without modifying files. This can be useful in CI environments.

"lint": "eslint src/**/*.{ts,tsx}",
"lint:fix": "eslint src/**/*.{ts,tsx} --fix",
"link": "npm link @nexgenstudiodev/fastkit",
"build": "tsc && pnpm exec tsc-alias",
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The build script uses tsc && pnpm exec tsc-alias. Consider adding a clean step (e.g., rimraf dist && tsc && pnpm exec tsc-alias) to ensure the dist directory is clean before each build. This prevents stale files from causing issues.

rimraf dist && tsc && pnpm exec tsc-alias

"link:manage": "ts-node src/script/manage-link.ts",
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

This script points to src/script/manage-link.ts, but this file does not exist in the pull request. This will cause the pnpm run link:manage command to fail. Please either add the missing file or remove this script if it's not intended to be part of this change.

"manage": "ts-node src/script/index.ts"
},

"keywords": [
"fastkit",
"auth",
Expand Down Expand Up @@ -82,8 +95,10 @@
"jest": "^30.0.3",
"lint-staged": "^16.1.2",
"prettier": "^3.6.2",
"prompts": "^2.4.2",
"rimraf": "^6.0.1",
"ts-jest": "^29.4.0",
"ts-node": "^10.9.2",
"ts-node-dev": "^2.0.0",
"tsc-alias": "^1.8.16",
"tsconfig-paths": "^4.2.0",
Expand Down
30 changes: 30 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Empty file.
Empty file.
15 changes: 15 additions & 0 deletions src/script/build.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { execSync } from 'child_process';


export function build() {
console.log('Running clean...');
execSync('rimraf dist', { stdio: 'inherit' });
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Consider adding a -f flag to the rimraf command to force deletion and avoid potential errors due to file permissions or other issues.

Suggested change
execSync('rimraf dist', { stdio: 'inherit' });
execSync('rimraf -f dist', { stdio: 'inherit' });


console.log('Compiling TypeScript...');
execSync('tsc', { stdio: 'inherit' });

console.log('Fixing path aliases...');
execSync('pnpm exec tsc-alias', { stdio: 'inherit' });

console.log('Build complete!');
}
35 changes: 35 additions & 0 deletions src/script/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import prompts from 'prompts';
import { build } from './build';
import { startProd } from './production';
import { publish } from './publish';

async function main() {
const response = await prompts({
type: 'select',
name: 'command',
message: 'Which script do you want to run?',
choices: [
{ title: 'Build', value: 'build' },
{ title: 'Start Production', value: 'prod' },
{ title: 'Publish', value: 'publish' },
{ title: 'Exit', value: 'exit' },
],
});

switch (response.command) {
case 'build':
build();
break;
case 'prod':
startProd();
break;
case 'publish':
publish();
break;
default:
console.log('Exiting...');
process.exit(0);
}
}

main();
9 changes: 9 additions & 0 deletions src/script/production.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { execSync } from 'child_process';

export function startProd() {
console.log('Running pre-production tasks: format, lint, build');
execSync('pnpm run format && pnpm run lint --fix && pnpm run build', { stdio: 'inherit' });
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The command pnpm run lint --fix automatically fixes linting issues. While this is convenient, it might be unexpected for some developers. Consider adding a separate script that only checks for linting errors without fixing them (e.g., pnpm run lint:check) and using that in the production script.


console.log('Starting production server...');
execSync('node dist/index.js', { stdio: 'inherit' });
}
29 changes: 29 additions & 0 deletions src/script/publish.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { execSync } from 'child_process';

/**
* Bump version, run format/lint/build, then publish
* @param bumpType one of 'patch' | 'minor' | 'major' (default: patch)
* @param tag optional npm tag (e.g., 'beta')
*/
function publishWithVersionBump(bumpType = 'patch', tag?: string) {
console.log(`Bumping version (${bumpType})...`);
execSync(`npm version ${bumpType}`, { stdio: 'inherit' });

console.log('Running prepublish tasks: format, lint, build');
execSync('pnpm run format && pnpm run lint && pnpm run build', { stdio: 'inherit' });

const publishCmd = tag
? `npm publish --access public --tag ${tag}`
: 'npm publish --access public';

console.log(`Publishing${tag ? ` with tag "${tag}"` : ''} to npm...`);
execSync(publishCmd, { stdio: 'inherit' });
}

export function publish() {
publishWithVersionBump('patch');
}

export function publishBeta() {
publishWithVersionBump('patch', 'beta');
}
1 change: 1 addition & 0 deletions test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import {} from '@nexgenstudiodev/fastkit'
6 changes: 4 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"@nexgenstudiodev/fastkit-auth": ["src/packages/fastkit-auth/src"],
"@nexgenstudiodev/fastkit-dbconfig": ["src/packages/fastkit-db-config/src"]
}

},
"include": ["src/**/*"],
"exclude": [
Expand All @@ -32,7 +33,8 @@
"src/script/*.ts",
"src/**/*.test.ts",
"src/**/*.spec.ts",
"src/**/__tests__/**",
"**/*.d.ts"

"src/**/__test__/**"
]

}