Skip to content

Swipecast/shared

Repository files navigation

@swipecast/shared

Shared business logic package for Swipecast React Native and Web applications.

Installation

npm install @swipecast/shared
# or
yarn add @swipecast/shared

Usage

StripeHelpers

import { StripeHelpers } from '@swipecast/shared';

const card = {
  brand: 'American Express',
  last4: '1234',
  exp_month: 12,
  exp_year: 2025,
};

const label = StripeHelpers.getCardBrandLabel(card); // "Amex"

Development

Setup

npm install

Build

npm run build

This will compile TypeScript to JavaScript in the dist directory.

Publishing

Automatic Publishing (CI/CD)

The package is automatically published to npm when code is pushed to the main branch. The workflow will:

  1. Build the package
  2. Publish to npm using the NPM_TOKEN secret

Setup:

  1. Add your npm token as a GitHub secret named NPM_TOKEN:

    • Go to your repository settings → Secrets and variables → Actions
    • Add a new secret with your npm token (get it from npmjs.com → Access Tokens)
  2. Update the version in package.json before pushing:

    npm version patch  # for bug fixes
    npm version minor  # for new features
    npm version major  # for breaking changes
  3. Push to main:

    git push origin main

Skip publishing: Add [skip publish] to your commit message to skip automatic publishing.

Manual Publishing

If you need to publish manually:

  1. Make sure you're logged into npm:

    npm login
  2. Update the version in package.json:

    npm version patch  # for bug fixes
    npm version minor  # for new features
    npm version major  # for breaking changes
  3. Publish:

    npm publish

The prepublishOnly script will automatically build the package before publishing.

Publishing to a Private Registry

If you're using a private npm registry, update the publishConfig in package.json:

{
  "publishConfig": {
    "registry": "https://your-private-registry.com"
  }
}

Project Structure

shared/
├── src/
│   ├── stripe_helpers.ts  # Stripe-related business logic
│   └── index.ts           # Main entry point
├── dist/                  # Compiled output (generated)
├── package.json
├── tsconfig.json
└── README.md

License

UNLICENSED

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published