const assert = require('assert');
const path = require('path');
const pkg = require(path.join(__dirname, '..', 'package.json'));

try {
  assert.strictEqual(pkg.name, '@ansible/example', 'package name must be @ansible/example');
  assert.ok(pkg.version && typeof pkg.version === 'string', 'version must be present');
  assert.ok(pkg.author && pkg.author.includes('Sven'), 'author must be Sven Geboers');
  assert.ok(pkg.publishConfig && pkg.publishConfig.access === 'public', 'publishConfig.access must be public');
  assert.ok(Array.isArray(pkg.files), 'files array must exist');
  console.log('test_package_json: OK');
  process.exit(0);
} catch (err) {
  console.error('test_package_json: FAILED');
  console.error(err && err.message ? err.message : err);
  process.exit(1);
}
