<commit_before>/*global describe, it, expect, beforeEach, afterEach */
const os = require('os'),
	uuid = require('uuid'),
	path = require('path'),
	shell = require('shelljs'),
	readjson = require('../src/util/readjson'),
	fs = require('fs'),
	fsPromise = require('../src/util/fs-promise'),
	localizeDependencies = require('../src/tasks/localize-dependencies');
describe('localizeDependencies', () => {
	'use strict';
	let workdir, referencedir;
	beforeEach(() => {
		workdir = path.join(os.tmpdir(), uuid.v4());
		referencedir = path.join(os.tmpdir(), uuid.v4());
		shell.mkdir(workdir);
		shell.mkdir(referencedir);
	});
	afterEach(() => shell.rm('-rf', workdir, referencedir));
	it('does not modify package properties that have nothing to do with dependencies', done => {
		let referenceJSON;
		shell.cp(path.join(__dirname, '..', 'package.json'), workdir);
		localizeDependencies(workdir, referencedir)
		.then(() => readjson(path.join(__dirname, '..', 'package.json')))
		.then(contents => {
			referenceJSON = contents;
		})
		.then(() => readjson(path.join(workdir, 'package.json')))
		.then(contents => expect(contents).toEqual(referenceJSON))
		.then(done, done.fail);
	});
	it('complains if the working directory does not contain package.json', done => {
		localizeDependencies(workdir, referencedir)
		.then(done.fail, err => expect(err).toEqual(workdir + '/package.json is missing'))
		.then(done);
	});
	['dependencies', 'devDependencies', 'optionalDependencies'].forEach(depType => {
		const writeTemplate = function (overrideKey, value) {
			return readjson(path.join(__dirname, '..', 'package.json'))
			.then(content => {
				content[overrideKey] = value;
				return fsPromise.writeFileAsync(path.join(workdir, 'package.json'), JSON.stringify(content), { encoding: 'utf8' });
			});
		};
		it(`does not modify remote dependencies in ${depType}`, done => {
			const exampleDependencies = {
				'foo': '1.0.0 - 2.9999.9999',
				'bar': '>=1.0.2 <2.1.2',
				'baz': '>1.0.2 <=2.3.4',
				'boo': '2.0.1',
				'qux': '<1.0.0 || >=2.3.1 <2.4.5 || >=2.5.2 <3.0.0',
				'til': '~1.2',
				'elf': '~1.2.3',
				'two': '2.x',
				'thr': '3.3.x',
				'lat': 'latest',
				'git1': 'git://github.com/user/project.git#commit-ish',
				'http': 'http://asdf.com/asdf.tar.gz',
				'git2': 'git+ssh://user@hostname:project.git#commit-ish',
				'git3': 'git+ssh://user@hostname/project.git#commit-ish',
				'git4': 'git+http://user@hostname/project/blah.git#commit-ish',
				'git5': 'git+https://user@hostname/project/blah.git#commit-ish',
				'express': 'visionmedia/express',
				'mocha': 'visionmedia/mocha#4727d357ea'
			};
			writeTemplate(depType, exampleDependencies)
			.then(() => localizeDependencies(workdir, referencedir))
			.then(() => readjson(path.join(workdir, 'package.json')))
			.then(content => expect(content[depType]).toEqual(exampleDependencies))
			.then(done, done.fail);
		});
		it(`does not modify local dependencies that point to absolute paths in ${depType}`, done => {
			const exampleDependencies = {
				'homeRelative': '~/foo/bar',
				'absolute': '/foo/bar',
				'fileAbsolute': 'file:/foo/bar',
				'fileHome': 'file:~/foo/bar'
			};
			writeTemplate(depType, exampleDependencies)
			.then(() => localizeDependencies(workdir, referencedir))
			.then(() => readjson(path.join(workdir, 'package.json')))
			.then(content => expect(content[depType]).toEqual(exampleDependencies))
			.then(done, done.fail);
		});
		it(`modifies local dependencies in ${depType}`, done => {
			const exampleDependencies = {
				'parentRelative': '../foo/bar',
				'subdirRelative': './foo/bar',
				'fileRelative': 'file:../foo/bar',
				'fileSubdir': 'file:./foo/bar'
			};
			writeTemplate(depType, exampleDependencies)
			.then(() => localizeDependencies(workdir, referencedir))
			.then(() => readjson(path.join(workdir, 'package.json')))
			.then(content => {
				expect(content[depType]).toEqual({
					'parentRelative': 'file:' + path.resolve(referencedir, '../foo/bar'),
					'subdirRelative': 'file:' + path.resolve(referencedir, './foo/bar'),
					'fileRelative': 'file:' + path.resolve(referencedir, '../foo/bar'),
					'fileSubdir': 'file:' + path.resolve(referencedir, './foo/bar')
				});
			})
			.then(done, done.fail);
		});
	});
	it('does not create .npmrc if the original directory does not have one', done => {
		shell.cp(path.join(__dirname, '..', 'package.json'), workdir);
		localizeDependencies(workdir, referencedir)
		.then(() => expect(shell.test('-e', path.join(workdir, '.npmrc'))).toBeFalsy())
		.then(done, done.fail);
	});
	it('copies .npmrc if the original directory contains it', done => {
		fs.writeFileSync(path.join(referencedir, '.npmrc'), 'optional = false', 'utf8');
		shell.cp(path.join(__dirname, '..', 'package.json'), workdir);
		localizeDependencies(workdir, referencedir)
		.then(() => {
			const npmRcPath = path.join(workdir, '.npmrc');
			expect(shell.test('-e', npmRcPath)).toBeTruthy();
			expect(fs.readFileSync(npmRcPath, 'utf8')).toEqual('optional = false');
		})
		.then(done, done.fail);
	});
});
<commit_msg>fix test failure on windows<commit_after>/*global describe, it, expect, beforeEach, afterEach */
const os = require('os'),
	uuid = require('uuid'),
	path = require('path'),
	shell = require('shelljs'),
	readjson = require('../src/util/readjson'),
	fs = require('fs'),
	fsPromise = require('../src/util/fs-promise'),
	localizeDependencies = require('../src/tasks/localize-dependencies');
describe('localizeDependencies', () => {
	'use strict';
	let workdir, referencedir;
	beforeEach(() => {
		workdir = path.join(os.tmpdir(), uuid.v4());
		referencedir = path.join(os.tmpdir(), uuid.v4());
		shell.mkdir(workdir);
		shell.mkdir(referencedir);
	});
	afterEach(() => shell.rm('-rf', workdir, referencedir));
	it('does not modify package properties that have nothing to do with dependencies', done => {
		let referenceJSON;
		shell.cp(path.join(__dirname, '..', 'package.json'), workdir);
		localizeDependencies(workdir, referencedir)
		.then(() => readjson(path.join(__dirname, '..', 'package.json')))
		.then(contents => {
			referenceJSON = contents;
		})
		.then(() => readjson(path.join(workdir, 'package.json')))
		.then(contents => expect(contents).toEqual(referenceJSON))
		.then(done, done.fail);
	});
	it('complains if the working directory does not contain package.json', done => {
		localizeDependencies(workdir, referencedir)
		.then(done.fail, err => expect(err).toEqual(path.join(workdir, 'package.json') + ' is missing'))
		.then(done);
	});
	['dependencies', 'devDependencies', 'optionalDependencies'].forEach(depType => {
		const writeTemplate = function (overrideKey, value) {
			return readjson(path.join(__dirname, '..', 'package.json'))
			.then(content => {
				content[overrideKey] = value;
				return fsPromise.writeFileAsync(path.join(workdir, 'package.json'), JSON.stringify(content), { encoding: 'utf8' });
			});
		};
		it(`does not modify remote dependencies in ${depType}`, done => {
			const exampleDependencies = {
				'foo': '1.0.0 - 2.9999.9999',
				'bar': '>=1.0.2 <2.1.2',
				'baz': '>1.0.2 <=2.3.4',
				'boo': '2.0.1',
				'qux': '<1.0.0 || >=2.3.1 <2.4.5 || >=2.5.2 <3.0.0',
				'til': '~1.2',
				'elf': '~1.2.3',
				'two': '2.x',
				'thr': '3.3.x',
				'lat': 'latest',
				'git1': 'git://github.com/user/project.git#commit-ish',
				'http': 'http://asdf.com/asdf.tar.gz',
				'git2': 'git+ssh://user@hostname:project.git#commit-ish',
				'git3': 'git+ssh://user@hostname/project.git#commit-ish',
				'git4': 'git+http://user@hostname/project/blah.git#commit-ish',
				'git5': 'git+https://user@hostname/project/blah.git#commit-ish',
				'express': 'visionmedia/express',
				'mocha': 'visionmedia/mocha#4727d357ea'
			};
			writeTemplate(depType, exampleDependencies)
			.then(() => localizeDependencies(workdir, referencedir))
			.then(() => readjson(path.join(workdir, 'package.json')))
			.then(content => expect(content[depType]).toEqual(exampleDependencies))
			.then(done, done.fail);
		});
		it(`does not modify local dependencies that point to absolute paths in ${depType}`, done => {
			const exampleDependencies = {
				'homeRelative': '~/foo/bar',
				'absolute': '/foo/bar',
				'fileAbsolute': 'file:/foo/bar',
				'fileHome': 'file:~/foo/bar'
			};
			writeTemplate(depType, exampleDependencies)
			.then(() => localizeDependencies(workdir, referencedir))
			.then(() => readjson(path.join(workdir, 'package.json')))
			.then(content => expect(content[depType]).toEqual(exampleDependencies))
			.then(done, done.fail);
		});
		it(`modifies local dependencies in ${depType}`, done => {
			const exampleDependencies = {
				'parentRelative': '../foo/bar',
				'subdirRelative': './foo/bar',
				'fileRelative': 'file:../foo/bar',
				'fileSubdir': 'file:./foo/bar'
			};
			writeTemplate(depType, exampleDependencies)
			.then(() => localizeDependencies(workdir, referencedir))
			.then(() => readjson(path.join(workdir, 'package.json')))
			.then(content => {
				expect(content[depType]).toEqual({
					'parentRelative': 'file:' + path.resolve(referencedir, '../foo/bar'),
					'subdirRelative': 'file:' + path.resolve(referencedir, './foo/bar'),
					'fileRelative': 'file:' + path.resolve(referencedir, '../foo/bar'),
					'fileSubdir': 'file:' + path.resolve(referencedir, './foo/bar')
				});
			})
			.then(done, done.fail);
		});
	});
	it('does not create .npmrc if the original directory does not have one', done => {
		shell.cp(path.join(__dirname, '..', 'package.json'), workdir);
		localizeDependencies(workdir, referencedir)
		.then(() => expect(shell.test('-e', path.join(workdir, '.npmrc'))).toBeFalsy())
		.then(done, done.fail);
	});
	it('copies .npmrc if the original directory contains it', done => {
		fs.writeFileSync(path.join(referencedir, '.npmrc'), 'optional = false', 'utf8');
		shell.cp(path.join(__dirname, '..', 'package.json'), workdir);
		localizeDependencies(workdir, referencedir)
		.then(() => {
			const npmRcPath = path.join(workdir, '.npmrc');
			expect(shell.test('-e', npmRcPath)).toBeTruthy();
			expect(fs.readFileSync(npmRcPath, 'utf8')).toEqual('optional = false');
		})
		.then(done, done.fail);
	});
});
<|endoftext|>


<commit_before>'use strict';

const _yeoman = require('yeoman-generator');

const _fsUtils = require('../../utils/fs-utils');
const _consts = require('../../utils/constants');

const EMPTY_RESOURCE = 'EMPTY (Create at parent level)';

module.exports = _yeoman.Base.extend({
    /**
     * Initializes the generator.
     */
    constructor: function() {
        _yeoman.Base.apply(this, arguments);
        this.availableResources = ['/'];
    },

    /**
     * Queries the project to identify all defined dynamodb tables that can
     * serve as event sources.
     */
    lookupAvailableSources: function() {
        const done = this.async();
        const path = this.destinationPath('resources/api');
        _fsUtils.getSubDirectoryPaths(path).then((dirList) => {
            const pathRegex = new RegExp(`${path}/?`);
            this.availableResources = dirList.map(item => item.replace(pathRegex, '/'));
            done();
        }).catch((ex) => {
            this.env.error('Error determining existing API resources');
            done(ex);
        });
    },

    /**
     * Shows a the title of the sub generator, and a brief description.
     */
    showTitle: function() {
        this.log(_consts.SEPARATOR);
        this.log('Create a rest API:\n');
    },

    /**
     * Gathers resource information
     */
    gatherResourceInfo: function () {
        const prompts = [{
            type: 'list',
            name: 'apiParentResource',
            message: 'Parent resource?',
            choices: this.availableResources,
            default: 0
        }, {
            type: 'input',
            name: 'apiResourcePath',
            message: 'Resource Path (ex: user/:userId)?',
            default: EMPTY_RESOURCE,
            filter: resp => resp === EMPTY_RESOURCE? '':resp,
            validate: (response) => {
                const resPattern = /(^[^\/]|^:)((\/:?)?[a-zA-Z0-9]+)+$/;
                if(response === '' || response.match(resPattern)) {
                    return true;
                }
                return 'If non empty, resource name can only contain letters, numbers, "_" and "-".\n   Multiple resources can be separated by "/"\n   Parameterized resource paths should be prefixed with ":"';
            }
        }, {
            type: 'confirm',
            name: 'apiEnableCors',
            message: 'Enable CORS?',
            default: true
        }, {
            type: 'checkbox',
            name: 'apiCorsMethods',
            message: 'CORS Methods?',
            choices: ['GET', 'POST', 'PUT', 'DELETE'],
            default: [ 'GET', 'POST' ],
            when: answers => answers.apiEnableCors,
            validate: (response) => {
                if(response.length > 0) {
                    return true;
                }
                return 'Choose at least one applicable HTTP method';
            }
        }];

        return this.prompt(prompts).then((props) => {
            this.props = Object.assign(this.props || {}, props);
        });
    },

    /**
     * Creates cloud formation template for the api resource
     */
    createResourceTemplate: function() {
        let updated = false;
        const resourcePath = this.props.apiResourcePath;
        const resTokens = (resourcePath === EMPTY_RESOURCE)?'':resourcePath;

        let basePath = `resources/api${this.props.apiParentResource}`;
        resTokens.split('/').forEach((resourceName) => {
            const isRoot = (basePath === 'resources/api/');
            const props = Object.assign({}, this.props, {
                isDynamic: resourceName.indexOf(':') === 0,
                isRoot
            });
            resourceName = resourceName.replace(':', '');

            if(resourceName !== '') {
                this.fs.copyTpl(
                    this.templatePath(`resources/api/_resource/resource.js`),
                    this.destinationPath(`${basePath}/${resourceName}/resource.js`),
                    props
                );
                updated = true;
            }
            if(this.props.apiEnableCors) {
                this.fs.copyTpl(
                    this.templatePath(`resources/api/_resource/options.js`),
                    this.destinationPath(`${basePath}/${resourceName}/options.js`),
                    props
                );
                updated = true;
            }

            basePath = basePath + `/${resourceName}`;
        });
        if(!updated) {
            this.log('No updates necessary');
        }
    }
});
<commit_msg>Fix generator title<commit_after>'use strict';

const _yeoman = require('yeoman-generator');

const _fsUtils = require('../../utils/fs-utils');
const _consts = require('../../utils/constants');

const EMPTY_RESOURCE = 'EMPTY (Create at parent level)';

module.exports = _yeoman.Base.extend({
    /**
     * Initializes the generator.
     */
    constructor: function() {
        _yeoman.Base.apply(this, arguments);
        this.availableResources = ['/'];
    },

    /**
     * Queries the project to identify all defined dynamodb tables that can
     * serve as event sources.
     */
    lookupAvailableSources: function() {
        const done = this.async();
        const path = this.destinationPath('resources/api');
        _fsUtils.getSubDirectoryPaths(path).then((dirList) => {
            const pathRegex = new RegExp(`${path}/?`);
            this.availableResources = dirList.map(item => item.replace(pathRegex, '/'));
            done();
        }).catch((ex) => {
            this.env.error('Error determining existing API resources');
            done(ex);
        });
    },

    /**
     * Shows a the title of the sub generator, and a brief description.
     */
    showTitle: function() {
        this.log(_consts.SEPARATOR);
        this.log('Create a REST API Resource:\n');
    },

    /**
     * Gathers resource information
     */
    gatherResourceInfo: function () {
        const prompts = [{
            type: 'list',
            name: 'apiParentResource',
            message: 'Parent resource?',
            choices: this.availableResources,
            default: 0
        }, {
            type: 'input',
            name: 'apiResourcePath',
            message: 'Resource Path (ex: user/:userId)?',
            default: EMPTY_RESOURCE,
            filter: resp => resp === EMPTY_RESOURCE? '':resp,
            validate: (response) => {
                const resPattern = /(^[^\/]|^:)((\/:?)?[a-zA-Z0-9]+)+$/;
                if(response === '' || response.match(resPattern)) {
                    return true;
                }
                return 'If non empty, resource name can only contain letters, numbers, "_" and "-".\n   Multiple resources can be separated by "/"\n   Parameterized resource paths should be prefixed with ":"';
            }
        }, {
            type: 'confirm',
            name: 'apiEnableCors',
            message: 'Enable CORS?',
            default: true
        }, {
            type: 'checkbox',
            name: 'apiCorsMethods',
            message: 'CORS Methods?',
            choices: ['GET', 'POST', 'PUT', 'DELETE'],
            default: [ 'GET', 'POST' ],
            when: answers => answers.apiEnableCors,
            validate: (response) => {
                if(response.length > 0) {
                    return true;
                }
                return 'Choose at least one applicable HTTP method';
            }
        }];

        return this.prompt(prompts).then((props) => {
            this.props = Object.assign(this.props || {}, props);
        });
    },

    /**
     * Creates cloud formation template for the api resource
     */
    createResourceTemplate: function() {
        let updated = false;
        const resourcePath = this.props.apiResourcePath;
        const resTokens = (resourcePath === EMPTY_RESOURCE)?'':resourcePath;

        let basePath = `resources/api${this.props.apiParentResource}`;
        resTokens.split('/').forEach((resourceName) => {
            const isRoot = (basePath === 'resources/api/');
            const props = Object.assign({}, this.props, {
                isDynamic: resourceName.indexOf(':') === 0,
                isRoot
            });
            resourceName = resourceName.replace(':', '');

            if(resourceName !== '') {
                this.fs.copyTpl(
                    this.templatePath(`resources/api/_resource/resource.js`),
                    this.destinationPath(`${basePath}/${resourceName}/resource.js`),
                    props
                );
                updated = true;
            }
            if(this.props.apiEnableCors) {
                this.fs.copyTpl(
                    this.templatePath(`resources/api/_resource/options.js`),
                    this.destinationPath(`${basePath}/${resourceName}/options.js`),
                    props
                );
                updated = true;
            }

            basePath = basePath + `/${resourceName}`;
        });
        if(!updated) {
            this.log('No updates necessary');
        }
    }
});
<|endoftext|>


<commit_before>import React from 'react';
import style from './KeyPageActions.css';
import { connect } from 'react-redux';
import { compose } from 'recompose';
import * as keysActions from '../../../../../../store/ducks/selectedKey';
import { deleteKey } from '../../../../../../store/ducks/keys';
import { diff } from 'deep-diff';

const DeleteButton = ({isSaving, selectedKey, deleteKey}) => (
  <button disabled={isSaving}
    className={style['delete-key-button']}
    onClick={() => {
      if (confirm('Are you sure?')) {
        deleteKey(selectedKey.key);
      }
    } }>Delete key</button>
);

const SaveButton = ({selectedKey, isSaving, hasChanges, saveKey}) => (
  <button disabled={!hasChanges || isSaving}
    data-state-has-changes={hasChanges}
    data-state-is-saving={isSaving}
    className={style['save-changes-button']}
    onClick={() => saveKey(selectedKey.key)}>
    {isSaving ? 'Saving...' : 'Save changes'}
  </button>
);

const comp = compose(
  connect(
    state => ({ selectedKey: state.selectedKey }),
    { ...keysActions, deleteKey })
)(
  ({ selectedKey, isInAddMode, saveKey, deleteKey, isReadonly, isInStickyMode }) => {
    const { local, remote, isSaving } = selectedKey;
    const changes = diff(local, remote);
    const hasChanges = (changes || []).length > 0;

    return (

        {isReadonly ?

This key is readonly

          : null}

          {!isInAddMode && !isInStickyMode ?
            <DeleteButton isSaving={isSaving}
              selectedKey={selectedKey}
              deleteKey={deleteKey} />
            : null}
          <SaveButton selectedKey={selectedKey}
            isSaving={isSaving}
            hasChanges={hasChanges}
            saveKey={saveKey}
            />

    );
  });

export default comp;
<commit_msg>Removed tabindex from add and delete buttons<commit_after>import React from 'react';
import style from './KeyPageActions.css';
import { connect } from 'react-redux';
import { compose } from 'recompose';
import * as keysActions from '../../../../../../store/ducks/selectedKey';
import { deleteKey } from '../../../../../../store/ducks/keys';
import { diff } from 'deep-diff';

const DeleteButton = ({isSaving, selectedKey, deleteKey}) => (
  <button
    disabled={isSaving}
    className={style['delete-key-button']}
    tabIndex="-1"
    onClick={() => {
      if (confirm('Are you sure?')) {
        deleteKey(selectedKey.key);
      }
    } }>Delete key</button>
);

const SaveButton = ({selectedKey, isSaving, hasChanges, saveKey}) => (
  <button
    disabled={!hasChanges || isSaving}
    data-state-has-changes={hasChanges}
    data-state-is-saving={isSaving}
    tabIndex="-1"
    className={style['save-changes-button']}
    onClick={() => saveKey(selectedKey.key)}>
    {isSaving ? 'Saving...' : 'Save changes'}
  </button>
);

const comp = compose(
  connect(
    state => ({ selectedKey: state.selectedKey }),
    { ...keysActions, deleteKey })
)(
  ({ selectedKey, isInAddMode, saveKey, deleteKey, isReadonly, isInStickyMode }) => {
    const { local, remote, isSaving } = selectedKey;
    const changes = diff(local, remote);
    const hasChanges = (changes || []).length > 0;

    return (

        {isReadonly ?

This key is readonly

          : null}

          {!isInAddMode && !isInStickyMode ?
            <DeleteButton isSaving={isSaving}
              selectedKey={selectedKey}
              deleteKey={deleteKey} />
            : null}
          <SaveButton selectedKey={selectedKey}
            isSaving={isSaving}
            hasChanges={hasChanges}
            saveKey={saveKey}
            />

    );
  });

export default comp;
<|endoftext|>


<commit_before>/**
 * Copyright 2013-2020 the original author or authors from the JHipster project.
 *
 * This file is part of the JHipster project, see https://jhipster.github.io/
 * for more information.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
const constants = require('../generator-constants');

const { CLIENT_MAIN_SRC_DIR, CLIENT_TEST_SRC_DIR, REACT_DIR } = constants;

/**
 * The default is to use a file path string. It implies use of the template method.
 * For any other config an object { file:.., method:.., template:.. } can be used
 */
const files = {
    common: [
        {
            templates: [
                'package.json',
                '.eslintrc.json',
                '.eslint.react.json',
                'tsconfig.json',
                'tsconfig.test.json',
                { file: '.editorconfig', method: 'copy', noEjs: true },
                'webpack/logo-jhipster.png',
                'webpack/webpack.common.js',
                'webpack/webpack.dev.js',
                'webpack/webpack.prod.js',
                'webpack/utils.js',
            ],
        },
        {
            condition: generator => generator.protractorTests,
            templates: ['tsconfig.e2e.json'],
        },
    ],
    sass: [
        {
            templates: ['postcss.config.js'],
        },
    ],
    swagger: [
        {
            path: CLIENT_MAIN_SRC_DIR,
            templates: ['swagger-ui/index.html', { file: 'swagger-ui/dist/images/throbber.gif', method: 'copy' }],
        },
    ],
    commonWeb: [
        {
            path: CLIENT_MAIN_SRC_DIR,
            templates: [
                'WEB-INF/web.xml',
                { file: 'favicon.ico', method: 'copy' },
                'robots.txt',
                '404.html',
                'index.html',
                'content/css/loading.css',
            ],
        },
    ],
    reactApp: [
        {
            path: REACT_DIR,
            templates: [
                { file: 'app.tsx', method: 'processJsx' },
                { file: 'index.tsx', method: 'processJsx' },
                { file: 'routes.tsx', method: 'processJsx' },
                'typings.d.ts',
                'config/constants.ts',
                'config/axios-interceptor.ts',
                { file: 'config/devtools.tsx', method: 'processJsx' },
                'config/error-middleware.ts',
                'config/logger-middleware.ts',
                'config/notification-middleware.ts',
                'config/store.ts',
                'config/icon-loader.ts',
            ],
        },
        {
            condition: generator => generator.enableTranslation,
            path: REACT_DIR,
            templates: ['config/translation.ts'],
        },
        {
            condition: generator => generator.websocket === 'spring-websocket',
            path: REACT_DIR,
            templates: ['config/websocket-middleware.ts'],
        },
        {
            path: REACT_DIR,
            templates: ['app.scss', '_bootstrap-variables.scss'],
        },
    ],
    reactEntities: [
        {
            path: REACT_DIR,
            templates: [{ file: 'entities/index.tsx', method: 'processJsx' }],
        },
    ],
    reactMain: [
        {
            path: REACT_DIR,
            templates: [
                { file: 'modules/home/home.tsx', method: 'processJsx' },
                { file: 'modules/login/logout.tsx', method: 'processJsx' },
            ],
        },
        {
            condition: generator => generator.authenticationType !== 'oauth2',
            path: REACT_DIR,
            templates: [
                { file: 'modules/login/login.tsx', method: 'processJsx' },
                { file: 'modules/login/login-modal.tsx', method: 'processJsx' },
            ],
        },
        {
            path: REACT_DIR,
            templates: ['modules/home/home.scss'],
        },
    ],
    reducers: [
        {
            path: REACT_DIR,
            templates: [
                'shared/reducers/index.ts',
                'shared/reducers/action-type.util.ts',
                'shared/reducers/authentication.ts',
                'shared/reducers/application-profile.ts',
            ],
        },
        {
            condition: generator => generator.enableTranslation,
            path: REACT_DIR,
            templates: ['shared/reducers/locale.ts'],
        },
        {
            condition: generator => generator.authenticationType === 'oauth2',
            path: REACT_DIR,
            templates: ['shared/reducers/user-management.ts'],
        },
    ],
    accountModule: [
        {
            condition: generator => !generator.skipUserManagement,
            path: REACT_DIR,
            templates: [
                { file: 'modules/account/index.tsx', method: 'processJsx' },
                { file: 'modules/account/activate/activate.tsx', method: 'processJsx' },
                { file: 'modules/account/password/password.tsx', method: 'processJsx' },
                { file: 'modules/account/register/register.tsx', method: 'processJsx' },
                { file: 'modules/account/password-reset/init/password-reset-init.tsx', method: 'processJsx' },
                { file: 'modules/account/password-reset/finish/password-reset-finish.tsx', method: 'processJsx' },
                { file: 'modules/account/settings/settings.tsx', method: 'processJsx' },
                { file: 'modules/account/register/register.reducer.ts', method: 'processJsx' },
                { file: 'modules/account/activate/activate.reducer.ts', method: 'processJsx' },
                { file: 'modules/account/password-reset/password-reset.reducer.ts', method: 'processJsx' },
                { file: 'modules/account/password/password.reducer.ts', method: 'processJsx' },
                { file: 'modules/account/settings/settings.reducer.ts', method: 'processJsx' },
            ],
        },
        {
            condition: generator => generator.authenticationType === 'session' && !generator.skipUserManagement,
            path: REACT_DIR,
            templates: [
                { file: 'modules/account/sessions/sessions.tsx', method: 'processJsx' },
                'modules/account/sessions/sessions.reducer.ts',
            ],
        },
    ],
    adminModule: [
        {
            path: REACT_DIR,
            templates: [
                // admin modules
                { file: 'modules/administration/index.tsx', method: 'processJsx' },
                { file: 'modules/administration/configuration/configuration.tsx', method: 'processJsx' },
                { file: 'modules/administration/docs/docs.tsx', method: 'processJsx' },
                'modules/administration/docs/docs.scss',
                { file: 'modules/administration/health/health.tsx', method: 'processJsx' },
                { file: 'modules/administration/health/health-modal.tsx', method: 'processJsx' },
                { file: 'modules/administration/logs/logs.tsx', method: 'processJsx' },
                { file: 'modules/administration/metrics/metrics.tsx', method: 'processJsx' },
                'modules/administration/administration.reducer.ts',
            ],
        },
        {
            condition: generator => generator.websocket === 'spring-websocket',
            path: REACT_DIR,
            templates: [{ file: 'modules/administration/tracker/tracker.tsx', method: 'processJsx' }],
        },
        {
            condition: generator => !generator.skipUserManagement,
            path: REACT_DIR,
            templates: [
                { file: 'modules/administration/user-management/index.tsx', method: 'processJsx' },
                { file: 'modules/administration/user-management/user-management.tsx', method: 'processJsx' },
                { file: 'modules/administration/user-management/user-management-update.tsx', method: 'processJsx' },
                { file: 'modules/administration/user-management/user-management-detail.tsx', method: 'processJsx' },
                { file: 'modules/administration/user-management/user-management-delete-dialog.tsx', method: 'processJsx' },
                'modules/administration/user-management/user-management.reducer.ts',
            ],
        },
        {
            condition: generator => generator.applicationType === 'gateway' && generator.serviceDiscoveryType,
            path: REACT_DIR,
            templates: [{ file: 'modules/administration/gateway/gateway.tsx', method: 'processJsx' }],
        },
    ],
    reactShared: [
        {
            path: REACT_DIR,
            templates: [
                // layouts
                { file: 'shared/layout/footer/footer.tsx', method: 'processJsx' },
                { file: 'shared/layout/header/header.tsx', method: 'processJsx' },
                { file: 'shared/layout/header/header-components.tsx', method: 'processJsx' },
                'shared/layout/menus/index.ts',
                { file: 'shared/layout/menus/admin.tsx', method: 'processJsx' },
                { file: 'shared/layout/menus/account.tsx', method: 'processJsx' },
                { file: 'shared/layout/menus/entities.tsx', method: 'processJsx' },
                { file: 'shared/layout/menus/menu-components.tsx', method: 'processJsx' },
                { file: 'shared/layout/menus/menu-item.tsx', method: 'processJsx' },
                { file: 'shared/layout/password/password-strength-bar.tsx', method: 'processJsx' },
                // util
                'shared/util/date-utils.ts',
                'shared/util/pagination.constants.ts',
                'shared/util/entity-utils.ts',
                // components
                { file: 'shared/auth/private-route.tsx', method: 'processJsx' },
                { file: 'shared/error/error-boundary.tsx', method: 'processJsx' },
                { file: 'shared/error/error-boundary-route.tsx', method: 'processJsx' },
                { file: 'shared/error/page-not-found.tsx', method: 'processJsx' },
                { file: 'shared/DurationFormat.tsx', method: 'processJsx' },
                // model
                'shared/model/user.model.ts',
            ],
        },
        {
            condition: generator => generator.enableTranslation,
            path: REACT_DIR,
            templates: [{ file: 'shared/layout/menus/locale.tsx', method: 'processJsx' }],
        },
        {
            condition: generator => generator.authenticationType === 'oauth2',
            path: REACT_DIR,
            templates: ['shared/util/url-utils.ts'],
        },
        {
            condition: generator => generator.authenticationType === 'session' && generator.websocket === 'spring-websocket',
            path: REACT_DIR,
            templates: ['shared/util/cookie-utils.ts'],
        },
        {
            path: REACT_DIR,
            templates: [
                'shared/layout/header/header.scss',
                'shared/layout/footer/footer.scss',
                'shared/layout/password/password-strength-bar.scss',
            ],
        },
    ],
    clientTestFw: [
        {
            path: CLIENT_TEST_SRC_DIR,
            templates: [
                'jest.conf.js',
                'spec/icons-mock.ts',
                'spec/storage-mock.ts',
                'spec/app/utils.ts',
                'spec/app/config/axios-interceptor.spec.ts',
                'spec/app/config/notification-middleware.spec.ts',
                'spec/app/shared/reducers/application-profile.spec.ts',
                'spec/app/shared/reducers/authentication.spec.ts',
                'spec/app/shared/util/entity-utils.spec.ts',
                'spec/app/shared/auth/private-route.spec.tsx',
                'spec/app/shared/error/error-boundary.spec.tsx',
                'spec/app/shared/error/error-boundary-route.spec.tsx',
                'spec/app/shared/layout/header/header.spec.tsx',
                'spec/app/shared/layout/menus/account.spec.tsx',
                'spec/app/modules/administration/administration.reducer.spec.ts',
                // 'spec/app/account/activate/_activate.component.spec.js',
                // 'spec/app/account/password/_password.component.spec.js',
                // 'spec/app/account/password/_password-strength-bar.component.spec.js',
                // 'spec/app/account/password-reset/init/_password-reset-init.component.spec.js',
                // 'spec/app/account/password-reset/finish/_password-reset-finish.component.spec.js',
                // 'spec/app/account/settings/_settings.component.spec.js',
                // 'spec/app/admin/health/_health.component.spec.js',
                // 'spec/helpers/_spyobject.js',
                // 'spec/helpers/_mock-account.service.js',
                // 'spec/helpers/_mock-principal.service.js',
                // 'spec/helpers/_mock-route.service.js'
            ],
        },
        {
            condition: generator => !generator.skipUserManagement,
            path: CLIENT_TEST_SRC_DIR,
            templates: [
                // 'spec/app/modules/account/register/register.spec.tsx',
                'spec/app/modules/account/register/register.reducer.spec.ts',
                'spec/app/modules/account/activate/activate.reducer.spec.ts',
                'spec/app/modules/account/password/password.reducer.spec.ts',
                'spec/app/modules/account/settings/settings.reducer.spec.ts',
            ],
        },
        {
            condition: generator => !generator.skipUserManagement,
            path: CLIENT_TEST_SRC_DIR,
            templates: ['spec/app/modules/administration/user-management/user-management.reducer.spec.ts'],
        },
        {
            condition: generator => generator.enableTranslation,
            path: CLIENT_TEST_SRC_DIR,
            templates: ['spec/app/shared/reducers/locale.spec.ts'],
        },
        {
            condition: generator => generator.skipUserManagement && generator.authenticationType === 'oauth2',
            path: CLIENT_TEST_SRC_DIR,
            templates: ['spec/app/shared/reducers/user-management.spec.ts'],
        },
        // {
        //     condition: generator => generator.authenticationType === 'session',
        //     path: CLIENT_TEST_SRC_DIR,
        //     templates: [
        //         'spec/app/modules/account/sessions/sessions.reducer.spec.ts',
        //     ]
        // },
        {
            condition: generator => generator.protractorTests,
            path: CLIENT_TEST_SRC_DIR,
            templates: [
                'e2e/modules/account/account.spec.ts',
                'e2e/modules/administration/administration.spec.ts',
                'e2e/util/utils.ts',
                'e2e/page-objects/base-component.ts',
                'e2e/page-objects/navbar-page.ts',
                'e2e/page-objects/signin-page.ts',
                'protractor.conf.js',
            ],
        },
        {
            condition: generator => generator.protractorTests && !generator.skipUserManagement,
            path: CLIENT_TEST_SRC_DIR,
            templates: ['e2e/page-objects/password-page.ts', 'e2e/page-objects/settings-page.ts', 'e2e/page-objects/register-page.ts'],
        },
    ],
};

module.exports = {
    writeFiles,
    files,
};

function writeFiles() {
    // write React files
    this.writeFilesToDisk(files, this, false, this.fetchFromInstalledJHipster('client/templates/react'));
}
<commit_msg>Fix react eslint config.<commit_after>/**
 * Copyright 2013-2020 the original author or authors from the JHipster project.
 *
 * This file is part of the JHipster project, see https://jhipster.github.io/
 * for more information.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
const constants = require('../generator-constants');

const { CLIENT_MAIN_SRC_DIR, CLIENT_TEST_SRC_DIR, REACT_DIR } = constants;

/**
 * The default is to use a file path string. It implies use of the template method.
 * For any other config an object { file:.., method:.., template:.. } can be used
 */
const files = {
    common: [
        {
            templates: [
                'package.json',
                '.eslintrc.json',
                '.eslint.react.js',
                'tsconfig.json',
                'tsconfig.test.json',
                { file: '.editorconfig', method: 'copy', noEjs: true },
                'webpack/logo-jhipster.png',
                'webpack/webpack.common.js',
                'webpack/webpack.dev.js',
                'webpack/webpack.prod.js',
                'webpack/utils.js',
            ],
        },
        {
            condition: generator => generator.protractorTests,
            templates: ['tsconfig.e2e.json'],
        },
    ],
    sass: [
        {
            templates: ['postcss.config.js'],
        },
    ],
    swagger: [
        {
            path: CLIENT_MAIN_SRC_DIR,
            templates: ['swagger-ui/index.html', { file: 'swagger-ui/dist/images/throbber.gif', method: 'copy' }],
        },
    ],
    commonWeb: [
        {
            path: CLIENT_MAIN_SRC_DIR,
            templates: [
                'WEB-INF/web.xml',
                { file: 'favicon.ico', method: 'copy' },
                'robots.txt',
                '404.html',
                'index.html',
                'content/css/loading.css',
            ],
        },
    ],
    reactApp: [
        {
            path: REACT_DIR,
            templates: [
                { file: 'app.tsx', method: 'processJsx' },
                { file: 'index.tsx', method: 'processJsx' },
                { file: 'routes.tsx', method: 'processJsx' },
                'typings.d.ts',
                'config/constants.ts',
                'config/axios-interceptor.ts',
                { file: 'config/devtools.tsx', method: 'processJsx' },
                'config/error-middleware.ts',
                'config/logger-middleware.ts',
                'config/notification-middleware.ts',
                'config/store.ts',
                'config/icon-loader.ts',
            ],
        },
        {
            condition: generator => generator.enableTranslation,
            path: REACT_DIR,
            templates: ['config/translation.ts'],
        },
        {
            condition: generator => generator.websocket === 'spring-websocket',
            path: REACT_DIR,
            templates: ['config/websocket-middleware.ts'],
        },
        {
            path: REACT_DIR,
            templates: ['app.scss', '_bootstrap-variables.scss'],
        },
    ],
    reactEntities: [
        {
            path: REACT_DIR,
            templates: [{ file: 'entities/index.tsx', method: 'processJsx' }],
        },
    ],
    reactMain: [
        {
            path: REACT_DIR,
            templates: [
                { file: 'modules/home/home.tsx', method: 'processJsx' },
                { file: 'modules/login/logout.tsx', method: 'processJsx' },
            ],
        },
        {
            condition: generator => generator.authenticationType !== 'oauth2',
            path: REACT_DIR,
            templates: [
                { file: 'modules/login/login.tsx', method: 'processJsx' },
                { file: 'modules/login/login-modal.tsx', method: 'processJsx' },
            ],
        },
        {
            path: REACT_DIR,
            templates: ['modules/home/home.scss'],
        },
    ],
    reducers: [
        {
            path: REACT_DIR,
            templates: [
                'shared/reducers/index.ts',
                'shared/reducers/action-type.util.ts',
                'shared/reducers/authentication.ts',
                'shared/reducers/application-profile.ts',
            ],
        },
        {
            condition: generator => generator.enableTranslation,
            path: REACT_DIR,
            templates: ['shared/reducers/locale.ts'],
        },
        {
            condition: generator => generator.authenticationType === 'oauth2',
            path: REACT_DIR,
            templates: ['shared/reducers/user-management.ts'],
        },
    ],
    accountModule: [
        {
            condition: generator => !generator.skipUserManagement,
            path: REACT_DIR,
            templates: [
                { file: 'modules/account/index.tsx', method: 'processJsx' },
                { file: 'modules/account/activate/activate.tsx', method: 'processJsx' },
                { file: 'modules/account/password/password.tsx', method: 'processJsx' },
                { file: 'modules/account/register/register.tsx', method: 'processJsx' },
                { file: 'modules/account/password-reset/init/password-reset-init.tsx', method: 'processJsx' },
                { file: 'modules/account/password-reset/finish/password-reset-finish.tsx', method: 'processJsx' },
                { file: 'modules/account/settings/settings.tsx', method: 'processJsx' },
                { file: 'modules/account/register/register.reducer.ts', method: 'processJsx' },
                { file: 'modules/account/activate/activate.reducer.ts', method: 'processJsx' },
                { file: 'modules/account/password-reset/password-reset.reducer.ts', method: 'processJsx' },
                { file: 'modules/account/password/password.reducer.ts', method: 'processJsx' },
                { file: 'modules/account/settings/settings.reducer.ts', method: 'processJsx' },
            ],
        },
        {
            condition: generator => generator.authenticationType === 'session' && !generator.skipUserManagement,
            path: REACT_DIR,
            templates: [
                { file: 'modules/account/sessions/sessions.tsx', method: 'processJsx' },
                'modules/account/sessions/sessions.reducer.ts',
            ],
        },
    ],
    adminModule: [
        {
            path: REACT_DIR,
            templates: [
                // admin modules
                { file: 'modules/administration/index.tsx', method: 'processJsx' },
                { file: 'modules/administration/configuration/configuration.tsx', method: 'processJsx' },
                { file: 'modules/administration/docs/docs.tsx', method: 'processJsx' },
                'modules/administration/docs/docs.scss',
                { file: 'modules/administration/health/health.tsx', method: 'processJsx' },
                { file: 'modules/administration/health/health-modal.tsx', method: 'processJsx' },
                { file: 'modules/administration/logs/logs.tsx', method: 'processJsx' },
                { file: 'modules/administration/metrics/metrics.tsx', method: 'processJsx' },
                'modules/administration/administration.reducer.ts',
            ],
        },
        {
            condition: generator => generator.websocket === 'spring-websocket',
            path: REACT_DIR,
            templates: [{ file: 'modules/administration/tracker/tracker.tsx', method: 'processJsx' }],
        },
        {
            condition: generator => !generator.skipUserManagement,
            path: REACT_DIR,
            templates: [
                { file: 'modules/administration/user-management/index.tsx', method: 'processJsx' },
                { file: 'modules/administration/user-management/user-management.tsx', method: 'processJsx' },
                { file: 'modules/administration/user-management/user-management-update.tsx', method: 'processJsx' },
                { file: 'modules/administration/user-management/user-management-detail.tsx', method: 'processJsx' },
                { file: 'modules/administration/user-management/user-management-delete-dialog.tsx', method: 'processJsx' },
                'modules/administration/user-management/user-management.reducer.ts',
            ],
        },
        {
            condition: generator => generator.applicationType === 'gateway' && generator.serviceDiscoveryType,
            path: REACT_DIR,
            templates: [{ file: 'modules/administration/gateway/gateway.tsx', method: 'processJsx' }],
        },
    ],
    reactShared: [
        {
            path: REACT_DIR,
            templates: [
                // layouts
                { file: 'shared/layout/footer/footer.tsx', method: 'processJsx' },
                { file: 'shared/layout/header/header.tsx', method: 'processJsx' },
                { file: 'shared/layout/header/header-components.tsx', method: 'processJsx' },
                'shared/layout/menus/index.ts',
                { file: 'shared/layout/menus/admin.tsx', method: 'processJsx' },
                { file: 'shared/layout/menus/account.tsx', method: 'processJsx' },
                { file: 'shared/layout/menus/entities.tsx', method: 'processJsx' },
                { file: 'shared/layout/menus/menu-components.tsx', method: 'processJsx' },
                { file: 'shared/layout/menus/menu-item.tsx', method: 'processJsx' },
                { file: 'shared/layout/password/password-strength-bar.tsx', method: 'processJsx' },
                // util
                'shared/util/date-utils.ts',
                'shared/util/pagination.constants.ts',
                'shared/util/entity-utils.ts',
                // components
                { file: 'shared/auth/private-route.tsx', method: 'processJsx' },
                { file: 'shared/error/error-boundary.tsx', method: 'processJsx' },
                { file: 'shared/error/error-boundary-route.tsx', method: 'processJsx' },
                { file: 'shared/error/page-not-found.tsx', method: 'processJsx' },
                { file: 'shared/DurationFormat.tsx', method: 'processJsx' },
                // model
                'shared/model/user.model.ts',
            ],
        },
        {
            condition: generator => generator.enableTranslation,
            path: REACT_DIR,
            templates: [{ file: 'shared/layout/menus/locale.tsx', method: 'processJsx' }],
        },
        {
            condition: generator => generator.authenticationType === 'oauth2',
            path: REACT_DIR,
            templates: ['shared/util/url-utils.ts'],
        },
        {
            condition: generator => generator.authenticationType === 'session' && generator.websocket === 'spring-websocket',
            path: REACT_DIR,
            templates: ['shared/util/cookie-utils.ts'],
        },
        {
            path: REACT_DIR,
            templates: [
                'shared/layout/header/header.scss',
                'shared/layout/footer/footer.scss',
                'shared/layout/password/password-strength-bar.scss',
            ],
        },
    ],
    clientTestFw: [
        {
            path: CLIENT_TEST_SRC_DIR,
            templates: [
                'jest.conf.js',
                'spec/icons-mock.ts',
                'spec/storage-mock.ts',
                'spec/app/utils.ts',
                'spec/app/config/axios-interceptor.spec.ts',
                'spec/app/config/notification-middleware.spec.ts',
                'spec/app/shared/reducers/application-profile.spec.ts',
                'spec/app/shared/reducers/authentication.spec.ts',
                'spec/app/shared/util/entity-utils.spec.ts',
                'spec/app/shared/auth/private-route.spec.tsx',
                'spec/app/shared/error/error-boundary.spec.tsx',
                'spec/app/shared/error/error-boundary-route.spec.tsx',
                'spec/app/shared/layout/header/header.spec.tsx',
                'spec/app/shared/layout/menus/account.spec.tsx',
                'spec/app/modules/administration/administration.reducer.spec.ts',
                // 'spec/app/account/activate/_activate.component.spec.js',
                // 'spec/app/account/password/_password.component.spec.js',
                // 'spec/app/account/password/_password-strength-bar.component.spec.js',
                // 'spec/app/account/password-reset/init/_password-reset-init.component.spec.js',
                // 'spec/app/account/password-reset/finish/_password-reset-finish.component.spec.js',
                // 'spec/app/account/settings/_settings.component.spec.js',
                // 'spec/app/admin/health/_health.component.spec.js',
                // 'spec/helpers/_spyobject.js',
                // 'spec/helpers/_mock-account.service.js',
                // 'spec/helpers/_mock-principal.service.js',
                // 'spec/helpers/_mock-route.service.js'
            ],
        },
        {
            condition: generator => !generator.skipUserManagement,
            path: CLIENT_TEST_SRC_DIR,
            templates: [
                // 'spec/app/modules/account/register/register.spec.tsx',
                'spec/app/modules/account/register/register.reducer.spec.ts',
                'spec/app/modules/account/activate/activate.reducer.spec.ts',
                'spec/app/modules/account/password/password.reducer.spec.ts',
                'spec/app/modules/account/settings/settings.reducer.spec.ts',
            ],
        },
        {
            condition: generator => !generator.skipUserManagement,
            path: CLIENT_TEST_SRC_DIR,
            templates: ['spec/app/modules/administration/user-management/user-management.reducer.spec.ts'],
        },
        {
            condition: generator => generator.enableTranslation,
            path: CLIENT_TEST_SRC_DIR,
            templates: ['spec/app/shared/reducers/locale.spec.ts'],
        },
        {
            condition: generator => generator.skipUserManagement && generator.authenticationType === 'oauth2',
            path: CLIENT_TEST_SRC_DIR,
            templates: ['spec/app/shared/reducers/user-management.spec.ts'],
        },
        // {
        //     condition: generator => generator.authenticationType === 'session',
        //     path: CLIENT_TEST_SRC_DIR,
        //     templates: [
        //         'spec/app/modules/account/sessions/sessions.reducer.spec.ts',
        //     ]
        // },
        {
            condition: generator => generator.protractorTests,
            path: CLIENT_TEST_SRC_DIR,
            templates: [
                'e2e/modules/account/account.spec.ts',
                'e2e/modules/administration/administration.spec.ts',
                'e2e/util/utils.ts',
                'e2e/page-objects/base-component.ts',
                'e2e/page-objects/navbar-page.ts',
                'e2e/page-objects/signin-page.ts',
                'protractor.conf.js',
            ],
        },
        {
            condition: generator => generator.protractorTests && !generator.skipUserManagement,
            path: CLIENT_TEST_SRC_DIR,
            templates: ['e2e/page-objects/password-page.ts', 'e2e/page-objects/settings-page.ts', 'e2e/page-objects/register-page.ts'],
        },
    ],
};

module.exports = {
    writeFiles,
    files,
};

function writeFiles() {
    // write React files
    this.writeFilesToDisk(files, this, false, this.fetchFromInstalledJHipster('client/templates/react'));
}
<|endoftext|>


<commit_before>'use strict';
/* jshint node: true */
/* jshint esnext: true */
/* global describe, beforeEach, afterAll, spyOn, it, expect, fail */

describe('participants service', () => {

  const participants = require('../../service/participants');
  const pg = require('pg');
  let helper = require('../journeyHelper');

  const aParticipant = {
    firstname: 'Hertha',
    lastname: 'Mustermann',
    email: 'h.mustermann@example.com',
    category: 'Unicorn',
    birthyear: 1980,
    visibility: 'yes',
    discount:'no',
    team: 'Crazy runners'
  };

  const secureId = 'some_secure_id';
  const paymentToken = 'a token';

  const expectOnParticipantFields = function(participantFromDb, participantId) {
    expect(participantFromDb.id).toEqual(participantId);
    expect(participantFromDb.firstname).toEqual(aParticipant.firstname);
    expect(participantFromDb.lastname).toEqual(aParticipant.lastname);
    expect(participantFromDb.email).toEqual(aParticipant.email);
    expect(participantFromDb.category).toEqual(aParticipant.category);
    expect(participantFromDb.birthyear).toEqual(aParticipant.birthyear);
    expect(participantFromDb.visibility).toEqual(aParticipant.visibility);
    expect(participantFromDb.discount).toEqual(aParticipant.discount);
    expect(participantFromDb.team).toEqual(aParticipant.team);
    expect(participantFromDb.paymenttoken).toEqual(paymentToken);
    expect(participantFromDb.has_payed).toEqual(false);
    expect(participantFromDb.secureid).toEqual(secureId);
  };

  beforeEach((done) => {
    helper.changeOriginalTimeout();
    helper.setupDbConnection(done);
  });

  afterAll((done) => {
    helper.resetToOriginalTimeout();
    pg.end();
    done();
  });

  it('should store and read participants', (done) => {
    const randomToken = '1234567';

    participants.save(aParticipant, randomToken, secureId)
      .then(participants.getRegistered)
      .then(function (data) {
        expect(data.length).toBe(1);
        expect(data[0].firstname).toBe(aParticipant.firstname);
        expect(data[0].lastname).toBe(aParticipant.lastname);
        expect(data[0].email).toBe(aParticipant.email);
        expect(data[0].category).toBe(aParticipant.category);
        expect(data[0].birthyear).toBe(aParticipant.birthyear);
        expect(data[0].discount).toBe(aParticipant.discount);
        expect(data[0].team).toBe(aParticipant.team);
        done();
      })
      .fail(fail);
  });

  describe('save', () => {
    it('should return the id', (done) => {

      participants.save(aParticipant, paymentToken, secureId)
        .then(function (participantId) {
          expect(participantId).toBeDefined();
          done();
        })
        .fail(fail);
    });
  });

  describe('getById', () => {
    it('should return all information of the participant with given Id', (done) => {
      participants.save(aParticipant, paymentToken, secureId)
        .then(function (participantId) {
          participants.getById(participantId)
            .then(function (participant) {
              expectOnParticipantFields(participant, participantId);
              done();
            })
            .fail(fail);
        });
    });
  });

  describe('getByToken', () => {
    const aParticipantWithTshirt = {
      firstname: 'Hertha',
      lastname: 'Mustermann',
      email: 'h.mustermann@example.com',
      birthyear: 1980,
      tshirt: {
        size: 'XS',
        model: 'Crazy cool fit'
      }
    };

    it('should return participant\'s lastname and firstname and ordered tshirt for a given token', (done) => {
      participants.save(aParticipantWithTshirt, paymentToken)
        .then(function (participantId) {
          participants.addTShirt(aParticipantWithTshirt.tshirt, participantId)
            .then(() => {
              participants.getByToken(paymentToken)
                .then(function (participant) {
                  expect(participant.name).toEqual(aParticipantWithTshirt.lastname + ', ' + aParticipantWithTshirt.firstname);
                  expect(participant.tshirt.size).toEqual(aParticipantWithTshirt.tshirt.size);
                  expect(participant.tshirt.model).toEqual(aParticipantWithTshirt.tshirt.model);
                  done();
                })
                .fail(fail);
            });
        });
    });
  });

  describe('getBySecureId', () => {
    it('should return all information of the participant with given secureId', (done) => {
      participants.save(aParticipant, paymentToken, secureId)
        .then(function (participantId) {
          participants.getBySecureId(secureId)
            .then(function (participant) {
              expectOnParticipantFields(participant, participantId);
              done();
            })
            .fail(fail);
        });
    });
  });

  describe('confirmParticipant', () => {
    it('should mark the participant as payed and send a confirmation mail which includes the edit link', (done) => {
      spyOn(participants, 'markPayed').and.callThrough();
      spyOn(participants, 'sendEmail');

      participants.save(aParticipant, paymentToken, secureId)
        .then(function (participantId) {
          participants.confirmParticipant(participantId)
            .then(() => {
              expect(participants.markPayed).toHaveBeenCalledWith(participantId);

              expect(participants.sendEmail).toHaveBeenCalled();
              let partcipantsEmail = participants.sendEmail.calls.mostRecent().args[0];
              expect(partcipantsEmail).toBe(aParticipant.email);
              let subject = participants.sendEmail.calls.mostRecent().args[1];
              expect(subject).toBe('Lauf gegen Rechts: Zahlung erhalten');
              let content = participants.sendEmail.calls.mostRecent().args[2];
              expect(content).toMatch(aParticipant.firstname);
              expect(content).toMatch(/eingegangen/);
              expect(content).toMatch(secureId);

              done();
            })
            .fail(fail);
        });
    });

    it('should give error if ID is invalid', (done) => {
      let wrongId = '999';

      participants.save(aParticipant, paymentToken, secureId)
        .then(() => {
          participants.confirmParticipant(wrongId)
            .catch(() => {
              done();
            });
        });
    });
  });

  describe('delete', () => {
    it('should delete a user', (done) => {
      participants.save(aParticipant, paymentToken, secureId)
        .then((id) => {
            participants.delete(id).then(() => {
              done();
            });
        });
    });

    it('should delete users with tshirts', (done) => {
      const aParticipantWithTshirt = {
            firstname: 'Hertha',
            lastname: 'Mustermann',
            email: 'h.mustermann@example.com',
            birthyear: 1980,
            tshirt: {
              size: 'XS',
              model: 'Crazy cool fit'
            }
      };
      participants.save(aParticipantWithTshirt, paymentToken, secureId)
        .then((participantid) => {
            participants.delete(participantid).then(() => {
              done();
            })
            .fail(fail);
        });
    });

    it('should give error if accessing deleted user', (done) => {
      participants.save(aParticipant, paymentToken)
        .then((id) => {
            let participantid = id;
            participants.delete(participantid).then(() => {
              participants.getById(participantid).catch(() => {
                  done();
              });
            });
        });
    });
  });

  describe('registration', () => {
    it('should save the participant and send confirmation email', (done) => {
      spyOn(participants, 'save').and.callThrough();
      spyOn(participants, 'sendEmail');
      spyOn(participants, 'addTShirt');

      participants.register(aParticipant)
        .then((result) => {
          expect(participants.save).toHaveBeenCalled();
          let participant = participants.save.calls.mostRecent().args[0];
          expect(participant).toBe(aParticipant);
          let token = participants.save.calls.mostRecent().args[1];
          expect(token).toBe(result.token);
          let secureId = participants.save.calls.mostRecent().args[2];
          expect(secureId).not.toBeNull();

          expect(participants.sendEmail).toHaveBeenCalled();

          let participantsEmail = participants.sendEmail.calls.mostRecent().args[0];
          expect(participantsEmail).toBe(aParticipant.email);

          let subject = participants.sendEmail.calls.mostRecent().args[1];
          expect(subject).toBe('Lauf Gegen Rechts: Registrierung erfolgreich');

          let content = participants.sendEmail.calls.mostRecent().args[2];
          expect(content).toMatch(/Danke/);

          expect(participants.addTShirt).not.toHaveBeenCalled();
          done();
        })
        .fail(fail);
    });

    it('should call addTShirt if one ordered', (done) => {
      spyOn(participants, 'addTShirt');

      const aParticipantWithTshirt = {
        firstname: 'Hertha',
        lastname: 'Mustermann',
        email: 'h.mustermann@example.com',
        category: 'Unicorn',
        birthyear: 1980,
        team: 'Crazy runners',
        tshirt: {size: 'M', model: 'Slim fit'}
      };

      participants.register(aParticipantWithTshirt)
        .then(() => {
          expect(participants.addTShirt).toHaveBeenCalled();
          done();
        })
        .fail(fail);
    });
  });

  describe('addTShirt', () => {
    it('stores tshirt', (done) => {
      participants.save({
        firstname: 'Hertha',
        lastname: 'With TShirt',
        email: 'h.mustermann@example.com',
        category: 'Unicorn',
        birthyear: 1980,
        team: 'Crazy runners'
      }, 'tokenX').then(function (id) {
        participants.addTShirt({size: 'M', model: 'Skin fit'}, id)
          .then(() => {
            participants.getTShirtFor(id)
              .then(function (shirts) {
                expect(shirts.length).toBe(1);
                done();
              })
              .fail(fail);
          });
      });

    });
  });

  describe('update', () => {
    it('should return the full information for a participant with given Id', (done) => {
      participants.save(aParticipant, paymentToken, 'someSecureId')
        .then(function (id) {
          const updatedParticipant = {
            firstname: 'Hertha updated',
            lastname: 'Mustermann updated',
            email: 'h.mustermann@example.com updated',
            category: 'Unicorn updated',
            birthyear: 1981,
            team: 'Crazy runners updated'
          };
          participants.getById(id)
          .then((p) => {
            participants.update(updatedParticipant, p.secureid)
              .then(() => {
                participants.getById(id)
                  .then(function (participant) {
                    expect(participant.firstname).toBe('Hertha updated');
                    expect(participant.lastname).toBe('Mustermann updated');
                    expect(participant.email).toBe('h.mustermann@example.com updated');
                    expect(participant.category).toBe('Unicorn updated');
                    expect(participant.birthyear).toBe(1981);
                    expect(participant.team).toBe('Crazy runners updated');
                    done();
                  })
                  .fail(fail);
              });
          });
        });
    });
  });

  describe('getPubliclyVisible', () => {
    it('returns only participants which are confirmed and OK with being visible to the public', (done) => {
      participants.save(aParticipant, 'tokenXX')
        .then(participants.markPayed)
        .then(participants.getPubliclyVisible)
        .then(function (data) {
          expect(data.length).toBe(1);
          expect(data[0].firstname).toBe(aParticipant.firstname);
          expect(data[0].lastname).toBe(aParticipant.lastname);
          expect(data[0].email).toBe(aParticipant.email);
          expect(data[0].category).toBe(aParticipant.category);
          expect(data[0].birthyear).toBe(aParticipant.birthyear);
          expect(data[0].team).toBe(aParticipant.team);
          done();
        })
        .fail(fail);

    });
  });

  describe('bulkmail', () => {
    it('should send email to every participant', (done) => {
      spyOn(participants, 'sendEmail');
      participants.save(aParticipant,'tokenXX')
        .then(participants.bulkmail)
        .then((result) => {
          expect(participants.sendEmail).toHaveBeenCalled();

          let content = participants.sendEmail.calls.mostRecent().args[2];
          expect(content).toMatch(/Startnummer/);
          done();
        })
        .fail(fail);
    });
  });
})
;
<commit_msg>test checks if mails is sent to every participant<commit_after>'use strict';
/* jshint node: true */
/* jshint esnext: true */
/* global describe, beforeEach, afterAll, spyOn, it, expect, fail */

describe('participants service', () => {

  const participants = require('../../service/participants');
  const pg = require('pg');
  let helper = require('../journeyHelper');

  const aParticipant = {
    firstname: 'Hertha',
    lastname: 'Mustermann',
    email: 'h.mustermann@example.com',
    category: 'Unicorn',
    birthyear: 1980,
    visibility: 'yes',
    discount:'no',
    team: 'Crazy runners'
  };

  const aSecondParticipant = {
    firstname: 'Michel',
    lastname: 'Mueller',
    email: 'm.mueller@example.com',
    category: 'Unicorn',
    birthyear: 1982,
    visibility: 'no',
    discount:'no',
    team: 'Crazy runners'
  };

  const secureId = 'some_secure_id';
  const paymentToken = 'a token';

  const expectOnParticipantFields = function(participantFromDb, participantId) {
    expect(participantFromDb.id).toEqual(participantId);
    expect(participantFromDb.firstname).toEqual(aParticipant.firstname);
    expect(participantFromDb.lastname).toEqual(aParticipant.lastname);
    expect(participantFromDb.email).toEqual(aParticipant.email);
    expect(participantFromDb.category).toEqual(aParticipant.category);
    expect(participantFromDb.birthyear).toEqual(aParticipant.birthyear);
    expect(participantFromDb.visibility).toEqual(aParticipant.visibility);
    expect(participantFromDb.discount).toEqual(aParticipant.discount);
    expect(participantFromDb.team).toEqual(aParticipant.team);
    expect(participantFromDb.paymenttoken).toEqual(paymentToken);
    expect(participantFromDb.has_payed).toEqual(false);
    expect(participantFromDb.secureid).toEqual(secureId);
  };

  beforeEach((done) => {
    helper.changeOriginalTimeout();
    helper.setupDbConnection(done);
  });

  afterAll((done) => {
    helper.resetToOriginalTimeout();
    pg.end();
    done();
  });

  it('should store and read participants', (done) => {
    const randomToken = '1234567';

    participants.save(aParticipant, randomToken, secureId)
      .then(participants.getRegistered)
      .then(function (data) {
        expect(data.length).toBe(1);
        expect(data[0].firstname).toBe(aParticipant.firstname);
        expect(data[0].lastname).toBe(aParticipant.lastname);
        expect(data[0].email).toBe(aParticipant.email);
        expect(data[0].category).toBe(aParticipant.category);
        expect(data[0].birthyear).toBe(aParticipant.birthyear);
        expect(data[0].discount).toBe(aParticipant.discount);
        expect(data[0].team).toBe(aParticipant.team);
        done();
      })
      .fail(fail);
  });

  describe('save', () => {
    it('should return the id', (done) => {

      participants.save(aParticipant, paymentToken, secureId)
        .then(function (participantId) {
          expect(participantId).toBeDefined();
          done();
        })
        .fail(fail);
    });
  });

  describe('getById', () => {
    it('should return all information of the participant with given Id', (done) => {
      participants.save(aParticipant, paymentToken, secureId)
        .then(function (participantId) {
          participants.getById(participantId)
            .then(function (participant) {
              expectOnParticipantFields(participant, participantId);
              done();
            })
            .fail(fail);
        });
    });
  });

  describe('getByToken', () => {
    const aParticipantWithTshirt = {
      firstname: 'Hertha',
      lastname: 'Mustermann',
      email: 'h.mustermann@example.com',
      birthyear: 1980,
      tshirt: {
        size: 'XS',
        model: 'Crazy cool fit'
      }
    };

    it('should return participant\'s lastname and firstname and ordered tshirt for a given token', (done) => {
      participants.save(aParticipantWithTshirt, paymentToken)
        .then(function (participantId) {
          participants.addTShirt(aParticipantWithTshirt.tshirt, participantId)
            .then(() => {
              participants.getByToken(paymentToken)
                .then(function (participant) {
                  expect(participant.name).toEqual(aParticipantWithTshirt.lastname + ', ' + aParticipantWithTshirt.firstname);
                  expect(participant.tshirt.size).toEqual(aParticipantWithTshirt.tshirt.size);
                  expect(participant.tshirt.model).toEqual(aParticipantWithTshirt.tshirt.model);
                  done();
                })
                .fail(fail);
            });
        });
    });
  });

  describe('getBySecureId', () => {
    it('should return all information of the participant with given secureId', (done) => {
      participants.save(aParticipant, paymentToken, secureId)
        .then(function (participantId) {
          participants.getBySecureId(secureId)
            .then(function (participant) {
              expectOnParticipantFields(participant, participantId);
              done();
            })
            .fail(fail);
        });
    });
  });

  describe('confirmParticipant', () => {
    it('should mark the participant as payed and send a confirmation mail which includes the edit link', (done) => {
      spyOn(participants, 'markPayed').and.callThrough();
      spyOn(participants, 'sendEmail');

      participants.save(aParticipant, paymentToken, secureId)
        .then(function (participantId) {
          participants.confirmParticipant(participantId)
            .then(() => {
              expect(participants.markPayed).toHaveBeenCalledWith(participantId);

              expect(participants.sendEmail).toHaveBeenCalled();
              let partcipantsEmail = participants.sendEmail.calls.mostRecent().args[0];
              expect(partcipantsEmail).toBe(aParticipant.email);
              let subject = participants.sendEmail.calls.mostRecent().args[1];
              expect(subject).toBe('Lauf gegen Rechts: Zahlung erhalten');
              let content = participants.sendEmail.calls.mostRecent().args[2];
              expect(content).toMatch(aParticipant.firstname);
              expect(content).toMatch(/eingegangen/);
              expect(content).toMatch(secureId);

              done();
            })
            .fail(fail);
        });
    });

    it('should give error if ID is invalid', (done) => {
      let wrongId = '999';

      participants.save(aParticipant, paymentToken, secureId)
        .then(() => {
          participants.confirmParticipant(wrongId)
            .catch(() => {
              done();
            });
        });
    });
  });

  describe('delete', () => {
    it('should delete a user', (done) => {
      participants.save(aParticipant, paymentToken, secureId)
        .then((id) => {
            participants.delete(id).then(() => {
              done();
            });
        });
    });

    it('should delete users with tshirts', (done) => {
      const aParticipantWithTshirt = {
            firstname: 'Hertha',
            lastname: 'Mustermann',
            email: 'h.mustermann@example.com',
            birthyear: 1980,
            tshirt: {
              size: 'XS',
              model: 'Crazy cool fit'
            }
      };
      participants.save(aParticipantWithTshirt, paymentToken, secureId)
        .then((participantid) => {
            participants.delete(participantid).then(() => {
              done();
            })
            .fail(fail);
        });
    });

    it('should give error if accessing deleted user', (done) => {
      participants.save(aParticipant, paymentToken)
        .then((id) => {
            let participantid = id;
            participants.delete(participantid).then(() => {
              participants.getById(participantid).catch(() => {
                  done();
              });
            });
        });
    });
  });

  describe('registration', () => {
    it('should save the participant and send confirmation email', (done) => {
      spyOn(participants, 'save').and.callThrough();
      spyOn(participants, 'sendEmail');
      spyOn(participants, 'addTShirt');

      participants.register(aParticipant)
        .then((result) => {
          expect(participants.save).toHaveBeenCalled();
          let participant = participants.save.calls.mostRecent().args[0];
          expect(participant).toBe(aParticipant);
          let token = participants.save.calls.mostRecent().args[1];
          expect(token).toBe(result.token);
          let secureId = participants.save.calls.mostRecent().args[2];
          expect(secureId).not.toBeNull();

          expect(participants.sendEmail).toHaveBeenCalled();

          let participantsEmail = participants.sendEmail.calls.mostRecent().args[0];
          expect(participantsEmail).toBe(aParticipant.email);

          let subject = participants.sendEmail.calls.mostRecent().args[1];
          expect(subject).toBe('Lauf Gegen Rechts: Registrierung erfolgreich');

          let content = participants.sendEmail.calls.mostRecent().args[2];
          expect(content).toMatch(/Danke/);

          expect(participants.addTShirt).not.toHaveBeenCalled();
          done();
        })
        .fail(fail);
    });

    it('should call addTShirt if one ordered', (done) => {
      spyOn(participants, 'addTShirt');

      const aParticipantWithTshirt = {
        firstname: 'Hertha',
        lastname: 'Mustermann',
        email: 'h.mustermann@example.com',
        category: 'Unicorn',
        birthyear: 1980,
        team: 'Crazy runners',
        tshirt: {size: 'M', model: 'Slim fit'}
      };

      participants.register(aParticipantWithTshirt)
        .then(() => {
          expect(participants.addTShirt).toHaveBeenCalled();
          done();
        })
        .fail(fail);
    });
  });

  describe('addTShirt', () => {
    it('stores tshirt', (done) => {
      participants.save({
        firstname: 'Hertha',
        lastname: 'With TShirt',
        email: 'h.mustermann@example.com',
        category: 'Unicorn',
        birthyear: 1980,
        team: 'Crazy runners'
      }, 'tokenX').then(function (id) {
        participants.addTShirt({size: 'M', model: 'Skin fit'}, id)
          .then(() => {
            participants.getTShirtFor(id)
              .then(function (shirts) {
                expect(shirts.length).toBe(1);
                done();
              })
              .fail(fail);
          });
      });

    });
  });

  describe('update', () => {
    it('should return the full information for a participant with given Id', (done) => {
      participants.save(aParticipant, paymentToken, 'someSecureId')
        .then(function (id) {
          const updatedParticipant = {
            firstname: 'Hertha updated',
            lastname: 'Mustermann updated',
            email: 'h.mustermann@example.com updated',
            category: 'Unicorn updated',
            birthyear: 1981,
            team: 'Crazy runners updated'
          };
          participants.getById(id)
          .then((p) => {
            participants.update(updatedParticipant, p.secureid)
              .then(() => {
                participants.getById(id)
                  .then(function (participant) {
                    expect(participant.firstname).toBe('Hertha updated');
                    expect(participant.lastname).toBe('Mustermann updated');
                    expect(participant.email).toBe('h.mustermann@example.com updated');
                    expect(participant.category).toBe('Unicorn updated');
                    expect(participant.birthyear).toBe(1981);
                    expect(participant.team).toBe('Crazy runners updated');
                    done();
                  })
                  .fail(fail);
              });
          });
        });
    });
  });

  describe('getPubliclyVisible', () => {
    it('returns only participants which are confirmed and OK with being visible to the public', (done) => {
      participants.save(aParticipant, 'tokenXX')
        .then(participants.markPayed)
        .then(participants.getPubliclyVisible)
        .then(function (data) {
          expect(data.length).toBe(1);
          expect(data[0].firstname).toBe(aParticipant.firstname);
          expect(data[0].lastname).toBe(aParticipant.lastname);
          expect(data[0].email).toBe(aParticipant.email);
          expect(data[0].category).toBe(aParticipant.category);
          expect(data[0].birthyear).toBe(aParticipant.birthyear);
          expect(data[0].team).toBe(aParticipant.team);
          done();
        })
        .fail(fail);

    });
  });

  describe('bulkmail', () => {
    it('should send the correct email to every participant', (done) => {
      spyOn(participants, 'sendEmail');
      spyOn(participants, 'sendStatusEmail').and.callThrough();
      participants.save(aParticipant,'tokenXX')
        .then(participants.markPayed)
        .then(participants.save(aSecondParticipant,'tokenYY'))
        .then(participants.bulkmail)
        .then((result) => {
          expect(participants.sendEmail).toHaveBeenCalledTimes(2);
          expect(participants.sendStatusEmail).toHaveBeenCalledTimes(2);
          let content =       participants.sendEmail.calls.mostRecent().args[2];
          expect(content).toMatch(/Startnummer/);
          done();
        })
        .fail(fail);
    });
  });
})
;
<|endoftext|>


<commit_before>var Dashboard = React.createClass({

    render() {
        return(

BuildingProfile Viewer

        )
    }
});

React.render(
    <Dashboard />,
    document.getElementById('content')
);
<commit_msg>remove old file<commit_after><|endoftext|>