@24i/smartapps-bigscreen-rnv-build-engine 0.8.6-alpha.1394 → 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.
package/README.md
CHANGED
|
@@ -18,6 +18,7 @@ sidebar_label: Rnv Build Engine
|
|
|
18
18
|
- [Available Webpack Injections](#available-webpack-injections)
|
|
19
19
|
- [Package content](#package-content)
|
|
20
20
|
- [How to set up new project with SmartApps BIGscreen build engine](#how-to-set-up-new-project-with-smartapps-bigscreen-build-engine)
|
|
21
|
+
- [How to add new platform](#how-to-add-new-platform)
|
|
21
22
|
|
|
22
23
|
---
|
|
23
24
|
## About the package
|
|
@@ -46,7 +47,7 @@ it
|
|
|
46
47
|
| **webOS** | LG | `webos` | `.ipk` | `*.webos.tv.{js,jsx,ts,tsx,json}` | |
|
|
47
48
|
| **WebTV** | N/A | `webtv` | `.zip` | `*.webtv.{js,jsx,ts,tsx,json}` | for previewing builds in browser |
|
|
48
49
|
|
|
49
|
-
When building the application with ReNative, if file with ***registered platform
|
|
50
|
+
When building the application with ReNative, if file with ***registered platform extension*** is found,
|
|
50
51
|
it takes precedence and is bundled instead of file without registered file extension (such as `index.ts`).
|
|
51
52
|
For instance, this approach is useful (and is used) for platform drivers - only concrete driver can be bundled into the final package for selected platform:
|
|
52
53
|
|
|
@@ -107,11 +108,12 @@ Currently, following variable names are configured for replacing:
|
|
|
107
108
|
| :-------------------------------------------- | :----: | ------------------------------------------------------- | :-----------------------------------------: |
|
|
108
109
|
| **WEBPACK_INJECTION_APP_CONFIG_ID** | string | flavour id *(value of rnv CLI `-c` param value)* | `'animated_1080'`, `'basic_720'` |
|
|
109
110
|
| **WEBPACK_INJECTION_APP_CREATED** | string | build time in ISO 8601 format | `'2021-07-30T09:18:26.014Z'` |
|
|
111
|
+
| **WEBPACK_INJECTION_APP_SCHEME** | string | scheme used during the build | `'debug'`, `'rc:latest'`, `'release:dist'` |
|
|
110
112
|
| **WEBPACK_INJECTION_APP_RESOLUTION** | string | app resolution in `<WIDTH>x<HEIGHT>` format (in pixels) | `'1920x1080'`, `'1280x720'` |
|
|
111
113
|
| **WEBPACK_INJECTION_APP_VERSION** | string | app version | `'v0.0.1.dev'`, `'v0.0.1.rc-1'`, `'v0.0.1'` |
|
|
112
114
|
| **WEBPACK_INJECTION_APP_ENVIRONMENT** | string | environment used during the build | `'development'`, `'production'` |
|
|
113
115
|
| **WEBPACK_INJECTION_APP_PLATFORM** | string | platform id *(value of rnv CLI `-p` param value)* | `'webtv'`, `'webos'`, `'tizen'`, `'entone'` |
|
|
114
|
-
| **
|
|
116
|
+
| **WEBPACK_INJECTION_APP_CONTENT_PATH** | string | path to content directory | `'./public/content'` |
|
|
115
117
|
|
|
116
118
|
An example:
|
|
117
119
|
```typescript
|
|
@@ -210,3 +212,7 @@ and `.travis.yml`config file (related to Travis CI).
|
|
|
210
212
|
> To **start a new project** with usage of our build process,
|
|
211
213
|
> please use [SmartApps BIGscreen Template repository](https://github.com/24i/smartapps-bigscreen-template),
|
|
212
214
|
> it uses this package and contains other required configuration files as well.
|
|
215
|
+
|
|
216
|
+
---
|
|
217
|
+
## How to add new platform
|
|
218
|
+
To see how to add new platform, click [here](docs/PLATFORM_ADD.md).
|
|
@@ -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();
|
|
@@ -50,10 +50,9 @@ const includeRtlFiles = ({ shouldIncludeRtlFiles }) => (content, loaderContext)
|
|
|
50
50
|
}
|
|
51
51
|
return content;
|
|
52
52
|
};
|
|
53
|
-
const
|
|
54
|
-
const getAppRuntimeConfigPath = (baseUrl, isBuildHosted = false) => {
|
|
53
|
+
const getAppContentPath = (baseUrl, isBuildHosted = false) => {
|
|
55
54
|
const isBuildHostedAndHasBaseUrl = isBuildHosted && !!baseUrl;
|
|
56
|
-
const relativePath = path_1.default.join(isBuildHostedAndHasBaseUrl ? './public' : '', 'content'
|
|
55
|
+
const relativePath = path_1.default.join(isBuildHostedAndHasBaseUrl ? './public' : '', 'content');
|
|
57
56
|
return isBuildHostedAndHasBaseUrl
|
|
58
57
|
? `${baseUrl}/${relativePath}`
|
|
59
58
|
: relativePath;
|
|
@@ -151,7 +150,7 @@ function generateConfig(config) {
|
|
|
151
150
|
}
|
|
152
151
|
});
|
|
153
152
|
}
|
|
154
|
-
const
|
|
153
|
+
const appContentPath = getAppContentPath(baseUrl, isBuildHosted);
|
|
155
154
|
const copiedDirWithPublicContentPath = path_1.default.join(appBuildDir, `../${path_1.default.parse(appBuildDir).name}-public`);
|
|
156
155
|
const plugins = {
|
|
157
156
|
forkTsChecker: new fork_ts_checker_webpack_plugin_1.default({
|
|
@@ -163,11 +162,12 @@ function generateConfig(config) {
|
|
|
163
162
|
webpack: new webpack_1.default.DefinePlugin({
|
|
164
163
|
WEBPACK_INJECTION_APP_CONFIG_ID: JSON.stringify(config.appConfigId || ''),
|
|
165
164
|
WEBPACK_INJECTION_APP_CREATED: JSON.stringify(new Date().toISOString()),
|
|
165
|
+
WEBPACK_INJECTION_APP_SCHEME: JSON.stringify(config.scheme || ''),
|
|
166
166
|
WEBPACK_INJECTION_APP_RESOLUTION: JSON.stringify(getResolutionString(config)),
|
|
167
167
|
WEBPACK_INJECTION_APP_VERSION: JSON.stringify(buildVersion || ''),
|
|
168
168
|
WEBPACK_INJECTION_APP_ENVIRONMENT: JSON.stringify(config.environment || ''),
|
|
169
169
|
WEBPACK_INJECTION_APP_PLATFORM: JSON.stringify(PLATFORM || ''),
|
|
170
|
-
|
|
170
|
+
WEBPACK_INJECTION_APP_CONTENT_PATH: JSON.stringify(appContentPath),
|
|
171
171
|
}),
|
|
172
172
|
html: new html_webpack_plugin_1.default({
|
|
173
173
|
alwaysWriteToDisk: true,
|
|
@@ -201,8 +201,8 @@ function generateConfig(config) {
|
|
|
201
201
|
isDevServer ? {
|
|
202
202
|
move: [
|
|
203
203
|
{
|
|
204
|
-
source: path_1.default.join(appBuildDir, 'project', 'public', 'content'
|
|
205
|
-
destination: path_1.default.join(appBuildEngineProjectDir, 'content'
|
|
204
|
+
source: path_1.default.join(appBuildDir, 'project', 'public', 'content'),
|
|
205
|
+
destination: path_1.default.join(appBuildEngineProjectDir, 'content'),
|
|
206
206
|
},
|
|
207
207
|
],
|
|
208
208
|
} : null,
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# rnv-build-engine
|
|
2
|
+
## How to add new platform
|
|
3
|
+
|
|
4
|
+
---
|
|
5
|
+
### Choose platform ID
|
|
6
|
+
To see actual list of platform IDs, see table in [Supported platforms](../README.md#supported-platforms) section.
|
|
7
|
+
|
|
8
|
+
Platform ID is needed for ReNative CLI - to specify requested platform for build or for example for deploy:
|
|
9
|
+
|
|
10
|
+
`rnv build -c <flavour> -s <scheme> -p <platform_id>`
|
|
11
|
+
|
|
12
|
+
`rnv deploy -c <flavour> -s <scheme> -p <platform_id>`
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
### Choose file extension for new platform
|
|
16
|
+
Please read [Supported platforms](../README.md#supported-platforms) section,
|
|
17
|
+
where platform file extensions and their usage are described.
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
### Prepare driver for new platform
|
|
21
|
+
#### 1. Implement new platform driver
|
|
22
|
+
- Use [packages/create-package](../../create-package) to create a new package with driver for requested platform.
|
|
23
|
+
Name the new package `driver-<platform_id>` and implement the platform driver inside it.
|
|
24
|
+
Have a look at other driver packages to inspire.
|
|
25
|
+
|
|
26
|
+
#### 2. Include new platform driver into `device` package
|
|
27
|
+
- In [packages/device/src/resolver/index.ts](../../device/src/resolver/index.ts),
|
|
28
|
+
import driver for new platform from just created package with platform driver (previous step)
|
|
29
|
+
by the same way as other platform drivers.
|
|
30
|
+
- According to [Choose file extension for new platform](#choose-file-extension-for-new-platform) section,
|
|
31
|
+
in [packages/device/src/driver/](../../device/src/driver) dir,
|
|
32
|
+
add `index.<platform_extension>.ts` file and inside it, export new driver by the same way as other drivers.
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
### How to extend build engine with new platform
|
|
36
|
+
- in [package.json](../package.json), in `peerDependencies`, update version of `@24i/smartapps-bigscreen-device` package to new version (created in step above)
|
|
37
|
+
- add requested platform record into [renative.engine.json](../renative.engine.json)
|
|
38
|
+
- add requested platform record into [src/constants/platforms.ts](../src/constants/platforms.ts)
|
|
39
|
+
- add requested platform record into [src/index.ts](../src/index.ts):
|
|
40
|
+
- set file extension(s) for requested platform *(see [Choose file extension for new platform](#choose-file-extension-for-new-platform) section)*
|
|
41
|
+
- set value for `defaultPort`
|
|
42
|
+
- set `isWebHosted` to `true`
|
|
43
|
+
- add following webpack configs into `templates/platforms/<platform_id>/` dir *(you can copy them from `webtv` platform and edit as you need)*:
|
|
44
|
+
- `webpack.config.dev.ts`
|
|
45
|
+
- `webpack.config.prod.ts`
|
|
46
|
+
- add record for new platform into [src/scripts/release/urlsMarkdown.ts](../src/scripts/release/urlsMarkdown.ts) file, in `beautifyPlatformName` function
|
|
47
|
+
- extend build engine [tasks](../src/tasks) with new platform:
|
|
48
|
+
- extend `buildFn` in [src/tasks/task.rnv.build.ts](../src/tasks/task.rnv.build.ts) file with new platform
|
|
49
|
+
- extend `configureFn` in [src/tasks/task.rnv.configure.ts](../src/tasks/task.rnv.configure.ts) file with new platform
|
|
50
|
+
- extend `deployFn` in [src/tasks/task.rnv.deploy.ts](../src/tasks/task.rnv.deploy.ts) file with new platform
|
|
51
|
+
- extend `startFn` in [src/tasks/task.rnv.start.ts](../src/tasks/task.rnv.start.ts) file with new platform
|
|
52
|
+
- add info about new platform into [Supported platforms](../README.md#supported-platforms) section
|
|
53
|
+
- if needed, do other custom modifications / extends
|
|
54
|
+
- create alpha version of the package
|
|
55
|
+
(tutorial [here](https://24imedia.atlassian.net/wiki/spaces/PRDNGBIGSCR/pages/1183481960/Preparing+Alpha+Builds+After+Merged+PR+and+Before+Full+Publish))
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
### How to extend SmartApps Template repository with new platform
|
|
59
|
+
The last step is updating [SmartApps Template repository](https://github.com/24i/smartapps-bigscreen-template),
|
|
60
|
+
see its [documentation](https://github.com/24i/smartapps-bigscreen-template/blob/development/docs/PLATFORM_ADD.md) about adding a new platform.
|
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.
|
|
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": "
|
|
64
|
+
"gitHead": "d577658f9d7a498f73f013be66b7115268a398d7"
|
|
65
65
|
}
|