@node-core/utils 5.15.0 → 5.16.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.
package/README.md CHANGED
@@ -47,7 +47,7 @@ If you would prefer to build from the source, install and link:
47
47
  ```
48
48
  git clone git@github.com:nodejs/node-core-utils.git
49
49
  cd node-core-utils
50
- npm install
50
+ npm ci
51
51
  npm link
52
52
  ```
53
53
 
package/lib/config.js CHANGED
@@ -2,7 +2,7 @@ import path from 'node:path';
2
2
  import os from 'node:os';
3
3
 
4
4
  import { readJson, writeJson } from './file.js';
5
- import { existsSync } from 'node:fs';
5
+ import { existsSync, mkdtempSync, rmSync } from 'node:fs';
6
6
  import { spawnSync } from 'node:child_process';
7
7
 
8
8
  export const GLOBAL_CONFIG = Symbol('globalConfig');
@@ -61,13 +61,31 @@ export function getConfigPath(configType, dir) {
61
61
  };
62
62
 
63
63
  export function writeConfig(configType, obj, dir) {
64
- writeJson(getConfigPath(configType, dir), obj);
64
+ const configPath = getConfigPath(configType, dir);
65
+ const encryptedConfigPath = configPath + '.gpg';
66
+ if (existsSync(encryptedConfigPath)) {
67
+ const tmpDir = mkdtempSync(path.join(os.tmpdir(), 'ncurc-'));
68
+ const tmpFile = path.join(tmpDir, 'config.json');
69
+ try {
70
+ writeJson(tmpFile, obj);
71
+ const { status } = spawnSync('gpg',
72
+ ['--default-recipient-self', '--yes', '--encrypt', '--output', encryptedConfigPath, tmpFile]
73
+ );
74
+ if (status !== 0) {
75
+ throw new Error('Failed to encrypt config file: ' + encryptedConfigPath);
76
+ }
77
+ } finally {
78
+ rmSync(tmpDir, { recursive: true, force: true });
79
+ }
80
+ return encryptedConfigPath;
81
+ }
82
+ writeJson(configPath, obj);
83
+ return configPath;
65
84
  };
66
85
 
67
86
  export function updateConfig(configType, obj, dir) {
68
87
  const config = getConfig(configType, dir);
69
- const configPath = getConfigPath(configType, dir);
70
- writeJson(configPath, Object.assign(config, obj));
88
+ writeConfig(configType, Object.assign(config, obj), dir);
71
89
  };
72
90
 
73
91
  export function getHomeDir(home) {
@@ -55,6 +55,22 @@ export default class PrepareSecurityRelease extends SecurityRelease {
55
55
  // For now, close the ones with Security Release label
56
56
  await this.closePRWithLabel('Security Release');
57
57
 
58
+ if (vulnerabilityJSON.buildIssue) {
59
+ this.cli.info('Commenting on nodejs/build issue');
60
+ await this.req.commentIssue(
61
+ vulnerabilityJSON.buildIssue,
62
+ 'Security release is out'
63
+ );
64
+ }
65
+
66
+ if (vulnerabilityJSON.dockerIssue) {
67
+ this.cli.info('Commenting on nodejs/docker-node issue');
68
+ await this.req.commentIssue(
69
+ vulnerabilityJSON.dockerIssue,
70
+ 'Security release is out'
71
+ );
72
+ }
73
+
58
74
  const updateFolder = await this.cli.prompt(
59
75
  `Would you like to update the next-security-release folder to ${
60
76
  vulnerabilityJSON.releaseDate}?`,
package/lib/request.js CHANGED
@@ -81,6 +81,23 @@ export default class Request {
81
81
  return this.json(url, options);
82
82
  }
83
83
 
84
+ async commentIssue(fullUrl, comment) {
85
+ const commentUrl = fullUrl.replace('https://github.com/', 'https://api.github.com/repos/') +
86
+ '/comments';
87
+ const options = {
88
+ method: 'POST',
89
+ headers: {
90
+ Authorization: `Basic ${this.credentials.github}`,
91
+ 'User-Agent': 'node-core-utils',
92
+ Accept: 'application/vnd.github+json'
93
+ },
94
+ body: JSON.stringify({
95
+ body: comment,
96
+ })
97
+ };
98
+ return this.json(commentUrl, options);
99
+ }
100
+
84
101
  async getPullRequest(fullUrl) {
85
102
  const prUrl = fullUrl.replace('https://github.com/', 'https://api.github.com/repos/').replace('pull', 'pulls');
86
103
  const options = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@node-core/utils",
3
- "version": "5.15.0",
3
+ "version": "5.16.0",
4
4
  "description": "Utilities for Node.js core collaborators",
5
5
  "type": "module",
6
6
  "engines": {