Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GitHub support #346

Merged
merged 6 commits into from
Sep 11, 2024
Merged
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
Binary file modified electron-app/.yarn/install-state.gz
Binary file not shown.
8 changes: 6 additions & 2 deletions electron-app/postbuild_tests/modules.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1063,7 +1063,9 @@ describe('modules', () => {
test(
'Tidy-up: Ensure new project and modules were created, then remove from repository',
async () => {
console.log('::: test Tidy-up: Ensure new project and modules were created, then remove from repository');
console.log(
'::: test Tidy-up: Ensure new project and modules were created, then remove from repository',
);

// Check that new project and modules were created
const project_folder = path.join(__dirname, 'test-repo', 'workflows', 'MyNewProject');
Expand All @@ -1081,7 +1083,9 @@ describe('modules', () => {
// Ensure new project and modules were removed
expect(fs.existsSync(project_folder)).toBeFalsy();

console.log('<<< test Tidy-up: Ensure new project and modules were created, then remove from repository');
console.log(
'<<< test Tidy-up: Ensure new project and modules were created, then remove from repository',
);
},
ONE_MINUTE,
);
Expand Down
10 changes: 10 additions & 0 deletions electron-app/src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,16 @@ export type NewModuleAPI = {
export type SettingsAPI = {
StoreReadConfig: () => Promise<Query>;
StoreWriteConfig: (query: Query) => Promise<Query>;
GithubGetRepoStatus: (query: Query) => Promise<Query>;
GithubGetUntrackedFiles: (query: Query) => Promise<Query>;
GithubGetTrackedFileChanges: (query: Query) => Promise<Query>;
GithubPull: (query: Query) => Promise<Query>;
GithubPush: (query: Query) => Promise<Query>;
GithubStageFiles: (query: Query) => Promise<Query>;
GithubUnstageFiles: (query: Query) => Promise<Query>;
GithubCommit: (query: Query) => Promise<Query>;
GithubClone: (query: Query) => Promise<Query>;
GithubCommitAllChanges: (query: Query) => Promise<Query>;
};

declare global {
Expand Down
82 changes: 81 additions & 1 deletion electron-app/src/handles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export async function display_SelectFolder(
) {
const result = await dialog.showOpenDialog(win, {
defaultPath: path,
properties: ['openDirectory'],
properties: ['openDirectory', 'createDirectory'],
});
return result.filePaths;
}
Expand Down Expand Up @@ -414,3 +414,83 @@ export async function settings_StoreWriteConfig(event: Event, data: Query) {
store.set('config', data);
return store.get('config');
}

export async function settings_GithubGetRepoStatus(
event: Event,
query: Query,
stderr_callback: (cmd: string) => void,
) {
return await SafeProcessQuery(event, query, stderr_callback);
}

export async function settings_GithubGetUntrackedFiles(
event: Event,
query: Query,
stderr_callback: (cmd: string) => void,
) {
return await SafeProcessQuery(event, query, stderr_callback);
}

export async function settings_GithubGetTrackedFileChanges(
event: Event,
query: Query,
stderr_callback: (cmd: string) => void,
) {
return await SafeProcessQuery(event, query, stderr_callback);
}

export async function settings_GithubPull(
event: Event,
query: Query,
stderr_callback: (cmd: string) => void,
) {
return await SafeProcessQuery(event, query, stderr_callback);
}

export async function settings_GithubPush(
event: Event,
query: Query,
stderr_callback: (cmd: string) => void,
) {
return await SafeProcessQuery(event, query, stderr_callback);
}

export async function settings_GithubStageFiles(
event: Event,
query: Query,
stderr_callback: (cmd: string) => void,
) {
return await SafeProcessQuery(event, query, stderr_callback);
}

export async function settings_GithubUnstageFiles(
event: Event,
query: Query,
stderr_callback: (cmd: string) => void,
) {
return await SafeProcessQuery(event, query, stderr_callback);
}

export async function settings_GithubCommit(
event: Event,
query: Query,
stderr_callback: (cmd: string) => void,
) {
return await SafeProcessQuery(event, query, stderr_callback);
}

export async function settings_GithubClone(
event: Event,
query: Query,
stderr_callback: (cmd: string) => void,
) {
return await SafeProcessQuery(event, query, stderr_callback);
}

export async function settings_GithubCommitAllChanges(
event: Event,
query: Query,
stderr_callback: (cmd: string) => void,
) {
return await SafeProcessQuery(event, query, stderr_callback);
}
30 changes: 30 additions & 0 deletions electron-app/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,36 @@ app.whenReady().then(() => {
ipcMain.handle('settings/store-write-config', (event: Event, data: Query) =>
handles.settings_StoreWriteConfig(event, data),
);
ipcMain.handle('settings/github-get-repo-status', (event: Event, query: Query) =>
handles.settings_GithubGetRepoStatus(event, query, stderr_callback),
);
ipcMain.handle('settings/github-get-untracked-files', (event: Event, query: Query) =>
handles.settings_GithubGetUntrackedFiles(event, query, stderr_callback),
);
ipcMain.handle('settings/github-get-tracked-file-changes', (event: Event, query: Query) =>
handles.settings_GithubGetTrackedFileChanges(event, query, stderr_callback),
);
ipcMain.handle('settings/github-pull', (event: Event, query: Query) =>
handles.settings_GithubPull(event, query, stderr_callback),
);
ipcMain.handle('settings/github-push', (event: Event, query: Query) =>
handles.settings_GithubPush(event, query, stderr_callback),
);
ipcMain.handle('settings/github-stage-files', (event: Event, query: Query) =>
handles.settings_GithubStageFiles(event, query, stderr_callback),
);
ipcMain.handle('settings/github-unstage-files', (event: Event, query: Query) =>
handles.settings_GithubUnstageFiles(event, query, stderr_callback),
);
ipcMain.handle('settings/github-commit', (event: Event, query: Query) =>
handles.settings_GithubCommit(event, query, stderr_callback),
);
ipcMain.handle('settings/github-clone', (event: Event, query: Query) =>
handles.settings_GithubClone(event, query, stderr_callback),
);
ipcMain.handle('settings/github-commit-all-changes', (event: Event, query: Query) =>
handles.settings_GithubCommitAllChanges(event, query, stderr_callback),
);
});

app.on('will-quit', () => {
Expand Down
14 changes: 14 additions & 0 deletions electron-app/src/preload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,20 @@ contextBridge.exposeInMainWorld('newmoduleAPI', {
contextBridge.exposeInMainWorld('settingsAPI', {
StoreReadConfig: () => ipcRenderer.invoke('settings/store-read-config'),
StoreWriteConfig: (query: Query) => ipcRenderer.invoke('settings/store-write-config', query),
GithubGetRepoStatus: (query: Query) =>
ipcRenderer.invoke('settings/github-get-repo-status', query),
GithubGetUntrackedFiles: (query: Query) =>
ipcRenderer.invoke('settings/github-get-untracked-files', query),
GithubGetTrackedFileChanges: (query: Query) =>
ipcRenderer.invoke('settings/github-get-tracked-file-changes', query),
GithubPull: (query: Query) => ipcRenderer.invoke('settings/github-pull', query),
GithubPush: (query: Query) => ipcRenderer.invoke('settings/github-push', query),
GithubStageFiles: (query: Query) => ipcRenderer.invoke('settings/github-stage-files', query),
GithubUnstageFiles: (query: Query) => ipcRenderer.invoke('settings/github-unstage-files', query),
GithubCommit: (query: Query) => ipcRenderer.invoke('settings/github-commit', query),
GithubClone: (query: Query) => ipcRenderer.invoke('settings/github-clone', query),
GithubCommitAllChanges: (query: Query) =>
ipcRenderer.invoke('settings/github-commit-all-changes', query),
});

declare global {
Expand Down
69 changes: 69 additions & 0 deletions electron-app/src/python/pyrunner.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,75 @@ def post(request):
"body": runner.CheckNodeDependencies(data),
"returncode": 0,
}
elif query == "settings/github-get-repo-status":
data = {
"query": query,
"body": runner.github.GetRepoStatus(data["repo"], data["branch"]),
"returncode": 0,
}
elif query == "settings/github-get-tracked-file-changes":
data = {
"query": query,
"body": runner.github.GetTrackedFileChanges(data["repo"]),
"returncode": 0,
}
elif query == "settings/github-get-untracked-files":
data = {
"query": query,
"body": runner.github.GetUntrackedFiles(data["repo"]),
"returncode": 0,
}
elif query == "settings/github-pull":
data = {
"query": query,
"body": runner.github.Pull(data["repo"], data["branch"]),
"returncode": 0,
}
elif query == "settings/github-push":
data = {
"query": query,
"body": runner.github.Push(data["repo"], data["branch"]),
"returncode": 0,
}
elif query == "settings/github-stage-files":
data = {
"query": query,
"body": runner.github.StageFiles(data["repo"], data["files"]),
"returncode": 0,
}
elif query == "settings/github-unstage-files":
data = {
"query": query,
"body": runner.github.UnstageFiles(data["repo"], data["files"]),
"returncode": 0,
}
elif query == "settings/github-commit":
author = data.get("author", None)
email = data.get("email", None)
data = {
"query": query,
"body": runner.github.Commit(
data["repo"], data["message"], author, email
),
"returncode": 0,
}
elif query == "settings/github-commit-all-changes":
author = data.get("author", None)
email = data.get("email", None)
data = {
"query": query,
"body": runner.github.CommitAllChanges(
data["repo"], data["message"], author, email
),
"returncode": 0,
}
elif query == "settings/github-clone":
create_folder = data.get("createfolder", True)
data = {
"query": query,
"body": runner.github.Clone(data["url"], data["path"], create_folder),
"returncode": 0,
}

else:
raise NotImplementedError(f"Unknown query: {query}")
Expand Down
Binary file modified nodemapper/.yarn/install-state.gz
Binary file not shown.
10 changes: 10 additions & 0 deletions nodemapper/src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,16 @@ export type NewModuleAPI = {
export type SettingsAPI = {
StoreReadConfig: () => Promise<Query>;
StoreWriteConfig: (query: Query) => Promise<Query>;
GithubGetRepoStatus: (query: Query) => Promise<Query>;
GithubGetUntrackedFiles: (query: Query) => Promise<Query>;
GithubGetTrackedFileChanges: (query: Query) => Promise<Query>;
GithubPull: (query: Query) => Promise<Query>;
GithubPush: (query: Query) => Promise<Query>;
GithubStageFiles: (query: Query) => Promise<Query>;
GithubUnstageFiles: (query: Query) => Promise<Query>;
GithubCommit: (query: Query) => Promise<Query>;
GithubClone: (query: Query) => Promise<Query>;
GithubCommitAllChanges: (query: Query) => Promise<Query>;
};

declare global {
Expand Down
37 changes: 37 additions & 0 deletions nodemapper/src/components/DialogWait.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import CircularProgress from '@mui/material/CircularProgress';
import Typography from '@mui/material/Typography';
import Modal from '@mui/material/Modal';
import Box from '@mui/material/Box';
import React from 'react';

interface DialogWaitProps {
open: boolean;
text?: string;
}

export const DialogWait = ({ open, text }: DialogWaitProps) => {
text = text || 'Please wait...';
return (
<Modal open={open} onClose={() => {}}>
<Box
sx={{
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
height: '100%',
width: '100%',
}}
>
<Box sx={{ alignItems: 'center', textAlign: 'center', background: 'white', p: 4 }}>
<CircularProgress />
<Box sx={{ height: 20 }} />
<Typography variant="subtitle1" gutterBottom>
{text}
</Typography>
</Box>
</Box>
</Modal>
);
};

export default DialogWait;
Loading
Loading