Skip to content

Commit f78a0af

Browse files
YoungjaeKimh4l-yup
andauthored
fix: npm script to run on Windows and Ubuntu without errors (#231)
* fix various npm script to work on Windows and Ubuntu * fix build error * apply Prettier format * update yarn from 1.22.19 to 4.1.1 * update GitHub Action for newer Yarn v4 * update GitHub Action for newer Yarn v4 * update GitHub Action for newer Yarn v4 * update GitHub Action for newer Yarn v4 * update GitHub Action for newer Yarn v4 - add yarn cache clean * update GitHub Action for newer Yarn v4 - remove cache check * add dependencies for api:test pass * fix intervalCount to have positive value always * add yarn v2 update in steps * add tabWidth 2 and useTabs to false. * fix: yarn.lock * fix: yarn.lock * fix: yarn.lock --------- Co-authored-by: Carson <[email protected]>
1 parent 2795baf commit f78a0af

File tree

30 files changed

+21018
-15608
lines changed

30 files changed

+21018
-15608
lines changed

.github/workflows/e2e-test.yml

+9
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,15 @@ jobs:
3737
- name: Check out repository code
3838
uses: actions/checkout@main
3939

40+
- name: Install Yarn to latest stable version
41+
run: |
42+
npx corepack enable
43+
yarn set version stable
44+
yarn cache clean
45+
46+
- name: Install Dependencies
47+
run: yarn install
48+
4049
- name: Build and run
4150
run: |
4251
cd packages/ufb-shared

.github/workflows/test-on-pr.yml

+8-2
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,19 @@ jobs:
1212
- name: Checkout Repo
1313
uses: actions/checkout@v2
1414

15-
- name: Setup Node.js environment
15+
- name: Setup Node.js v18
1616
uses: actions/setup-node@v2
1717
with:
1818
node-version: '18'
1919

20+
- name: Install Yarn to latest stable version
21+
run: |
22+
npx corepack enable
23+
yarn set version stable
24+
yarn cache clean
25+
2026
- name: Install Dependencies
21-
run: yarn install --immutable --immutable-cache --check-cache
27+
run: yarn install
2228

2329
- name: setup environment variables (with opensearch)
2430
run: |

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
# dependencies
44
node_modules
5+
'node_modules
56
.pnp
67
.pnp.js
78

@@ -50,4 +51,4 @@ test-results
5051
user.json
5152

5253
# JetBrains
53-
.idea
54+
.idea

.yarnrc.yml

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
nodeLinker: node-modules

apps/api/package.json

+3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"clean": "git clean -xdf dist .turbo node_modules",
88
"dev": "nest start --watch",
99
"format": "prettier --check \"./src/**/*.{js,cjs,mjs,ts,tsx,md,json}\"",
10+
"format:fix": "prettier --write --list-different \"./src/**/*.{js,cjs,mjs,ts,tsx,md,json}\"",
1011
"lint": "eslint \"src/**/*.ts\"",
1112
"migration:generate": "npm run typeorm -- migration:generate src/configs/modules/typeorm-config/migrations/$npm_config_name",
1213
"migration:revert": "npm run typeorm -- migration:revert",
@@ -44,6 +45,7 @@
4445
"@nestjs/terminus": "^10.1.1",
4546
"@nestjs/typeorm": "^10.0.0",
4647
"@opensearch-project/opensearch": "^2.4.0",
48+
"@swc/helpers": "^0.5.8",
4749
"@ufb/shared": "^0.1.0",
4850
"@willsoto/nestjs-prometheus": "^6.0.0",
4951
"aws-sdk": "^2.1509.0",
@@ -54,6 +56,7 @@
5456
"exceljs": "^4.4.0",
5557
"fast-csv": "^5.0.1",
5658
"joi": "^17.11.0",
59+
"luxon": "^3.4.4",
5760
"magic-bytes.js": "^1.8.0",
5861
"mysql2": "^3.6.2",
5962
"nestjs-cls": "^3.6.0",

apps/api/src/domains/admin/channel/field/field.service.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,11 @@ export class FieldService {
5454
search_analyzer: 'ngram_analyzer',
5555
}
5656
: field.format === FieldFormatEnum.date
57-
? {
58-
type: FIELD_TYPES_TO_MAPPING_TYPES[field.format],
59-
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`,
60-
}
61-
: { type: FIELD_TYPES_TO_MAPPING_TYPES[field.format] },
57+
? {
58+
type: FIELD_TYPES_TO_MAPPING_TYPES[field.format],
59+
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`,
60+
}
61+
: { type: FIELD_TYPES_TO_MAPPING_TYPES[field.format] },
6262
}),
6363
{},
6464
);

apps/api/src/domains/admin/statistics/utils/util-functions.ts

+5-3
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,11 @@ export function getIntervalDatesInFormat(
3232
};
3333
} else {
3434
const intervalCount = Math.floor(
35-
DateTime.fromJSDate(new Date(inputDate))
36-
.until(DateTime.fromJSDate(new Date(endDate)))
37-
.length(interval) + 1,
35+
Math.abs(
36+
DateTime.fromJSDate(new Date(inputDate))
37+
.diff(DateTime.fromJSDate(new Date(endDate)), interval)
38+
.as(`${interval}s`),
39+
) + 1,
3840
);
3941
const startOfInterval =
4042
DateTime.fromJSDate(new Date(endDate))

apps/e2e/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@
1010
"axios": "^1.6.7",
1111
"mysql2": "^3.6.5"
1212
}
13-
}
13+
}

apps/web/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@
77
"clean": "git clean -xdf .next .turbo node_modules",
88
"dev": "next dev",
99
"format": "prettier --check \"./src/**/*.{js,cjs,mjs,ts,tsx,md,json}\"",
10+
"format:fix": "prettier --write --list-different \"./src/**/*.{js,cjs,mjs,ts,tsx,md,json}\"",
1011
"generate-api-type": "openapi-typescript http://0.0.0.0:4000/admin-docs-json --output src/types/api.type.ts",
11-
"lint": "SKIP_ENV_VALIDATION=1 next lint",
12+
"lint": "set SKIP_ENV_VALIDATION=1 && next lint",
1213
"start": "next start",
1314
"test": "jest --passWithNoTests",
1415
"test:ci": "jest --ci --passWithNoTests",

apps/web/src/components/cards/DashboardCard/DashboardCard.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ const DashboardCard: React.FC<IProps> = (props) => {
6161
percentage === 0
6262
? 'text-secondary'
6363
: percentage > 0
64-
? 'text-blue-primary'
65-
: 'text-red-primary'
64+
? 'text-blue-primary'
65+
: 'text-red-primary'
6666
}
6767
>
6868
{parseFloat(Math.abs(percentage).toFixed(1))}%

apps/web/src/components/etc/TableSearchInput/table-search-input.service.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,9 @@ export const objToStr = (
8585
}
8686
case 'issue':
8787
if (Array.isArray(value)) {
88-
const issueName = column.options?.find((v) => v.id === value[0])
89-
?.name;
88+
const issueName = column.options?.find(
89+
(v) => v.id === value[0],
90+
)?.name;
9091
return `${name}:${issueName}`;
9192
} else if (value?.name) {
9293
const issueName = value?.name;

apps/web/src/containers/create-channel-complete/FieldSection.tsx

+4-4
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,14 @@ const columns = [
6666
getValue() === 'API'
6767
? 'blue'
6868
: getValue() === 'ADMIN'
69-
? 'green'
70-
: 'black';
69+
? 'green'
70+
: 'black';
7171
const type =
7272
getValue() === 'API'
7373
? 'primary'
7474
: getValue() === 'ADMIN'
75-
? 'primary'
76-
: 'secondary';
75+
? 'primary'
76+
: 'secondary';
7777
return (
7878
<Badge color={color} type={type}>
7979
{getValue()}

apps/web/src/containers/create-channel/InputField.tsx

+4-4
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,14 @@ const getColumns = (
7272
getValue() === 'API'
7373
? 'blue'
7474
: getValue() === 'ADMIN'
75-
? 'green'
76-
: 'black';
75+
? 'green'
76+
: 'black';
7777
const type =
7878
getValue() === 'API'
7979
? 'primary'
8080
: getValue() === 'ADMIN'
81-
? 'primary'
82-
: 'secondary';
81+
? 'primary'
82+
: 'secondary';
8383
return (
8484
<Badge color={color} type={type}>
8585
{getValue()}

apps/web/src/containers/setting-menu/FieldSetting/FieldSetting.tsx

+4-4
Original file line numberDiff line numberDiff line change
@@ -90,14 +90,14 @@ const getColumns = (
9090
getValue() === 'API'
9191
? 'blue'
9292
: getValue() === 'ADMIN'
93-
? 'green'
94-
: 'black';
93+
? 'green'
94+
: 'black';
9595
const type =
9696
getValue() === 'API'
9797
? 'primary'
9898
: getValue() === 'ADMIN'
99-
? 'primary'
100-
: 'secondary';
99+
? 'primary'
100+
: 'secondary';
101101
return (
102102
<Badge color={color} type={type}>
103103
{getValue()}

apps/web/src/containers/setting-menu/FieldSetting/PreviewTable.tsx

+23-21
Original file line numberDiff line numberDiff line change
@@ -75,27 +75,29 @@ const PreviewTable: React.FC<IProps> = ({ fields }) => {
7575
field.format === 'date'
7676
? faker.date.anytime()
7777
: field.format === 'keyword'
78-
? faker.word.noun()
79-
: field.format === 'multiSelect'
80-
? faker.helpers.arrayElements(
81-
(field.options ?? []).map((v) => v.name),
82-
)
83-
: field.format === 'select'
84-
? faker.helpers.arrayElement(
85-
(field.options ?? []).map((v) => v.name),
86-
)
87-
: field.format === 'number'
88-
? faker.number.int()
89-
: field.format === 'text'
90-
? faker.lorem.text()
91-
: field.format === 'images'
92-
? faker.helpers.arrayElements(
93-
Array.from(
94-
{ length: faker.number.int({ min: 1, max: 15 }) },
95-
() => '/assets/images/sample_image.png',
96-
),
97-
)
98-
: null;
78+
? faker.word.noun()
79+
: field.format === 'multiSelect'
80+
? faker.helpers.arrayElements(
81+
(field.options ?? []).map((v) => v.name),
82+
)
83+
: field.format === 'select'
84+
? faker.helpers.arrayElement(
85+
(field.options ?? []).map((v) => v.name),
86+
)
87+
: field.format === 'number'
88+
? faker.number.int()
89+
: field.format === 'text'
90+
? faker.lorem.text()
91+
: field.format === 'images'
92+
? faker.helpers.arrayElements(
93+
Array.from(
94+
{
95+
length: faker.number.int({ min: 1, max: 15 }),
96+
},
97+
() => '/assets/images/sample_image.png',
98+
),
99+
)
100+
: null;
99101
}
100102
}
101103
fakeRows.push(fakeData);

apps/web/src/containers/setting-menu/WebhookSetting/WebhookUpsertDialog.tsx

+4-5
Original file line numberDiff line numberDiff line change
@@ -178,11 +178,10 @@ const WebhookUpsertDialog: React.FC<IProps> = (props) => {
178178

179179
const getEventChannels = (type: WebhookEventEnum) => {
180180
const channels = data?.items ?? [];
181-
return channels.filter(
182-
(channel) =>
183-
watch('events')
184-
.find((e) => e.type === type)
185-
?.channelIds?.includes(channel.id),
181+
return channels.filter((channel) =>
182+
watch('events')
183+
.find((e) => e.type === type)
184+
?.channelIds?.includes(channel.id),
186185
);
187186
};
188187

apps/web/src/containers/tables/FeedbackTable/ColumnSettingPopover/ColumnSettingPopover.tsx

+8-8
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,12 @@ const ColumnSettingPopover: React.FC<IProps> = ({
6161
columnOrder.length === 0
6262
? (columns.map((v) => v.id) as string[])
6363
: columnOrder.length === columns.length
64-
? columnOrder
65-
: columnOrder.concat(
66-
columns
67-
.filter((v) => !columnOrder.includes(v.id as string))
68-
.map((v) => v.id) as string[],
69-
),
64+
? columnOrder
65+
: columnOrder.concat(
66+
columns
67+
.filter((v) => !columnOrder.includes(v.id as string))
68+
.map((v) => v.id) as string[],
69+
),
7070
[columns, columnOrder],
7171
);
7272

@@ -77,8 +77,8 @@ const ColumnSettingPopover: React.FC<IProps> = ({
7777
(typeof columnVisibility[key] === 'undefined'
7878
? 1
7979
: columnVisibility[key]
80-
? 1
81-
: 0)
80+
? 1
81+
: 0)
8282
);
8383
}, 0);
8484
}, [columnKeys, columnVisibility]);

apps/web/src/containers/tables/FeedbackTable/DownloadButton/DownloadButton.tsx

+2-6
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,8 @@ const DownloadButton: React.FC<IDownloadButtonProps> = ({
7474
query: {
7575
...query,
7676
createdAt: {
77-
gte: dayjs(createdAtRange?.startDate)
78-
.startOf('day')
79-
.toISOString(),
80-
lt: dayjs(createdAtRange?.endDate)
81-
.endOf('day')
82-
.toISOString(),
77+
gte: dayjs(createdAtRange?.startDate).startOf('day').toISOString(),
78+
lt: dayjs(createdAtRange?.endDate).endOf('day').toISOString(),
8379
},
8480
},
8581
}),

apps/web/src/containers/tables/FeedbackTable/EditableCell/EditableCell.tsx

+17-18
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,14 @@ const EditableCell: React.FC<IProps> = memo((props) => {
5151
field.format === 'select'
5252
? field.options?.find((v) => v.key === value) ?? null
5353
: field.format === 'multiSelect'
54-
? (value ?? []).map(
55-
(optionKey: string) =>
54+
? (value ?? []).map((optionKey: string) =>
5655
field.options?.find((v) => v.key === optionKey),
57-
)
58-
: field.format === 'number'
59-
? value
60-
? Number(value)
61-
: null
62-
: value,
56+
)
57+
: field.format === 'number'
58+
? value
59+
? Number(value)
60+
: null
61+
: value,
6362
);
6463
}, [value]);
6564

@@ -71,16 +70,16 @@ const EditableCell: React.FC<IProps> = memo((props) => {
7170
field.format === 'text' || field.format === 'keyword'
7271
? currentValue ?? ''
7372
: field.format === 'number'
74-
? Number(currentValue)
75-
: field.format === 'date'
76-
? new Date(currentValue)
77-
: field.format === 'select'
78-
? currentValue?.key ?? null
79-
: field.format === 'multiSelect'
80-
? (currentValue ?? []).map(
81-
(v: { id: number; key: string; name: string }) => v.key,
82-
) ?? null
83-
: currentValue,
73+
? Number(currentValue)
74+
: field.format === 'date'
75+
? new Date(currentValue)
76+
: field.format === 'select'
77+
? currentValue?.key ?? null
78+
: field.format === 'multiSelect'
79+
? (currentValue ?? []).map(
80+
(v: { id: number; key: string; name: string }) => v.key,
81+
) ?? null
82+
: currentValue,
8483
);
8584
}, [currentValue, editableState]);
8685

apps/web/src/containers/tables/FeedbackTable/FeedbackTableBar/FeedbackTableBar.tsx

+4-4
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ const getSearchItemPriority = (a: SearchItemType) =>
3636
a.name === 'Created'
3737
? 1
3838
: a.name === 'Updated'
39-
? 2
40-
: a.name === 'Issue'
41-
? 3
42-
: 4;
39+
? 2
40+
: a.name === 'Issue'
41+
? 3
42+
: 4;
4343
interface IProps {
4444
onChangeChannel: (channelId: number) => void;
4545
columns: ColumnDef<any, any>[];

apps/web/src/hooks/useOAIQuery.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ export default function useOAIQuery<
4848
} & (TVariables extends undefined
4949
? { variables?: undefined }
5050
: O.RequiredKeys<NonNullable<TVariables>> extends never
51-
? { variables?: TVariables }
52-
: { variables: TVariables })) {
51+
? { variables?: TVariables }
52+
: { variables: TVariables })) {
5353
return useQuery<
5454
TData,
5555
IFetchError,

0 commit comments

Comments
 (0)