Skip to content

Commit

Permalink
feat: cleanup (#1)
Browse files Browse the repository at this point in the history
Co-authored-by: splincode <>
  • Loading branch information
splincode authored Jun 30, 2023
1 parent d4ad61b commit be6f24b
Show file tree
Hide file tree
Showing 94 changed files with 26,732 additions and 42,536 deletions.
13 changes: 11 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,20 @@
module.exports = {
root: true,
extends: [
'@tinkoff/eslint-config',
'@tinkoff/eslint-config-angular',
'@tinkoff/eslint-config-angular/html',
'@tinkoff/eslint-config-angular/rxjs',
'@tinkoff/eslint-config-angular/imports',
],
ignorePatterns: [
'projects/**/test.ts',
'*.json',
'*.less',
'*.md',
'*.js',
'jest.config.ts',
'setup-jest.ts',
],
ignorePatterns: ['projects/**/test.ts', '*.json', '*.less', '*.md', '*.js'],
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 2020,
Expand Down
43 changes: 0 additions & 43 deletions .github/workflows/e2e.yml

This file was deleted.

4 changes: 1 addition & 3 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
legacy-peer-deps=true
engine-strict=false
lockfileVersion=2
engine-strict=false
ignore-engines=true
loglevel=error
95 changes: 1 addition & 94 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,94 +1 @@
# Angular Open-source Starter

[![Deploy](https://github.com/Tinkoff/angular-open-source-starter/actions/workflows/deploy.yml/badge.svg)](https://github.com/Tinkoff/angular-open-source-starter/actions/workflows/deploy.yml)
[![Unit tests](https://github.com/Tinkoff/angular-open-source-starter/actions/workflows/test.yml/badge.svg)](https://github.com/Tinkoff/angular-open-source-starter/actions/workflows/test.yml)
[![codecov](https://codecov.io/gh/Tinkoff/angular-open-source-starter/branch/main/graph/badge.svg?token=KfV90T6KkK)](https://codecov.io/gh/Tinkoff/angular-open-source-starter)
[![Demo](https://img.shields.io/badge/demo-website-green)](https://tinkoff.github.io/angular-open-source-starter/)

## How to use

> This is a starter project for creating open-source libraries for Angular. It is a full-fledged Angular workspace with
> demo application and easy library addition. It is designed to be used for open-sourcing libraries on GitHub and has
> everything you'd need ready for CI, code coverage, SSR testing, StackBlitz demo deployment and more.
1. Run `npm ci` to install everything

2. Use search to replace all mentions of `angular-open-source-starter` with your new library name (`npmScope` inside
`nx.json`, matadata of the root `package.json`, root `README.md` etc.)

3. Create basic file structure via [Nx-generators](https://nx.dev/plugin-features/use-code-generators):

- `nx g @nrwl/js:library [your-library-name]` - create Typescript library. See
[available options](https://nx.dev/packages/js/generators/library#options).
- `nx g @nrwl/angular:library [your-library-name]` - create Angular library. See
[available options](https://nx.dev/packages/angular/generators/library#options).

4. Fill in `projects/[your-library-name]/package.json` metadata for your newly generated library

5. Add your email at [INSERT YOUR EMAIL HERE] in `CODE_OF_CONDUCT.md`

6. Update `LICENSE` file according to your preferences

7. Update root `package.json` metadata to represent your project

8. Code your library and create demo for it

## Cool features

- [x] Versioning is ready for you with following simple commands:

```json
{
"release": "standard-version",
"release:patch": "npm run release -- --release-as patch",
"release:minor": "npm run release -- --release-as minor",
"release:major": "npm run release -- --release-as major",
"publish": "nx run-many --target build --all --exclude=demo && nx run-many --target publish --all"
}
```

Just use [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0-beta.4/) format and `CHANGELOG.md` will be
automatically generated on releases by
[Standard Version](https://github.com/conventional-changelog/standard-version#standard-version).

- [x] This project has Angular Universal — you can easily test your library with SSR and Prerender:

`npm run serve:dev:ssr` or `npm run build:prerender && npm run serve:prerender`

- [x] CI and code coverage are ready, GitHub Action checks that packages build, test and lint correctly. It also sends
test results to [Codecov](https://about.codecov.io).

- [x] Precommit checks, prettier, linter and all that jazz is there.

- [x] You can also deploy your demo to [StackBlitz](https://stackblitz.com) with no hustle, just use link in the
following format:

https://stackblitz.com/github/[User|Organization]/[Repository]/tree/main/projects/demo

- [x] You can add more libraries using the same [Nx-generators](https://nx.dev/plugin-features/use-code-generators) to
create a whole Angular Workspace with multiple libraries. Versioning and publishing is configured that they are
released simultaneously like Angular packages.

## Infrastructure

- [x] GitHub Actions
- [x] Node.js 16+, npm 8+
- [x] Angular 12+
- [x] TypeScript 4+
- [x] Prettier 2.6+
- [x] Stylelint 14+
- [x] ESLint 7+
- [x] Husky 7+
- [x] Cypress 10+
- [x] Jest 27+
- [x] Nx 13+

## Badge

Show that your project is based off of our starter

[![angular-open-source-starter](https://img.shields.io/badge/made%20with-angular--open--source--starter-d81676?logo=angular)](https://github.com/Tinkoff/angular-open-source-starter)

```md
[![angular-open-source-starter](https://img.shields.io/badge/made%20with-angular--open--source--starter-d81676?logo=angular)](https://github.com/Tinkoff/angular-open-source-starter)
```
# TUI Editor
7 changes: 0 additions & 7 deletions angular.json

This file was deleted.

156 changes: 156 additions & 0 deletions jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
import {Config} from 'jest';
import {resolve} from 'path';
import {pathsToModuleNameMapper} from 'ts-jest';

process.env.TZ = `Europe/Moscow`;
process.env.FORCE_COLOR = `true`;
process.env.TS_JEST_DISABLE_VER_CHECKER = `true`;

const {compilerOptions} = require(resolve(__dirname, `tsconfig.json`));
const maxParallel = require(`os`).cpus().length / 2;

module.exports = {
rootDir: __dirname,

/**
* The preset sets up the environment and is very opinionated
* and based on what we found to be useful at Facebook.
* All of the configuration options can be overwritten
* just as they can be customized when no preset is used.
*/
preset: `jest-preset-angular`,

/**
* The test environment that will be used for testing.
* The default environment in Jest is a Node.js environment.
* If you are building a web app, you can use a browser-like environment through jsdom instead.
*/
testEnvironment: `jsdom`,

/**
* A set of global variables that need
* to be available in all test environments.
*/
globals: {
'ts-jest': {
tsconfig: resolve(__dirname, `tsconfig.spec.json`),
isolatedModules: true,
},
},

/**
* Jest will run .mjs and .js files with nearest package.json's type
* field set to module as ECMAScript Modules. If you have any other files
* that should run with native ESM, you need to specify their file extension here.
*/
extensionsToTreatAsEsm: [`.ts`],

/**
* A list of paths to modules that run some code to configure
* or to set up the testing framework before each test.
*/
setupFilesAfterEnv: [`<rootDir>/setup-jest.ts`],

/**
* A map from regular expressions to paths to transformers.
*/
transform: {'^.+\\.(ts|js|mjs|html|svg)$': `jest-preset-angular`},

/**
* The glob patterns Jest uses to detect test files.
*/
testMatch: [`<rootDir>/projects/**/*.spec.ts`],

/**
* A single or array of regexp pattern strings that are tested
* against all tests paths before executing the test.
*/
testPathIgnorePatterns: [`/demo-integrations/`, `/node_modules/`, `/schematics/`],

/**
* The directory where Jest should output its coverage files.
*/
coverageDirectory: `<rootDir>/coverage`,

/**
* An array of glob patterns indicating a set of files for which coverage
* information should be collected. If a file matches the specified glob pattern,
* coverage information will be collected for it even if no tests exist for this file and
* it's never required in the test suite.
*/
collectCoverageFrom: [`<rootDir>/projects/**/*.ts`],

/**
* An array of regexp pattern strings that are matched against
* all file paths before executing the test. If the file path matches
* any of the patterns, coverage information will be skipped.
*/
coveragePathIgnorePatterns: [
`node_modules`,
`schematics`,
`load-assets.ts`,
`.spec.ts`,
`.cy.ts`,
],

/**
* A map from regular expressions to module names that allow to stub out resources,
* like images or styles with a single module. Modules that are mapped to an alias are
* un mocked by default, regardless of whether auto mocking is enabled or not.
* Use <rootDir> string token to refer to rootDir value if you want to use file paths.
* Additionally, you can substitute captured regex groups using numbered back references.
*/
moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths, {
prefix: `<rootDir>/${compilerOptions.baseUrl}/`
.replace(/\.\//g, `/`)
.replace(/\/\/+/g, `/`),
}),

/**
* An array of regexp pattern strings that are matched against all module paths before those
* paths are to be considered 'visible' to the module loader. If a given module's path
* matches any of the patterns, it will not be require()-able in the test environment.
*/
modulePathIgnorePatterns: [`.cache`, `dist`, `<rootDir>/dist/`],

/**
* A list of reporter names that Jest uses when writing coverage reports.
* Any istanbul reporter can be used.
*/
coverageReporters: [`text`, `lcov`, `clover`],

/**
* The directory where Jest should store its cached dependency information.
*/
cacheDirectory: `<rootDir>/node_modules/.cache/jest`,
/**
* A number limiting the number of tests that are allowed to run at the same time when
* using test.concurrent. any test above this limit will be queued and executed once
* a slot is released.
*/
maxConcurrency: maxParallel,

/**
* Specifies the maximum number of workers the worker-pool will spawn for running tests.
* In single run mode, this defaults to the number of the cores available
* on your machine minus one for the main thread.
*/
maxWorkers: maxParallel,

/**
* Display individual test results with the test suite hierarchy.
*/
verbose: true,

/**
* By default, Jest runs all tests and produces all errors into the console upon completion.
* The bail config option can be used here to have Jest stop running tests after n failures.
* Setting bail to true is the same as setting bail to 1
*/
bail: 1,

/**
* Run tests with specified reporters
*/
reporters: [`default`],
} as unknown as Config;
16 changes: 14 additions & 2 deletions jest.preset.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
const nxPreset = require('@nrwl/jest/preset');
const nxPreset = require('@nx/jest/preset').default;

module.exports = {...nxPreset};
module.exports = {
...nxPreset,
/* TODO: Update to latest Jest snapshotFormat
* By default Nx has kept the older style of Jest Snapshot formats
* to prevent breaking of any existing tests with snapshots.
* It's recommend you update to the latest format.
* You can do this by removing snapshotFormat property
* and running tests with --update-snapshot flag.
* Example: "nx affected --targets=test --update-snapshot"
* More info: https://jestjs.io/docs/upgrading-to-jest29#snapshot-format
*/
snapshotFormat: {escapeString: true, printBasicPrototype: true},
};
Loading

0 comments on commit be6f24b

Please sign in to comment.