Skip to content

erichosick/sqlpm

Repository files navigation

sqlpm

A lerna mono-repo project.

  • Tech stack:
    • eslint
    • jest + jsdom + unit/integration testing
    • lerna (package-level versioning)
    • typescript
    • yarn
    • webpack

lerna

How To Use These Libraries

README: For consumers of node packages (jest and ts-node as examples), by default, a transformer will not be invoked on a typescript package in node_modules: though these same libraries will automatically transform your typescript packages if they are located in any other directory.

The intent of packages in this mono-repo is to use the packages as a typescript libraries: compiling them to Javascript occurring within your project on release (using tsc for example). To use these libraries during development, you will need to enable transforming within the node_modules directory.

Jest

To enable jest transforming typescript for @sqlpm projects in jest, add to your jest.config.ts the transformIgnorePatterns: ['/node_modules/(?!(@sqlpm)/)']. Your final config file should looks something like this:

import type {
  Config,
} from 'jest';

const config: Config = {
  preset: 'ts-jest',
  testEnvironment: 'node',
  transformIgnorePatterns: ['/node_modules/(?!(@sqlpm)/)'],
};

export default config;

ts-node

See ts-node transpilation options for details.

# run ts-node with the -skipIgnore option
yarn ts-node --skipIgnore fails

# or using an environment variable
TS_NODE_SKIP_IGNORE=true yarn ts-node fail

Development

Development requirements:

  • Node + Yarn
# Within the sqlpm directory
# init all the projects
yarn

# packages development

# continuously run tests
yarn test:unit:watch

# build any distributable and run unit tests
yarn test:unit

# A specific file
yarn test:unit ./packages/node-package-ts/__tests__/build-dependency.unit.spec.ts

# build javascript library from typescript library
yarn build

# continuously build javascript library from typescript library
yarn build:watch

# publish all packages that have changed to npmjs.com
yarn publish:all

# schema development (postgresql)

# spin up database
yarn docker:up

# run schema tests one time

yarn test:postgresql

# watch and run schema tests change
yarn test:postgresql:watch

Testing

See package.json for testing options.

  • sql - Run yarn test:postgresql:watch for CI/CD against schema.

Pushing Changes

# verify test run
yarn test:unit

# verify build works
yarn build

# make sure everything is commented, checked in and pushed into git
# TODO: Document code review process

# publish all packages that have changed
# you will need to have setup the account with npmjs.com
yarn publish:all

# enter the one-time password generated using 
# select correct version bump

Adding a New Package

# Add a new project
yarn lerna:create {@name/new-package-name}  # @example yarn lerna:create @sqlpm/http-context

# Link it to other projects
yarn lerna add {@name/existing-module} --scope={@name/new-package-name}

Adding a New Schema

SQL Schema pac

yarn sqlpm generate '{"packageName": "lib", "databaseSystem": "postgresql", "description": "domains, types, etc.", "author": "${your_name}", "email": "${your_email}", "purposes": ["readwrite"], "actions": ["run", "test", "reset"]}'

Linking To Another Project

yarn lerna add @name/link-to-package --scope=@name/package-to-contain-link
# example
 yarn lerna add @sqlpm/universal-schema --scope=@sqlpm/iso-schema

Database Libraries

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published