diff --git a/.github/workflows/node.yml b/.github/workflows/node.yml new file mode 100644 index 0000000000..62bfc7a445 --- /dev/null +++ b/.github/workflows/node.yml @@ -0,0 +1,26 @@ +# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node +# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions + +name: Node CI + +on: + pull_request: + +jobs: + build: + + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [10.x, 12.x, 14.x] + + steps: + - uses: actions/checkout@v2 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node-version }} + - run: npm i + - run: npm run build --if-present + - run: npm test diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000000..5172a98704 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,58 @@ +# This workflow will run tests using node and then publish a package to NPM and GitHub Packages when a release is created +# For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages + +#name: Publish Packages +# +#on: +# push: +# branches: [ eleven ] +#jobs: +# build: +# runs-on: ubuntu-latest +# steps: +# - uses: actions/checkout@v2 +# - uses: actions/setup-node@v1 +# with: +# node-version: 12 +# - run: npm ci +# - run: npm test +# +# publish-npm: +# needs: build +# runs-on: ubuntu-latest +# steps: +# - uses: actions/checkout@v2 +# with: +# fetch-depth: 0 +# - uses: actions/setup-node@v1 +# with: +# node-version: 12 +# registry-url: https://registry.npmjs.org/ +# - run: npm ci +# - run: git config user.email "NEED AUTHORISED EMAIL" +# - run: git config user.name ${{ github.actor }} +# - run: npm run postinstall +# - run: npm run publish:lerna +# env: +# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} +# NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} + +# publish-gpr: +# needs: build +# runs-on: ubuntu-latest +# steps: +# - uses: actions/checkout@v2 +# with: +# fetch-depth: 0 +# - uses: actions/setup-node@v1 +# with: +# node-version: 12 +# registry-url: https://npm.pkg.github.com/ +# - run: npm ci +# - run: git config user.email "NEED AUTHORISED EMAIL" +# - run: git config user.name ${{ github.actor }} +# - run: npm run postinstall +# - run: npm run publish:lerna +# env: +# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} +# NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}} diff --git a/README.md b/README.md index 3e936be4f9..1504cfad5b 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,9 @@ This monorepo holds all packages dedicated to `@particle` packages. [![lerna](https://img.shields.io/badge/maintained%20with-lerna-cc00ff.svg)](https://lerna.js.org/) - +[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/) +[![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg)](https://conventionalcommits.org) +[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release) ## Installation TBD @@ -17,9 +19,9 @@ TBD ### Steps 1. Clone the repo -1. Run `npm install`, This will install all dev dependencies and run the postinstall script `lerna:install` which runs `lerna bootstrap --nohoist` and installs all package dependencies. +1. Run `npm install`, This will install all dev dependencies and run the postinstall script `lerna:install` which runs `lerna bootstrap --hoist` and installs all package dependencies. 1. If you update subdependencies, simply run `npm install` or `npm run lerna:install` to re-install lerna package dependencies. This is especially helpful when you are pulling in new code (with sub dependency additionas) from another branch. -1. `npm run build:watch` build the project in the `packages//lib` folder, packages that do not contain a .tsconfig and do not have a `tsc` and `tsc:build` script will be ignored lerna executes packages that contain only these scripts. +1. `npm run build:watch` build the project in the `packages//lib` folder, packages that do not contain a .tsconfig and do not have a `tsc` and `tsc:build` script will be ignored as lerna executes packages that contain only these scripts. 1. For all packages, simply execute the target file such as `node packages/particle-cli/lib/bin/particle-cli.js init` to run things, typescript must be compiled for typescript packages to execute 1. `npm run test:watch` to start jest in watch mode (recommended) @@ -60,3 +62,18 @@ To remove all node_modules in packages run `npm dev:clean:node_modules` ```bash npx lerna run --scope @phase2/particle-cli test ``` + +### Making a commit + +Particle 11 uses [Lerna](https://github.com/lerna/lerna) in concert with [Commitizen](https://github.com/commitizen/cz-cli) to follow the [Semantic Versioning](http://semver.org/) specifications. This will allow for all of our package versions to be update automatically when they are published to their file registries. + +To this end every commit should be made using ```npm run commit``` or ```npx cz```. Also consider installing [Commitizen](https://github.com/commitizen/cz-cli) globally on your machine and just using ```cz```. This will present you with a CLI to construct your commits + +![](https://github.com/commitizen/cz-cli/raw/master/meta/screenshots/add-commit.png) + +If you commit without using Commitizen, or have to fix a commit, follow this format: + +[type](https://www.conventionalcommits.org/en/v1.0.0/) (scope/file changed, optional): message +EX: ```chore(README.md): update documentation ``` + +In case you make the wrong kind of commit [SEE THIS](https://www.conventionalcommits.org/en/v1.0.0/#what-do-i-do-if-i-accidentally-use-the-wrong-commit-type) diff --git a/lerna.json b/lerna.json index 0b88bf2270..e263fb4e81 100644 --- a/lerna.json +++ b/lerna.json @@ -1,14 +1,15 @@ { "npmClient": "npm", + "version": "independent", + "packages": ["packages/*"], "command": { "publish": { "ignoreChanges": ["ignored-file", "*.md"], - "message": "chore(release): publish" + "message": "chore(release): publish", + "conventionalCommits": true }, "bootstrap": { - "npmClientArgs": ["--hoist", "--no-package-lock"] + "npmClientArgs": ["--no-package-lock"] } - }, - "packages": ["packages/*"], - "version": "independent" + } } diff --git a/package.json b/package.json index b97fd701c2..7791242be7 100644 --- a/package.json +++ b/package.json @@ -23,9 +23,10 @@ }, "license": "GPL-2.0", "scripts": { - "lerna:install": "lerna bootstrap", + "lerna:install": "lerna bootstrap --hoist", "postinstall": "npm run lerna:install; npm run build", "pretty-check": "prettier --check packages/**/*.js", + "publish": "lerna publish --yes", "test": "jest", "test:watch": "jest --watch", "build": "lerna run --concurrency 1 --scope='{@phase2/particle-types,@phase2/generator-particle-storybook,@phase2/generator-particle-base,@phase2/particle-cli}' tsc", @@ -33,9 +34,11 @@ "dev:clean:lib": "lerna exec --parallel --scope='{@phase2/particle-types,@phase2/generator-particle-storybook,@phase2/generator-particle-base,@phase2/particle-cli}' 'rm -rf lib/'", "build:watch": "lerna run --parallel --scope='{@phase2/*,generator-*}' tsc:watch", "update:check": "ncu && lerna exec --concurrency 1 --no-bail -- ncu", - "update:start": "npm-upgrade && lerna exec --concurrency 1 -- npm-upgrade; npm run lerna:install" + "update:start": "npm-upgrade && lerna exec --concurrency 1 -- npm-upgrade; npm run lerna:install", + "commit": "cz" }, "dependencies": { + "commitizen": "^4.2.1", "lerna": "^3.22.1", "typescript": "^3.9.7" }, @@ -44,6 +47,7 @@ "@phase2/prettier-config-particle": "./packages/prettier-config", "@types/jest": "^26.0.8", "@types/node": "^14.0.27", + "cz-conventional-changelog": "^3.3.0", "eslint": "^7.6.0", "jest": "^26.2.2", "jest-watch-typeahead": "^0.6.0", @@ -52,5 +56,10 @@ "prettier": "2.0.5", "ts-jest": "^26.1.4", "ts-node": "^8.10.2" + }, + "config": { + "commitizen": { + "path": "./node_modules/cz-conventional-changelog" + } } }