secure-flow
Advanced tools
Comparing version 1.0.3 to 1.0.4
@@ -13,6 +13,22 @@ #!/usr/bin/env node | ||
const configPath = path.resolve(process.cwd(), "secureflow.config.ts"); | ||
const args = process.argv.slice(2); | ||
let fileType = "javascript"; // Default to JavaScript | ||
if (args.includes("--typescript")) { | ||
fileType = "ts"; | ||
} else if (args.includes("--javascript")) { | ||
fileType = "js"; | ||
} else { | ||
console.error("Invalid argument. Use --typescript or --javascript."); | ||
process.exit(1); | ||
} | ||
// Determine the config file path based on the fileType | ||
const configFileName = `secureflow.config.${fileType}`; | ||
const configPath = path.resolve(process.cwd(), configFileName); | ||
// Check if config file already exists | ||
if (fs.existsSync(configPath)) { | ||
console.error("secureflow.config.ts already exists in the root directory."); | ||
console.error(`${configFileName} already exists in the root directory.`); | ||
process.exit(1); | ||
@@ -19,0 +35,0 @@ } |
@@ -14,5 +14,16 @@ "use strict"; | ||
`; | ||
const configPath = path_1.default.resolve(process.cwd(), 'secureflow.config.ts'); | ||
const args = process.argv.slice(2); | ||
let configPath; | ||
if (args.includes('--typescript')) { | ||
configPath = path_1.default.resolve(process.cwd(), 'secureflow.config.ts'); | ||
} | ||
else if (args.includes('--javascript')) { | ||
configPath = path_1.default.resolve(process.cwd(), 'secureflow.config.js'); | ||
} | ||
else { | ||
console.error('Invalid argument. Use --typescript or --javascript.', args); | ||
process.exit(1); | ||
} | ||
if (fs_1.default.existsSync(configPath)) { | ||
console.error('secureflow.config.ts already exists in the root directory.'); | ||
console.error(args.includes('--typescript') ? 'secureflow.config.js already exists in the root directory.' : 'secureflow.config.ts already exists in the root directory.'); | ||
process.exit(1); | ||
@@ -19,0 +30,0 @@ } |
@@ -11,5 +11,16 @@ "use strict"; | ||
function loadConfig() { | ||
const customConfigPath = path_1.default.resolve(process.cwd(), 'secureflow.config.ts'); | ||
let customConfigPath; | ||
const args = process.argv.slice(2); | ||
if (args.includes('--typescript')) { | ||
customConfigPath = path_1.default.resolve(process.cwd(), 'secureflow.config.ts'); | ||
} | ||
else if (args.includes('--javascript')) { | ||
customConfigPath = path_1.default.resolve(process.cwd(), 'secureflow.config.js'); | ||
} | ||
else { | ||
// Default to JavaScript if no argument is provided | ||
customConfigPath = path_1.default.resolve(process.cwd(), 'secureflow.config.js'); | ||
} | ||
if (fs_1.default.existsSync(customConfigPath)) { | ||
const customConfig = require(customConfigPath); | ||
const customConfig = require(customConfigPath).default || require(customConfigPath); | ||
return Object.assign(Object.assign({}, config_js_1.defaultConfig), customConfig); | ||
@@ -16,0 +27,0 @@ } |
{ | ||
"name": "secure-flow", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"description": "Secure Flow is a lightweight TypeScript utility package for encryption and decryption using the AES-256-CBC algorithm. This package simplifies the process of securely encrypting and decrypting text, making it easy to integrate strong encryption into your Node.js applications.", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -10,7 +10,16 @@ import fs from 'fs'; | ||
`; | ||
const args = process.argv.slice(2); | ||
const configPath = path.resolve(process.cwd(), 'secureflow.config.ts'); | ||
let configPath: string; | ||
if (args.includes('--typescript')) { | ||
configPath = path.resolve(process.cwd(), 'secureflow.config.ts'); | ||
} else if (args.includes('--javascript')) { | ||
configPath = path.resolve(process.cwd(), 'secureflow.config.js'); | ||
} else { | ||
console.error('Invalid argument. Use --typescript or --javascript.', args); | ||
process.exit(1); | ||
} | ||
if (fs.existsSync(configPath)) { | ||
console.error('secureflow.config.ts already exists in the root directory.'); | ||
console.error(args.includes('--typescript') ? 'secureflow.config.js already exists in the root directory.' : 'secureflow.config.ts already exists in the root directory.'); | ||
process.exit(1); | ||
@@ -17,0 +26,0 @@ } |
@@ -6,5 +6,16 @@ import { defaultConfig, Config } from './config.js'; | ||
export function loadConfig(): Config { | ||
const customConfigPath = path.resolve(process.cwd(), 'secureflow.config.ts'); | ||
let customConfigPath: string; | ||
const args = process.argv.slice(2); | ||
if (args.includes('--typescript')) { | ||
customConfigPath = path.resolve(process.cwd(), 'secureflow.config.ts'); | ||
} else if (args.includes('--javascript')) { | ||
customConfigPath = path.resolve(process.cwd(), 'secureflow.config.js'); | ||
} else { | ||
// Default to JavaScript if no argument is provided | ||
customConfigPath = path.resolve(process.cwd(), 'secureflow.config.js'); | ||
} | ||
if (fs.existsSync(customConfigPath)) { | ||
const customConfig = require(customConfigPath); | ||
const customConfig = require(customConfigPath).default || require(customConfigPath); | ||
return { ...defaultConfig, ...customConfig }; | ||
@@ -11,0 +22,0 @@ } else { |
16313
325
5