Skip to content

Commit f1aa538

Browse files
authored
style(prettier): changes tab indentation to 2 space indentation (#32)
1 parent e4000b2 commit f1aa538

17 files changed

+11572
-11580
lines changed

PRIVACY.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Privacy Policy
2+
23
This app does not save your data what so ever. The app generates links for publishing messages to a specific channel using the public API. These links are immediatly shared with (YOU) the user and not saved in any larger extent than what slack saves.
34

45
# Liabiliy
6+
57
We do not take responsibility for what you do with this app. It is up to you to evaluate the security implications from using it, while we just promise not to use any data to deliberately cause any harm or annoyance.

README.md

+13-13
Original file line numberDiff line numberDiff line change
@@ -29,24 +29,24 @@ The plugin can be configured in the [**semantic-release** configuration file](ht
2929

3030
```json
3131
{
32-
"plugins": [
33-
"@semantic-release/commit-analyzer",
34-
"@semantic-release/release-notes-generator",
35-
[
36-
"semantic-release-slack-bot",
37-
{
38-
"notifyOnSuccess": false,
39-
"notifyOnFail": true
40-
}
41-
]
42-
]
32+
"plugins": [
33+
"@semantic-release/commit-analyzer",
34+
"@semantic-release/release-notes-generator",
35+
[
36+
"semantic-release-slack-bot",
37+
{
38+
"notifyOnSuccess": false,
39+
"notifyOnFail": true
40+
}
41+
]
42+
]
4343
}
4444
```
4545

4646
With this example:
4747

48-
- Slack notifications are skipped on a succesfull release
49-
- Slack notifications are sent on a failed release
48+
- Slack notifications are skipped on a succesfull release
49+
- Slack notifications are sent on a failed release
5050

5151
## Screenshots
5252

index.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const success = require('./lib/success')
33
const fail = require('./lib/fail')
44

55
module.exports = {
6-
verifyConditions,
7-
success,
8-
fail
6+
verifyConditions,
7+
success,
8+
fail
99
}

lambda/create-webhook.js

+66-66
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,76 @@
11
const https = require('https')
22

33
exports.handler = function(event, context) {
4-
// https://lambda/?code=xxx&state=
5-
// If this is the initial request.
6-
if (event.httpMethod === 'GET' && event.queryStringParameters.code) {
7-
// Retrieve the initial auth
8-
// https://slack.com/api/oauth.access?client_id&client_secret&code
9-
let { client_id, client_secret } = process.env
4+
// https://lambda/?code=xxx&state=
5+
// If this is the initial request.
6+
if (event.httpMethod === 'GET' && event.queryStringParameters.code) {
7+
// Retrieve the initial auth
8+
// https://slack.com/api/oauth.access?client_id&client_secret&code
9+
let { client_id, client_secret } = process.env
1010

11-
const optionspost = {
12-
host: 'slack.com',
13-
path: `/api/oauth.access?client_id=${client_id}&client_secret=${client_secret}&code=${
14-
event.queryStringParameters.code
15-
}`,
16-
method: 'GET'
17-
}
11+
const optionspost = {
12+
host: 'slack.com',
13+
path: `/api/oauth.access?client_id=${client_id}&client_secret=${client_secret}&code=${
14+
event.queryStringParameters.code
15+
}`,
16+
method: 'GET'
17+
}
1818

19-
let body = ''
19+
let body = ''
2020

21-
var reqPost = https
22-
.request(optionspost, function(res) {
23-
res.on('data', function(chunk) {
24-
body += chunk
25-
})
21+
var reqPost = https
22+
.request(optionspost, function(res) {
23+
res.on('data', function(chunk) {
24+
body += chunk
25+
})
2626

27-
res.on('end', function() {
28-
let jsonStr = JSON.parse(body)
27+
res.on('end', function() {
28+
let jsonStr = JSON.parse(body)
2929

30-
// {"ok":true,
31-
// "access_token":"xoxp-xxx-xxx-xxx",
32-
// "scope":"identify,incoming-webhook,chat:write:bot",
33-
// "user_id":"xxx","team_name":"xxx","team_id":"xxx"}
34-
if (jsonStr.ok) {
35-
// context.succeed({
36-
// 'statusCode': 200,
37-
// body: JSON.stringify({'ok': true, 'access_token': jsonStr.access_token}),
38-
// })
39-
context.succeed({
40-
statusCode: 301,
41-
headers: {
42-
Location: `https://juliuscc.github.io/semantic-release-slack-bot/index.html?access_token=${
43-
jsonStr.access_token
44-
}`
45-
}
46-
})
47-
} else {
48-
context.succeed({
49-
statusCode: 401,
50-
body: JSON.stringify({
51-
ok: false,
52-
message: 'Invalid credentials'
53-
})
54-
})
55-
}
56-
})
57-
})
58-
.on('error', function(e) {
59-
context.succeed({
60-
statusCode: 500,
61-
body: JSON.stringify({
62-
ok: false,
63-
message: 'Could not connect to slack.'
64-
})
65-
})
66-
})
30+
// {"ok":true,
31+
// "access_token":"xoxp-xxx-xxx-xxx",
32+
// "scope":"identify,incoming-webhook,chat:write:bot",
33+
// "user_id":"xxx","team_name":"xxx","team_id":"xxx"}
34+
if (jsonStr.ok) {
35+
// context.succeed({
36+
// 'statusCode': 200,
37+
// body: JSON.stringify({'ok': true, 'access_token': jsonStr.access_token}),
38+
// })
39+
context.succeed({
40+
statusCode: 301,
41+
headers: {
42+
Location: `https://juliuscc.github.io/semantic-release-slack-bot/index.html?access_token=${
43+
jsonStr.access_token
44+
}`
45+
}
46+
})
47+
} else {
48+
context.succeed({
49+
statusCode: 401,
50+
body: JSON.stringify({
51+
ok: false,
52+
message: 'Invalid credentials'
53+
})
54+
})
55+
}
56+
})
57+
})
58+
.on('error', function(e) {
59+
context.succeed({
60+
statusCode: 500,
61+
body: JSON.stringify({
62+
ok: false,
63+
message: 'Could not connect to slack.'
64+
})
65+
})
66+
})
6767

68-
reqPost.write('')
69-
reqPost.end()
70-
} else {
71-
context.succeed({
72-
statusCode: 400,
73-
body: JSON.stringify({ ok: false, message: 'Invalid request.' })
74-
})
75-
}
68+
reqPost.write('')
69+
reqPost.end()
70+
} else {
71+
context.succeed({
72+
statusCode: 400,
73+
body: JSON.stringify({ ok: false, message: 'Invalid request.' })
74+
})
75+
}
7676
}

lib/fail.js

+90-90
Original file line numberDiff line numberDiff line change
@@ -3,108 +3,108 @@ const postMessage = require('./postMessage')
33
const template = require('./template')
44

55
module.exports = async (pluginConfig, context) => {
6-
const {
7-
logger,
8-
options,
9-
errors,
10-
env: { SEMANTIC_RELEASE_PACKAGE, npm_package_name }
11-
} = context
12-
const { slackWebhook = process.env.SLACK_WEBHOOK } = pluginConfig
6+
const {
7+
logger,
8+
options,
9+
errors,
10+
env: { SEMANTIC_RELEASE_PACKAGE, npm_package_name }
11+
} = context
12+
const { slackWebhook = process.env.SLACK_WEBHOOK } = pluginConfig
1313

14-
const package_name = SEMANTIC_RELEASE_PACKAGE || npm_package_name
14+
const package_name = SEMANTIC_RELEASE_PACKAGE || npm_package_name
1515

16-
if (!pluginConfig.notifyOnFail) {
17-
logger.log('Notifying on fail skipped')
18-
return
19-
}
16+
if (!pluginConfig.notifyOnFail) {
17+
logger.log('Notifying on fail skipped')
18+
return
19+
}
2020

21-
logger.log('Sending slack notification on fail')
21+
logger.log('Sending slack notification on fail')
2222

23-
let slackMessage = {}
24-
const repoPath =
25-
options.repositoryUrl.indexOf('[email protected]') !== -1
26-
? options.repositoryUrl.split(':')[1].replace('.git', '')
27-
: undefined
28-
const repoURL = repoPath && `https://github.com/${repoPath}`
23+
let slackMessage = {}
24+
const repoPath =
25+
options.repositoryUrl.indexOf('[email protected]') !== -1
26+
? options.repositoryUrl.split(':')[1].replace('.git', '')
27+
: undefined
28+
const repoURL = repoPath && `https://github.com/${repoPath}`
2929

30-
// Override default fail template
31-
if (pluginConfig.onFailTemplate) {
32-
slackMessage = template(pluginConfig.onFailTemplate, {
33-
package_name,
34-
repo_path: repoPath,
35-
repo_url: repoURL
36-
})
37-
} else {
38-
const plural = errors.length > 1
30+
// Override default fail template
31+
if (pluginConfig.onFailTemplate) {
32+
slackMessage = template(pluginConfig.onFailTemplate, {
33+
package_name,
34+
repo_path: repoPath,
35+
repo_url: repoURL
36+
})
37+
} else {
38+
const plural = errors.length > 1
3939

40-
const messageSummaryLine = `${
41-
plural ? 'Errors' : 'An error'
42-
} occurred while trying to publish the new version of \`${npm_package_name}\`!`
40+
const messageSummaryLine = `${
41+
plural ? 'Errors' : 'An error'
42+
} occurred while trying to publish the new version of \`${npm_package_name}\`!`
4343

44-
const divider = {
45-
type: 'divider'
46-
}
44+
const divider = {
45+
type: 'divider'
46+
}
4747

48-
let messageBlocks = [
49-
{
50-
type: 'section',
51-
text: {
52-
type: 'mrkdwn',
53-
text: messageSummaryLine
54-
}
55-
}
56-
]
48+
let messageBlocks = [
49+
{
50+
type: 'section',
51+
text: {
52+
type: 'mrkdwn',
53+
text: messageSummaryLine
54+
}
55+
}
56+
]
5757

58-
if (repoPath) {
59-
const metadata = {
60-
type: 'context',
61-
elements: [
62-
{
63-
type: 'mrkdwn',
64-
text: `*<${repoURL}|${repoPath}>*`
65-
}
66-
]
67-
}
58+
if (repoPath) {
59+
const metadata = {
60+
type: 'context',
61+
elements: [
62+
{
63+
type: 'mrkdwn',
64+
text: `*<${repoURL}|${repoPath}>*`
65+
}
66+
]
67+
}
6868

69-
messageBlocks.push(metadata)
70-
}
69+
messageBlocks.push(metadata)
70+
}
7171

72-
const attachments = [
73-
{
74-
type: 'section',
75-
text: {
76-
type: 'mrkdwn',
77-
text: `:no_entry: *${plural ? 'Exceptions' : 'Exception'}*`
78-
}
79-
}
80-
]
72+
const attachments = [
73+
{
74+
type: 'section',
75+
text: {
76+
type: 'mrkdwn',
77+
text: `:no_entry: *${plural ? 'Exceptions' : 'Exception'}*`
78+
}
79+
}
80+
]
8181

82-
for (const error of errors) {
83-
if (attachments.length > 2) {
84-
attachments.push(divider)
85-
}
86-
attachments.push({
87-
type: 'section',
88-
text: {
89-
type: 'mrkdwn',
90-
text: `\`\`\`${error.stack}\`\`\``
91-
}
92-
})
93-
}
82+
for (const error of errors) {
83+
if (attachments.length > 2) {
84+
attachments.push(divider)
85+
}
86+
attachments.push({
87+
type: 'section',
88+
text: {
89+
type: 'mrkdwn',
90+
text: `\`\`\`${error.stack}\`\`\``
91+
}
92+
})
93+
}
9494

95-
slackMessage = {
96-
text: `${
97-
plural ? 'Errors' : 'An error'
98-
} occurred while trying to publish the new version of ${package_name}!`,
99-
blocks: messageBlocks,
100-
attachments: [
101-
{
102-
color: '#ff0000',
103-
blocks: attachments
104-
}
105-
]
106-
}
107-
}
95+
slackMessage = {
96+
text: `${
97+
plural ? 'Errors' : 'An error'
98+
} occurred while trying to publish the new version of ${package_name}!`,
99+
blocks: messageBlocks,
100+
attachments: [
101+
{
102+
color: '#ff0000',
103+
blocks: attachments
104+
}
105+
]
106+
}
107+
}
108108

109-
await postMessage(slackMessage, logger, slackWebhook)
109+
await postMessage(slackMessage, logger, slackWebhook)
110110
}

0 commit comments

Comments
 (0)