Skip to content

Commit

Permalink
Merge pull request #22 from sineverba/release-1.2.0
Browse files Browse the repository at this point in the history
Release 1.2.0
  • Loading branch information
sineverba committed May 10, 2022
2 parents 4951ff9 + 9683680 commit 7490bed
Show file tree
Hide file tree
Showing 10 changed files with 53 additions and 25 deletions.
2 changes: 2 additions & 0 deletions .env.bak
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
SONAR_LOGIN=your_LOCAL_SonarTokenHere
SONAR_HOST_URL=http://localhost:9000
18 changes: 9 additions & 9 deletions .semaphore/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
version: v1.0

name: Deploy to NPM pipeline
name: Deploy
agent:
machine:
type: e1-standard-2
os_image: ubuntu1804
os_image: ubuntu2004

global_job_config:
secrets:
- name: ACCESS_TOKENS

blocks:
- name: Deploy
- name: Deploy To NPM
task:
jobs:
- name: Deploy
- name: Deploy To NPM
commands:
- checkout
- mv npmrc.txt .npmrc
- npm build
- npm publish

secrets:
- name: NPM_TOKEN
- npm publish
12 changes: 5 additions & 7 deletions .semaphore/semaphore.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
version: v1.0

name: Build and test Pipeline
name: Test and build
agent:
machine:
type: e1-standard-2
os_image: ubuntu1804
os_image: ubuntu2004

global_job_config:
secrets:
- name: COVERALLS_DATECONVERT_REPO_TOKEN
- name: NPM_TOKEN
- name: SONARCLOUD
- name: ACCESS_TOKENS

blocks:
- name: Install dependencies
Expand Down Expand Up @@ -40,7 +38,6 @@ blocks:
values: [ "10", "12", "14", "16" ]
commands:
- sem-version node $NODE_VERSION
- node --version
- npm run test

- name: Coverage
Expand All @@ -54,12 +51,13 @@ blocks:
jobs:
- name: Coverage
commands:
- export COVERALLS_REPO_TOKEN=$COVERALLS_NPM_PKG_DATE_CONVERT
- npm run cover
- cat coverage/lcov.info | node_modules/coveralls/bin/coveralls.js
- name: Sonarcloud
commands:
- npm run cover
- docker run --rm -e SONAR_HOST_URL="https://sonarcloud.io" -e SONAR_LOGIN=$SONAR_AUTH_TOKEN -v "/home/semaphore/npm-pkg-date-convert:/usr/src" sonarsource/sonar-scanner-cli:4.6
- docker run --rm -e SONAR_HOST_URL="https://sonarcloud.io" -e SONAR_LOGIN=$SONAR_TOKEN -v "/home/semaphore/npm-pkg-date-convert:/usr/src" sonarsource/sonar-scanner-cli:4.6

promotions:
- name: Deploy
Expand Down
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
# 1.1.0
# 1.2.0
+ Fix deploy
+ Refactor Semaphore
+ Clean Semaphore - Upgrade dependencies
+ Add handle separator

## 1.1.0
+ Reorganize project and fix some trouble on CI/CD
+ Add SonarQube and fix some code smells
+ Upgrade dependencies
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
sonar:
docker-compose start sonarscanner && docker-compose logs -f sonarscanner
docker-compose up sonarscanner

upgrade:
npx ncu -u
Expand Down
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,16 @@ Date Convert
| SonarCloud | [![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=npm-pkg-date-convert&metric=alert_status)](https://sonarcloud.io/dashboard?id=npm-pkg-date-convert) |


`date-convert` converts a 8-digit, ISO format YYYYMMDD, string "19820405" to "05/04/1982" (where 05 is day and 04 is April).
`date-convert` converts a ISO format YYYYMMDD string "19820405" to "05/04/1982" (where 05 is day and 04 is April). Use `"/"` as separator in output.

### Accepted INPUT

| Input | Output |
| ----- | -------|
| "20220323" | 23/03/2022 |
| "2022-03-23" | 23/03/2022 |
| "2022-03-09T12:31:16.699904" | 09/03/2022 |

Use `"/"` as separator.

## Installation
`npm install @sineverba/date-convert`
Expand All @@ -37,6 +44,7 @@ console.log(isoDate); // returns 20200102
`npm run cover` for coverage

### SonarQube (local Docker)
+ Copy `.env.bak` in `.env`
+ Spin images `docker-compose up -d`
+ Create a new project inside Sonarqube and grab the token
+ Replace the token in the ENV var of `docker-compose.yml` file
Expand Down
5 changes: 3 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@ services:
volumes:
- ./:/usr/src
environment:
- SONAR_HOST_URL=http://sonarqube:9000
- SONAR_LOGIN=c50a6e3f92b033bd77443c2922d56a84de2c71e9
- SONAR_HOST_URL=${SONAR_HOST_URL}
- SONAR_LOGIN=${SONAR_LOGIN}
networks:
- npm-pkg-date-convert


networks:
npm-pkg-date-convert:
name: npm-pkg-date-convert
driver: bridge
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sineverba/date-convert",
"version": "1.1.0",
"version": "1.2.0",
"description": "Convert a date from / to ISO format YYYYMMDD to human readable format (DD/MM/YYYY)",
"main": "index.js",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion sonar-project.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
sonar.projectKey=npm-pkg-date-convert
sonar.projectVersion=1.1.0
sonar.projectVersion=1.2.0
sonar.organization=sineverba
sonar.sources=./index.js
sonar.exclusions=test/**
Expand Down
15 changes: 14 additions & 1 deletion test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,18 @@ describe('#fromIsoToHuman', function() {
expect(result).to.equal("08/09/2020");
});

it('Should namage hyphen separator', function() {
var isoDateWithHyphen = "2020-01-02";
var result = fromIsoToHuman(isoDateWithHyphen);
expect(result).to.equal("02/01/2020");
});

it('Should namage a longer date', function() {
var longerDate = "2022-03-09T12:31:16.699904";
var result = fromIsoToHuman(longerDate);
expect(result).to.equal("09/03/2022");
});

})

describe('#fromHumanToIso', function() {
Expand All @@ -20,4 +32,5 @@ describe('#fromHumanToIso', function() {
var result = fromHumanToIso(humanDate);
expect(result).to.equal("20201231");
});
})
})

0 comments on commit 7490bed

Please sign in to comment.