Skip to content

Commit

Permalink
Merge pull request #27 from Himenon/fix-some-bugs
Browse files Browse the repository at this point in the history
fix: some dependency not parsed error
  • Loading branch information
Himenon authored Jan 7, 2020
2 parents d08df06 + 41f5c9c commit b45284d
Show file tree
Hide file tree
Showing 15 changed files with 56 additions and 60 deletions.
4 changes: 2 additions & 2 deletions .lintstagedrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"*.{js,jsx,json,yml,yaml,html,md}": ["prettier --write", "git add"],
"*.{js,jsx,json,yml,yaml,html}": ["prettier --write", "git add"],
"*.{ts,tsx}": ["yarn run format", "yarn run lint", "git add"],
"package.json": ["sort-package-json", "git add"]
}
}
5 changes: 1 addition & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,11 @@ All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

<a name="0.3.2"></a>

## 0.3.2 (2020-01-07)

**Note:** Version bump only for package code-dependency





<a name="0.3.1"></a>

## [0.3.1](https://github.com/Himenon/code-dependency/compare/v0.3.0...v0.3.1) (2020-01-06)
Expand Down
8 changes: 2 additions & 6 deletions lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,10 @@
"publish": {
"access": "public",
"allowBranch": "master",
"ignoreChanges": [
"CHANGELOG.md"
]
"ignoreChanges": ["CHANGELOG.md"]
}
},
"packages": [
"packages/*"
],
"packages": ["packages/*"],
"version": "0.3.2",
"npmClient": "yarn",
"registry": "https://registry.npmjs.org/",
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
"initialize": "run-s bootstrap clean:all setup build:lib",
"lint": "eslint -c ./.eslintrc.js 'packages/**/*.{ts,tsx}'",
"lint:fix": "yarn lint --fix",
"publish": "lerna publish from-package",
"test": "lerna run test",
"version_up": "lerna version --yes"
},
Expand Down
5 changes: 1 addition & 4 deletions packages/cli/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,11 @@ All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

<a name="0.3.2"></a>

## 0.3.2 (2020-01-07)

**Note:** Version bump only for package @code-dependency/cli





<a name="0.3.1"></a>

## [0.3.1](https://github.com/Himenon/code-dependency/packages/cli/compare/v0.3.0...v0.3.1) (2020-01-06)
Expand Down
3 changes: 1 addition & 2 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
},
"dependencies": {
"@code-dependency/view": "^0.3.2",
"chalk": "^3.0.0",
"commander": "4.0.1",
"compression": "^1.7.4",
"cors": "^2.8.5",
Expand All @@ -57,7 +56,7 @@
"react-router-dom": "^5.1.2",
"recursive-readdir": "^2.2.2",
"resolve-pkg": "^2.0.0",
"viz.js": "^2.1.2"
"tsconfig": "^7.0.0"
},
"devDependencies": {
"@types/compression": "^1.0.1",
Expand Down
20 changes: 13 additions & 7 deletions packages/cli/src/controller/ApiController.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import express from "express";
import * as path from "path";
import * as Service from "../service";
import * as Config from "../config";
import * as Service from "../service";
import { logger } from "../logger";
import { Api } from "@code-dependency/view";

export const createApiResponse = <T>(data: T): Api.ApiResponse<T> => {
Expand All @@ -18,12 +19,17 @@ export const create = (service: Service.Type, config: Config.Type) => {

router.post("/graph", async (req, res) => {
const filename = path.join(config.absoluteRootDirPath, req.body.path);
const dot = service.dependencyCruiser.getDependenciesDot(filename);
const data = createApiResponse<Api.GraphResponseData>({
element: dot,
});
res.json(data);
res.end();
try {
const dot = service.dependencyCruiser.getDependenciesDot(filename);
const data = createApiResponse<Api.GraphResponseData>({
element: dot,
});
res.json(data);
} catch (error) {
res.status(500).send(error.message);
logger.error(error);
res.end();
}
});

router.use("/paths", async (req, res) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const main = async () => {
const server = createServer(service, config);

logger.info(`Start: http://localhost:${args.port}`);
server.listen(3000);
server.listen(args.port);
};

main().catch(error => {
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/service/DependencyCruiserService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export interface Option {
export const create = (option: Option) => {
const getDependenciesDot = (source: string): string => {
logger.info(`cruise: ${source}`);
const dependencies = cruise([source], { exclude: "node_modules", maxDepth: 99, combinedDependencies: true }, undefined, option.tsConfig);
const dependencies = cruise([source], { tsPreCompilationDeps: true }, undefined, option.tsConfig);
if (typeof dependencies.output !== "string") {
return format(dependencies.output, "dot").output.toString();
}
Expand Down
18 changes: 0 additions & 18 deletions packages/cli/src/service/VizJsService.ts

This file was deleted.

5 changes: 2 additions & 3 deletions packages/cli/src/service/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as DependencyCruiserService from "./DependencyCruiserService";
import * as VizJsService from "./VizJsService";
import * as fs from "fs";
import * as tsconfig from "tsconfig";

type GetPromiseValue<T> = T extends Promise<infer R> ? R : T;

Expand All @@ -9,10 +9,9 @@ export interface Option {
}

export const create = async (option: Option) => {
const tsConfig = option.tsconfigFilePath && JSON.parse(fs.readFileSync(option.tsconfigFilePath, { encoding: "utf-8" }));
const tsConfig = option.tsconfigFilePath && tsconfig.readFileSync(option.tsconfigFilePath);
return {
dependencyCruiser: DependencyCruiserService.create({ tsConfig }),
viz: VizJsService.create(),
};
};

Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/view/IndexView/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export interface Props {
export const create = async ({ url, serverUrl, context, service, filePathList }: Props) => {
const client = ApiClient.create(serverUrl, true);
const state: ServerSideRenderingProps["state"] = {
graphvizSource: await service.viz.renderToString("digraph { hello -> world }"),
graphvizSource: "select from left source file.",
filePathList,
};
const props: ServerSideRenderingProps = {
Expand Down
5 changes: 1 addition & 4 deletions packages/view/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,11 @@ All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

<a name="0.3.2"></a>

## 0.3.2 (2020-01-07)

**Note:** Version bump only for package @code-dependency/view





<a name="0.3.1"></a>

## [0.3.1](https://github.com/Himenon/code-dependency/compare/v0.3.0...v0.3.1) (2020-01-06)
Expand Down
12 changes: 8 additions & 4 deletions packages/view/src/container/FileTree/Store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,14 @@ export const generateFolderTree = (filePathObjectList: FilePathObject[], updateK

export const generateStore = (domainStores: Domain.Graphviz.Stores, { client, createSvgString }: InjectionMethod) => {
const onClick = async (nextSource: string) => {
const res = await client.getGraph({ path: nextSource });
if (res) {
const graph = await createSvgString(res.data.element);
domainStores.graphviz.dispatch({ type: "UPDATE_SELECTED_FILE_PATH", filePath: nextSource, graphvizSource: graph });
try {
const res = await client.getGraph({ path: nextSource });
if (res) {
const graph = await createSvgString(res.data.element);
domainStores.graphviz.dispatch({ type: "UPDATE_SELECTED_FILE_PATH", filePath: nextSource, graphvizSource: graph });
}
} catch (error) {
console.error(error);
}
};
const rootDirectory = generateFolderTree(domainStores.graphviz.state.filePathList, onClick);
Expand Down
24 changes: 22 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2189,6 +2189,16 @@
resolved "https://registry.yarnpkg.com/@types/stack-utils/-/stack-utils-1.0.1.tgz#0a851d3bd96498fa25c33ab7278ed3bd65f06c3e"
integrity sha512-l42BggppR6zLmpfU6fq9HEa2oGPEI8yrSPL3GITjfRInppYFahObbIQOQK3UGxEnyQpltZLaPe75046NOZQikw==

"@types/strip-bom@^3.0.0":
version "3.0.0"
resolved "https://registry.yarnpkg.com/@types/strip-bom/-/strip-bom-3.0.0.tgz#14a8ec3956c2e81edb7520790aecf21c290aebd2"
integrity sha1-FKjsOVbC6B7bdSB5CuzyHCkK69I=

"@types/[email protected]":
version "0.0.30"
resolved "https://registry.yarnpkg.com/@types/strip-json-comments/-/strip-json-comments-0.0.30.tgz#9aa30c04db212a9a0649d6ae6fd50accc40748a1"
integrity sha512-7NQmHra/JILCd1QqpSzl8+mJRc8ZHz3uDm8YV1Ks9IhK0epEiTw8aIErbvH9PI+6XbqhyIQy3462nEsn7UVzjQ==

"@types/tapable@*":
version "1.0.4"
resolved "https://registry.yarnpkg.com/@types/tapable/-/tapable-1.0.4.tgz#b4ffc7dc97b498c969b360a41eee247f82616370"
Expand Down Expand Up @@ -3525,7 +3535,7 @@ [email protected], chalk@^2.0.0, chalk@^2.0.1, chalk@^2.1.0, chalk@^2.3.0, chalk@^2.3.
escape-string-regexp "^1.0.5"
supports-color "^5.3.0"

[email protected], chalk@^3.0.0:
[email protected]:
version "3.0.0"
resolved "https://registry.yarnpkg.com/chalk/-/chalk-3.0.0.tgz#3f73c2bf526591f574cc492c51e2456349f844e4"
integrity sha512-4D3B6Wf41KOYRFdszmDqMCGq5VV/uMAB273JILmO+3jAlh8X4qDtdtgCR3fxtbLEMzSx22QdhnDcJvu2u1fVwg==
Expand Down Expand Up @@ -11953,7 +11963,7 @@ [email protected], strip-json-comments@^3.0.1:
resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-3.0.1.tgz#85713975a91fb87bf1b305cca77395e40d2a64a7"
integrity sha512-VTyMAUfdm047mwKl+u79WIdrZxtFtn+nBxHeb844XBQ9uMNTuTHdx2hc5RiAJYqwTj3wc/xe5HLSdJSkJ+WfZw==

strip-json-comments@~2.0.1:
strip-json-comments@^2.0.0, strip-json-comments@~2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-2.0.1.tgz#3c531942e908c2697c0ec344858c286c7ca0a60a"
integrity sha1-PFMZQukIwml8DsNEhYwobHygpgo=
Expand Down Expand Up @@ -12408,6 +12418,16 @@ tsconfig-paths@^3.4.0:
minimist "^1.2.0"
strip-bom "^3.0.0"

tsconfig@^7.0.0:
version "7.0.0"
resolved "https://registry.yarnpkg.com/tsconfig/-/tsconfig-7.0.0.tgz#84538875a4dc216e5c4a5432b3a4dec3d54e91b7"
integrity sha512-vZXmzPrL+EmC4T/4rVlT2jNVMWCi/O4DIiSj3UHg1OE5kCKbk4mfrXc6dZksLgRM/TZlKnousKH9bbTazUWRRw==
dependencies:
"@types/strip-bom" "^3.0.0"
"@types/strip-json-comments" "0.0.30"
strip-bom "^3.0.0"
strip-json-comments "^2.0.0"

tslib@^1.8.1, tslib@^1.9.0:
version "1.10.0"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.10.0.tgz#c3c19f95973fb0a62973fb09d90d961ee43e5c8a"
Expand Down

0 comments on commit b45284d

Please sign in to comment.