Skip to content

Commit a80df63

Browse files
committed
Merge branch 'release/v0.4.0'
2 parents 330c0f8 + 50ca673 commit a80df63

File tree

14 files changed

+33
-39
lines changed

14 files changed

+33
-39
lines changed

.eslintignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
node_modules
22
next-env.d.ts
33
jest.config.js
4-
dist/
4+
bin/

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,7 @@ typings/
6262
.env
6363

6464
# next.js build output
65-
.next
65+
.next
66+
67+
# A2R generated content
68+
.a2r

Dockerfile

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,10 @@
11
FROM node:12-alpine
22
WORKDIR /usr/src/app
3-
LABEL Description="A2R API Watcher"
4-
# Production packages install
3+
LABEL Description="A2R Watcher"
54
COPY ["package.json", "package-lock.json*", "npm-shrinkwrap.json*", "./"]
65
RUN npm install --production --silent
7-
# Copy the source code and build the solution
86
COPY . ./src
9-
RUN cd ./src;npm install --silent;npm run build
10-
# Copy de compiled version
11-
RUN cp -r ./src/bin ./bin
12-
# Remove the sources
13-
RUN rm -rf ./src
14-
# Enviroment por production
7+
RUN rm -rf ./src/server
8+
VOLUME ["/usr/src/app/src/server"]
159
ENV NODE_ENV production
16-
# Vulumes for mapping
17-
VOLUME ["/usr/src/app/bin/server"]
18-
# Start command
19-
CMD npm start
10+
CMD cd ./src;npm install --silent;npm run build;cp -r ./bin ../bin;cd ..;rm -rf ./src;npm start

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
# A2R API Watcher
1+
# A2R Watcher
22

33
[![Build Status](https://travis-ci.org/acttoreact/api-watcher.svg?branch=master)](https://travis-ci.org/acttoreact/api-watcher) [![Coverage Status](https://coveralls.io/repos/github/acttoreact/api-watcher/badge.svg?branch=master)](https://coveralls.io/github/acttoreact/api-watcher) [![Snyk Vulnerabilities for GitHub Repo](https://img.shields.io/snyk/vulnerabilities/github/acttoreact/api-watcher)](https://snyk.io/test/github/acttoreact/api-watcher) [![Docker Image Version (latest by date)](https://img.shields.io/docker/v/act2react/api-watcher?sort=date)](https://hub.docker.com/r/act2react/api-watcher) [![Docker Image Size (latest by date)](https://img.shields.io/docker/image-size/act2react/api-watcher?sort=date)](https://hub.docker.com/r/act2react/api-watcher) [![GitHub](https://img.shields.io/github/license/acttoreact/api-watcher)](https://github.com/acttoreact/api-watcher/blob/develop/license.md) [![Documentation](https://img.shields.io/badge/documentation-ready-green)](https://htmlpreview.github.io/?https://github.com/acttoreact/api-watcher/blob/develop/docs/jsdocs/index.html#readDir)
44

5-
A2R Framework API Watcher
5+
A2R Framework API and model watcher

index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ export const start = async (): Promise<chokidar.FSWatcher[]> =>
9090
export const restart = start;
9191

9292
/**
93-
* Inits API Watcher by ensuring destination path and running start process
93+
* Inits watchers by ensuring destination path and running start process
9494
*/
9595
const init = async (): Promise<void> => {
9696
await ensureDir(proxyDestPath);

jest.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ module.exports = {
99
collectCoverageFrom: [
1010
"**/*.{ts,tsx}",
1111
"!**/node_modules/**",
12-
"!**/dist/**",
12+
"!**/bin/**",
1313
"!**/test/mocks/**"
1414
],
1515
coverageReporters: ['text', 'lcov', 'json', 'html'],

jsdoc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"source": {
33
"include": ["./"],
44
"includePattern": "\\.(jsx|js|ts|tsx)$",
5-
"excludePattern": "(dist|tests|tmp|node_modules)"
5+
"excludePattern": "(bin|tests|tmp|node_modules)"
66
},
77
"plugins": [
88
"plugins/markdown",

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
{
22
"name": "watcher",
3-
"version": "0.3.0",
3+
"version": "0.4.0",
44
"description": "API and model watcher",
55
"engines": {
66
"node": ">=12"
77
},
88
"scripts": {
99
"build": "tsc",
1010
"dev": "NODE_ENV=development ts-node-dev --debug --respawn --transpileOnly ./index.ts",
11-
"docker-build": "IMAGE=$npm_package_name:latest;docker build --rm --pull -f \"./Dockerfile\" -t $IMAGE \".\"",
12-
"docker-start": "IMAGE=$npm_package_name:latest;docker run -it -v $INIT_CWD/server:/usr/src/app/server $IMAGE",
13-
"docker-start-from-hub": "IMAGE=act2react/watcher:version-$npm_package_version;docker run -it -v $INIT_CWD/server:/usr/src/app/server $IMAGE",
11+
"docker-build": "npm run build;IMAGE=$npm_package_name:latest;docker build --rm --pull -f \"./Dockerfile\" -t $IMAGE \".\"",
12+
"docker-start": "IMAGE=$npm_package_name:latest;docker run -it -d -v $INIT_CWD/server:/usr/src/app/server $IMAGE",
13+
"docker-start-from-hub": "IMAGE=act2react/watcher:version-$npm_package_version;docker run -it -d -v $INIT_CWD/server:/usr/src/app/server $IMAGE",
1414
"start": "node ./bin/index.js",
1515
"lint": "npx eslint --config ./.eslintrc ./**/*.ts",
1616
"test": "jest",
17-
"test-clear": "rm -rf coverage;rm -rf dist",
17+
"test-clear": "rm -rf coverage;rm -rf bin",
1818
"test-dev": "NODE_ENV=development npx jest --watch",
1919
"test-coverage": "jest --coverage",
2020
"test-coverage-dev": "NODE_ENV=development jest --coverage --watchAll",
@@ -54,7 +54,7 @@
5454
"@types/rimraf": "^3.0.0",
5555
"@typescript-eslint/eslint-plugin": "^2.33.0",
5656
"@typescript-eslint/parser": "^2.33.0",
57-
"babel-jest": "^25.4.0",
57+
"babel-jest": "^25.5.1",
5858
"better-docs": "^2.0.1",
5959
"coveralls": "^3.0.11",
6060
"eslint": "^7.0.0",
@@ -63,7 +63,7 @@
6363
"eslint-plugin-import": "^2.18.2",
6464
"eslint-plugin-jsx-a11y": "^6.2.3",
6565
"eslint-plugin-react": "^7.20.0",
66-
"jest": "^25.4.0",
66+
"jest": "^25.5.1",
6767
"jsdoc": "^3.6.3",
6868
"ts-jest": "^25.5.1",
6969
"ts-node-dev": "^1.0.0-pre.40",

test/mocks/.a2r/model-imports/api/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,19 +57,19 @@ const methodWrapper = (method: string, ...args: any[]): Promise<any> => {
5757
* Gets data from server
5858
* @returns {Promise<model.Data>}
5959
*/
60-
const getData = (data: Data2, blas: Blas): Promise<Data> => methodWrapper('modelImports2', data, blas);
60+
const getData = (data: Data2, blas: Blas): Promise<Data> => methodWrapper('model-imports-2', data, blas);
6161

6262
/**
6363
* Gets data from server
6464
* @returns {Promise<model.Data>}
6565
*/
66-
const getData2 = (): Promise<Data3> => methodWrapper('modelImports3');
66+
const getData2 = (): Promise<Data3> => methodWrapper('model-imports-3');
6767

6868
/**
6969
* Gets data from server
7070
* @returns {Promise<model.Data>}
7171
*/
72-
const getData3 = (data: Data2, juan: Juan): Promise<Data> => methodWrapper('modelImports', data, juan);
72+
const getData3 = (data: Data2, juan: Juan): Promise<Data> => methodWrapper('model-imports', data, juan);
7373

7474
const api = {
7575
modelImports2: getData,

test/tests/ts/getExportsIdentifiersFromNodes.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ test('Get exports identifiers', async (): Promise<void> => {
1212
const sourceFile = ts.createSourceFile(filePath, content, ts.ScriptTarget.Latest, true);
1313
const fileNodes = sourceFile.getChildren();
1414
const identifiers = getExportsIdentifiersFromNodes(fileNodes);
15-
console.log(identifiers);
1615
expect(identifiers.length).toBe(1);
1716
expect(identifiers).toContain('Data');
1817
});

test/tests/validations/stressValidator.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const writeSeveralFiles = async (
2323
nFiles = 5,
2424
): Promise<void> => {
2525
const files = new Array(nFiles)
26-
.fill(null)
26+
.fill(true)
2727
.map((_val, i) => path.resolve(filePath, `file-${i}.ts`));
2828
await Promise.all(files.map(file => writeFile(file, '// test file')));
2929
};

utils/getModuleInfo.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import path from 'path';
44
import { ModuleInfo } from '../model/api';
55

66
import { readFile } from '../tools/fs';
7-
import cleanText from '../tools/cleanText';
87
import getMainMethodName from './getMainMethodName';
98
import getMainMethodNode from './getMainMethodNode';
109
import getFunctionDocContainer from './getFunctionDocContainer';
@@ -39,8 +38,7 @@ const getModuleInfo = async (filePath: string, apiSourcePath: string): Promise<M
3938
const keys = path
4039
.relative(apiSourcePath, filePath)
4140
.replace(/\.ts$/, '')
42-
.split(path.sep)
43-
.map(s => cleanText(s, false, true, true, true, '-'));
41+
.split(path.sep);
4442
return {
4543
mainMethodDocs,
4644
mainMethodName,

utils/updateApiObject.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { ApiNamespace } from '../model/api';
22

3+
import cleanText from '../tools/cleanText';
4+
35
const updateApiObject = (
46
structure: ApiNamespace,
57
keys: string[],
@@ -9,17 +11,18 @@ const updateApiObject = (
911
const lastIndex = keys.length - 1;
1012
return keys.reduce(
1113
(t: ApiNamespace, key: string, i: number): ApiNamespace => {
14+
const cleanKey = cleanText(key, false, true, true, true, '-');
1215
if (i === lastIndex) {
1316
t.methods.push({
14-
key,
17+
key: cleanKey,
1518
methodName,
1619
});
1720
return newApiObject;
1821
}
19-
let namespace = t.namespaces.find((n): boolean => n.key === key);
22+
let namespace = t.namespaces.find((n): boolean => n.key === cleanKey);
2023
if (!namespace) {
2124
namespace = {
22-
key,
25+
key: cleanKey,
2326
namespaces: [],
2427
methods: [],
2528
};

0 commit comments

Comments
 (0)