u
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user