newrelic 7.1.2 → 7.1.3

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/NEWS.md CHANGED
@@ -1,3 +1,36 @@
1
+ ### v7.1.3 (2021-03-09)
2
+
3
+ * Bumped @grpc/grpc-js to ^1.2.7.
4
+
5
+ * Removed index-bad-config test which tested a no-longer possible use-case.
6
+
7
+ * Removed license-key test logic from serverless-harvest test.
8
+
9
+ Serverless mode does not require a license key as data transfer is handled by the integration.
10
+
11
+ * Added support metric to be able to track usage of cert bundle via usage of custom certificates.
12
+
13
+ * Removed requirement to configure application name when running in AWS Lambda (serverless mode).
14
+
15
+ Application name is not currently leveraged by New Relic for Lambda invocations. The agent now defaults the application name in serverless mode to remove the requirement of end-user configuration while handling cases if it were to be leveraged in the future.
16
+
17
+ * Stopped binding/propagating segments via `setImmediate` for ended transactions.
18
+
19
+ * Fixed bug where agent would attempt to call the 'preconnect' endpoint on the redirect host returned by the previous 'preconnect' call when reconnecting to the New Relic servers.
20
+
21
+ The 'preconnect' calls will now always use the original agent configuration value. Subsequent endpoints (connect, harvest endpoints, etc.) will continue to leverage the new redirect host value returned by 'preconnect.' The original config values are no-longer overridden.
22
+
23
+ * Fixed issue where a call to `transaction.acceptDistributedTraceHeaders` would throw an error when the `headers` parameter is a string.
24
+
25
+ * Improved clarity of logging between 'no log file' or disabled agent startup issues.
26
+
27
+ * Logs no-config file error to initialized logger (stdout) in addition to existing console.error() logging.
28
+ * Adds specific message to no config file separate from being disabled.
29
+
30
+ * Removed aws-sdk versioned test filtering.
31
+
32
+ * Removed unused Travis CI scripts.
33
+
1
34
  ### v7.1.2 (2021-02-24)
2
35
 
3
36
  * Fixed bug where the agent failed to reconnect to Infinite Tracing gRPC streams on Status OK at higher log levels.
@@ -0,0 +1,109 @@
1
+ 'use strict'
2
+
3
+ const fs = require('fs')
4
+ const {program} = require('commander')
5
+
6
+ const Github = require('./github')
7
+ const { indexOf } = require('benchmark')
8
+
9
+ const DEFAULT_FILE_NAME = 'NEWS.md'
10
+ /** e.g. v7.2.1 */
11
+ const TAG_VALID_REGEX = /v\d+\.\d+\.\d+/
12
+
13
+ program.requiredOption('--tag <tag>', 'tag name to create GitHub release for')
14
+ program.option('--repo-owner <repoOwner>', 'repository owner', 'newrelic')
15
+ program.option('--release-notes-file <releaseNotesFile>', 'path to release notes file', DEFAULT_FILE_NAME)
16
+ program.option('-f --force', 'bypass validation')
17
+
18
+ async function createRelease() {
19
+ // Parse commandline options inputs
20
+ program.parse()
21
+
22
+ const options = program.opts()
23
+
24
+ console.log('Script running with following options: ', JSON.stringify(options))
25
+
26
+ const github = new Github(options.repoOwner)
27
+
28
+ try {
29
+ const tagName = options.tag.replace('refs/tags/', '')
30
+ console.log('Using tag name: ', tagName)
31
+
32
+ logStep('Validation')
33
+ if (options.force) {
34
+ console.log('--force set. Skipping validation logic')
35
+ }
36
+
37
+ if (!options.force && !TAG_VALID_REGEX.exec(tagName)) {
38
+ console.log('Tag arg invalid (%s). Valid tags in form: v#.#.# (e.g. v7.2.1)', tagName)
39
+ stopOnError()
40
+ }
41
+
42
+ logStep('Get Release Notes from File')
43
+ const body = await getReleaseNotes(tagName, options.releaseNotesFile)
44
+
45
+ logStep('Create Release')
46
+ await github.createRelease(tagName, tagName, body)
47
+
48
+ console.log('*** Full Run Successful ***')
49
+ } catch (err) {
50
+ if (err.status && err.status === 404) {
51
+ console.log('404 status error detected. For octokit, this may mean insuffient permissions.')
52
+ console.log('Ensure you have a valid GITHUB_TOKEN set in your env vars.')
53
+ }
54
+
55
+ stopOnError(err)
56
+ }
57
+ }
58
+
59
+ async function getReleaseNotes(tagName, releaseNotesFile) {
60
+ console.log('Retrieving release notes from file: ', releaseNotesFile)
61
+
62
+ const data = await readReleaseNoteFile(releaseNotesFile)
63
+
64
+ const currentVersionHeader = `### ${tagName}`
65
+ if (data.indexOf(currentVersionHeader) !== 0) {
66
+ throw new Error(`Current tag (${currentVersionHeader}) not first line of release notes.`)
67
+ }
68
+
69
+ const sections = data.split('### ', 2)
70
+ if (sections.length !== 2) {
71
+ throw new Error('Did not split into multiple sections. Double check notes format.')
72
+ }
73
+
74
+ const tagSection = sections[1]
75
+ // e.g. v7.1.2 (2021-02-24)\n\n
76
+ const headingRegex = /^v\d+\.\d+\.\d+ \(\d{4}-\d{2}-\d{2}\)\n\n/
77
+ const headingRemoved = tagSection.replace(headingRegex, '')
78
+
79
+ return headingRemoved
80
+ }
81
+
82
+ async function readReleaseNoteFile(file) {
83
+ const promise = new Promise((resolve, reject) => {
84
+ fs.readFile(file, 'utf8', function (err, data) {
85
+ if (err) {
86
+ return reject(err)
87
+ }
88
+
89
+ resolve(data)
90
+ })
91
+ })
92
+
93
+ return promise
94
+ }
95
+
96
+ function stopOnError(err) {
97
+ if (err) {
98
+ console.error(err)
99
+ }
100
+
101
+ console.log('Halting execution with exit code: 1')
102
+ process.exit(1)
103
+ }
104
+
105
+ function logStep(step) {
106
+ console.log(`\n ----- [Step]: ${step} -----\n`)
107
+ }
108
+
109
+ createRelease()
@@ -0,0 +1,95 @@
1
+ 'use strict'
2
+
3
+ const {program} = require('commander')
4
+
5
+ const checkWorkflowRun = require('./check-workflow-run')
6
+ const git = require('./git-commands')
7
+
8
+ // Add command line options
9
+ program.option('-b, --branch <branch>', 'release branch', 'main')
10
+ program.option('-o, --repo-owner <repoOwner>', 'repository owner', 'newrelic')
11
+ program.option('-f --force', 'bypass validation')
12
+
13
+ async function createReleaseTag() {
14
+ // Parse commandline options inputs
15
+ program.parse()
16
+
17
+ const options = program.opts()
18
+
19
+ console.log('Script running with following options: ', JSON.stringify(options))
20
+
21
+ const branch = options.branch.replace('refs/heads/', '')
22
+ const repoOwner = options.repoOwner
23
+
24
+ if (options.force) {
25
+ console.log('--force set. Skipping validation logic')
26
+ }
27
+
28
+ try {
29
+ const isValid = options.force || (
30
+ await validateLocalChanges() &&
31
+ await validateCurrentBranch(branch) &&
32
+ await checkWorkflowRun(repoOwner, branch)
33
+ )
34
+
35
+ if (!isValid) {
36
+ process.exit(1)
37
+ }
38
+
39
+ const packagePath = '../package.json'
40
+ console.log('Extracting new version from package.json here: ', )
41
+ const packageInfo = require(packagePath)
42
+
43
+ const version = `v${packageInfo.version}`
44
+ console.log('New version is: ', version)
45
+
46
+ console.log('Creating and pushing tag')
47
+
48
+ await git.createAnnotatedTag(version, version)
49
+ await git.pushTags()
50
+
51
+ console.log('*** Full Run Successful ***')
52
+ } catch (err) {
53
+ console.log(err)
54
+
55
+ process.exit(1)
56
+ }
57
+ }
58
+
59
+ async function validateLocalChanges() {
60
+ try {
61
+ const localChanges = await git.getLocalChanges()
62
+ if (localChanges.length > 0) {
63
+ console.log('Local changes detected: ', localChanges)
64
+ console.log('Please commit to a feature branch or stash changes and then try again.')
65
+ return false
66
+ }
67
+
68
+ return true
69
+ } catch (err) {
70
+ console.error(err)
71
+ return false
72
+ }
73
+ }
74
+
75
+ async function validateCurrentBranch(branch) {
76
+ try {
77
+ const currentBranch = await git.getCurrentBranch()
78
+
79
+ if (branch != currentBranch) {
80
+ console.log(
81
+ 'Current checked-out branch (%s) does not match expected (%s)',
82
+ currentBranch,
83
+ branch
84
+ )
85
+ return false
86
+ }
87
+
88
+ return true
89
+ } catch (err) {
90
+ console.error(err)
91
+ return false
92
+ }
93
+ }
94
+
95
+ createReleaseTag()
@@ -0,0 +1,110 @@
1
+ 'use strict'
2
+
3
+ const { exec } = require('child_process')
4
+
5
+ async function getPushRemotes() {
6
+ const stdout = await execAsPromise('git remote -v')
7
+
8
+ const remotes = stdout.split('\n')
9
+ const processedRemotes = remotes.reduce((remotePairs, currentRemote) => {
10
+ const parts = currentRemote.split('\t')
11
+ if (parts.length < 2) {
12
+ return remotePairs
13
+ }
14
+
15
+ const [name, url] = parts
16
+ if (url.indexOf('(push)') >= 0) {
17
+ remotePairs[name] = url
18
+ }
19
+
20
+ return remotePairs
21
+ }, {})
22
+
23
+ return processedRemotes
24
+ }
25
+
26
+ async function getLocalChanges() {
27
+ const stdout = await execAsPromise('git status --short --porcelain')
28
+ const changes = stdout.split('\n').filter((line) => {
29
+ return line.length > 0
30
+ })
31
+
32
+ return changes
33
+ }
34
+
35
+ async function getCurrentBranch() {
36
+ const stdout = await execAsPromise('git branch --show-current')
37
+ const branch = stdout.trim()
38
+
39
+ return branch
40
+ }
41
+
42
+ async function checkoutNewBranch(name) {
43
+ const stdout = await execAsPromise(`git checkout -b ${name}`)
44
+ const output = stdout.trim()
45
+
46
+ return output
47
+ }
48
+
49
+ async function addAllFiles() {
50
+ const stdout = await execAsPromise(`git add .`)
51
+ const output = stdout.trim()
52
+
53
+ return output
54
+ }
55
+
56
+ async function commit(message) {
57
+ const stdout = await execAsPromise(`git commit -m "${message}"`)
58
+ const output = stdout.trim()
59
+
60
+ return output
61
+ }
62
+
63
+ async function pushToRemote(remote, branchName) {
64
+ const stdout = await execAsPromise(`git push --set-upstream ${remote} ${branchName}`)
65
+ const output = stdout.trim()
66
+
67
+ return output
68
+ }
69
+
70
+ async function createAnnotatedTag(name, message) {
71
+ const stdout = await execAsPromise(`git tag -a ${name} -m ${message}`)
72
+ const output = stdout.trim()
73
+
74
+ return output
75
+ }
76
+
77
+ async function pushTags() {
78
+ const stdout = await execAsPromise('git push --tags')
79
+ const output = stdout.trim()
80
+
81
+ return output
82
+ }
83
+
84
+ function execAsPromise(command) {
85
+ const promise = new Promise((resolve, reject) => {
86
+ console.log(`Executing: '${command}'`)
87
+
88
+ exec(command, (err, stdout) => {
89
+ if (err) {
90
+ return reject(err)
91
+ }
92
+
93
+ resolve(stdout)
94
+ })
95
+ })
96
+
97
+ return promise
98
+ }
99
+
100
+ module.exports = {
101
+ getPushRemotes,
102
+ getLocalChanges,
103
+ getCurrentBranch,
104
+ checkoutNewBranch,
105
+ addAllFiles,
106
+ commit,
107
+ pushToRemote,
108
+ createAnnotatedTag,
109
+ pushTags
110
+ }
package/bin/github.js CHANGED
@@ -11,10 +11,9 @@ const octokit = new Octokit({
11
11
  })
12
12
 
13
13
  class Github {
14
- constructor(repoOwner, repository) {
15
- // Default to node agent repo for now
16
- this.repoOwner = repoOwner || 'newrelic'
17
- this.repository = repository || 'node-newrelic'
14
+ constructor(repoOwner = 'newrelic', repository = 'node-newrelic') {
15
+ this.repoOwner = repoOwner
16
+ this.repository = repository
18
17
  }
19
18
 
20
19
  async getLatestRelease() {
@@ -26,6 +25,18 @@ class Github {
26
25
  return result.data
27
26
  }
28
27
 
28
+ async createRelease(tag, name, body) {
29
+ const result = await octokit.repos.createRelease({
30
+ owner: this.repoOwner,
31
+ repo: this.repository,
32
+ tag_name: tag,
33
+ name: name,
34
+ body: body
35
+ })
36
+
37
+ return result.data
38
+ }
39
+
29
40
  async getTagByName(name) {
30
41
  const perPage = 100
31
42
 
@@ -114,6 +125,20 @@ class Github {
114
125
 
115
126
  return runs.data.workflow_runs[0]
116
127
  }
128
+
129
+ async createPR(options) {
130
+ const {head, base, title, body, draft} = options
131
+
132
+ await octokit.pulls.create({
133
+ owner: this.repoOwner,
134
+ repo: this.repository,
135
+ head: head,
136
+ base: base,
137
+ title: title,
138
+ body: body,
139
+ draft: draft
140
+ })
141
+ }
117
142
  }
118
143
 
119
144
  module.exports = Github
@@ -0,0 +1,31 @@
1
+ 'use strict'
2
+
3
+ const { exec } = require('child_process')
4
+
5
+ async function version(typeOrVersion, shouldCommitAndTag) {
6
+ let command = `npm version ${typeOrVersion}`
7
+
8
+ command += shouldCommitAndTag ? '' : ' --no-git-tag-version'
9
+
10
+ await execAsPromise(command)
11
+ }
12
+
13
+ function execAsPromise(command) {
14
+ const promise = new Promise((resolve, reject) => {
15
+ console.log(`Executing: '${command}'`)
16
+
17
+ exec(command, (err, stdout) => {
18
+ if (err) {
19
+ return reject(err)
20
+ }
21
+
22
+ resolve(stdout)
23
+ })
24
+ })
25
+
26
+ return promise
27
+ }
28
+
29
+ module.exports = {
30
+ version
31
+ }