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

Fix npm script to run on Windows and Ubuntu without errors #231

Merged
merged 18 commits into from
Apr 1, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
9 changes: 9 additions & 0 deletions .github/workflows/e2e-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,15 @@ jobs:
- name: Check out repository code
uses: actions/checkout@main

- name: Install Yarn to latest stable version
run: |
npx corepack enable
yarn set version stable
yarn cache clean

- name: Install Dependencies
run: yarn install

- name: Build and run
run: |
cd packages/ufb-shared
Expand Down
10 changes: 8 additions & 2 deletions .github/workflows/test-on-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,19 @@ jobs:
- name: Checkout Repo
uses: actions/checkout@v2

- name: Setup Node.js environment
- name: Setup Node.js v18
uses: actions/setup-node@v2
with:
node-version: '18'

- name: Install Yarn to latest stable version
run: |
npx corepack enable
yarn set version stable
yarn cache clean

- name: Install Dependencies
run: yarn install --immutable --immutable-cache --check-cache
run: yarn install

- name: setup environment variables (with opensearch)
run: |
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

# dependencies
node_modules
'node_modules
.pnp
.pnp.js

Expand Down Expand Up @@ -50,4 +51,4 @@ test-results
user.json

# JetBrains
.idea
.idea
1 change: 1 addition & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nodeLinker: node-modules
3 changes: 3 additions & 0 deletions apps/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"clean": "git clean -xdf dist .turbo node_modules",
"dev": "nest start --watch",
"format": "prettier --check \"./src/**/*.{js,cjs,mjs,ts,tsx,md,json}\"",
"format:fix": "prettier --write --list-different \"./src/**/*.{js,cjs,mjs,ts,tsx,md,json}\"",
"lint": "eslint \"src/**/*.ts\"",
"migration:generate": "npm run typeorm -- migration:generate src/configs/modules/typeorm-config/migrations/$npm_config_name",
"migration:revert": "npm run typeorm -- migration:revert",
Expand Down Expand Up @@ -44,6 +45,7 @@
"@nestjs/terminus": "^10.1.1",
"@nestjs/typeorm": "^10.0.0",
"@opensearch-project/opensearch": "^2.4.0",
"@swc/helpers": "^0.5.8",
"@ufb/shared": "^0.1.0",
"@willsoto/nestjs-prometheus": "^6.0.0",
"aws-sdk": "^2.1509.0",
Expand All @@ -54,6 +56,7 @@
"exceljs": "^4.4.0",
"fast-csv": "^5.0.1",
"joi": "^17.11.0",
"luxon": "^3.4.4",
"magic-bytes.js": "^1.8.0",
"mysql2": "^3.6.2",
"nestjs-cls": "^3.6.0",
Expand Down
10 changes: 5 additions & 5 deletions apps/api/src/domains/admin/channel/field/field.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ export class FieldService {
search_analyzer: 'ngram_analyzer',
}
: field.format === FieldFormatEnum.date
? {
type: FIELD_TYPES_TO_MAPPING_TYPES[field.format],
format: `yyyy-MM-dd HH:mm:ss||yyyy-MM-dd HH:mm:ssZ||yyyy-MM-dd HH:mm:ssZZZZZ||yyyy-MM-dd||epoch_millis||strict_date_optional_time`,
}
: { type: FIELD_TYPES_TO_MAPPING_TYPES[field.format] },
? {
type: FIELD_TYPES_TO_MAPPING_TYPES[field.format],
format: `yyyy-MM-dd HH:mm:ss||yyyy-MM-dd HH:mm:ssZ||yyyy-MM-dd HH:mm:ssZZZZZ||yyyy-MM-dd||epoch_millis||strict_date_optional_time`,
}
: { type: FIELD_TYPES_TO_MAPPING_TYPES[field.format] },
}),
{},
);
Expand Down
8 changes: 5 additions & 3 deletions apps/api/src/domains/admin/statistics/utils/util-functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,11 @@ export function getIntervalDatesInFormat(
};
} else {
const intervalCount = Math.floor(
DateTime.fromJSDate(new Date(inputDate))
.until(DateTime.fromJSDate(new Date(endDate)))
.length(interval) + 1,
Math.abs(
DateTime.fromJSDate(new Date(inputDate))
.diff(DateTime.fromJSDate(new Date(endDate)), interval)
.as(`${interval}s`),
) + 1,
);
const startOfInterval =
DateTime.fromJSDate(new Date(endDate))
Expand Down
2 changes: 1 addition & 1 deletion apps/e2e/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@
"axios": "^1.6.7",
"mysql2": "^3.6.5"
}
}
}
3 changes: 2 additions & 1 deletion apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
"clean": "git clean -xdf .next .turbo node_modules",
"dev": "next dev",
"format": "prettier --check \"./src/**/*.{js,cjs,mjs,ts,tsx,md,json}\"",
"format:fix": "prettier --write --list-different \"./src/**/*.{js,cjs,mjs,ts,tsx,md,json}\"",
"generate-api-type": "openapi-typescript http://0.0.0.0:4000/admin-docs-json --output src/types/api.type.ts",
"lint": "SKIP_ENV_VALIDATION=1 next lint",
"lint": "set SKIP_ENV_VALIDATION=1 && next lint",
"start": "next start",
"test": "jest --passWithNoTests",
"test:ci": "jest --ci --passWithNoTests",
Expand Down
4 changes: 2 additions & 2 deletions apps/web/src/components/cards/DashboardCard/DashboardCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ const DashboardCard: React.FC<IProps> = (props) => {
percentage === 0
? 'text-secondary'
: percentage > 0
? 'text-blue-primary'
: 'text-red-primary'
? 'text-blue-primary'
: 'text-red-primary'
}
>
{parseFloat(Math.abs(percentage).toFixed(1))}%
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,9 @@ export const objToStr = (
}
case 'issue':
if (Array.isArray(value)) {
const issueName = column.options?.find((v) => v.id === value[0])
?.name;
const issueName = column.options?.find(
(v) => v.id === value[0],
)?.name;
return `${name}:${issueName}`;
} else if (value?.name) {
const issueName = value?.name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,14 @@ const columns = [
getValue() === 'API'
? 'blue'
: getValue() === 'ADMIN'
? 'green'
: 'black';
? 'green'
: 'black';
const type =
getValue() === 'API'
? 'primary'
: getValue() === 'ADMIN'
? 'primary'
: 'secondary';
? 'primary'
: 'secondary';
return (
<Badge color={color} type={type}>
{getValue()}
Expand Down
8 changes: 4 additions & 4 deletions apps/web/src/containers/create-channel/InputField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,14 @@ const getColumns = (
getValue() === 'API'
? 'blue'
: getValue() === 'ADMIN'
? 'green'
: 'black';
? 'green'
: 'black';
const type =
getValue() === 'API'
? 'primary'
: getValue() === 'ADMIN'
? 'primary'
: 'secondary';
? 'primary'
: 'secondary';
return (
<Badge color={color} type={type}>
{getValue()}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,14 @@ const getColumns = (
getValue() === 'API'
? 'blue'
: getValue() === 'ADMIN'
? 'green'
: 'black';
? 'green'
: 'black';
const type =
getValue() === 'API'
? 'primary'
: getValue() === 'ADMIN'
? 'primary'
: 'secondary';
? 'primary'
: 'secondary';
return (
<Badge color={color} type={type}>
{getValue()}
Expand Down
44 changes: 23 additions & 21 deletions apps/web/src/containers/setting-menu/FieldSetting/PreviewTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,27 +75,29 @@ const PreviewTable: React.FC<IProps> = ({ fields }) => {
field.format === 'date'
? faker.date.anytime()
: field.format === 'keyword'
? faker.word.noun()
: field.format === 'multiSelect'
? faker.helpers.arrayElements(
(field.options ?? []).map((v) => v.name),
)
: field.format === 'select'
? faker.helpers.arrayElement(
(field.options ?? []).map((v) => v.name),
)
: field.format === 'number'
? faker.number.int()
: field.format === 'text'
? faker.lorem.text()
: field.format === 'images'
? faker.helpers.arrayElements(
Array.from(
{ length: faker.number.int({ min: 1, max: 15 }) },
() => '/assets/images/sample_image.png',
),
)
: null;
? faker.word.noun()
: field.format === 'multiSelect'
? faker.helpers.arrayElements(
(field.options ?? []).map((v) => v.name),
)
: field.format === 'select'
? faker.helpers.arrayElement(
(field.options ?? []).map((v) => v.name),
)
: field.format === 'number'
? faker.number.int()
: field.format === 'text'
? faker.lorem.text()
: field.format === 'images'
? faker.helpers.arrayElements(
Array.from(
{
length: faker.number.int({ min: 1, max: 15 }),
},
() => '/assets/images/sample_image.png',
),
)
: null;
}
}
fakeRows.push(fakeData);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,11 +178,10 @@ const WebhookUpsertDialog: React.FC<IProps> = (props) => {

const getEventChannels = (type: WebhookEventEnum) => {
const channels = data?.items ?? [];
return channels.filter(
(channel) =>
watch('events')
.find((e) => e.type === type)
?.channelIds?.includes(channel.id),
return channels.filter((channel) =>
watch('events')
.find((e) => e.type === type)
?.channelIds?.includes(channel.id),
);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,12 @@ const ColumnSettingPopover: React.FC<IProps> = ({
columnOrder.length === 0
? (columns.map((v) => v.id) as string[])
: columnOrder.length === columns.length
? columnOrder
: columnOrder.concat(
columns
.filter((v) => !columnOrder.includes(v.id as string))
.map((v) => v.id) as string[],
),
? columnOrder
: columnOrder.concat(
columns
.filter((v) => !columnOrder.includes(v.id as string))
.map((v) => v.id) as string[],
),
[columns, columnOrder],
);

Expand All @@ -77,8 +77,8 @@ const ColumnSettingPopover: React.FC<IProps> = ({
(typeof columnVisibility[key] === 'undefined'
? 1
: columnVisibility[key]
? 1
: 0)
? 1
: 0)
);
}, 0);
}, [columnKeys, columnVisibility]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,8 @@ const DownloadButton: React.FC<IDownloadButtonProps> = ({
query: {
...query,
createdAt: {
gte: dayjs(createdAtRange?.startDate)
.startOf('day')
.toISOString(),
lt: dayjs(createdAtRange?.endDate)
.endOf('day')
.toISOString(),
gte: dayjs(createdAtRange?.startDate).startOf('day').toISOString(),
lt: dayjs(createdAtRange?.endDate).endOf('day').toISOString(),
},
},
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,14 @@ const EditableCell: React.FC<IProps> = memo((props) => {
field.format === 'select'
? field.options?.find((v) => v.key === value) ?? null
: field.format === 'multiSelect'
? (value ?? []).map(
(optionKey: string) =>
? (value ?? []).map((optionKey: string) =>
field.options?.find((v) => v.key === optionKey),
)
: field.format === 'number'
? value
? Number(value)
: null
: value,
)
: field.format === 'number'
? value
? Number(value)
: null
: value,
);
}, [value]);

Expand All @@ -71,16 +70,16 @@ const EditableCell: React.FC<IProps> = memo((props) => {
field.format === 'text' || field.format === 'keyword'
? currentValue ?? ''
: field.format === 'number'
? Number(currentValue)
: field.format === 'date'
? new Date(currentValue)
: field.format === 'select'
? currentValue?.key ?? null
: field.format === 'multiSelect'
? (currentValue ?? []).map(
(v: { id: number; key: string; name: string }) => v.key,
) ?? null
: currentValue,
? Number(currentValue)
: field.format === 'date'
? new Date(currentValue)
: field.format === 'select'
? currentValue?.key ?? null
: field.format === 'multiSelect'
? (currentValue ?? []).map(
(v: { id: number; key: string; name: string }) => v.key,
) ?? null
: currentValue,
);
}, [currentValue, editableState]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ const getSearchItemPriority = (a: SearchItemType) =>
a.name === 'Created'
? 1
: a.name === 'Updated'
? 2
: a.name === 'Issue'
? 3
: 4;
? 2
: a.name === 'Issue'
? 3
: 4;
interface IProps {
onChangeChannel: (channelId: number) => void;
columns: ColumnDef<any, any>[];
Expand Down
4 changes: 2 additions & 2 deletions apps/web/src/hooks/useOAIQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ export default function useOAIQuery<
} & (TVariables extends undefined
? { variables?: undefined }
: O.RequiredKeys<NonNullable<TVariables>> extends never
? { variables?: TVariables }
: { variables: TVariables })) {
? { variables?: TVariables }
: { variables: TVariables })) {
return useQuery<
TData,
IFetchError,
Expand Down
Loading
Loading