Compare commits
36 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
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 |
24
README.md
24
README.md
@@ -40,15 +40,19 @@ 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* .
|
||||
3) Go to [http://localhost:2018](http://localhost:2018/#) in the browser to check it out.
|
||||
|
||||
### CLI
|
||||
Parameter | Description | Example
|
||||
--- | --- | ---
|
||||
```-d```, ```--dir``` | Relative path to project source code directory | ```-d src```
|
||||
```-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```
|
||||
```-i```, ```--ideCmd``` | command to open file in IDE from bash (default 'webstorm') | ```-i code```
|
||||
```-p```, ```--port``` | Port for Codecrumbs client (optional, default *2018*) | ```-p 2019```
|
||||
```-n```, ```--projectName``` | Project name alias (optional, default same as ```-d``` value) | ```-n my-hello-world```
|
||||
### Configuration
|
||||
Run codecrumbs with CLI params or specify static config file `codecrumbs.config.js` (see example [here](/example-project/codecrumbs.config.js))
|
||||
|
||||
CLI | Config file | Description | Example
|
||||
--- | --- | --- | ---
|
||||
```d``` | ```projectDir``` | Relative path to project source code directory | ```-d src```
|
||||
```e``` | ```entryPoint``` | 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```
|
||||
```i``` | ```ideCmd``` | command to open file in IDE from bash (default 'webstorm') | ```-i code```
|
||||
```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
|
||||
### Breadcrumbs and trails
|
||||
@@ -76,6 +80,8 @@ Example | Description | Use case
|
||||
|
||||
> 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
|
||||
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.
|
||||
|
||||
@@ -1,12 +1,17 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
const path = require('path');
|
||||
const program = require('commander');
|
||||
const colors = require('colors');
|
||||
const _ = require('lodash');
|
||||
|
||||
const showUpdatesInfo = require('./updatesInfo');
|
||||
const server = require('../src/server');
|
||||
|
||||
showUpdatesInfo();
|
||||
|
||||
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(
|
||||
'-w, --webpack [webpackConfigFile]',
|
||||
@@ -20,27 +25,33 @@ program
|
||||
.option('-i, --ideCmd [ideCmd]', 'IDE command to open file')
|
||||
.option('-x, --excludeDir [excludeDirectories]', 'Exclude directories')
|
||||
.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);
|
||||
|
||||
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(
|
||||
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();
|
||||
}
|
||||
|
||||
server.setup(
|
||||
{
|
||||
projectNameAlias: program.projectName,
|
||||
entryPoint: program.entry,
|
||||
projectDir: program.dir,
|
||||
webpackConfigPath: program.webpack,
|
||||
tsConfigPath: program.tsconfig,
|
||||
clientPort: program.port,
|
||||
excludeDir: program.excludeDir,
|
||||
ideCmd: program.ideCmd
|
||||
},
|
||||
{ isDev: false }
|
||||
);
|
||||
const configFromFile = configFileExists ? require(path.resolve(pathToConfigFile)) : {};
|
||||
|
||||
const configFromCLI = {
|
||||
projectNameAlias: program.projectName,
|
||||
entryPoint: program.entry,
|
||||
projectDir: program.dir,
|
||||
webpackConfigPath: program.webpack,
|
||||
tsConfigPath: program.tsconfig,
|
||||
clientPort: program.port,
|
||||
excludeDir: program.excludeDir,
|
||||
ideCmd: program.ideCmd,
|
||||
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) {}
|
||||
};
|
||||
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
|
||||
};
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "codecrumbs",
|
||||
"version": "1.6.9",
|
||||
"version": "1.7.0",
|
||||
"author": "Bohdan Liashenko",
|
||||
"license": "BSD-3-Clause",
|
||||
"repository": {
|
||||
@@ -13,6 +13,7 @@
|
||||
"server:two": "node src/index.dev.js two",
|
||||
"client-dev": "cd src/public && webpack --config webpack.dev.js --progress --colors --watch --env dev",
|
||||
"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",
|
||||
"clean": "rm -rf build",
|
||||
"babel-compile-standalone": "babel src/public/js -d build --config-file ./src/public/babel.config.js --copy-files",
|
||||
@@ -36,7 +37,7 @@
|
||||
"directory-tree": "^2.1.0",
|
||||
"file-saver": "^2.0.0",
|
||||
"http-server": "0.9.0",
|
||||
"js2flowchart": "^1.1.7",
|
||||
"js2flowchart": "1.3.2",
|
||||
"lodash": "^4.17.10",
|
||||
"lodash.debounce": "^4.0.8",
|
||||
"madge": "^3.4.4",
|
||||
|
||||
@@ -5,7 +5,8 @@ const namespaceOne = {
|
||||
projectDir: `example-project/src-client`,
|
||||
entryPoint: `example-project/src-client/index.js`,
|
||||
webpackConfigPath: `example-project/webpack.config.js`,
|
||||
clientPort: 2018
|
||||
clientPort: 2018,
|
||||
debugModeEnabled: true
|
||||
};
|
||||
|
||||
const namespaceTwo = {
|
||||
|
||||
@@ -22,9 +22,7 @@ const ExplorerBar = React.lazy(() =>
|
||||
import(/* webpackChunkName: "explorer-bar" */ './components/explorerBar/ExplorerBarContainer')
|
||||
);
|
||||
|
||||
const Footer = React.lazy(() =>
|
||||
import(/* webpackChunkName: "footer" */ './components/footer')
|
||||
);
|
||||
const Footer = React.lazy(() => import(/* webpackChunkName: "footer" */ './components/footer'));
|
||||
|
||||
import './App.less';
|
||||
|
||||
@@ -61,6 +59,9 @@ const App = (props = {}) => {
|
||||
<Suspense fallback={null}>
|
||||
<SideBar />
|
||||
</Suspense>
|
||||
{props.extraLayout.appBodyBottom && (
|
||||
<props.extraLayout.appBodyBottom.Component {...props} />
|
||||
)}
|
||||
</div>
|
||||
|
||||
<footer className="footer">
|
||||
|
||||
@@ -28,6 +28,7 @@ export default class extends React.Component {
|
||||
this.codeRef.scrollTo(0, (lines[0][0] - 1) * (lineHeight || LINE_HEIGHT) + PADDING_TOP - 2);
|
||||
}
|
||||
componentDidUpdate(prevProps) {
|
||||
// TODO: don\t do it each time (check real changes)
|
||||
this.fixScroll();
|
||||
}
|
||||
componentDidMount() {
|
||||
|
||||
@@ -34,7 +34,7 @@ const CrumbsTab = props => {
|
||||
header={`[${typeof stepFile.step !== 'undefined' ? stepFile.step : '*'}] ${
|
||||
stepFile.file.path
|
||||
}`}
|
||||
key={i}
|
||||
key={stepFile.crumbNodeLines.join(',')}
|
||||
>
|
||||
<Code
|
||||
language={language}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
.TreeDiagramsContainer {
|
||||
overflow: auto;
|
||||
width: 100%;
|
||||
margin-top: 20px;
|
||||
margin-left: 10px;
|
||||
}
|
||||
|
||||
.MainLoader {
|
||||
@@ -10,4 +12,4 @@
|
||||
padding: 250px;
|
||||
margin-top: 60px;
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ const TreeDiagramsContainer = ({ namespacesList, activeNamespace }) => {
|
||||
);
|
||||
}
|
||||
|
||||
// TODO: use ref for TreeDiagram container (on mount set it to store)
|
||||
return (
|
||||
<div className={'TreeDiagramsContainer'}>
|
||||
{namespacesList.map(namespace => (
|
||||
|
||||
@@ -13,6 +13,7 @@ export const CodeCrumbName = props => {
|
||||
cover,
|
||||
flow,
|
||||
flowStep,
|
||||
original,
|
||||
selected,
|
||||
onMouseOver,
|
||||
onClick
|
||||
@@ -73,7 +74,7 @@ export const CodeCrumbName = props => {
|
||||
onClick={onClick}
|
||||
className={'CodeCrumbName-flow'}
|
||||
>
|
||||
{flowStep}
|
||||
{flowStep !== 0 ? flowStep : /#0/.test(original) ? 0 : '*'}
|
||||
</text>
|
||||
</React.Fragment>
|
||||
)) ||
|
||||
|
||||
@@ -27,7 +27,11 @@ export default props => {
|
||||
if (!i) return null;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -38,7 +42,7 @@ export default props => {
|
||||
});
|
||||
|
||||
const edgeBaseProps = {
|
||||
key: `cc-external-edge-${fromItem.name}-${toItem.name}`,
|
||||
key: `cc-external-edge-${fromItem.name}-${toItem.name}-${edgePoints[0].y}`,
|
||||
sourcePosition: edgePoints[0],
|
||||
targetPosition: edgePoints[1],
|
||||
onClick: () => onFlowEdgeClick(fromItem, toItem, ccNamespacesKeys),
|
||||
|
||||
@@ -40,7 +40,7 @@ const Tree = props => {
|
||||
).x;
|
||||
|
||||
return (
|
||||
<React.Fragment key={`code-crumb-${node.data.path}-${key}`}>
|
||||
<React.Fragment key={`code-crumb-${key}-${nX}-${nY}`}>
|
||||
{!codeCrumbsMinimize &&
|
||||
node.children.map((crumb, i) => {
|
||||
const [_, cY] = [crumb.y, crumb.x];
|
||||
@@ -55,7 +55,9 @@ const Tree = props => {
|
||||
const ccParams = crumbData.params;
|
||||
|
||||
return (
|
||||
<React.Fragment key={`code-crumb-edge-${file.path}-${crumbData.name}`}>
|
||||
<React.Fragment
|
||||
key={`code-crumb-edge-${crumbData.name}-${crumbPosition.x}-${crumbPosition.y}`}
|
||||
>
|
||||
{!i && (
|
||||
<PartEdge
|
||||
sourcePosition={position}
|
||||
@@ -84,6 +86,7 @@ const Tree = props => {
|
||||
currentSelectedCrumbedFlowKey !== NO_TRAIL_FLOW
|
||||
}
|
||||
flowStep={ccParams.flowStep}
|
||||
original={ccParams.original}
|
||||
onClick={e => onCodeCrumbSelect(e, { fileNode: file, codeCrumb: crumbData })}
|
||||
/>
|
||||
</React.Fragment>
|
||||
|
||||
@@ -80,7 +80,7 @@ const DependenciesTree = props => {
|
||||
|
||||
const edge = (
|
||||
<DependenciesEdge
|
||||
key={`dep-edge-${importedNodePath}`}
|
||||
key={`dep-edge-${importedNodePath}-${sourcePosition.x}-${targetPosition.x}`}
|
||||
anyEdgeSelected={!!selectedDependencyEdgeNodes}
|
||||
selected={selected}
|
||||
groupName={groupName}
|
||||
@@ -106,7 +106,7 @@ const DependenciesTree = props => {
|
||||
|
||||
const arrow = (
|
||||
<DependenciesArrow
|
||||
key={`dep-arrow-${importedNodePath}`}
|
||||
key={`dep-arrow-${importedNodePath}-${groupName}`}
|
||||
selected={arrowSelected}
|
||||
groupName={groupName}
|
||||
targetPosition={targetPosition}
|
||||
|
||||
@@ -60,7 +60,7 @@ const SourceTree = props => {
|
||||
|
||||
const edge = (
|
||||
<SourceEdge
|
||||
key={`source-edge-${path}`}
|
||||
key={`source-edge-${path}-${sourcePosition.x}-${sourcePosition.y}`}
|
||||
targetPosition={position}
|
||||
sourcePosition={sourcePosition}
|
||||
disabled={sourceDimFolders}
|
||||
@@ -77,7 +77,13 @@ const SourceTree = props => {
|
||||
(type === FILE_NODE_TYPE &&
|
||||
!(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;
|
||||
|
||||
@@ -15,11 +15,21 @@ import {
|
||||
getNamespacesList
|
||||
} from '../../../core/dataBus/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 { gatherFlowStepsData, getMaxWidthForNs } from './Tree/CodeCrumbs/helpers';
|
||||
|
||||
class TreeDiagram extends React.Component {
|
||||
componentDidUpdate(prevProps) {
|
||||
if (!prevProps.layoutSize && this.props.layoutSize) {
|
||||
this.props.saveContentId(this.treeDiagramContent.getAttribute('id'));
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
// TODO: fix diagramZoom
|
||||
const {
|
||||
@@ -50,7 +60,7 @@ class TreeDiagram extends React.Component {
|
||||
});
|
||||
|
||||
return (
|
||||
<div className={'TreeDiagram'}>
|
||||
<div className={classNames('TreeDiagram', { border: multiple })}>
|
||||
{multiple ? (
|
||||
<p
|
||||
className={classNames('namespaceTitle', {
|
||||
@@ -60,35 +70,41 @@ class TreeDiagram extends React.Component {
|
||||
{projectName}
|
||||
</p>
|
||||
) : null}
|
||||
<svg
|
||||
width={maxWidth || width}
|
||||
height={height}
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
shapeRendering="optimizeSpeed"
|
||||
<div
|
||||
id={`TreeDiagram-${namespace}-content`}
|
||||
className={'content'}
|
||||
ref={el => (this.treeDiagramContent = el)}
|
||||
>
|
||||
{sourceLayoutTree && (
|
||||
<React.Fragment>
|
||||
<UnderLayer width={maxWidth || width} height={height} onClick={onUnderLayerClick} />
|
||||
<SourceTree
|
||||
namespace={namespace}
|
||||
shiftToCenterPoint={shiftToCenterPoint}
|
||||
areaHeight={height}
|
||||
sortedFlowSteps={sortedFlowSteps}
|
||||
involvedNsData={involvedNsData}
|
||||
ccShiftIndexMap={ccShiftIndexMap}
|
||||
/>
|
||||
</React.Fragment>
|
||||
)}
|
||||
</svg>
|
||||
{codeCrumbsDiagramOn ? (
|
||||
<CodeCrumbsExtraInfo
|
||||
namespace={namespace}
|
||||
shiftToCenterPoint={shiftToCenterPoint}
|
||||
ccShiftIndexMap={ccShiftIndexMap}
|
||||
sortedFlowSteps={sortedFlowSteps}
|
||||
flowSteps={flowSteps}
|
||||
/>
|
||||
) : null}
|
||||
<svg
|
||||
width={maxWidth || width}
|
||||
height={height}
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
shapeRendering="optimizeSpeed"
|
||||
>
|
||||
{sourceLayoutTree && (
|
||||
<React.Fragment>
|
||||
<UnderLayer width={maxWidth || width} height={height} onClick={onUnderLayerClick} />
|
||||
<SourceTree
|
||||
namespace={namespace}
|
||||
shiftToCenterPoint={shiftToCenterPoint}
|
||||
areaHeight={height}
|
||||
sortedFlowSteps={sortedFlowSteps}
|
||||
involvedNsData={involvedNsData}
|
||||
ccShiftIndexMap={ccShiftIndexMap}
|
||||
/>
|
||||
</React.Fragment>
|
||||
)}
|
||||
</svg>
|
||||
{codeCrumbsDiagramOn ? (
|
||||
<CodeCrumbsExtraInfo
|
||||
namespace={namespace}
|
||||
shiftToCenterPoint={shiftToCenterPoint}
|
||||
ccShiftIndexMap={ccShiftIndexMap}
|
||||
sortedFlowSteps={sortedFlowSteps}
|
||||
flowSteps={flowSteps}
|
||||
/>
|
||||
) : null}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -149,7 +165,8 @@ const mapDispatchToProps = (dispatch, props) => {
|
||||
dispatch(setActiveNamespace(namespace));
|
||||
dispatch(selectDependencyEdge(undefined, namespace));
|
||||
dispatch(selectCcFlowEdge(undefined, namespace));
|
||||
}
|
||||
},
|
||||
saveContentId: ref => dispatch(saveTreeDiagramContentId(ref, namespace))
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -5,7 +5,10 @@
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
overflow-y: hidden;
|
||||
border-bottom: 1px solid #ebedf0;
|
||||
|
||||
&.border {
|
||||
border-bottom: 1px solid #ebedf0;
|
||||
}
|
||||
|
||||
.namespaceTitle {
|
||||
position: absolute;
|
||||
@@ -22,7 +25,9 @@
|
||||
}
|
||||
}
|
||||
|
||||
svg {
|
||||
display: block;
|
||||
.content {
|
||||
svg {
|
||||
display: block;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,3 +24,8 @@ export const setZoom = payload => ({
|
||||
type: ACTIONS.SET_ZOOM,
|
||||
payload
|
||||
});
|
||||
|
||||
export const setFullState = payload => ({
|
||||
type: ACTIONS.SET_FULL_STATE,
|
||||
payload
|
||||
});
|
||||
|
||||
@@ -339,3 +339,19 @@ export const setPredefinedState = predefinedState => dispatch => {
|
||||
}, 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 = {
|
||||
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',
|
||||
SET_CHANGED_SOURCE_DATA: 'DATA_BUS.SET_CHANGED_SOURCE_DATA',
|
||||
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',
|
||||
SELECT_DEPENDENCY_EDGE: 'DATA_BUS.SELECT_DEPENDENCY_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'
|
||||
};
|
||||
|
||||
@@ -195,6 +195,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:
|
||||
return DefaultState;
|
||||
|
||||
|
||||
@@ -13,6 +13,11 @@ export const getProjectMetadata = createSelector([getNamespaceState], namespaceS
|
||||
return { projectName, language, platformPathSeparator, fullFeaturesSupport };
|
||||
});
|
||||
|
||||
export const getTreeDiagramContentId = createSelector([getNamespaceState], namespaceState => {
|
||||
const { treeDiagramContentId } = namespaceState;
|
||||
return { id: treeDiagramContentId };
|
||||
});
|
||||
|
||||
export const getSource = createSelector([getNamespaceState], namespaceState => {
|
||||
const { sourceTree, filesMap, foldersMap } = namespaceState;
|
||||
|
||||
|
||||
@@ -35,24 +35,28 @@ export const calculateLayoutProps = (list, padding = 120) => {
|
||||
minX = x;
|
||||
}
|
||||
|
||||
if (y - ySize / 2 < minY) {
|
||||
minY = y - ySize / 2;
|
||||
if (y < minY) {
|
||||
minY = y;
|
||||
}
|
||||
|
||||
if (x + xSize > maxX) {
|
||||
maxX = x + xSize;
|
||||
}
|
||||
|
||||
if (y + ySize / 2 > maxY) {
|
||||
maxY = y + ySize / 2;
|
||||
if (y + ySize > maxY) {
|
||||
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 * padding);
|
||||
|
||||
return {
|
||||
width: Math.round(Math.abs(maxX + maxCcWidth) + Math.abs(minX) + 2 * padding),
|
||||
height: Math.round(Math.abs(maxY) + Math.abs(minY) + 2 * padding),
|
||||
xShift: padding / 4,
|
||||
yShift: Math.abs(Math.round(minY)) > 2 * padding ? Math.abs(Math.round(minY)) : 2 * padding,
|
||||
xShift: 5,
|
||||
width,
|
||||
height,
|
||||
yShift,
|
||||
ccAlightPoint
|
||||
};
|
||||
};
|
||||
|
||||
@@ -69,6 +69,8 @@ export const getTreeLayout = (
|
||||
}, 0);
|
||||
}
|
||||
|
||||
// TODO: calc properly, not 5000
|
||||
// impossible to do in one loop
|
||||
const LARGE_WIDTH_CC = 5000;
|
||||
const widthSpace =
|
||||
node.data.type !== DIR_NODE_TYPE && node.data.type !== FILE_NODE_TYPE
|
||||
|
||||
@@ -4,3 +4,8 @@ export const setActiveNamespace = payload => ({
|
||||
type: ACTIONS.SET_ACTIVE_NAMESPACE,
|
||||
payload
|
||||
});
|
||||
|
||||
export const setFullState = payload => ({
|
||||
type: ACTIONS.SET_FULL_STATE,
|
||||
payload
|
||||
});
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
export const ACTIONS = {
|
||||
SET_ACTIVE_NAMESPACE: 'NAMESPACE_INTEGRATION.SET_ACTIVE_NAMESPACE',
|
||||
SET_FULL_STATE: 'NAMESPACE_INTEGRATION.SET_FULL_STATE',
|
||||
RESET_ALL: 'NAMESPACE_INTEGRATION.RESET_ALL'
|
||||
};
|
||||
|
||||
@@ -12,6 +12,12 @@ export default (state = DefaultState, action) => {
|
||||
activeNamespace: action.payload
|
||||
};
|
||||
|
||||
case ACTIONS.SET_FULL_STATE:
|
||||
return {
|
||||
...state,
|
||||
...action.payload
|
||||
};
|
||||
|
||||
case ACTIONS.RESET_ALL:
|
||||
return DefaultState;
|
||||
|
||||
|
||||
@@ -9,13 +9,13 @@ import dataBus from '../dataBus/reducer';
|
||||
import namespaceIntegration from '../namespaceIntegration/reducer';
|
||||
import rootSaga from './sagas';
|
||||
|
||||
export default () => {
|
||||
export default ({ extraReducers = {}, extraPersistWhiteList = [] } = {}) => {
|
||||
const sagaMiddleware = createSagaMiddleware();
|
||||
const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
|
||||
|
||||
const persistConfig = {
|
||||
key: 'codecrumbs-config-storage',
|
||||
whitelist: ['controlsBus'],
|
||||
whitelist: ['controlsBus', ...extraPersistWhiteList],
|
||||
storage
|
||||
};
|
||||
|
||||
@@ -24,7 +24,8 @@ export default () => {
|
||||
combineReducers({
|
||||
controlsBus,
|
||||
dataBus,
|
||||
namespaceIntegration
|
||||
namespaceIntegration,
|
||||
...extraReducers
|
||||
})
|
||||
);
|
||||
|
||||
|
||||
@@ -6,13 +6,14 @@ import { PersistGate } from 'redux-persist/integration/react';
|
||||
import App from './App';
|
||||
import getStore from './core/store';
|
||||
|
||||
const extraLayout = {};
|
||||
export default (options, mountNodeId) => {
|
||||
const { store, persistor } = getStore();
|
||||
|
||||
ReactDOM.render(
|
||||
<Provider store={store}>
|
||||
<PersistGate loading={null} persistor={persistor}>
|
||||
<App {...options} />
|
||||
<App extraLayout={extraLayout} {...options} />
|
||||
</PersistGate>
|
||||
</Provider>,
|
||||
document.getElementById(mountNodeId)
|
||||
|
||||
@@ -4,12 +4,21 @@ const { getLanguageParsers } = require('./language');
|
||||
const parseFile = (
|
||||
itemPath,
|
||||
projectDir,
|
||||
{ parseCodeCrumbs, parseImports, parseDependencies, attachCode, language, webpackConfigPath, tsConfigPath } = {}
|
||||
{
|
||||
parseCodeCrumbs,
|
||||
parseImports,
|
||||
parseDependencies,
|
||||
attachCode,
|
||||
language,
|
||||
webpackConfigPath,
|
||||
tsConfigPath
|
||||
} = {}
|
||||
) => {
|
||||
const { codecrumbsParser, dependenciesParser } = getLanguageParsers(language);
|
||||
|
||||
|
||||
return Promise.all([
|
||||
parseDependencies && dependenciesParser.getDependencies(itemPath, projectDir, {webpackConfigPath, tsConfigPath}),
|
||||
parseDependencies &&
|
||||
dependenciesParser.getDependencies(itemPath, projectDir, { webpackConfigPath, tsConfigPath }),
|
||||
file.read(itemPath, 'utf8')
|
||||
]).then(([dependencies, code]) => {
|
||||
const item = {
|
||||
@@ -37,7 +46,7 @@ const parseFile = (
|
||||
item.flows = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (parseImports) {
|
||||
const importedDependencies = dependenciesParser.getImports(code, itemPath);
|
||||
if (importedDependencies.length) {
|
||||
|
||||
@@ -10,9 +10,6 @@ const mediator = require('./mediator');
|
||||
const sourceWatcher = require('./source-watcher');
|
||||
|
||||
const setup = (options, devOptions) => {
|
||||
logger.fun(`>\n> Codecrumbs magic begins!\n>`);
|
||||
logger.info(`> started with options: ${JSON.stringify(options)}`);
|
||||
|
||||
const {
|
||||
projectNameAlias,
|
||||
projectDir,
|
||||
@@ -21,9 +18,15 @@ const setup = (options, devOptions) => {
|
||||
tsConfigPath,
|
||||
clientPort,
|
||||
excludeDir,
|
||||
ideCmd
|
||||
ideCmd,
|
||||
debugModeEnabled
|
||||
} = 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 HOST = '127.0.0.1';
|
||||
|
||||
@@ -94,11 +97,11 @@ const alignPlatformPath = (p = '') =>
|
||||
|
||||
const validateProjectPath = (pDir, ePoint) => {
|
||||
const paths = [];
|
||||
if (!fs.existsSync(alignPlatformPath(pDir))) {
|
||||
if (!checkIfPathExists(pDir)) {
|
||||
paths.push(pDir);
|
||||
}
|
||||
|
||||
if (!fs.existsSync(alignPlatformPath(ePoint))) {
|
||||
if (!checkIfPathExists(ePoint)) {
|
||||
paths.push(ePoint);
|
||||
}
|
||||
|
||||
@@ -110,6 +113,9 @@ const validateProjectPath = (pDir, ePoint) => {
|
||||
}
|
||||
};
|
||||
|
||||
const checkIfPathExists = path => fs.existsSync(alignPlatformPath(path));
|
||||
|
||||
module.exports = {
|
||||
checkIfPathExists,
|
||||
setup
|
||||
};
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
const chalk = require('chalk');
|
||||
|
||||
const logAdapter = msg => console.log(msg);
|
||||
let isDebugModeEnabled = false;
|
||||
const logAdapter = (msg, force) => (isDebugModeEnabled || force) && console.log(msg);
|
||||
|
||||
module.exports = {
|
||||
getText: e => {
|
||||
@@ -13,6 +14,7 @@ module.exports = {
|
||||
log: (...args) => logAdapter(chalk.blue.apply(chalk, args)),
|
||||
info: (...args) => logAdapter(chalk.green.apply(chalk, args)),
|
||||
warn: (...args) => logAdapter(chalk.yellow.apply(chalk, args)),
|
||||
error: (...args) => logAdapter(chalk.red.apply(chalk, args)),
|
||||
fun: (...args) => logAdapter(chalk.keyword('purple').apply(chalk, args))
|
||||
error: (...args) => logAdapter(chalk.red.apply(chalk, args), true),
|
||||
fun: (...args) => logAdapter(chalk.keyword('purple').apply(chalk, args), true),
|
||||
setDebugModeEnabled: (debugModeEnabled) => isDebugModeEnabled = debugModeEnabled
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user