New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

acme-commander

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

acme-commander - npm Package Compare versions

Comparing version 1.3.1 to 1.4.0

2

package.json
{
"name": "acme-commander",
"version": "1.3.1",
"version": "1.4.0",
"description": "Twin-panel file manager",

@@ -5,0 +5,0 @@ "bin": "bin/acme-commander.sh",

@@ -57,2 +57,5 @@ const { Event, Gravity, Rectangle } = imports.gi.Gdk;

createTab: action(this.createTab),
deselectAll: action(this.deselectAll),
invert: action(this.invert),
selectAll: action(this.selectAll),
showHidSys: action(this.showHidSys),

@@ -226,2 +229,19 @@ });

ActionService.prototype.deselectAll = function() {
this.tabService.deselectAll(this.panelService.getActiveTabId());
};
ActionService.prototype.deselectGlob = function() {
this.dialogService.prompt("Pattern:", "", pattern => {
if (pattern) {
this.tabService.deselectGlob({
id: this.panelService.getActiveTabId(),
pattern,
});
}
return;
});
};
ActionService.prototype.getPlaces = function() {

@@ -288,2 +308,6 @@ this.gioService.getPlaces((_, places) => {

ActionService.prototype.invert = function() {
this.tabService.invert(this.panelService.getActiveTabId());
};
ActionService.prototype.jobs = function() {

@@ -539,2 +563,26 @@ /** @type {Popover} */

ActionService.prototype.selectAll = function() {
this.tabService.selectAll(this.panelService.getActiveTabId());
};
ActionService.prototype.selectDiff = function() {
this.tabService.selectDiff(
this.panelService.entities[0].activeTabId,
this.panelService.entities[1].activeTabId,
);
};
ActionService.prototype.selectGlob = function() {
this.dialogService.prompt("Pattern:", "", pattern => {
if (pattern) {
this.tabService.selectGlob({
id: this.panelService.getActiveTabId(),
pattern,
});
}
return;
});
};
ActionService.prototype.showHidSys = function() {

@@ -541,0 +589,0 @@ this.tabService.showHidSys = !this.tabService.showHidSys;

@@ -269,2 +269,8 @@ const Gdk = imports.gi.Gdk;

case Gdk.KEY_a:
if (ev.ctrlKey) {
actionService.selectAll();
}
break;
case Gdk.KEY_b:

@@ -282,2 +288,14 @@ if (ev.ctrlKey) {

case Gdk.KEY_d:
if (ev.ctrlKey) {
actionService.deselectAll();
}
break;
case Gdk.KEY_I:
if (ev.ctrlKey) {
actionService.invert();
}
break;
case Gdk.KEY_j:

@@ -284,0 +302,0 @@ if (ev.ctrlKey) {

const { FileType } = imports.gi.Gio;
const GLib = imports.gi.GLib;
const Component = require("inferno-component").default;

@@ -67,3 +68,6 @@ const h = require("inferno-hyperscript").default;

DirectoryFile.prototype.shouldSearchSkip = function(input) {
return this.props.file.name.toLowerCase().indexOf(input.toLowerCase()) !== 0;
return !GLib.pattern_match_simple(
input.toLowerCase() + "*",
this.props.file.name.toLowerCase(),
);
};

@@ -70,0 +74,0 @@

const { FileType } = imports.gi.Gio;
const expect = require("expect");
const h = require("inferno-hyperscript").default;
const { File } = require("../../domain/File/File");
const { DirectoryFile } = require("./DirectoryFile");

@@ -119,2 +120,15 @@ const { shallow } = require("../Test/Test");

});
it("selects matching file as user types, with glob support", () => {
const file = new File();
file.name = "foo.bar";
const dirFile = new DirectoryFile({
file,
isSelected: false,
});
expect(dirFile.shouldSearchSkip("*.bar")).toBe(false);
expect(dirFile.shouldSearchSkip("*.js")).toBe(true);
});
});

@@ -25,3 +25,3 @@ const Gdk = imports.gi.Gdk;

if (shiftKey && which === Gdk.KEY_Down) {
if ((shiftKey && which === Gdk.KEY_Down) || which === Gdk.KEY_Insert) {
if (selected.indexOf(cursor) !== -1) {

@@ -114,3 +114,15 @@ return assign({}, state, {

if (which === Gdk.KEY_space) {
if (selected.indexOf(cursor) !== -1) {
return assign({}, state, {
selected: selected.filter(x => x !== cursor),
});
} else {
return assign({}, state, {
selected: selected.concat(cursor).sort((a, b) => a - b),
});
}
}
return state;
};

@@ -11,2 +11,3 @@ const expect = require("expect");

Shift__Down: [1, 0, 0],
Insert: [1, 0, 0],
Up: [0, null, 0],

@@ -18,2 +19,3 @@ Shift__Up: [0, 0, 0],

Shift__Page_Up: [0, 0, 0],
space: [0, 0, 0],
});

@@ -25,2 +27,3 @@

Shift__Down: [1, null, 0],
Insert: [1, null, 0],
Up: [0, 0, 0],

@@ -32,2 +35,3 @@ Shift__Up: [0, null, 0],

Shift__Page_Up: [0, null, 0],
space: [0, null, 0],
});

@@ -39,2 +43,3 @@

Shift__Down: [1, "1 5 7 11", 0],
Insert: [1, "1 5 7 11", 0],
Up: [0, "0 5 7 11", 0],

@@ -46,2 +51,3 @@ Shift__Up: [0, "1 5 7 11", 0],

Shift__Page_Up: [0, "1 5 7 11", 0],
space: [0, "1 5 7 11", 0],
});

@@ -53,2 +59,3 @@

Shift__Down: [13, "0 12", 0],
Insert: [13, "0 12", 0],
Up: [11, "0 11", 0],

@@ -60,2 +67,3 @@ Shift__Up: [11, "0 12", 0],

Shift__Page_Up: [0, "0 12", 0],
space: [12, "0 12", 0],
});

@@ -67,2 +75,3 @@

Shift__Down: [1, "1 12", 0],
Insert: [1, "1 12", 0],
Up: [0, "0 12", 0],

@@ -74,2 +83,3 @@ Shift__Up: [0, "1 12", 0],

Shift__Page_Up: [0, "1 12", 0],
space: [0, "1 12", 0],
});

@@ -81,2 +91,3 @@

Shift__Down: [13, null, 0],
Insert: [13, null, 0],
Up: [11, 12, 0],

@@ -88,2 +99,3 @@ Shift__Up: [11, null, 0],

Shift__Page_Up: [0, null, 0],
space: [12, null, 0],
});

@@ -95,2 +107,3 @@

Shift__Down: [3, 2, 0],
Insert: [3, 2, 0],
Up: [1, null, 0],

@@ -102,2 +115,3 @@ Shift__Up: [1, 2, 0],

Shift__Page_Up: [0, "0 2", 0],
space: [2, 2, 0],
});

@@ -109,2 +123,3 @@

Shift__Down: [3, null, 0],
Insert: [3, null, 0],
Up: [1, 2, 0],

@@ -116,2 +131,3 @@ Shift__Up: [1, null, 0],

Shift__Page_Up: [0, null, 0],
space: [2, null, 0],
});

@@ -123,2 +139,3 @@

Shift__Down: [13, 12, 0],
Insert: [13, 12, 0],
Up: [11, null, 0],

@@ -130,2 +147,3 @@ Shift__Up: [11, 12, 0],

Shift__Page_Up: [0, "1 12", 0],
space: [12, 12, 0],
});

@@ -137,2 +155,3 @@

Shift__Down: [14, 13, 1],
Insert: [14, 13, 1],
Up: [12, null, 0],

@@ -144,2 +163,3 @@ Shift__Up: [12, 13, 0],

Shift__Page_Up: [1, "2 13", 0],
space: [13, 13, 0],
});

@@ -151,2 +171,3 @@

Shift__Down: [14, null, 1],
Insert: [14, null, 1],
Up: [12, 13, 0],

@@ -158,2 +179,3 @@ Shift__Up: [12, null, 0],

Shift__Page_Up: [1, null, 0],
space: [13, null, 0],
});

@@ -165,2 +187,3 @@

Shift__Down: [25, 25, 12],
Insert: [25, 25, 12],
Up: [24, null, 12],

@@ -172,2 +195,3 @@ Shift__Up: [24, 25, 12],

Shift__Page_Up: [13, "14 25", 12],
space: [25, 25, 12],
});

@@ -179,2 +203,3 @@

Shift__Down: [25, null, 12],
Insert: [25, null, 12],
Up: [24, 25, 12],

@@ -186,2 +211,3 @@ Shift__Up: [24, null, 12],

Shift__Page_Up: [13, null, 12],
space: [25, null, 12],
});

@@ -193,2 +219,3 @@

Shift__Down: [14, "13 25", 12],
Insert: [14, "13 25", 12],
Up: [12, "14 25", 12],

@@ -200,2 +227,3 @@ Shift__Up: [12, "13 25", 12],

Shift__Page_Up: [1, "2 25", 1],
space: [13, "13 25", 12],
});

@@ -207,2 +235,3 @@

Shift__Down: [25, "13 24", 12],
Insert: [25, "13 24", 12],
Up: [24, "13 25", 12],

@@ -214,2 +243,3 @@ Shift__Up: [24, "13 24", 12],

Shift__Page_Up: [13, 13, 12],
space: [25, "13 24", 12],
});

@@ -216,0 +246,0 @@ });

@@ -24,2 +24,8 @@ const Component = require("inferno-component").default;

{ action: "paste", label: "Paste" },
{ action: "selectAll", label: "Select all" },
{ action: "deselectAll", label: "Deselect all" },
{ action: "invert", label: "Invert selection" },
{ action: "selectGlob", label: "Select glob" },
{ action: "deselectGlob", label: "Deselect glob" },
{ action: "selectDiff", label: "Compare directories" },
],

@@ -26,0 +32,0 @@

const { FileType } = imports.gi.Gio;
const GLib = imports.gi.GLib;
const { action, computed, extendObservable, observable } = require("mobx");

@@ -13,2 +14,4 @@ const orderBy = require("lodash/orderBy");

cursor: action(this.cursor),
deselectAll: action(this.deselectAll),
deselectGlob: action(this.deselectGlob),
entities: {

@@ -30,2 +33,7 @@ 0: {

},
invert: action(this.invert),
selectAll: action(this.selectAll),
selectDiff: action(this.selectDiff),
selectGlob: action(this.selectGlob),
selected: action(this.selected),
set: action(this.set),

@@ -41,22 +49,17 @@ showHidSys: this.showHidSys,

const sampleFiles = [
{
name: "..",
fileType: FileType.DIRECTORY,
icon: "folder",
iconType: "ICON_NAME",
size: 0,
modificationTime: Date.now(),
mode: "0755",
},
{
name: "clan in da front.txt",
fileType: FileType.REGULAR,
icon: "text-x-generic",
iconType: "ICON_NAME",
size: 4110,
modificationTime: Date.now(),
mode: "0644",
},
];
/**
* @type {File[]}
*/
const sampleFiles = [{
displayName: "..",
fileType: FileType.DIRECTORY,
icon: "go-up",
iconType: "ICON_NAME",
mode: "1755",
modificationTime: 0,
mountUri: "file:///",
name: "..",
size: 0,
uri: "file:///",
}];

@@ -83,2 +86,89 @@ /**

/**
* @param {number} tabId
*/
TabService.prototype.deselectAll = function(tabId) {
this.entities[tabId].selected.splice(0);
};
/**
* @param {{ id: number, pattern: string }} props
*/
TabService.prototype.deselectGlob = function(props) {
if (!props.pattern) {
return;
}
const tab = this.entities[props.id];
const visibleFiles = this.visibleFiles[props.id];
tab.selected = tab.selected
.filter(i => !GLib.pattern_match_simple(props.pattern, visibleFiles[i].name));
};
/**
* @param {number} tabId
*/
TabService.prototype.invert = function(tabId) {
const tab = this.entities[tabId];
tab.selected = this.visibleFiles[tabId]
.map((_, i) => i)
.filter((i) => tab.selected.indexOf(i) === -1);
};
/**
* @param {number} tabId
*/
TabService.prototype.selectAll = function(tabId) {
this.entities[tabId].selected = this.visibleFiles[tabId].map((_, i) => i);
};
/**
* @param {number} id
* @param {number} id1
*/
TabService.prototype.selectDiff = function(id, id1) {
const files = this.visibleFiles[id];
const files1 = this.visibleFiles[id1];
/** @type {number[]} */
const selected = [];
/** @type {number[]} */
const selected0 = [];
for (let i = 0; i < files.length; i++) {
if (this.hasDiff(files[i], files1)) {
selected.push(i);
}
}
for (let i = 0; i < files1.length; i++) {
if (this.hasDiff(files1[i], files)) {
selected0.push(i);
}
}
this.entities[id].selected = selected;
this.entities[id1].selected = selected0;
};
/**
* @param {{ id: number, pattern: string }} props
*/
TabService.prototype.selectGlob = function(props) {
if (!props.pattern) {
return;
}
const tab = this.entities[props.id];
tab.selected = this.visibleFiles[props.id]
.map((file, i) => GLib.pattern_match_simple(props.pattern, file.name)
? i
: tab.selected.indexOf(i))
.filter((i) => i !== -1);
};
/**
* @param {{ selected: number[], tabId: number }} props

@@ -91,15 +181,28 @@ */

/**
* @param {{ files: any[], id: number, location: string, sortedBy?: string }} props
* @param {{ files: any[], id: number, location: string }} props
*/
TabService.prototype.set = function(props) {
const tab = this.entities[props.id];
const sortedBy = props.sortedBy || tab.sortedBy;
tab.files = observable.shallowArray(sortFiles(sortedBy, props.files));
let visibleFiles = this.visibleFiles[props.id];
const cursorUri = visibleFiles[tab.cursor].uri;
const selectedUris = tab.selected.map(i => visibleFiles[i].uri);
tab.files = observable.shallowArray(sortFiles(tab.sortedBy, props.files));
tab.location = props.location;
const visibleFiles = this.visibleFiles[props.id];
visibleFiles = this.visibleFiles[props.id];
const cursor = visibleFiles.findIndex(file => file.uri === cursorUri);
tab.cursor = Math.min(tab.cursor, visibleFiles.length);
tab.selected = tab.selected.filter(x => x < visibleFiles.length);
tab.cursor = cursor === -1
? Math.min(tab.cursor, visibleFiles.length - 1)
: cursor;
const selected = [];
for (let i = 0; i < visibleFiles.length; i++) {
if (selectedUris.indexOf(visibleFiles[i].uri) !== -1) {
selected.push(i);
}
}
tab.selected = selected;
};

@@ -112,8 +215,9 @@

const tab = this.entities[props.tabId];
tab.sortedBy = nextSort(tab.sortedBy, props.by);
const by = nextSort(tab.sortedBy, props.by);
const files = sortFiles(by, tab.files);
tab.sortedBy = by;
tab.files = files;
this.set({
files: tab.files,
id: props.tabId,
location: tab.location,
});
};

@@ -134,2 +238,31 @@

/**
* @private
* @param {File} file
* @param {File[]} files1
*/
TabService.prototype.hasDiff = function(file, files1) {
if (file.name === "..") {
return false;
}
for (const file1 of files1) {
if (file.name !== file1.name) {
continue;
}
if (file.size !== file1.size) {
continue;
}
if (file.modificationTime !== file1.modificationTime) {
continue;
}
return false;
}
return true;
};
exports.nextSort = nextSort;

@@ -136,0 +269,0 @@ function nextSort(prevBy, by) {

const { FileType } = imports.gi.Gio;
const expect = require("expect");
const { File } = require("../../domain/File/File");
const { TabService } = require("./TabService");

@@ -73,3 +74,3 @@

expect(tabService.entities[0].cursor).toBe(2);
expect(tabService.entities[0].cursor).toBe(1);
expect(tabService.entities[0].selected.slice()).toEqual([0, 1]);

@@ -83,2 +84,3 @@ });

"0": {
cursor: 0,
files: [

@@ -96,2 +98,3 @@ ["config.sub", 2],

})),
selected: [],
sortedBy: undefined,

@@ -168,2 +171,3 @@ },

"0": {
cursor: 0,
files: [

@@ -178,2 +182,3 @@ "n.w.a",

})),
selected: [],
sortedBy: undefined,

@@ -198,2 +203,265 @@ },

});
it("selects glob", () => {
const tabService = new TabService();
const tab = tabService.entities[0];
tab.files = [
"config.sub",
"usb.ids",
"magic.mgc",
"pci.ids",
"node_modules",
"config.guess",
].map(name => {
const file = new File();
file.name = name;
return file;
});
tab.selected = [];
tabService.selectGlob({
id: 0,
pattern: "*.ids",
});
expect(tab.selected.slice()).toEqual([1, 3]);
});
it("selects glob, noop if empty pattern", () => {
const tabService = new TabService();
const tab = tabService.entities[0];
tab.files = [
"config.sub",
"usb.ids",
"magic.mgc",
"pci.ids",
"node_modules",
"config.guess",
].map(name => {
const file = new File();
file.name = name;
return file;
});
tab.selected = [1, 3];
tabService.selectGlob({
id: 0,
pattern: "",
});
expect(tab.selected.slice()).toEqual([1, 3]);
});
it("inverts", () => {
const tabService = new TabService();
const tab = tabService.entities[0];
tab.files = [
"config.sub",
"usb.ids",
"magic.mgc",
"pci.ids",
"node_modules",
"config.guess",
].map(name => {
const file = new File();
file.name = name;
return file;
});
tab.selected = [1, 3];
tabService.invert(0);
expect(tab.selected.slice()).toEqual([0, 2, 4, 5]);
});
it("deselects glob", () => {
const tabService = new TabService();
const tab = tabService.entities[0];
tab.files = [
"config.sub",
"usb.ids",
"magic.mgc",
"pci.ids",
"node_modules",
"config.guess",
].map(name => {
const file = new File();
file.name = name;
return file;
});
tab.selected = [0, 2, 4, 5];
tabService.deselectGlob({
id: 0,
pattern: "*.guess",
});
expect(tab.selected.slice()).toEqual([0, 2, 4]);
});
it("deselects glob, noop if empty pattern", () => {
const tabService = new TabService();
const tab = tabService.entities[0];
tab.files = [
"config.sub",
"usb.ids",
"magic.mgc",
"pci.ids",
"node_modules",
"config.guess",
].map(name => {
const file = new File();
file.name = name;
return file;
});
tab.selected = [0, 2, 4];
tabService.deselectGlob({
id: 0,
pattern: "",
});
expect(tab.selected.slice()).toEqual([0, 2, 4]);
});
it("deselects all", () => {
const tabService = new TabService();
const tab = tabService.entities[0];
tab.files = [
"config.sub",
"usb.ids",
"magic.mgc",
"pci.ids",
"node_modules",
"config.guess",
].map(name => {
const file = new File();
file.name = name;
return file;
});
tab.selected = [0, 2, 4];
tabService.deselectAll(0);
expect(tab.selected.length).toBe(0);
});
it("selects all", () => {
const tabService = new TabService();
const tab = tabService.entities[0];
tab.files = [
"config.sub",
"usb.ids",
"magic.mgc",
"pci.ids",
"node_modules",
"config.guess",
].map(name => {
const file = new File();
file.name = name;
return file;
});
tabService.selectAll(0);
expect(tab.selected.slice()).toEqual([0, 1, 2, 3, 4, 5]);
});
it("selects diff, empty selected if all equal", () => {
const tabService = new TabService();
const tab = tabService.entities[0];
tab.files = [new File()];
const tab1 = tabService.entities[1];
tab1.files = [new File()];
tabService.selectDiff(0, 1);
expect(tab.selected.length).toBe(0);
expect(tab1.selected.length).toBe(0);
});
it("selects diff, comparing name", () => {
const tabService = new TabService();
const tab = tabService.entities[0];
tab.files = [new File()];
tab.files[0].name = "style.css";
const tab1 = tabService.entities[1];
tab1.files = [new File()];
tab1.files[0].name = "main.js";
tabService.selectDiff(0, 1);
expect(tab.selected.slice()).toEqual([0]);
expect(tab1.selected.slice()).toEqual([0]);
});
it("selects diff, comparing mtime", () => {
const tabService = new TabService();
const tab = tabService.entities[0];
tab.files = [new File()];
tab.files[0].modificationTime = 0;
const tab1 = tabService.entities[1];
tab1.files = [new File()];
tab1.files[0].modificationTime = 1;
tabService.selectDiff(0, 1);
expect(tab.selected.slice()).toEqual([0]);
expect(tab1.selected.slice()).toEqual([0]);
});
it("selects diff, comparing size", () => {
const tabService = new TabService();
const tab = tabService.entities[0];
tab.files = [new File()];
tab.files[0].size = 0;
const tab1 = tabService.entities[1];
tab1.files = [new File()];
tab1.files[0].size = 1;
tabService.selectDiff(0, 1);
expect(tab.selected.slice()).toEqual([0]);
expect(tab1.selected.slice()).toEqual([0]);
});
it("selects diff, skipping dotdot", () => {
const tabService = new TabService();
const tab = tabService.entities[0];
tab.files = [new File()];
tab.files[0].name = "..";
tab.files[0].size = 0;
const tab1 = tabService.entities[1];
tab1.files = [new File()];
tab1.files[0].name = "..";
tab1.files[0].size = 1;
tabService.selectDiff(0, 1);
expect(tab.selected.length).toBe(0);
expect(tab1.selected.length).toBe(0);
});
});
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