Remove moment
This commit is contained in:
@ -1,6 +1,6 @@
|
|||||||
// @flow
|
// @flow
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import moment from 'moment';
|
import distanceInWordsToNow from 'date-fns/distance_in_words_to_now';
|
||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
import Flex from 'shared/components/Flex';
|
import Flex from 'shared/components/Flex';
|
||||||
import Avatar from 'components/Avatar';
|
import Avatar from 'components/Avatar';
|
||||||
@ -20,9 +20,13 @@ const Collaborators = ({ document }: Props) => {
|
|||||||
let tooltip;
|
let tooltip;
|
||||||
|
|
||||||
if (createdAt === updatedAt) {
|
if (createdAt === updatedAt) {
|
||||||
tooltip = `${createdBy.name} published ${moment(createdAt).fromNow()}`;
|
tooltip = `${createdBy.name} published ${distanceInWordsToNow(
|
||||||
|
new Date(createdAt)
|
||||||
|
)} ago`;
|
||||||
} else {
|
} else {
|
||||||
tooltip = `${updatedBy.name} modified ${moment(updatedAt).fromNow()}`;
|
tooltip = `${updatedBy.name} modified ${distanceInWordsToNow(
|
||||||
|
new Date(updatedAt)
|
||||||
|
)} ago`;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
// @flow
|
// @flow
|
||||||
import React, { Component } from 'react';
|
import React, { Component } from 'react';
|
||||||
import moment from 'moment';
|
import distanceInWordsToNow from 'date-fns/distance_in_words_to_now';
|
||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
import { color } from 'shared/styles/constants';
|
import { color } from 'shared/styles/constants';
|
||||||
import Collection from 'models/Collection';
|
import Collection from 'models/Collection';
|
||||||
@ -35,7 +35,7 @@ class PublishingInfo extends Component {
|
|||||||
publishedAt,
|
publishedAt,
|
||||||
} = document;
|
} = document;
|
||||||
|
|
||||||
const timeAgo = moment(createdAt).fromNow();
|
const timeAgo = `${distanceInWordsToNow(new Date(createdAt))} ago`;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Container align="center">
|
<Container align="center">
|
||||||
|
244
flow-typed/npm/moment_v2.x.x.js
vendored
244
flow-typed/npm/moment_v2.x.x.js
vendored
@ -1,244 +0,0 @@
|
|||||||
// flow-typed signature: 18b0758a665cf7eb72bdb60fb6713aca
|
|
||||||
// flow-typed version: 5eb011abdd/moment_v2.x.x/flow_>=v0.34.x
|
|
||||||
|
|
||||||
type moment$MomentOptions = {
|
|
||||||
y?: number|string,
|
|
||||||
year?: number|string,
|
|
||||||
years?: number|string,
|
|
||||||
M?: number|string,
|
|
||||||
month?: number|string,
|
|
||||||
months?: number|string,
|
|
||||||
d?: number|string,
|
|
||||||
day?: number|string,
|
|
||||||
days?: number|string,
|
|
||||||
date?: number|string,
|
|
||||||
h?: number|string,
|
|
||||||
hour?: number|string,
|
|
||||||
hours?: number|string,
|
|
||||||
m?: number|string,
|
|
||||||
minute?: number|string,
|
|
||||||
minutes?: number|string,
|
|
||||||
s?: number|string,
|
|
||||||
second?: number|string,
|
|
||||||
seconds?: number|string,
|
|
||||||
ms?: number|string,
|
|
||||||
millisecond?: number|string,
|
|
||||||
milliseconds?: number|string,
|
|
||||||
};
|
|
||||||
|
|
||||||
type moment$MomentObject = {
|
|
||||||
years: number,
|
|
||||||
months: number,
|
|
||||||
date: number,
|
|
||||||
hours: number,
|
|
||||||
minutes: number,
|
|
||||||
seconds: number,
|
|
||||||
milliseconds: number,
|
|
||||||
};
|
|
||||||
|
|
||||||
type moment$MomentCreationData = {
|
|
||||||
input: string,
|
|
||||||
format: string,
|
|
||||||
locale: Object,
|
|
||||||
isUTC: bool,
|
|
||||||
strict: bool,
|
|
||||||
};
|
|
||||||
|
|
||||||
type moment$CalendarFormat = string | (moment: moment$Moment) => string;
|
|
||||||
|
|
||||||
type moment$CalendarFormats = {
|
|
||||||
sameDay?: moment$CalendarFormat,
|
|
||||||
nextDay?: moment$CalendarFormat,
|
|
||||||
nextWeek?: moment$CalendarFormat,
|
|
||||||
lastDay?: moment$CalendarFormat,
|
|
||||||
lastWeek?: moment$CalendarFormat,
|
|
||||||
sameElse?: moment$CalendarFormat,
|
|
||||||
};
|
|
||||||
|
|
||||||
type moment$Inclusivity = '()' | '[)' | '()' | '(]' | '[]'
|
|
||||||
|
|
||||||
declare class moment$LocaleData {
|
|
||||||
months(moment: moment$Moment): string;
|
|
||||||
monthsShort(moment: moment$Moment): string;
|
|
||||||
monthsParse(month: string): number;
|
|
||||||
weekdays(moment: moment$Moment): string;
|
|
||||||
weekdaysShort(moment: moment$Moment): string;
|
|
||||||
weekdaysMin(moment: moment$Moment): string;
|
|
||||||
weekdaysParse(weekDay: string): number;
|
|
||||||
longDateFormat(dateFormat: string): string;
|
|
||||||
isPM(date: string): bool;
|
|
||||||
meridiem(hours: number, minutes: number, isLower: bool): string;
|
|
||||||
calendar(key: 'sameDay'|'nextDay'|'lastDay'|'nextWeek'|'prevWeek'|'sameElse', moment: moment$Moment): string;
|
|
||||||
relativeTime(number: number, withoutSuffix: bool, key: 's'|'m'|'mm'|'h'|'hh'|'d'|'dd'|'M'|'MM'|'y'|'yy', isFuture: bool): string;
|
|
||||||
pastFuture(diff: any, relTime: string): string;
|
|
||||||
ordinal(number: number): string;
|
|
||||||
preparse(str: string): any;
|
|
||||||
postformat(str: string): any;
|
|
||||||
week(moment: moment$Moment): string;
|
|
||||||
invalidDate(): string;
|
|
||||||
firstDayOfWeek(): number;
|
|
||||||
firstDayOfYear(): number;
|
|
||||||
}
|
|
||||||
declare class moment$MomentDuration {
|
|
||||||
humanize(suffix?: bool): string;
|
|
||||||
milliseconds(): number;
|
|
||||||
asMilliseconds(): number;
|
|
||||||
seconds(): number;
|
|
||||||
asSeconds(): number;
|
|
||||||
minutes(): number;
|
|
||||||
asMinutes(): number;
|
|
||||||
hours(): number;
|
|
||||||
asHours(): number;
|
|
||||||
days(): number;
|
|
||||||
asDays(): number;
|
|
||||||
months(): number;
|
|
||||||
asMonths(): number;
|
|
||||||
years(): number;
|
|
||||||
asYears(): number;
|
|
||||||
add(value: number|moment$MomentDuration|Object, unit?: string): this;
|
|
||||||
subtract(value: number|moment$MomentDuration|Object, unit?: string): this;
|
|
||||||
as(unit: string): number;
|
|
||||||
get(unit: string): number;
|
|
||||||
toJSON(): string;
|
|
||||||
toISOString(): string;
|
|
||||||
}
|
|
||||||
declare class moment$Moment {
|
|
||||||
static ISO_8601: string;
|
|
||||||
static (string?: string, format?: string|Array<string>, locale?: string, strict?: bool): moment$Moment;
|
|
||||||
static (
|
|
||||||
initDate: ?Object|number|Date|Array<number>|moment$Moment|string,
|
|
||||||
validFormats?: ?Array<string>|string,
|
|
||||||
locale?: ?boolean|string,
|
|
||||||
strict?: ?boolean|string
|
|
||||||
): moment$Moment;
|
|
||||||
static unix(seconds: number): moment$Moment;
|
|
||||||
static utc(): moment$Moment;
|
|
||||||
static utc(number: number|Array<number>): moment$Moment;
|
|
||||||
static utc(str: string, str2?: string|Array<string>, str3?: string): moment$Moment;
|
|
||||||
static utc(moment: moment$Moment): moment$Moment;
|
|
||||||
static utc(date: Date): moment$Moment;
|
|
||||||
static parseZone(rawDate: string): moment$Moment;
|
|
||||||
isValid(): bool;
|
|
||||||
invalidAt(): 0|1|2|3|4|5|6;
|
|
||||||
creationData(): moment$MomentCreationData;
|
|
||||||
millisecond(number: number): this;
|
|
||||||
milliseconds(number: number): this;
|
|
||||||
millisecond(): number;
|
|
||||||
milliseconds(): number;
|
|
||||||
second(number: number): this;
|
|
||||||
seconds(number: number): this;
|
|
||||||
second(): number;
|
|
||||||
seconds(): number;
|
|
||||||
minute(number: number): this;
|
|
||||||
minutes(number: number): this;
|
|
||||||
minute(): number;
|
|
||||||
minutes(): number;
|
|
||||||
hour(number: number): this;
|
|
||||||
hours(number: number): this;
|
|
||||||
hour(): number;
|
|
||||||
hours(): number;
|
|
||||||
date(number: number): this;
|
|
||||||
dates(number: number): this;
|
|
||||||
date(): number;
|
|
||||||
dates(): number;
|
|
||||||
day(day: number|string): this;
|
|
||||||
days(day: number|string): this;
|
|
||||||
day(): number;
|
|
||||||
days(): number;
|
|
||||||
weekday(number: number): this;
|
|
||||||
weekday(): number;
|
|
||||||
isoWeekday(number: number): this;
|
|
||||||
isoWeekday(): number;
|
|
||||||
dayOfYear(number: number): this;
|
|
||||||
dayOfYear(): number;
|
|
||||||
week(number: number): this;
|
|
||||||
weeks(number: number): this;
|
|
||||||
week(): number;
|
|
||||||
weeks(): number;
|
|
||||||
isoWeek(number: number): this;
|
|
||||||
isoWeeks(number: number): this;
|
|
||||||
isoWeek(): number;
|
|
||||||
isoWeeks(): number;
|
|
||||||
month(number: number): this;
|
|
||||||
months(number: number): this;
|
|
||||||
month(): number;
|
|
||||||
months(): number;
|
|
||||||
quarter(number: number): this;
|
|
||||||
quarter(): number;
|
|
||||||
year(number: number): this;
|
|
||||||
years(number: number): this;
|
|
||||||
year(): number;
|
|
||||||
years(): number;
|
|
||||||
weekYear(number: number): this;
|
|
||||||
weekYear(): number;
|
|
||||||
isoWeekYear(number: number): this;
|
|
||||||
isoWeekYear(): number;
|
|
||||||
weeksInYear(): number;
|
|
||||||
isoWeeksInYear(): number;
|
|
||||||
get(string: string): number;
|
|
||||||
set(unit: string, value: number): this;
|
|
||||||
set(options: { [unit: string]: number }): this;
|
|
||||||
static max(...dates: Array<moment$Moment>): moment$Moment;
|
|
||||||
static max(dates: Array<moment$Moment>): moment$Moment;
|
|
||||||
static min(...dates: Array<moment$Moment>): moment$Moment;
|
|
||||||
static min(dates: Array<moment$Moment>): moment$Moment;
|
|
||||||
add(value: number|moment$MomentDuration|moment$Moment|Object, unit?: string): this;
|
|
||||||
subtract(value: number|moment$MomentDuration|moment$Moment|string|Object, unit?: string): this;
|
|
||||||
startOf(unit: string): this;
|
|
||||||
endOf(unit: string): this;
|
|
||||||
local(): this;
|
|
||||||
utc(): this;
|
|
||||||
utcOffset(offset: number|string, keepLocalTime?: boolean, keepMinutes?: boolean): this;
|
|
||||||
utcOffset(): number;
|
|
||||||
format(format?: string): string;
|
|
||||||
fromNow(removeSuffix?: bool): string;
|
|
||||||
from(value: moment$Moment|string|number|Date|Array<number>, removePrefix?: bool): string;
|
|
||||||
toNow(removePrefix?: bool): string;
|
|
||||||
to(value: moment$Moment|string|number|Date|Array<number>, removePrefix?: bool): string;
|
|
||||||
calendar(refTime?: any, formats?: moment$CalendarFormats): string;
|
|
||||||
diff(date: moment$Moment|string|number|Date|Array<number>, format?: string, floating?: bool): number;
|
|
||||||
valueOf(): number;
|
|
||||||
unix(): number;
|
|
||||||
daysInMonth(): number;
|
|
||||||
toDate(): Date;
|
|
||||||
toArray(): Array<number>;
|
|
||||||
toJSON(): string;
|
|
||||||
toISOString(): string;
|
|
||||||
toObject(): moment$MomentObject;
|
|
||||||
isBetween(from: moment$Moment|string|number|Date|Array<number>, to: moment$Moment|string|number|Date|Array<number>, units?: string, inclusivity?: moment$Inclusivity): bool;
|
|
||||||
isBefore(date?: moment$Moment|string|number|Date|Array<number>, units?: ?string): bool;
|
|
||||||
isSame(date?: moment$Moment|string|number|Date|Array<number>, units?: ?string): bool;
|
|
||||||
isAfter(date?: moment$Moment|string|number|Date|Array<number>, units?: ?string): bool;
|
|
||||||
isSameOrBefore(date?: moment$Moment|string|number|Date|Array<number>, units?: ?string): bool;
|
|
||||||
isSameOrAfter(date?: moment$Moment|string|number|Date|Array<number>, units?: ?string): bool;
|
|
||||||
isDST(): bool;
|
|
||||||
isDSTShifted(): bool;
|
|
||||||
isLeapYear(): bool;
|
|
||||||
clone(): moment$Moment;
|
|
||||||
static isMoment(obj: any): bool;
|
|
||||||
static isDate(obj: any): bool;
|
|
||||||
static locale(locale: string, localeData?: Object): string;
|
|
||||||
static updateLocale(locale: string, localeData?: ?Object): void;
|
|
||||||
static locale(locales: Array<string>): string;
|
|
||||||
locale(locale: string, customization?: Object|null): moment$Moment;
|
|
||||||
locale(): string;
|
|
||||||
static months(): Array<string>;
|
|
||||||
static monthsShort(): Array<string>;
|
|
||||||
static weekdays(): Array<string>;
|
|
||||||
static weekdaysShort(): Array<string>;
|
|
||||||
static weekdaysMin(): Array<string>;
|
|
||||||
static months(): string;
|
|
||||||
static monthsShort(): string;
|
|
||||||
static weekdays(): string;
|
|
||||||
static weekdaysShort(): string;
|
|
||||||
static weekdaysMin(): string;
|
|
||||||
static localeData(key?: string): moment$LocaleData;
|
|
||||||
static duration(value: number|Object|string, unit?: string): moment$MomentDuration;
|
|
||||||
static isDuration(obj: any): bool;
|
|
||||||
static normalizeUnits(unit: string): string;
|
|
||||||
static invalid(object: any): moment$Moment;
|
|
||||||
}
|
|
||||||
|
|
||||||
declare module 'moment' {
|
|
||||||
declare module.exports: Class<moment$Moment>;
|
|
||||||
}
|
|
@ -90,6 +90,7 @@
|
|||||||
"cancan": "3.1.0",
|
"cancan": "3.1.0",
|
||||||
"copy-to-clipboard": "^3.0.6",
|
"copy-to-clipboard": "^3.0.6",
|
||||||
"css-loader": "^0.28.7",
|
"css-loader": "^0.28.7",
|
||||||
|
"date-fns": "1.29.0",
|
||||||
"debug": "2.2.0",
|
"debug": "2.2.0",
|
||||||
"dotenv": "^4.0.0",
|
"dotenv": "^4.0.0",
|
||||||
"emoji-regex": "^6.5.1",
|
"emoji-regex": "^6.5.1",
|
||||||
@ -135,7 +136,6 @@
|
|||||||
"mobx": "^3.1.9",
|
"mobx": "^3.1.9",
|
||||||
"mobx-react": "^4.1.8",
|
"mobx-react": "^4.1.8",
|
||||||
"mobx-react-devtools": "^4.2.11",
|
"mobx-react-devtools": "^4.2.11",
|
||||||
"moment": "2.13.0",
|
|
||||||
"natural-sort": "^1.0.0",
|
"natural-sort": "^1.0.0",
|
||||||
"node-dev": "3.1.0",
|
"node-dev": "3.1.0",
|
||||||
"nodemailer": "^4.4.0",
|
"nodemailer": "^4.4.0",
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
// @flow
|
// @flow
|
||||||
import crypto from 'crypto';
|
import crypto from 'crypto';
|
||||||
import moment from 'moment';
|
import addHours from 'date-fns/add_hours';
|
||||||
|
import format from 'date-fns/format';
|
||||||
import AWS from 'aws-sdk';
|
import AWS from 'aws-sdk';
|
||||||
import invariant from 'invariant';
|
import invariant from 'invariant';
|
||||||
import fetch from 'isomorphic-fetch';
|
import fetch from 'isomorphic-fetch';
|
||||||
@ -10,6 +11,7 @@ const AWS_SECRET_ACCESS_KEY = process.env.AWS_SECRET_ACCESS_KEY;
|
|||||||
const AWS_S3_UPLOAD_BUCKET_NAME = process.env.AWS_S3_UPLOAD_BUCKET_NAME;
|
const AWS_S3_UPLOAD_BUCKET_NAME = process.env.AWS_S3_UPLOAD_BUCKET_NAME;
|
||||||
|
|
||||||
export const makePolicy = () => {
|
export const makePolicy = () => {
|
||||||
|
const tomorrow = addHours(new Date(), 24);
|
||||||
const policy = {
|
const policy = {
|
||||||
conditions: [
|
conditions: [
|
||||||
{ bucket: process.env.AWS_S3_UPLOAD_BUCKET_NAME },
|
{ bucket: process.env.AWS_S3_UPLOAD_BUCKET_NAME },
|
||||||
@ -19,9 +21,7 @@ export const makePolicy = () => {
|
|||||||
['starts-with', '$Content-Type', 'image'],
|
['starts-with', '$Content-Type', 'image'],
|
||||||
['starts-with', '$Cache-Control', ''],
|
['starts-with', '$Cache-Control', ''],
|
||||||
],
|
],
|
||||||
expiration: moment()
|
expiration: format(tomorrow, 'YYYY-MM-DDTHH:mm:ss\\Z'),
|
||||||
.add(24 * 60, 'minutes')
|
|
||||||
.format('YYYY-MM-DDTHH:mm:ss\\Z'),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return new Buffer(JSON.stringify(policy)).toString('base64');
|
return new Buffer(JSON.stringify(policy)).toString('base64');
|
||||||
|
@ -70,7 +70,6 @@ module.exports = {
|
|||||||
new webpack.ProvidePlugin({
|
new webpack.ProvidePlugin({
|
||||||
fetch: 'imports-loader?this=>global!exports-loader?global.fetch!isomorphic-fetch',
|
fetch: 'imports-loader?this=>global!exports-loader?global.fetch!isomorphic-fetch',
|
||||||
}),
|
}),
|
||||||
new webpack.ContextReplacementPlugin(/moment[\\\/]locale$/, /^\.\/(en)$/),
|
|
||||||
new webpack.IgnorePlugin(/unicode\/category\/So/),
|
new webpack.IgnorePlugin(/unicode\/category\/So/),
|
||||||
],
|
],
|
||||||
stats: {
|
stats: {
|
||||||
|
12
yarn.lock
12
yarn.lock
@ -2399,6 +2399,10 @@ data-uri-regex@^0.1.2:
|
|||||||
version "0.1.4"
|
version "0.1.4"
|
||||||
resolved "https://registry.yarnpkg.com/data-uri-regex/-/data-uri-regex-0.1.4.tgz#1e1db6c8397eca8a48ecdb55ad1b927ec0bbac2e"
|
resolved "https://registry.yarnpkg.com/data-uri-regex/-/data-uri-regex-0.1.4.tgz#1e1db6c8397eca8a48ecdb55ad1b927ec0bbac2e"
|
||||||
|
|
||||||
|
date-fns@1.29.0:
|
||||||
|
version "1.29.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/date-fns/-/date-fns-1.29.0.tgz#12e609cdcb935127311d04d33334e2960a2a54e6"
|
||||||
|
|
||||||
date-fns@^1.27.2:
|
date-fns@^1.27.2:
|
||||||
version "1.28.5"
|
version "1.28.5"
|
||||||
resolved "https://registry.yarnpkg.com/date-fns/-/date-fns-1.28.5.tgz#257cfc45d322df45ef5658665967ee841cd73faf"
|
resolved "https://registry.yarnpkg.com/date-fns/-/date-fns-1.28.5.tgz#257cfc45d322df45ef5658665967ee841cd73faf"
|
||||||
@ -6545,14 +6549,14 @@ moment-timezone@^0.5.4:
|
|||||||
dependencies:
|
dependencies:
|
||||||
moment ">= 2.9.0"
|
moment ">= 2.9.0"
|
||||||
|
|
||||||
moment@2.13.0, moment@^2.13.0:
|
|
||||||
version "2.13.0"
|
|
||||||
resolved "https://registry.yarnpkg.com/moment/-/moment-2.13.0.tgz#24162d99521e6d40f99ae6939e806d2139eaac52"
|
|
||||||
|
|
||||||
moment@2.x.x, "moment@>= 2.9.0", moment@^2.16.0, moment@^2.17.1:
|
moment@2.x.x, "moment@>= 2.9.0", moment@^2.16.0, moment@^2.17.1:
|
||||||
version "2.18.1"
|
version "2.18.1"
|
||||||
resolved "https://registry.yarnpkg.com/moment/-/moment-2.18.1.tgz#c36193dd3ce1c2eed2adb7c802dbbc77a81b1c0f"
|
resolved "https://registry.yarnpkg.com/moment/-/moment-2.18.1.tgz#c36193dd3ce1c2eed2adb7c802dbbc77a81b1c0f"
|
||||||
|
|
||||||
|
moment@^2.13.0:
|
||||||
|
version "2.13.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/moment/-/moment-2.13.0.tgz#24162d99521e6d40f99ae6939e806d2139eaac52"
|
||||||
|
|
||||||
morgan@~1.6.1:
|
morgan@~1.6.1:
|
||||||
version "1.6.1"
|
version "1.6.1"
|
||||||
resolved "https://registry.yarnpkg.com/morgan/-/morgan-1.6.1.tgz#5fd818398c6819cba28a7cd6664f292fe1c0bbf2"
|
resolved "https://registry.yarnpkg.com/morgan/-/morgan-1.6.1.tgz#5fd818398c6819cba28a7cd6664f292fe1c0bbf2"
|
||||||
|
Reference in New Issue
Block a user