Skip to content

Commit

Permalink
Merge branch 'release/v0.9.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelBinpar committed May 27, 2020
2 parents 8076211 + 4f4c433 commit 5439d4a
Show file tree
Hide file tree
Showing 30 changed files with 65 additions and 304 deletions.
2 changes: 1 addition & 1 deletion index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import path from 'path';
import chokidar from 'chokidar';
import { ensureDir } from '@a2r/fs';

import { targetPath, proxyPath } from './settings';
import initWatchers from './utils/initWatchers';
import { ensureDir } from './tools/fs';
import { isJest } from './tools/isJest';

/**
Expand Down
16 changes: 12 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "watcher",
"version": "0.8.0",
"version": "0.9.0",
"description": "API and model watcher",
"engines": {
"node": ">=12"
Expand Down Expand Up @@ -38,11 +38,11 @@
"license": "ISC",
"homepage": "https://a2r.com/",
"dependencies": {
"@a2r/fs": "^1.1.4",
"@a2r/telemetry": "^1.0.30",
"chalk": "^4.0.0",
"chokidar": "^3.4.0",
"rimraf": "^3.0.2",
"snyk": "^1.328.0",
"snyk": "^1.329.0",
"socket.io": "^2.3.0",
"typescript": "^3.9.3",
"winston": "^3.2.1",
Expand Down
2 changes: 1 addition & 1 deletion test/tests/api/apiProxy.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import path from 'path';
import waitForExpect from 'wait-for-expect';
import { emptyFolder, exists } from '@a2r/fs';

import { build } from '../../../utils/apiProxy';
import { emptyFolder, exists } from '../../../tools/fs';

const apiSourcePath = path.resolve(__dirname, '../../mocks/server/module-info/api');
const proxyTargetPath = path.resolve(__dirname, '../../mocks/.a2r/api-proxy/api');
Expand Down
2 changes: 1 addition & 1 deletion test/tests/api/isClientContent.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import path from 'path';
import { readFile } from '@a2r/fs';

import { readFile } from '../../../tools/fs';
import getIsClientContent from '../../../utils/getIsClientContent';

const isClientPath = path.resolve(__dirname, '../../../tools/isClient.ts');
Expand Down
2 changes: 1 addition & 1 deletion test/tests/api/modelImports.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import path from 'path';
import waitForExpect from 'wait-for-expect';
import { emptyFolder, exists } from '@a2r/fs';

import { build } from '../../../utils/apiProxy';
import { emptyFolder, exists } from '../../../tools/fs';

const apiSourcePath = path.resolve(__dirname, '../../mocks/server/model-imports/api');
const proxyTargetPath = path.resolve(__dirname, '../../mocks/.a2r/model-imports/api');
Expand Down
30 changes: 0 additions & 30 deletions test/tests/fs/copyContents.ts

This file was deleted.

16 changes: 0 additions & 16 deletions test/tests/fs/emptyFolder.ts

This file was deleted.

22 changes: 0 additions & 22 deletions test/tests/fs/ensureDir.ts

This file was deleted.

17 changes: 0 additions & 17 deletions test/tests/fs/getFilesRecursively.ts

This file was deleted.

2 changes: 1 addition & 1 deletion test/tests/ts/getExportsIdentifiersFromNodes.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import ts from 'typescript';
import path from 'path';
import { readFile } from '@a2r/fs';

import getExportsIdentifiersFromNodes from '../../../utils/getExportsIdentifiersFromNodes';
import { readFile } from '../../../tools/fs';

const modelSourcePath = path.resolve(__dirname, '../../mocks/server/model-imports/model');

Expand Down
2 changes: 1 addition & 1 deletion test/tests/ts/getFunctionDocContainer.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import ts from 'typescript';
import path from 'path';
import { readFile } from '@a2r/fs';

import { readFile } from '../../../tools/fs';
import getMainMethodName from '../../../utils/getMainMethodName';
import getMainMethodNode from '../../../utils/getMainMethodNode';
import getFunctionDocContainer from '../../../utils/getFunctionDocContainer';
Expand Down
2 changes: 1 addition & 1 deletion test/tests/ts/getFunctionName.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import ts from 'typescript';
import path from 'path';
import { readFile } from '@a2r/fs';

import { readFile } from '../../../tools/fs';
import getMainMethodName from '../../../utils/getMainMethodName';
import getMainMethodNode from '../../../utils/getMainMethodNode';
import getFunctionName from '../../../utils/getFunctionName';
Expand Down
2 changes: 1 addition & 1 deletion test/tests/ts/getFunctionReturnTypeInfo.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import ts from 'typescript';
import path from 'path';
import { readFile } from '@a2r/fs';

import getFunctionReturnTypeInfo from '../../../utils/getFunctionReturnTypeInfo';
import getMainMethodName from '../../../utils/getMainMethodName';
import getMainMethodNode from '../../../utils/getMainMethodNode';
import { readFile } from '../../../tools/fs';

const filePath = path.resolve(__dirname, '../../mocks/server/no-return/no-return.ts');

Expand Down
2 changes: 1 addition & 1 deletion test/tests/ts/getMainMethodName.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import ts from 'typescript';
import path from 'path';
import { readFile } from '@a2r/fs';

import { readFile } from '../../../tools/fs';
import getMainMethodName from '../../../utils/getMainMethodName';

const apiPath = path.resolve(__dirname, '../../mocks/server/api');
Expand Down
2 changes: 1 addition & 1 deletion test/tests/ts/getMainMethodNode.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import ts from 'typescript';
import path from 'path';
import { readFile } from '@a2r/fs';

import { readFile } from '../../../tools/fs';
import getMainMethodNode from '../../../utils/getMainMethodNode';

const apiPath = path.resolve(__dirname, '../../mocks/server/api');
Expand Down
36 changes: 20 additions & 16 deletions test/tests/ts/getModelImports.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import ts from 'typescript';
import path from 'path';
import { readFile, getFilesRecursively } from '@a2r/fs';

import { readFile, getFilesRecursively } from '../../../tools/fs';
import getModelImports from '../../../utils/getModelImports';
import getGroupedModelImports from '../../../utils/getGroupedModelImports';
import { ModelImport } from '../../../model/api';
Expand Down Expand Up @@ -34,23 +34,27 @@ test('Get model imports', async (): Promise<void> => {
test('Group model imports from same path', async (): Promise<void> => {
const apiPath = path.resolve(mainPath, 'api');
const files = await getFilesRecursively(apiPath, ['.ts']);
const fileImports = await Promise.all(files.map(async (filePath): Promise<ModelImport[]> => {
const content = await readFile(filePath, 'utf8');
const sourceFile = ts.createSourceFile(
filePath,
content,
ts.ScriptTarget.Latest,
false,
ts.ScriptKind.TS,
);

const children = sourceFile.getChildren(sourceFile);

return getModelImports(children, sourceFile);
}));
const fileImports: ModelImport[][] = await Promise.all(
files.map(
async (filePath): Promise<ModelImport[]> => {
const content = await readFile(filePath, 'utf8');
const sourceFile = ts.createSourceFile(
filePath,
content,
ts.ScriptTarget.Latest,
false,
ts.ScriptKind.TS,
);

const children = sourceFile.getChildren(sourceFile);

return getModelImports(children, sourceFile);
},
),
);

const imports = fileImports.reduce((t, i) => [...t, ...i], []);
expect(imports.length).toBe(5);
const groupedImports = getGroupedModelImports(imports);
expect(groupedImports.length).toBe(3);
});
});
2 changes: 1 addition & 1 deletion test/tests/validations/stressValidator.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import path from 'path';
import waitForExpect from 'wait-for-expect';
import { mkDir, emptyFolder, exists, writeFile } from '@a2r/fs';

import { WatcherOptions, OnReady } from '../../../model/watcher';

import onError from '../../../utils/onError';
import Validator from '../../../utils/runtimeValidator';
import watchFolder from '../../../utils/watchFolder';
import fileValidation from '../../../utils/modelFileValidation';
import { mkDir, emptyFolder, exists, writeFile } from '../../../tools/fs';

const serverPath = path.resolve(
__dirname,
Expand Down
15 changes: 7 additions & 8 deletions test/tests/validations/validator.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
import path from 'path';
import waitForExpect from 'wait-for-expect';

import { WatcherOptions, OnReady } from '../../../model/watcher';

import onError from '../../../utils/onError';
import Validator from '../../../utils/runtimeValidator';
import watchFolder from '../../../utils/watchFolder';
import fileValidation from '../../../utils/modelFileValidation';
import {
mkDir,
emptyFolder,
exists,
writeFile,
unlink,
rmDir,
} from '../../../tools/fs';
} from '@a2r/fs';

import { WatcherOptions, OnReady } from '../../../model/watcher';

import onError from '../../../utils/onError';
import Validator from '../../../utils/runtimeValidator';
import watchFolder from '../../../utils/watchFolder';
import fileValidation from '../../../utils/modelFileValidation';
const serverPath = path.resolve(__dirname, '../../mocks/server/validator');

beforeAll(async () => {
Expand Down
2 changes: 1 addition & 1 deletion test/tests/watcher/initWatchers.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import path from 'path';
import waitForExpect from 'wait-for-expect';
import { emptyFolder, ensureDir, writeFile, exists } from '@a2r/fs';

import { apiPath, modelPath, proxyPath } from '../../../settings';
import { emptyFolder, ensureDir, writeFile, exists } from '../../../tools/fs';
import initWatchers from '../../../utils/initWatchers';
import { setForceDisableJestDetection } from '../../../tools/isJest';

Expand Down
2 changes: 1 addition & 1 deletion test/tests/watcher/watchFolder.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import path from 'path';
import chokidar from 'chokidar';
import { emptyFolder } from '@a2r/fs';

import { Omit } from '../../../@types';
import { emptyFolder } from '../../../tools/fs';
import onError from '../../../utils/onError';
import watchFolder from '../../../utils/watchFolder';
import { WatcherOptions } from '../../../model/watcher';
Expand Down
Loading

0 comments on commit 5439d4a

Please sign in to comment.