"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;
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
const fs = __importStar(require("fs"));
const os = __importStar(require("os"));
const path = __importStar(require("path"));
const child_process_1 = require("child_process");
describe('CLI regression — bin entrypoint', () => {
    const binPath = path.resolve(__dirname, '../../bin/cell.js');
    it('bin/cell.js points to correct CLI path (not ../dist/cli.js)', () => {
        const content = fs.readFileSync(binPath, 'utf8');
        expect(content).toContain('dist/walls/07-runtime/cli/cli.js');
        expect(content).not.toContain('dist/cli.js');
    });
    it('node bin/cell.js --version exits 0', () => {
        const out = (0, child_process_1.execSync)(`node "${binPath}" --version`, {
            cwd: path.resolve(__dirname, '../..'),
            encoding: 'utf8',
            timeout: 10000,
        });
        expect(out).toContain('cell v');
    });
    it('node bin/cell.js help exits 0', () => {
        const out = (0, child_process_1.execSync)(`node "${binPath}" help`, {
            cwd: path.resolve(__dirname, '../..'),
            encoding: 'utf8',
            timeout: 10000,
        });
        expect(out).toContain('FivoCell');
        expect(out).toContain('setup');
        expect(out).toContain('doctor');
    });
});
describe('CLI regression — setup dynamic requires', () => {
    let tmpDir;
    beforeEach(() => {
        tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'cell-setup-regression-'));
    });
    afterEach(() => {
        try {
            fs.rmSync(tmpDir, { recursive: true, force: true });
        }
        catch { }
    });
    it('runSetup with --dry-run succeeds (setup.ts loads without crash)', async () => {
        const { runSetup } = require('../walls/07-runtime/setup/setup');
        const result = await runSetup({
            cwd: tmpDir,
            homedir: fs.mkdtempSync(path.join(os.tmpdir(), 'cell-setup-home-reg-')),
            projectName: 'regression-test',
            skipScan: false,
            skipWatch: true,
            skipMcp: true,
            dryRun: true,
        });
        expect(result).toBeDefined();
        expect(result.scan.reason).toContain('dry-run');
    });
    it('runSetup with --skip-scan succeeds', async () => {
        const { runSetup } = require('../walls/07-runtime/setup/setup');
        const result = await runSetup({
            cwd: tmpDir,
            homedir: fs.mkdtempSync(path.join(os.tmpdir(), 'cell-setup-home-reg2-')),
            projectName: 'regression-test',
            skipScan: true,
            skipWatch: true,
            skipMcp: true,
        });
        expect(result).toBeDefined();
        expect(result.scan.reason).toContain('skipped');
    });
});
//# sourceMappingURL=cli-regression.test.js.map