@relative-ci/agent
Advanced tools
Comparing version 1.0.0-2 to 1.0.0
module.exports = { | ||
'extends': 'airbnb-base', | ||
'rules': { | ||
extends: 'airbnb-base', | ||
globals: { | ||
describe: true, | ||
it: true | ||
}, | ||
rules: { | ||
'no-console': 'off' | ||
} | ||
}; |
@@ -45,3 +45,3 @@ #!/usr/bin/env node | ||
default: envs.build, | ||
} | ||
}, | ||
}) | ||
@@ -48,0 +48,0 @@ .help().argv; |
@@ -1,8 +0,62 @@ | ||
const read = require('./read'); | ||
const fs = require('fs-extra'); | ||
const { get, omit, set } = require('lodash'); | ||
const { debug } = require('./utils'); | ||
const { extractWebpackStats } = require('./extract'); | ||
const send = require('./send'); | ||
module.exports = ({ config, params }) => { | ||
const data = read(config); | ||
const WEBPACK_STATS = 'webpack.stats'; | ||
return send(data, params); | ||
const SOURCE_EXTRACTORS = { | ||
[WEBPACK_STATS]: extractWebpackStats, | ||
}; | ||
const getConfiguredArtifacts = config => Object.keys(SOURCE_EXTRACTORS) | ||
.map((key) => { | ||
const artifactConfig = get(config, key); | ||
if (!artifactConfig) { | ||
return null; | ||
} | ||
if (typeof artifactConfig === 'object') { | ||
return { | ||
key, | ||
filepath: artifactConfig.filepath, | ||
options: omit(artifactConfig, 'filepath'), | ||
}; | ||
} | ||
return { | ||
key, | ||
filepath: artifactConfig, | ||
}; | ||
}) | ||
.filter(item => item); | ||
const getDataFromArtifacts = async artifacts => Promise.all( | ||
artifacts.map(async ({ key, filepath, options }) => { | ||
debug('Read artifact', filepath); | ||
const data = await fs.readJSON(filepath); | ||
return { | ||
key, | ||
data, | ||
options, | ||
}; | ||
}), | ||
); | ||
const getFilteredData = artifactsData => artifactsData.reduce( | ||
(agg, { key, data, options }) => set(agg, key, SOURCE_EXTRACTORS[key](data, options)), | ||
{}, | ||
); | ||
module.exports = async ({ config, params }) => { | ||
const artifacts = getConfiguredArtifacts(config); | ||
const artifactsData = await getDataFromArtifacts(artifacts); | ||
const filteredData = getFilteredData(artifactsData); | ||
return send(filteredData, params); | ||
}; |
{ | ||
"name": "@relative-ci/agent", | ||
"version": "1.0.0-2", | ||
"version": "1.0.0", | ||
"description": "Relative CI agent", | ||
@@ -12,3 +12,3 @@ "repository": "relative-ci/agent", | ||
"lint": "eslint lib", | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
"test": "mocha test/extract/*.js" | ||
}, | ||
@@ -29,3 +29,4 @@ "keywords": [], | ||
"eslint-config-airbnb-base": "^13.1.0", | ||
"eslint-plugin-import": "^2.14.0" | ||
"eslint-plugin-import": "^2.14.0", | ||
"mocha": "^5.2.0" | ||
}, | ||
@@ -32,0 +33,0 @@ "dependencies": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
0
0
8
8200
4
225
3
33