├── .editorconfig
├── .eslintignore
├── .eslintrc.js
├── .gitignore
├── .npmrc
├── LICENSE.md
├── README.md
├── api-extractor.json
├── art
└── logo.png
├── index.js
├── jest.config.js
├── package.json
├── rollup.config.js
├── scripts
├── build.js
└── release.sh
├── src
└── index.ts
├── tests
└── foo.test.ts
├── tsconfig.json
└── yarn.lock
/.editorconfig:
--------------------------------------------------------------------------------
1 | root = true
2 |
3 | [*]
4 | end_of_line = lf
5 | insert_final_newline = true
6 | indent_style = space
7 | indent_size = 2
8 |
9 | [*.{js}]
10 | charset = utf-8
11 |
--------------------------------------------------------------------------------
/.eslintignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | dist
3 | coverage
4 |
--------------------------------------------------------------------------------
/.eslintrc.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | plugins: ["functional", "sonarjs", "simple-import-sort", "promise"],
3 | extends: [
4 | "algolia/jest",
5 | "algolia/typescript",
6 | "plugin:functional/recommended",
7 | "plugin:sonarjs/recommended",
8 | "plugin:promise/recommended"
9 | ],
10 | rules: {
11 | "eslint-comments/disable-enable-pair": ["error", {"allowWholeFile": true}],
12 | "simple-import-sort/sort": "error",
13 | "max-len": [1, 120, 2, { ignoreComments: true }],
14 | "prettier/prettier": [
15 | "error",
16 | {
17 | trailingComma: "es5",
18 | singleQuote: true,
19 | printWidth: 100
20 | }
21 | ],
22 | "object-shorthand": [
23 | "error",
24 | "always",
25 | { avoidExplicitReturnArrows: true }
26 | ],
27 | "lines-between-class-members": ["error", "always"],
28 | "newline-before-return": ["error"],
29 | "import/no-extraneous-dependencies": [
30 | "error",
31 | { packageDir: "./", devDependencies: true }
32 | ],
33 | "import/extensions": ["off"],
34 | "valid-jsdoc": ["off"],
35 | "functional/no-expression-statement": ["off"],
36 | "functional/no-conditional-statement": ["off"],
37 | "functional/no-throw-statement": ["off"],
38 | "functional/no-mixed-type": ["off"],
39 | "promise/always-return": ["off"],
40 | "functional/functional-parameters": ["off"],
41 | "functional/no-return-void": ["off"],
42 | "@typescript-eslint/no-triple-slash-reference": ["off"]
43 | },
44 | settings: {
45 | "import/resolver": {
46 | alias: {
47 | map: [
48 | ["package-name", "./src"]
49 | ],
50 | extensions: [".ts"]
51 | },
52 | node: {
53 | extensions: [".ts"]
54 | }
55 | }
56 | },
57 | overrides: [
58 | {
59 | files: ["./tests/**", "./scripts/**"],
60 | rules: {
61 | "functional/immutable-data": 0,
62 | "import/no-extraneous-dependencies": 0,
63 | "functional/no-let": 0,
64 | "functional/no-this-expression": 0,
65 | "functional/no-loop-statement": 0,
66 | "functional/no-try-statement": 0,
67 | "@typescript-eslint/explicit-function-return-type": 0,
68 | "functional/prefer-readonly-type": 0,
69 | "sonarjs/no-duplicate-string": 0,
70 | "jest/expect-expect": 0
71 | }
72 | }
73 | ]
74 | };
75 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | coverage
3 | node_modules
4 | dist
5 | .vscode
6 | *.test.ts.snap
7 |
--------------------------------------------------------------------------------
/.npmrc:
--------------------------------------------------------------------------------
1 | //registry.npmjs.org/:_authToken=${NPM_TOKEN}
2 |
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) Nuno Maduro
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in
13 | all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | THE SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
The perfect starting point to ...
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 | ## About package-name
18 |
19 | package-name was created by, and is maintained by [Nuno Maduro](https://github.com/nunomaduro), and is ....
20 |
21 | ## Installation & Usage
22 |
23 | First, install package-name via the npm package manager:
24 |
25 | ```bash
26 | yarn add package-name
27 | ```
28 |
29 | ## Contributing
30 |
31 | Thank you for considering to contribute to package-name. All the contribution guidelines are mentioned [here](CONTRIBUTING.md).
32 |
33 | You can have a look at the [CHANGELOG](CHANGELOG.md) for constant updates & detailed information about the changes. You can also follow the twitter account for latest announcements or just come say hi!: [@enunomaduro](https://twitter.com/enunomaduro)
34 |
35 | ## Support the development
36 | **Do you like this project? Support it by donating**
37 |
38 | - PayPal: [Donate](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=66BYDWAT92N6L)
39 | - Patreon: [Donate](https://www.patreon.com/nunomaduro)
40 |
41 | ## License
42 |
43 | package-name is an open-sourced software licensed under the [MIT license](LICENSE.md).
44 |
--------------------------------------------------------------------------------
/api-extractor.json:
--------------------------------------------------------------------------------
1 | {
2 | "mainEntryPointFilePath": "./dist/src/index.d.ts",
3 |
4 | "dtsRollup": {
5 | "untrimmedFilePath": "./dist/package-name.d.ts"
6 | },
7 |
8 | "$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
9 |
10 | "apiReport": {
11 | "enabled": false,
12 | },
13 |
14 | "docModel": {
15 | "enabled": false
16 | },
17 |
18 | "dtsRollup": {
19 | "enabled": true
20 | },
21 |
22 | "tsdocMetadata": {
23 | "enabled": false
24 | },
25 |
26 | "messages": {
27 | "compilerMessageReporting": {
28 | "default": {
29 | "logLevel": "warning"
30 | }
31 | },
32 |
33 | "extractorMessageReporting": {
34 | "default": {
35 | "logLevel": "warning",
36 | "addToApiReportFile": true
37 | },
38 |
39 | "ae-missing-release-tag": {
40 | "logLevel": "none"
41 | }
42 | },
43 |
44 | "tsdocMessageReporting": {
45 | "default": {
46 | "logLevel": "warning"
47 | }
48 | }
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/art/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nunomaduro/skeleton-js/eda1a40807a01be8486d7d7396e172a9b54c8547/art/logo.png
--------------------------------------------------------------------------------
/index.js:
--------------------------------------------------------------------------------
1 | // eslint-disable-next-line functional/immutable-data, import/no-commonjs
2 | module.exports = require('./dist/package-name.cjs.js');
3 |
--------------------------------------------------------------------------------
/jest.config.js:
--------------------------------------------------------------------------------
1 | /* eslint-disable import/no-commonjs, functional/immutable-data */
2 | const { pathsToModuleNameMapper } = require('ts-jest/utils');
3 |
4 | const { compilerOptions } = require('./tsconfig');
5 |
6 | const config = {
7 | testMatch: ['**/tests/**/*.test.ts'],
8 | preset: 'ts-jest',
9 | transform: { '^.+\\.ts?$': 'ts-jest' },
10 | moduleFileExtensions: ['js', 'ts'],
11 | moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths, {
12 | prefix: '/',
13 | }),
14 | transformIgnorePatterns: [],
15 | coverageReporters: ['text'],
16 | collectCoverage: true,
17 | collectCoverageFrom: ['**/src/**/*.ts', '!**/tests/**/*.ts'],
18 | coverageThreshold: {
19 | global: {
20 | branches: 100,
21 | functions: 100,
22 | lines: 100,
23 | statements: 100,
24 | },
25 | },
26 | };
27 |
28 | module.exports = {
29 | projects: [
30 | Object.assign(
31 | {
32 | displayName: 'browser',
33 | testEnvironment: 'jsdom',
34 | testPathIgnorePatterns: [
35 | // ignored paths
36 | ],
37 | },
38 | config
39 | ),
40 | Object.assign(
41 | {
42 | displayName: 'node',
43 | testEnvironment: 'node',
44 | testPathIgnorePatterns: [
45 | // ignored paths
46 | ],
47 | },
48 | config
49 | ),
50 | ],
51 | };
52 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "package-name",
3 | "version": "0.0.0",
4 | "description": "Package description",
5 | "license": "MIT",
6 | "files": [
7 | "index.js",
8 | "dist"
9 | ],
10 | "sideEffects": false,
11 | "main": "index.js",
12 | "module": "dist/package-name.esm.js",
13 | "types": "dist/package-name.d.ts",
14 | "scripts": {
15 | "build": "node --max-old-space-size=4096 scripts/build.js",
16 | "lint": "eslint . --ext .js,.ts --fix && sort-package-json",
17 | "pre-commit": "yarn test:lint && yarn test:types",
18 | "release": "./scripts/release.sh",
19 | "release:publish": "npm publish --verbose --publish --access public",
20 | "test:lint": "eslint . --ext .js,.ts",
21 | "test:locally": "yarn lint && yarn test:types && yarn test:unit",
22 | "test:size": "bundlesize",
23 | "test:types": "yarn tsc",
24 | "test:unit": "jest --verbose --updateSnapshot",
25 | "update": "rm -rf node_modules && rm -f yarn.lock && yarn install"
26 | },
27 | "husky": {
28 | "hooks": {
29 | "pre-commit": "yarn pre-commit"
30 | }
31 | },
32 | "devDependencies": {
33 | "@babel/cli": "^7.6.0",
34 | "@babel/core": "^7.6.0",
35 | "@babel/preset-env": "^7.4.5",
36 | "@babel/preset-typescript": "^7.6.0",
37 | "@microsoft/api-extractor": "^7.5.2",
38 | "@rollup/plugin-json": "^4.0.0",
39 | "@types/jest": "^24.0.18",
40 | "@types/node": "^13.1.4",
41 | "@typescript-eslint/eslint-plugin": "^2.2.0",
42 | "@typescript-eslint/parser": "^2.2.0",
43 | "bundlesize": "^0.18.0",
44 | "eslint": "^6.2.2",
45 | "eslint-config-algolia": "^15.0.0",
46 | "eslint-config-prettier": "^6.1.0",
47 | "eslint-import-resolver-alias": "^1.1.2",
48 | "eslint-plugin-eslint-comments": "^3.1.2",
49 | "eslint-plugin-functional": "^2.0.0",
50 | "eslint-plugin-import": "^2.18.2",
51 | "eslint-plugin-jest": "^23.0.4",
52 | "eslint-plugin-prettier": "^3.1.2",
53 | "eslint-plugin-promise": "^4.2.1",
54 | "eslint-plugin-simple-import-sort": "^5.0.0",
55 | "eslint-plugin-sonarjs": "^0.5.0",
56 | "fs-extra": "^8.1.0",
57 | "husky": "^3.0.4",
58 | "jest": "^24.9.0",
59 | "prettier": "^1.18.2",
60 | "rollup": "^1.20.3",
61 | "rollup-plugin-babel": "^4.3.3",
62 | "rollup-plugin-commonjs": "^10.1.0",
63 | "rollup-plugin-filesize": "6.0.1",
64 | "rollup-plugin-ignore": "^1.0.5",
65 | "rollup-plugin-node-globals": "^1.4.0",
66 | "rollup-plugin-terser": "^5.1.2",
67 | "rollup-plugin-typescript2": "^0.25.2",
68 | "sort-package-json": "^1.23.1",
69 | "ts-jest": "^24.0.2",
70 | "ts-node": "^8.3.0",
71 | "typescript": "^3.5.2"
72 | },
73 | "engines": {
74 | "node": ">= 8.0.0",
75 | "yarn": ">= 1.6.0"
76 | },
77 | "bundlesize": [
78 | {
79 | "path": "dist/package-name.umd.js",
80 | "maxSize": "1.0KB"
81 | }
82 | ]
83 | }
84 |
--------------------------------------------------------------------------------
/rollup.config.js:
--------------------------------------------------------------------------------
1 | /* eslint-disable import/no-commonjs, functional/immutable-data, functional/no-let */
2 |
3 | import json from '@rollup/plugin-json';
4 | import path from 'path';
5 | import babel from 'rollup-plugin-babel';
6 | import filesize from 'rollup-plugin-filesize';
7 | import ignore from 'rollup-plugin-ignore';
8 | import globals from 'rollup-plugin-node-globals';
9 | import { terser } from 'rollup-plugin-terser';
10 | import ts from 'rollup-plugin-typescript2';
11 |
12 | const version = require('./package.json').version;
13 | const copyright = '© Nuno Maduro.';
14 | const link = 'https://github.com/nunomaduro/package-name';
15 | const createLicence = name => {
16 | return `/*! ${name} | ${version} | ${copyright} | ${link} */`;
17 | };
18 |
19 | const builds = [
20 | { file: `package-name.esm.js`, format: `es` },
21 | { file: `package-name.cjs.js`, format: `cjs` },
22 | { file: `package-name.umd.js`, format: `umd` },
23 | ];
24 |
25 | const babelConfig = {
26 | babelrc: false,
27 | extensions: ['.ts'],
28 | presets: [
29 | [
30 | '@babel/preset-env',
31 | {
32 | modules: false,
33 | targets: {
34 | browsers: ['last 2 versions', 'ie >= 11'],
35 | },
36 | },
37 | ],
38 | ],
39 | };
40 |
41 | export default builds.map(build => {
42 | const output = build;
43 |
44 | const isUmdBuild = /\.umd.js$/.test(output.file);
45 |
46 | if (isUmdBuild) {
47 | output.name = 'copyrightsearch';
48 | output.banner = createLicence(output.file);
49 | }
50 |
51 | output.file = `dist/${output.file}`;
52 |
53 | let dependencies = require('./package.json').dependencies;
54 |
55 | if (isUmdBuild || dependencies === undefined) {
56 | dependencies = [];
57 | }
58 |
59 | return {
60 | input: 'src/index.ts',
61 | external: [], // external dependencies, if any
62 | plugins: [
63 | json({ namedExports: false }),
64 | globals({ global: true }),
65 | ignore([]), // external dependencies to ignore, if any.
66 | ts({
67 | check: true,
68 | tsconfig: path.resolve(__dirname, 'tsconfig.json'),
69 | cacheRoot: path.resolve(__dirname, 'node_modules/.rts2_cache'),
70 | tsconfigOverride: {
71 | include: ['src/**/*.ts'],
72 | exclude: ['tests/**'],
73 | compilerOptions: {
74 | declaration: true,
75 | declarationMap: true,
76 | },
77 | },
78 | }),
79 | // we apply babel on browser builds
80 | ...(isUmdBuild ? [terser(), babel(babelConfig)] : []),
81 | filesize({
82 | showMinifiedSize: false,
83 | showGzippedSize: true,
84 | }),
85 | ],
86 | output,
87 | onwarn(msg, warn) {
88 | if (!/Circular/.test(msg)) {
89 | warn(msg);
90 | }
91 | },
92 | };
93 | });
94 |
--------------------------------------------------------------------------------
/scripts/build.js:
--------------------------------------------------------------------------------
1 | /* eslint-disable no-console, import/no-commonjs */
2 |
3 | const fs = require('fs-extra');
4 | const path = require('path');
5 | const chalk = require('chalk');
6 | const execa = require('execa');
7 |
8 | (async function run() {
9 | await fs.remove('./dist');
10 |
11 | await execa(`rollup`, ['-c'], { stdio: 'inherit' });
12 |
13 | console.log();
14 | console.log(chalk.bold(chalk.yellow(`Rolling up type definitions for package-name...`)));
15 |
16 | const { Extractor, ExtractorConfig } = require('@microsoft/api-extractor');
17 |
18 | const extractorConfigPath = path.resolve('./', 'api-extractor.json');
19 |
20 | const extractorConfig = ExtractorConfig.loadFileAndPrepare(extractorConfigPath);
21 | const result = Extractor.invoke(extractorConfig, {
22 | localBuild: true,
23 | showVerboseMessages: true,
24 | });
25 |
26 | if (result.succeeded) {
27 | console.log(chalk.bold(chalk.green(`API Extractor completed successfully.`)));
28 | } else {
29 | console.error(
30 | `API Extractor completed with ${result.errorCount} errors` +
31 | ` and ${result.warningCount} warnings`
32 | );
33 |
34 | process.exitCode = 1;
35 | }
36 |
37 | await fs.remove('./dist/src');
38 |
39 | console.log();
40 | })();
41 |
--------------------------------------------------------------------------------
/scripts/release.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | GREEN='\033[0;32m'
4 | RED='\e[31m'
5 | NC='\033[0m'
6 |
7 | printf "\n"
8 |
9 | set -e
10 |
11 | if [[ $npm_config_user_agent != npm* ]]; then
12 | echo "You ran this script differently than with 'npm run release'"
13 | exit 1
14 | fi
15 |
16 | printf "\n${GREEN}You are about the start a release process${NC}\n"
17 |
18 | printf "\n${RED}[ACTION]${NC} Changes on changelog are not part of this release process.\n"
19 | read -p "is the changelog modified and commited separately? If yes, are you sure? (y/n): "
20 | if [[ ! $REPLY =~ ^[Yy]$ ]]; then exit 1; fi
21 |
22 | releaseBranch='master'
23 | currentBranch=`git rev-parse --abbrev-ref HEAD`
24 |
25 | if [ "$currentBranch" != "$releaseBranch" ]; then
26 | printf "\n${RED}[ERROR]${NC} You must be on master.\n"
27 | exit 1
28 | fi
29 |
30 | changes=`echo $(git add . && git diff --cached --numstat | wc -l) | sed 's/ *$//g'`
31 |
32 | if [[ "$changes" != "0" ]]; then
33 | printf "\n${RED}[ERROR]${NC} Working tree is not clean.\n"
34 | exit 1
35 | fi
36 |
37 | printf "${GREEN}[INFO]${NC} Update working tree.\n"
38 | git pull origin $releaseBranch
39 | git fetch origin --tags
40 |
41 | currentVersion=`cat package.json | jq -r '.version'`
42 |
43 | printf "\n${RED}[ACTION]${NC} Checking CI status is an manual step! Check here: CI PATH\n"
44 | read -p "Is the latest commit a success? If yes, are you sure? (y/n): "
45 | if [[ ! $REPLY =~ ^[Yy]$ ]]; then exit 1; fi
46 |
47 | printf "\n${GREEN}[INFO]${NC} current version is ${GREEN}$currentVersion${NC}. Please type the new chosen version > "
48 | read -e newVersion
49 |
50 | printf "\n"
51 |
52 | if [[ "$newVersion" == "" ]]; then
53 | printf "\n${GREEN}[INFO]${NC} The version must be provided.\n"
54 | exit 1
55 | fi
56 |
57 | read -p "Releasing $newVersion - are you sure? (y/n): "
58 | if [[ ! $REPLY =~ ^[Yy]$ ]]; then exit 1; fi
59 |
60 | printf "\n"
61 |
62 | yarn version --new-version $newVersion --no-git-tag-version --no-push --exact
63 |
64 | git add package.json
65 |
66 | if [[ -n $(git diff --exit-code) ]]; then
67 | printf "\n${RED}[ERROR]${NC} there is unstaged files.\n"
68 | exit 1
69 | fi
70 |
71 | # build the dist
72 | yarn install --pure-lockfile
73 |
74 | if [[ -n $(git diff --exit-code) ]]; then
75 | printf "\n${RED}[ERROR]${NC} there is unstaged files.\n"
76 | exit 1
77 | fi
78 |
79 | yarn build
80 |
81 | if [[ -n $(git diff --exit-code) ]]; then
82 | printf "\n${RED}[ERROR]${NC} there is unstaged files.\n"
83 | exit 1
84 | fi
85 |
86 | printf "\n\n${GREEN}[INFO]${NC} almost done, check everything in another terminal tab if you want.\n"
87 | printf "\n\nAfter this, we are going to push changes, tag them, and publish the package to npm.\n"
88 | read -p "=> when ready, press [Y/y] to push to github and publish the package. (y/n): "
89 | if [[ ! $REPLY =~ ^[Yy]$ ]]; then exit 1; fi
90 |
91 | printf "\n${GREEN}[INFO]${NC} Committing changes"
92 | git commit -m "release: $newVersion"
93 |
94 | printf "\n${GREEN}[INFO]${NC} Creating tag and pushing it"
95 | git tag "v$newVersion"
96 | git push origin $releaseBranch
97 | git push origin --tags
98 |
99 | printf "\n${GREEN}[INFO]${NC} pushing package to NPM\n"
100 | npm run release:publish
101 |
102 | printf "\n${GREEN}[INFO]${NC} All done!\n\n"
103 |
--------------------------------------------------------------------------------
/src/index.ts:
--------------------------------------------------------------------------------
1 | export default 'foo';
2 |
--------------------------------------------------------------------------------
/tests/foo.test.ts:
--------------------------------------------------------------------------------
1 | import foo from 'package-name';
2 |
3 | describe('foo', () => {
4 | it('foo', () => expect(foo).toBe('foo'));
5 | });
6 |
--------------------------------------------------------------------------------
/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "baseUrl": ".",
4 | "outDir": "dist",
5 | "strict": true,
6 | "sourceMap": false,
7 | "target": "esnext",
8 | "module": "esnext",
9 | "moduleResolution": "node",
10 | "allowJs": false,
11 | "noUnusedLocals": true,
12 | "strictNullChecks": true,
13 | "noImplicitAny": true,
14 | "noImplicitThis": true,
15 | "experimentalDecorators": true,
16 | "resolveJsonModule": true,
17 | "esModuleInterop": true,
18 | "removeComments": false,
19 | "lib": ["esnext", "dom"],
20 | "types": ["jest", "node"],
21 | "rootDir": ".",
22 | "paths": {
23 | "package-name": ["src"]
24 | }
25 | },
26 | "include": ["src/**/*.ts", "tests/**/*.ts"]
27 | }
28 |
--------------------------------------------------------------------------------