Socket
Socket
Sign inDemoInstall

battenberg

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

battenberg - npm Package Compare versions

Comparing version 0.1.0 to 0.2.0

.battenberg.json

36

app/src/backend.js
const {fetch, Headers, Request} = window;
function gimme(req) {
return fetch(req)
.then(resp => {
if (resp.ok) {
return resp;
} else {
throw resp;
}
})
.then(resp => resp.json());
}
function POST(url, data) {

@@ -10,7 +22,17 @@ const headers = new Headers({

const req = new Request(url, {body, method, headers});
return fetch(req).then(resp => resp.json());
return gimme(req);
}
function PUT(url, data) {
const headers = new Headers({
'Content-Type': 'application/json'
});
const body = JSON.stringify(data);
const method = 'PUT';
const req = new Request(url, {body, method, headers});
return gimme(req);
}
function GET(url) {
return fetch(url).then(resp => resp.json());
return gimme(url);
}

@@ -31,4 +53,14 @@

function saveSettings(settings) {
return PUT('/settings', settings);
}
function loadSettings(settings) {
return GET('/settings');
}
exports.lint = lint;
exports.open = open;
exports.cwd = cwd;
exports.saveSettings = saveSettings;
exports.loadSettings = loadSettings;

16

app/src/log-view.js

@@ -24,12 +24,12 @@ 'use strict';

const {logs} = props;
let elem = null;
const ref = ref => { elem = ref; };
const refs = {elem: null};
const ref = elem => { refs.elem = elem; };
const scrollToTop = () => {
if (elem) {
elem.scrollTop = 0;
if (refs.elem) {
refs.elem.scrollTop = 0;
}
};
const scrollToBottom = () => {
if (elem) {
elem.scrollTop = elem.scrollHeight;
if (refs.elem) {
refs.elem.scrollTop = refs.elem.scrollHeight;
}

@@ -40,4 +40,4 @@ };

R('div', {className: 'LogViewToolbar'},
R(ToolbarButton, {text: 'Top', onClick: scrollToTop}),
R(ToolbarButton, {text: 'Bottom', onClick: scrollToBottom})
R(ToolbarButton, {text: '↑', onClick: scrollToTop}),
R(ToolbarButton, {text: '↓', onClick: scrollToBottom})
)

@@ -44,0 +44,0 @@ );

@@ -5,2 +5,3 @@ require('./main-action-bar.less');

const LoadingSpinner = require('./loading-spinner');
const Notify = require('./notify');

@@ -7,0 +8,0 @@ function MainActionBar(props) {

@@ -10,2 +10,4 @@ 'use strict';

const T = require('./translation.json');
const Settings = require('./backend');
const backend = require('./backend');

@@ -43,3 +45,3 @@ const primaryReducer = require('./primary-reducer');

// fetch('something...')
// TODO: Maybe wait for these network requests before showing the app?

@@ -54,2 +56,10 @@ backend.cwd()

backend.loadSettings()
.then(settings => {
store.dispatch({
type: 'UPDATE_SETTINGS',
value: settings
});
});
function start() {

@@ -56,0 +66,0 @@ const root = document.getElementById('react-root');

@@ -0,1 +1,4 @@

const Backend = require('./backend');
const Notify = require('./notify');
function merge(obj1, obj2) {

@@ -30,4 +33,8 @@ return Object.freeze(Object.assign({}, obj1, obj2));

UPDATE_SETTINGS: (state, action) =>
({settings: merge(state.settings, action.value)}),
UPDATE_SETTINGS: (state, action) => {
// TODO: Is it bad to write a file to the disk here in a reducer?
const settings = merge(state.settings, action.value);
Backend.saveSettings(settings);
return {settings};
},

@@ -42,2 +49,5 @@ SHOW_SETTINGS: (state, action) =>

const logs = processLintResults(action.value.results);
if (action.value.errorCount > 0) {
Notify.buildError();
}
if (state.settings.replace) {

@@ -44,0 +54,0 @@ return {logs};

{
"BUILD_ERROR": "Build error",
"APP_NAME": "Battenberg",

@@ -3,0 +4,0 @@ "CLOSE": "Close",

{
"name": "battenberg",
"version": "0.1.0",
"version": "0.2.0",
"description": "A friendly web GUI for building and developing JavaScript projects",

@@ -5,0 +5,0 @@ "main": "src/no-api.js",

const path = require('path');
module.exports = {
FILENAME: '.battenberg.json',
APP_PATH: path.join(__dirname, '..', 'app'),

@@ -5,0 +6,0 @@ PORT: 3200,

@@ -22,2 +22,3 @@ // const OFF = 'off';

strict: [WARN, 'safe'],
'no-undef': ERROR,
'wrap-iife': WARN,

@@ -24,0 +25,0 @@ 'no-trailing-spaces': WARN,

{
"BAD_REQUEST": 400
"NOT_FOUND": 404,
"BAD_REQUEST": 400,
"INTERNAL_ERROR": 500
}

@@ -11,2 +11,4 @@ 'use strict';

const routesOpen = require('./routes/open');
const routesLoadSettings = require('./routes/load-settings');
const routesSaveSettings = require('./routes/save-settings');

@@ -25,2 +27,4 @@ const app = express();

app.post('/open', routesOpen);
app.get('/settings', routesLoadSettings);
app.put('/settings', routesSaveSettings);
app.listen(C.PORT, C.HOST, greet);

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc