@collectionscms/plugin-text-generator
Advanced tools
Comparing version 1.0.2 to 1.0.3
24
bin.js
@@ -5,9 +5,26 @@ #!/usr/bin/env node | ||
import { TextGenerator } from "./generations/textGenerator.js"; | ||
import { Translator } from "./translations/translator.js"; | ||
const program = new Command(); | ||
const runSummarize = async (options) => { | ||
const value = options.value.trim(); | ||
const generator = new TextGenerator(process.env.OPENAI_API_KEY ?? "", "gpt-4o-mini"); | ||
const apiKey = process.env.OPENAI_API_KEY; | ||
if (!apiKey) { | ||
console.error("❌ Error: OPENAI_API_KEY is not set"); | ||
return; | ||
} | ||
const generator = new TextGenerator(apiKey, "gpt-4o-mini"); | ||
const result = await generator.summarizeSeo(value, "English"); | ||
console.log(`✨ Success`, result); | ||
}; | ||
const runTranslate = async (options) => { | ||
const value = options.value.trim(); | ||
const apiKey = process.env.TRANSLATOR_API_KEY; | ||
if (!apiKey) { | ||
console.error("❌ Error: TRANSLATOR_API_KEY is not set"); | ||
return; | ||
} | ||
const translator = new Translator(apiKey); | ||
const result = await translator.translate([value], "ja", "en-US"); | ||
console.log(`✨ Success`, result); | ||
}; | ||
program | ||
@@ -18,2 +35,7 @@ .command("text:summarize") | ||
.action(runSummarize); | ||
program | ||
.command("text:translate") | ||
.description("translate documents") | ||
.requiredOption("-v, --value <value>", "value option") | ||
.action(runTranslate); | ||
program.parseAsync(process.argv); |
{ | ||
"name": "@collectionscms/plugin-text-generator", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "Text Generation Plugin for Collections.", | ||
@@ -9,2 +9,3 @@ "type": "module", | ||
"text:summarize": "node --loader ts-node/esm ./src/bin.ts text:summarize", | ||
"text:translate": "node --loader ts-node/esm ./src/bin.ts text:translate", | ||
"lint": "eslint 'src/**/*.ts' --ignore-path .gitignore", | ||
@@ -11,0 +12,0 @@ "lint:fix": "npm run lint -- --fix", |
@@ -9,2 +9,3 @@ import * as deepl from "deepl-node"; | ||
preserveFormatting: true, | ||
tagHandling: "html", | ||
}); | ||
@@ -11,0 +12,0 @@ return textResults.map((textResult) => ({ |
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
5666
123
3