Comparing version 0.1.0 to 0.2.0
@@ -1,3 +0,3 @@ | ||
import { TPrefixes } from '@auto/utils'; | ||
import { TPrefixes, TWorkspacesOptions } from '@auto/utils'; | ||
import { TGithubOptions, TWorkspacesLog } from './types'; | ||
export declare const makeWorkspacesGithubReleases: (logs: TWorkspacesLog[], prefixes: TPrefixes, options: TGithubOptions) => Promise<void>; | ||
export declare const makeWorkspacesGithubReleases: (logs: TWorkspacesLog[], prefixes: TPrefixes, workspacesOptions: TWorkspacesOptions, githubOptions: TGithubOptions) => Promise<void>; |
@@ -10,8 +10,10 @@ "use strict"; | ||
var _utils = require("@auto/utils"); | ||
var _requestPromiseNative = _interopRequireDefault(require("request-promise-native")); | ||
var _utils = require("./utils"); | ||
var _utils2 = require("./utils"); | ||
const makeWorkspacesGithubReleases = async (logs, prefixes, options) => { | ||
if (typeof options.token !== 'string') { | ||
const makeWorkspacesGithubReleases = async (logs, prefixes, workspacesOptions, githubOptions) => { | ||
if (typeof githubOptions.token !== 'string') { | ||
throw new Error('GitHub token is required'); | ||
@@ -21,12 +23,13 @@ } | ||
for (const log of logs) { | ||
const name = (0, _utils.removeAutoNamePrefix)(log.name, workspacesOptions.autoNamePrefix); | ||
await (0, _requestPromiseNative.default)({ | ||
uri: `${_utils.GITHUB_API_REPOS_URL}${options.username}/${options.repo}/releases`, | ||
uri: `${_utils2.GITHUB_API_REPOS_URL}${githubOptions.username}/${githubOptions.repo}/releases`, | ||
method: 'POST', | ||
headers: { | ||
Authorization: `token ${options.token}`, | ||
Authorization: `token ${githubOptions.token}`, | ||
'User-Agent': 'auto-tools' | ||
}, | ||
json: { | ||
tag_name: `${log.name}@${log.version}`, | ||
name: `${log.name}@${log.version}`, | ||
tag_name: `${name}@${log.version}`, | ||
name: `${name}@${log.version}`, | ||
body: log.messages.map(message => `* ${prefixes.required[message.type].value} ${message.value}`).join('\n') | ||
@@ -33,0 +36,0 @@ } |
@@ -1,3 +0,3 @@ | ||
import { TPrefixes } from '@auto/utils'; | ||
import { TPrefixes, TWorkspacesOptions } from '@auto/utils'; | ||
import { TSlackOptions, TWorkspacesLog } from './types'; | ||
export declare const sendWorkspacesSlackMessage: (logs: TWorkspacesLog[], prefixes: TPrefixes, options: TSlackOptions) => Promise<void>; | ||
export declare const sendWorkspacesSlackMessage: (logs: TWorkspacesLog[], prefixes: TPrefixes, workspacesOptions: TWorkspacesOptions, slackOptions: TSlackOptions) => Promise<void>; |
@@ -12,17 +12,22 @@ "use strict"; | ||
var _utils = require("./utils"); | ||
var _utils = require("@auto/utils"); | ||
const sendWorkspacesSlackMessage = async (logs, prefixes, options) => { | ||
if (typeof options.token !== 'string') { | ||
var _utils2 = require("./utils"); | ||
const sendWorkspacesSlackMessage = async (logs, prefixes, workspacesOptions, slackOptions) => { | ||
if (typeof slackOptions.token !== 'string') { | ||
throw new Error('Slack token is required'); | ||
} | ||
const allAttachments = logs.map(bump => ({ | ||
color: options.colors[bump.type], | ||
fields: [{ | ||
title: `${bump.name} v${bump.version}`, | ||
value: bump.messages.map(message => `${prefixes.required[message.type].value} ${message.value}`).join('\n') | ||
}] | ||
})); | ||
const numIterations = Math.ceil(allAttachments.length / _utils.MAX_ATTACHMENTS); | ||
const allAttachments = logs.map(log => { | ||
const name = (0, _utils.removeAutoNamePrefix)(log.name, workspacesOptions.autoNamePrefix); | ||
return { | ||
color: slackOptions.colors[log.type], | ||
fields: [{ | ||
title: `${name} v${log.version}`, | ||
value: log.messages.map(message => `${prefixes.required[message.type].value} ${message.value}`).join('\n') | ||
}] | ||
}; | ||
}); | ||
const numIterations = Math.ceil(allAttachments.length / _utils2.MAX_ATTACHMENTS); | ||
const attachmentsInIteration = Math.ceil(allAttachments.length / numIterations); | ||
@@ -32,9 +37,9 @@ | ||
await (0, _requestPromiseNative.default)({ | ||
uri: `${_utils.SLACK_HOOKS_URL}${options.token}`, | ||
uri: `${_utils2.SLACK_HOOKS_URL}${slackOptions.token}`, | ||
method: 'POST', | ||
json: { | ||
channel: options.channel, | ||
username: options.username, | ||
channel: slackOptions.channel, | ||
username: slackOptions.username, | ||
link_names: '1', | ||
icon_emoji: options.iconEmoji, | ||
icon_emoji: slackOptions.iconEmoji, | ||
unfurl_media: false, | ||
@@ -41,0 +46,0 @@ attachments: allAttachments.slice(i * attachmentsInIteration, Math.min((i + 1) * attachmentsInIteration, allAttachments.length)) |
{ | ||
"name": "@auto/log", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "keywords": [], |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
15501
370
0