@24i/bigscreen-sdk 1.0.36-alpha.2633 → 1.0.36

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/package.json CHANGED
@@ -1,15 +1,16 @@
1
1
  {
2
2
  "name": "@24i/bigscreen-sdk",
3
- "version": "1.0.36-alpha.2633",
3
+ "version": "1.0.36",
4
4
  "description": "SmartApps BIGscreen SDK monorepo",
5
5
  "main": "index.js",
6
6
  "scripts": {
7
- "prepare": "husky install && npm run patch-types && npm run scripts:prepare",
7
+ "prepare": "husky && npm run patch-types && npm run scripts:prepare",
8
8
  "prepublishOnly": "npm run scripts:prepare",
9
9
  "scripts:prepare": "ts-node ./utils/run-scripts/index.ts \"prepare:.+\"",
10
10
  "scripts:prepare:create-export-maps": "ts-node ./utils/create-export-maps/index.ts --project ./tsconfig.utils.json",
11
11
  "scripts:prepare:webos": "cd packages/driver-webos && ts-node ./scripts/exportWebOSTVjs.ts --project ../../tsconfig.utils.json",
12
12
  "scripts:create-package": "ts-node ./utils/create-package/src/index.ts --project ./tsconfig.utils.json",
13
+ "release": "ts-node --project ./tsconfig.utils.json ./utils/release/release.ts",
13
14
  "jest": "cross-env NODE_ICU_DATA=node_modules/full-icu jest",
14
15
  "eslint": "eslint \"./packages/**/src/**/*.{ts,tsx}\"",
15
16
  "stylelint": "stylelint \"./packages/**/src/**/*.scss\"",
@@ -40,7 +41,7 @@
40
41
  "@24i/appstage-shared-analytics": "1.0.20-alpha.70",
41
42
  "@24i/appstage-shared-events-manager": "1.0.11",
42
43
  "@24i/appstage-shared-perf-utils": "1.0.11",
43
- "@24i/bigscreen-players-engine-base": "4.0.1",
44
+ "@24i/bigscreen-players-engine-base": "4.0.3",
44
45
  "@24i/smartapps-datalayer": "3.0.15",
45
46
  "@sentry/browser": "7.35.0",
46
47
  "@sentry/types": "7.35.0",
@@ -18,6 +18,7 @@ const TO_PERCENT = 100;
18
18
 
19
19
  type Props = {
20
20
  ui: IPlayerUIWithSeeking;
21
+ children?: JSX.Element;
21
22
  } & PlayerUICommonProps;
22
23
 
23
24
  export class Seekbar extends Component<Props> implements IFocusable {
@@ -249,7 +250,7 @@ export class Seekbar extends Component<Props> implements IFocusable {
249
250
  }
250
251
 
251
252
  render() {
252
- const { className } = this.props;
253
+ const { children, className } = this.props;
253
254
  return (
254
255
  <div
255
256
  className={`seek-bar ${className}`}
@@ -260,6 +261,7 @@ export class Seekbar extends Component<Props> implements IFocusable {
260
261
  onClick={this.onMouseClick}
261
262
  onBlur={this.onBlur}
262
263
  >
264
+ {children}
263
265
  <div className="bar" ref={this.seekBarWrap}>
264
266
  <div className="bg" ref={this.seekBar} />
265
267
  </div>
@@ -0,0 +1,154 @@
1
+ import { ok } from 'assert';
2
+ import { execSync, ExecSyncOptions } from 'child_process';
3
+
4
+ const branchNames = {
5
+ dev: 'development',
6
+ main: 'master',
7
+ release: 'release',
8
+ };
9
+
10
+ const cmdSync = (command: string, options?: ExecSyncOptions) => execSync(command, options);
11
+ const cmdSyncInheritOut = (command: string) => cmdSync(command, { stdio: 'inherit' });
12
+ const cmdSyncPipeOut = (command: string) => cmdSync(command, { stdio: 'pipe' });
13
+ const cmdSyncTrimOut = (command: string) => cmdSync(command).toString().trim();
14
+
15
+ const splitByNewLine = (string = '') => string.split(/\r?\n/);
16
+
17
+ const statusList = () => {
18
+ const gitCmd = 'git status --porcelain';
19
+ const outputString = cmdSyncTrimOut(gitCmd);
20
+
21
+ if (!outputString) return [];
22
+ const handleMultipleWhitespaces = (rowString: string) => {
23
+ const spaceChar = ' ';
24
+ const parts = rowString.split(spaceChar);
25
+ return parts.filter(Boolean).join(spaceChar);
26
+ };
27
+
28
+ return splitByNewLine(outputString).map(handleMultipleWhitespaces);
29
+ };
30
+ const createBranch = (branchName: string) => cmdSyncPipeOut(`git branch ${branchName}`);
31
+ const checkout = (branchName: string) => cmdSyncPipeOut(`git checkout ${branchName}`);
32
+ const addAll = () => cmdSyncPipeOut('git add --all');
33
+
34
+ const commit = (commitMessage: string, noVerify = false) => {
35
+ const maybeNoVerifyParam = noVerify ? '--no-verify' : '';
36
+ return cmdSyncPipeOut(`git commit -m "${commitMessage}" ${maybeNoVerifyParam}`.trimEnd());
37
+ };
38
+
39
+ const push = (branchName: string, noVerify = false) => {
40
+ const maybeNoVerifyParam = noVerify ? '--no-verify' : '';
41
+ const cmd = `git push --set-upstream origin ${branchName} ${maybeNoVerifyParam}`.trimEnd();
42
+ return cmdSyncPipeOut(cmd);
43
+ };
44
+
45
+ const pushTag = (version: string) => {
46
+ const cmd = `git push v${version}`;
47
+ return cmdSyncPipeOut(cmd);
48
+ };
49
+
50
+ const assertEmptyStatusList = () => {
51
+ ok(statusList().length === 0, 'An empty GIT stage is expected!');
52
+ };
53
+
54
+ const getCurrentBranchName = () => cmdSyncTrimOut('git branch --show-current');
55
+
56
+ const remoteBranchExists = (expectedBranchName: string) => {
57
+ const gitCmd = `git ls-remote --heads origin ${expectedBranchName}`;
58
+ const output = cmdSyncTrimOut(gitCmd);
59
+ return Boolean(output);
60
+ };
61
+
62
+ // only for GitHub
63
+ const pullRequest = (fromBranch: string, toBranch: string, prTitle: string) => {
64
+ const cmdTool = 'hub';
65
+ const installDocUrl = 'https://github.com/github/hub#installation';
66
+ const errorMsg = `${cmdTool} is not installed! See ${installDocUrl}\n`;
67
+
68
+ try {
69
+ const toolPath = cmdSyncTrimOut(`${cmdTool} --version`);
70
+ ok(toolPath, errorMsg);
71
+ } catch (error) {
72
+ throw new Error(errorMsg);
73
+ }
74
+
75
+ const cmd = `${cmdTool} pull-request -m "${prTitle}" --head ${fromBranch} --base ${toBranch}`;
76
+ cmdSyncInheritOut(cmd);
77
+ };
78
+
79
+ const assertCurrentBranch = (expectedBranchName: string) => {
80
+ const currentGitBranchName = getCurrentBranchName();
81
+ // eslint-disable-next-line max-len
82
+ const errorMsg = `The ${expectedBranchName} branch is expected to be active, not "${currentGitBranchName}"`;
83
+ ok(currentGitBranchName === expectedBranchName, errorMsg);
84
+ };
85
+
86
+ const bumpVersion = (version: string | 'major' | 'minor' | 'patch') => {
87
+ // it bumps version, creates commit and GIT tag
88
+ execSync(`npm version ${version}`, { stdio: 'inherit' });
89
+ };
90
+
91
+ const getNewReleaseBranchName = () => {
92
+ const date = new Date();
93
+ const yyyy = date.getFullYear();
94
+ const mm = String(date.getMonth() + 1).padStart(2, '0');
95
+ const dd = String(date.getDate()).padStart(2, '0');
96
+ let bod = 0;
97
+ const dateString = `${yyyy}-${mm}-${dd}`;
98
+ while (true) {
99
+ bod += 1;
100
+ const bodString = String(bod).padStart(2, '0');
101
+ const branchName = `${branchNames.release}/${dateString}-${bodString}`;
102
+ if (!remoteBranchExists(branchName)) {
103
+ return branchName;
104
+ }
105
+ }
106
+ };
107
+
108
+ /**
109
+ * Release process.
110
+ * @param versionType Version type one of 'major', 'minor', 'patch' or specific
111
+ * version like '0.0.2'.
112
+ */
113
+ const release = (versionType: string | 'major' | 'minor' | 'patch') => {
114
+ console.log(`Start release with version: ${versionType}`);
115
+ assertCurrentBranch(branchNames.dev);
116
+ assertEmptyStatusList();
117
+ const newReleaseBranchName = getNewReleaseBranchName();
118
+
119
+ console.log(`Creating "${newReleaseBranchName}" branch ...`);
120
+ createBranch(newReleaseBranchName);
121
+ checkout(newReleaseBranchName);
122
+
123
+ console.log(`Bumping version with "${versionType}" ...`);
124
+ bumpVersion(versionType);
125
+ const version = cmdSyncTrimOut('npm pkg get version');
126
+ ok(version, 'Oops, cannot get current version from package.json');
127
+
128
+ console.log(`Publishing package version: ${version} ...`);
129
+ cmdSyncInheritOut('npm publish');
130
+
131
+ console.log(`Generating changelog: ${version} ...`);
132
+ cmdSyncInheritOut('npm run generate-changelog');
133
+ addAll(); // add version changes (changelog) into a git stage
134
+
135
+ console.log('Creating commit with changed version and changelog ...');
136
+ commit('chore(CHANGELOG): generated changelog', true);
137
+
138
+ console.log(`Pushing ${newReleaseBranchName} branch ...`);
139
+ push(newReleaseBranchName, true);
140
+
141
+ console.log(`Pushing ${version} tag ...`);
142
+ pushTag(version);
143
+
144
+ const prTitle = `Release: ${newReleaseBranchName.split('/')[1]}`;
145
+ // eslint-disable-next-line max-len
146
+ console.log(`Creating Pull Request from ${newReleaseBranchName} branch to ${branchNames.main} branch...`);
147
+ console.log(`Applied PR title: "${prTitle}"`);
148
+ pullRequest(newReleaseBranchName, branchNames.main, prTitle);
149
+
150
+ console.log('Done!');
151
+ };
152
+
153
+ const version = process.argv[2] || 'patch'; // 'major' | 'minor' | 'patch'
154
+ release(version);