Skip to content

Commit

Permalink
feat(upgrade): Upgraded to support date-fns v2
Browse files Browse the repository at this point in the history
New pipes:
- dfnsAddBusinessDays
- dfnsDifferenceInBusinessDays
- dfnsGetUnixTime
- dfnsGetWeek
- dfnsGetWeekOfMonth
- dfnsGetWeeksInMonth
- dfnsGetDecade
- dfnsGetWeekYear
- dfnsLastDayOfDecade
- dfnsStartOfDecade
- dfnsStartOfWeekYear

BREAKING CHANGE:
- Library is now Angular >= v8 only.
- Pipe argument validations are now done by date-fns.
- Renamed dfnsAddISOYears to dfnsAddISOWeekYears.
- Renamed dfnsDifferenceInCalendarISOYears to dfnsDifferenceInCalendarISOWeekYears.
- Renamed dfnsDifferenceInISOYears to dfnsDifferenceInISOWeekYears.
- Renamed dfnsDistanceInWords to dfnsFormatDistance. Also, notice that date arguments have been swapped to be consistent with date-fns.
- Renamed dfnsDistanceInWordsStrict to dfnsFormatDistanceStrict. Also, notice that date arguments have been swapped to be consistent with date-fns. See https://date-fns.org/v2.0.1/docs/formatDistanceStrict#v2.0.0-breaking-changes for more breaking changes related to the options param.
- Renamed dfnsDistanceInWordsToNow to dfnsFormatDistanceToNow.
- Renamed dfnsEndOfISOYear to dfnsEndOfISOWeekYear.
- Renamed dfnsGetISOYear to dfnsGetISOWeekYear
- Renamed dfnsGetOverlappingDaysInRanges to dfnsGetOverlappingDaysInIntervals. Also, time interval arguments are passed differently: See https://date-fns.org/v2.0.1/docs/getOverlappingDaysInIntervals#v2.0.0-breaking-changes for more info.
- Renamed dfnsLastDayOfISOYear to dfnsLastDayOfISOWeekYear.
- Renamed dfnsStartOfISOYear to dfnsStartOfISOWeekYear
- Renamed dfnsSubISOYears to dfnsSubISOWeekYears
- In general, all date-fns changes (lots of changes) also apply to this library. See https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md and https://github.com/date-fns/date-fns/blob/master/CHANGELOG.md#200---2019-08-20 for the whole upgrade guide.
  • Loading branch information
joanllenas committed Sep 2, 2019
1 parent 59dd36c commit 2b5909a
Show file tree
Hide file tree
Showing 261 changed files with 11,568 additions and 10,169 deletions.
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@
/dist
/tmp
/out-tsc
# Only exists if Bazel was run
/bazel-out

# dependencies
/node_modules

# profiling files
chrome-profiler-events.json
speed-measure-plugin.json
chrome-profiler-events*.json
speed-measure-plugin*.json

# IDEs and editors
/.idea
Expand Down
250 changes: 129 additions & 121 deletions README.md

Large diffs are not rendered by default.

76 changes: 31 additions & 45 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,28 @@
"version": 1,
"newProjectRoot": "projects",
"projects": {
"ngxv2": {
"ngx-date-fns-app": {
"projectType": "application",
"schematics": {},
"root": "",
"sourceRoot": "src",
"projectType": "application",
"prefix": "app",
"schematics": {
"@schematics/angular:component": {
"styleext": "scss"
}
},
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist/ngxv2",
"outputPath": "dist/ngx-date-fns-app",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "src/tsconfig.app.json",
"tsConfig": "tsconfig.app.json",
"aot": false,
"assets": [
"src/favicon.ico",
"src/assets"
],
"styles": [
"src/styles.scss"
"src/styles.css"
],
"scripts": []
},
Expand All @@ -53,6 +50,11 @@
"type": "initial",
"maximumWarning": "2mb",
"maximumError": "5mb"
},
{
"type": "anyComponentStyle",
"maximumWarning": "6kb",
"maximumError": "10kb"
}
]
}
Expand All @@ -61,83 +63,68 @@
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
"browserTarget": "ngxv2:build"
"browserTarget": "ngx-date-fns-app:build"
},
"configurations": {
"production": {
"browserTarget": "ngxv2:build:production"
"browserTarget": "ngx-date-fns-app:build:production"
}
}
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "ngxv2:build"
"browserTarget": "ngx-date-fns-app:build"
}
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"main": "src/test.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "src/tsconfig.spec.json",
"karmaConfig": "src/karma.conf.js",
"styles": [
"src/styles.scss"
],
"scripts": [],
"tsConfig": "tsconfig.spec.json",
"karmaConfig": "karma.conf.js",
"assets": [
"src/favicon.ico",
"src/assets"
]
],
"styles": [
"src/styles.css"
],
"scripts": []
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": [
"src/tsconfig.app.json",
"src/tsconfig.spec.json"
"tsconfig.app.json",
"tsconfig.spec.json",
"e2e/tsconfig.json"
],
"exclude": [
"**/node_modules/**"
]
}
}
}
},
"ngxv2-e2e": {
"root": "e2e/",
"projectType": "application",
"prefix": "",
"architect": {
},
"e2e": {
"builder": "@angular-devkit/build-angular:protractor",
"options": {
"protractorConfig": "e2e/protractor.conf.js",
"devServerTarget": "ngxv2:serve"
"devServerTarget": "ngx-date-fns-app:serve"
},
"configurations": {
"production": {
"devServerTarget": "ngxv2:serve:production"
"devServerTarget": "ngx-date-fns-app:serve:production"
}
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": "e2e/tsconfig.e2e.json",
"exclude": [
"**/node_modules/**"
]
}
}
}
},
"ngx-date-fns": {
"projectType": "library",
"root": "projects/ngx-date-fns",
"sourceRoot": "projects/ngx-date-fns/src",
"projectType": "library",
"prefix": "lib",
"architect": {
"build": {
Expand Down Expand Up @@ -168,7 +155,6 @@
}
}
}
}
},
"defaultProject": "ngxv2"
}},
"defaultProject": "ngx-date-fns-app"
}
12 changes: 12 additions & 0 deletions browserslist
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# This file is used by the build system to adjust CSS and JS output to support the specified browsers below.
# For additional information regarding the format and rule options, please see:
# https://github.com/browserslist/browserslist#queries

# You can see what browsers were selected by your queries by running:
# npx browserslist

> 0.5%
last 2 versions
Firefox ESR
not dead
not IE 9-11 # For IE 9-11 support, remove 'not'.
6 changes: 5 additions & 1 deletion e2e/protractor.conf.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
// @ts-check
// Protractor configuration file, see link for more information
// https://github.com/angular/protractor/blob/master/lib/config.ts

const { SpecReporter } = require('jasmine-spec-reporter');

/**
* @type { import("protractor").Config }
*/
exports.config = {
allScriptsTimeout: 11000,
specs: [
Expand All @@ -21,7 +25,7 @@ exports.config = {
},
onPrepare() {
require('ts-node').register({
project: require('path').join(__dirname, './tsconfig.e2e.json')
project: require('path').join(__dirname, './tsconfig.json')
});
jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
}
Expand Down
4 changes: 2 additions & 2 deletions e2e/src/app.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ describe('workspace-project App', () => {

it('should display welcome message', () => {
page.navigateTo();
expect(page.getTitleText()).toEqual('Welcome to ngxv2!');
expect(page.getTitleText()).toEqual('ngx-date-fns-app app is running!');
});

afterEach(async () => {
// Assert that there are no errors emitted from the browser
const logs = await browser.manage().logs().get(logging.Type.BROWSER);
expect(logs).not.toContain(jasmine.objectContaining({
level: logging.Level.SEVERE,
}));
} as logging.Entry));
});
});
4 changes: 2 additions & 2 deletions e2e/src/app.po.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import { browser, by, element } from 'protractor';

export class AppPage {
navigateTo() {
return browser.get('/');
return browser.get(browser.baseUrl) as Promise<any>;
}

getTitleText() {
return element(by.css('app-root h1')).getText();
return element(by.css('app-root .content span')).getText() as Promise<string>;
}
}
4 changes: 2 additions & 2 deletions e2e/tsconfig.e2e.json → e2e/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "../out-tsc/app",
"outDir": "../out-tsc/e2e",
"module": "commonjs",
"target": "es5",
"types": [
Expand All @@ -10,4 +10,4 @@
"node"
]
}
}
}
7 changes: 4 additions & 3 deletions src/karma.conf.js → karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module.exports = function (config) {
clearContext: false // leave Jasmine Spec Runner output visible in browser
},
coverageIstanbulReporter: {
dir: require('path').join(__dirname, '../coverage'),
dir: require('path').join(__dirname, './coverage/ngx-date-fns-app'),
reports: ['html', 'lcovonly', 'text-summary'],
fixWebpackSourcePaths: true
},
Expand All @@ -26,6 +26,7 @@ module.exports = function (config) {
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['Chrome'],
singleRun: false
singleRun: false,
restartOnFileChange: true
});
};
};
Loading

0 comments on commit 2b5909a

Please sign in to comment.