Skip to content

Commit

Permalink
Titan v1.3.0 Release
Browse files Browse the repository at this point in the history
Merge pull request #8 from ArrushC/7-add-issue-number-per-each-branch-folder
  • Loading branch information
ArrushC authored Sep 17, 2024
2 parents 16b31c8 + 3e9f5f6 commit c6f1c51
Show file tree
Hide file tree
Showing 18 changed files with 384 additions and 168 deletions.
2 changes: 1 addition & 1 deletion dist/assets/index.css

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

6 changes: 3 additions & 3 deletions dist/assets/index.js

Large diffs are not rendered by default.

62 changes: 31 additions & 31 deletions dist/assets/vendor.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "titan",
"private": true,
"proxy": "http://localhost:5173",
"version": "1.2.19",
"version": "1.3.0",
"type": "module",
"main": "main.js",
"description": "A desktop application for streamlining your workflow in Revision Control Systems (RCS) like Subversion (SVN).",
Expand Down
89 changes: 40 additions & 49 deletions server/logger.js
Original file line number Diff line number Diff line change
@@ -1,75 +1,66 @@
import { createLogger, format, transports } from "winston";
import fs from "fs";
import path from "path";
import { fileURLToPath } from "url";

const { combine, timestamp, printf, errors, label } = format;
const { combine, timestamp, printf, errors } = format;

const myFormat = printf(({ level, message, timestamp, stack, label }) => {
return `${timestamp} [${label}] [${level}]: ${stack || message}`;
return `${timestamp} [${label}] [${level}]: ${stack || message}`;
});

export const logFilePath = "C:/ATHive/Titan.app.log";

// Ensure the log file exists
const logDir = path.dirname(logFilePath);
if (!fs.existsSync(logDir)) {
fs.mkdirSync(logDir, { recursive: true });
}
if (!fs.existsSync(logFilePath)) {
fs.writeFileSync(logFilePath, "");
fs.mkdirSync(logDir, { recursive: true });
}

fs.writeFileSync(logFilePath, "");

const baseLogger = createLogger({
format: combine(
timestamp({ format: "YYYY-MM-DD HH:mm:ss" }),
errors({ stack: true }),
myFormat
),
transports: [
new transports.Console({
level: "info",
format: combine(
format.colorize(),
myFormat
),
}),
new transports.File({
filename: logFilePath,
level: "silly",
maxsize: 5242880, // 5MB
maxFiles: 5,
}),
],
format: combine(timestamp({ format: "YYYY-MM-DD HH:mm:ss" }), errors({ stack: true }), myFormat),
transports: [
new transports.Console({
level: "info",
format: combine(format.colorize(), myFormat),
}),
new transports.File({
filename: logFilePath,
level: "silly",
maxsize: 5242880, // 5MB
maxFiles: 5,
}),
],
});

export function setupLogger(moduleName) {
return {
log: (level, message, meta = {}) => {
baseLogger.log(level, message, { ...meta, label: moduleName });
},
error: (message, meta) => baseLogger.error(message, { ...meta, label: moduleName }),
warn: (message, meta) => baseLogger.warn(message, { ...meta, label: moduleName }),
info: (message, meta) => baseLogger.info(message, { ...meta, label: moduleName }),
verbose: (message, meta) => baseLogger.verbose(message, { ...meta, label: moduleName }),
debug: (message, meta) => baseLogger.debug(message, { ...meta, label: moduleName }),
silly: (message, meta) => baseLogger.silly(message, { ...meta, label: moduleName }),
};
return {
log: (level, message, meta = {}) => {
baseLogger.log(level, message, { ...meta, label: moduleName });
},
error: (message, meta) => baseLogger.error(message, { ...meta, label: moduleName }),
warn: (message, meta) => baseLogger.warn(message, { ...meta, label: moduleName }),
info: (message, meta) => baseLogger.info(message, { ...meta, label: moduleName }),
verbose: (message, meta) => baseLogger.verbose(message, { ...meta, label: moduleName }),
debug: (message, meta) => baseLogger.debug(message, { ...meta, label: moduleName }),
silly: (message, meta) => baseLogger.silly(message, { ...meta, label: moduleName }),
};
}

export function setupUncaughtExceptionHandler(logger) {
process.on('uncaughtException', (error) => {
logger.error('Uncaught Exception:', error);
process.exit(1);
});
process.on("uncaughtException", (error) => {
logger.error("Uncaught Exception:", error);
process.exit(1);
});

process.on('unhandledRejection', (reason, promise) => {
logger.error('Unhandled Rejection at:', promise, 'reason:', reason);
});
process.on("unhandledRejection", (reason, promise) => {
logger.error("Unhandled Rejection at:", promise, "reason:", reason);
});
}

export default {
logFilePath,
setupLogger,
setupUncaughtExceptionHandler
};
logFilePath,
setupLogger,
setupUncaughtExceptionHandler,
};
20 changes: 15 additions & 5 deletions server/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,10 @@ async function sendConfig(socket) {
currentVersion: latestVersion,
branches: [],
branchFolderColours: {},
commitOptions: {
useIssuePerFolder: false,
reusePreviousCommitMessage: false,
},
trelloIntegration: {
key: "TRELLO_API_KEY",
token: "TRELLO_TOKEN",
Expand Down Expand Up @@ -809,16 +813,20 @@ io.on("connection", (socket) => {
return acc;
}, {});

let originalIssueNumber = issueNumber[sourceBranch["Branch Folder"]] || "";

for (const [svnBranch, branchInfo] of Object.entries(filesByBranch)) {
const { branchId, branchFolder, branchVersion, files } = branchInfo;

let prefixedCommitMessage;
let originalMessage = `(${sourceBranch["Branch Folder"]}${originalIssueNumber !== "" ? ` #${originalIssueNumber}` : ""})`;
if (branchFolder === sourceBranch["Branch Folder"]) {
prefixedCommitMessage = `Issue ${issueNumber} (${branchFolder} ${sourceBranch["Branch Version"]}): ${commitMessage}`;
} else {
prefixedCommitMessage = `Issue ${issueNumber} (${sourceBranch["Branch Folder"]}): ${commitMessage}`;
originalMessage = `(${branchFolder} ${sourceBranch["Branch Version"]})`;
}
prefixedCommitMessage = sanitizeCommitMessage(prefixedCommitMessage);

let branchIssueNumber = issueNumber[branchFolder] || originalIssueNumber;
let prefixedCommitMessage = sanitizeCommitMessage(`Issue ${branchIssueNumber} ${originalMessage}: ${commitMessage}`);

console.log("Commit message:", prefixedCommitMessage);

const task = {
command: "commit",
Expand All @@ -844,6 +852,7 @@ io.on("connection", (socket) => {
// Emit commit status for frontend
io.emit("svn-commit-status-live", {
branchId: branchId,
branchIssueNumber: branchIssueNumber,
"Branch Folder": branchFolder,
"Branch Version": branchVersion,
"SVN Branch": svnBranch,
Expand All @@ -862,6 +871,7 @@ io.on("connection", (socket) => {
// Emit commit status for frontend
io.emit("svn-commit-status-live", {
branchId: branchId,
branchIssueNumber: branchIssueNumber,
"Branch Folder": branchFolder,
"Branch Version": branchVersion,
"SVN Branch": svnBranch,
Expand Down
34 changes: 20 additions & 14 deletions src/AppContext.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const AppContext = createContext({
sourceBranch: null,
setSourceBranch: (_) => {},
branchOptions: [],
issueNumber: null,
issueNumber: {},
setIssueNumber: (_) => {},
commitMessage: "",
setCommitMessage: (_) => {},
Expand All @@ -56,7 +56,7 @@ export const AppProvider = ({ children }) => {
const [config, setConfig] = useState(null);
const [socket, setSocket] = useState(null);
const toast = useToast();
const [isDebug, setIsDebug] = useState(localStorage.getItem("isDebug") === "true");
const [isDebug, setIsDebug] = useState(() => localStorage.getItem("isDebug") === "true");

useEffect(() => {
const newSocket = socketIOClient(URL_SOCKET_CLIENT);
Expand Down Expand Up @@ -94,7 +94,7 @@ export const AppProvider = ({ children }) => {
const saveConfig = useCallback(
(configToSave) => {
if (configToSave === null || configToSave === undefined) return;
console.log("Saving config:", configToSave);
console.debug("Saving config:", configToSave);
socket?.emit("titan-config-set", configToSave);
},
[socket]
Expand All @@ -104,6 +104,7 @@ export const AppProvider = ({ children }) => {
(updateFunction) => {
setConfig((currentConfig) => {
const newConfig = updateFunction(currentConfig);
if (_.isEqual(currentConfig, newConfig)) return currentConfig;
saveConfig(newConfig);
return newConfig;
});
Expand All @@ -125,17 +126,22 @@ export const AppProvider = ({ children }) => {
const untrackedChangesGridRef = useRef(null);
const [showCommitView, setShowCommitView] = useState(false);
const [sourceBranch, setSourceBranch] = useState(null);
const branchOptions = useMemo(
() =>
configurableRowData
.filter((row) => row["Branch Folder"] && row["Branch Version"] && row["SVN Branch"] && row["Branch Folder"] !== "" && row["Branch Version"] !== "" && row["SVN Branch"] !== "")
.map((row) => ({
value: row.id,
label: branchString(row["Branch Folder"], row["Branch Version"], row["SVN Branch"]),
})),
[configurableRowData]
);
const [issueNumber, setIssueNumber] = useState(null);
const branchOptions = useMemo(() => {
// if (config && config.commitOptions && config.commitOptions.useIssuePerFolder) {
// return selectedBranches.filter((row) => row["Branch Folder"] && row["Branch Version"] && row["SVN Branch"] && row["Branch Folder"] !== "" && row["Branch Version"] !== "" && row["SVN Branch"] !== "").map((row) => ({
// value: row.id,
// label: branchString(row["Branch Folder"], row["Branch Version"], row["SVN Branch"]),
// }));
// }

return configurableRowData
.filter((row) => row["Branch Folder"] && row["Branch Version"] && row["SVN Branch"] && row["Branch Folder"] !== "" && row["Branch Version"] !== "" && row["SVN Branch"] !== "")
.map((row) => ({
value: row.id,
label: branchString(row["Branch Folder"], row["Branch Version"], row["SVN Branch"]),
}));
}, [config, selectedBranches, configurableRowData]);
const [issueNumber, setIssueNumber] = useState({});
const [commitMessage, setCommitMessage] = useState("");
const [selectedLocalChanges, setSelectedLocalChanges] = useState([]);
const [selectedUntrackedChanges, setSelectedUntrackedChanges] = useState([]);
Expand Down
2 changes: 1 addition & 1 deletion src/components/AlertUpdateTitan.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export default function AlertUpdateTitan() {
} else {
RaiseClientNotificaiton("Cannot update Titan in a non-desktop application environment", "error", 5000);
}
}, [updateInProgress, RaiseClientNotificaiton, onCloseAlert]);
}, [updateInProgress, RaiseClientNotificaiton, setUpdateInProgress, onCloseAlert]);

return (
<AlertDialog isOpen={isAlertOpen} leastDestructiveRef={cancelRef} onClose={onCloseAlert} motionPreset="slideInBottom" closeOnOverlayClick={!updateInProgress}>
Expand Down
28 changes: 22 additions & 6 deletions src/components/FooterSectionCommit.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,15 @@ import React, { useCallback } from "react";
import { MdCloudUpload } from "react-icons/md";
import { useApp } from "../AppContext";
import useNotifications from "../hooks/useNotifications";
import _ from "lodash";
import useConfigUtilities from "../hooks/useConfigUtilities";
import useCommitOptions from "../hooks/useCommitOptions";

export default function FooterSectionCommit({ openCommitModal }) {
const { setShowCommitView, selectedLocalChanges, sourceBranch, issueNumber, commitMessage, setSocketPayload, configurableRowData } = useApp();
const { setShowCommitView, selectedLocalChanges, sourceBranch, issueNumber, commitMessage, setSocketPayload, configurableRowData, selectedBranches } = useApp();
const { RaiseClientNotificaiton } = useNotifications();
const commitOptions = useCommitOptions();
const { selectedBranchFolders } = useConfigUtilities();

const performRefresh = useCallback(() => {
setShowCommitView(false);
Expand All @@ -20,9 +25,19 @@ export default function FooterSectionCommit({ openCommitModal }) {
return;
}

const sourceBranchRow = configurableRowData.find((row) => row.id == sourceBranch.value);
const hasFilledIssueNumbers = commitOptions?.useIssuePerFolder ? selectedBranchFolders.every((branchFolder) => issueNumber[branchFolder] && issueNumber[branchFolder] !== "") : true;
const hasFilledSourceIssueNumber = commitOptions?.useIssuePerFolder ? !selectedBranches.some((branch) => branch["Branch Folder"] === sourceBranchRow["Branch Folder"]) || issueNumber[sourceBranchRow["Branch Folder"]] : issueNumber[sourceBranchRow["Branch Folder"]];

// Check if the issue number and commit message is provided
if (!issueNumber || !commitMessage || issueNumber === "" || commitMessage === "") {
RaiseClientNotificaiton("Please provide the issue number and the commit message to proceed!", "error");
if (!issueNumber || _.isEmpty(issueNumber) || !hasFilledIssueNumbers || !hasFilledSourceIssueNumber) {
RaiseClientNotificaiton("Please provide the issue number to proceed!", "error");
return;
}

// Check if the commit message is provided
if (!commitMessage || commitMessage.trim() === "") {
RaiseClientNotificaiton("Please provide the commit message to proceed!", "error");
return;
}

Expand All @@ -32,9 +47,9 @@ export default function FooterSectionCommit({ openCommitModal }) {
// return;
// }

setSocketPayload({ sourceBranch: configurableRowData.find((row) => row.id == sourceBranch.value), issueNumber: issueNumber, commitMessage, filesToProcess: selectedLocalChanges });
setSocketPayload({ sourceBranch: sourceBranchRow, issueNumber: issueNumber, commitMessage, filesToProcess: selectedLocalChanges });
openCommitModal();
}, [sourceBranch, issueNumber, commitMessage, RaiseClientNotificaiton, selectedLocalChanges, configurableRowData]);
}, [RaiseClientNotificaiton, sourceBranch, configurableRowData, commitOptions, selectedBranchFolders, issueNumber, selectedBranches, commitMessage, selectedLocalChanges]);

return (
<Box>
Expand All @@ -44,7 +59,8 @@ export default function FooterSectionCommit({ openCommitModal }) {
</Button>
<Tooltip label={"Select at least 1 file"} hasArrow isDisabled={selectedLocalChanges.length > 0}>
<Button onClick={performCommit} leftIcon={<Icon as={MdCloudUpload} />} colorScheme={"yellow"} isDisabled={selectedLocalChanges.length < 1}>
Commit {selectedLocalChanges.length > 0 ? `${selectedLocalChanges.length} File` : ""}{selectedLocalChanges.length > 1 ? "s" : ""}
Commit {selectedLocalChanges.length > 0 ? `${selectedLocalChanges.length} File` : ""}
{selectedLocalChanges.length > 1 ? "s" : ""}
</Button>
</Tooltip>
</Flex>
Expand Down
Loading

0 comments on commit c6f1c51

Please sign in to comment.