<|start_filename|>node_modules/@confy/core/config/typescript/index.js<|end_filename|>
module.exports = options => ({
    compilerOptions: {
        outDir: options.buildDir,
    },
    include: [options.srcDir],
});


<|start_filename|>node_modules/@confy/core/config/webpack/output.js<|end_filename|>
const path = require('path');

module.exports = (options) => ({
    path: path.resolve(options.buildDir),
    publicPath: './',
    filename: options.jsOutputFile,
});


<|start_filename|>node_modules/@confy/core/lib/utils/combineConfigs.js<|end_filename|>
const invariant = require('invariant');
const merge = require('./merge');

/**
 * The sections of a valid configuration object.
 * The order of items does matter when combining.
 * @type {string[]}
 */
const sections = ['options', 'addons', 'runners'];

/**
 * Casts a value to a function wrapper.
 * @param {*} value
 * @returns {Function}
 */
const castFn = (value) => (
    typeof value === 'function' ? value : () => value
);

/**
 * Combines a given list of configuration objects.
 * The first element in the list must be the root configuration.
 * The last element in the list must be the external configuration.
 * In between there can be other (preset) configurations.
 * @param {Array} configs A list of configurations
 * @returns {Object} The resulting combined configuration object
 */
const combineConfigs = (configs) => {
    invariant(
        configs.length >= 2,
        `Expected to receive at least 2 configurations. Received: ${configs.length}`
    );

    invariant(
        sections.every(key => key in configs[0]),
        `Expected root config to contain the following sections: ${sections.join(', ')}`
    );

    /**
     * The following block returns the final configuration
     * by merging all passed configs, section by section.
     * The sections are merged in the same order as defined in
     * `sections` above.
     * Every section also receives the current state of the
     * merged config.
     * Therefore addons can use options, and runners can
     * use both options and addons.
     */
    return sections.reduce((mergedConfig, sectionKey) => ({
        ...mergedConfig,
        [sectionKey]: configs.reduce((mergedSection, config) => (
            merge(
                mergedSection,
                // Normalize each config section by casting it to a function.
                castFn(config[sectionKey])({
                    ...mergedConfig,
                    [sectionKey]: {
                        ...mergedSection,
                    },
                })
            )
        ), {}),
    }), {});
};

module.exports = combineConfigs;


<|start_filename|>node_modules/@confy/core/lib/utils/getConfig.js<|end_filename|>
const resolvePresets = require('./resolvePresets');
const combineConfigs = require('./combineConfigs');

/**
 * Resolves all preset configurations that are used.
 * Then combines these to the final configuration object.
 * @returns {Object}
 */
const getConfig = () => (
    combineConfigs(
        resolvePresets()
    )
);

module.exports = getConfig;


<|start_filename|>node_modules/@confy/core/config/jest/setupEnv.js<|end_filename|>
global.requestAnimationFrame = setTimeout;


<|start_filename|>node_modules/@confy/core/resources/package.json<|end_filename|>
{
  "scripts": {
    "init": "confy-core init --env=development",
    "start": "confy-core start --env=development",
    "build": "confy-core build --env=production",
    "build-watch": "confy-core build --watch --env=production",
    "test": "confy-core test --env=test",
    "config": "confy-core show-config --env=development"
  }
}


<|start_filename|>node_modules/@confy/core/bin/confy-core.js<|end_filename|>
#!/usr/bin/env node

const yargs = require('yargs');
const invariant = require('invariant');

const build = require('../lib/commands/build');
const start = require('../lib/commands/start');
const test = require('../lib/commands/test');
const showConfig = require('../lib/commands/showConfig');

const settings = require('../lib/settings');
const writeFile = require('../lib/utils/writeFile');
const getConfig = require('../lib/utils/getConfig');
const requireConfig = require('../lib/utils/requireConfig');

const { argv } = yargs;

process.env.NODE_ENV = process.env.NODE_ENV || argv.env;

invariant(
    process.env.NODE_ENV !== undefined,
    'The NODE_ENV environment variable is required but was not specified.'
);

const config = getConfig();
// Always rebuild .eslintrc file.
writeFile(settings.appPath, '.eslintrc', config.addons.eslint);
// Always rebuild .prettierrc file.
writeFile(settings.appPath, '.prettierrc', config.addons.prettier);
// Always rebuild tsconfig.json file if TS is used in presets.
const { presets = [] } = requireConfig(settings.appPath);
if (presets.some(preset => preset.includes('typescript'))) {
    writeFile(settings.appPath, 'tsconfig.json', config.addons.typescript);
}

yargs
    .command(build)
    .command(start)
    .command(test)
    .command(showConfig)
    .help()
    .argv;


<|start_filename|>node_modules/@confy/preset-react/config/jest/svgrMock.js<|end_filename|>
module.exports = {
    default: 'SvgMock',
    ReactComponent: 'SvgComponentMock',
};


<|start_filename|>node_modules/@confy/core/lib/utils/writeBabelConfigJs.js<|end_filename|>
const fs = require('fs');
const path = require('path');

const template = `/* eslint-disable */
module.exports = function(api) {
    api.cache(() => process.env.NODE_ENV);

    return $CONTENT$;
}

`;

/**
 * Creates a babel.config.js file with the given content.
 * @param {string} extPath
 * @param {Object} content
 */
const writeBabelConfigJs = (extPath, content) => {
    const file = path.join(extPath, 'babel.config.js');
    const jsonContent = JSON.stringify(content, null, 4);

    fs.writeFileSync(file, template.replace('$CONTENT$', jsonContent));
};

module.exports = writeBabelConfigJs;


<|start_filename|>node_modules/@confy/core/config/eslint/index.js<|end_filename|>
module.exports = () => ({
    extends: [
        'eslint-config-airbnb-base',
        'plugin:prettier/recommended',
    ],
    parser: 'babel-eslint',
    env: {
        browser: true,
        es6: true,
        jest: true,
    },
    settings: {
        'import/extensions': ['.js', '.jsx'],
    },
    rules: {
        'no-console': 'warn',
        'arrow-body-style': 'off',
        'prefer-arrow-callback': 'off',
        'import/no-extraneous-dependencies': 'off',
    },
});


<|start_filename|>node_modules/@confy/core/lib/index.js<|end_filename|>
/**
 * NOTE: The exports in this file are considered public API.
 */
module.exports = {};


<|start_filename|>node_modules/@confy/core/lib/utils/merge.js<|end_filename|>
/**
 * Merges a leaf for a given key.
 * @param key {string} The given key.
 * @param {Object} left The source object.
 * @param {Object|Function} right The object or function to merge.
 * @param {Function} merge The merge callback.
 * @returns {Object} The merged result.
 */
const mergeLeaf = (key, left, right, merge) => ({
    // TODO: should we use `immer` to handle mutations in an immutable way?
    [key]: merge(left[key], right),
});

/**
 * Creates a new merged object.
 * Object keys of right can be functions that receive the
 * equivalent value of the given key in left or undefined if the key
 * does not exist in left.
 * @param {Object} left The source object.
 * @param {Object|Function} right The object or function to merge.
 * @returns {Object} The merged result.
 */
const merge = (left, right) => {
    if (
        // If left or right side is primitive ...
        (typeof left !== 'object' || Array.isArray(left) || typeof right !== 'object')
        // and right side is not a function.
        && typeof right !== 'function'
    ) {
        // Return right side if defined, else the original value.
        return right !== undefined ? right : left;
    }

    if (typeof right === 'function') {
        return right(left);
    }

    // Recursively create the object.
    const diff = Object.keys(right).reduce((acc, key) => ({
        ...acc,
        ...mergeLeaf(key, left, right[key], merge),
    }), {});

    return {
        ...left,
        ...diff,
    };
};

module.exports = merge;


<|start_filename|>node_modules/@confy/core/config/jest/index.js<|end_filename|>
const settings = require('../../lib/settings');

module.exports = () => ({
    verbose: true,
    rootDir: settings.appPath,
    testEnvironment: 'jsdom',
    // fix possible issue with jsdom localStorage.
    // see: https://github.com/facebook/jest/issues/6766
    testURL: 'http://localhost',
    setupFiles: [
        require.resolve('./setupEnv'),
    ],
    moduleNameMapper: {
        '\\.css$': require.resolve('identity-obj-proxy'),
        // Example for internal path alias (e.g. assets/foo -> src/assets/foo)
        // '^assets(.*)$': `<rootDir>${path.join(options.srcDir, 'assets')}$1`,
    },
    transform: {
        '\\.js$': require.resolve('babel-jest'),
        '\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$': require.resolve('./fileTransform'),
    },
});


<|start_filename|>node_modules/@confy/core/boilerplate/src/index.js<|end_filename|>
// eslint-disable-next-line
console.log('It works!');


<|start_filename|>node_modules/@confy/core/lib/utils/resolvePresets.js<|end_filename|>
const path = require('path');
const requireConfig = require('./requireConfig');
const settings = require('../settings');

/**
 * Resolves the configurations including presets and the base scripts package.
 * @param [appPath=settings.appPath] An optional path to the app root.
 * @returns {Object[]} The configuration objects of base scripts, presets and app.
 */
const resolvePresets = (appPath = settings.appPath) => {
    const config = requireConfig(appPath);

    const core = `${settings.prefix}core`;
    // Add base scripts as initial configuration.
    const presets = [core]
        .concat((config.presets || []).map(preset => {
            // Return untouched preset name if it contains @ or -
            if (/(@|-)/.test(preset)) return preset;
            // Prefix preset if it contains only 1 word.
            // This is considered confy preset shorthand name.
            return `${settings.prefix}preset-${preset}`;
        }));

    return presets
        .map(preset => {
            // require.resolve refers to the `main` entry in package.json by default.
            // Therefore we require the package.json itself.
            let presetConfigPath = require.resolve(`${preset}/package.json`, { paths: [appPath] });
            // Then fall back to the package root directory.
            presetConfigPath = path.dirname(presetConfigPath);
            return requireConfig(presetConfigPath);
        })
        .concat([config]);
};

module.exports = resolvePresets;


<|start_filename|>node_modules/@confy/core/lib/commands/showConfig.js<|end_filename|>
const util = require('util');
const getConfig = require('../utils/getConfig');

module.exports = {
    command: 'show-config',

    desc: 'Print config to the console.',

    handler () {
        const config = getConfig();

        console.log(util.inspect(config, true, null));
    },
};


<|start_filename|>node_modules/@confy/core/config/webpack/rules/files.js<|end_filename|>
const path = require('path');

module.exports = (options) => {
    const assetsDir = path.basename(options.assetsDir);

    return {
        test: [
            /\.(jpg|jpeg|png|gif|webp|svg|eot|otf|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$/,
        ],
        loader: 'url-loader',
        options: {
            // Use inline base64 URI
            limit: options.inlineFileSize,
            // Otherwise fallback to file
            name: `${assetsDir}/_processed_/[name].[hash:5].[ext]`,
        },
    };
};


<|start_filename|>node_modules/@confy/core/lib/settings.js<|end_filename|>
const path = require('path');

// Define path to root directory
const rootPath = path.resolve(__dirname, '../');
// Define path to app / project root directory
const appPath = process.cwd();
// Define path to local node_modules
const nodeModulesPath = path.resolve(rootPath, 'node_modules');
// Define path to app node_modules
const appNodeModulesPath = path.resolve(appPath, 'node_modules');
// Define valid config filenames
const configFilenames = ['apprc.js', '.apprc.js'];
// Define namespace scope
const prefix = '@confy/';

module.exports = {
    rootPath,
    appPath,
    nodeModulesPath,
    appNodeModulesPath,
    configFilenames,
    prefix,
};


<|start_filename|>node_modules/@confy/core/lib/utils/requireConfig.js<|end_filename|>
const fs = require('fs');
const path = require('path');
const settings = require('../settings');

/**
 * Tests if a config file exists in path, then requires it.
 * If it does not exist, an empty object is returned instead.
 * @param {string} absPath The absolute directory path where the config should be
 */
const requireConfig = absPath => {
    const configFilename = settings.configFilenames.find(
        name => fs.existsSync(path.join(absPath, name))
    );

    return configFilename ? require(path.join(absPath, configFilename)) : {};
};

module.exports = requireConfig;


<|start_filename|>node_modules/@confy/core/lib/commands/test.js<|end_filename|>
const invariant = require('invariant');
const jest = require('jest');
const getConfig = require('../utils/getConfig');
const writeBabelConfigJs = require('../utils/writeBabelConfigJs');
const settings = require('../settings');

module.exports = {
    command: 'test',

    desc: 'Run tests with Jest.',

    handler() {
        const config = getConfig();

        invariant(config.options.testMode, 'Make sure to run tests in "test" mode.');

        // Makes the script crash on unhandled rejections instead of silently
        // ignoring them. In the future, promise rejections that are not handled will
        // terminate the Node.js process with a non-zero exit code.
        process.on('unhandledRejection', err => {
            throw err;
        });

        // Make configuration globally available in test environment.
        // This is necessary for the babel-jest transformer to work.
        writeBabelConfigJs(settings.appPath, config.addons.babel);

        // Remove initial items from arguments list and pass the remaining args to Jest.
        // Initial items are: `[node] [confy-core] test`
        const argsList = process.argv.slice(3)
            // Also remove any --env flag that is only confy-core related
            .filter(arg => !arg.includes('--env='));

        argsList.push('--config', JSON.stringify(config.runners.jest));

        jest.run(argsList);
    },
};


<|start_filename|>node_modules/@confy/core/config/webpack/rules/scripts.js<|end_filename|>
const path = require('path');
const settings = require('../../../lib/settings');

module.exports = (options, addons) => ({
    test: /\.js$/,
    use: [
        {
            loader: 'babel-loader',
            options: {
                ...addons.babel,
                babelrc: false,
            },
        },
        {
            loader: 'eslint-loader',
        },
    ],
    include: [
        path.join(settings.appPath, options.srcDir),
    ],
});


<|start_filename|>node_modules/@confy/core/apprc.js<|end_filename|>
module.exports = {
    options: () => ({
        // Working and output directories
        srcDir: 'src',
        assetsDir: 'assets', // relative to srcDir
        buildDir: 'build',
        // Define files for main bundle
        entryFiles: ['index'],
        // Set js output filename
        jsOutputFile: '[name].bundle.js',
        // Set css output filename
        cssOutputFile: 'style.css',
        // Set css filename for dynamic chunks
        cssChunkFile: '[id].css',
        // Set default html template (or `null` for no html template)
        htmlTemplate: 'index.html',
        // Define page title
        title: 'New App',
        // Code style indention
        tabWidth: 4,
        // DevServer settings
        host: '0.0.0.0',
        port: 3000,
        // List of supported browsers for babel-preset-env and autoprefixer.
        browsersList: [
            '>2.5%',
            'last 4 chrome versions',
            'last 4 ff versions',
            'last 2 edge versions',
            'last 2 ios versions',
            'last 2 safari versions',
            'not ie 11',
        ],
        // The file size in bytes under which the url-loader kicks in.
        inlineFileSize: -1, // Disabled
        // Define environment boolean flags
        devMode: process.env.NODE_ENV === 'development',
        testMode: process.env.NODE_ENV === 'test',
    }),

    addons: config => ({
        babel: require('./config/babel')(config.options),
        eslint: require('./config/eslint')(config.options),
        prettier: require('./config/prettier')(config.options),
        typescript: require('./config/typescript')(config.options),
    }),

    runners: config => ({
        webpack: require('./config/webpack')(config),
        jest: require('./config/jest')(config),
    }),
};


<|start_filename|>node_modules/@confy/core/config/webpack/plugins.js<|end_filename|>
const fs = require('fs');
const path = require('path');
const webpack = require('webpack');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const settings = require('../../lib/settings');

module.exports = (options) => {
    const plugins = [];

    // Add clean up plugin
    plugins.push(new CleanWebpackPlugin());

    // Resolve assets folder
    const assetsPath = path.resolve(settings.appPath, options.srcDir, options.assetsDir);

    // Add copy plugin if an assets folder exists
    if (fs.existsSync(assetsPath)) {
        const assetsOutputPath = path.resolve(
            settings.appPath,
            options.buildDir,
            path.basename(options.assetsDir)
        );

        plugins.push(
            new CopyWebpackPlugin([
                { from: assetsPath, to: assetsOutputPath },
            ])
        );
    }

    // Add html plugin if a template is set
    if (options.htmlTemplate) {
        plugins.push(
            new HtmlWebpackPlugin({
                title: options.title,
                template: path.resolve(
                    settings.appPath,
                    options.srcDir,
                    options.htmlTemplate
                ),
            }),
        );
    }

    // Add additional plugins for development
    if (options.devMode) {
        plugins.push(
            new webpack.HotModuleReplacementPlugin(),
        );

        return plugins;
    }

    // Add additional plugins for production
    plugins.push(
        new MiniCssExtractPlugin({
            filename: options.cssOutputFile,
            chunkFilename: options.cssChunkFile,
        }),
    );

    return plugins;
};
