Commit efae1f8f authored by Mike Greiling's avatar Mike Greiling

Merge branch 'feature/add-jh-vue-components-entry' into 'master'

Add JH vue components entry

See merge request gitlab-org/gitlab!68772
parents fc277ecd a1d952b8
......@@ -37,6 +37,7 @@ import initBroadcastNotifications from './broadcast_notification';
import { initTopNav } from './nav';
import 'ee_else_ce/main_ee';
import 'jh_else_ce/main_jh';
applyGitLabUIConfig();
......
// This is an empty file to satisfy jh_else_ce import for the JH main entry point
......@@ -161,6 +161,9 @@ const alias = {
// the following resolves files which are different between CE and EE
ee_else_ce: path.join(ROOT_PATH, 'app/assets/javascripts'),
// the following resolves files which are different between CE and JH
jh_else_ce: path.join(ROOT_PATH, 'app/assets/javascripts'),
// override loader path for icons.svg so we do not duplicate this asset
'@gitlab/svgs/dist/icons.svg': path.join(
ROOT_PATH,
......@@ -184,10 +187,13 @@ if (IS_EE) {
if (IS_JH) {
Object.assign(alias, {
jh: path.join(ROOT_PATH, 'jh/app/assets/javascripts'),
jh_component: path.join(ROOT_PATH, 'jh/app/assets/javascripts'),
jh_empty_states: path.join(ROOT_PATH, 'jh/app/views/shared/empty_states'),
jh_icons: path.join(ROOT_PATH, 'jh/app/views/shared/icons'),
jh_images: path.join(ROOT_PATH, 'jh/app/assets/images'),
jh_spec: path.join(ROOT_PATH, 'jh/spec/javascripts'),
jh_jest: path.join(ROOT_PATH, 'jh/spec/frontend'),
jh_else_ce: path.join(ROOT_PATH, 'jh/app/assets/javascripts'),
});
}
......@@ -523,6 +529,15 @@ module.exports = {
);
}),
!IS_JH &&
new webpack.NormalModuleReplacementPlugin(/^jh_component\/(.*)\.vue/, (resource) => {
// eslint-disable-next-line no-param-reassign
resource.request = path.join(
ROOT_PATH,
'app/assets/javascripts/vue_shared/components/empty_component.js',
);
}),
new CopyWebpackPlugin({
patterns: [
{
......@@ -638,10 +653,12 @@ module.exports = {
}),
new webpack.DefinePlugin({
// This one is used to define window.gon.ee and other things properly in tests:
// These are used to define window.gon.ee, window.gon.jh and other things properly in tests:
'process.env.IS_EE': JSON.stringify(IS_EE),
// This one is used to check against "EE" properly in application code
'process.env.IS_JH': JSON.stringify(IS_JH),
// These are used to check against "EE" properly in application code
IS_EE: IS_EE ? 'window.gon && window.gon.ee' : JSON.stringify(false),
IS_JH: IS_JH ? 'window.gon && window.gon.jh' : JSON.stringify(false),
// This is used by Sourcegraph because these assets are loaded dnamically
'process.env.SOURCEGRAPH_PUBLIC_PATH': JSON.stringify(SOURCEGRAPH_PUBLIC_PATH),
}),
......
const IS_EE = require('./config/helpers/is_ee_env');
const isESLint = require('./config/helpers/is_eslint');
const IS_JH = require('./config/helpers/is_jh_env');
module.exports = (path, options = {}) => {
const {
moduleNameMapper: extModuleNameMapper = {},
moduleNameMapperEE: extModuleNameMapperEE = {},
moduleNameMapperJH: extModuleNameMapperJH = {},
} = options;
const reporters = ['default'];
......@@ -29,6 +31,9 @@ module.exports = (path, options = {}) => {
testMatch.push(`<rootDir>/ee/${glob}`);
}
if (IS_JH) {
testMatch.push(`<rootDir>/jh/${glob}`);
}
// workaround for eslint-import-resolver-jest only resolving in test files
// see https://github.com/JoinColony/eslint-import-resolver-jest#note
if (isESLint(module)) {
......@@ -41,8 +46,11 @@ module.exports = (path, options = {}) => {
'^~(/.*)$': '<rootDir>/app/assets/javascripts$1',
'^ee_component(/.*)$':
'<rootDir>/app/assets/javascripts/vue_shared/components/empty_component.js',
'^jh_component(/.*)$':
'<rootDir>/app/assets/javascripts/vue_shared/components/empty_component.js',
'^shared_queries(/.*)$': '<rootDir>/app/graphql/queries$1',
'^ee_else_ce(/.*)$': '<rootDir>/app/assets/javascripts$1',
'^jh_else_ce(/.*)$': '<rootDir>/app/assets/javascripts$1',
'^helpers(/.*)$': '<rootDir>/spec/frontend/__helpers__$1',
'^vendor(/.*)$': '<rootDir>/vendor/assets/javascripts$1',
[TEST_FIXTURES_PATTERN]: '<rootDir>/tmp/tests/frontend/fixtures$1',
......@@ -70,6 +78,19 @@ module.exports = (path, options = {}) => {
collectCoverageFrom.push(rootDirEE.replace('$1', '/**/*.{js,vue}'));
}
if (IS_JH) {
const rootDirJH = '<rootDir>/jh/app/assets/javascripts$1';
Object.assign(moduleNameMapper, {
'^jh(/.*)$': rootDirJH,
'^jh_component(/.*)$': rootDirJH,
'^jh_else_ce(/.*)$': rootDirJH,
'^jh_jest/(.*)$': '<rootDir>/jh/spec/frontend/$1',
...extModuleNameMapperJH,
});
collectCoverageFrom.push(rootDirJH.replace('$1', '/**/*.{js,vue}'));
}
const coverageDirectory = () => {
if (process.env.CI_NODE_INDEX && process.env.CI_NODE_TOTAL) {
return `<rootDir>/coverage-frontend/jest-${process.env.CI_NODE_INDEX}-${process.env.CI_NODE_TOTAL}`;
......@@ -107,6 +128,7 @@ module.exports = (path, options = {}) => {
testEnvironment: '<rootDir>/spec/frontend/environment.js',
testEnvironmentOptions: {
IS_EE,
IS_JH,
},
};
};
......@@ -8,9 +8,13 @@ module.exports = {
moduleNameMapper: {
'^test_helpers(/.*)$': '<rootDir>/spec/frontend_integration/test_helpers$1',
'^ee_else_ce_test_helpers(/.*)$': '<rootDir>/spec/frontend_integration/test_helpers$1',
'^jh_else_ce_test_helpers(/.*)$': '<rootDir>/spec/frontend_integration/test_helpers$1',
},
moduleNameMapperEE: {
'^ee_else_ce_test_helpers(/.*)$': '<rootDir>/ee/spec/frontend_integration/test_helpers$1',
},
moduleNameMapperJH: {
'^jh_else_ce_test_helpers(/.*)$': '<rootDir>/jh/spec/frontend_integration/test_helpers$1',
},
}),
};
......@@ -37,6 +37,7 @@ module Gitlab
gon.first_day_of_week = current_user&.first_day_of_week || Gitlab::CurrentSettings.first_day_of_week
gon.time_display_relative = true
gon.ee = Gitlab.ee?
gon.jh = Gitlab.jh?
gon.dot_com = Gitlab.com?
if current_user
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment