import path from "path"; import { CBFileSystem } from "../node/file-system"; /** * Package validator for validating app structure. * This primarily validates the app directory and the structure of the app which developer bundles and uploads to Chargebee. */ export class PackageValidator { private fileSystem: CBFileSystem; constructor(fileSystem: CBFileSystem) { this.fileSystem = fileSystem; } /** * Validates that the app directory exists * @param {string} targetDir - Target directory path * @returns {boolean} True if directory exists */ validateAppDirectoryExists(targetDir: string): boolean { return this.fileSystem.existsSync(targetDir); } /** * Validates that manifest.json exists in the app directory * @param {string} targetDir - Target directory path * @returns {boolean} True if manifest.json exists */ validateManifestExists(targetDir: string): boolean { const manifestPath = path.join(targetDir, 'manifest.json'); return this.fileSystem.existsSync(manifestPath); } /** * Validates that handler.js exists in the app directory * @param {string} targetDir - Target directory path * @returns {boolean} True if handler.js exists */ validateHandlerExists(targetDir: string): boolean { const handlerPath = path.join(targetDir, 'handler', 'handler.js'); return this.fileSystem.existsSync(handlerPath); } }