Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Rewrite report.js to a react component
- Loading branch information
Showing
18 changed files
with
11,201 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
env: | ||
browser: true | ||
commonjs: true | ||
node: true | ||
extends: | ||
- 'eslint:recommended' | ||
- 'plugin:react/recommended' | ||
globals: | ||
Atomics: readonly | ||
SharedArrayBuffer: readonly | ||
parserOptions: | ||
ecmaFeatures: | ||
jsx: true | ||
ecmaVersion: 2018 | ||
sourceType: module | ||
plugins: | ||
- react | ||
rules: {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
node_modules | ||
.DS_Store | ||
target/ | ||
node/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* Copy from https://github.com/SonarSource/sonar-custom-plugin-example/blob/7.x/conf/env.js | ||
* | ||
* Copyright (C) 2017-2017 SonarSource SA | ||
* All rights reserved | ||
* mailto:info AT sonarsource DOT com | ||
*/ | ||
// Grab NODE_ENV and REACT_APP_* environment variables and prepare them to be | ||
// injected into the application via DefinePlugin in Webpack configuration. | ||
|
||
const REACT_APP = /^REACT_APP_/i; | ||
|
||
function getClientEnvironment() { | ||
return Object.keys(process.env).filter(key => REACT_APP.test(key)).reduce((env, key) => { | ||
env['process.env.' + key] = JSON.stringify(process.env[key]); | ||
return env; | ||
}, { | ||
// Useful for determining whether we’re running in production mode. | ||
// Most importantly, it switches React into the correct mode. | ||
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'development') | ||
}); | ||
} | ||
|
||
module.exports = getClientEnvironment; |
23 changes: 23 additions & 0 deletions
23
sonar-dependency-check-plugin/conf/webpack/webpack.config.dev.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* | ||
* Copy from https://github.com/SonarSource/sonar-custom-plugin-example/blob/7.x/conf/webpack/webpack.config.dev.js | ||
* | ||
* Copyright (C) 2017-2017 SonarSource SA | ||
* All rights reserved | ||
* mailto:info AT sonarsource DOT com | ||
*/ | ||
const webpack = require("webpack"); | ||
const config = require("./webpack.config"); | ||
|
||
config.devtool = "eval"; | ||
|
||
config.output.publicPath = "/static/dependencycheck/"; | ||
|
||
config.output.pathinfo = true; | ||
|
||
Object.keys(config.entry).forEach((key) => { | ||
config.entry[key].unshift(require.resolve("react-dev-utils/webpackHotDevClient")); | ||
}); | ||
|
||
config.plugins = [new webpack.HotModuleReplacementPlugin()]; | ||
|
||
module.exports = config; |
70 changes: 70 additions & 0 deletions
70
sonar-dependency-check-plugin/conf/webpack/webpack.config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/* | ||
* Copy from https://github.com/SonarSource/sonar-custom-plugin-example/blob/7.x/conf/webpack/webpack.config.js | ||
* | ||
* Copyright (C) 2017-2017 SonarSource SA | ||
* All rights reserved | ||
* mailto:info AT sonarsource DOT com | ||
*/ | ||
const path = require("path"); | ||
const autoprefixer = require("autoprefixer"); | ||
|
||
module.exports = { | ||
// Define the entry points here. They MUST have the same name as the page_id | ||
// defined in src/main/java/org/sonarsource/plugins/example/web/MyPluginPageDefinition.java | ||
entry: { | ||
// Using React: | ||
report_page: ["./src/main/js/report_page/index.js"], | ||
}, | ||
output: { | ||
// The entry point files MUST be shipped inside the final JAR's static/ | ||
// directory. | ||
path: path.join(__dirname, "../../target/classes/static"), | ||
filename: "[name].js" | ||
}, | ||
resolve: { | ||
root: path.join(__dirname, "src/main/js") | ||
}, | ||
externals: { | ||
// React 16.8 ships with SonarQube, and should be re-used to avoid | ||
// collisions at runtime. | ||
react: "React", | ||
"react-dom": "ReactDOM", | ||
// Register the Sonar* globals as packages, to simplify importing. | ||
// See src/main/js/common/api.js for more information on what is exposed | ||
// in SonarRequest. | ||
"sonar-request": "SonarRequest", | ||
// TODO: provide an example | ||
"sonar-measures": "SonarMeasures", | ||
// See src/main/js/portfolio_page/components/MeasuresHistory.js for some | ||
// examples using React components from SonarQube. | ||
"sonar-components": "SonarComponents" | ||
}, | ||
module: { | ||
// Our example uses Babel to transpile our code. | ||
loaders: [ | ||
{ | ||
test: /\.js$/, | ||
loader: "babel", | ||
exclude: /(node_modules)/ | ||
}, | ||
{ | ||
test: /\.css/, | ||
loader: "style-loader!css-loader!postcss-loader" | ||
}, | ||
{ test: /\.json$/, loader: "json" } | ||
] | ||
}, | ||
postcss() { | ||
return [ | ||
autoprefixer({ | ||
browsers: [ | ||
"last 3 Chrome versions", | ||
"last 3 Firefox versions", | ||
"last 3 Safari versions", | ||
"last 3 Edge versions", | ||
"IE 11" | ||
] | ||
}) | ||
]; | ||
} | ||
}; |
58 changes: 58 additions & 0 deletions
58
sonar-dependency-check-plugin/conf/webpack/webpack.config.prod.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* | ||
* Copy from https://github.com/SonarSource/sonar-custom-plugin-example/blob/7.x/conf/webpack/webpack.config.prod.js | ||
* | ||
* Copyright (C) 2017-2017 SonarSource SA | ||
* All rights reserved | ||
* mailto:info AT sonarsource DOT com | ||
*/ | ||
const webpack = require('webpack'); | ||
const config = require('./webpack.config'); | ||
const getClientEnvironment = require('../env'); | ||
|
||
// Get environment variables to inject into our app. | ||
const env = getClientEnvironment(); | ||
|
||
// Assert this just to be safe. | ||
// Development builds of React are slow and not intended for production. | ||
if (env['process.env.NODE_ENV'] !== '"production"') { | ||
throw new Error('Production builds must have NODE_ENV=production.'); | ||
} | ||
|
||
const noUglify = process.argv.some(arg => arg.indexOf('--no-uglify') > -1); | ||
|
||
// Don't attempt to continue if there are any errors. | ||
config.bail = true; | ||
|
||
config.plugins = [ | ||
// Makes some environment variables available to the JS code, for example: | ||
// if (process.env.NODE_ENV === 'production') { ... }. See `./env.js`. | ||
// It is absolutely essential that NODE_ENV was set to production here. | ||
// Otherwise React will be compiled in the very slow development mode. | ||
new webpack.DefinePlugin(env), | ||
|
||
// This helps ensure the builds are consistent if source hasn't changed: | ||
new webpack.optimize.OccurrenceOrderPlugin(), | ||
|
||
// Try to dedupe duplicated modules, if any: | ||
new webpack.optimize.DedupePlugin() | ||
]; | ||
|
||
if (!noUglify) { | ||
config.plugins.push( | ||
new webpack.optimize.UglifyJsPlugin({ | ||
compress: { | ||
screw_ie8: true, // React doesn't support IE8 | ||
warnings: false | ||
}, | ||
mangle: { | ||
screw_ie8: true | ||
}, | ||
output: { | ||
comments: false, | ||
screw_ie8: true | ||
} | ||
}) | ||
); | ||
} | ||
|
||
module.exports = config; |
Oops, something went wrong.