Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[APPS-2108] break direct dependency on moment.js #9032

Merged
merged 7 commits into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,7 @@
"scripts": [
"node_modules/pdfjs-dist/build/pdf.js",
"node_modules/pdfjs-dist/web/pdf_viewer.js",
"node_modules/raphael/raphael.min.js",
"node_modules/moment/min/moment.min.js"
"node_modules/raphael/raphael.min.js"
],
"vendorChunk": true,
"extractLicenses": false,
Expand Down
1 change: 0 additions & 1 deletion lib/content-services/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ module.exports = function (config) {
included: true,
watched: false
},
{pattern: 'node_modules/moment/min/moment.min.js', included: true, watched: false},
{pattern: 'lib/content-services/src/lib/i18n/**/en.json', included: false, served: true, watched: false},
{
pattern: 'lib/content-services/src/lib/assets/images/**/*.svg',
Expand Down
1 change: 0 additions & 1 deletion lib/content-services/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
"@angular/router": ">=14.1.3",
"@alfresco/js-api": ">=7.1.0-1437",
"@ngx-translate/core": ">=14.0.0",
"moment": ">=2.22.2",
"@alfresco/adf-core": ">=6.3.0"
},
"keywords": [
Expand Down
1 change: 0 additions & 1 deletion lib/core/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ module.exports = function (config) {
included: true,
watched: false
},
{pattern: 'node_modules/moment/min/moment.min.js', included: true, watched: false},
{pattern: 'lib/core/src/lib/i18n/**/en.json', included: false, served: true, watched: false},
{pattern: 'lib/core/**/*.ts', included: false, served: true, watched: false},
{pattern: 'lib/core/src/lib/assets/**/*.svg', included: false, served: true, watched: false},
Expand Down
3 changes: 0 additions & 3 deletions lib/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,12 @@
"@angular/core": ">=14.1.3",
"@angular/forms": ">=14.1.3",
"@angular/material": ">=14.1.2",
"@angular/material-moment-adapter": ">=14.1.2",
"@angular/router": ">=14.1.3",
"@mat-datetimepicker/core": "^10.1.1",
"@mat-datetimepicker/moment": "^10.1.1",
"@alfresco/js-api": ">=7.1.0-1437",
"@alfresco/adf-extensions": ">=6.3.0",
"@ngx-translate/core": ">=14.0.0",
"minimatch-browser": ">=1.0.0",
"moment": ">=2.22.2",
"pdfjs-dist": ">=3.3.122"
},
"keywords": [
Expand Down
8 changes: 6 additions & 2 deletions lib/core/src/lib/common/utils/moment-date-adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,13 @@

import { Injectable } from '@angular/core';
import { DateAdapter } from '@angular/material/core';
import moment, { isMoment, Moment } from 'moment';
import { UserPreferencesService, UserPreferenceValues } from '../services/user-preferences.service';

// Stub for the moment.js integration.
// While this dependency is no longer used by the libraries, the moment adapter can still discover the moment.js linked to the application
declare let moment: any;
type Moment = any;

/**
* @deprecated this class is deprecated and should not be used.
* Consider using `AdfDateFnsAdapter` or `AdfDateTimeFnsAdapter` instead
Expand Down Expand Up @@ -183,7 +187,7 @@ export class MomentDateAdapter extends DateAdapter<Moment> {
if (first == null) {
// same if both null
return second == null;
} else if (isMoment(first)) {
} else if (moment.isMoment(first)) {
return first.isSame(second);
} else {
const isSame = super.sameDate(first, second);
Expand Down
5 changes: 3 additions & 2 deletions lib/core/src/lib/pipes/moment-date.pipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@
*/

import { Pipe, PipeTransform } from '@angular/core';
import moment, { Moment } from 'moment';

declare let moment: any;

/**
* @deprecated this pipe is deprecated and should no longer be used
*/
@Pipe({ name: 'adfMomentDate' })
export class MomentDatePipe implements PipeTransform {
transform(value: moment.MomentInput, dateFormat: string): Moment {
transform(value: any, dateFormat: string): any {
return moment(value, dateFormat);
}
}
9 changes: 3 additions & 6 deletions lib/core/src/lib/pipes/moment-datetime.pipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,14 @@
*/

import { Pipe, PipeTransform } from '@angular/core';
import moment, { Moment } from 'moment';
declare let moment: any;

/**
* @deprecated this pipe is deprecated and should no longer be used
*/
@Pipe({ name: 'adfMomentDateTime' })
export class MomentDateTimePipe implements PipeTransform {
transform(value: moment.MomentInput, dateFormat: string): Moment {
return moment(value, dateFormat)
.add(
moment(value, dateFormat).utcOffset(),
'minutes');
transform(value: any, dateFormat: string): any {
return moment(value, dateFormat).add(moment(value, dateFormat).utcOffset(), 'minutes');
}
}
1 change: 0 additions & 1 deletion lib/insights/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ module.exports = function (config) {
watched: false
},

{pattern: 'node_modules/moment/min/moment.min.js', included: true, watched: false},
{pattern: 'lib/insights/src/lib/i18n/**/en.json', included: false, served: true, watched: false},
{pattern: 'lib/insights/**/*.ts', included: false, served: true, watched: false},
{pattern: 'lib/config/app.config.json', included: false, served: true, watched: false},
Expand Down
1 change: 0 additions & 1 deletion lib/insights/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
"@alfresco/adf-core": ">=6.3.0",
"@ngx-translate/core": ">=14.0.0",
"chart.js": "^4.3.0",
"moment": ">=2.22.2",
"ng2-charts": "^4.1.1",
"raphael": ">=2.3.0"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ export class DateRangeWidgetComponent implements OnInit {
constructor(private dateAdapter: DateAdapter<Date>) {}

ngOnInit() {
const momentDateAdapter = this.dateAdapter as AdfDateFnsAdapter;
momentDateAdapter.displayFormat = DISPLAY_FORMAT;
const dateAdapter = this.dateAdapter as AdfDateFnsAdapter;
dateAdapter.displayFormat = DISPLAY_FORMAT;

if (this.field) {
if (this.field.value?.startDate) {
Expand Down
1 change: 0 additions & 1 deletion lib/process-services-cloud/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ module.exports = function (config) {
},
{ pattern: 'node_modules/chart.js/dist/Chart.js', included: true, watched: false },
{ pattern: 'node_modules/raphael/raphael.min.js', included: true, watched: false },
{ pattern: 'node_modules/moment/min/moment.min.js', included: true, watched: false },
{ pattern: 'lib/core/src/lib/i18n/**/en.json', included: false, served: true, watched: false },
{ pattern: 'lib/process-services-cloud/src/lib/i18n/*.json', included: false, served: true, watched: false },
{ pattern: 'lib/process-services-cloud/src/lib/mock/*.json', included: false, served: true, watched: false },
Expand Down
2 changes: 0 additions & 2 deletions lib/process-services-cloud/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
"@angular/core": ">=14.1.3",
"@angular/forms": ">=14.1.3",
"@angular/material": ">=14.1.2",
"@angular/material-moment-adapter": ">=14.1.2",
"@angular/platform-browser": ">=14.1.3",
"@angular/platform-browser-dynamic": ">=14.1.3",
"@angular/router": ">=14.1.3",
Expand All @@ -41,7 +40,6 @@
"@apollo/client": "^3.7.2",
"@ngx-translate/core": ">=14.0.0",
"apollo-angular": "^4.0.1",
"moment": ">=2.22.2",
"subscriptions-transport-ws": "^0.11.0"
},
"keywords": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
* limitations under the License.
*/

import { Moment } from 'moment';

export interface FormContent {
formRepresentation: FormRepresentation;
}
Expand Down Expand Up @@ -109,7 +107,7 @@ export interface VisibilityCondition {
leftType: string;
leftValue: string;
operator: string;
rightValue: string | number | Date | Moment;
rightValue: string | number | Date;
rightType: string;
nextConditionOperator?: string;
nextCondition?: VisibilityCondition;
Expand Down
1 change: 0 additions & 1 deletion lib/process-services/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ module.exports = function (config) {
},
{ pattern: 'node_modules/chart.js/dist/Chart.js', included: true, watched: false },
{ pattern: 'node_modules/raphael/raphael.min.js', included: true, watched: false },
{ pattern: 'node_modules/moment/min/moment.min.js', included: true, watched: false },
{ pattern: 'lib/core/src/lib/i18n/**/en.json', included: false, served: true, watched: false },
{ pattern: 'lib/content-services/src/lib/i18n/**/en.json', included: false, served: true, watched: false },
{ pattern: 'lib/process-services/src/lib/i18n/**/en.json', included: false, served: true, watched: false },
Expand Down
3 changes: 1 addition & 2 deletions lib/process-services/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@
"@alfresco/js-api": ">=7.1.0-1437",
"@alfresco/adf-core": ">=6.3.0",
"@alfresco/adf-content-services": ">=6.3.0",
"@ngx-translate/core": ">=14.0.0",
"moment": ">=2.22.2"
"@ngx-translate/core": ">=14.0.0"
},
"keywords": [
"process-services",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ export class DateEditorComponent implements OnInit {
constructor(private dateAdapter: DateAdapter<Date>) {}

ngOnInit() {
const momentDateAdapter = this.dateAdapter as AdfDateFnsAdapter;
momentDateAdapter.displayFormat = this.DATE_FORMAT;
const dateAdapter = this.dateAdapter as AdfDateFnsAdapter;
dateAdapter.displayFormat = this.DATE_FORMAT;

this.value = this.table.getCellValue(this.row, this.column) as Date;
}
Expand Down
34 changes: 4 additions & 30 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@
"@angular/forms": "14.1.3",
"@angular/material": "14.1.2",
"@angular/material-date-fns-adapter": "^14.1.2",
"@angular/material-moment-adapter": "14.1.2",
"@angular/platform-browser": "14.1.3",
"@angular/platform-browser-dynamic": "14.1.3",
"@angular/router": "14.1.3",
Expand All @@ -74,7 +73,6 @@
"@editorjs/list": "1.8.0",
"@editorjs/underline": "1.1.0",
"@mat-datetimepicker/core": "^10.1.1",
"@mat-datetimepicker/moment": "^10.1.1",
"@ngx-translate/core": "^14.0.0",
"@storybook/core-server": "^6.5.16",
"angular-oauth2-oidc": "^13.0.1",
Expand Down Expand Up @@ -168,6 +166,7 @@
"lint-staged": "^13.2.0",
"lite-server": "^2.6.1",
"mini-css-extract-plugin": "^2.7.6",
"moment": "^2.29.4",
"nconf": "^0.12.0",
"ng-packagr": "14.0.3",
"nx": "14.4.2",
Expand Down Expand Up @@ -227,4 +226,3 @@
"module": "./index.js",
"typings": "./index.d.ts"
}

Loading