@24i/smartapps-bigscreen-rnv-build-engine 0.8.6-alpha.1402 → 0.8.6-alpha.1403

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.
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
11
+ }) : function(o, v) {
12
+ o["default"] = v;
13
+ });
14
+ var __importStar = (this && this.__importStar) || function (mod) {
15
+ if (mod && mod.__esModule) return mod;
16
+ var result = {};
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
+ __setModuleDefault(result, mod);
19
+ return result;
20
+ };
21
+ Object.defineProperty(exports, "__esModule", { value: true });
22
+ const https = __importStar(require("https"));
23
+ const querystring = __importStar(require("querystring"));
24
+ const path = __importStar(require("path"));
25
+ const fs = __importStar(require("fs"));
26
+ const replaceWebhookUrl = (newWebhookUrl, channelName) => {
27
+ const filePath = path.resolve(process.cwd(), 'renative.json');
28
+ const parsedFile = JSON.parse(fs.readFileSync(filePath).toString());
29
+ const jsonIndentSpaces = 4;
30
+ parsedFile.common.deploy.slack.webhookUrl = newWebhookUrl;
31
+ fs.writeFileSync(filePath, JSON.stringify(parsedFile, null, jsonIndentSpaces));
32
+ console.log(`Webhook for "${channelName}" channel successfully written into ${filePath}.`);
33
+ };
34
+ const postRequestCallback = (receivedData) => {
35
+ const parsedData = JSON.parse(receivedData);
36
+ if (parsedData.ok === false)
37
+ throw parsedData;
38
+ const { channel, url } = parsedData.incoming_webhook;
39
+ console.log(`\nGenerated slack webhook: ${url}`);
40
+ replaceWebhookUrl(url, channel);
41
+ };
42
+ const { redirect_uri, client_id, client_secret, code } = process.env;
43
+ const formData = querystring.stringify({ redirect_uri, client_id, client_secret, code });
44
+ const requestOptions = {
45
+ hostname: 'slack.com',
46
+ path: '/api/oauth.v2.access',
47
+ method: 'POST',
48
+ headers: {
49
+ 'Content-Type': 'application/x-www-form-urlencoded',
50
+ 'Content-Length': formData.length,
51
+ },
52
+ };
53
+ const request = https.request(requestOptions, (response) => {
54
+ let receivedData = '';
55
+ response.on('data', (d) => {
56
+ receivedData += d;
57
+ });
58
+ response.on('end', () => {
59
+ postRequestCallback(receivedData);
60
+ });
61
+ });
62
+ request.on('error', (error) => {
63
+ throw error;
64
+ });
65
+ request.write(formData);
66
+ request.end();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@24i/smartapps-bigscreen-rnv-build-engine",
3
- "version": "0.8.6-alpha.1402+fdefc217",
3
+ "version": "0.8.6-alpha.1403+d577658f",
4
4
  "description": "Package with build engine for SmartApps BIGscreen projects...",
5
5
  "main": "dist/src/index.js",
6
6
  "scripts": {
@@ -61,5 +61,5 @@
61
61
  "keywords": [],
62
62
  "author": "24i",
63
63
  "license": "ISC",
64
- "gitHead": "fdefc21765850532808963bb3756f6399010354e"
64
+ "gitHead": "d577658f9d7a498f73f013be66b7115268a398d7"
65
65
  }