Skip to content

Commit 47134b0

Browse files
committed
fix: improve error handling and logging in asset upload script
1 parent 3f2de0f commit 47134b0

2 files changed

Lines changed: 28 additions & 14 deletions

File tree

dockers/teable/Dockerfile

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -78,16 +78,12 @@ RUN set -ex; \
7878
pnpm install --prod --prefer-offline --frozen-lockfile; \
7979
pnpm -F @teable/db-main-prisma prisma-generate --schema ./prisma/postgres/schema.prisma
8080

81-
RUN chmod +x ./scripts/upload-assets.mjs;
82-
RUN echo "UPLOAD_ASSETS_LIST: $UPLOAD_ASSETS_LIST";
83-
RUN zx ./scripts/upload-assets.mjs --list="$UPLOAD_ASSETS_LIST";
84-
85-
# RUN set -ex; \
86-
# chmod +x ./scripts/upload-assets.mjs; \
87-
# echo "UPLOAD_ASSETS_LIST: $UPLOAD_ASSETS_LIST"; \
88-
# if [ -n "$UPLOAD_ASSETS_LIST" ]; then \
89-
# zx ./scripts/upload-assets.mjs --list="$UPLOAD_ASSETS_LIST"; \
90-
# fi
81+
RUN set -ex; \
82+
chmod +x ./scripts/upload-assets.mjs; \
83+
echo "UPLOAD_ASSETS_LIST: $UPLOAD_ASSETS_LIST"; \
84+
if [ -n "$UPLOAD_ASSETS_LIST" ]; then \
85+
zx ./scripts/upload-assets.mjs --list="$UPLOAD_ASSETS_LIST"; \
86+
fi
9187

9288

9389
##################################################################

scripts/upload-assets.mjs

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,31 @@ const mcPath = '~/minio-binaries/mc';
77
// [[name, endpoint, accessKey, secretKey, bucket]]
88
const { list } = argv;
99

10-
console.log('test list: ', list);
11-
const parsedList = list && typeof list === 'string' ? JSON.parse(list) : [];
10+
11+
let parsedList = [];
12+
if (list && typeof list === 'string' && list.trim() !== '') {
13+
try {
14+
parsedList = JSON.parse(list);
15+
} catch (error) {
16+
console.warn('Warning: Failed to parse list JSON:', error.message);
17+
console.log('Skipping upload due to invalid configuration...');
18+
process.exit(0);
19+
}
20+
}
21+
1222
if (!Array.isArray(parsedList)) {
13-
console.error('Error: list must be a array');
14-
return;
23+
console.warn('Warning: list must be a array, but got:', typeof parsedList);
24+
console.log('Skipping upload due to invalid configuration...');
25+
process.exit(0);
1526
}
1627

28+
if (parsedList.length === 0) {
29+
console.log('No upload assets list provided, skipping upload...');
30+
process.exit(0);
31+
}
32+
33+
console.log('upload assets list: ', JSON.stringify(parsedList));
34+
1735
const checkPlatform = async () => {
1836
const platform = await $`uname -m`;
1937
const os = await $`uname -s`;

0 commit comments

Comments
 (0)