Skip to content
This repository has been archived by the owner on Apr 4, 2022. It is now read-only.

Commit

Permalink
Merge pull request #934 from nugit/fix/protected-branch
Browse files Browse the repository at this point in the history
[NG-1770, NG-1910, NG-1911] Housekeeping
  • Loading branch information
limtingzhi committed Dec 9, 2021
2 parents 7dbae21 + 8d6334e commit c21e060
Show file tree
Hide file tree
Showing 16 changed files with 994 additions and 999 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"es6": true,
"node": true
},
"parser": "babel-eslint",
"parser": "@babel/eslint-parser",
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module",
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/changelog.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Changelog

on:
on:
pull_request:
types: [opened, edited, synchronize]
branches: [master]
Expand All @@ -9,7 +9,6 @@ jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2.4.0
- uses: nugit/actions-pr-changelog@v1.2.5
with:
token: ${{ secrets.GITHUB_TOKEN }}
Expand Down
18 changes: 18 additions & 0 deletions .github/workflows/create-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Create Release

on:
schedule:
- cron: '* * 1 * *'

jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2.5.0
- uses: nugit/actions-pr-changelog/createReleaseAction@v1.2.5
with:
token: ${{ secrets.GH_TOKEN }}
head: develop
base: master
title: Next Release
reviewers: 'moroine,limtingzhi,tuannugit'
2 changes: 2 additions & 0 deletions .github/workflows/deploy-production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2.4.0
with:
token: ${{ secrets.GH_TOKEN }}
- uses: actions/setup-node@v2.5.0
with:
node-version: 12
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/deploy-staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2.4.0
with:
token: ${{ secrets.GH_TOKEN }}
- uses: actions/setup-node@v2.5.0
with:
node-version: 12
Expand Down
15 changes: 13 additions & 2 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,31 @@ name: Check

on:
push:
branches-ignore:
- dependabot/**
branches:
- "master"
- "develop"
pull_request:

jobs:
check:
runs-on: ubuntu-latest
steps:
- if: ${{ github.actor == 'dependabot[bot]' }}
run: echo "Skipping - Will be tested in dependabot-merge"
- uses: actions/checkout@v2.4.0
if: ${{ github.actor != 'dependabot[bot]' }}
- uses: actions/setup-node@v2.5.0
if: ${{ github.actor != 'dependabot[bot]' }}
with:
node-version: 12
cache: 'yarn'
- run: yarn install
if: ${{ github.actor != 'dependabot[bot]' }}
- run: yarn lint
if: ${{ github.actor != 'dependabot[bot]' }}
- run: yarn flow
if: ${{ github.actor != 'dependabot[bot]' }}
- run: yarn test
if: ${{ github.actor != 'dependabot[bot]' }}
- run: yarn build
if: ${{ github.actor != 'dependabot[bot]' }}
4 changes: 2 additions & 2 deletions flow-typed/npm/sinon_vx.x.x.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// flow-typed signature: 90f057dd59cf5e39883e5bcc18e959c1
// flow-typed version: <<STUB>>/sinon_v11.1.2/flow_v0.160.2
// flow-typed signature: dc2504017ba773dd469a4665f815a05f
// flow-typed version: <<STUB>>/sinon_v^11.1.2/flow_v0.166.1

/**
* This is an autogenerated libdef stub for:
Expand Down
4 changes: 2 additions & 2 deletions flow-typed/npm/timezone-mock_vx.x.x.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// flow-typed signature: 16e7434ec2002619632c7cc9acbbab1f
// flow-typed version: <<STUB>>/timezone-mock_v1.2.2/flow_v0.160.2
// flow-typed signature: cabae98edae37568ed822763bf92cf3a
// flow-typed version: <<STUB>>/timezone-mock_v^1.2.2/flow_v0.166.1

/**
* This is an autogenerated libdef stub for:
Expand Down
76 changes: 66 additions & 10 deletions lib/nugit-datetime-utils.cjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -288,21 +288,37 @@ const formatRange = (start, end) => ({
end: formatDate(end)
});

const getLastRelativePeriodRange = (num, unit, base = new Date()) => {
const getLastRelativePeriodRange = function (num, unit, base) {
if (base === void 0) {
base = new Date();
}

const startOf = getStartOfFn(unit);
const endOf = getEndOfFn(unit);
const sub = getSubtractionFn(unit);
return formatRange(startOf(sub(base, num)), endOf(sub(base, 1)));
};

const getThisRelativePeriodRange = (unit, base = new Date(), num = 1) => {
const getThisRelativePeriodRange = function (unit, base, num) {
if (base === void 0) {
base = new Date();
}

if (num === void 0) {
num = 1;
}

const dayBefore = subDays(base, 1);
const startOf = getStartOfFn(unit);
const sub = getSubtractionFn(unit);
return formatRange(startOf(sub(dayBefore, num - 1)), formatDate(dayBefore));
};

const getTillYesterdayRange = (start, base = new Date()) => {
const getTillYesterdayRange = function (start, base) {
if (base === void 0) {
base = new Date();
}

const dayBefore = subDays(base, 1);
return formatRange(start, dayBefore);
};
Expand Down Expand Up @@ -384,7 +400,15 @@ const getPeriodParams = period => {
}
};

const getRange = (period, base = new Date(), utcOffset = 0) => {
const getRange = function (period, base, utcOffset) {
if (base === void 0) {
base = new Date();
}

if (utcOffset === void 0) {
utcOffset = 0;
}

const baseDate = applyOffset(utcOffset, base);
const params = getPeriodParams(period);

Expand Down Expand Up @@ -447,7 +471,11 @@ const getBestCompareUnit = (start, end) => {
return 'day';
};

const getAutoCompareRangeAndLabel = (period, baseDate = new Date()) => {
const getAutoCompareRangeAndLabel = function (period, baseDate) {
if (baseDate === void 0) {
baseDate = new Date();
}

const {
start,
end
Expand Down Expand Up @@ -494,7 +522,11 @@ const getAutoCompareRangeAndLabel = (period, baseDate = new Date()) => {
}
};

const getCompareRange = (period, compareMode = 'auto') => {
const getCompareRange = function (period, compareMode) {
if (compareMode === void 0) {
compareMode = 'auto';
}

switch (compareMode) {
case 'auto':
return getAutoCompareRangeAndLabel(period).range;
Expand Down Expand Up @@ -563,7 +595,11 @@ const migrateLegacyPeriod = period => {
}
};

const migrateLegacyCompareMode = (compareMode = 'auto') => {
const migrateLegacyCompareMode = function (compareMode) {
if (compareMode === void 0) {
compareMode = 'auto';
}

switch (compareMode) {
case 'auto':
case '12_months_ago':
Expand Down Expand Up @@ -593,13 +629,33 @@ const toLegacyCompareMode = compareMode => {
}
};

const retrievePeriod = (period, base = new Date(), offset = 0) => getRange(migrateLegacyPeriod(period), base, offset);
const retrievePeriod = function (period, base, offset) {
if (base === void 0) {
base = new Date();
}

if (offset === void 0) {
offset = 0;
}

return getRange(migrateLegacyPeriod(period), base, offset);
};

const retrievePeriodParams = period => getPeriodParams(migrateLegacyPeriod(period));

const retrieveComparePeriod = (period, compareMode = 'auto') => getCompareRange(migrateLegacyPeriod(period), migrateLegacyCompareMode(compareMode));
const retrieveComparePeriod = function (period, compareMode) {
if (compareMode === void 0) {
compareMode = 'auto';
}

return getCompareRange(migrateLegacyPeriod(period), migrateLegacyCompareMode(compareMode));
};

const calculateAutoCompare = function (period, base) {
if (base === void 0) {
base = new Date();
}

const calculateAutoCompare = (period, base = new Date()) => {
const {
label,
range
Expand Down
76 changes: 66 additions & 10 deletions lib/nugit-datetime-utils.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,21 +231,37 @@ const formatRange = (start, end) => ({
end: formatDate(end)
});

const getLastRelativePeriodRange = (num, unit, base = new Date()) => {
const getLastRelativePeriodRange = function (num, unit, base) {
if (base === void 0) {
base = new Date();
}

const startOf = getStartOfFn(unit);
const endOf = getEndOfFn(unit);
const sub = getSubtractionFn(unit);
return formatRange(startOf(sub(base, num)), endOf(sub(base, 1)));
};

const getThisRelativePeriodRange = (unit, base = new Date(), num = 1) => {
const getThisRelativePeriodRange = function (unit, base, num) {
if (base === void 0) {
base = new Date();
}

if (num === void 0) {
num = 1;
}

const dayBefore = subDays(base, 1);
const startOf = getStartOfFn(unit);
const sub = getSubtractionFn(unit);
return formatRange(startOf(sub(dayBefore, num - 1)), formatDate(dayBefore));
};

const getTillYesterdayRange = (start, base = new Date()) => {
const getTillYesterdayRange = function (start, base) {
if (base === void 0) {
base = new Date();
}

const dayBefore = subDays(base, 1);
return formatRange(start, dayBefore);
};
Expand Down Expand Up @@ -327,7 +343,15 @@ const getPeriodParams = period => {
}
};

const getRange = (period, base = new Date(), utcOffset = 0) => {
const getRange = function (period, base, utcOffset) {
if (base === void 0) {
base = new Date();
}

if (utcOffset === void 0) {
utcOffset = 0;
}

const baseDate = applyOffset(utcOffset, base);
const params = getPeriodParams(period);

Expand Down Expand Up @@ -390,7 +414,11 @@ const getBestCompareUnit = (start, end) => {
return 'day';
};

const getAutoCompareRangeAndLabel = (period, baseDate = new Date()) => {
const getAutoCompareRangeAndLabel = function (period, baseDate) {
if (baseDate === void 0) {
baseDate = new Date();
}

const {
start,
end
Expand Down Expand Up @@ -437,7 +465,11 @@ const getAutoCompareRangeAndLabel = (period, baseDate = new Date()) => {
}
};

const getCompareRange = (period, compareMode = 'auto') => {
const getCompareRange = function (period, compareMode) {
if (compareMode === void 0) {
compareMode = 'auto';
}

switch (compareMode) {
case 'auto':
return getAutoCompareRangeAndLabel(period).range;
Expand Down Expand Up @@ -506,7 +538,11 @@ const migrateLegacyPeriod = period => {
}
};

const migrateLegacyCompareMode = (compareMode = 'auto') => {
const migrateLegacyCompareMode = function (compareMode) {
if (compareMode === void 0) {
compareMode = 'auto';
}

switch (compareMode) {
case 'auto':
case '12_months_ago':
Expand Down Expand Up @@ -536,13 +572,33 @@ const toLegacyCompareMode = compareMode => {
}
};

const retrievePeriod = (period, base = new Date(), offset = 0) => getRange(migrateLegacyPeriod(period), base, offset);
const retrievePeriod = function (period, base, offset) {
if (base === void 0) {
base = new Date();
}

if (offset === void 0) {
offset = 0;
}

return getRange(migrateLegacyPeriod(period), base, offset);
};

const retrievePeriodParams = period => getPeriodParams(migrateLegacyPeriod(period));

const retrieveComparePeriod = (period, compareMode = 'auto') => getCompareRange(migrateLegacyPeriod(period), migrateLegacyCompareMode(compareMode));
const retrieveComparePeriod = function (period, compareMode) {
if (compareMode === void 0) {
compareMode = 'auto';
}

return getCompareRange(migrateLegacyPeriod(period), migrateLegacyCompareMode(compareMode));
};

const calculateAutoCompare = function (period, base) {
if (base === void 0) {
base = new Date();
}

const calculateAutoCompare = (period, base = new Date()) => {
const {
label,
range
Expand Down
2 changes: 1 addition & 1 deletion lib/nugit-datetime-utils.umd.js

Large diffs are not rendered by default.

Loading

0 comments on commit c21e060

Please sign in to comment.