Skip to content

Commit 2df7e4c

Browse files
authored
Merge branch 'staging' into JIB3377-patch-1
2 parents 871a1b8 + 7b7a993 commit 2df7e4c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+1348
-402
lines changed

.eslintrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
"rules": {
77
"arrow-body-style": "off",
88
"no-plusplus": "off",
9-
"no-param-reassign": "off"
9+
"no-param-reassign": "off",
10+
"linebreak-style": "off"
1011
},
1112
"env": {
1213
"jest": true,

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
# production
1212
/build
13+
/dist
1314

1415
# misc
1516
.DS_Store

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ Spearmint helps developers easily create functional React/Redux/Endpoint/Paint T
55
# Installation
66
Please download spearmint from our [website](https://www.spearmintjs.com/). Available for Mac OS, Windows and Linux.
77

8+
89
# How to use in development mode
910

1011
### For Mac developers
@@ -29,10 +30,20 @@ In an Administrator PowerShell run the following command:
2930
2. ```npm run install-once```
3031
3. ```npm run start-windows```
3132

33+
Download spearmint @ spearmintjs.com. Available for Mac OS, Windows and Linux.
34+
35+
36+
Mac users:
37+
### Pre-requisite
38+
* Download latest version of Xcode
39+
* run "npm install-once" to install dependencies and run electron rebuild sequentially
40+
41+
<br>
3242

3343

3444
# How it works
3545

46+
3647
1. On the initial screen, load your application to start creating tests.
3748

3849
![](/public/mainPage.JPG)

config-overrides.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/* config-overrides.js */
2+
3+
module.exports = function override(config, env) {
4+
//do stuff with the webpack config...
5+
config.target = 'electron-renderer';
6+
return config;
7+
}

package.json

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"name": "spearmint",
3-
"version": "0.5.0",
3+
"version": "0.6.0",
44
"description": "An open-source developer tool that simplifies testing and hopes to help increase awareness about web accessibility.",
5-
"author": "spearmintjs",
5+
"author": "team spearmint",
66
"build": {
77
"appId": "com.spearmint",
88
"files": [
@@ -12,12 +12,24 @@
1212
],
1313
"directories": {
1414
"buildResources": "build"
15+
},
16+
"linux": {
17+
"target": [
18+
"deb"
19+
],
20+
"icon": "build/icon.*",
21+
"maintainer": "Team Spearmint"
1522
}
1623
},
1724
"main": "public/electron.js",
25+
"bugs": {
26+
"url": "https://github.com/oslabs-beta/spearmint_LA42/issues"
27+
},
1828
"homepage": "./",
1929
"private": true,
2030
"dependencies": {
31+
"@material-ui/core": "^4.11.3",
32+
"@material-ui/icons": "^4.11.2",
2133
"@types/jest": "^25.2.3",
2234
"@types/react-beautiful-dnd": "^12.1.2",
2335
"@types/react-dom": "^16.9.8",
@@ -28,33 +40,40 @@
2840
"dotenv": "^8.2.0",
2941
"electron-is-dev": "^1.1.0",
3042
"fibers": "^5.0.0",
43+
"fix-path": "^3.0.0",
3144
"js-beautify": "^1.10.0",
3245
"monaco-editor": "^0.17.0",
33-
"node-sass": "^4.12.0",
46+
"node-pty": "^0.10.0",
3447
"react": "^16.8.6",
3548
"react-autosuggest": "^9.4.3",
3649
"react-beautiful-dnd": "^11.0.3",
3750
"react-dom": "^16.8.6",
3851
"react-modal": "^3.8.1",
3952
"react-monaco-editor": "^0.25.1",
4053
"react-scripts": "^3.4.1",
41-
"sass": "^1.26.5",
54+
"sass": "^1.32.11",
4255
"typescript": "^3.9.2",
43-
"wait-on": "^3.3.0"
56+
"wait-on": "^3.3.0",
57+
"xterm": "^4.11.0",
58+
"xterm-addon-fit": "^0.5.0",
59+
"xterm-for-react": "^1.0.4"
4460
},
4561
"scripts": {
46-
"test": "react-scripts test --env=jsdom",
62+
"install-once": "npm i && npm run electron-rebuild",
63+
"test": "react-app-rewired test --env=jsdom",
4764
"test:e2e": "./node_modules/mocha/bin/mocha src/__tests__/spec.e2e.js",
4865
"test:integra": "mocha src/__tests__/spec.integra.js",
4966
"test:watch": "jest --watch",
5067
"react-start": "react-scripts start",
5168
"react-eject": "react-scripts eject",
52-
"build": "NODE_ENV=production npm run react-build && npm run electron-build",
69+
"build": "NODE_ENV=production react-app-rewired build && npm run electron-build",
5370
"react-build": "NODE_ENV=production react-scripts build",
5471
"electron-build": "NODE_ENV=production electron-builder -mwl",
72+
"electron-rebuild": "electron-rebuild -f -w node-pty",
73+
"postinstall": "electron-builder install-app-deps",
5574
"release": "npm run react-build && electron-builder --publish=always",
56-
"start-windows": "SET NODE_ENV=development concurrently \"cross-env BROWSER=none npm run react-start\" \"wait-on http://localhost:3000 && electron .\"",
57-
"start": "NODE_ENV=development concurrently \"cross-env BROWSER=none npm run react-start\" \"wait-on http://localhost:3000 && electron .\""
75+
"start-windows": "cross-env NODE_ENV=development concurrently \"cross-env BROWSER=none react-app-rewired start\" \"wait-on http://localhost:3000 && electron .\"",
76+
"start": "NODE_ENV=development concurrently \"cross-env BROWSER=none react-app-rewired start\" \"wait-on http://localhost:3000 && electron .\""
5877
},
5978
"browserslist": {
6079
"production": [
@@ -78,9 +97,10 @@
7897
"@typescript-eslint/parser": "^2.33.0",
7998
"chai": "^4.3.4",
8099
"chai-as-promised": "^7.1.1",
81-
"electron": "^5.0.3",
100+
"electron": "^12.0.5",
82101
"electron-builder": "^22.6.1",
83102
"electron-devtools-installer": "^3.0.0",
103+
"electron-rebuild": "^2.3.5",
84104
"enzyme": "^3.10.0",
85105
"enzyme-adapter-react-16": "^1.14.0",
86106
"eslint-config-airbnb-typescript": "^7.2.1",
@@ -89,8 +109,9 @@
89109
"eslint-plugin-react": "^7.20.0",
90110
"eslint-plugin-react-hooks": "^2.5.1",
91111
"mocha": "^8.3.2",
112+
"react-app-rewired": "^2.1.8",
92113
"react-test-renderer": "^16.12.0",
93114
"spectron": "^5.0.0",
94115
"test-data-bot": "^0.8.0"
95116
}
96-
}
117+
}

public/AccLens_Demo.gif

404 KB
Loading

public/appDemo - Copy.gif

-2 MB
Binary file not shown.

public/electron.js

Lines changed: 173 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,173 @@
1-
const { app, BrowserWindow } = require('electron');
2-
const path = require('path');
3-
const isDev = require('electron-is-dev');
4-
let mainWindow;
5-
6-
if (isDev) console.log('electron version', process.versions.electron);
7-
8-
if (isDev) {
9-
const {
10-
default: installExtension,
11-
REACT_DEVELOPER_TOOLS,
12-
} = require('electron-devtools-installer');
13-
function addDevTools() {
14-
app.whenReady().then(() => {
15-
installExtension(REACT_DEVELOPER_TOOLS)
16-
.then((name) => console.log(`Added Extension: ${name}`))
17-
.catch((err) => console.log('An error occurred: ', err));
18-
});
19-
}
20-
}
21-
function createWindow() {
22-
mainWindow = new BrowserWindow({
23-
width: 1550,
24-
height: 750,
25-
minHeight: 750,
26-
icon: path.join(__dirname, 'public/icon.png'),
27-
webPreferences: {
28-
nodeIntegration: true,
29-
webviewTag: true,
30-
},
31-
});
32-
mainWindow.loadURL(
33-
isDev ? 'http://localhost:3000' : `file://${path.join(__dirname, '../build/index.html')}`
34-
);
35-
mainWindow.on('closed', () => (mainWindow = null));
36-
}
37-
38-
if (isDev) {
39-
app.on('ready', addDevTools);
40-
}
41-
42-
app.on('ready', createWindow);
43-
app.on('window-all-closed', () => {
44-
if (process.platform !== 'darwin') {
45-
app.quit();
46-
}
47-
});
48-
app.on('activate', () => {
49-
if (mainWindow === null) {
50-
createWindow();
51-
}
52-
});
1+
const {
2+
app, BrowserWindow, ipcMain, dialog,
3+
} = require('electron');
4+
const path = require('path');
5+
const isDev = require('electron-is-dev');
6+
const fs = require('fs');
7+
const os = require('os');
8+
const pty = require('node-pty');
9+
const fixPath = require('fix-path');
10+
11+
//Dynamic variable to change terminal type based on os
12+
const shell = os.platform() === 'win32' ? 'powershell.exe' : 'bash';
13+
console.log("process.env.Path1: ", process.env.PATH);
14+
//=> '/usr/bin'
15+
16+
fixPath();
17+
18+
console.log("process.env.Path2: ", process.env.PATH);
19+
//=> '/usr/local/bin:/usr/bin'
20+
let mainWindow;
21+
22+
if (isDev) console.log('electron version', process.versions.electron);
23+
24+
if (isDev) {
25+
const {
26+
default: installExtension,
27+
REACT_DEVELOPER_TOOLS,
28+
} = require('electron-devtools-installer');
29+
function addDevTools() {
30+
app.whenReady().then(() => {
31+
installExtension(REACT_DEVELOPER_TOOLS)
32+
.then((name) => console.log(`Added Extension: ${name}`))
33+
.catch((err) => console.log('An error occurred: ', err));
34+
});
35+
}
36+
};
37+
38+
function createWindow() {
39+
mainWindow = new BrowserWindow({
40+
width: 1550,
41+
height: 750,
42+
minHeight: 750,
43+
icon: path.join(__dirname, 'icon.png'),
44+
webPreferences: {
45+
nodeIntegration: true,
46+
webviewTag: true,
47+
contextIsolation: false,
48+
},
49+
});
50+
mainWindow.loadURL(
51+
isDev ? 'http://localhost:3000' : `file://${path.join(__dirname, '../build/index.html')}`,
52+
);
53+
mainWindow.on('closed', () => (mainWindow = null));
54+
55+
// PTY PROCESS FOR IN APP TERMINAL
56+
const ptyArgs = {
57+
name: 'xterm-color',
58+
cols: 80,
59+
rows: 80,
60+
cwd: process.env.HOME,
61+
env: process.env,
62+
};
63+
console.log("process.env.HOME: ", process.env.HOME);
64+
65+
const ptyProcess = pty.spawn(shell, [], ptyArgs);
66+
// with ptyProcess, we want to send incoming data to the channel terminal.incData
67+
ptyProcess.on('data', (data) => {
68+
mainWindow.webContents.send('terminal.incData', data);
69+
});
70+
// in the main process, at terminal.toTerm channel, when data is received,
71+
// main process will write to ptyProcess
72+
ipcMain.on('terminal.toTerm', (event, data) => {
73+
ptyProcess.write(data);
74+
});
75+
}
76+
77+
// EDITORVIEW.JSX SAVE FILE FUNCTIONALITY
78+
ipcMain.on('EditorView.saveFile', (e, filePath, editedText) => {
79+
fs.writeFile(filePath, editedText, (err) => {
80+
if (err) throw err;
81+
});
82+
// Return a success message upon save
83+
e.returnValue = 'Changes Saved';
84+
});
85+
86+
/*
87+
EXPORTFILEMODAL.JSX FILE FUNCTIONALITY
88+
(check existence and create folder)
89+
*/
90+
ipcMain.on('ExportFileModal.exists', (e, fileOrFolderPath) => {
91+
e.returnValue = fs.existsSync(fileOrFolderPath, (err) => {
92+
if (err) throw err;
93+
});
94+
});
95+
96+
ipcMain.on('ExportFileModal.mkdir', (e, folderPath) => {
97+
e.returnValue = fs.mkdirSync(folderPath, (err) => {
98+
if (err) throw err;
99+
});
100+
});
101+
102+
ipcMain.on('ExportFileModal.fileCreate', (e, filePath, file) => {
103+
e.returnValue = fs.writeFile(filePath, file, (err) => {
104+
if (err) throw err;
105+
});
106+
});
107+
108+
ipcMain.on('ExportFileModal.readFile', (e, filePath) => {
109+
e.returnValue = fs.readFileSync(filePath, 'utf8', (err) => {
110+
if (err) throw err;
111+
});
112+
});
113+
114+
// OPENFOLDERBUTTON.JSX FILE FUNCTIONALITY
115+
ipcMain.on('OpenFolderButton.isDirectory', (e, filePath) => {
116+
e.returnValue = fs.statSync(filePath).isDirectory();
117+
});
118+
119+
ipcMain.on('OpenFolderButton.dialog', (e) => {
120+
const dialogOptions = {
121+
properties: ['openDirectory', 'createDirectory'],
122+
filters: [
123+
{ name: 'Javascript Files', extensions: ['js', 'jsx'] },
124+
{ name: 'Style', extensions: ['css'] },
125+
{ name: 'Html', extensions: ['html'] },
126+
],
127+
message: 'Please select your project folder',
128+
};
129+
e.returnValue = dialog.showOpenDialogSync(dialogOptions);
130+
});
131+
132+
/*
133+
UNIVERSAL IPC CALLS
134+
(The following IPC calls are made from various components in the codebase)
135+
*/
136+
ipcMain.on('Universal.stat', (e, filePath) => {
137+
e.returnValue = fs.statSync(filePath).isDirectory();
138+
});
139+
140+
ipcMain.on('Universal.readDir', (e, projectFilePath) => {
141+
e.returnValue = fs.readdirSync(projectFilePath, (err) => {
142+
if (err) throw err;
143+
});
144+
});
145+
146+
ipcMain.on('Universal.readFile', (e, filePath) => {
147+
e.returnValue = fs.readFileSync(filePath, 'utf8', (err) => {
148+
if (err) throw err;
149+
});
150+
});
151+
152+
ipcMain.on('Universal.path', (e, folderPath, filePath) => {
153+
e.returnValue = path.relative(folderPath, filePath, (err) => {
154+
if (err) throw err;
155+
});
156+
})
157+
158+
// ELECTRON BOILERPLATE FOR DEVTOOLS AND WINDOW CREATION
159+
if (isDev) {
160+
app.on('ready', addDevTools);
161+
}
162+
163+
app.on('ready', createWindow);
164+
app.on('window-all-closed', () => {
165+
if (process.platform !== 'darwin') {
166+
app.quit();
167+
}
168+
});
169+
app.on('activate', () => {
170+
if (mainWindow === null) {
171+
createWindow();
172+
}
173+
});

public/generateTest.png

207 KB
Loading
395 KB
Loading

0 commit comments

Comments
 (0)