UNPKG

@appswap/cli

Version:

A comprehensive CLI tool for CI/CD pipelines to manage versioning and publishing across multiple platforms

148 lines 6.13 kB
#!/usr/bin/env node "use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || (function () { var ownKeys = function(o) { ownKeys = Object.getOwnPropertyNames || function (o) { var ar = []; for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; return ar; }; return ownKeys(o); }; return function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); __setModuleDefault(result, mod); return result; }; })(); var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const commander_1 = require("commander"); const chalk_1 = __importDefault(require("chalk")); const dotenv_1 = __importDefault(require("dotenv")); const version_1 = require("./commands/version"); const publish_1 = require("./commands/publish"); const init_1 = require("./commands/init"); const status_1 = require("./commands/status"); const doctor_1 = require("./commands/doctor"); const fs = __importStar(require("fs")); const path = __importStar(require("path")); dotenv_1.default.config(); const packageJsonPath = path.join(__dirname, '../package.json'); const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8')); commander_1.program .name('appswap') .description('A comprehensive CLI tool for CI/CD pipelines to manage versioning and publishing') .version(packageJson.version, '-v, --version', 'display version number'); commander_1.program .command('init') .description('Bootstrap AppSwap configuration for your project') .option('-f, --force', 'overwrite existing configuration', false) .option('-t, --template <template>', 'use a specific template') .option('--no-interactive', 'skip interactive setup') .action(async (options) => { try { const initCommand = new init_1.InitCommand(); await initCommand.execute(options); } catch (error) { console.error(chalk_1.default.red('Error:'), error instanceof Error ? error.message : String(error)); process.exit(1); } }); commander_1.program .command('version [strategy]') .description('Calculate and write a version to package.json') .option('-d, --dry-run', 'show what would be done without making changes', false) .option('-m, --message <message>', 'tag message for git tag') .option('--no-tag', 'skip creating git tag') .action(async (strategy, options) => { try { const versionCommand = new version_1.VersionCommand(); const versionOptions = { dryRun: options.dryRun, message: options.message, tag: options.tag, ...(strategy && { strategy: strategy }) }; await versionCommand.execute(versionOptions); } catch (error) { console.error(chalk_1.default.red('Error:'), error instanceof Error ? error.message : String(error)); process.exit(1); } }); commander_1.program .command('publish') .description('Publish package based on branch configuration') .option('-t, --target <targets>', 'comma-separated list of destinations (overrides branch config)') .option('-d, --dry-run', 'show what would be published without actually publishing', false) .option('-f, --force', 'skip pre-flight checks', false) .option('--skip-hooks', 'skip running pre/post publish hooks', false) .option('--skip-build', 'skip running build command', false) .option('--skip-git-checks', 'skip git working directory clean checks', false) .action(async (options) => { try { const publishCommand = new publish_1.PublishCommand(); await publishCommand.execute(options); } catch (error) { console.error(chalk_1.default.red('Error:'), error instanceof Error ? error.message : String(error)); process.exit(1); } }); commander_1.program .command('status') .description('Show currently published versions across all destinations') .option('-d, --detailed', 'show detailed information including URLs and timestamps', false) .option('-j, --json', 'output status as JSON', false) .action(async (options) => { try { const statusCommand = new status_1.StatusCommand(); await statusCommand.execute(options); } catch (error) { console.error(chalk_1.default.red('Error:'), error instanceof Error ? error.message : String(error)); process.exit(1); } }); commander_1.program .command('doctor') .description('Validate configuration and check project health') .option('--fix', 'attempt to automatically fix issues', false) .option('-v, --verbose', 'show detailed output', false) .action(async (options) => { try { const doctorCommand = new doctor_1.DoctorCommand(); await doctorCommand.execute(options); } catch (error) { console.error(chalk_1.default.red('Error:'), error instanceof Error ? error.message : String(error)); process.exit(1); } }); commander_1.program.parse(); if (!process.argv.slice(2).length) { commander_1.program.outputHelp(); } //# sourceMappingURL=cli.js.map