Last active
July 18, 2022 10:25
-
-
Save mihkeleidast/bfc00676ace81de370d4c120cabb48af to your computer and use it in GitHub Desktop.
common-ui analytics
This file contains hidden or 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
const { execSync } = require('child_process'); | |
const scanComponents = require('./scan-components'); | |
const scanMetadata = require('./scan-metadata'); | |
const currentDirectory = __dirname; | |
const repositories = [ | |
{ | |
name: 'customer-web', | |
rootPath: '/packages/customer-web/' | |
}, | |
{ | |
name: 'login-web', | |
rootPath: '/' | |
}, | |
]; | |
const currentTime = new Date(); | |
for (const project of repositories) { | |
const { name, rootPath } = project; | |
process.chdir(`./${name}`); | |
const sha = execSync('git rev-parse HEAD').toString().replace('\n', ''); | |
const time = currentTime.valueOf(); | |
scanMetadata({ sha, time, project, rootPath }); | |
scanComponents({ time, project, rootPath }) | |
process.chdir(currentDirectory); | |
} |
This file contains hidden or 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
const path = require('path'); | |
module.exports = { | |
crawlFrom: path.join(__dirname, `./${process.env.scanProjectPath}src`), | |
includeSubComponents: true, | |
importedFrom: '@sixfold/common-ui', | |
processors: [['raw-report', { outputTo: `./historic_data/${process.env.scanProject}/${process.env.scanTime}/report.json` }]], | |
}; |
This file contains hidden or 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
const { execSync } = require('child_process'); | |
module.exports = ({ time, project, rootPath }) => { | |
process.env.scanTime = time; | |
process.env.scanProject = project; | |
process.env.scanProjectPath = project + rootPath; | |
execSync('npx react-scanner -c ../react-scanner.config.js', {stdio: 'inherit'}); | |
} |
This file contains hidden or 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
const { writeFileSync, mkdirSync } = require('fs'); | |
const path = require('path'); | |
const importFresh = require('import-fresh'); | |
const scan = ({ sha, time, project, rootPath }) => { | |
const { dependencies, name } = importFresh(`./${project}${rootPath}package.json`); | |
const result = { | |
dirName: process.cwd(), | |
repository: name, | |
version: dependencies['@sixfold/common-ui'], | |
commitSha: sha, | |
commitTime: time, | |
}; | |
mkdirSync(path.join(__dirname, `historic_data/${project}/${time}/`), { recursive: true }, (err) => { | |
if (err) throw err; | |
}); | |
writeFileSync(path.join(__dirname, `historic_data/${project}/${time}/metadata.json`), JSON.stringify(result, null, 2)); | |
} | |
module.exports = scan; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment