this.me 2.4.7 → 2.4.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,11 @@
1
+ const { getAllFiles, hashThis } = require('./path-to-your-main-file');
2
+
3
+ process.on('message', (directory) => {
4
+ try {
5
+ const files = getAllFiles(directory);
6
+ const hash = hashThis(files);
7
+ process.send({ success: true, hash });
8
+ } catch (error) {
9
+ process.send({ success: false, error: error.message });
10
+ }
11
+ });
@@ -0,0 +1,43 @@
1
+ //hashing.js
2
+ //.. THIS SECTION IS FOR HASHING PURPOSES ...//
3
+ /* Create a function that computes the hash of the @src directory.
4
+ 'hash-src') to handle hashing when the relevant command is passed to the script.*/
5
+ const fs = require('fs');
6
+ const path = require('path');
7
+ const crypto = require('crypto');
8
+
9
+ function getAllFiles(directory) {
10
+ const stack = [directory];
11
+ const visited = new Set();
12
+ const filesList = [];
13
+ while (stack.length) {
14
+ const currentDir = stack.pop();
15
+ if (visited.has(currentDir)) continue;
16
+ visited.add(currentDir);
17
+ const contents = fs.readdirSync(currentDir, { withFileTypes: true });
18
+ for (const item of contents) {
19
+ const fullPath = path.join(currentDir, item.name);
20
+ if (item.isDirectory()) {
21
+ stack.push(fullPath);
22
+ } else if (item.isFile()) {
23
+ filesList.push(fullPath);
24
+ }
25
+ }
26
+ }
27
+ return filesList;
28
+ }
29
+
30
+ function hashThis(directory) {
31
+ const files = getAllFiles(directory);
32
+ const hash = crypto.createHash('sha256');
33
+ for (const file of files) {
34
+ const fileData = fs.readFileSync(file);
35
+ hash.update(fileData);
36
+ }
37
+ return hash.digest('hex');
38
+ }
39
+
40
+ module.exports = {
41
+ getAllFiles,
42
+ hashThis
43
+ };
package/main.js CHANGED
@@ -28,6 +28,10 @@ Welcome to .me - Your AI Playground
28
28
  give me one sec please...
29
29
  `);
30
30
  };
31
+
32
+ //User Context.
33
+ const os = require('os');
34
+ console.log(`Running as user: ${os.userInfo().username}`);
31
35
  //ATOMS ELECTRONS AND PARTICLES IN PROGRESS...
32
36
  //WE WILL RUN OUR NODE PROCCESSES IN ELECTRON WINDOWS AND EACH ATOM WILL HOLD ELECTRONS WHICH HOLDS THE PROCESSES
33
37
  //THUS WE WILL KNOW HOW CHARGED AN ATOM IS BY THE NUMBER OF ELECTRONS IT HAS AND HOW MANY PROCESSES IT IS RUNNING.
@@ -63,41 +67,10 @@ function handleAtomCommand() {
63
67
 
64
68
  //.. THIS SECTION IS FOR HASHING PURPOSES ...//
65
69
  /* Create a function that computes the hash of the @src directory.
66
- 'hash-src') to handle hashing when the relevant command is passed to the script.*/
67
- function getAllFiles(directory) {
68
- const entries = fs.readdirSync(directory, { withFileTypes: true });
69
- const files = entries.filter(fileDirent => fileDirent.isFile()).map(fileDirent => path.join(directory, fileDirent.name));
70
- const folders = entries.filter(folderDirent => folderDirent.isDirectory());
71
- for (const folder of folders) {
72
- files.push(...getAllFiles(path.join(directory, folder.name)));
73
- }
74
- return files;
75
- }
76
- function hashThis(directoryOrFilePath) {
77
- // Ensure path is absolute
78
- if (!path.isAbsolute(directoryOrFilePath)) {
79
- throw new Error('Path must be absolute.');
80
- }
81
- let allContent = "";
82
- // Check if it's a directory or a file
83
- const stat = fs.statSync(directoryOrFilePath);
84
- if (stat.isDirectory()) {
85
- // Get all files from the directory recursively
86
- const allFiles = getAllFiles(directoryOrFilePath);
87
- // Read all file content and concatenate it
88
- allContent = allFiles.map(file => fs.readFileSync(file)).join('');
89
- } else if (stat.isFile()) {
90
- // Read file content
91
- allContent = fs.readFileSync(directoryOrFilePath);
92
- } else {
93
- throw new Error('Provided path is neither a directory nor a file.');
94
- }
95
- // Hash the content using SHA256 (or another hashing algorithm)
96
- const hash = crypto.createHash('sha256').update(allContent).digest('hex');
97
- return hash;
98
- }
99
-
100
- function hashSrc() {
70
+ 'hashSrc') to handle hashing when the relevant command is passed to the script.*/
71
+ const { fork } = require('child_process');
72
+ const { getAllFiles, hashThis } = require('./hash/hashing');
73
+ function hashSrc() {
101
74
  try {
102
75
  // Adjust this to the exact location of your @src directory
103
76
  const srcDirPath = path.resolve(__dirname, '@src');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "this.me",
3
- "version": "2.4.7",
3
+ "version": "2.4.9",
4
4
  "description": "This.me should This.be",
5
5
  "bin": {
6
6
  ".me": "./main.js"
@@ -25,6 +25,8 @@
25
25
  "dependencies": {
26
26
  "be.this": "^1.1.3",
27
27
  "cleaker": "^2.2.9",
28
+ "crypto": "^1.0.1",
29
+ "fs": "^0.0.1-security",
28
30
  "i.mlearning": "^2.1.7",
29
31
  "netget": "^2.1.6",
30
32
  "neurons.me": "^2.6.3",
package/testHashIt.js ADDED
@@ -0,0 +1,3 @@
1
+ const { hashThis } = require('./main.js');
2
+ const hashValueForFile = hashThis('/');
3
+ console.log(`Hash value for the file: ${hashValueForFile}`);
package/tab.js DELETED
@@ -1,29 +0,0 @@
1
- const { app, BrowserWindow, ipcMain } = require('electron');
2
- let win;
3
- app.on('ready', () => {
4
- win = new BrowserWindow({
5
- width: 377,
6
- height: 244,
7
- webPreferences: {
8
- nodeIntegration: true,
9
- contextIsolation: false, // Add this line
10
- },
11
- frame: false,
12
- transparent: true,
13
- //opacity: 0.5
14
- });
15
-
16
- win.on('closed', () => {
17
- win = null;
18
- });
19
-
20
- win.loadFile('./atom/view.html');
21
- });
22
-
23
- ipcMain.on('minimize-window', () => {
24
- win.minimize();
25
- });
26
-
27
- ipcMain.on('close-window', () => {
28
- win.close();
29
- });