This commit is contained in:
seb
2026-07-31 19:49:07 +02:00
parent 6b1701d4dc
commit e8326e22ac
10 changed files with 827 additions and 5 deletions

View File

@@ -1,3 +1,4 @@
import { readFile } from 'node:fs/promises';
import 'dotenv/config';
import sql from 'mssql';
import chalk from 'chalk';
@@ -119,6 +120,11 @@ const MENU = {
label: 'updateBySku',
hint: 'googleAuthId, sku, name → row',
},
{
value: 'article.addImage',
label: 'addImage',
hint: 'googleAuthId, sku, avif file path → sizes',
},
],
},
companyuser: {
@@ -420,6 +426,23 @@ async function runMethod(client, action) {
await client.article.updateBySku(Number(googleAuthId), sku, { name }),
];
}
case 'article.addImage': {
const googleAuthId = await askInt('google_auth id');
if (googleAuthId == null) return;
const sku = await askText('sku', {
validate: (v) => (!v?.trim() ? 'Required' : undefined),
});
if (sku == null) return;
const filePath = await askText('AVIF file path', {
validate: (v) => (!v?.trim() ? 'Required' : undefined),
});
if (filePath == null) return;
const image = await readFile(filePath.trim());
return [
'result',
await client.article.addImage(Number(googleAuthId), sku, image),
];
}
case 'companyuser.add': {
const companyId = await askInt('Company id');
if (companyId == null) return;