<commit_before>// Builds the site using Metalsmith as the top-level build runner.

const Metalsmith = require('metalsmith');
const archive = require('metalsmith-archive');
const assets = require('metalsmith-assets');
const blc = require('metalsmith-broken-link-checker');
const collections = require('metalsmith-collections');
const commandLineArgs = require('command-line-args');
const dateInFilename = require('metalsmith-date-in-filename');
const define = require('metalsmith-define');
const filenames = require('metalsmith-filenames');
const inPlace = require('metalsmith-in-place');
const layouts = require('metalsmith-layouts');
const liquid = require('tinyliquid');
const markdown = require('metalsmith-markdownit');
const moment = require('moment');
const navigation = require('metalsmith-navigation');
const permalinks = require('metalsmith-permalinks');
const redirect = require('metalsmith-redirect');
const sitemap = require('metalsmith-sitemap');
const watch = require('metalsmith-watch');
const webpack = require('metalsmith-webpack');
const webpackConfigGenerator = require('../config/webpack.config');
const webpackDevServer = require('metalsmith-webpack-dev-server');
const semver = require('semver');

const fs = require('fs');
const path = require('path');

const sourceDir = '../content/pages';
const minimumNodeVersion = '6.10.3';

if (!(process.env.INSTALL_HOOKS === 'no')) {
  // Make sure git pre-commit hooks are installed
  ['pre-commit'].forEach(hook => {
    const src = path.join(__dirname, `../hooks/${hook}`);
    const dest = path.join(__dirname, `../.git/hooks/${hook}`);
    if (fs.existsSync(src)) {
      if (!fs.existsSync(dest)) {
        // Install hooks
        fs.linkSync(src, dest);
      }
    }
  });
}

if (semver.compare(process.version, minimumNodeVersion) === -1) {
  process.stdout.write(`Node.js version (mininum): v${minimumNodeVersion}\n`);
  process.stdout.write(`Node.js version (installed): ${process.version}\n`);
  process.exit(1);
}

const smith = Metalsmith(__dirname); // eslint-disable-line new-cap

const optionDefinitions = [
  { name: 'buildtype', type: String, defaultValue: 'development' },
  { name: 'no-sanity-check-node-env', type: Boolean, defaultValue: false },
  { name: 'port', type: Number, defaultValue: 3001 },
  { name: 'watch', type: Boolean, defaultValue: false },
  { name: 'entry', type: String, defaultValue: null },
  { name: 'host', type: String, defaultValue: 'localhost' },
  { name: 'public', type: String, defaultValue: null },

  // Catch-all for bad arguments.
  { name: 'unexpected', type: String, multile: true, defaultOption: true },
];
const options = commandLineArgs(optionDefinitions);

const env = require('get-env')();

if (options.unexpected && options.unexpected.length !== 0) {
  throw new Error(`Unexpected arguments: '${options.unexpected}'`);
}

if (options.buildtype === undefined) {
  options.buildtype = 'development';
}

switch (options.buildtype) {
  case 'development':
    // No extra checks needed in dev.
    break;

  case 'staging':
    break;

  case 'production':
    if (options['no-sanity-check-node-env'] === false) {
      if (env !== 'prod') {
        throw new Error(`buildtype ${options.buildtype} expects NODE_ENV to be production, not '${process.env.NODE_ENV}'`);
      }
    }
    break;

  default:
    throw new Error(`Unknown buildtype: '${options.buildtype}'`);
}

const webpackConfig = webpackConfigGenerator(options);

// Custom liquid filter(s)
liquid.filters.humanizeDate = (dt) => moment(dt).format('MMMM D, YYYY');


// Set up Metalsmith. BE CAREFUL if you change the order of the plugins. Read the comments and
// add comments about any implicit dependencies you are introducing!!!
//
smith.source(sourceDir);
smith.destination(`../build/${options.buildtype}`);

// This lets us access the {{buildtype}} variable within liquid templates.
smith.metadata({ buildtype: options.buildtype });

// To block an app from production add the following to the below list:
//  ignoreList.push('<path-to-content-file>');
const ignore = require('metalsmith-ignore');
const ignoreList = [];
if (options.buildtype === 'production') {
  ignoreList.push('pension/application/527EZ.md');
  ignoreList.push('burials-and-memorials/application/530.md');
  ignoreList.push('burials-and-memorials/burial-planning/application.md');
}
smith.use(ignore(ignoreList));

// This adds the filename into the "entry" that is passed to other plugins. Without this errors
// during templating end up not showing which file they came from. Load it very early in in the
// plugin chain.
smith.use(filenames());<commit_msg>Remove burial form from ignore list (#6042)<commit_after>// Builds the site using Metalsmith as the top-level build runner.

const Metalsmith = require('metalsmith');
const archive = require('metalsmith-archive');
const assets = require('metalsmith-assets');
const blc = require('metalsmith-broken-link-checker');
const collections = require('metalsmith-collections');
const commandLineArgs = require('command-line-args');
const dateInFilename = require('metalsmith-date-in-filename');
const define = require('metalsmith-define');
const filenames = require('metalsmith-filenames');
const inPlace = require('metalsmith-in-place');
const layouts = require('metalsmith-layouts');
const liquid = require('tinyliquid');
const markdown = require('metalsmith-markdownit');
const moment = require('moment');
const navigation = require('metalsmith-navigation');
const permalinks = require('metalsmith-permalinks');
const redirect = require('metalsmith-redirect');
const sitemap = require('metalsmith-sitemap');
const watch = require('metalsmith-watch');
const webpack = require('metalsmith-webpack');
const webpackConfigGenerator = require('../config/webpack.config');
const webpackDevServer = require('metalsmith-webpack-dev-server');
const semver = require('semver');

const fs = require('fs');
const path = require('path');

const sourceDir = '../content/pages';
const minimumNodeVersion = '6.10.3';

if (!(process.env.INSTALL_HOOKS === 'no')) {
  // Make sure git pre-commit hooks are installed
  ['pre-commit'].forEach(hook => {
    const src = path.join(__dirname, `../hooks/${hook}`);
    const dest = path.join(__dirname, `../.git/hooks/${hook}`);
    if (fs.existsSync(src)) {
      if (!fs.existsSync(dest)) {
        // Install hooks
        fs.linkSync(src, dest);
      }
    }
  });
}

if (semver.compare(process.version, minimumNodeVersion) === -1) {
  process.stdout.write(`Node.js version (mininum): v${minimumNodeVersion}\n`);
  process.stdout.write(`Node.js version (installed): ${process.version}\n`);
  process.exit(1);
}

const smith = Metalsmith(__dirname); // eslint-disable-line new-cap

const optionDefinitions = [
  { name: 'buildtype', type: String, defaultValue: 'development' },
  { name: 'no-sanity-check-node-env', type: Boolean, defaultValue: false },
  { name: 'port', type: Number, defaultValue: 3001 },
  { name: 'watch', type: Boolean, defaultValue: false },
  { name: 'entry', type: String, defaultValue: null },
  { name: 'host', type: String, defaultValue: 'localhost' },
  { name: 'public', type: String, defaultValue: null },

  // Catch-all for bad arguments.
  { name: 'unexpected', type: String, multile: true, defaultOption: true },
];
const options = commandLineArgs(optionDefinitions);

const env = require('get-env')();

if (options.unexpected && options.unexpected.length !== 0) {
  throw new Error(`Unexpected arguments: '${options.unexpected}'`);
}

if (options.buildtype === undefined) {
  options.buildtype = 'development';
}

switch (options.buildtype) {
  case 'development':
    // No extra checks needed in dev.
    break;

  case 'staging':
    break;

  case 'production':
    if (options['no-sanity-check-node-env'] === false) {
      if (env !== 'prod') {
        throw new Error(`buildtype ${options.buildtype} expects NODE_ENV to be production, not '${process.env.NODE_ENV}'`);
      }
    }
    break;

  default:
    throw new Error(`Unknown buildtype: '${options.buildtype}'`);
}

const webpackConfig = webpackConfigGenerator(options);

// Custom liquid filter(s)
liquid.filters.humanizeDate = (dt) => moment(dt).format('MMMM D, YYYY');


// Set up Metalsmith. BE CAREFUL if you change the order of the plugins. Read the comments and
// add comments about any implicit dependencies you are introducing!!!
//
smith.source(sourceDir);
smith.destination(`../build/${options.buildtype}`);

// This lets us access the {{buildtype}} variable within liquid templates.
smith.metadata({ buildtype: options.buildtype });

// To block an app from production add the following to the below list:
//  ignoreList.push('<path-to-content-file>');
const ignore = require('metalsmith-ignore');
const ignoreList = [];
if (options.buildtype === 'production') {
  ignoreList.push('pension/application/527EZ.md');
  ignoreList.push('burials-and-memorials/burial-planning/application.md');
}
smith.use(ignore(ignoreList));

// This adds the filename into the "entry" that is passed to other plugins. Without this errors
// during templating end up not showing which file they came from. Load it very early in in the
// plugin chain.
smith.use(filenames());
{'fraction_non_alphanumeric': 0.15648399348887684, 'fraction_numerical': 0.0037981551817688553, 'mean_word_length': 4.710037174721189, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '456826', 'n_tokens_mistral': 2820, 'n_tokens_neox': 2742, 'n_words': 740}