0.21.2 • Published 3 years ago

ts-deps v0.21.2

Weekly downloads
279
License
MIT
Repository
github
Last release
3 years ago

Installation

npm add ts-deps --save-dev
npx ts-deps init

The init command will scaffold config files for your project. The typical output would be:

scripts/
scripts/build.js
scripts/clean.js
scripts/combineCoverage.js
src/
src/__integration-tests__
src/__tests__
.eslintrc.js
babel.config.js
commitlint.config.js
jest.config.integration.js
jest.config.js
package.json
prettier.config.js
release.config.js
tsconfig.json
tsconfig.declarations.json

Following packages already included for you:

The init command can be run on an existing project, it will change your package.json and remove superfluous dev dependencies.

Building your code

All the source code should be located in src directory. Extensions for the code should be .ts or .js. You can add // @ts-check in the beginning of .js files to make TypeScript check those files as well.

For a Web app, please consider using create-react-app, however, .tsx and .jsx extensions are still allowed, but not well-tested.

npm build

The code will be transformed by Babel and put into lib folder. In addition to that .json and .d.ts files are copied over as well.

Declarations

If declarations are required, we can generate them by running:

npm run declarations

This will use tsconfig.declarations.json config to write declarations to the same lib folder as transformed .js or .ts files.

Checking your code

To run all builds and compilation checks we can use the check command which is automatically executed by husky on push.

npm run check

The build and other commands listed below are included into check.

So, to check your code for Type Script errors we can run:

npm run type-check

Linting:

npm run lint

Aliases

Current configuration supports aliases. Sometimes we need to be able to alias a path to a module in order to require it by that alias name like so:

import { db } from '@shared'

The above becomes possible with aliases. The setup of aliases is tedious and requires multiple configuration changes that span across Babel, TypeScript and Jest.

With ts-deps it should be as simple as creating a ts-deps.config.js file at the root of your project and executing ts-deps patch to patch tsconfig.json:

module.exports = {
  aliases: {
    '@core-lib': './src/shared/core-lib',
    '@feature-1': './src/shared/features/feature-1',
  },
}

In the above example, in order to reference files within core-lib directory we can just use:

import Module from '@core-lib'

That saves us from having to backward slash to that directory if we have a module in feature-1 directory that requires it.

Testing

The library supports two categories of tests: unit-tests and integration-tests.

Unit tests should be located within __tests__ directory anywhere under src directory. Deep nesting is supported. Every test should have .test. suffix. This is to ensure that the tests can also have test-only related helper files that can be required by the test but not included into result of build.

Integration tests should be located within ./src/__integration-tests__ at the root. Similarly, every test should have .test. suffix.

Integration and unit tests can be ran separately. If integration tests generate any coverage information we can combine it with unit tests using combine-coverage script.

npm run test --coverage
npm run integration --coverage
npm run combine-coverage

Release

To use semantic-release for release process we could run:

npm run release

To setup follow the link at the top and follow the steps in documentation. With current config we only need to declare environment variables to make semantic-release push changes to GitHub Releases, git repo and npm.

export GH_TOKEN=
export NPM_TOKEN=
export GIT_AUTHOR_EMAIL=
export GIT_AUTHOR_NAME=
export GIT_COMMITTER_EMAIL=
export GIT_COMMITTER_NAME

Happy coding!

0.21.2

3 years ago

0.21.1

3 years ago

0.21.0

3 years ago

0.21.1-alpha.1

3 years ago

0.20.0

3 years ago

0.19.4

3 years ago

0.19.3

4 years ago

0.19.2

4 years ago

0.19.1

4 years ago

0.19.0

4 years ago

0.18.4

4 years ago

0.18.3

4 years ago

0.18.2

4 years ago

0.18.1

4 years ago

0.18.0

4 years ago

0.17.0

4 years ago

0.16.0

4 years ago

0.16.0-alpha.4

4 years ago

0.16.0-alpha.3

4 years ago

0.16.0-alpha.1

4 years ago

0.16.0-alpha.2

4 years ago

0.15.9

4 years ago

0.15.9-alpha.2

4 years ago

0.15.9-alpha.1

4 years ago

0.15.8

4 years ago

0.15.7

4 years ago

0.15.6

4 years ago

0.15.5

4 years ago

0.15.4

4 years ago

0.15.1

4 years ago

0.15.2

4 years ago

0.15.3

4 years ago

0.15.0

4 years ago

0.14.0

4 years ago

0.14.0-alpha.2

4 years ago

0.14.0-alpha.1

4 years ago

0.13.0

4 years ago

0.12.13

4 years ago

0.12.12

4 years ago

0.12.10

4 years ago

0.12.11

4 years ago

0.12.9

4 years ago

0.13.0-alpha.8

4 years ago

0.13.0-alpha.7

4 years ago

0.13.0-alpha.6

4 years ago

0.13.0-alpha.5

4 years ago

0.13.0-alpha.4

4 years ago

0.13.0-alpha.3

4 years ago

0.13.0-alpha.2

4 years ago

0.13.0-alpha.1

4 years ago

0.12.7

4 years ago

0.12.8

4 years ago

0.12.6

4 years ago

0.12.5

4 years ago

0.12.2

4 years ago

0.12.3

4 years ago

0.12.4

4 years ago

0.12.1

4 years ago

0.12.0

4 years ago

0.11.1

4 years ago

0.11.0

4 years ago

0.10.0

4 years ago

0.10.0-alpha.6

4 years ago

0.10.0-alpha.5

4 years ago

0.10.0-alpha.4

4 years ago

0.10.0-alpha.3

4 years ago

0.10.0-alpha.2

4 years ago

0.10.0-alpha.1

4 years ago

0.9.1-alpha.1

4 years ago

0.9.0

4 years ago

0.8.1

4 years ago

0.8.0

4 years ago

0.8.0-alpha.1

4 years ago

0.7.0

4 years ago

0.6.0

5 years ago

0.5.0

5 years ago

0.4.4

5 years ago

0.4.3

5 years ago

0.4.2

5 years ago

0.4.1

5 years ago

0.4.1-alpha.1

5 years ago

0.4.0

5 years ago

0.3.7

5 years ago

0.3.6

5 years ago

0.3.5

5 years ago

0.3.4

5 years ago

0.3.3

5 years ago

0.3.2

5 years ago

0.3.1

5 years ago

0.3.0

5 years ago

0.3.0-master.2

5 years ago

0.3.0-master.1

5 years ago

0.2.5

5 years ago

0.2.4

5 years ago

0.2.3

5 years ago

0.2.2

5 years ago

0.2.1

5 years ago

0.2.0

5 years ago

0.1.0

5 years ago

0.0.1

5 years ago