@bitblit/ratchet-node-only 4.0.115-alpha → 4.0.119-alpha
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/lib/build/ratchet-node-only-info.d.ts +1 -1
- package/lib/cli/abstract-ratchet-cli-handler.d.ts +1 -1
- package/lib/cli/ratchet-cli-handler.d.ts +1 -1
- package/lib/csv/csv-ratchet.d.ts +1 -1
- package/lib/index.d.ts +11 -1
- package/lib/index.mjs +3 -0
- package/lib/index.mjs.map +1 -0
- package/package.json +11 -9
- package/lib/build/ratchet-node-only-info.js +0 -14
- package/lib/ci/apply-ci-env-variables-to-files.js +0 -80
- package/lib/ci/apply-ci-env-variables-to-files.spec.js +0 -23
- package/lib/ci/ci-run-information-util.js +0 -43
- package/lib/ci/ci-run-information.js +0 -1
- package/lib/cli/abstract-ratchet-cli-handler.js +0 -28
- package/lib/cli/cli-ratchet.js +0 -28
- package/lib/cli/ratchet-cli-handler.js +0 -17
- package/lib/csv/csv-ratchet.js +0 -158
- package/lib/csv/csv-ratchet.spec.js +0 -41
- package/lib/files/files-to-static-class.js +0 -56
- package/lib/files/files-to-static-class.spec.js +0 -11
- package/lib/index.js +0 -1
- package/lib/third-party/git/git-ratchet.js +0 -70
- package/lib/third-party/git/git-ratchet.spec.js +0 -9
- package/lib/third-party/slack/publish-ci-release-to-slack.js +0 -60
- package/lib/third-party/slack/publish-ci-release-to-slack.spec.js +0 -24
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { DateTime } from 'luxon';
|
|
2
|
-
import { Logger } from '@bitblit/ratchet-common/lib/logger/logger.js';
|
|
3
|
-
import { GlobalRatchet } from '@bitblit/ratchet-common/lib/lang/global-ratchet.js';
|
|
4
|
-
import fetch from 'cross-fetch';
|
|
5
|
-
import util from 'util';
|
|
6
|
-
import { GitRatchet } from '../git/git-ratchet.js';
|
|
7
|
-
export class PublishCiReleaseToSlack {
|
|
8
|
-
static async process(slackHookUrl, timezone = 'America/Los_Angeles') {
|
|
9
|
-
if (!slackHookUrl) {
|
|
10
|
-
throw new Error('slackHookUrl must be defined');
|
|
11
|
-
}
|
|
12
|
-
const buildNum = GlobalRatchet.fetchGlobalVar('CIRCLE_BUILD_NUM');
|
|
13
|
-
const userName = GlobalRatchet.fetchGlobalVar('CIRCLE_USERNAME');
|
|
14
|
-
const projectName = GlobalRatchet.fetchGlobalVar('CIRCLE_PROJECT_REPONAME');
|
|
15
|
-
const branch = GlobalRatchet.fetchGlobalVar('CIRCLE_BRANCH') || '';
|
|
16
|
-
const tag = GlobalRatchet.fetchGlobalVar('CIRCLE_TAG') || '';
|
|
17
|
-
const sha1 = GlobalRatchet.fetchGlobalVar('CIRCLE_SHA1') || '';
|
|
18
|
-
const localTime = DateTime.local().setZone(timezone).toFormat('MMMM Do yyyy, h:mm:ss a z');
|
|
19
|
-
const gitData = await GitRatchet.getLastCommitSwallowException();
|
|
20
|
-
if (!buildNum || !userName || !projectName) {
|
|
21
|
-
throw new Error('CIRCLE_BUILD_NUM, CIRCLE_USERNAME, CIRCLE_PROJECT_REPONAME env vars not set - apparently not in a CircleCI environment');
|
|
22
|
-
}
|
|
23
|
-
Logger.info('Sending slack notification %j with build %s, branch %s, tag %s, sha %s, time: %s', buildNum, branch, tag, sha1, localTime);
|
|
24
|
-
let message = util.format('%s performed release %s on %s at %s', userName, tag + ' ' + branch, projectName, localTime);
|
|
25
|
-
if (!!gitData && !!gitData.subject) {
|
|
26
|
-
message += '\n\n' + gitData.subject;
|
|
27
|
-
}
|
|
28
|
-
const response = await fetch(slackHookUrl, {
|
|
29
|
-
method: 'POST',
|
|
30
|
-
mode: 'cors',
|
|
31
|
-
cache: 'no-cache',
|
|
32
|
-
headers: {
|
|
33
|
-
'Content-Type': 'application/json',
|
|
34
|
-
},
|
|
35
|
-
redirect: 'follow',
|
|
36
|
-
body: JSON.stringify({ text: message }),
|
|
37
|
-
});
|
|
38
|
-
const bodyOut = await response.text();
|
|
39
|
-
Logger.info('Slack returned : %s', bodyOut);
|
|
40
|
-
return bodyOut;
|
|
41
|
-
}
|
|
42
|
-
static extractHookUrl() {
|
|
43
|
-
let rval = null;
|
|
44
|
-
if (process && process.argv && process.argv.length > 2) {
|
|
45
|
-
rval = process.argv[2];
|
|
46
|
-
}
|
|
47
|
-
return rval;
|
|
48
|
-
}
|
|
49
|
-
static async runFromCliArgs(args) {
|
|
50
|
-
Logger.info('Running PublishCiReleaseToSlack from command line arguments');
|
|
51
|
-
const hook = PublishCiReleaseToSlack.extractHookUrl();
|
|
52
|
-
if (!!hook) {
|
|
53
|
-
return PublishCiReleaseToSlack.process(hook);
|
|
54
|
-
}
|
|
55
|
-
else {
|
|
56
|
-
Logger.infoP('Usage : ratchet-publish-circle-ci-release-to-slack {hookUrl} ...');
|
|
57
|
-
return null;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { Logger } from '@bitblit/ratchet-common/lib/logger/logger.js';
|
|
2
|
-
import { GlobalRatchet } from '@bitblit/ratchet-common/lib/lang/global-ratchet.js';
|
|
3
|
-
import { PublishCiReleaseToSlack } from './publish-ci-release-to-slack.js';
|
|
4
|
-
describe('#publishCircleCiReleaseToSlack', function () {
|
|
5
|
-
xit('should fail if not in a circle ci environment', async () => {
|
|
6
|
-
try {
|
|
7
|
-
const result = await PublishCiReleaseToSlack.process('https://testslack.erigir.com');
|
|
8
|
-
this.bail();
|
|
9
|
-
}
|
|
10
|
-
catch (err) {
|
|
11
|
-
Logger.debug('Caught expected error : %s', err);
|
|
12
|
-
}
|
|
13
|
-
});
|
|
14
|
-
xit('should not fail if in a circle ci environment', async () => {
|
|
15
|
-
GlobalRatchet.setGlobalVar('CIRCLE_BUILD_NUM', '1');
|
|
16
|
-
GlobalRatchet.setGlobalVar('CIRCLE_BRANCH', 'B');
|
|
17
|
-
GlobalRatchet.setGlobalVar('CIRCLE_TAG', 'T');
|
|
18
|
-
GlobalRatchet.setGlobalVar('CIRCLE_SHA1', 'S');
|
|
19
|
-
GlobalRatchet.setGlobalVar('CIRCLE_USERNAME', 'cweiss');
|
|
20
|
-
GlobalRatchet.setGlobalVar('CIRCLE_PROJECT_REPONAME', 'tester');
|
|
21
|
-
const result = await PublishCiReleaseToSlack.process('slackUrlHere');
|
|
22
|
-
expect(result).toEqual('ok');
|
|
23
|
-
});
|
|
24
|
-
});
|