Compare commits
78 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
31ca6f4a78 | ||
|
|
1f9bc3a2d3 | ||
|
|
aad81bedbd | ||
|
|
1158c5fc1d | ||
|
|
a9727b990d | ||
|
|
a9f94a2cfa | ||
|
|
eb0b9bfc40 | ||
|
|
b4e1a99add | ||
|
|
c21d3ff504 | ||
|
|
2957d95133 | ||
|
|
d6ce727b0c | ||
|
|
c18c9fadd1 | ||
|
|
dce33716d9 | ||
|
|
cf8ba61943 | ||
|
|
26383aa79d | ||
|
|
136bd77d5f | ||
|
|
ba6620f040 | ||
|
|
4a8e7b7dc8 | ||
|
|
6ca48eb537 | ||
|
|
2864a098ab | ||
|
|
fec0cceba6 | ||
|
|
3bf39ce1b0 | ||
|
|
3a047b5bbe | ||
|
|
50145d4d1a | ||
|
|
4df2e8a48b | ||
|
|
3dae451776 | ||
|
|
4d038f37b3 | ||
|
|
a09ef4df65 | ||
|
|
628862d024 | ||
|
|
af83be1fcc | ||
|
|
05cb5527e3 | ||
|
|
7d910a0f75 | ||
|
|
ab74f6426e | ||
|
|
390bb8ff67 | ||
|
|
fcd108f9e7 | ||
|
|
dd2c6ee3d2 | ||
|
|
9917425cc8 | ||
|
|
3f54ca11a1 | ||
|
|
e059f800d6 | ||
|
|
f2dec10c05 | ||
|
|
d8117eac7d | ||
|
|
354514818c | ||
|
|
4ac814be93 | ||
|
|
2f7387a67f | ||
|
|
1cf779c5a6 | ||
|
|
64c9a75d92 | ||
|
|
5a8c4e6a9b | ||
|
|
2fd728b5e8 | ||
|
|
9bda1672d5 | ||
|
|
101eade38f | ||
|
|
6a1c8bcd75 | ||
|
|
c49a09e721 | ||
|
|
d526ded04b | ||
|
|
06344bee72 | ||
|
|
f9f67ff9ea | ||
|
|
9e519166d5 | ||
|
|
1b649bbe96 | ||
|
|
9ed305c08b | ||
|
|
dfebfa20a2 | ||
|
|
564c81362e | ||
|
|
d938ea3ef1 | ||
|
|
beceb476d9 | ||
|
|
ca882e4568 | ||
|
|
227c626c3a | ||
|
|
c3606e3c3e | ||
|
|
ae9ffccf65 | ||
|
|
897dcb8c3b | ||
|
|
38e1fdeeda | ||
|
|
c94e587675 | ||
|
|
5354dad9fe | ||
|
|
cbbab432e4 | ||
|
|
e21ab82729 | ||
|
|
987a98732a | ||
|
|
3ddfda80ed | ||
|
|
3e5da523ce | ||
|
|
6f6625d3db | ||
|
|
e9b4331d60 | ||
|
|
b7e5b70df7 |
@@ -1,4 +1,5 @@
|
|||||||
.idea
|
.idea
|
||||||
example-project
|
example-project
|
||||||
docs
|
docs
|
||||||
src/public/js
|
src/public/js
|
||||||
|
build
|
||||||
|
|||||||
11
Dockerfile
Normal file
11
Dockerfile
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
FROM node:14-slim
|
||||||
|
|
||||||
|
WORKDIR /usr/src/codecrumbs
|
||||||
|
|
||||||
|
COPY package*.json ./
|
||||||
|
|
||||||
|
RUN yarn install
|
||||||
|
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
EXPOSE 2018 3018
|
||||||
68
README.md
68
README.md
@@ -18,17 +18,28 @@
|
|||||||
<a href="#support">Support</a>
|
<a href="#support">Support</a>
|
||||||
</h3>
|
</h3>
|
||||||
|
|
||||||
## What
|
**Have you ever got lost in a big or unknown codebase?** This tool will help you to solve that. Also, it will increase your development speed and give more knowledge about your application architecture.
|
||||||
> **Have you ever got lost in a big or unknown codebase?** This tool will help you to solve that. Also, it will increase your development speed and give more knowledge about your application architecture.
|
> If you like this project, follow me on Twitter [@bliashenko](https://twitter.com/bliashenko) to hear about things I am building.
|
||||||
>
|
|
||||||
|
## Codecrumbs v2
|
||||||
|
Check out new version of this project as [standalone application](https://codecrumbs.io). Just in a few clicks you can start exploring a codebase in more efficient way, create interactive visual guides and share them with others on your own blog! See [quick guide here](https://codecrumbs.io/guides/web-app-with-github/).
|
||||||
|
|
||||||
|
<p align="center">
|
||||||
|
<a href="https://codecrumbs.io" target="_blank">
|
||||||
|
<img src="https://codecrumbs.io/external/img/common/app-ui-1.png" />
|
||||||
|
</a>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
|
||||||
|
## Demo
|
||||||
|
Check out prepared example for [**standalone version running here**](https://codecrumbs.io/app).
|
||||||
|
|
||||||
|
## Codecrumbs v1
|
||||||
|
|
||||||
>**How it works?** You run `codecrumbs` command for a codebase, it analyzes source code and builds its visual representation. Write down a codecrumb-comment and codebase state will be reflected by visual client in browser on the fly.
|
>**How it works?** You run `codecrumbs` command for a codebase, it analyzes source code and builds its visual representation. Write down a codecrumb-comment and codebase state will be reflected by visual client in browser on the fly.
|
||||||
>
|
>
|
||||||
> Check out [my talk at React-Finland](https://www.youtube.com/watch?v=S_1-1jzLxm4) for more details.
|
> Check out [my talk at React-Finland](https://www.youtube.com/watch?v=S_1-1jzLxm4) for more details.
|
||||||
>
|
|
||||||
>-[@bliashenko](https://twitter.com/bliashenko)
|
|
||||||
|
|
||||||
## Demo
|
|
||||||
Check out the example of [**standalone version running here**](https://codecrumbs.io/#showcase=todo-react-redux).
|
|
||||||
|
|
||||||
<img src="/docs/main-ui-3.png" width="100%"/>
|
<img src="/docs/main-ui-3.png" width="100%"/>
|
||||||
|
|
||||||
@@ -40,15 +51,18 @@ Check out the example of [**standalone version running here**](https://codecrumb
|
|||||||
2) Run ```codecrumbs -d project-src-dir -e project-src-dir/index.js```. Change parameters to match your project:```-d``` is *directory with source code*, ```-e``` is *entry point file* .
|
2) Run ```codecrumbs -d project-src-dir -e project-src-dir/index.js```. Change parameters to match your project:```-d``` is *directory with source code*, ```-e``` is *entry point file* .
|
||||||
3) Go to [http://localhost:2018](http://localhost:2018/#) in the browser to check it out.
|
3) Go to [http://localhost:2018](http://localhost:2018/#) in the browser to check it out.
|
||||||
|
|
||||||
### CLI
|
### Configuration
|
||||||
Parameter | Description | Example
|
Run codecrumbs with CLI params or specify static config file `codecrumbs.config.js` (see example [here](/example-project/codecrumbs.config.js))
|
||||||
--- | --- | ---
|
|
||||||
```-d```, ```--dir``` | Relative path to project source code directory | ```-d src```
|
CLI | Config file | Description | Example
|
||||||
```-e```, ```--entry``` | Relative path to project source entry point file (must be inside ```dir```) | ```-e src/app.js```
|
--- | --- | --- | ---
|
||||||
```-x```, ```--excludeDir``` | Relative path(or paths separated by ```,```) to directories for exclusion | ```-x src/doc,src/thirdparty```
|
```d``` | ```projectDir``` | Relative path to project source code directory | ```-d src```
|
||||||
```-i```, ```--ideCmd``` | command to open file in IDE from bash (default 'webstorm') | ```-i code```
|
```e``` | ```entryPoint``` | Relative path to project source entry point file (must be inside ```dir```) | ```-e src/app.js```
|
||||||
```-p```, ```--port``` | Port for Codecrumbs client (optional, default *2018*) | ```-p 2019```
|
```x``` | ```excludeDir``` | Relative path(or paths separated by ```,```) to directories for exclusion | ```-x src/doc,src/thirdparty```
|
||||||
```-n```, ```--projectName``` | Project name alias (optional, default same as ```-d``` value) | ```-n my-hello-world```
|
```p``` | ```clientPort``` | Port for Codecrumbs client (optional, default *2018*) | ```-p 2019```
|
||||||
|
```n``` | ```projectNameAlias``` | Project name alias (optional, default same as ```-d``` value) | ```-n my-hello-world```
|
||||||
|
```C``` | - | Path to codecrumbs.config.js (optional, by default will try to find the file in PWD) | ```-C config/codecrumbs.config.js```
|
||||||
|
```D``` | ```debugModeEnabled``` | Enable debug mode for logs (optional, default is ```false```) | ```-D```
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
### Breadcrumbs and trails
|
### Breadcrumbs and trails
|
||||||
@@ -76,6 +90,8 @@ Example | Description | Use case
|
|||||||
|
|
||||||
> Note: current version supports single line comments only.
|
> Note: current version supports single line comments only.
|
||||||
|
|
||||||
|
> Hint: you can use trail id without step number (e.g. ```//cc:groupname#;test```) just to group breadcrumbs, you always can add step numbers later when you know the correct order.
|
||||||
|
|
||||||
### Multi-codebase integration
|
### Multi-codebase integration
|
||||||
You might be interested to study connections between several codebases (sub-modules), codecrumbs supports that.
|
You might be interested to study connections between several codebases (sub-modules), codecrumbs supports that.
|
||||||
Simply start codecrumbs multiple times (once for each codebase), it all **will be synced in one picture** inside the browser tab. To control a diagram UI - select it by clicking on it.
|
Simply start codecrumbs multiple times (once for each codebase), it all **will be synced in one picture** inside the browser tab. To control a diagram UI - select it by clicking on it.
|
||||||
@@ -102,12 +118,6 @@ Current version supports next programming languages:
|
|||||||
|
|
||||||
Please file an issue to support other language you would like to have.
|
Please file an issue to support other language you would like to have.
|
||||||
|
|
||||||
### Download & Upload (learn and share your knowledge)
|
|
||||||
|
|
||||||
You can take a snapshot of application state at any point of time and share it with others. Simply download the json file of codecrumbs store (*top-right corner, "setup -> download"*). This json file can be then uploaded to codecrumbs (*top-right corner, "setup -> upload"*) to represent exactly same picture, even without having that project locally!
|
|
||||||
|
|
||||||
<img src="/docs/upload-feature-2.gif" width="100%"/>
|
|
||||||
|
|
||||||
### Dependencies
|
### Dependencies
|
||||||
> Note: In current version only [JavaScript, TypeScript] offer this feature
|
> Note: In current version only [JavaScript, TypeScript] offer this feature
|
||||||
|
|
||||||
@@ -125,18 +135,6 @@ UI explained:
|
|||||||
|
|
||||||
[js2flowchart](https://github.com/Bogdan-Lyashenko/js-code-to-svg-flowchart) is used in the sidebar to draw flowchart for the selected file code.
|
[js2flowchart](https://github.com/Bogdan-Lyashenko/js-code-to-svg-flowchart) is used in the sidebar to draw flowchart for the selected file code.
|
||||||
|
|
||||||
### IDE integration
|
|
||||||
> Check ```-i``` CLI param first to configure command.
|
|
||||||
|
|
||||||
Navigate from browser to your code editor simply by clicking ```Command+click```(or ```Alt+click```) on a file or a codecrumb to open file in your IDE.
|
|
||||||
|
|
||||||
<img src="/docs/ide-integration.gif" width="100%"/>
|
|
||||||
|
|
||||||
## Case studies
|
|
||||||
The tool (codecrumbs) allows us to learn, document and explain a codebase much faster. Also, with *Download & Upload* feature it becomes super easy to collect and share your "investigation results".
|
|
||||||
|
|
||||||
The ultimate goal is to have many case studies hosting at [https://codecrumbs.io](https://codecrumbs.io/). **The library of projects "explained with codecrumbs", the place for collaborative learning**. More features around that coming soon, stay tuned.
|
|
||||||
|
|
||||||
## Support
|
## Support
|
||||||
Any support is very much appreciated! 👍 😘 ❤️
|
Any support is very much appreciated! 👍 😘 ❤️
|
||||||
If you like this project, please, **put a :star: and tweet about it**. Thanks!
|
If you like this project, please, **put a :star: and tweet about it**. Thanks!
|
||||||
@@ -168,6 +166,4 @@ yarn && yarn start
|
|||||||
|
|
||||||
## WIP
|
## WIP
|
||||||
Next features are developing:
|
Next features are developing:
|
||||||
- **eject codecrumbs** - ability to remove all "breadcrumbs" from source code in "one click"
|
|
||||||
- **data transferring between cc trail steps**
|
|
||||||
- **VS Code extension** - some neat features right inside the code editor. Checkout [the repo here](https://github.com/Bogdan-Lyashenko/vs-code-codecrumbs).
|
- **VS Code extension** - some neat features right inside the code editor. Checkout [the repo here](https://github.com/Bogdan-Lyashenko/vs-code-codecrumbs).
|
||||||
|
|||||||
@@ -1,12 +1,17 @@
|
|||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
|
|
||||||
|
const path = require('path');
|
||||||
const program = require('commander');
|
const program = require('commander');
|
||||||
const colors = require('colors');
|
const colors = require('colors');
|
||||||
|
const _ = require('lodash');
|
||||||
|
|
||||||
|
const showUpdatesInfo = require('./updatesInfo');
|
||||||
const server = require('../src/server');
|
const server = require('../src/server');
|
||||||
|
|
||||||
|
showUpdatesInfo();
|
||||||
|
|
||||||
program
|
program
|
||||||
.option('-e, --entry [entryFile]', 'Specify path to entry point file. E.g. `src/app.js`')
|
.option('-e, --entry [entryPoint]', 'Specify path to entry point file. E.g. `src/app.js`')
|
||||||
.option('-d, --dir [projectDir]', 'Specify path to project source code directory. E.g. `src`', '')
|
.option('-d, --dir [projectDir]', 'Specify path to project source code directory. E.g. `src`', '')
|
||||||
.option(
|
.option(
|
||||||
'-w, --webpack [webpackConfigFile]',
|
'-w, --webpack [webpackConfigFile]',
|
||||||
@@ -20,27 +25,33 @@ program
|
|||||||
.option('-i, --ideCmd [ideCmd]', 'IDE command to open file')
|
.option('-i, --ideCmd [ideCmd]', 'IDE command to open file')
|
||||||
.option('-x, --excludeDir [excludeDirectories]', 'Exclude directories')
|
.option('-x, --excludeDir [excludeDirectories]', 'Exclude directories')
|
||||||
.option('-n, --projectName [projectNameAlias]', 'Project name alias')
|
.option('-n, --projectName [projectNameAlias]', 'Project name alias')
|
||||||
|
.option('-C, --configFile [pathToConfigFile]', 'Path to codecrumbs.config.js')
|
||||||
|
.option('-D, --debugModeEnabled [debugModeEnabled]', 'Enable debug mode for logs.')
|
||||||
.parse(process.argv);
|
.parse(process.argv);
|
||||||
|
|
||||||
if (!program.entry || !program.dir) {
|
const pathToConfigFile = program.configFile || 'codecrumbs.config.js';
|
||||||
|
const configFileExists = server.checkIfPathExists(pathToConfigFile);
|
||||||
|
if ((!program.entry || !program.dir) && !configFileExists) {
|
||||||
console.log(
|
console.log(
|
||||||
colors.magenta(
|
colors.magenta(
|
||||||
'Please specify `entry` and `dir` params. E.g. `codecrumbs -e src/app.js -d src`'
|
'Please specify `entryPoint` and `projectDir` params (e.g. `codecrumbs -e src/app.js -d src`). Or use `-C codecrumbs.config.js` instead.'
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
process.exit();
|
process.exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
server.setup(
|
const configFromFile = configFileExists ? require(path.resolve(pathToConfigFile)) : {};
|
||||||
{
|
|
||||||
projectNameAlias: program.projectName,
|
const configFromCLI = {
|
||||||
entryPoint: program.entry,
|
projectNameAlias: program.projectName,
|
||||||
projectDir: program.dir,
|
entryPoint: program.entry,
|
||||||
webpackConfigPath: program.webpack,
|
projectDir: program.dir,
|
||||||
tsConfigPath: program.tsconfig,
|
webpackConfigPath: program.webpack,
|
||||||
clientPort: program.port,
|
tsConfigPath: program.tsconfig,
|
||||||
excludeDir: program.excludeDir,
|
clientPort: program.port,
|
||||||
ideCmd: program.ideCmd
|
excludeDir: program.excludeDir,
|
||||||
},
|
ideCmd: program.ideCmd,
|
||||||
{ isDev: false }
|
debugModeEnabled: program.debugModeEnabled
|
||||||
);
|
};
|
||||||
|
|
||||||
|
server.setup(_.merge(configFromCLI, configFromFile), { isDev: false });
|
||||||
|
|||||||
20
cli/updatesInfo.js
Normal file
20
cli/updatesInfo.js
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
const colors = require('colors');
|
||||||
|
const exec = require('child_process').exec;
|
||||||
|
|
||||||
|
module.exports = () => {
|
||||||
|
try {
|
||||||
|
exec('npm outdated codecrumbs').stdout.on('data', function(data) {
|
||||||
|
const list = data
|
||||||
|
.split(' ')
|
||||||
|
.filter(v => !!v)
|
||||||
|
.map(v => v.trim());
|
||||||
|
|
||||||
|
const latestVersion = list[list.length - 2];
|
||||||
|
console.log(
|
||||||
|
colors.cyan.underline(
|
||||||
|
`There is new version of codecrumbs (${latestVersion}) available! Please update to have all latest features and improvements!`
|
||||||
|
)
|
||||||
|
);
|
||||||
|
});
|
||||||
|
} catch (e) {}
|
||||||
|
};
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 1.8 MiB |
7
example-project/codecrumbs.config.js
Normal file
7
example-project/codecrumbs.config.js
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
module.exports = {
|
||||||
|
entryPoint: 'example-project/src-client/index.js',
|
||||||
|
projectDir: 'example-project/src-client',
|
||||||
|
clientPort: 1234,
|
||||||
|
projectNameAlias: 'example-project-for-client',
|
||||||
|
debugModeEnabled: true
|
||||||
|
};
|
||||||
2
example-project/languages/lua-lang.lua
Normal file
2
example-project/languages/lua-lang.lua
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
-- hello world program
|
||||||
|
print ("Hello World!")
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use App\Http\Requests\CommentRequest;
|
||||||
|
|
||||||
|
use App\Models\Post;
|
||||||
|
use App\Models\Comment;
|
||||||
|
use Auth;
|
||||||
|
use Validator;
|
||||||
|
|
||||||
|
class CommentController extends Controller
|
||||||
|
{
|
||||||
|
function index()
|
||||||
|
{
|
||||||
|
// index
|
||||||
|
}
|
||||||
|
}
|
||||||
18
example-project/src-php/Http/Controllers/PostController.php
Normal file
18
example-project/src-php/Http/Controllers/PostController.php
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use App\Http\Requests\PostRequest;
|
||||||
|
use App\Models\Post;
|
||||||
|
use App\Models\Category;
|
||||||
|
use Hashids\Hashids;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
|
class PostController extends Controller
|
||||||
|
{
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
// index
|
||||||
|
}
|
||||||
|
}
|
||||||
15
example-project/src-php/Http/Requests/PostRequest.php
Normal file
15
example-project/src-php/Http/Requests/PostRequest.php
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Requests;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
use App\Rules\Category;
|
||||||
|
|
||||||
|
|
||||||
|
class PostRequest extends FormRequest
|
||||||
|
{
|
||||||
|
public function authorize()
|
||||||
|
{
|
||||||
|
// authorize
|
||||||
|
}
|
||||||
|
}
|
||||||
13
example-project/src-php/Models/Category.php
Normal file
13
example-project/src-php/Models/Category.php
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class Category extends Model
|
||||||
|
{
|
||||||
|
public function posts()
|
||||||
|
{
|
||||||
|
// posts
|
||||||
|
}
|
||||||
|
}
|
||||||
13
example-project/src-php/Models/Post.php
Normal file
13
example-project/src-php/Models/Post.php
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class Post extends Model
|
||||||
|
{
|
||||||
|
public function user()
|
||||||
|
{
|
||||||
|
// user
|
||||||
|
}
|
||||||
|
}
|
||||||
7
example-project/src-php/index.php
Normal file
7
example-project/src-php/index.php
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App;
|
||||||
|
|
||||||
|
use App\Http\Controllers\CommentController;
|
||||||
|
use App\Http\Controllers\PostController;
|
||||||
|
use App\Http\Requests\PostRequest;
|
||||||
17
package.json
17
package.json
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "codecrumbs",
|
"name": "codecrumbs",
|
||||||
"version": "1.6.7",
|
"version": "1.8.3",
|
||||||
"author": "Bohdan Liashenko",
|
"author": "Bohdan Liashenko",
|
||||||
"license": "BSD-3-Clause",
|
"license": "BSD-3-Clause",
|
||||||
"repository": {
|
"repository": {
|
||||||
@@ -13,11 +13,11 @@
|
|||||||
"server:two": "node src/index.dev.js two",
|
"server:two": "node src/index.dev.js two",
|
||||||
"client-dev": "cd src/public && webpack --config webpack.dev.js --progress --colors --watch --env dev",
|
"client-dev": "cd src/public && webpack --config webpack.dev.js --progress --colors --watch --env dev",
|
||||||
"server-dev": "nodemon src/index.dev.js",
|
"server-dev": "nodemon src/index.dev.js",
|
||||||
|
"server:cli": "node cli/index.cli.js -e example-project/src-client/index.js -d example-project/src-client/",
|
||||||
"server-debug": "nodemon --inspect src/index.dev.js",
|
"server-debug": "nodemon --inspect src/index.dev.js",
|
||||||
"clean": "rm -rf build",
|
"clean": "rm -rf build",
|
||||||
"babel-compile-standalone": "babel src/public/js -d build --config-file ./src/public/babel.config.js --copy-files",
|
|
||||||
"webpack-compile-local": "cd src/public && webpack --config webpack.local.js --progress",
|
"webpack-compile-local": "cd src/public && webpack --config webpack.local.js --progress",
|
||||||
"build": "yarn clean && yarn babel-compile-standalone && yarn webpack-compile-local",
|
"build": "yarn clean && yarn webpack-compile-local",
|
||||||
"pretty": "prettier --write \"./src/public/js/**/*.js\""
|
"pretty": "prettier --write \"./src/public/js/**/*.js\""
|
||||||
},
|
},
|
||||||
"bin": {
|
"bin": {
|
||||||
@@ -35,14 +35,15 @@
|
|||||||
"d3-flextree": "^2.1.1",
|
"d3-flextree": "^2.1.1",
|
||||||
"directory-tree": "^2.1.0",
|
"directory-tree": "^2.1.0",
|
||||||
"file-saver": "^2.0.0",
|
"file-saver": "^2.0.0",
|
||||||
"http-server": "^0.11.1",
|
"http-server": "0.9.0",
|
||||||
"js2flowchart": "^1.1.7",
|
"js2flowchart": "1.3.2",
|
||||||
"lodash": "^4.17.10",
|
"lodash": "^4.17.10",
|
||||||
"lodash.debounce": "^4.0.8",
|
"lodash.debounce": "^4.0.8",
|
||||||
"madge": "^3.3.0",
|
"madge": "^3.4.4",
|
||||||
|
"php-parser": "^3.0.2",
|
||||||
"portscanner": "^2.2.0",
|
"portscanner": "^2.2.0",
|
||||||
"react": "^16.7.0",
|
"react": "^16.8.6",
|
||||||
"react-dom": "^16.7.0",
|
"react-dom": "^16.8.6",
|
||||||
"react-redux": "^5.0.7",
|
"react-redux": "^5.0.7",
|
||||||
"react-syntax-highlighter": "8.0.1",
|
"react-syntax-highlighter": "8.0.1",
|
||||||
"redux": "^4.0.0",
|
"redux": "^4.0.0",
|
||||||
|
|||||||
@@ -5,7 +5,8 @@ const namespaceOne = {
|
|||||||
projectDir: `example-project/src-client`,
|
projectDir: `example-project/src-client`,
|
||||||
entryPoint: `example-project/src-client/index.js`,
|
entryPoint: `example-project/src-client/index.js`,
|
||||||
webpackConfigPath: `example-project/webpack.config.js`,
|
webpackConfigPath: `example-project/webpack.config.js`,
|
||||||
clientPort: 2018
|
clientPort: 2018,
|
||||||
|
debugModeEnabled: true
|
||||||
};
|
};
|
||||||
|
|
||||||
const namespaceTwo = {
|
const namespaceTwo = {
|
||||||
@@ -23,6 +24,13 @@ const namespaceTypeScriptExample = {
|
|||||||
clientPort: 2018
|
clientPort: 2018
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const namespacePhpExample = {
|
||||||
|
projectNameAlias: 'php-example-server',
|
||||||
|
projectDir: `example-project/src-php`,
|
||||||
|
entryPoint: `example-project/src-php/index.php`,
|
||||||
|
clientPort: 2018
|
||||||
|
};
|
||||||
|
|
||||||
const namespaceDebug = {
|
const namespaceDebug = {
|
||||||
projectNameAlias: 'debug',
|
projectNameAlias: 'debug',
|
||||||
projectDir: `example-project/debug`,
|
projectDir: `example-project/debug`,
|
||||||
@@ -40,7 +48,8 @@ const namespaceLanguageTest = {
|
|||||||
const args = process.argv.slice(2);
|
const args = process.argv.slice(2);
|
||||||
const namespaces = {
|
const namespaces = {
|
||||||
two: namespaceTwo,
|
two: namespaceTwo,
|
||||||
ts: namespaceTypeScriptExample
|
ts: namespaceTypeScriptExample,
|
||||||
|
php: namespacePhpExample
|
||||||
};
|
};
|
||||||
const namespace = namespaces[args[0]] !== undefined ? namespaces[args[0]] : namespaceOne;
|
const namespace = namespaces[args[0]] !== undefined ? namespaces[args[0]] : namespaceOne;
|
||||||
server.setup(namespace, { isDev: true });
|
server.setup(namespace, { isDev: true });
|
||||||
|
|||||||
@@ -22,9 +22,7 @@ const ExplorerBar = React.lazy(() =>
|
|||||||
import(/* webpackChunkName: "explorer-bar" */ './components/explorerBar/ExplorerBarContainer')
|
import(/* webpackChunkName: "explorer-bar" */ './components/explorerBar/ExplorerBarContainer')
|
||||||
);
|
);
|
||||||
|
|
||||||
const Footer = React.lazy(() =>
|
const Footer = React.lazy(() => import(/* webpackChunkName: "footer" */ './components/footer'));
|
||||||
import(/* webpackChunkName: "footer" */ './components/footer')
|
|
||||||
);
|
|
||||||
|
|
||||||
import './App.less';
|
import './App.less';
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ const PADDING_TOP = 5;
|
|||||||
//TODO: add select with several themes
|
//TODO: add select with several themes
|
||||||
//TODO: scrool to/highlight crumbed lines
|
//TODO: scrool to/highlight crumbed lines
|
||||||
//https://github.com/conorhastings/react-syntax-highlighter/blob/master/README.md
|
//https://github.com/conorhastings/react-syntax-highlighter/blob/master/README.md
|
||||||
export default class extends React.Component {
|
export default class extends React.PureComponent {
|
||||||
fixScroll() {
|
fixScroll() {
|
||||||
const { dependenciesLines = [], crumbedLines = [], lineHeight } = this.props;
|
const { dependenciesLines = [], crumbedLines = [], lineHeight } = this.props;
|
||||||
if (!this.codeRef || !this.codeRef.scrollTo) {
|
if (!this.codeRef || !this.codeRef.scrollTo) {
|
||||||
@@ -28,6 +28,7 @@ export default class extends React.Component {
|
|||||||
this.codeRef.scrollTo(0, (lines[0][0] - 1) * (lineHeight || LINE_HEIGHT) + PADDING_TOP - 2);
|
this.codeRef.scrollTo(0, (lines[0][0] - 1) * (lineHeight || LINE_HEIGHT) + PADDING_TOP - 2);
|
||||||
}
|
}
|
||||||
componentDidUpdate(prevProps) {
|
componentDidUpdate(prevProps) {
|
||||||
|
// TODO: don\t do it each time (check real changes)
|
||||||
this.fixScroll();
|
this.fixScroll();
|
||||||
}
|
}
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
|
|||||||
@@ -8,8 +8,7 @@ import 'antd/es/alert/style';
|
|||||||
|
|
||||||
import { NO_TRAIL_FLOW } from '../../../../shared-constants';
|
import { NO_TRAIL_FLOW } from '../../../../shared-constants';
|
||||||
import { getCodeCrumbsUserChoice } from '../../../../core/dataBus/selectors';
|
import { getCodeCrumbsUserChoice } from '../../../../core/dataBus/selectors';
|
||||||
import { getNamespacesList } from '../../../../core/dataBus/selectors';
|
import { getSharedFlowStepsData } from '../../../../core/namespaceIntegration/selectors';
|
||||||
import { gatherFlowStepsData } from '../../../treeDiagram/component/Tree/CodeCrumbs/helpers';
|
|
||||||
|
|
||||||
import Code from '../Code';
|
import Code from '../Code';
|
||||||
import './index.less';
|
import './index.less';
|
||||||
@@ -34,7 +33,7 @@ const CrumbsTab = props => {
|
|||||||
header={`[${typeof stepFile.step !== 'undefined' ? stepFile.step : '*'}] ${
|
header={`[${typeof stepFile.step !== 'undefined' ? stepFile.step : '*'}] ${
|
||||||
stepFile.file.path
|
stepFile.file.path
|
||||||
}`}
|
}`}
|
||||||
key={i}
|
key={stepFile.crumbNodeLines.join(',')}
|
||||||
>
|
>
|
||||||
<Code
|
<Code
|
||||||
language={language}
|
language={language}
|
||||||
@@ -58,7 +57,6 @@ const CrumbsTab = props => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const mapStateToProps = (state, props) => {
|
const mapStateToProps = (state, props) => {
|
||||||
const namespacesList = getNamespacesList(state);
|
|
||||||
const { namespace } = props;
|
const { namespace } = props;
|
||||||
|
|
||||||
const {
|
const {
|
||||||
@@ -69,10 +67,7 @@ const mapStateToProps = (state, props) => {
|
|||||||
namespace
|
namespace
|
||||||
});
|
});
|
||||||
|
|
||||||
const { involvedNsData, sortedFlowSteps } = gatherFlowStepsData(state, {
|
const { involvedNsData, sortedFlowSteps } = getSharedFlowStepsData(state);
|
||||||
currentSelectedCrumbedFlowKey,
|
|
||||||
namespacesList
|
|
||||||
});
|
|
||||||
|
|
||||||
if (currentSelectedCrumbedFlowKey === NO_TRAIL_FLOW) {
|
if (currentSelectedCrumbedFlowKey === NO_TRAIL_FLOW) {
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import 'antd/es/icon/style';
|
|||||||
import { VIEW_TYPES } from '../../../../../core/controlsBus/constants';
|
import { VIEW_TYPES } from '../../../../../core/controlsBus/constants';
|
||||||
import './ViewSwitch.less';
|
import './ViewSwitch.less';
|
||||||
|
|
||||||
class ViewSwitch extends React.Component {
|
class ViewSwitch extends React.PureComponent {
|
||||||
renderMenu() {
|
renderMenu() {
|
||||||
const {
|
const {
|
||||||
name,
|
name,
|
||||||
@@ -78,7 +78,7 @@ class ViewSwitch extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { name, itemKey, subMenuItems, checkedState, toggleSwitch } = this.props;
|
const { name, itemKey, subMenuItems, checkedState, disabledState, toggleSwitch } = this.props;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="ViewSwitchItem">
|
<div className="ViewSwitchItem">
|
||||||
@@ -92,6 +92,7 @@ class ViewSwitch extends React.Component {
|
|||||||
size="small"
|
size="small"
|
||||||
checked={checkedState[itemKey]}
|
checked={checkedState[itemKey]}
|
||||||
onChange={v => toggleSwitch(itemKey, v)}
|
onChange={v => toggleSwitch(itemKey, v)}
|
||||||
|
disabled={disabledState[itemKey]}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.settingContainer {
|
.settingContainer {
|
||||||
display: flex;
|
display: none;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
|
|
||||||
.spacer {
|
.spacer {
|
||||||
@@ -26,4 +26,4 @@
|
|||||||
border-left: 1px solid #d9d9d9;
|
border-left: 1px solid #d9d9d9;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
.TreeDiagramsContainer {
|
.TreeDiagramsContainer {
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
margin-top: 20px;
|
||||||
|
margin-left: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.MainLoader {
|
.MainLoader {
|
||||||
@@ -10,4 +12,4 @@
|
|||||||
padding: 250px;
|
padding: 250px;
|
||||||
margin-top: 60px;
|
margin-top: 60px;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ const TreeDiagramsContainer = ({ namespacesList, activeNamespace }) => {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: use ref for TreeDiagram container (on mount set it to store)
|
||||||
return (
|
return (
|
||||||
<div className={'TreeDiagramsContainer'}>
|
<div className={'TreeDiagramsContainer'}>
|
||||||
{namespacesList.map(namespace => (
|
{namespacesList.map(namespace => (
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ export const CodeCrumbName = props => {
|
|||||||
cover,
|
cover,
|
||||||
flow,
|
flow,
|
||||||
flowStep,
|
flowStep,
|
||||||
|
original,
|
||||||
selected,
|
selected,
|
||||||
onMouseOver,
|
onMouseOver,
|
||||||
onClick
|
onClick
|
||||||
@@ -73,7 +74,7 @@ export const CodeCrumbName = props => {
|
|||||||
onClick={onClick}
|
onClick={onClick}
|
||||||
className={'CodeCrumbName-flow'}
|
className={'CodeCrumbName-flow'}
|
||||||
>
|
>
|
||||||
{flowStep}
|
{flowStep !== 0 ? flowStep : /#0/.test(original) ? 0 : '*'}
|
||||||
</text>
|
</text>
|
||||||
</React.Fragment>
|
</React.Fragment>
|
||||||
)) ||
|
)) ||
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ const DetailsComponent = props => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const ccUnderlayPaddingH = 20;
|
const ccUnderlayPaddingH = 20;
|
||||||
class CodeComponent extends React.Component {
|
class CodeComponent extends React.PureComponent {
|
||||||
state = {};
|
state = {};
|
||||||
|
|
||||||
onMouseEnter = () => {
|
onMouseEnter = () => {
|
||||||
@@ -48,8 +48,7 @@ class CodeComponent extends React.Component {
|
|||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { position, crumbNodeLines, file, language, namespace } = this.props;
|
const { position, crumbNodeLines, file, language, namespace } = this.props;
|
||||||
const { fileCode } = file.data;
|
const { fileCode, path, name } = file.data;
|
||||||
|
|
||||||
const { isExpanded } = this.state;
|
const { isExpanded } = this.state;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -63,6 +62,12 @@ class CodeComponent extends React.Component {
|
|||||||
onMouseEnter={this.onMouseEnter}
|
onMouseEnter={this.onMouseEnter}
|
||||||
onMouseLeave={this.onMouseLeave}
|
onMouseLeave={this.onMouseLeave}
|
||||||
>
|
>
|
||||||
|
<div className={'FilePath'}>
|
||||||
|
<span>{path.replace(name, '')}</span>
|
||||||
|
<span>
|
||||||
|
<b>{name}</b>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
<Suspense fallback={null}>
|
<Suspense fallback={null}>
|
||||||
<Code
|
<Code
|
||||||
namespace={namespace}
|
namespace={namespace}
|
||||||
@@ -101,7 +106,7 @@ const ExtraInfoSet = ({
|
|||||||
namespace,
|
namespace,
|
||||||
language
|
language
|
||||||
}) => {
|
}) => {
|
||||||
if (!detailsEnabled && !codePreviewEnabled) return null;
|
if ((!detailsEnabled && !codePreviewEnabled) || !sortedFlowSteps) return null;
|
||||||
|
|
||||||
const crumbs = sortedFlowSteps.length ? sortedFlowSteps : flowSteps;
|
const crumbs = sortedFlowSteps.length ? sortedFlowSteps : flowSteps;
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -22,6 +22,12 @@
|
|||||||
transition: height .1s;
|
transition: height .1s;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
z-index: 1;
|
z-index: 1;
|
||||||
|
|
||||||
|
.FilePath {
|
||||||
|
border-bottom: 1px solid #ebedf0;
|
||||||
|
font-size: 11px;
|
||||||
|
padding: 1px 5px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@CcCodeContainerExpandedHeight: 300px;
|
@CcCodeContainerExpandedHeight: 300px;
|
||||||
@@ -47,4 +53,4 @@
|
|||||||
height: (@CcCodeContainerExpandedHeight + @ccUnderlayPaddingV);
|
height: (@CcCodeContainerExpandedHeight + @ccUnderlayPaddingV);
|
||||||
transition: height, background-color .1s;
|
transition: height, background-color .1s;
|
||||||
z-index: 2;
|
z-index: 2;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,10 @@ export default props => {
|
|||||||
selectedCcFlowEdgeNodes
|
selectedCcFlowEdgeNodes
|
||||||
} = props;
|
} = props;
|
||||||
|
|
||||||
|
if (!involvedNsData || !involvedNsData[namespace]) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
const { codecrumbsLayoutMap } = involvedNsData[namespace];
|
const { codecrumbsLayoutMap } = involvedNsData[namespace];
|
||||||
const ccNamespacesKeys = Object.keys(involvedNsData || {});
|
const ccNamespacesKeys = Object.keys(involvedNsData || {});
|
||||||
|
|
||||||
@@ -27,7 +31,11 @@ export default props => {
|
|||||||
if (!i) return null;
|
if (!i) return null;
|
||||||
|
|
||||||
const fromItem = list[i - 1];
|
const fromItem = list[i - 1];
|
||||||
if (fromItem.namespace !== namespace && toItem.namespace !== namespace) {
|
|
||||||
|
if (
|
||||||
|
(fromItem.namespace !== namespace && toItem.namespace !== namespace) ||
|
||||||
|
fromItem.step === toItem.step
|
||||||
|
) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -38,7 +46,7 @@ export default props => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const edgeBaseProps = {
|
const edgeBaseProps = {
|
||||||
key: `cc-external-edge-${fromItem.name}-${toItem.name}`,
|
key: `cc-external-edge-${fromItem.name}-${toItem.name}-${edgePoints[0].y}`,
|
||||||
sourcePosition: edgePoints[0],
|
sourcePosition: edgePoints[0],
|
||||||
targetPosition: edgePoints[1],
|
targetPosition: edgePoints[1],
|
||||||
onClick: () => onFlowEdgeClick(fromItem, toItem, ccNamespacesKeys),
|
onClick: () => onFlowEdgeClick(fromItem, toItem, ccNamespacesKeys),
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import { isCodeCrumbSelected, getCcPosition } from './helpers';
|
|||||||
|
|
||||||
const Tree = props => {
|
const Tree = props => {
|
||||||
const {
|
const {
|
||||||
|
sourceDiagramOn,
|
||||||
ccAlightPoint,
|
ccAlightPoint,
|
||||||
ccShiftIndexMap,
|
ccShiftIndexMap,
|
||||||
shiftToCenterPoint,
|
shiftToCenterPoint,
|
||||||
@@ -19,6 +20,10 @@ const Tree = props => {
|
|||||||
selectedCcFlowEdgeNodes
|
selectedCcFlowEdgeNodes
|
||||||
} = props;
|
} = props;
|
||||||
|
|
||||||
|
if (!ccShiftIndexMap) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<React.Fragment>
|
<React.Fragment>
|
||||||
{Object.keys(codecrumbsLayoutMap).map(key => {
|
{Object.keys(codecrumbsLayoutMap).map(key => {
|
||||||
@@ -40,7 +45,7 @@ const Tree = props => {
|
|||||||
).x;
|
).x;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<React.Fragment key={`code-crumb-${node.data.path}-${key}`}>
|
<React.Fragment key={`code-crumb-${key}-${nX}-${nY}`}>
|
||||||
{!codeCrumbsMinimize &&
|
{!codeCrumbsMinimize &&
|
||||||
node.children.map((crumb, i) => {
|
node.children.map((crumb, i) => {
|
||||||
const [_, cY] = [crumb.y, crumb.x];
|
const [_, cY] = [crumb.y, crumb.x];
|
||||||
@@ -55,22 +60,26 @@ const Tree = props => {
|
|||||||
const ccParams = crumbData.params;
|
const ccParams = crumbData.params;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<React.Fragment key={`code-crumb-edge-${file.path}-${crumbData.name}`}>
|
<React.Fragment
|
||||||
{!i && (
|
key={`code-crumb-edge-${crumbData.name}-${crumbPosition.x}-${crumbPosition.y}`}
|
||||||
<PartEdge
|
>
|
||||||
sourcePosition={position}
|
{!i &&
|
||||||
parentName={file.name}
|
sourceDiagramOn && (
|
||||||
ccAlightPoint={crumbPosition.x}
|
<PartEdge
|
||||||
singleCrumb={singleCrumb}
|
sourcePosition={position}
|
||||||
/>
|
parentName={file.name}
|
||||||
)}
|
ccAlightPoint={crumbPosition.x}
|
||||||
{!singleCrumb && (
|
singleCrumb={singleCrumb}
|
||||||
<CodeCrumbMultiEdge
|
/>
|
||||||
sourcePosition={position}
|
)}
|
||||||
targetPosition={crumbPosition}
|
{!singleCrumb &&
|
||||||
ccAlightPoint={i && firstCrumbXPoint}
|
sourceDiagramOn && (
|
||||||
/>
|
<CodeCrumbMultiEdge
|
||||||
)}
|
sourcePosition={position}
|
||||||
|
targetPosition={crumbPosition}
|
||||||
|
ccAlightPoint={i && firstCrumbXPoint}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
<CodeCrumbName
|
<CodeCrumbName
|
||||||
position={crumbPosition}
|
position={crumbPosition}
|
||||||
loc={codeCrumbsLineNumbers ? crumbData.displayLoc : ''}
|
loc={codeCrumbsLineNumbers ? crumbData.displayLoc : ''}
|
||||||
@@ -84,6 +93,7 @@ const Tree = props => {
|
|||||||
currentSelectedCrumbedFlowKey !== NO_TRAIL_FLOW
|
currentSelectedCrumbedFlowKey !== NO_TRAIL_FLOW
|
||||||
}
|
}
|
||||||
flowStep={ccParams.flowStep}
|
flowStep={ccParams.flowStep}
|
||||||
|
original={ccParams.original}
|
||||||
onClick={e => onCodeCrumbSelect(e, { fileNode: file, codeCrumb: crumbData })}
|
onClick={e => onCodeCrumbSelect(e, { fileNode: file, codeCrumb: crumbData })}
|
||||||
/>
|
/>
|
||||||
</React.Fragment>
|
</React.Fragment>
|
||||||
|
|||||||
@@ -1,6 +1,3 @@
|
|||||||
import { getCodeCrumbsUserChoice, getSourceLayout } from '../../../../../core/dataBus/selectors';
|
|
||||||
import { NO_TRAIL_FLOW } from '../../../../../core/constants';
|
|
||||||
|
|
||||||
export const isCodeCrumbsEqual = (cc, currentCc) =>
|
export const isCodeCrumbsEqual = (cc, currentCc) =>
|
||||||
cc.name === currentCc.name && cc.flowStep === currentCc.flowStep;
|
cc.name === currentCc.name && cc.flowStep === currentCc.flowStep;
|
||||||
|
|
||||||
@@ -13,100 +10,4 @@ export const isCodeCrumbSelected = (selectedCcFlowEdgeNodes, cc) => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const stepSorter = (a, b) => a.step - b.step;
|
|
||||||
|
|
||||||
const getFlowSteps = ({
|
|
||||||
namespace,
|
|
||||||
codeCrumbedFlowsMap,
|
|
||||||
selectedCrumbedFlowKey,
|
|
||||||
codecrumbsLayoutMap
|
|
||||||
}) => {
|
|
||||||
const currentFlow = codeCrumbedFlowsMap[selectedCrumbedFlowKey] || {};
|
|
||||||
|
|
||||||
return Object.keys(currentFlow).reduce((flowSteps, filePath) => {
|
|
||||||
const steps = ((codecrumbsLayoutMap[filePath] && codecrumbsLayoutMap[filePath].children) || [])
|
|
||||||
.filter(({ data }) => data.params.flow === selectedCrumbedFlowKey)
|
|
||||||
.map(({ data, x, y }) => ({
|
|
||||||
...data,
|
|
||||||
namespace,
|
|
||||||
filePath,
|
|
||||||
step: data.params.flowStep,
|
|
||||||
flow: selectedCrumbedFlowKey,
|
|
||||||
x,
|
|
||||||
y
|
|
||||||
}));
|
|
||||||
|
|
||||||
return [...flowSteps, ...steps];
|
|
||||||
}, []);
|
|
||||||
};
|
|
||||||
|
|
||||||
const createCcShiftIndexMap = sortedFlowSteps => {
|
|
||||||
const ccMap = {};
|
|
||||||
let shiftOrderIndex = 0;
|
|
||||||
|
|
||||||
sortedFlowSteps.forEach((crumb, i, list) => {
|
|
||||||
if (!i) {
|
|
||||||
ccMap[crumb.id] = shiftOrderIndex;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (crumb.x < list[i - 1].x) {
|
|
||||||
shiftOrderIndex++;
|
|
||||||
}
|
|
||||||
|
|
||||||
ccMap[crumb.id] = shiftOrderIndex;
|
|
||||||
});
|
|
||||||
|
|
||||||
return ccMap;
|
|
||||||
};
|
|
||||||
|
|
||||||
export const gatherFlowStepsData = (state, { namespacesList, currentSelectedCrumbedFlowKey }) => {
|
|
||||||
const flowStepsData = namespacesList.reduce(
|
|
||||||
(acc, ns) => {
|
|
||||||
const namespaceProps = { namespace: ns };
|
|
||||||
const { selectedCrumbedFlowKey, codeCrumbedFlowsMap } = getCodeCrumbsUserChoice(
|
|
||||||
state,
|
|
||||||
namespaceProps
|
|
||||||
);
|
|
||||||
|
|
||||||
if (currentSelectedCrumbedFlowKey !== selectedCrumbedFlowKey) {
|
|
||||||
return acc;
|
|
||||||
}
|
|
||||||
|
|
||||||
const { codecrumbsLayoutMap, ccAlightPoint } = getSourceLayout(state, namespaceProps);
|
|
||||||
|
|
||||||
const flowSteps = getFlowSteps({
|
|
||||||
namespace: ns,
|
|
||||||
codeCrumbedFlowsMap,
|
|
||||||
selectedCrumbedFlowKey,
|
|
||||||
codecrumbsLayoutMap
|
|
||||||
});
|
|
||||||
|
|
||||||
return {
|
|
||||||
flowSteps,
|
|
||||||
sortedFlowSteps:
|
|
||||||
selectedCrumbedFlowKey !== NO_TRAIL_FLOW
|
|
||||||
? [...acc.sortedFlowSteps, ...flowSteps].sort(stepSorter)
|
|
||||||
: [],
|
|
||||||
involvedNsData: {
|
|
||||||
...acc.involvedNsData,
|
|
||||||
[ns]: { codecrumbsLayoutMap, ccAlightPoint }
|
|
||||||
}
|
|
||||||
};
|
|
||||||
},
|
|
||||||
{ involvedNsData: {}, flowSteps: [], sortedFlowSteps: [] }
|
|
||||||
);
|
|
||||||
|
|
||||||
return {
|
|
||||||
...flowStepsData,
|
|
||||||
ccShiftIndexMap: createCcShiftIndexMap(flowStepsData.sortedFlowSteps)
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
export const getCcPosition = (x, index = 0) => x + 70 * index;
|
export const getCcPosition = (x, index = 0) => x + 70 * index;
|
||||||
|
|
||||||
export const getMaxWidthForNs = (state, { namespacesList }) =>
|
|
||||||
namespacesList.reduce((maxWidth, namespace) => {
|
|
||||||
const { layoutSize } = getSourceLayout(state, { namespace });
|
|
||||||
return layoutSize && layoutSize.width > maxWidth ? layoutSize.width : maxWidth;
|
|
||||||
}, 0);
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ import Tree from './Tree';
|
|||||||
import FlowEdges from './FlowEdge';
|
import FlowEdges from './FlowEdge';
|
||||||
|
|
||||||
const mapStateToProps = (state, props) => {
|
const mapStateToProps = (state, props) => {
|
||||||
const { codeCrumbsMinimize, codeCrumbsLineNumbers } = getCheckedState(state);
|
const { codeCrumbsMinimize, codeCrumbsLineNumbers, sourceDiagramOn } = getCheckedState(state);
|
||||||
|
|
||||||
const namespacesList = getNamespacesList(state);
|
const namespacesList = getNamespacesList(state);
|
||||||
|
|
||||||
@@ -35,6 +35,7 @@ const mapStateToProps = (state, props) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
sourceDiagramOn,
|
||||||
codecrumbsLayoutMap,
|
codecrumbsLayoutMap,
|
||||||
ccAlightPoint,
|
ccAlightPoint,
|
||||||
filesMap,
|
filesMap,
|
||||||
|
|||||||
@@ -2,24 +2,20 @@ import React from 'react';
|
|||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
|
|
||||||
import { DependenciesEdge, DependenciesArrow } from '../../Edge/DepenenciesEdge';
|
import { DependenciesEdge, DependenciesArrow } from '../../Edge/DepenenciesEdge';
|
||||||
import { FileName } from '../../../component/Node/File';
|
|
||||||
import { selectDependencyEdge } from '../../../../../core/dataBus/actions';
|
import { selectDependencyEdge } from '../../../../../core/dataBus/actions';
|
||||||
import {
|
import {
|
||||||
getSourceLayout,
|
getSourceLayout,
|
||||||
getSourceUserChoice,
|
getSourceUserChoice,
|
||||||
getDependenciesUserChoice
|
getDependenciesUserChoice
|
||||||
} from '../../../../../core/dataBus/selectors';
|
} from '../../../../../core/dataBus/selectors';
|
||||||
import { getCheckedState } from '../../../../../core/controlsBus/selectors';
|
|
||||||
|
|
||||||
import { getGroupsAroundNode, checkIsEdgeSelected } from './utils';
|
import { getGroupsAroundNode, checkIsEdgeSelected } from './utils';
|
||||||
|
|
||||||
const DependenciesTree = props => {
|
const DependenciesTree = props => {
|
||||||
const {
|
const {
|
||||||
language,
|
|
||||||
selectedNode,
|
selectedNode,
|
||||||
filesLayoutMap,
|
filesLayoutMap,
|
||||||
shiftToCenterPoint,
|
shiftToCenterPoint,
|
||||||
sourceDiagramOn,
|
|
||||||
onDependencyEdgeClick,
|
onDependencyEdgeClick,
|
||||||
selectedDependencyEdgeNodes
|
selectedDependencyEdgeNodes
|
||||||
} = props;
|
} = props;
|
||||||
@@ -33,28 +29,19 @@ const DependenciesTree = props => {
|
|||||||
<React.Fragment>
|
<React.Fragment>
|
||||||
{selectedNodeDependencies &&
|
{selectedNodeDependencies &&
|
||||||
[selectedNodeDependencies].map(({ moduleName, importedModuleNames }) => {
|
[selectedNodeDependencies].map(({ moduleName, importedModuleNames }) => {
|
||||||
const moduleNode = filesLayoutMap[moduleName];
|
const moduleNode = filesLayoutMap[selectedNode.path];
|
||||||
if (!moduleNode) return null;
|
if (!moduleNode) return null;
|
||||||
|
|
||||||
const { name, path } = moduleNode.data;
|
|
||||||
const [mX, mY] = [moduleNode.y, moduleNode.x];
|
const [mX, mY] = [moduleNode.y, moduleNode.x];
|
||||||
const targetPosition = shiftToCenterPoint(mX, mY);
|
const targetPosition = shiftToCenterPoint(mX, mY);
|
||||||
const sourceNodes = [];
|
|
||||||
if (!sourceDiagramOn) {
|
|
||||||
// TODO: un sync with FileName in SourceTree, duplication
|
|
||||||
sourceNodes.push(
|
|
||||||
<FileName
|
|
||||||
language={language}
|
|
||||||
key={path}
|
|
||||||
position={targetPosition}
|
|
||||||
name={name}
|
|
||||||
dependency={true}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
const importedNodes = importedModuleNames
|
const importedNodes = importedModuleNames
|
||||||
.map(name => filesLayoutMap[name])
|
.map(moduleName => {
|
||||||
|
const key = Object.keys(selectedNode.dependencies).find(key => {
|
||||||
|
return selectedNode.dependencies[key].moduleName === moduleName
|
||||||
|
})
|
||||||
|
return filesLayoutMap[key]
|
||||||
|
})
|
||||||
.filter(node => !!node);
|
.filter(node => !!node);
|
||||||
|
|
||||||
const edges = [];
|
const edges = [];
|
||||||
@@ -72,15 +59,15 @@ const DependenciesTree = props => {
|
|||||||
groupNodes.forEach((importedNode, i) => {
|
groupNodes.forEach((importedNode, i) => {
|
||||||
const [iX, iY] = [importedNode.y, importedNode.x];
|
const [iX, iY] = [importedNode.y, importedNode.x];
|
||||||
const sourcePosition = shiftToCenterPoint(iX, iY);
|
const sourcePosition = shiftToCenterPoint(iX, iY);
|
||||||
const { path: importedNodePath, name } = importedNode.data;
|
const { path: importedNodePath } = importedNode.data;
|
||||||
|
|
||||||
const selected =
|
const selected =
|
||||||
selectedDependencyEdgeNodes &&
|
selectedDependencyEdgeNodes &&
|
||||||
checkIsEdgeSelected(selectedDependencyEdgeNodes, moduleName, importedNodePath);
|
checkIsEdgeSelected(selectedDependencyEdgeNodes, selectedNode.path, importedNodePath);
|
||||||
|
|
||||||
const edge = (
|
const edge = (
|
||||||
<DependenciesEdge
|
<DependenciesEdge
|
||||||
key={`dep-edge-${importedNodePath}`}
|
key={`dep-edge-${importedNodePath}-${sourcePosition.x}-${targetPosition.x}`}
|
||||||
anyEdgeSelected={!!selectedDependencyEdgeNodes}
|
anyEdgeSelected={!!selectedDependencyEdgeNodes}
|
||||||
selected={selected}
|
selected={selected}
|
||||||
groupName={groupName}
|
groupName={groupName}
|
||||||
@@ -89,7 +76,7 @@ const DependenciesTree = props => {
|
|||||||
firstSourcePosition={i ? firstSourcePosition : null}
|
firstSourcePosition={i ? firstSourcePosition : null}
|
||||||
onClick={() =>
|
onClick={() =>
|
||||||
onDependencyEdgeClick({
|
onDependencyEdgeClick({
|
||||||
target: moduleName,
|
target: selectedNode.path,
|
||||||
sources: [importedNodePath],
|
sources: [importedNodePath],
|
||||||
groupName
|
groupName
|
||||||
})
|
})
|
||||||
@@ -106,7 +93,7 @@ const DependenciesTree = props => {
|
|||||||
|
|
||||||
const arrow = (
|
const arrow = (
|
||||||
<DependenciesArrow
|
<DependenciesArrow
|
||||||
key={`dep-arrow-${importedNodePath}`}
|
key={`dep-arrow-${importedNodePath}-${groupName}`}
|
||||||
selected={arrowSelected}
|
selected={arrowSelected}
|
||||||
groupName={groupName}
|
groupName={groupName}
|
||||||
targetPosition={targetPosition}
|
targetPosition={targetPosition}
|
||||||
@@ -114,18 +101,6 @@ const DependenciesTree = props => {
|
|||||||
);
|
);
|
||||||
arrowSelected ? selectedEdges.push(arrow) : edges.push(arrow);
|
arrowSelected ? selectedEdges.push(arrow) : edges.push(arrow);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!sourceDiagramOn) {
|
|
||||||
sourceNodes.push(
|
|
||||||
<FileName
|
|
||||||
key={importedNodePath}
|
|
||||||
language={language}
|
|
||||||
position={sourcePosition}
|
|
||||||
name={name}
|
|
||||||
dependency={true}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@@ -134,7 +109,6 @@ const DependenciesTree = props => {
|
|||||||
<React.Fragment key={moduleName}>
|
<React.Fragment key={moduleName}>
|
||||||
{edges}
|
{edges}
|
||||||
{selectedEdges}
|
{selectedEdges}
|
||||||
{sourceNodes}
|
|
||||||
</React.Fragment>
|
</React.Fragment>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
@@ -143,8 +117,6 @@ const DependenciesTree = props => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const mapStateToProps = (state, props) => {
|
const mapStateToProps = (state, props) => {
|
||||||
const { sourceDiagramOn } = getCheckedState(state);
|
|
||||||
|
|
||||||
const { namespace } = props;
|
const { namespace } = props;
|
||||||
const namespaceProps = { namespace };
|
const namespaceProps = { namespace };
|
||||||
const { filesLayoutMap } = getSourceLayout(state, namespaceProps);
|
const { filesLayoutMap } = getSourceLayout(state, namespaceProps);
|
||||||
@@ -152,7 +124,6 @@ const mapStateToProps = (state, props) => {
|
|||||||
const { selectedDependencyEdgeNodes } = getDependenciesUserChoice(state, namespaceProps);
|
const { selectedDependencyEdgeNodes } = getDependenciesUserChoice(state, namespaceProps);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
sourceDiagramOn,
|
|
||||||
filesLayoutMap,
|
filesLayoutMap,
|
||||||
selectedNode,
|
selectedNode,
|
||||||
selectedDependencyEdgeNodes
|
selectedDependencyEdgeNodes
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ const SourceTree = props => {
|
|||||||
|
|
||||||
const edge = (
|
const edge = (
|
||||||
<SourceEdge
|
<SourceEdge
|
||||||
key={`source-edge-${path}`}
|
key={`source-edge-${path}-${sourcePosition.x}-${sourcePosition.y}`}
|
||||||
targetPosition={position}
|
targetPosition={position}
|
||||||
sourcePosition={sourcePosition}
|
sourcePosition={sourcePosition}
|
||||||
disabled={sourceDimFolders}
|
disabled={sourceDimFolders}
|
||||||
@@ -77,7 +77,13 @@ const SourceTree = props => {
|
|||||||
(type === FILE_NODE_TYPE &&
|
(type === FILE_NODE_TYPE &&
|
||||||
!(dependenciesDiagramOn && selectedNode.dependencies && selectedNode.dependencies[path]))
|
!(dependenciesDiagramOn && selectedNode.dependencies && selectedNode.dependencies[path]))
|
||||||
) {
|
) {
|
||||||
sourceDotes.push(<Dot key={`dot-${path}`} position={position} selected={selected} />);
|
sourceDotes.push(
|
||||||
|
<Dot
|
||||||
|
key={`dot-${path}-${position.x}-${position.y}`}
|
||||||
|
position={position}
|
||||||
|
selected={selected}
|
||||||
|
/>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
let nodeBasedOnType = null;
|
let nodeBasedOnType = null;
|
||||||
@@ -108,7 +114,7 @@ const SourceTree = props => {
|
|||||||
selectedNodeDependencies[path] &&
|
selectedNodeDependencies[path] &&
|
||||||
!selectedNodeDependencies[path].importedModuleNames.length
|
!selectedNodeDependencies[path].importedModuleNames.length
|
||||||
}
|
}
|
||||||
onNodeClick={e => onFileNodeClick(e, fileNode)}
|
onNodeClick={e => selectedNode !== fileNode && onFileNodeClick(e, fileNode)}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
} else if (type === DIR_NODE_TYPE) {
|
} else if (type === DIR_NODE_TYPE) {
|
||||||
|
|||||||
@@ -8,18 +8,23 @@ import { UnderLayer } from './UnderLayer';
|
|||||||
import './TreeDiagram.less';
|
import './TreeDiagram.less';
|
||||||
|
|
||||||
import { buildShiftToPoint } from '../../../core/dataBus/utils/geometry';
|
import { buildShiftToPoint } from '../../../core/dataBus/utils/geometry';
|
||||||
import {
|
import { getProjectMetadata, getSourceLayout } from '../../../core/dataBus/selectors';
|
||||||
getProjectMetadata,
|
|
||||||
getSourceLayout,
|
|
||||||
getCodeCrumbsUserChoice,
|
|
||||||
getNamespacesList
|
|
||||||
} from '../../../core/dataBus/selectors';
|
|
||||||
import { getCheckedState, getValuesState } from '../../../core/controlsBus/selectors';
|
import { getCheckedState, getValuesState } from '../../../core/controlsBus/selectors';
|
||||||
import { selectDependencyEdge, selectCcFlowEdge } from '../../../core/dataBus/actions';
|
import {
|
||||||
|
selectDependencyEdge,
|
||||||
|
selectCcFlowEdge,
|
||||||
|
saveTreeDiagramContentId
|
||||||
|
} from '../../../core/dataBus/actions';
|
||||||
import { setActiveNamespace } from '../../../core/namespaceIntegration/actions';
|
import { setActiveNamespace } from '../../../core/namespaceIntegration/actions';
|
||||||
import { gatherFlowStepsData, getMaxWidthForNs } from './Tree/CodeCrumbs/helpers';
|
import { getSharedFlowStepsData } from '../../../core/namespaceIntegration/selectors';
|
||||||
|
|
||||||
|
class TreeDiagram extends React.PureComponent {
|
||||||
|
componentDidUpdate(prevProps) {
|
||||||
|
if (!prevProps.layoutSize && this.props.layoutSize) {
|
||||||
|
this.props.saveContentId(this.treeDiagramContent.getAttribute('id'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class TreeDiagram extends React.Component {
|
|
||||||
render() {
|
render() {
|
||||||
// TODO: fix diagramZoom
|
// TODO: fix diagramZoom
|
||||||
const {
|
const {
|
||||||
@@ -50,7 +55,7 @@ class TreeDiagram extends React.Component {
|
|||||||
});
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={'TreeDiagram'}>
|
<div className={classNames('TreeDiagram', { border: multiple })}>
|
||||||
{multiple ? (
|
{multiple ? (
|
||||||
<p
|
<p
|
||||||
className={classNames('namespaceTitle', {
|
className={classNames('namespaceTitle', {
|
||||||
@@ -60,35 +65,41 @@ class TreeDiagram extends React.Component {
|
|||||||
{projectName}
|
{projectName}
|
||||||
</p>
|
</p>
|
||||||
) : null}
|
) : null}
|
||||||
<svg
|
<div
|
||||||
width={maxWidth || width}
|
id={`TreeDiagram-${namespace}-content`}
|
||||||
height={height}
|
className={'content'}
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
ref={el => (this.treeDiagramContent = el)}
|
||||||
shapeRendering="optimizeSpeed"
|
|
||||||
>
|
>
|
||||||
{sourceLayoutTree && (
|
<svg
|
||||||
<React.Fragment>
|
width={maxWidth || width}
|
||||||
<UnderLayer width={maxWidth || width} height={height} onClick={onUnderLayerClick} />
|
height={height}
|
||||||
<SourceTree
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
namespace={namespace}
|
shapeRendering="optimizeSpeed"
|
||||||
shiftToCenterPoint={shiftToCenterPoint}
|
>
|
||||||
areaHeight={height}
|
{sourceLayoutTree && (
|
||||||
sortedFlowSteps={sortedFlowSteps}
|
<React.Fragment>
|
||||||
involvedNsData={involvedNsData}
|
<UnderLayer width={maxWidth || width} height={height} onClick={onUnderLayerClick} />
|
||||||
ccShiftIndexMap={ccShiftIndexMap}
|
<SourceTree
|
||||||
/>
|
namespace={namespace}
|
||||||
</React.Fragment>
|
shiftToCenterPoint={shiftToCenterPoint}
|
||||||
)}
|
areaHeight={height}
|
||||||
</svg>
|
sortedFlowSteps={sortedFlowSteps}
|
||||||
{codeCrumbsDiagramOn ? (
|
involvedNsData={involvedNsData}
|
||||||
<CodeCrumbsExtraInfo
|
ccShiftIndexMap={ccShiftIndexMap}
|
||||||
namespace={namespace}
|
/>
|
||||||
shiftToCenterPoint={shiftToCenterPoint}
|
</React.Fragment>
|
||||||
ccShiftIndexMap={ccShiftIndexMap}
|
)}
|
||||||
sortedFlowSteps={sortedFlowSteps}
|
</svg>
|
||||||
flowSteps={flowSteps}
|
{codeCrumbsDiagramOn ? (
|
||||||
/>
|
<CodeCrumbsExtraInfo
|
||||||
) : null}
|
namespace={namespace}
|
||||||
|
shiftToCenterPoint={shiftToCenterPoint}
|
||||||
|
ccShiftIndexMap={ccShiftIndexMap}
|
||||||
|
sortedFlowSteps={sortedFlowSteps}
|
||||||
|
flowSteps={flowSteps}
|
||||||
|
/>
|
||||||
|
) : null}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -105,31 +116,7 @@ const mapStateToProps = (state, props) => {
|
|||||||
const { diagramZoom } = getValuesState(state);
|
const { diagramZoom } = getValuesState(state);
|
||||||
const { codeCrumbsDiagramOn } = getCheckedState(state);
|
const { codeCrumbsDiagramOn } = getCheckedState(state);
|
||||||
|
|
||||||
let extendedCcProps = {};
|
const extendedCcProps = codeCrumbsDiagramOn ? getSharedFlowStepsData(state) : {};
|
||||||
if (codeCrumbsDiagramOn) {
|
|
||||||
const codeCrumbsUserChoice = getCodeCrumbsUserChoice(state, {
|
|
||||||
namespace
|
|
||||||
});
|
|
||||||
|
|
||||||
const namespacesList = getNamespacesList(state);
|
|
||||||
const { flowSteps, sortedFlowSteps, involvedNsData, ccShiftIndexMap } = gatherFlowStepsData(
|
|
||||||
state,
|
|
||||||
{
|
|
||||||
currentSelectedCrumbedFlowKey: codeCrumbsUserChoice.selectedCrumbedFlowKey,
|
|
||||||
namespacesList
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
const maxWidth = getMaxWidthForNs(state, { namespacesList });
|
|
||||||
|
|
||||||
extendedCcProps = {
|
|
||||||
flowSteps,
|
|
||||||
sortedFlowSteps,
|
|
||||||
involvedNsData,
|
|
||||||
ccShiftIndexMap,
|
|
||||||
maxWidth
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
namespace,
|
namespace,
|
||||||
@@ -149,7 +136,8 @@ const mapDispatchToProps = (dispatch, props) => {
|
|||||||
dispatch(setActiveNamespace(namespace));
|
dispatch(setActiveNamespace(namespace));
|
||||||
dispatch(selectDependencyEdge(undefined, namespace));
|
dispatch(selectDependencyEdge(undefined, namespace));
|
||||||
dispatch(selectCcFlowEdge(undefined, namespace));
|
dispatch(selectCcFlowEdge(undefined, namespace));
|
||||||
}
|
},
|
||||||
|
saveContentId: ref => dispatch(saveTreeDiagramContentId(ref, namespace))
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,10 @@
|
|||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
overflow-y: hidden;
|
overflow-y: hidden;
|
||||||
border-bottom: 1px solid #ebedf0;
|
|
||||||
|
&.border {
|
||||||
|
border-bottom: 1px solid #ebedf0;
|
||||||
|
}
|
||||||
|
|
||||||
.namespaceTitle {
|
.namespaceTitle {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
@@ -14,6 +17,7 @@
|
|||||||
left: 0;
|
left: 0;
|
||||||
z-index: 2;
|
z-index: 2;
|
||||||
border-left: 1px solid #ebedf0;
|
border-left: 1px solid #ebedf0;
|
||||||
|
background: rgba(255,255,255,0.8);
|
||||||
font-size: 11px;
|
font-size: 11px;
|
||||||
|
|
||||||
&.activeTreeDiagram {
|
&.activeTreeDiagram {
|
||||||
@@ -22,7 +26,9 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
svg {
|
.content {
|
||||||
display: block;
|
svg {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,3 +24,8 @@ export const setZoom = payload => ({
|
|||||||
type: ACTIONS.SET_ZOOM,
|
type: ACTIONS.SET_ZOOM,
|
||||||
payload
|
payload
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export const setFullState = payload => ({
|
||||||
|
type: ACTIONS.SET_FULL_STATE,
|
||||||
|
payload
|
||||||
|
});
|
||||||
|
|||||||
@@ -7,8 +7,11 @@ import { getFoldersForPaths, downloadObjectAsJsonFile, uploadFileAsObject } from
|
|||||||
import {
|
import {
|
||||||
getTreeLayout,
|
getTreeLayout,
|
||||||
getFilesForCurrentCcFlow,
|
getFilesForCurrentCcFlow,
|
||||||
getCodeCrumbsMapForCurrentCcFlow
|
getCodeCrumbsMapForCurrentCcFlow,
|
||||||
|
getFileNodesMap,
|
||||||
|
getCodecrumbNodesMap
|
||||||
} from './utils/treeLayout';
|
} from './utils/treeLayout';
|
||||||
|
import { calculateLayoutProps } from './utils/geometry';
|
||||||
|
|
||||||
import { ACTIONS } from './constants';
|
import { ACTIONS } from './constants';
|
||||||
import {
|
import {
|
||||||
@@ -155,6 +158,7 @@ export const calcFilesTreeLayoutNodes = namespace => (dispatch, getState) => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
const {
|
const {
|
||||||
|
sourceDiagramOn,
|
||||||
codeCrumbsDiagramOn,
|
codeCrumbsDiagramOn,
|
||||||
codeCrumbsMinimize,
|
codeCrumbsMinimize,
|
||||||
codeCrumbsDetails,
|
codeCrumbsDetails,
|
||||||
@@ -172,16 +176,30 @@ export const calcFilesTreeLayoutNodes = namespace => (dispatch, getState) => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const sourceLayoutTree = getTreeLayout(sourceTree, {
|
||||||
|
includeFileChildren: codeCrumbsDiagramOn && !codeCrumbsMinimize,
|
||||||
|
extraSpaceForDetails: codeCrumbsDetails,
|
||||||
|
extraSpaceForCodePreview: codeCrumbsCodePreview,
|
||||||
|
openedFolders,
|
||||||
|
activeItemsMap,
|
||||||
|
activeCodeCrumbs
|
||||||
|
});
|
||||||
|
|
||||||
|
const filesLayoutMap = getFileNodesMap(sourceLayoutTree);
|
||||||
|
const codecrumbsLayoutMap = getCodecrumbNodesMap(filesLayoutMap);
|
||||||
|
const { ccAlightPoint, ...layoutSize } = calculateLayoutProps(sourceLayoutTree, {
|
||||||
|
sourceDiagramOn
|
||||||
|
});
|
||||||
|
|
||||||
return dispatch({
|
return dispatch({
|
||||||
type: ACTIONS.UPDATE_FILES_TREE_LAYOUT_NODES,
|
type: ACTIONS.UPDATE_FILES_TREE_LAYOUT_NODES,
|
||||||
payload: getTreeLayout(sourceTree, {
|
payload: {
|
||||||
includeFileChildren: codeCrumbsDiagramOn && !codeCrumbsMinimize,
|
sourceLayoutTree,
|
||||||
extraSpaceForDetails: codeCrumbsDetails,
|
filesLayoutMap,
|
||||||
extraSpaceForCodePreview: codeCrumbsCodePreview,
|
codecrumbsLayoutMap,
|
||||||
openedFolders,
|
ccAlightPoint,
|
||||||
activeItemsMap,
|
layoutSize
|
||||||
activeCodeCrumbs
|
},
|
||||||
}),
|
|
||||||
namespace
|
namespace
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -339,3 +357,19 @@ export const setPredefinedState = predefinedState => dispatch => {
|
|||||||
}, 100 * i);
|
}, 100 * i);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const saveTreeDiagramContentId = (payload, namespace) => ({
|
||||||
|
type: ACTIONS.SAVE_TREE_DIAGRAM_CONTENT_ID,
|
||||||
|
payload,
|
||||||
|
namespace
|
||||||
|
});
|
||||||
|
|
||||||
|
export const setFullState = payload => ({
|
||||||
|
type: ACTIONS.SET_FULL_STATE,
|
||||||
|
payload
|
||||||
|
});
|
||||||
|
|
||||||
|
export const setNamespaceState = payload => ({
|
||||||
|
type: ACTIONS.SET_NAMESPACE_STATE,
|
||||||
|
payload
|
||||||
|
});
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
export const ACTIONS = {
|
export const ACTIONS = {
|
||||||
SET_INITIAL_SOURCE_DATA: 'DATA_BUS.SET_INITIAL_SOURCE_DATA',
|
SET_INITIAL_SOURCE_DATA: 'DATA_BUS.SET_INITIAL_SOURCE_DATA',
|
||||||
|
SET_FULL_STATE: 'DATA_BUS.SET_FULL_STATE',
|
||||||
|
SET_NAMESPACE_STATE: 'DATA_BUS.SET_NAMESPACE_STATE',
|
||||||
RESET_ALL: 'DATA_BUS.RESET_ALL',
|
RESET_ALL: 'DATA_BUS.RESET_ALL',
|
||||||
SET_CHANGED_SOURCE_DATA: 'DATA_BUS.SET_CHANGED_SOURCE_DATA',
|
SET_CHANGED_SOURCE_DATA: 'DATA_BUS.SET_CHANGED_SOURCE_DATA',
|
||||||
UPDATE_FILES_TREE_LAYOUT_NODES: 'DATA_BUS.UPDATE_FILES_TREE_LAYOUT_NODES',
|
UPDATE_FILES_TREE_LAYOUT_NODES: 'DATA_BUS.UPDATE_FILES_TREE_LAYOUT_NODES',
|
||||||
@@ -14,5 +16,6 @@ export const ACTIONS = {
|
|||||||
SET_DEPENDENCIES_ENTRY_POINT: 'DATA_BUS.SET_DEPENDENCIES_ENTRY_POINT',
|
SET_DEPENDENCIES_ENTRY_POINT: 'DATA_BUS.SET_DEPENDENCIES_ENTRY_POINT',
|
||||||
SELECT_DEPENDENCY_EDGE: 'DATA_BUS.SELECT_DEPENDENCY_EDGE',
|
SELECT_DEPENDENCY_EDGE: 'DATA_BUS.SELECT_DEPENDENCY_EDGE',
|
||||||
SELECT_CC_FLOW_EDGE: 'DATA_BUS.SELECT_CC_FLOW_EDGE',
|
SELECT_CC_FLOW_EDGE: 'DATA_BUS.SELECT_CC_FLOW_EDGE',
|
||||||
UPDATE_FILES: 'DATA_BUS.UPDATE_FILES'
|
UPDATE_FILES: 'DATA_BUS.UPDATE_FILES',
|
||||||
|
SAVE_TREE_DIAGRAM_CONTENT_ID: 'DATA_BUS.SAVE_TREE_DIAGRAM_CONTENT_ID'
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import {
|
|||||||
updateFiles
|
updateFiles
|
||||||
} from './actions';
|
} from './actions';
|
||||||
|
|
||||||
class DataBusContainer extends React.Component {
|
class DataBusContainer extends React.PureComponent {
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
const { standalone } = this.props;
|
const { standalone } = this.props;
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
import { FOLDER_OPEN_STATE } from '../constants';
|
import { FOLDER_OPEN_STATE } from '../constants';
|
||||||
|
|
||||||
import { ACTIONS } from './constants';
|
import { ACTIONS } from './constants';
|
||||||
import { getFileNodesMap, getCodecrumbNodesMap } from './utils/treeLayout';
|
|
||||||
import { calculateLayoutProps } from './utils/geometry';
|
|
||||||
|
|
||||||
const DefaultState = {};
|
const DefaultState = {};
|
||||||
|
|
||||||
@@ -36,7 +34,7 @@ export const getMergeState = (state, namespace) => namespaceStateUpdate => ({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const FULL_FEATURES_LANG_LIST = ['javascript', 'typescript'];
|
const FULL_FEATURES_LANG_LIST = ['javascript', 'typescript', 'php'];
|
||||||
|
|
||||||
export default (state = DefaultState, action) => {
|
export default (state = DefaultState, action) => {
|
||||||
const namespace = action.namespace;
|
const namespace = action.namespace;
|
||||||
@@ -65,18 +63,9 @@ export default (state = DefaultState, action) => {
|
|||||||
return mergeState(action.payload);
|
return mergeState(action.payload);
|
||||||
|
|
||||||
case ACTIONS.UPDATE_FILES_TREE_LAYOUT_NODES: {
|
case ACTIONS.UPDATE_FILES_TREE_LAYOUT_NODES: {
|
||||||
const { payload: sourceLayoutTree } = action;
|
const { payload } = action;
|
||||||
|
|
||||||
const { ccAlightPoint, ...layoutSize } = calculateLayoutProps(sourceLayoutTree);
|
|
||||||
const filesLayoutMap = getFileNodesMap(sourceLayoutTree);
|
|
||||||
const codecrumbsLayoutMap = getCodecrumbNodesMap(filesLayoutMap);
|
|
||||||
|
|
||||||
return mergeState({
|
return mergeState({
|
||||||
sourceLayoutTree,
|
...payload
|
||||||
layoutSize,
|
|
||||||
filesLayoutMap,
|
|
||||||
codecrumbsLayoutMap,
|
|
||||||
ccAlightPoint
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -161,10 +150,9 @@ export default (state = DefaultState, action) => {
|
|||||||
const { fileNode } = action.payload;
|
const { fileNode } = action.payload;
|
||||||
const dependenciesEntryName = fileNode ? fileNode.path : namespaceState.dependenciesEntryName;
|
const dependenciesEntryName = fileNode ? fileNode.path : namespaceState.dependenciesEntryName;
|
||||||
|
|
||||||
// do some reducerr
|
// do some reducer
|
||||||
return mergeState({
|
return mergeState({
|
||||||
dependenciesEntryName,
|
dependenciesEntryName,
|
||||||
selectedDependencyEdgeNodes: null
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -195,6 +183,22 @@ export default (state = DefaultState, action) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
case ACTIONS.SAVE_TREE_DIAGRAM_CONTENT_ID:
|
||||||
|
return mergeState({
|
||||||
|
treeDiagramContentId: action.payload
|
||||||
|
});
|
||||||
|
|
||||||
|
case ACTIONS.SET_FULL_STATE:
|
||||||
|
return {
|
||||||
|
...state,
|
||||||
|
...action.payload
|
||||||
|
};
|
||||||
|
|
||||||
|
case ACTIONS.SET_NAMESPACE_STATE:
|
||||||
|
return mergeState({
|
||||||
|
...action.payload
|
||||||
|
});
|
||||||
|
|
||||||
case ACTIONS.RESET_ALL:
|
case ACTIONS.RESET_ALL:
|
||||||
return DefaultState;
|
return DefaultState;
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,11 @@ export const getProjectMetadata = createSelector([getNamespaceState], namespaceS
|
|||||||
return { projectName, language, platformPathSeparator, fullFeaturesSupport };
|
return { projectName, language, platformPathSeparator, fullFeaturesSupport };
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export const getTreeDiagramContentId = createSelector([getNamespaceState], namespaceState => {
|
||||||
|
const { treeDiagramContentId } = namespaceState;
|
||||||
|
return { id: treeDiagramContentId };
|
||||||
|
});
|
||||||
|
|
||||||
export const getSource = createSelector([getNamespaceState], namespaceState => {
|
export const getSource = createSelector([getNamespaceState], namespaceState => {
|
||||||
const { sourceTree, filesMap, foldersMap } = namespaceState;
|
const { sourceTree, filesMap, foldersMap } = namespaceState;
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { CC_NODE_TYPE } from '../../constants';
|
import { CC_NODE_TYPE } from '../../constants';
|
||||||
|
|
||||||
export const calculateLayoutProps = (list, padding = 100) => {
|
export const calculateLayoutProps = (list, { sourceDiagramOn }) => {
|
||||||
if (!list) {
|
if (!list) {
|
||||||
return {
|
return {
|
||||||
width: 0,
|
width: 0,
|
||||||
@@ -35,25 +35,29 @@ export const calculateLayoutProps = (list, padding = 100) => {
|
|||||||
minX = x;
|
minX = x;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (y - ySize / 2 < minY) {
|
if (y < minY) {
|
||||||
minY = y - ySize / 2;
|
minY = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (x + xSize > maxX) {
|
if (x + xSize > maxX) {
|
||||||
maxX = x + xSize;
|
maxX = x + xSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (y + ySize / 2 > maxY) {
|
if (y + ySize > maxY) {
|
||||||
maxY = y + ySize / 2;
|
maxY = y + ySize;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const yShift = Math.abs(Math.round(minY)) + 20;
|
||||||
|
const height = Math.round(Math.abs(maxY) + Math.abs(yShift)) + 5;
|
||||||
|
const width = Math.round(Math.abs(maxX + maxCcWidth) + Math.abs(minX) + 2 * 20);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
width: Math.round(Math.abs(maxX + maxCcWidth) + Math.abs(minX) + 2 * padding),
|
xShift: 5,
|
||||||
height: Math.round(Math.abs(maxY) + Math.abs(minY) + 2 * padding),
|
width,
|
||||||
xShift: padding / 4,
|
height,
|
||||||
yShift: Math.abs(Math.round(minY)) > 2 * padding ? Math.abs(Math.round(minY)) : 2 * padding,
|
yShift,
|
||||||
ccAlightPoint
|
ccAlightPoint: sourceDiagramOn ? ccAlightPoint : 50
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -69,6 +69,8 @@ export const getTreeLayout = (
|
|||||||
}, 0);
|
}, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: calc properly, not 5000
|
||||||
|
// impossible to do in one loop
|
||||||
const LARGE_WIDTH_CC = 5000;
|
const LARGE_WIDTH_CC = 5000;
|
||||||
const widthSpace =
|
const widthSpace =
|
||||||
node.data.type !== DIR_NODE_TYPE && node.data.type !== FILE_NODE_TYPE
|
node.data.type !== DIR_NODE_TYPE && node.data.type !== FILE_NODE_TYPE
|
||||||
|
|||||||
@@ -1,6 +1,32 @@
|
|||||||
import { ACTIONS } from './constants';
|
import { ACTIONS } from './constants';
|
||||||
|
import { gatherFlowStepsData } from './utils/sharedCcFlows';
|
||||||
|
import { getCodeCrumbsUserChoice, getNamespacesList } from '../dataBus/selectors';
|
||||||
|
import { getActiveNamespace } from './selectors';
|
||||||
|
|
||||||
export const setActiveNamespace = payload => ({
|
export const setActiveNamespace = payload => ({
|
||||||
type: ACTIONS.SET_ACTIVE_NAMESPACE,
|
type: ACTIONS.SET_ACTIVE_NAMESPACE,
|
||||||
payload
|
payload
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export const calcSharedFlowStepsData = () => (dispatch, getState) => {
|
||||||
|
const state = getState();
|
||||||
|
|
||||||
|
const namespace = getActiveNamespace(state);
|
||||||
|
const namespacesList = getNamespacesList(state);
|
||||||
|
const { selectedCrumbedFlowKey: currentSelectedCrumbedFlowKey } = getCodeCrumbsUserChoice(state, {
|
||||||
|
namespace
|
||||||
|
});
|
||||||
|
|
||||||
|
dispatch({
|
||||||
|
type: ACTIONS.CALC_SHARED_FLOW_STEPS_DATA,
|
||||||
|
payload: gatherFlowStepsData(state, {
|
||||||
|
currentSelectedCrumbedFlowKey,
|
||||||
|
namespacesList
|
||||||
|
})
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
export const setFullState = payload => ({
|
||||||
|
type: ACTIONS.SET_FULL_STATE,
|
||||||
|
payload
|
||||||
|
});
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
export const ACTIONS = {
|
export const ACTIONS = {
|
||||||
SET_ACTIVE_NAMESPACE: 'NAMESPACE_INTEGRATION.SET_ACTIVE_NAMESPACE',
|
SET_ACTIVE_NAMESPACE: 'NAMESPACE_INTEGRATION.SET_ACTIVE_NAMESPACE',
|
||||||
|
CALC_SHARED_FLOW_STEPS_DATA: 'NAMESPACE_INTEGRATION.CALC_SHARED_FLOW_STEPS_DATA',
|
||||||
|
SET_FULL_STATE: 'NAMESPACE_INTEGRATION.SET_FULL_STATE',
|
||||||
RESET_ALL: 'NAMESPACE_INTEGRATION.RESET_ALL'
|
RESET_ALL: 'NAMESPACE_INTEGRATION.RESET_ALL'
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
import { ACTIONS } from './constants';
|
import { ACTIONS } from './constants';
|
||||||
|
|
||||||
const DefaultState = {
|
const DefaultState = {
|
||||||
activeNamespace: undefined
|
activeNamespace: undefined,
|
||||||
|
sharedFlowStepsData: null
|
||||||
};
|
};
|
||||||
|
|
||||||
export default (state = DefaultState, action) => {
|
export default (state = DefaultState, action) => {
|
||||||
@@ -12,6 +13,18 @@ export default (state = DefaultState, action) => {
|
|||||||
activeNamespace: action.payload
|
activeNamespace: action.payload
|
||||||
};
|
};
|
||||||
|
|
||||||
|
case ACTIONS.CALC_SHARED_FLOW_STEPS_DATA:
|
||||||
|
return {
|
||||||
|
...state,
|
||||||
|
sharedFlowStepsData: action.payload
|
||||||
|
};
|
||||||
|
|
||||||
|
case ACTIONS.SET_FULL_STATE:
|
||||||
|
return {
|
||||||
|
...state,
|
||||||
|
...action.payload
|
||||||
|
};
|
||||||
|
|
||||||
case ACTIONS.RESET_ALL:
|
case ACTIONS.RESET_ALL:
|
||||||
return DefaultState;
|
return DefaultState;
|
||||||
|
|
||||||
|
|||||||
@@ -1 +1,2 @@
|
|||||||
export const getActiveNamespace = state => state.namespaceIntegration.activeNamespace;
|
export const getActiveNamespace = state => state.namespaceIntegration.activeNamespace;
|
||||||
|
export const getSharedFlowStepsData = state => state.namespaceIntegration.sharedFlowStepsData;
|
||||||
|
|||||||
@@ -0,0 +1,99 @@
|
|||||||
|
import { getCodeCrumbsUserChoice, getSourceLayout } from '../../dataBus/selectors';
|
||||||
|
import { NO_TRAIL_FLOW } from '../../../shared-constants';
|
||||||
|
|
||||||
|
export const gatherFlowStepsData = (state, { namespacesList, currentSelectedCrumbedFlowKey }) => {
|
||||||
|
const flowStepsData = namespacesList.reduce(
|
||||||
|
(acc, ns) => {
|
||||||
|
const namespaceProps = { namespace: ns };
|
||||||
|
const { selectedCrumbedFlowKey, codeCrumbedFlowsMap } = getCodeCrumbsUserChoice(
|
||||||
|
state,
|
||||||
|
namespaceProps
|
||||||
|
);
|
||||||
|
|
||||||
|
if (currentSelectedCrumbedFlowKey !== selectedCrumbedFlowKey) {
|
||||||
|
return acc;
|
||||||
|
}
|
||||||
|
|
||||||
|
const { codecrumbsLayoutMap, ccAlightPoint } = getSourceLayout(state, namespaceProps);
|
||||||
|
|
||||||
|
const flowSteps = getFlowSteps({
|
||||||
|
namespace: ns,
|
||||||
|
codeCrumbedFlowsMap,
|
||||||
|
selectedCrumbedFlowKey,
|
||||||
|
codecrumbsLayoutMap
|
||||||
|
});
|
||||||
|
|
||||||
|
return {
|
||||||
|
flowSteps,
|
||||||
|
sortedFlowSteps:
|
||||||
|
selectedCrumbedFlowKey !== NO_TRAIL_FLOW
|
||||||
|
? [...acc.sortedFlowSteps, ...flowSteps].sort(stepSorter)
|
||||||
|
: [],
|
||||||
|
involvedNsData: {
|
||||||
|
...acc.involvedNsData,
|
||||||
|
[ns]: { codecrumbsLayoutMap, ccAlightPoint }
|
||||||
|
}
|
||||||
|
};
|
||||||
|
},
|
||||||
|
{ involvedNsData: {}, flowSteps: [], sortedFlowSteps: [] }
|
||||||
|
);
|
||||||
|
|
||||||
|
return {
|
||||||
|
...flowStepsData,
|
||||||
|
ccShiftIndexMap: createCcShiftIndexMap(flowStepsData.sortedFlowSteps),
|
||||||
|
maxWidth: getMaxWidthForNs(state, { namespacesList })
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
const stepSorter = (a, b) => a.step - b.step;
|
||||||
|
|
||||||
|
const getFlowSteps = ({
|
||||||
|
namespace,
|
||||||
|
codeCrumbedFlowsMap,
|
||||||
|
selectedCrumbedFlowKey,
|
||||||
|
codecrumbsLayoutMap
|
||||||
|
}) => {
|
||||||
|
const currentFlow = codeCrumbedFlowsMap[selectedCrumbedFlowKey] || {};
|
||||||
|
|
||||||
|
return Object.keys(currentFlow).reduce((flowSteps, filePath) => {
|
||||||
|
const steps = ((codecrumbsLayoutMap[filePath] && codecrumbsLayoutMap[filePath].children) || [])
|
||||||
|
.filter(({ data }) => data.params.flow === selectedCrumbedFlowKey)
|
||||||
|
.map(({ data, x, y }) => ({
|
||||||
|
...data,
|
||||||
|
namespace,
|
||||||
|
filePath,
|
||||||
|
step: data.params.flowStep,
|
||||||
|
flow: selectedCrumbedFlowKey,
|
||||||
|
x,
|
||||||
|
y
|
||||||
|
}));
|
||||||
|
|
||||||
|
return [...flowSteps, ...steps];
|
||||||
|
}, []);
|
||||||
|
};
|
||||||
|
|
||||||
|
const createCcShiftIndexMap = sortedFlowSteps => {
|
||||||
|
const ccMap = {};
|
||||||
|
let shiftOrderIndex = 0;
|
||||||
|
|
||||||
|
sortedFlowSteps.forEach((crumb, i, list) => {
|
||||||
|
if (!i) {
|
||||||
|
ccMap[crumb.id] = shiftOrderIndex;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (crumb.x < list[i - 1].x) {
|
||||||
|
shiftOrderIndex++;
|
||||||
|
}
|
||||||
|
|
||||||
|
ccMap[crumb.id] = shiftOrderIndex;
|
||||||
|
});
|
||||||
|
|
||||||
|
return ccMap;
|
||||||
|
};
|
||||||
|
|
||||||
|
const getMaxWidthForNs = (state, { namespacesList }) =>
|
||||||
|
namespacesList.reduce((maxWidth, namespace) => {
|
||||||
|
const { layoutSize } = getSourceLayout(state, { namespace }); // TODO: double select for getSourceLayout, use from above
|
||||||
|
return layoutSize && layoutSize.width > maxWidth ? layoutSize.width : maxWidth;
|
||||||
|
}, 0);
|
||||||
@@ -17,7 +17,8 @@ import { ACTIONS as SWITCHES_ACTIONS, CONTROLS_KEYS } from '../controlsBus/const
|
|||||||
import { setDisabledControl, toggleSwitch } from '../controlsBus/actions';
|
import { setDisabledControl, toggleSwitch } from '../controlsBus/actions';
|
||||||
import { getCheckedState } from '../controlsBus/selectors';
|
import { getCheckedState } from '../controlsBus/selectors';
|
||||||
|
|
||||||
import { setActiveNamespace } from '../namespaceIntegration/actions';
|
import { getActiveNamespace } from '../namespaceIntegration/selectors';
|
||||||
|
import { setActiveNamespace, calcSharedFlowStepsData } from '../namespaceIntegration/actions';
|
||||||
|
|
||||||
function* reactOnSwitchToggle(action) {
|
function* reactOnSwitchToggle(action) {
|
||||||
const namespacesList = yield select(getNamespacesList);
|
const namespacesList = yield select(getNamespacesList);
|
||||||
@@ -29,6 +30,20 @@ function* reactOnSwitchToggle(action) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function* applyReactionOnSwitchToggleToNamespace({ switchKey, checked, namespace }) {
|
function* applyReactionOnSwitchToggleToNamespace({ switchKey, checked, namespace }) {
|
||||||
|
if (switchKey === CONTROLS_KEYS.SOURCE_DIAGRAM_ON) {
|
||||||
|
if (!checked) {
|
||||||
|
yield all([
|
||||||
|
put(toggleSwitch(CONTROLS_KEYS.DEPENDENCIES_DIAGRAM_ON, false)),
|
||||||
|
put(setDisabledControl(CONTROLS_KEYS.DEPENDENCIES_DIAGRAM_ON, true))
|
||||||
|
]);
|
||||||
|
} else {
|
||||||
|
yield all([
|
||||||
|
put(setDisabledControl(CONTROLS_KEYS.DEPENDENCIES_DIAGRAM_ON, false)),
|
||||||
|
reactByUpdatingFoldersState({ namespace })
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (switchKey === CONTROLS_KEYS.SOURCE_KEEP_ONLY_ACTIVE_ITEMS) {
|
if (switchKey === CONTROLS_KEYS.SOURCE_KEEP_ONLY_ACTIVE_ITEMS) {
|
||||||
if (checked) {
|
if (checked) {
|
||||||
yield reactByUpdatingFoldersState({ namespace });
|
yield reactByUpdatingFoldersState({ namespace });
|
||||||
@@ -102,14 +117,24 @@ function* applyReactionOnButtonActionToNamespace({ buttonKey, namespace }) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function* reactOnUpdateFiles({namespace}) {
|
||||||
|
const {dependenciesShowDirectOnly} = yield select(getCheckedState)
|
||||||
|
if (dependenciesShowDirectOnly) {
|
||||||
|
yield put(setDependenciesEntryPoint(undefined, namespace))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function* reactOnToggledFolder({ namespace }) {
|
function* reactOnToggledFolder({ namespace }) {
|
||||||
yield put(calcFilesTreeLayoutNodes(namespace));
|
yield put(calcFilesTreeLayoutNodes(namespace));
|
||||||
}
|
}
|
||||||
|
|
||||||
function* reactOnSourceSet({ namespace }) {
|
function* reactOnSourceSet({ namespace }) {
|
||||||
const { dependenciesDiagramOn, codeCrumbsDiagramOn } = yield select(getCheckedState);
|
const { dependenciesDiagramOn, codeCrumbsDiagramOn } = yield select(getCheckedState);
|
||||||
|
const activeNamespace = yield select(getActiveNamespace);
|
||||||
|
|
||||||
yield put(setActiveNamespace(namespace));
|
if (activeNamespace !== namespace) {
|
||||||
|
yield put(setActiveNamespace(namespace));
|
||||||
|
}
|
||||||
|
|
||||||
if (!dependenciesDiagramOn && !codeCrumbsDiagramOn) {
|
if (!dependenciesDiagramOn && !codeCrumbsDiagramOn) {
|
||||||
yield reactByUpdatingFoldersState({ namespace });
|
yield reactByUpdatingFoldersState({ namespace });
|
||||||
@@ -129,6 +154,13 @@ function* reactByUpdatingFoldersState({ namespace }) {
|
|||||||
yield put(calcFilesTreeLayoutNodes(namespace));
|
yield put(calcFilesTreeLayoutNodes(namespace));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function* reactByCalcSharedFlowStepsData() {
|
||||||
|
const { codeCrumbsDiagramOn } = yield select(getCheckedState);
|
||||||
|
if (codeCrumbsDiagramOn) {
|
||||||
|
yield put(calcSharedFlowStepsData());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: will work if switches per namespace as well
|
// TODO: will work if switches per namespace as well
|
||||||
/*function* reactByDisablingFeatures({ payload }) {
|
/*function* reactByDisablingFeatures({ payload }) {
|
||||||
const { fullFeaturesSupport } = yield select(state =>
|
const { fullFeaturesSupport } = yield select(state =>
|
||||||
@@ -147,8 +179,11 @@ function* reactOnCcFlowEdgeSelect({ payload, namespace }) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function* reactBySettingActiveNamespace({ payload, namespace }) {
|
function* reactBySettingActiveNamespace({ namespace }) {
|
||||||
yield put(setActiveNamespace(namespace));
|
const activeNamespace = yield select(getActiveNamespace);
|
||||||
|
if (activeNamespace !== namespace) {
|
||||||
|
yield put(setActiveNamespace(namespace));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function* rootSaga() {
|
export default function* rootSaga() {
|
||||||
@@ -160,9 +195,10 @@ export default function* rootSaga() {
|
|||||||
takeLatest(DATA_BUS_ACTIONS.SET_CHANGED_SOURCE_DATA, reactOnSourceSet),
|
takeLatest(DATA_BUS_ACTIONS.SET_CHANGED_SOURCE_DATA, reactOnSourceSet),
|
||||||
takeLatest(DATA_BUS_ACTIONS.SET_DEPENDENCIES_ENTRY_POINT, reactByUpdatingFoldersState),
|
takeLatest(DATA_BUS_ACTIONS.SET_DEPENDENCIES_ENTRY_POINT, reactByUpdatingFoldersState),
|
||||||
takeLatest(DATA_BUS_ACTIONS.SELECT_CODE_CRUMBED_FLOW, reactByUpdatingFoldersState),
|
takeLatest(DATA_BUS_ACTIONS.SELECT_CODE_CRUMBED_FLOW, reactByUpdatingFoldersState),
|
||||||
takeLatest(DATA_BUS_ACTIONS.UPDATE_FILES, reactByUpdatingFoldersState),
|
|
||||||
takeLatest(DATA_BUS_ACTIONS.SELECT_CC_FLOW_EDGE, reactOnCcFlowEdgeSelect),
|
takeLatest(DATA_BUS_ACTIONS.SELECT_CC_FLOW_EDGE, reactOnCcFlowEdgeSelect),
|
||||||
takeLatest(DATA_BUS_ACTIONS.SELECT_NODE, reactBySettingActiveNamespace),
|
takeLatest(DATA_BUS_ACTIONS.SELECT_NODE, reactBySettingActiveNamespace),
|
||||||
takeLatest(DATA_BUS_ACTIONS.SELECT_CODE_CRUMB, reactBySettingActiveNamespace)
|
takeLatest(DATA_BUS_ACTIONS.UPDATE_FILES, reactOnUpdateFiles),
|
||||||
|
takeLatest(DATA_BUS_ACTIONS.SELECT_CODE_CRUMB, reactBySettingActiveNamespace),
|
||||||
|
takeLatest(DATA_BUS_ACTIONS.UPDATE_FILES_TREE_LAYOUT_NODES, reactByCalcSharedFlowStepsData)
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,8 @@ module.exports = merge(common, {
|
|||||||
openAnalyzer: false
|
openAnalyzer: false
|
||||||
}),
|
}),
|
||||||
new webpack.DefinePlugin({
|
new webpack.DefinePlugin({
|
||||||
'process.env.LOCAL': JSON.stringify(true)
|
'process.env.LOCAL': JSON.stringify(true),
|
||||||
|
'process.env.DEV': JSON.stringify(true)
|
||||||
})
|
})
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -4,12 +4,21 @@ const { getLanguageParsers } = require('./language');
|
|||||||
const parseFile = (
|
const parseFile = (
|
||||||
itemPath,
|
itemPath,
|
||||||
projectDir,
|
projectDir,
|
||||||
{ parseCodeCrumbs, parseImports, parseDependencies, attachCode, language, webpackConfigPath, tsConfigPath } = {}
|
{
|
||||||
|
parseCodeCrumbs,
|
||||||
|
parseImports,
|
||||||
|
parseDependencies,
|
||||||
|
attachCode,
|
||||||
|
language,
|
||||||
|
webpackConfigPath,
|
||||||
|
tsConfigPath
|
||||||
|
} = {}
|
||||||
) => {
|
) => {
|
||||||
const { codecrumbsParser, dependenciesParser } = getLanguageParsers(language);
|
const { codecrumbsParser, dependenciesParser } = getLanguageParsers(language);
|
||||||
|
|
||||||
return Promise.all([
|
return Promise.all([
|
||||||
parseDependencies && dependenciesParser.getDependencies(itemPath, projectDir, {webpackConfigPath, tsConfigPath}),
|
parseDependencies &&
|
||||||
|
dependenciesParser.getDependencies(itemPath, projectDir, { webpackConfigPath, tsConfigPath }),
|
||||||
file.read(itemPath, 'utf8')
|
file.read(itemPath, 'utf8')
|
||||||
]).then(([dependencies, code]) => {
|
]).then(([dependencies, code]) => {
|
||||||
const item = {
|
const item = {
|
||||||
@@ -37,7 +46,7 @@ const parseFile = (
|
|||||||
item.flows = undefined;
|
item.flows = undefined;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parseImports) {
|
if (parseImports) {
|
||||||
const importedDependencies = dependenciesParser.getImports(code, itemPath);
|
const importedDependencies = dependenciesParser.getImports(code, itemPath);
|
||||||
if (importedDependencies.length) {
|
if (importedDependencies.length) {
|
||||||
|
|||||||
@@ -1,7 +1,4 @@
|
|||||||
const { setupGetCrumbs, setupGetCommentsFromCode } = require('../default/codecrumbs');
|
const { getCrumbs } = require('../default/codecrumbs');
|
||||||
|
|
||||||
const CPP_COMMENT_REGEX = /^([^\/\/]*)\/\/(.*)$/;
|
|
||||||
const getCrumbs = setupGetCrumbs(setupGetCommentsFromCode(CPP_COMMENT_REGEX));
|
|
||||||
|
|
||||||
// replace with own implementation if needed
|
// replace with own implementation if needed
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
|||||||
@@ -1,8 +1,4 @@
|
|||||||
const { setupGetCrumbs, setupGetCommentsFromCode } = require('../default/codecrumbs');
|
const { getCrumbs } = require('../default/codecrumbs');
|
||||||
|
|
||||||
const CSHARP_COMMENT_REGEX = /^([^\/\/]*)\/\/(.*)$/;
|
|
||||||
const getCrumbs = setupGetCrumbs(setupGetCommentsFromCode(CSHARP_COMMENT_REGEX));
|
|
||||||
|
|
||||||
// replace with own implementation if needed
|
// replace with own implementation if needed
|
||||||
module.exports = {
|
module.exports = {
|
||||||
getCrumbs
|
getCrumbs
|
||||||
|
|||||||
@@ -1,7 +1,4 @@
|
|||||||
const { setupGetCrumbs, setupGetCommentsFromCode } = require('../default/codecrumbs');
|
const { getCrumbs } = require('../default/codecrumbs');
|
||||||
|
|
||||||
const GOLANG_COMMENT_REGEX = /^([^\/\/]*)\/\/(.*)$/
|
|
||||||
const getCrumbs = setupGetCrumbs(setupGetCommentsFromCode(GOLANG_COMMENT_REGEX));
|
|
||||||
|
|
||||||
// replace with own implementation if needed
|
// replace with own implementation if needed
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ const LANGUAGES = [
|
|||||||
'java',
|
'java',
|
||||||
'javascript',
|
'javascript',
|
||||||
'kotlin',
|
'kotlin',
|
||||||
|
'lua',
|
||||||
'ocaml',
|
'ocaml',
|
||||||
'perl',
|
'perl',
|
||||||
'php',
|
'php',
|
||||||
|
|||||||
@@ -1,7 +1,4 @@
|
|||||||
const { setupGetCrumbs, setupGetCommentsFromCode } = require('../default/codecrumbs');
|
const { getCrumbs } = require('../default/codecrumbs');
|
||||||
|
|
||||||
const JAVA_COMMENT_REGEX = /^([^\/\/]*)\/\/(.*)$/;
|
|
||||||
const getCrumbs = setupGetCrumbs(setupGetCommentsFromCode(JAVA_COMMENT_REGEX));
|
|
||||||
|
|
||||||
// replace with own implementation if needed
|
// replace with own implementation if needed
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
|||||||
@@ -23,11 +23,9 @@ const getCrumbs = (fileCode, path) => {
|
|||||||
}
|
}
|
||||||
};*/
|
};*/
|
||||||
|
|
||||||
const { setupGetCrumbs, setupGetCommentsFromCode } = require('../default/codecrumbs');
|
const { getCrumbs } = require('../default/codecrumbs');
|
||||||
|
|
||||||
const JAVA_SCRIPT_COMMENT_REGEX = /^([^\/\/]*)\/\/(.*)$/;
|
|
||||||
const getCrumbs = setupGetCrumbs(setupGetCommentsFromCode(JAVA_SCRIPT_COMMENT_REGEX));
|
|
||||||
|
|
||||||
|
// replace with own implementation if needed
|
||||||
module.exports = {
|
module.exports = {
|
||||||
getCrumbs
|
getCrumbs
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,7 +1,4 @@
|
|||||||
const { setupGetCrumbs, setupGetCommentsFromCode } = require('../default/codecrumbs');
|
const { getCrumbs } = require('../default/codecrumbs');
|
||||||
|
|
||||||
const KOTLIN_COMMENT_REGEX = /^([^\/\/]*)\/\/(.*)$/;
|
|
||||||
const getCrumbs = setupGetCrumbs(setupGetCommentsFromCode(KOTLIN_COMMENT_REGEX));
|
|
||||||
|
|
||||||
// replace with own implementation if needed
|
// replace with own implementation if needed
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
|||||||
9
src/server/code-parse/language/lua/codecrumbs.js
Normal file
9
src/server/code-parse/language/lua/codecrumbs.js
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
const { setupGetCrumbs, setupGetCommentsFromCode } = require('../default/codecrumbs');
|
||||||
|
|
||||||
|
const LUA_COMMENT_REGEX = /^([^--]*)--(.*)$/;
|
||||||
|
const getCrumbs = setupGetCrumbs(setupGetCommentsFromCode(LUA_COMMENT_REGEX));
|
||||||
|
|
||||||
|
// replace with own implementation if needed
|
||||||
|
module.exports = {
|
||||||
|
getCrumbs
|
||||||
|
};
|
||||||
7
src/server/code-parse/language/lua/dependencies.js
Normal file
7
src/server/code-parse/language/lua/dependencies.js
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
const defaultDependencies = require('../default/dependencies');
|
||||||
|
|
||||||
|
// replace with own implementation if needed
|
||||||
|
module.exports = {
|
||||||
|
getImports: defaultDependencies.getImports,
|
||||||
|
getDependencies: defaultDependencies.getDependencies
|
||||||
|
};
|
||||||
1
src/server/code-parse/language/lua/extensions.js
Normal file
1
src/server/code-parse/language/lua/extensions.js
Normal file
@@ -0,0 +1 @@
|
|||||||
|
module.exports = /\.(lua|luac)$/;
|
||||||
@@ -1,7 +1,4 @@
|
|||||||
const { setupGetCrumbs, setupGetCommentsFromCode } = require('../default/codecrumbs');
|
const { getCrumbs } = require('../default/codecrumbs');
|
||||||
|
|
||||||
const PHP_COMMENT_REGEX = /^([^\/\/]*)\/\/(.*)$/;
|
|
||||||
const getCrumbs = setupGetCrumbs(setupGetCommentsFromCode(PHP_COMMENT_REGEX));
|
|
||||||
|
|
||||||
// replace with own implementation if needed
|
// replace with own implementation if needed
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
|||||||
@@ -1,7 +1,70 @@
|
|||||||
const defaultDependencies = require('../default/dependencies');
|
const path = require('path');
|
||||||
|
const namespaces = require('./namespaces');
|
||||||
|
const parser = require('./parser');
|
||||||
|
|
||||||
|
const getDependencies = async (entryPoint, projectDir) => {
|
||||||
|
const phpNamespaces = await namespaces.parse(projectDir);
|
||||||
|
|
||||||
|
const dependencies = {
|
||||||
|
[entryPoint]: phpNamespaces[entryPoint]
|
||||||
|
};
|
||||||
|
|
||||||
|
if (phpNamespaces[entryPoint]) {
|
||||||
|
phpNamespaces[entryPoint].importedModuleNames.forEach(moduleName => {
|
||||||
|
Object.keys(phpNamespaces).forEach(itemPath => {
|
||||||
|
if (phpNamespaces[itemPath].moduleName !== moduleName) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies[itemPath] = phpNamespaces[itemPath];
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return dependencies;
|
||||||
|
};
|
||||||
|
|
||||||
|
const getImports = (fileCode, itemPath) => {
|
||||||
|
const phpNamespaces = namespaces.getCache();
|
||||||
|
const parsed = parser.parseCode(fileCode, path.basename(itemPath));
|
||||||
|
const dependencies = [];
|
||||||
|
|
||||||
|
const findSourceFile = phpNamespace => {
|
||||||
|
return Object.keys(phpNamespaces).find(key => {
|
||||||
|
return phpNamespaces[key].moduleName === phpNamespace;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
(parsed.children || []).forEach(parsedChild => {
|
||||||
|
(parsedChild.children || []).forEach(c => {
|
||||||
|
if (c.kind !== 'usegroup') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const dependence = {
|
||||||
|
importNodeLines: [c.loc.start.line, c.loc.end.line],
|
||||||
|
sourceFile: null,
|
||||||
|
specifiers: []
|
||||||
|
};
|
||||||
|
c.items.forEach(item => {
|
||||||
|
dependence.sourceFile = findSourceFile(item.name);
|
||||||
|
const importSpecifierName =
|
||||||
|
dependence && dependence.sourceFile && dependence.sourceFile.split('/').pop();
|
||||||
|
|
||||||
|
if (importSpecifierName) {
|
||||||
|
dependence.specifiers.push({
|
||||||
|
type: 'ImportSpecifier',
|
||||||
|
name: importSpecifierName
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
dependencies.push(dependence);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
return dependencies.filter(({ sourceFile }) => !!sourceFile);
|
||||||
|
};
|
||||||
|
|
||||||
// replace with own implementation if needed
|
// replace with own implementation if needed
|
||||||
module.exports = {
|
module.exports = {
|
||||||
getImports: defaultDependencies.getImports,
|
getImports: getImports,
|
||||||
getDependencies: defaultDependencies.getDependencies
|
getDependencies: getDependencies
|
||||||
};
|
};
|
||||||
|
|||||||
54
src/server/code-parse/language/php/namespaces.js
Normal file
54
src/server/code-parse/language/php/namespaces.js
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
const readdirRecursive = require('fs-readdir-recursive');
|
||||||
|
const file = require('../../../utils/file');
|
||||||
|
const extensions = require('./extensions');
|
||||||
|
const path = require('path');
|
||||||
|
const parser = require('./parser');
|
||||||
|
|
||||||
|
let cache = {};
|
||||||
|
|
||||||
|
const addNamespaces = (namespaces, itemPath, parsed) =>
|
||||||
|
(parsed.children || []).filter(parsedChild => parsedChild.name).forEach(parsedChild => {
|
||||||
|
const namespace = {
|
||||||
|
moduleName: parsedChild.name,
|
||||||
|
importedModuleNames: []
|
||||||
|
};
|
||||||
|
|
||||||
|
(parsedChild.children || []).forEach(c => {
|
||||||
|
switch (c.kind) {
|
||||||
|
case 'usegroup':
|
||||||
|
c.items.forEach(item => {
|
||||||
|
namespace.importedModuleNames.push(item.name);
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case 'class':
|
||||||
|
case 'trait':
|
||||||
|
case 'interface':
|
||||||
|
namespace.moduleName = `${parsedChild.name}\\${c.name.name}`;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
namespaces[itemPath] = namespace;
|
||||||
|
});
|
||||||
|
|
||||||
|
const parse = async projectDir => {
|
||||||
|
const namespaces = {};
|
||||||
|
const tasks = readdirRecursive(projectDir)
|
||||||
|
.filter(f => extensions.test('.' + f.split('.').pop()))
|
||||||
|
.map(async f => {
|
||||||
|
const separator = path.sep;
|
||||||
|
const itemPath = `${projectDir}${separator}${f.replace(/\//g, separator)}`;
|
||||||
|
const fileCode = await file.read(itemPath, 'utf8');
|
||||||
|
addNamespaces(namespaces, itemPath, parser.parseCode(fileCode, path.basename(f)));
|
||||||
|
});
|
||||||
|
|
||||||
|
await Promise.all(tasks);
|
||||||
|
cache = namespaces;
|
||||||
|
|
||||||
|
return namespaces;
|
||||||
|
};
|
||||||
|
const getCache = () => cache;
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
parse,
|
||||||
|
getCache
|
||||||
|
};
|
||||||
12
src/server/code-parse/language/php/parser.js
Normal file
12
src/server/code-parse/language/php/parser.js
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
const Engine = require('php-parser');
|
||||||
|
|
||||||
|
const parser = new Engine({
|
||||||
|
parser: {
|
||||||
|
extractDoc: true,
|
||||||
|
php7: true
|
||||||
|
},
|
||||||
|
ast: {
|
||||||
|
withPositions: true
|
||||||
|
}
|
||||||
|
});
|
||||||
|
module.exports = parser
|
||||||
@@ -1,7 +1,4 @@
|
|||||||
const { setupGetCrumbs, setupGetCommentsFromCode } = require('../default/codecrumbs');
|
const { getCrumbs } = require('../default/codecrumbs');
|
||||||
|
|
||||||
const TYPE_SCRIPT_COMMENT_REGEX = /^([^\/\/]*)\/\/(.*)$/;
|
|
||||||
const getCrumbs = setupGetCrumbs(setupGetCommentsFromCode(TYPE_SCRIPT_COMMENT_REGEX));
|
|
||||||
|
|
||||||
// replace with own implementation if needed
|
// replace with own implementation if needed
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
|||||||
@@ -10,9 +10,6 @@ const mediator = require('./mediator');
|
|||||||
const sourceWatcher = require('./source-watcher');
|
const sourceWatcher = require('./source-watcher');
|
||||||
|
|
||||||
const setup = (options, devOptions) => {
|
const setup = (options, devOptions) => {
|
||||||
logger.fun(`>\n> Codecrumbs magic begins!\n>`);
|
|
||||||
logger.info(`> started with options: ${JSON.stringify(options)}`);
|
|
||||||
|
|
||||||
const {
|
const {
|
||||||
projectNameAlias,
|
projectNameAlias,
|
||||||
projectDir,
|
projectDir,
|
||||||
@@ -21,11 +18,17 @@ const setup = (options, devOptions) => {
|
|||||||
tsConfigPath,
|
tsConfigPath,
|
||||||
clientPort,
|
clientPort,
|
||||||
excludeDir,
|
excludeDir,
|
||||||
ideCmd
|
ideCmd,
|
||||||
|
debugModeEnabled
|
||||||
} = options;
|
} = options;
|
||||||
|
|
||||||
|
logger.setDebugModeEnabled(debugModeEnabled);
|
||||||
|
|
||||||
|
logger.fun(`>\n> Codecrumbs magic begins!\n>`);
|
||||||
|
logger.info(`> started with options: ${JSON.stringify(options)}`);
|
||||||
|
|
||||||
const PORT_IN_USE = 'open';
|
const PORT_IN_USE = 'open';
|
||||||
const HOST = '127.0.0.1';
|
const HOST = '0.0.0.0';
|
||||||
|
|
||||||
validateProjectPath(projectDir, entryPoint);
|
validateProjectPath(projectDir, entryPoint);
|
||||||
|
|
||||||
@@ -94,11 +97,11 @@ const alignPlatformPath = (p = '') =>
|
|||||||
|
|
||||||
const validateProjectPath = (pDir, ePoint) => {
|
const validateProjectPath = (pDir, ePoint) => {
|
||||||
const paths = [];
|
const paths = [];
|
||||||
if (!fs.existsSync(alignPlatformPath(pDir))) {
|
if (!checkIfPathExists(pDir)) {
|
||||||
paths.push(pDir);
|
paths.push(pDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!fs.existsSync(alignPlatformPath(ePoint))) {
|
if (!checkIfPathExists(ePoint)) {
|
||||||
paths.push(ePoint);
|
paths.push(ePoint);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -110,6 +113,9 @@ const validateProjectPath = (pDir, ePoint) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const checkIfPathExists = path => fs.existsSync(alignPlatformPath(path));
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
checkIfPathExists,
|
||||||
setup
|
setup
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
const chalk = require('chalk');
|
const chalk = require('chalk');
|
||||||
|
|
||||||
const logAdapter = msg => console.log(msg);
|
let isDebugModeEnabled = false;
|
||||||
|
const logAdapter = (msg, force) => (isDebugModeEnabled || force) && console.log(msg);
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
getText: e => {
|
getText: e => {
|
||||||
@@ -13,6 +14,7 @@ module.exports = {
|
|||||||
log: (...args) => logAdapter(chalk.blue.apply(chalk, args)),
|
log: (...args) => logAdapter(chalk.blue.apply(chalk, args)),
|
||||||
info: (...args) => logAdapter(chalk.green.apply(chalk, args)),
|
info: (...args) => logAdapter(chalk.green.apply(chalk, args)),
|
||||||
warn: (...args) => logAdapter(chalk.yellow.apply(chalk, args)),
|
warn: (...args) => logAdapter(chalk.yellow.apply(chalk, args)),
|
||||||
error: (...args) => logAdapter(chalk.red.apply(chalk, args)),
|
error: (...args) => logAdapter(chalk.red.apply(chalk, args), true),
|
||||||
fun: (...args) => logAdapter(chalk.keyword('purple').apply(chalk, args))
|
fun: (...args) => logAdapter(chalk.keyword('purple').apply(chalk, args), true),
|
||||||
|
setDebugModeEnabled: (debugModeEnabled) => isDebugModeEnabled = debugModeEnabled
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user