From cfd8ba19a5e76409251ad633fa378dac9ef74d3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tour=C3=A9=20Holder?= Date: Fri, 4 Sep 2020 15:09:40 -0300 Subject: [PATCH 1/6] chore: git ignore .vscode folder --- .gitignore | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 65fb93e..04b5734 100644 --- a/.gitignore +++ b/.gitignore @@ -111,4 +111,6 @@ dist # Stores VSCode versions used for testing VSCode extensions .vscode-test -# End of https://www.toptal.com/developers/gitignore/api/node \ No newline at end of file +# End of https://www.toptal.com/developers/gitignore/api/node + +.vscode/ \ No newline at end of file From e3d9699bd4313942cce769957ef8ae1590d28baf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tour=C3=A9=20Holder?= Date: Fri, 4 Sep 2020 15:10:44 -0300 Subject: [PATCH 2/6] build: update package-lock.json --- package-lock.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package-lock.json b/package-lock.json index 8b90deb..026274f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@wizsolucoes/syz-analyzer", - "version": "0.0.1", + "version": "1.0.0", "lockfileVersion": 1, "requires": true, "dependencies": { From edbc384b7f381ae0c512e01611d68a85803515c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tour=C3=A9=20Holder?= Date: Fri, 4 Sep 2020 15:11:09 -0300 Subject: [PATCH 3/6] docs: improve documentation --- README.md | 57 ++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 42 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index df37aaf..4836c6f 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,20 @@ + # SYZ Analyzer Ferramenta CLI para analisar adesão de uma aplicação ao design system SYZ. +- [Uso](#uso) +- [Desenvolvimento, por onde começar](#desenvolvimento-por-onde-começar) +- [Como funciona](#como-funciona) +- [Parâmetros](#parâmetros) + - [`--app`](#--app) + - [`--src`](#--src) + - [`--gateway`](#--gateway) + - [`--break-build`](#--break-build) + - [Exemplo completo](#exemplo-completo) +- [Variáveis de ambiente](#variáveis-de-ambiente) +- [OpenAPI Specification do serviço de componentes](#openapi-specification-do-serviço-de-componentes) + ## Uso ```bash # Install @@ -11,14 +24,26 @@ npm i -g @wizsolucoes/syz-analyzer syz-analyzer ``` +## Desenvolvimento, por onde começar +```bash +# Install +npm install + +# Run tests +npm test + +# Run +npm start +``` + ## Como funciona -A analizador segue os seguintes passos: +A analisador segue os seguintes passos: 1. Busca uma lista dos components do SYZ esperados para a aplicação sob análise, 2. Procura por tags html que correspondem aos componentes SYZ, 3. Publica a porcentagem dos components do SYZ esperados que foram encontrados para um repostório de dados, -4. Opcionalmente termina seu processo com código de erro se a porcentagem estiver abaixo de um treshold especificado, o que provocaria a quebra do build em um pipeline de CI. +4. Opcionalmente termina seu processo com código de erro se a porcentagem estiver abaixo de um threshold especificado, o que provocaria a quebra do build em um pipeline de CI. -## Options +## Parâmetros ### `--app` **(Required)** Nome do respositório da aplicação a ser analisada. @@ -27,21 +52,21 @@ $ syz-analyzer --app speed-web ``` ### `--src` -Caminho para a pasta do código fonte a ser analizado. Default: "src" +Caminho para a pasta do código fonte a ser analisado. **Default: "src"** ```sh $ syz-analyzer --src projects/speed-web/src ``` ### `--gateway` -Porcentagem dos components do SYZ esperados que devem ser encontrados nos arquivos html para evitar a quebra do build. Default: 100 +Porcentagem dos components do SYZ esperados que devem ser encontrados nos arquivos html para evitar a quebra do build. **Default: 100** ```sh $ syz-analyzer --gateway 70 ``` ### `--break-build` -Booleano que determina se o build de CI deve se quebrar quando o `gateway` de adesão ao SYZ não for atingido. Default: false +Booleano que determina se o build de CI deve se quebrar quando o `gateway` de adesão ao SYZ não for atingido. **Default: false** ```sh $ syz-analyzer --break-build @@ -65,18 +90,20 @@ Você deve prover a url base para o serviço que vá buscar a lista de component ## OpenAPI Specification do serviço de componentes + ### / - + #### POST + ##### Description -Get list of compomonents by repository name - +Get list of components by repository name + ##### Parameters | Name | Located in | Description | Required | Schema | | ---- | ---------- | ----------- | -------- | ---- | -| body | body | Object with name of repository | Yes | [compomonentsListRequest](#compomonentslistrequest) | +| body | body | Object with name of repository | Yes | [componentsListRequest](#componentslistrequest) | Example value ```json @@ -84,7 +111,7 @@ Example value "repository": "speed-web" } ``` - + ##### Responses | Code | Description | Schema | @@ -103,10 +130,10 @@ Example value ] ``` - + ### Models - -#### compomonentsListRequest + +#### componentsListRequest | Name | Type | Description | Required | | ---- | ---- | ----------- | -------- | @@ -118,7 +145,7 @@ Example value "repository": "speed-web" } ``` - + #### componentObj | Name | Type | Description | Required | From 0b170ce2b6bd8593729c1d75779f9214f87b35b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tour=C3=A9=20Holder?= Date: Fri, 4 Sep 2020 15:13:37 -0300 Subject: [PATCH 4/6] feat: only build breakder exits process with error code --- src/components-list-service.js | 4 ++-- src/syz-analysis-publisher.js | 2 +- src/syz-analyzer.js | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components-list-service.js b/src/components-list-service.js index fffa7d2..a27c539 100644 --- a/src/components-list-service.js +++ b/src/components-list-service.js @@ -7,7 +7,7 @@ var exports = module.exports; exports.fetch = async function (appId) { if (!baseUrl) { console.log('ERROR: Component service base url not provided. Aborting analysis.'); - process.exit(1); + process.exit(); } try { @@ -20,7 +20,7 @@ exports.fetch = async function (appId) { return response.data.map(extractComponentName); } catch (error) { console.error('ERROR:', error); - process.exit(1); + process.exit(); } } diff --git a/src/syz-analysis-publisher.js b/src/syz-analysis-publisher.js index 8a8d039..b6ca10d 100644 --- a/src/syz-analysis-publisher.js +++ b/src/syz-analysis-publisher.js @@ -66,7 +66,7 @@ function onAnalysisEntityInserted(error, result, response) { function handleError(error) { if (error) { - process.exit(1) + process.exit() } } diff --git a/src/syz-analyzer.js b/src/syz-analyzer.js index 53f83d4..f261e3d 100644 --- a/src/syz-analyzer.js +++ b/src/syz-analyzer.js @@ -102,6 +102,6 @@ function onResultsPublished() { function abortIfNoName(appName) { if (!appName) { console.log('ERROR: No app name provided. Aborting analysis.'); - process.exit(1); + process.exit(); } } From 9261a2f7ccbf22a444abb937ad8f4dac362c54bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tour=C3=A9=20Holder?= Date: Fri, 4 Sep 2020 18:53:30 -0300 Subject: [PATCH 5/6] feat: publish components found and not found --- src/syz-analysis-publisher.js | 18 +++++++++++++++--- src/syz-analyzer.js | 18 +++++++++++++++--- 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/src/syz-analysis-publisher.js b/src/syz-analysis-publisher.js index b6ca10d..49f3ec6 100644 --- a/src/syz-analysis-publisher.js +++ b/src/syz-analysis-publisher.js @@ -9,13 +9,23 @@ var tableSvc; var appId; var analysisValue; var callerCallBack; +var componentsFoundList; +var componentsNotFoundList; var exports = module.exports; -exports.publish = function(appName, value, callBack) { +exports.publish = function ( + appName, + value, + componentsFound, + componentsNotFound, + callBack +) { appId = appName; analysisValue = value; - callerCallBack = callBack + callerCallBack = callBack; + componentsFoundList = componentsFound; + componentsNotFoundList = componentsNotFound; if (!areAzureStorageParamsValid()) { callBack(); @@ -52,7 +62,9 @@ function onAppEntityInserted(error, result, response) { var analysisEntity = { PartitionKey: entGen.String(appId), RowKey: entGen.String(`${new Date().getTime()}`), - value: entGen.Double(analysisValue) + value: entGen.Double(analysisValue), + componentsFound: entGen.String(componentsFoundList.toString()), + componentsNotFound: entGen.String(componentsNotFoundList.toString()), }; tableSvc.insertOrMergeEntity(tableName, analysisEntity, onAnalysisEntityInserted); diff --git a/src/syz-analyzer.js b/src/syz-analyzer.js index f261e3d..77e747c 100644 --- a/src/syz-analyzer.js +++ b/src/syz-analyzer.js @@ -16,8 +16,15 @@ exports.runAnalysis = async function (appName, expectedCoverage, breakBuild, src printHeader(); const expectedComponents = await fetchExpectedComponentsList(appName); - const coverage = await calculateCoverage(expectedComponents, srcPath); - publisher.publish(appName, coverage, onResultsPublished); + const { coverage, componentsFound, componentsNotFound } = await calculateCoverage(expectedComponents, srcPath); + + publisher.publish( + appName, + coverage, + componentsFound, + componentsNotFound, + onResultsPublished + ); } function printHeader() { @@ -88,7 +95,12 @@ async function calculateCoverage(expectedComponents, srcPath) { coverage = ((compareResult.found.length / expectedComponents.length) * 100).toFixed(2) console.log('INFO: SYZ Coverage:', coverage); - return coverage; + + return { + coverage, + componentsFound: compareResult.found, + componentsNotFound: compareResult.notFound, + }; } function onResultsPublished() { From c8ea62f611de8bf740d23151a62ab57a6e352805 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tour=C3=A9=20Holder?= Date: Fri, 4 Sep 2020 18:54:37 -0300 Subject: [PATCH 6/6] chore: bump version - 1.1.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9726f4d..bbcfdd6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@wizsolucoes/syz-analyzer", - "version": "1.0.0", + "version": "1.1.0", "description": "", "main": "index.js", "bin": {