From 5e87b2d2af62fc62326714d0782d3a9bb555c228 Mon Sep 17 00:00:00 2001 From: olewandowski1 Date: Fri, 24 Nov 2023 11:52:49 +0100 Subject: [PATCH] OM-78: sonar, prettier, eslint, template adjustments --- .eslintrc | 25 ++++++-------- .github/workflows/CI_and_build.yml | 44 ++++++++++++++++++++++++ .github/workflows/npmpublish.yml | 51 ++++++++++++++++++++++++++++ .github/workflows/sonar-analysis.yml | 23 +++++++++++++ .prettierrc.json | 6 ++++ README.md | 22 +++++++++--- package.json | 10 +++--- src/index.js | 6 ++-- 8 files changed, 161 insertions(+), 26 deletions(-) create mode 100644 .github/workflows/CI_and_build.yml create mode 100644 .github/workflows/npmpublish.yml create mode 100644 .github/workflows/sonar-analysis.yml create mode 100644 .prettierrc.json diff --git a/.eslintrc b/.eslintrc index e74d212..1de0561 100644 --- a/.eslintrc +++ b/.eslintrc @@ -1,23 +1,20 @@ { - "parser": "babel-eslint", - "extends": [ - "standard", - "standard-react" - ], "env": { - "es6": true + "browser": true, + "es2021": true }, - "plugins": [ - "react" - ], + "extends": ["plugin:react/recommended", "airbnb"], + "overrides": [], "parserOptions": { + "ecmaVersion": "latest", "sourceType": "module" }, + "plugins": ["react"], "rules": { - // don't force es6 functions to include space before paren - "space-before-function-paren": 0, - - // allow specifying true explicitly for boolean props - "react/jsx-boolean-value": 0 + "react/prop-types": "off", + "no-shadow": "off", // disabled due to use of bindActionCreators + "react/jsx-filename-extension": [1, { "extensions": [".js", ".jsx"] }], // disabled due to naming consistency with other modules + "import/no-unresolved": "off", // disable due to module architecture. For modules most references are marked as unresolved + "max-len": ["error", { "code": 120 }] } } diff --git a/.github/workflows/CI_and_build.yml b/.github/workflows/CI_and_build.yml new file mode 100644 index 0000000..fb19bf0 --- /dev/null +++ b/.github/workflows/CI_and_build.yml @@ -0,0 +1,44 @@ +# This is a basic workflow to help you get started with Actions + +name: Build + +# Controls when the workflow will run +on: + # Triggers the workflow on push or pull request events but only for the main branch + pull_request: + branches: [ main, develop ] + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + # This workflow contains a single job called "build" + build: + # The type of runner that the job will run on + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [16.x] + + # Steps represent a sequence of tasks that will be executed as part of the job + steps: + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it + - uses: actions/checkout@v2 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v2 + with: + node-version: ${{ matrix.node-version }} + - name: Install dependencies + run : yarn install + - name: build + run : yarn build + - name: Check build status + run: | + if [ -d "dist" ]; then + echo "Build successful!" + else + echo "Build failed!" + exit 1 + fi diff --git a/.github/workflows/npmpublish.yml b/.github/workflows/npmpublish.yml new file mode 100644 index 0000000..61bbd22 --- /dev/null +++ b/.github/workflows/npmpublish.yml @@ -0,0 +1,51 @@ +# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created +# For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages + +name: Node.js Package + +on: + release: + types: [created] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v1 + with: + node-version: 12 + - run: yarn install + - run: yarn build + + publish-npm: + needs: build + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v1 + with: + node-version: 12 + registry-url: https://registry.npmjs.org/ + scope: openimis + - run: yarn install + - run: yarn build + - run: npm publish --access public + env: + NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} + + publish-gpr: + needs: build + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v1 + with: + node-version: 12 + registry-url: https://npm.pkg.github.com/ + - run: yarn install + - run: yarn build + - run: npm publish + env: + NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}} + \ No newline at end of file diff --git a/.github/workflows/sonar-analysis.yml b/.github/workflows/sonar-analysis.yml new file mode 100644 index 0000000..da93b2d --- /dev/null +++ b/.github/workflows/sonar-analysis.yml @@ -0,0 +1,23 @@ +name: Sonar CI pipeline +on: + push: + branches: + - main + - 'release/**' + - develop + - 'feature/**' + pull_request: + types: [opened, synchronize, reopened] +jobs: + sonarcloud: + name: SonarCloud + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: SonarCloud Scan + uses: SonarSource/sonarcloud-github-action@master + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} diff --git a/.prettierrc.json b/.prettierrc.json new file mode 100644 index 0000000..0dc119f --- /dev/null +++ b/.prettierrc.json @@ -0,0 +1,6 @@ +{ + "trailingComma": "all", + "printWidth": 120, + "quoteProps": "preserve", + "arrowParens": "always" +} diff --git a/README.md b/README.md index 66fe370..080b75c 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,25 @@ -# openIMIS Frontend Template module -This repository holds the files of the openIMIS Frontend Template module. +# openIMIS Frontend Worker Voucher module +This repository holds the files of the openIMIS Frontend Worker Voucher module. It is dedicated to be bootstrap development of [openimis-fe_js](https://github.com/openimis/openimis-fe_js) modules, providing an empty (yet deployable) module. Please refer to [openimis-fe_js](https://github.com/openimis/openimis-fe_js) to see how to build and and deploy (in developement or server mode). The module is built with [rollup](https://rollupjs.org/). -In development mode, you can use `yarn link` and `yarn start` to continuously scan for changes and automatically update your development server. +In development mode, you can use `npm link` and `npm start` to continuously scan for changes and automatically update your development server. [![License: AGPL v3](https://img.shields.io/badge/License-AGPL%20v3-blue.svg)](https://www.gnu.org/licenses/agpl-3.0) -[![Total alerts](https://img.shields.io/lgtm/alerts/g/openimis/openimis-fe-template_js.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/openimis/openimis-fe-template_js/alerts/) +[![Total alerts](https://img.shields.io/lgtm/alerts/g/openimis/openimis-fe-tasks_management_js.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/openimis/openimis-fe-tasks_management_js/alerts/) + +## Main Menu Contributions + +## Other Contributions + +## Available Contribution Points + +## Dispatched Redux Actions + +## Other Modules Listened Redux Actions + +## Other Modules Redux State Bindings + +## Configurations Options diff --git a/package.json b/package.json index 01dc2de..30bb46e 100644 --- a/package.json +++ b/package.json @@ -1,9 +1,9 @@ { - "name": "@openimis/fe-template", - "version": "1.2.0-rc1", + "name": "@openimis/fe-worker_voucher", + "version": "0.1.0", "license": "AGPL-3.0-only", - "description": "openIMIS Frontend Template module", - "repository": "openimis/openimis-fe-template_js", + "description": "openIMIS Frontend Worker Voucher module", + "repository": "openimis/openimis-fe-worker_voucher_js", "main": "dist/index.js", "module": "dist/index.es.js", "engines": { @@ -14,7 +14,7 @@ "build": "rollup -c", "start": "rollup -c -w", "format": "prettier src -w", - "prepare":"npm run build" + "prepare": "npm run build" }, "devDependencies": { "@babel/cli": "^7.8.4", diff --git a/src/index.js b/src/index.js index 4f57e02..c9c5ebf 100644 --- a/src/index.js +++ b/src/index.js @@ -2,8 +2,8 @@ import messages_en from "./translations/en.json"; const DEFAULT_CONFIG = { "translations": [{ key: "en", messages: messages_en }], -} +}; -export const TemplateModule = (cfg) => { +export const WorkerVoucherModule = (cfg) => { return { ...DEFAULT_CONFIG, ...cfg }; -} \ No newline at end of file +};