Skip to content

Commit

Permalink
Merge branch 'master' into fix/reject-invalid-paths
Browse files Browse the repository at this point in the history
# Conflicts:
#	apps/http-server/packages/generic/src/storage/fileStorage.ts
#	shared/packages/api/src/lib.ts
#	shared/packages/worker/src/worker/accessorHandlers/http.ts
#	shared/packages/worker/src/worker/accessorHandlers/lib/FileHandler.ts
  • Loading branch information
nytamin committed Aug 28, 2024
2 parents 7e0789f + e576a66 commit ecc6a6e
Show file tree
Hide file tree
Showing 73 changed files with 5,337 additions and 441 deletions.
2 changes: 2 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@ updates:
interval: "weekly"
reviewers:
- "@nrkno/sofie-ops"
# Only create security updates
open-pull-requests-limit: 0
2 changes: 2 additions & 0 deletions .github/workflows/build-windows.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ jobs:

steps:
- uses: actions/checkout@v4
with:
persist-credentials: false

- name: Use Node.js
uses: actions/setup-node@v4
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/lint-and-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ jobs:
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v4
with:
persist-credentials: false

- name: Use Node.js
uses: actions/setup-node@v4
Expand Down Expand Up @@ -60,6 +62,8 @@ jobs:
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v4
with:
persist-credentials: false

- name: Use Node.js ${{ matrix.node_version }}
uses: actions/setup-node@v4
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/publish-prerelease-docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ jobs:

steps:
- uses: actions/checkout@v4
with:
persist-credentials: false

- name: Determine if images should be published to DockerHub
id: dockerhub
Expand Down Expand Up @@ -166,7 +168,7 @@ jobs:
tags: "${{ steps.quantel-dockerhub-tag.outputs.tags }}"

trivy-scanning-http-server:
uses: nrkno/github-workflow-docker-build-push/.github/workflows/workflow.yaml@v4.0.1
uses: nrkno/github-workflow-docker-build-push/.github/workflows/workflow.yaml@v4.1.0
with:
runs-on: "['ubuntu-latest']"
registry-url: ghcr.io
Expand All @@ -183,7 +185,7 @@ jobs:
token: ${{ secrets.GITHUB_TOKEN }}

trivy-scanning-quantel-http-transformer-proxy:
uses: nrkno/github-workflow-docker-build-push/.github/workflows/workflow.yaml@v4.0.1
uses: nrkno/github-workflow-docker-build-push/.github/workflows/workflow.yaml@v4.1.0
with:
runs-on: "['ubuntu-latest']"
registry-url: ghcr.io
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/publish-prerelease.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ jobs:
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v4
with:
persist-credentials: false
- name: Use Node.js ${{ matrix.node_version }}
uses: actions/setup-node@v4
with:
Expand Down Expand Up @@ -46,6 +48,7 @@ jobs:
- uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false
- name: Use Node.js
uses: actions/setup-node@v4
with:
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,5 @@ ffprobe.exe
apps/single-app/app/expectedPackages.json_smartbull
.ffmpeg/
signtool.exe
apps/single-app/app/tmp/
apps/single-app/app/tmpRenderHTML/
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,19 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [1.50.7](https://github.com/nrkno/tv-automation-package-manager/compare/v1.50.6...v1.50.7) (2024-07-04)


### Bug Fixes

* http-server: add '/list' endpoint, that displays a HTML page with a list of the packages ([1acfb0c](https://github.com/nrkno/tv-automation-package-manager/commit/1acfb0c21d0b4a0cbf76a959cff83ea2a8cdd102))
* improve the info message at '/' and refactor ([d5ac4a1](https://github.com/nrkno/tv-automation-package-manager/commit/d5ac4a15468f568a27d2d8704559fd4ded7e36f3))
* the path need to be relative to account for when the http-server is proxied ([79e67b4](https://github.com/nrkno/tv-automation-package-manager/commit/79e67b4d1c189a643b6ac8ed8b2c190db2cecf84))





# [1.50.5](https://github.com/nrkno/tv-automation-package-manager/compare/v1.50.4...v1.50.5) (2024-04-09)

### Bug Fixes
Expand Down
3 changes: 2 additions & 1 deletion apps/appcontainer-node/packages/generic/src/appContainer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,8 @@ export class AppContainer {
availableApp: AvailableAppInfo,
useCriticalOnlyMode: boolean
): cp.ChildProcess {
const cwd = process.execPath.match(/node.exe$/)
const isRunningInDevelopmentMode = process.execPath.endsWith('node.exe') || process.execPath.endsWith('node')
const cwd = isRunningInDevelopmentMode
? undefined // Process runs as a node process, we're probably in development mode.
: path.dirname(process.execPath) // Process runs as a node process, we're probably in development mode.

Expand Down
4 changes: 4 additions & 0 deletions apps/html-renderer/app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
ffmpeg.exe
ffprobe.exe
log.log
deploy/*
73 changes: 73 additions & 0 deletions apps/html-renderer/app/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# HTML Renderer

## How to run

### Default CasparCG template

_This is used for a HTML file that follows the typical CasparCG lifespan (`update(data); play(); stop()`)_

```bash
html-renderer.exe -- --url=file://C:/templates/mytemplate.html outputPath="C:\\rendered" --screenshots=true --recording=true --recording-cropped=true --casparData='{"name":"John Doe"}' --casparDelay=1000
```

### Generic HTML template

_This is used for a HTML file that doesn't require any additional input during its run._

```bash
html-renderer.exe -- --url=https://bouncingdvdlogo.com outputPath="C:\\rendered" --screenshots=true --recording=true --recording-cropped=false --genericWaitIdle=1000 --genericWaitPlay=1000 --genericWaitStop=1000 --width=480 --height=320 --zoom=0.25
```

### Interactive mode

_This is used for HTML templates that require manual handling (like, external API calls need to be made)_

```bash
html-renderer.exe -- --url=https://bouncingdvdlogo.com outputPath=C:\\rendered --interactive=1
```

In interactive mode, commands are sent to the renderer via the console. The following commands are available:

```json

// Wait for this message before sending interactive messages.
{ "status": "ready" }


// Wait for the load event to be fired
{ "do": "waitForLoad" }
// Reply:
{ "reply": "waitForLoad" }

// Take a screenshot and save it as PNG
{ "do": "takeScreenshot", "fileName": "screenshot.png" }
// Reply:
{ "reply": "takeScreenshot" }
{ "reply": "takeScreenshot", "error": "Unable to write file \"screenshot.png\"" }

// Start recording
{ "do": "startRecording", "fileName": "recording.webm" }
// Reply:
{ "reply": "startRecording" }
{ "reply": "startRecording", "error": "Recording already started" }


// Stop recording
{ "do": "stopRecording" }
// Reply:
{ "reply": "stopRecording"}
{ "reply": "stopRecording", "error": "Unable to write file \"recording.webm\"" }

// Analyze the recording and crop it to only include the region with content
{ "do": "cropRecording", "fileName": "recording-cropped.webm" }
// Reply:
{ "reply": "cropRecording" }
{ "reply": "cropRecording", "error": "No recording found" }

// Execute javascript in the renderer
{ "do": "executeJs", "js": "update(\"myData\")" }
// Reply:
{ "reply": "executeJs" }
{ "reply": "executeJs", "error": "Some error" }

```
7 changes: 7 additions & 0 deletions apps/html-renderer/app/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const base = require('../../../jest.config.base')
const packageJson = require('./package')

module.exports = {
...base,
displayName: packageJson.name,
}
76 changes: 76 additions & 0 deletions apps/html-renderer/app/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
{
"name": "@html-renderer/app",
"version": "1.50.5",
"description": "HTML-renderer",
"private": true,
"main": "dist/index.js",
"scripts": {
"build": "yarn rimraf dist && yarn build:main",
"build:main": "tsc -p tsconfig.json",
"build-win32": "yarn prepare-build-win32 && electron-builder && yarn post-build-win32",
"prepare-build-win32": "node scripts/prepare_build.js",
"post-build-win32": "node scripts/post_build.js",
"__test": "jest",
"start": "electron dist/index.js"
},
"prettier": "@sofie-automation/code-standard-preset/.prettierrc.json",
"engines": {
"node": ">=18"
},
"lint-staged": {
"*.{js,css,json,md,scss}": [
"prettier"
],
"*.{ts,tsx}": [
"eslint"
]
},
"peerDependencies": {
"ws": "*"
},
"dependencies": {
"@html-renderer/generic": "1.50.5",
"@sofie-automation/shared-lib": "1.51.0-nightly-fix-pm-types-html-template-20240823-061828-d90c220.0",
"@sofie-package-manager/api": "1.50.6",
"portfinder": "^1.0.32",
"tslib": "^2.1.0",
"yargs": "^17.7.2"
},
"devDependencies": {
"@types/ws": "^8.5.4",
"archiver": "^7.0.1",
"electron": "30.0.6",
"electron-builder": "^24.13.3",
"lerna": "^6.6.1",
"rimraf": "^5.0.5"
},
"build": {
"productName": "html-renderer",
"appId": "no.nrk.sofie.html-renderer",
"win": {
"extraFiles": [],
"target": [
{
"target": "portable",
"arch": [
"x64"
]
}
]
},
"linux": {
"target": "dir",
"executableName": "html-renderer",
"extraFiles": []
},
"files": [
"dist/**/*"
],
"portable": {
"artifactName": "html-renderer.exe"
},
"directories": {
"output": "deploy"
}
}
}
46 changes: 46 additions & 0 deletions apps/html-renderer/app/scripts/post_build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/* eslint-disable no-console, node/no-unpublished-require */
const fs = require('fs')
const path = require('path')
const archiver = require('archiver')

/*
* This script gathers the built files from electron-builder and zips them into a zip file
*/

async function main() {
const myDir = path.resolve('.')
const deployDir = path.join(myDir, 'deploy')
const archiveDir = path.join(deployDir, 'win-unpacked')

const zipFile = path.join(deployDir, 'html-renderer.zip')

await new Promise((resolve, reject) => {
const output = fs.createWriteStream(zipFile)
const archive = archiver('zip', {
zlib: { level: 5 }, // Sets the compression level.
})
output.on('close', function () {
console.log(archive.pointer() + ' total bytes')
resolve()
})
archive.on('warning', function (err) {
if (err.code === 'ENOENT') console.log(`WARNING: ${err}`)
else reject(err)
})
archive.on('error', reject)
archive.pipe(output)

console.log(`Archiving ${archiveDir}`)
archive.directory(archiveDir, false)

archive.finalize()
})
console.log('Zipping done, removing temporary artifacts...')

// Remove the archived directory
await fs.promises.rm(archiveDir, { recursive: true })
await fs.promises.rm(path.join(deployDir, 'html-renderer.exe'), { recursive: true })
await fs.promises.rm(path.join(myDir, 'node_modules'), { recursive: true })
}

main().catch(console.error)
32 changes: 32 additions & 0 deletions apps/html-renderer/app/scripts/prepare_build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
const fs = require('fs')
const path = require('path')
/* eslint-disable no-console */

/*
* This script copies some dependencies from the main node_modules folder to the node_modules folder of this project.
* So that electron-builder includes them when building the executable.
*/

async function main() {
// Things to copy:

const baseDir = path.resolve('../../..')
const myDir = path.resolve('.')

const libsToCopy = ['tslib', '@sofie-automation']

// Create node_modules folder
await fs.promises.mkdir(path.join(myDir, 'node_modules'), { recursive: true })

for (const lib of libsToCopy) {
const src = path.join(baseDir, `node_modules/${lib}`)
const target = path.join(myDir, `node_modules/${lib}`)
console.log(`Copying ${src} to ${target}`)
await fs.promises.cp(src, target, {
recursive: true,
})
}
}

main().catch(console.error)
7 changes: 7 additions & 0 deletions apps/html-renderer/app/src/__tests__/test.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
describe('tmp', () => {
test('tmp', () => {
// Note: To enable tests in this package, ensure that the "test" script is present in package.json
expect(1).toEqual(1)
})
})
export {}
Loading

0 comments on commit ecc6a6e

Please sign in to comment.