Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,12 @@
"javascript"
],
"scripts": {
"install:all": "lerna bootstrap && lerna link",
"start:comp": "lerna run start --scope=@gitgraph/{core,js,react} --parallel",
"start:all": "lerna run start --scope=@gitgraph/{core,js,react,stories} --parallel",
"lerna": "lerna",
"build": "lerna run build --scope=@gitgraph/{core,react,js,node} --stream",
"watch": "lerna run watch --stream",
"watch": "lerna run watch --scope=@gitgraph/{core,react,js,node} --stream",
"storybook": "sleep 3 && lerna run storybook --stream",
"develop": "concurrently npm:watch npm:storybook",
"website": "lerna run start --scope=@gitgraph/website --stream",
Expand All @@ -49,11 +52,11 @@
"eslint-plugin-react": "^7.21.5",
"husky": "1.1.2",
"jest": "23.3.0",
"lerna": "3.13.1",
"lerna": "3.10.7",
"prettier": "^2.2.0",
"pretty-quick": "^3.1.0",
"ts-jest": "23.0.0",
"typescript": "3.5.1"
"typescript": "4.8.3"
},
"workspaces": [
"packages/*"
Expand Down
12 changes: 7 additions & 5 deletions packages/gitgraph-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,12 @@
"publishConfig": {
"access": "public"
},
"main": "./lib/bundle.umd.js",
"module": "./lib/index.js",
"jsnext:main": "./lib/index.js",
"typings": "./lib/index.d.ts",
"main": "dist/index.js",
"module": "dist/index.es.js",
"jsnext:main": "dist/index.es.js",
"typings": "dist/index.d.ts",
"scripts": {
"start": "rollup -c -w",
"prewatch": "rimraf ./lib",
"watch": "tsc -w",
"test": "jest",
Expand All @@ -45,12 +46,13 @@
"prepublishOnly": "npm run test"
},
"devDependencies": {
"@rollup/plugin-typescript": "8.5.0",
"@types/node": "9.4.6",
"auto-changelog": "1.12.1",
"browserify": "14.5.0",
"npm-run-all": "4.1.2",
"rimraf": "2.6.2",
"rollup": "0.51.8",
"rollup": "2.79.1",
"uglify-es": "3.3.9"
},
"jest": {
Expand Down
23 changes: 18 additions & 5 deletions packages/gitgraph-core/rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,20 @@
import typescript from "@rollup/plugin-typescript";

import pkg from "./package.json";

export default {
input: "lib/index.js",
output: {
file: "lib/bundle.umd.js",
format: "umd",
},
input: "src/index.ts",
output: [
{
file: pkg.main,
format: "cjs",
sourcemap: true,
},
{
file: pkg.module,
format: "es",
sourcemap: true,
},
],
plugins: [typescript({ module: "ESNext" })],
};
4 changes: 3 additions & 1 deletion packages/gitgraph-core/src/gitgraph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,9 @@ class GitgraphCore<TNode = SVGElement> {

const branch = new Branch<TNode>(options);
this.branches.set(branch.name, branch);

if (options.parentCommitHash != null) {
this.refs.set(branch.name, options.parentCommitHash);
}
return branch;
}

Expand Down
22 changes: 13 additions & 9 deletions packages/gitgraph-core/src/user-api/branch-user-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,11 @@ class BranchUserApi<TNode> {

options.from = this;

return this._graph.createBranch(options).getUserApi();
const branch = this._graph.createBranch(options);
this._commitWithParents(options, []);
this._onGraphUpdate();

return branch.getUserApi();
}

/**
Expand Down Expand Up @@ -308,14 +312,14 @@ class BranchUserApi<TNode> {
style: this._getCommitStyle(options.style),
});

if (parentOnSameBranch) {
// Take all the refs from the parent
const parentRefs = this._graph.refs.getNames(parentOnSameBranch);
parentRefs.forEach((ref) => this._graph.refs.set(ref, commit.hash));
} else {
// Set the branch ref
this._graph.refs.set(this._branch.name, commit.hash);
}
// if (parentOnSameBranch) {
// // Take all the refs from the parent
// const parentRefs = this._graph.refs.getNames(parentOnSameBranch);
// parentRefs.forEach((ref) => this._graph.refs.set(ref, commit.hash));
// } else {
// // Set the branch ref
// }
this._graph.refs.set(this._branch.name, commit.hash);

// Add the new commit
this._graph.commits.push(commit);
Expand Down
4 changes: 2 additions & 2 deletions packages/gitgraph-core/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
"declaration": true,
"sourceMap": true,
"removeComments": false,
"strict": true,
"noImplicitAny": true,
"strict": false,
"noImplicitAny": false,
"noImplicitReturns": true,
"noImplicitThis": true,
"noUnusedLocals": true,
Expand Down
20 changes: 11 additions & 9 deletions packages/gitgraph-js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,19 @@
"publishConfig": {
"access": "public"
},
"main": "./lib/index.js",
"browser": "./lib/gitgraph.umd.js",
"module": "./lib/index.js",
"jsnext:main": "./lib/index.js",
"typings": "./lib/index.d.ts",
"main": "dist/gitgraph.umd.js",
"browser": "dist/gitgraph.umd.js",
"module": "dist/gitgraph.umd.js",
"jsnext:main": "dist/index.es.js",
"typings:main": "dist/gitgraph.d.ts",
"directories": {
"lib": "lib"
"lib": "dist"
},
"files": [
"lib"
"dist"
],
"scripts": {
"start": "rollup -c -w",
"prewatch": "rimraf ./lib",
"watch": "tsc -w",
"build": "run-s build:*",
Expand All @@ -49,14 +50,15 @@
"version": "auto-changelog -p -l 0 --tag-prefix @gitgraph/js@ && git add CHANGELOG.md"
},
"dependencies": {
"@gitgraph/core": "1.5.0"
"@gitgraph/core": "1.5.0",
"@rollup/plugin-typescript": "8.5.0"
},
"devDependencies": {
"@types/node": "9.4.6",
"auto-changelog": "1.12.1",
"npm-run-all": "4.1.2",
"rimraf": "2.6.2",
"rollup": "1.10.1",
"rollup": "2.79.1",
"rollup-plugin-commonjs": "9.3.4",
"rollup-plugin-node-resolve": "4.2.3",
"uglify-es": "3.3.9"
Expand Down
8 changes: 5 additions & 3 deletions packages/gitgraph-js/rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import resolve from "rollup-plugin-node-resolve";
import commonJS from "rollup-plugin-commonjs";
import typescript from "@rollup/plugin-typescript";

export default {
input: "lib/index.js",
input: "src/index.ts",
output: {
file: "lib/gitgraph.umd.js",
file: "dist/gitgraph.umd.js",
format: "umd",
name: "GitgraphJS",
sourcemap: true,
},
plugins: [resolve(), commonJS()],
plugins: [resolve(), commonJS(), typescript({ module: "ESNext" })],
};
32 changes: 21 additions & 11 deletions packages/gitgraph-js/src/gitgraph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ function createGitgraph(
let commitsElements: {
[commitHash: string]: {
branchLabel: SVGGElement | null;
branchLabels: SVGGraphicsElement[] | null;
tags: SVGGElement[];
message: SVGGElement | null;
};
Expand Down Expand Up @@ -195,21 +196,24 @@ function createGitgraph(
// Ensure commits elements (branch labels, message…) are well positionned.
// It can't be done at render time since elements size is dynamic.
Object.keys(commitsElements).forEach((commitHash) => {
const { branchLabel, tags, message } = commitsElements[commitHash];
const { branchLabels, tags, message } = commitsElements[commitHash];

// We'll store X position progressively and translate elements.
let x = commitMessagesX;

if (branchLabel) {
branchLabels.forEach((branchLabel) => {
moveElement(branchLabel, x);

// BBox width misses box padding
// => they are set later, on branch label update.
// We would need to make branch label update happen before to solve it.
const branchLabelWidth =
branchLabel.getBBox().width + 2 * BRANCH_LABEL_PADDING_X;
x += branchLabelWidth + padding;
}
// BBox width misses box padding and offset
// => they are set later, on branchLabel update.
// We would need to make branchLabel update happen before to solve it.
const offset = parseFloat(
branchLabel.getAttribute("data-offset") || "0",
);
const tagWidth =
branchLabel.getBBox().width + 2 * TAG_PADDING_X + offset;
x += tagWidth + padding;
});

tags.forEach((tag) => {
moveElement(tag, x);
Expand Down Expand Up @@ -440,12 +444,16 @@ function createGitgraph(

if (!gitgraph.branchLabelOnEveryCommit) {
const commitHash = gitgraph.refs.getCommit(branch.name);
if (commit.hash !== commitHash) return null;
if (branch.name == "develop") {
}
if (commit.hash !== commitHash) {
return null;
}
}

// For the moment, we don't handle multiple branch labels.
// To do so, we'd need to reposition each of them appropriately.
if (commit.branchToDisplay !== branch.name) return null;
// if (commit.branchToDisplay !== branch.name) return null;

const branchLabel = branch.renderLabel
? branch.renderLabel(branch)
Expand Down Expand Up @@ -592,6 +600,7 @@ function createGitgraph(
}

commitsElements[commit.hashAbbrev].branchLabel = branchLabels;
commitsElements[commit.hashAbbrev].branchLabels.push(branchLabels);
}

function setMessageRef(commit: Commit, message: SVGGElement | null): void {
Expand All @@ -613,6 +622,7 @@ function createGitgraph(
function initCommitElements(commit: Commit): void {
commitsElements[commit.hashAbbrev] = {
branchLabel: null,
branchLabels: [],
tags: [],
message: null,
};
Expand Down
6 changes: 3 additions & 3 deletions packages/gitgraph-js/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"compilerOptions": {
"rootDir": "src",
"outDir": "lib",
"target": "es5",
"target": "es6",
"module": "es2015",
"lib": [
"dom",
Expand All @@ -11,8 +11,8 @@
"declaration": true,
"sourceMap": true,
"removeComments": false,
"strict": true,
"noImplicitAny": true,
"strict": false,
"noImplicitAny": false,
"noImplicitReturns": true,
"noImplicitThis": true,
"noUnusedLocals": true,
Expand Down
1 change: 1 addition & 0 deletions packages/gitgraph-node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
},
"main": "./src/index.ts",
"scripts": {
"start": "rollup -c -w",
"example:default": "ts-node examples/default.ts",
"example:branches": "ts-node examples/branches.ts",
"version": "auto-changelog -p -l 0 --tag-prefix @gitgraph/node@ && git add CHANGELOG.md"
Expand Down
4 changes: 2 additions & 2 deletions packages/gitgraph-node/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
"declaration": true,
"sourceMap": true,
"removeComments": false,
"strict": true,
"noImplicitAny": true,
"strict": false,
"noImplicitAny": false,
"noImplicitReturns": true,
"noImplicitThis": true,
"noUnusedLocals": true
Expand Down
14 changes: 8 additions & 6 deletions packages/gitgraph-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,12 @@
"publishConfig": {
"access": "public"
},
"main": "./lib/bundle.umd.js",
"module": "./lib/index.js",
"jsnext:main": "./lib/index.js",
"typings": "./lib/index.d.ts",
"main": "dist/bundle.umd.js",
"module": "dist/bundle.umd.js",
"jsnext:main": "dist/index.es.js",
"typings:main": "dist/Gitgraph.d.ts",
"scripts": {
"start": "rollup -c -w",
"prewatch": "rimraf ./lib",
"watch": "tsc -w",
"build": "run-s build:*",
Expand All @@ -44,7 +45,8 @@
"version": "auto-changelog -p -l 0 --tag-prefix @gitgraph/react@ && git add CHANGELOG.md"
},
"dependencies": {
"@gitgraph/core": "1.5.0"
"@gitgraph/core": "1.5.0",
"@rollup/plugin-typescript": "8.5.0"
},
"peerDependencies": {
"react": ">= 16.8.0"
Expand All @@ -59,7 +61,7 @@
"react": "16.8.4",
"react-dom": "16.8.4",
"rimraf": "2.6.2",
"rollup": "0.51.8",
"rollup": "2.79.1",
"uglify-es": "3.3.9"
}
}
20 changes: 13 additions & 7 deletions packages/gitgraph-react/rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
import typescript from "@rollup/plugin-typescript";

const globals = {
"@gitgraph/core": "gitgraph.core",
react: "React",
};

export default {
input: "lib/index.js",
input: "src/index.tsx",
output: {
file: "lib/bundle.umd.js",
// name: "@gitgraph/react",
file: "dist/bundle.umd.js",
format: "umd",

name: "GitgraphReact",
exports: "named",
sourcemap: true,

globals: globals,
},
name: "GitgraphReact",
exports: "named",
sourcemap: true,
external: Object.keys(globals),
plugins: [typescript({ module: "ESNext" })],
onwarn,
globals,
};

function onwarn(message) {
Expand Down
Loading