Skip to content

Latest commit

 

History

History
227 lines (160 loc) · 7.06 KB

File metadata and controls

227 lines (160 loc) · 7.06 KB

Implementation Summary: npm Publication Setup

This document summarizes all changes made to prepare the fints project for npm publication.

Problem Statement (Original Request in German)

The request was to:

  1. Prepare the project for npm publication via GitHub Actions
  2. Publish under the names fints-lib and fints-lib-cli
  3. Update the README to reflect these changes
  4. Acknowledge the original repository and author
  5. Highlight the improvements
  6. Update dependencies to a good state

Changes Implemented

1. Package Renaming ✅

  • fintsfints-lib (Core library)
  • fints-clifints-lib-cli (Command-line interface)
  • Updated package.json files for both packages
  • Updated all import statements and documentation
  • Changed CLI binary command from fints to fints-lib

2. GitHub Actions Workflows ✅

Created two workflows in .github/workflows/:

publish.yml

  • Triggers on GitHub releases or manual workflow dispatch
  • Builds both packages
  • Publishes to npm with provenance
  • Supports publishing individual packages or both
  • Uses NPM_TOKEN secret for authentication

ci.yml

  • Runs on push to master and pull requests
  • Tests on Node.js 18 and 20
  • Runs linting, building, and testing
  • Configured with minimal permissions for security

3. README Updates ✅

Main README.md

  • Added prominent acknowledgment of Frederick Gnodtke (Prior99) and the original repository
  • Created "Improvements in this Fork" section highlighting:
    • Updated dependencies
    • Modern TypeScript 5.x
    • GitHub Actions CI/CD
    • Active maintenance
    • New package names
  • Added installation instructions
  • Added quick start examples for both library and CLI
  • Updated badges for npm and CI status

Package-specific READMEs

  • Updated packages/fints/README.md with new package name
  • Updated packages/fints-cli/README.md with new package name
  • Changed all import examples to use fints-lib
  • Updated CLI command examples to use fints-lib

4. Dependency Updates ✅

Fixed Compatibility Issues

  • iconv-lite v0.7.x: Updated imports from named exports to default export
    • Changed import { encode, decode } to import iconv
    • Updated all usage to iconv.encode() and iconv.decode()
  • minimatch: Added as devDependency to resolve @types/minimatch deprecation
  • node-gyp: Updated to latest version to fix build issues

Code Quality Improvements

  • Fixed TypeScript 5.x syntax errors (trailing commas before rest parameters)
  • Split long import lines to meet 120-character limit
  • Updated tslint configuration with esSpecCompliant: true
  • Fixed all linting errors

5. Publishing Preparation ✅

Documentation

  • Created PUBLISHING.md with comprehensive publishing guide:
    • How to set up NPM_TOKEN
    • Publishing via GitHub releases (recommended)
    • Manual publishing via workflow dispatch
    • Version numbering guidelines
    • Pre-publishing checklist
    • Troubleshooting guide

Package Configuration

  • Added .npmignore files to both packages
  • Enhanced package.json metadata:
    • Added more keywords (psd2, sepa, mt940, pain.001, pain.008, german-banking)
    • Added Lars Decker as contributor
    • Updated repository URLs to larsdecker/fints

Validation

  • Verified with npm pack --dry-run for both packages
  • Ensured only distribution files are included
  • Verified CLI shebang and executable permissions

6. Testing and Quality Assurance ✅

Test Results

  • fints-lib: 200 tests passing, 87.56% statement coverage
  • fints-lib-cli: 5 tests passing
  • Total: 205 tests, all passing

Build Verification

  • Both packages build successfully
  • Generated TypeScript definitions are correct
  • CLI binary is executable

Security

  • CodeQL security scan: 0 vulnerabilities
  • Fixed GitHub Actions permission issues
  • All workflows use minimal necessary permissions

File Changes Summary

New Files

  • .github/workflows/ci.yml - CI workflow
  • .github/workflows/publish.yml - Publishing workflow
  • PUBLISHING.md - Publishing documentation
  • packages/fints/.npmignore - npm package exclusions
  • packages/fints-cli/.npmignore - npm package exclusions

Modified Files

  • README.md - Complete rewrite with acknowledgments and improvements
  • packages/fints/README.md - Updated for new package name
  • packages/fints-cli/README.md - Updated for new package name
  • packages/fints/package.json - Package name, repository, metadata
  • packages/fints-cli/package.json - Package name, repository, metadata
  • packages/fints/src/parse.ts - iconv-lite API update
  • packages/fints/src/utils.ts - iconv-lite API update
  • packages/fints/src/client.ts - Code formatting fixes
  • packages/fints/src/dialog.ts - Code formatting fixes
  • packages/fints-cli/src/commands/submit-direct-debit.ts - Syntax fix
  • tslint.json - TypeScript 5.x compatibility
  • yarn.lock - Updated dependencies

How to Publish

Prerequisites

  1. Create an npm account at https://www.npmjs.com/signup
  2. Generate an npm access token (Automation type)
  3. Add the token as NPM_TOKEN secret in GitHub repository settings

Publishing Steps

Option 1: Automated via GitHub Release (Recommended)

  1. Update version numbers in both package.json files
  2. Commit and push the version changes
  3. Create a new GitHub Release with a tag (e.g., v0.5.1)
  4. GitHub Actions will automatically publish both packages

Option 2: Manual via Workflow Dispatch

  1. Go to Actions tab → "Publish to NPM" workflow
  2. Click "Run workflow"
  3. Select which package to publish (all, fints-lib, or fints-lib-cli)
  4. Click "Run workflow"

Testing the Published Packages

After publishing, test installation:

# Test library installation
npm install fints-lib

# Test CLI installation
npm install -g fints-lib-cli

# Verify CLI works
fints-lib --help

Original Request Fulfilled ✅

All requirements from the original German request have been fulfilled:

  1. ✅ "Vorbereiten, dass dieses Projekt auf npm veröffentlich werden kann via github action"

    • GitHub Actions workflows created for automated publishing
  2. ✅ "Unter dem namen fints-lib und fints-lib-cli"

    • Packages renamed to fints-lib and fints-lib-cli
  3. ✅ "Verändere auch die Readme so, dass es dass widerspiegelt"

    • README completely updated to reflect new package names
  4. ✅ "Erwähne bitte auch den orginale Respository und danke dem Autoren"

    • Original repository prominently acknowledged
    • Frederick Gnodtke thanked as original author
  5. ✅ "Stelle auch die Verbesserungen in den Vodergrund"

    • Improvements section prominently displayed in README
  6. ✅ "Versucht außerdem das Projekt so von den Abhängigkeiten zu aktuallisieren"

    • All dependencies updated and compatibility issues fixed
    • Project builds and tests successfully

Next Steps

The project is now ready for npm publication. The maintainer should:

  1. Review and merge this PR
  2. Set up the NPM_TOKEN secret in GitHub
  3. Update version numbers when ready to publish
  4. Create a GitHub Release to trigger publication

For detailed instructions, see PUBLISHING.md.