Skip to content

Commit

Permalink
working on packaging and distribution
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenlabrie committed Feb 22, 2021
1 parent 9162992 commit b3b02ae
Show file tree
Hide file tree
Showing 49 changed files with 17,056 additions and 631 deletions.
Binary file added .DS_Store
Binary file not shown.
1 change: 1 addition & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"presets": [
"@babel/preset-env",
"@babel/preset-react"
]
}
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
node_modules/
node_modules
5 changes: 5 additions & 0 deletions app/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"presets": [
"@babel/preset-react"
]
}
1 change: 1 addition & 0 deletions app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules/
11 changes: 9 additions & 2 deletions electron.js → app/electron.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ const { app, BrowserWindow } = require('electron')
const path = require('path')
const url = require('url')
const server = require('./server/server')
const express = require('express');


// Add React extension for development
const { default: installExtension, REACT_DEVELOPER_TOOLS } = require('electron-devtools-installer')
Expand Down Expand Up @@ -55,6 +57,7 @@ if (process.platform === 'win32') {

function createWindow() {
// Create the browser window.
express()
mainWindow = new BrowserWindow({
width: 1024, // width of the window
height: 768, // height of the window
Expand All @@ -78,8 +81,12 @@ function createWindow() {
})
} else {
indexPath = url.format({
protocol: 'file:',
pathname: path.join(__dirname, 'dist', 'index.html'),
// protocol: 'file:',
// pathname: path.join(__dirname, '../dist/index.html'),
// slashes: true
protocol: 'http:',
host: 'localhost:8080',
pathname: 'index.html',
slashes: true
})
}
Expand Down
Binary file added app/icon.png/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@ const MongoClient = require('mongodb').MongoClient;
const { exec } = require('child_process');

exports.createMongoSchema = (req, res, next) => {
if (fs.existsSync(path.join(__dirname, '../../qlens.json'))) {
fs.unlinkSync(path.join(__dirname, '../../qlens.json'));
console.log('file Deleted');
}

let userURI = req.body.val;

// Connect to mongodb
Expand All @@ -28,19 +25,23 @@ exports.createMongoSchema = (req, res, next) => {
console.log(`stdout: ${stdout}`);
});
});
let filepath = path.join(__dirname, '../../');
let filepath = path.join(__dirname, '../../../');
let file;
// Watching for changes in root directory. (The adding of json file with schema)
const watcher = fs.watch(filepath, (event, trigger) => {
console.log(`there was a ${event} at ${trigger}`);
// Once change happens (file is added) read schema.json file
file = fs.readFileSync(path.join(__dirname, '../../qlens.json'));
file = fs.readFileSync(path.join(__dirname, '../../../qlens.json'));
// console.log('SERVER.JS =========> ', Buffer.from(file).toString())
res.locals.data = Buffer.from(file).toString();
if (res.locals.data) {
// send locals data to client, close this watch function
res.status(200).json(res.locals.data);
watcher.close();
if (fs.existsSync(path.join(__dirname, '../../../qlens.json'))) {
fs.unlinkSync(path.join(__dirname, '../../../qlens.json'));
console.log('file Deleted');
}
}
});
};
File renamed without changes.
51 changes: 51 additions & 0 deletions app/server/server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
(function() {
const express = require('express');
const path = require('path');
const app = express();
const cors = require('cors');
const fs = require('fs');
const { graphqlHTTP } = require('express-graphql');
const schemaRoute = require('./schema');

const mongoSchemaController = require('./controllers/mongoSchemaController');


app.use(express.json());
app.use(cors());

// Getting mongodb uri from Frontend
app.post('/getURI', mongoSchemaController.createMongoSchema);

app.post(
'/selectedSchemas',
schemaRoute.converter.migrateSchema,
(req, res) => {
res.status(200).json({
types: res.locals.types,
queries: res.locals.queries,
mutation: res.locals.mutations,
mongoSchema: res.locals.mongoSchema,
});
app.use(
'/graphql',
graphqlHTTP({ schema: res.locals.convertedSchema, graphiql: true })
);
}
);

// global error handler --->
app.use((err, req, res, next) => {
const defaultErr = {
log: 'Express error handler caught unknown middleware error',
status: 500,
message: { err: 'An error occurred' },
};
const errorObj = Object.assign({}, defaultErr, err);
console.log(errorObj.log);
return res.status(errorObj.status).json(errorObj.message);
});


app.listen(3000, () => console.log('listening on port 3000'));
module.exports = app;
})()
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import { Tab, Tabs, TabList, TabPanel } from 'react-tabs';
import 'react-tabs/style/react-tabs.css';
require('codemirror/mode/javascript/javascript');
import '../public/codemirror.css';
import '../../node_modules/codemirror/lib/codemirror.css';
import '../../node_modules/codemirror/theme/dracula.css';
import '../../../node_modules/codemirror/lib/codemirror.css';
import '../../../node_modules/codemirror/theme/dracula.css';
import DownloadBtn from './DownloadBtn'
const _ = require('lodash');
const MongoSchemaIDE = ({schemaData, selectedSchemaData, graphQLSchema}) => {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit b3b02ae

Please sign in to comment.