uploadExclusions.test.mjs 1.61 KB
import assert from 'node:assert/strict';
import { readFileSync } from 'node:fs';
import path from 'node:path';
import test from 'node:test';
import { fileURLToPath } from 'node:url';

const projectRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../..');

test('upload configuration excludes development and agent metadata', () => {
  const config = JSON.parse(readFileSync(path.join(projectRoot, 'project.config.json'), 'utf8'));
  const ignored = new Set((config.packOptions?.ignore || []).map(({ value }) => value));
  for (const entry of [
    'docs',
    'tests',
    'scripts',
    '.codex-tmp',
    'outputs',
    '.agents',
    '.github',
    'AGENTS.md',
  ]) {
    assert.ok(ignored.has(entry), `${entry} must be excluded from upload`);
  }

  for (const retiredEntry of ['.cursor', '.cloudbase']) {
    assert.equal(
      ignored.has(retiredEntry),
      false,
      `${retiredEntry} must not remain as a stale exclusion`,
    );
  }
});

test('local agent artifacts are ignored at repository root', () => {
  const gitignore = readFileSync(path.join(projectRoot, '.gitignore'), 'utf8');
  assert.match(gitignore, /^\/\.codex-tmp\/$/m);
  assert.match(gitignore, /^\/\.superpowers\/$/m);
});

test('development compilation excludes unreferenced Node-only scripts', () => {
  for (const configFile of ['project.config.json', 'project.private.config.json']) {
    const config = JSON.parse(readFileSync(path.join(projectRoot, configFile), 'utf8'));
    assert.equal(
      config.setting?.ignoreDevUnusedFiles,
      true,
      `${configFile} must not compile unreferenced Node-only test and script files`,
    );
  }
});