Skip to content

Latest commit

 

History

History
120 lines (86 loc) · 3.63 KB

CONTRIBUTING.md

File metadata and controls

120 lines (86 loc) · 3.63 KB

Starlay utilities

Scripts

The following npm scripts are made available to you in the project root. You can run each of them with npm run <script-name>.

If you want to limit the scope of a script to a particular package, add the --scope option to the command (e.g., npm run clean -- --scope=@starlay/math-utils). See run options.

You can also run Lerna commands in this project. It is recommended that you use npx to run these commands (i.e., npx lerna <command>).

clean

Supports run options.

Clean coverage results in ./coverage and runs npm run clean for each package.

lint

Supports run options.

Runs ESLint for each package.

check-types

Supports run options.

Runs the TypeScript compiler for each package without emitting any files. This is used in a pre-push hook for a faster alternative than a full build, so you probably won't want to run it directly.

build

Supports run options.

Runs the TypeScript compiler for each package.

test

Runs Jest in watch mode, which attempts to run only on changed files.

This command doesn't support --scope, but you can narrow the test run by adding filename (path) filters in as many ...args that follow (e.g., npm test core/src).

cover

Runs Jest in coverage mode, dumping coverage results in ./coverage and showing a text summary in the console output.

Feel free to add more coverage reporters to the list. The Jest configuration can be found in the root package.json.

commit

Runs Commitizen commit wizard, ensuring that your commit messages conform to Conventional Commits.

Use the git commit command directly with the -n, --no-verify option to bypasses the pre-commit and commit-msg hooks.

Setup a new package

When we setup a new package you just need to create a new folder in packages and do npm init and tsc --init. In the tsconfig paste:

{
  "extends": "../../tsconfig.json",
  "compilerOptions": {
    "outDir": "./dist/esm",
    "rootDir": "src"
  }
}

In the package.json copy these scripts and replace YOUR_PACKAGE_NAME with your package name

"scripts": {
    "clean": "cd ../.. && npx rimraf packages/YOUR_PACKAGE_NAME/dist packages/math-utils/*.log*",
    "lint": "cd ../.. && eslint packages/YOUR_PACKAGE_NAME/src/**/*.ts",
    "check-types": "yarn build -- --noEmit",
    "prebuild": "yarn clean",
    "build": "cd ../.. && tsc -p packages/YOUR_PACKAGE_NAME/tsconfig.json && tsc -p packages/YOUR_PACKAGE_NAME/tsconfig.json --module commonjs --outDir ./packages/YOUR_PACKAGE_NAME/dist/cjs",
    "test": "cd ../.. && yarn test packages/YOUR_PACKAGE_NAME",
    "cover": "cd ../.. && yarn cover packages/YOUR_PACKAGE_NAME",
    "commit": "cd ../.. && yarn commit",
    "prepublishOnly": "yarn build"
  },

also in the package.json paste these in:

"main": "./dist/cjs/index.js",
"module": "./dist/esm/index.js",
"types": "./dist/esm/index.d.ts",

Thats it now start writing your logic, you must write your typescript code in the src folder in your package.