@naturalcycles/shared-module

> Set of opinionated configuration files and tools for common project needs, to be shared between > all modules. Enforces conventions between projects.

use @naturalcycles/dev-lib instead
Last updated 5 months ago by cervicalmucus .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @naturalcycles/shared-module 
SYNC missed versions from official npm registry.

@naturalcycles/shared-module

Set of opinionated configuration files and tools for common project needs, to be shared between all modules. Enforces conventions between projects.

npm Maintainability Test Coverage code style: prettier

How to use

yarn add -D @naturalcycles/shared-module prettier tslint

This unlocks all commands listed below in "Yarn commands" section, e.g:

yarn lint-all

By default it uses default configs for Prettier and TSLint that are included in this package (for convenience). You can override them by putting your own prettier.config.js / tslint.json in root folder of your project.

Conventions

Primary language: TypeScript (*.ts).

All files are linted and prettified upon commit (using husky, lint-staged and prettier).

Folder structure

  • /dist target dir to put compiled files into (*.js and additional files like *.json)
  • /dist-cjs target for CommonJS files
  • /dist-esm target for ES Modules
  • /src for all source files
  • /scripts for all non-production source files / scripts.
  • /src/test for generic test-related files and utilities, integration tests.
  • /src/test/mock
  • /src/test/integration for integration tests (unit tests should be placed next to the file)
  • /src/@linked
  • /src/typings
  • /src/environments
  • /coverage
  • /report
    • /jest/unit.xml
    • /jest/integration.xml
    • /coverage-integration

Yarn commands

These commands are available to be called as yarn <command>, because they are exposed as npm scripts in node_modules/.bin/.

Build commands

  • tsc-prod: does tsc -p tsconfig.prod.ts

  • tsc-scripts: does tsc -p ./scripts/tsconfig.ts --noEmit (type-checking for ./scripts)

  • build: "Development build". Checks that "everything compiles". Does del ./dist && tsc && tsc-scripts

  • bt: "Build & Test". Does del ./dist && tsc && tsc-scripts && test

  • build-copy: copies additional files into dist folder (e.g *.json)

  • build-prod: "Production build". Does del ./dist && build-copy && tsc-prod

Test commands

  • test: alias for jest. Automatically detects full-icu module presense, adds NODE_ICU_DATA=${fullICUPath} if needed. Automatically adds --silent (and JEST_SILENT env var) if all tests are run. Adds APP_ENV=test env var (for all runs except integration).
  • test-ci: runs test in CI environment, with coverage. Includes fix for "CircleCI out of memory issue"
  • test-integration: runs Jest with jest.integration-test.config.js config. Which will only run tests from ./src/test/integration folder.
  • test-integration-ci
  • test-leaks: runs Jest with --logHeapUsage --detectOpenHandles --detectLeaks (requires weak module to be installed in target project).

For unit tests (yarn test) these setupFilesAfterEnv will be used (if found) in that order:

  • <rootDir>/src/test/setupJest.ts
  • <rootDir>/src/test/setupJest.unit.ts

For integration tests (yarn test-integration) these setupFilesAfterEnv will be used (if found) in that order:

  • <rootDir>/src/test/setupJest.ts
  • <rootDir>/src/test/setupJest.integration.ts

Lint commands

  • lint-all: runs Prettier as we want it: first prettier on needed paths, then tslint on top of it.

    • --commitOnChanges will commit lint-modified changes and push them
    • --failOnChanges will exit with status 1 in the end (will fail the command)
  • tslint-all: runs tslint on needed paths

  • prettier-all: runs just Prettier on needed paths

  • lint-circleci: fails if .circleci/config.yml is invalid (CircleCI CLI must be installed before)

Run commands

All these commands will skip type-checking for speed (ts-node -T). Instead, type-checking is done via tsc-scripts as a part of build

  • tsn: short alias for ts-node -r tsconfig-paths/register
  • tsn-script: like tsn but for running scripts inside ./scripts folder, will use ./scripts/tsconfig.json (file will be auto-generated in not present).

Other commands

  • init-from-shared-module: copy config files from shared-module/cfg/init to the project
  • update-from-shared-module: copy config files from shared-module/cfg/overwrite to the project
  • generate-build-info: generate buildInfo.json
    • --dir <someDir> will save it to given dir
    • --shell will also generate buildInfo.sh

Non-extendable config files

These files cannot be extended, so they are instead copied into the target project: first time when seeding the project, later manually by running yarn update-from-shared-module.

These files are overwritten in target project every time the mentioned command is run. So, be careful! Solution is to either extend them in other way (e.g put more .gitignore files in subfolders), OR PR to this project, if the need is generic.

  • .editorconfig
  • .gitignore
  • .codeclimate.yml (with some work it can be made extendable later)

Extendable config files

These files are meant to be extended in target project, so act as recommended defaults.

  • husky.config.js
  • lint-staged.config.js
  • prettier.config.js
  • tslint.json
  • jest.config.js

Dependencies

@naturalcycles/shared-module is supposed to be included as devDependency.

It has dependencies that will be installed to all modules.

ONLY the dependencies that are:

  • stable
  • safe to automatically update according to semver (e.g ^1.0.0)

are included.

Examples of what devDeps cannot be included:

  • prettier, because patch versions can change how source code is printed significantly, and we want to control how and when to update it.
  • tslint, for same reasons
  • jest

Deps that are listed here are blessed and battle-tested.

Current Tags

  • 5.17.1                                ...           latest (5 months ago)

116 Versions

  • 5.17.1 [deprecated]           ...           5 months ago
  • 5.17.0 [deprecated]           ...           5 months ago
  • 5.16.0 [deprecated]           ...           5 months ago
  • 5.15.0 [deprecated]           ...           5 months ago
  • 5.14.5 [deprecated]           ...           5 months ago
  • 5.14.4 [deprecated]           ...           5 months ago
  • 5.14.3 [deprecated]           ...           5 months ago
  • 5.14.2 [deprecated]           ...           5 months ago
  • 5.14.1 [deprecated]           ...           5 months ago
  • 5.14.0 [deprecated]           ...           5 months ago
  • 5.13.0 [deprecated]           ...           5 months ago
  • 5.12.0 [deprecated]           ...           5 months ago
  • 5.11.0 [deprecated]           ...           5 months ago
  • 5.10.0 [deprecated]           ...           6 months ago
  • 5.9.0 [deprecated]           ...           6 months ago
  • 5.8.0 [deprecated]           ...           6 months ago
  • 5.7.0 [deprecated]           ...           6 months ago
  • 5.6.1 [deprecated]           ...           6 months ago
  • 5.6.0 [deprecated]           ...           6 months ago
  • 5.5.1 [deprecated]           ...           6 months ago
  • 5.5.0 [deprecated]           ...           6 months ago
  • 5.4.0 [deprecated]           ...           6 months ago
  • 5.3.0 [deprecated]           ...           6 months ago
  • 5.2.0 [deprecated]           ...           6 months ago
  • 5.1.0 [deprecated]           ...           6 months ago
  • 5.0.1 [deprecated]           ...           6 months ago
  • 5.0.0 [deprecated]           ...           6 months ago
  • 4.2.0 [deprecated]           ...           6 months ago
  • 4.1.0 [deprecated]           ...           6 months ago
  • 4.0.3 [deprecated]           ...           6 months ago
  • 4.0.2 [deprecated]           ...           6 months ago
  • 4.0.1 [deprecated]           ...           6 months ago
  • 4.0.0 [deprecated]           ...           6 months ago
  • 3.4.2 [deprecated]           ...           6 months ago
  • 3.4.1 [deprecated]           ...           6 months ago
  • 3.4.0 [deprecated]           ...           6 months ago
  • 3.3.1 [deprecated]           ...           6 months ago
  • 3.3.0 [deprecated]           ...           6 months ago
  • 3.2.0 [deprecated]           ...           6 months ago
  • 3.1.1 [deprecated]           ...           7 months ago
  • 3.1.0 [deprecated]           ...           7 months ago
  • 3.0.0 [deprecated]           ...           7 months ago
  • 2.4.0 [deprecated]           ...           7 months ago
  • 2.3.0 [deprecated]           ...           7 months ago
  • 2.2.1 [deprecated]           ...           7 months ago
  • 2.2.0 [deprecated]           ...           7 months ago
  • 2.1.1 [deprecated]           ...           7 months ago
  • 2.1.0 [deprecated]           ...           7 months ago
  • 2.0.0 [deprecated]           ...           7 months ago
  • 1.8.0 [deprecated]           ...           7 months ago
  • 1.7.0 [deprecated]           ...           8 months ago
  • 1.6.0 [deprecated]           ...           8 months ago
  • 1.5.0 [deprecated]           ...           9 months ago
  • 1.4.5 [deprecated]           ...           10 months ago
  • 1.4.4 [deprecated]           ...           10 months ago
  • 1.4.3 [deprecated]           ...           10 months ago
  • 1.4.2 [deprecated]           ...           10 months ago
  • 1.4.1 [deprecated]           ...           10 months ago
  • 1.4.0 [deprecated]           ...           10 months ago
  • 1.3.1 [deprecated]           ...           10 months ago
  • 1.3.0 [deprecated]           ...           10 months ago
  • 1.2.4 [deprecated]           ...           10 months ago
  • 1.2.3 [deprecated]           ...           a year ago
  • 1.2.2 [deprecated]           ...           a year ago
  • 1.2.1 [deprecated]           ...           a year ago
  • 1.2.0 [deprecated]           ...           a year ago
  • 1.1.2 [deprecated]           ...           a year ago
  • 1.1.1 [deprecated]           ...           a year ago
  • 1.1.0 [deprecated]           ...           a year ago
  • 1.0.1 [deprecated]           ...           a year ago
  • 1.0.0 [deprecated]           ...           a year ago
  • 1.0.50 [deprecated]           ...           a year ago
  • 1.0.49 [deprecated]           ...           a year ago
  • 1.0.48 [deprecated]           ...           a year ago
  • 1.0.47 [deprecated]           ...           a year ago
  • 1.0.46 [deprecated]           ...           a year ago
  • 1.0.45 [deprecated]           ...           a year ago
  • 1.0.44 [deprecated]           ...           a year ago
  • 1.0.43 [deprecated]           ...           a year ago
  • 1.0.42 [deprecated]           ...           a year ago
  • 1.0.41 [deprecated]           ...           a year ago
  • 1.0.40 [deprecated]           ...           a year ago
  • 1.0.39 [deprecated]           ...           a year ago
  • 1.0.38 [deprecated]           ...           a year ago
  • 1.0.36 [deprecated]           ...           a year ago
  • 1.0.35 [deprecated]           ...           a year ago
  • 1.0.34 [deprecated]           ...           a year ago
  • 1.0.33 [deprecated]           ...           a year ago
  • 1.0.32 [deprecated]           ...           a year ago
  • 1.0.31 [deprecated]           ...           a year ago
  • 1.0.30 [deprecated]           ...           a year ago
  • 1.0.29 [deprecated]           ...           a year ago
  • 1.0.28 [deprecated]           ...           a year ago
  • 1.0.27 [deprecated]           ...           a year ago
  • 1.0.26 [deprecated]           ...           a year ago
  • 1.0.25 [deprecated]           ...           a year ago
  • 1.0.21 [deprecated]           ...           a year ago
  • 1.0.20 [deprecated]           ...           a year ago
  • 1.0.19 [deprecated]           ...           a year ago
  • 1.0.18 [deprecated]           ...           a year ago
  • 1.0.17 [deprecated]           ...           a year ago
  • 1.0.16 [deprecated]           ...           a year ago
  • 1.0.15 [deprecated]           ...           a year ago
  • 1.0.14 [deprecated]           ...           a year ago
  • 1.0.13 [deprecated]           ...           a year ago
  • 1.0.12 [deprecated]           ...           a year ago
  • 1.0.11 [deprecated]           ...           a year ago
  • 1.0.10 [deprecated]           ...           a year ago
  • 1.0.9 [deprecated]           ...           a year ago
  • 1.0.8 [deprecated]           ...           a year ago
  • 1.0.7 [deprecated]           ...           a year ago
  • 1.0.6 [deprecated]           ...           a year ago
  • 1.0.5 [deprecated]           ...           a year ago
  • 1.0.4 [deprecated]           ...           a year ago
  • 1.0.3 [deprecated]           ...           a year ago
  • 1.0.2 [deprecated]           ...           a year ago
Downloads
Today 0
This Week 0
This Month 117
Last Day 0
Last Week 117
Last Month 0
Dependencies (15)
Dev Dependencies (11)
Dependents (1)

Copyright 2014 - 2017 © taobao.org |