Skip to content

Commit 5844a0c

Browse files
authored
Merge pull request Sofie-Automation#1230 from nrkno/feat/vite-ui-bundler2
2 parents 497bd3d + 8e16b94 commit 5844a0c

File tree

1,181 files changed

+22370
-9155
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,181 files changed

+22370
-9155
lines changed

.github/workflows/node.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,11 +184,18 @@ jobs:
184184
run: |
185185
cd meteor
186186
yarn inject-git-hash
187+
- name: Prepare webui for meteor build
188+
if: steps.check-build-and-push.outputs.enable == 'true'
189+
run: |
190+
rm -Rf meteor/public
191+
cp -R packages/webui/dist meteor/public
187192
- name: Meteor Build
188193
if: steps.check-build-and-push.outputs.enable == 'true'
189194
run: |
190195
cd meteor
191196
NODE_OPTIONS="--max-old-space-size=4096" METEOR_DEBUG_BUILD=1 meteor build --allow-superuser --directory .
197+
mv bundle/programs/web.browser/assets/ bundle/programs/web.browser/app/assets/ || true
198+
192199
- name: Meteor Bundle NPM Build
193200
if: steps.check-build-and-push.outputs.enable == 'true'
194201
run: |
@@ -422,9 +429,11 @@ jobs:
422429
- mos-gateway
423430
- corelib
424431
- shared-lib
432+
- meteor-lib
425433
- job-worker
426434
- openapi
427435
- live-status-gateway
436+
- webui
428437

429438
steps:
430439
- uses: actions/checkout@v4
@@ -491,6 +500,14 @@ jobs:
491500
- node-version: 18.x
492501
package-name: live-status-gateway
493502
send-coverage: true
503+
- node-version: 18.x
504+
package-name: webui
505+
# manual meteor-lib as it only needs a couple of versions
506+
- node-version: 18.x
507+
package-name: meteor-lib
508+
send-coverage: true
509+
- node-version: 14.x
510+
package-name: meteor-lib
494511

495512
steps:
496513
- uses: actions/checkout@v4

DEVELOPER.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ yarn start
3636

3737
> 💡 First startup may take a while, especially on Windows. To speed things up, consider adding `%LOCALAPPDATA%\.meteor` and the directory where you cloned `server-core` to your Windows Defender virus protection exclusions.
3838
39+
The Sofie ui (served by Vite) can be accessed at `http://localhost:3005`. The meteor http server can be access directly at `http://localhost:3000`
40+
3941
### Slightly more Involved Start
4042

4143
1. Clone the repository (for development, it is recommended to base your work on the latest unstable release branch)

meteor/.eslintrc.js

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -56,43 +56,20 @@ const tsBase = {
5656
}
5757

5858
module.exports = {
59-
extends: [...commonExtends, 'plugin:react/recommended'],
60-
plugins: [...commonPlugins, 'react'],
59+
extends: [...commonExtends],
60+
plugins: [...commonPlugins],
6161
rules: {
6262
'prettier/prettier': 'error',
6363
},
6464
env: { es2017: true },
6565
parserOptions: { sourceType: 'module', ecmaVersion: 2018 },
66-
settings: {
67-
react: {
68-
version: 'detect', // Tells eslint-plugin-react to automatically detect the version of React to use
69-
},
70-
},
66+
settings: {},
7167
overrides: [
7268
// Note: these replace the values defined above, so make sure to extend them if they are needed
7369
{
7470
files: ['*.ts'],
7571
...tsBase,
7672
},
77-
{
78-
files: ['*.tsx'],
79-
...tsBase,
80-
extends: [...tsBase.extends, 'plugin:react/recommended'],
81-
parserOptions: {
82-
...tsBase.parserOptions,
83-
ecmaFeatures: {
84-
jsx: true, // Allows for the parsing of JSX
85-
},
86-
},
87-
rules: {
88-
...tsBase.rules,
89-
'node/no-extraneous-import': 'off', // because there are a lot of them as dev-dependencies
90-
'node/no-missing-import': 'off', // erroring on every single import
91-
'react/prop-types': 'off', // we don't use this
92-
'@typescript-eslint/no-empty-interface': 'off', // many prop/state types are {}
93-
'@typescript-eslint/promise-function-async': 'off', // event handlers can't be async
94-
},
95-
},
9673
{
9774
files: ['*.js'],
9875
env: {

meteor/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ src/**/*.js.map
55
coverage
66
settings.json
77
server/_force_restart.js
8+
public/
89

910
# Ignore TV2-features:
1011
client/styles/tv2

meteor/Dockerfile

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,18 @@
11
# syntax=docker/dockerfile:experimental
2+
3+
# BUILD WEBUI
4+
FROM node:18
5+
COPY packages /opt/core/packages
6+
WORKDIR /opt/core/packages
7+
8+
RUN rm -R *-gateway documentation openapi
9+
RUN corepack enable
10+
RUN yarn install && yarn build
11+
12+
# Install production dependencies for the worker
13+
# HACK:
14+
# RUN yarn workspaces focus --production @sofie-automation/job-worker @sofie-automation/corelib
15+
216
# BUILD IMAGE
317
FROM meteor/node:14.21.4
418
RUN curl "https://install.meteor.com/?release=2.13.3" | sh
@@ -9,17 +23,18 @@ ENV NODE_ENV anythingButProduction
923

1024
# Prepare the packages
1125
COPY package.json /opt/core/package.json
12-
COPY packages /opt/core/packages
13-
WORKDIR /opt/core/packages
14-
RUN rm -R *-gateway documentation openapi
15-
RUN corepack enable
16-
RUN yarn install && yarn build
26+
COPY --from=0 /opt/core/packages /opt/core/packages
1727

1828
# Add the meteor source
1929
COPY meteor /opt/core/meteor
2030
COPY scripts /opt/core/scripts
2131
WORKDIR /opt/core/meteor
2232

33+
# move the webui to the correct place
34+
RUN rm -Rf /opt/core/meteor/public
35+
RUN cp -R /opt/core/packages/webui/dist /opt/core/meteor/public
36+
RUN rm -R /opt/core/packages/webui
37+
2338
# Force meteor to setup the runtime
2439
RUN meteor --version --allow-superuser
2540
RUN meteor corepack enable
@@ -31,9 +46,8 @@ RUN --mount=type=cache,target=/opt/core/meteor/.meteor/local NODE_OPTIONS="--max
3146
WORKDIR /opt/bundle/programs/server/
3247
RUN npm install
3348

34-
# Install production dependencies for the worker
35-
WORKDIR /opt/core/packages
36-
RUN yarn workspaces focus --production @sofie-automation/job-worker @sofie-automation/corelib
49+
# meteor does something weird with these files
50+
RUN mv /opt/bundle/programs/web.browser/assets /opt/bundle/programs/web.browser/app/assets || true
3751

3852
# DEPLOY IMAGE
3953
FROM alpine:3.19
@@ -60,11 +74,8 @@ ENV PATH $DIR_NODE/v$NODE_VERSION/bin:$PATH
6074
# confirm installation
6175
RUN node -v && npm -v
6276

63-
COPY --from=0 /opt/bundle /opt/core
77+
COPY --from=1 /opt/bundle /opt/core
6478
COPY meteor/docker-entrypoint.sh /opt
6579

66-
# Tell meteor where the worker code is located
67-
ENV WORKER_EXEC_DIR=/opt/packages/job-worker
68-
6980
WORKDIR /opt/core/
7081
CMD ["/opt/docker-entrypoint.sh"]

meteor/__mocks__/_extendJest.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@ import { UserError, UserErrorMessage } from '@sofie-automation/corelib/dist/erro
22
import { Meteor } from 'meteor/meteor'
33
import { clone } from '@sofie-automation/corelib/dist/lib'
44
import { stringifyError } from '@sofie-automation/shared-lib/dist/lib/stringifyError'
5-
import '../server/api/logger'
65
import _ from 'underscore'
7-
import { ClientAPI } from '../lib/api/client'
6+
import { ClientAPI } from '@sofie-automation/meteor-lib/dist/api/client'
87

98
// Include this file in to get access to the extended functions
109

meteor/__mocks__/_setupMocks.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { setLogLevel } from '../server/logging'
22
import { Fiber } from './Fibers'
33
import { resetRandomId } from './random'
44
import { makeCompatible } from 'meteor-promise'
5-
import { LogLevel } from '../lib/lib'
5+
import { LogLevel } from '../server/lib/tempLib'
66
import { SupressLogMessages } from './suppressLogging'
77

88
// This file is run before all tests start.
@@ -34,8 +34,6 @@ jest.mock('meteor/webapp', (...args) => require('./webapp').setup(args), { virtu
3434
jest.mock('../server/api/integration/slack', (...args) => require('./slack').setup(args), { virtual: true })
3535
jest.mock('../server/worker/worker', (...args) => require('./worker').setup(args), { virtual: true })
3636

37-
require('../server/api/logger.ts')
38-
3937
SupressLogMessages.init()
4038

4139
beforeEach(() => {

meteor/__mocks__/defaultCollectionObjects.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { DBStudio } from '@sofie-automation/corelib/dist/dataModel/Studio'
2-
import { clone, getCurrentTime, unprotectString } from '../lib/lib'
2+
import { clone, unprotectString } from '../server/lib/tempLib'
33
import { DBRundownPlaylist } from '@sofie-automation/corelib/dist/dataModel/RundownPlaylist'
44
import { DBRundown } from '@sofie-automation/corelib/dist/dataModel/Rundown'
55
import { DBSegment } from '@sofie-automation/corelib/dist/dataModel/Segment'
@@ -9,7 +9,7 @@ import { Piece, EmptyPieceTimelineObjectsBlob } from '@sofie-automation/corelib/
99
import { AdLibPiece } from '@sofie-automation/corelib/dist/dataModel/AdLibPiece'
1010
import { getRundownId } from '../server/api/ingest/lib'
1111
import { wrapDefaultObject } from '@sofie-automation/corelib/dist/settings/objectWithOverrides'
12-
import { PartInstance } from '../lib/collections/PartInstances'
12+
import { PartInstance } from '@sofie-automation/meteor-lib/dist/collections/PartInstances'
1313
import { PieceInstance } from '@sofie-automation/corelib/dist/dataModel/PieceInstance'
1414
import {
1515
PartId,
@@ -37,8 +37,8 @@ export function defaultRundownPlaylist(_id: RundownPlaylistId, studioId: StudioI
3737
studioId: studioId,
3838

3939
name: 'Default RundownPlaylist',
40-
created: getCurrentTime(),
41-
modified: getCurrentTime(),
40+
created: Date.now(),
41+
modified: Date.now(),
4242

4343
// activationId: undefined,
4444
rehearsal: false,
@@ -72,8 +72,8 @@ export function defaultRundown(
7272
externalId: externalId,
7373
name: 'Default Rundown',
7474

75-
created: getCurrentTime(),
76-
modified: getCurrentTime(),
75+
created: Date.now(),
76+
modified: Date.now(),
7777
importVersions: {
7878
studio: '',
7979
showStyleBase: '',

meteor/__mocks__/helpers/database.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,18 @@ import {
3636
import { DBShowStyleBase } from '@sofie-automation/corelib/dist/dataModel/ShowStyleBase'
3737
import { DBShowStyleVariant } from '@sofie-automation/corelib/dist/dataModel/ShowStyleVariant'
3838
import { Blueprint } from '@sofie-automation/corelib/dist/dataModel/Blueprint'
39-
import { ICoreSystem, SYSTEM_ID, stripVersion } from '../../lib/collections/CoreSystem'
39+
import { ICoreSystem, SYSTEM_ID } from '@sofie-automation/meteor-lib/dist/collections/CoreSystem'
40+
import { stripVersion } from '../../server/systemStatus/semverUtils'
4041
import { internalUploadBlueprint } from '../../server/api/blueprints/api'
4142
import {
4243
literal,
43-
getCurrentTime,
4444
protectString,
4545
unprotectString,
4646
getRandomId,
4747
getRandomString,
4848
Complete,
4949
normalizeArray,
50-
} from '../../lib/lib'
50+
} from '../../server/lib/tempLib'
5151
import { DBRundown } from '@sofie-automation/corelib/dist/dataModel/Rundown'
5252
import { DBSegment } from '@sofie-automation/corelib/dist/dataModel/Segment'
5353
import { DBPart } from '@sofie-automation/corelib/dist/dataModel/Part'
@@ -59,14 +59,14 @@ import { restartRandomId } from '../random'
5959
import { MongoMock } from '../mongo'
6060
import { defaultRundownPlaylist, defaultStudio } from '../defaultCollectionObjects'
6161
import { PackageInfo } from '../../server/coreSystem'
62-
import { DBTriggeredActions } from '../../lib/collections/TriggeredActions'
63-
import { WorkerStatus } from '../../lib/collections/Workers'
62+
import { DBTriggeredActions } from '@sofie-automation/meteor-lib/dist/collections/TriggeredActions'
63+
import { WorkerStatus } from '@sofie-automation/meteor-lib/dist/collections/Workers'
6464
import { WorkerThreadStatus } from '@sofie-automation/corelib/dist/dataModel/WorkerThreads'
6565
import {
6666
applyAndValidateOverrides,
6767
wrapDefaultObject,
6868
} from '@sofie-automation/corelib/dist/settings/objectWithOverrides'
69-
import { UIShowStyleBase } from '../../lib/api/showStyles'
69+
import { UIShowStyleBase } from '@sofie-automation/meteor-lib/dist/api/showStyles'
7070
import {
7171
BlueprintId,
7272
OrganizationId,
@@ -624,8 +624,8 @@ export async function setupDefaultRundown(
624624
externalId: 'MOCK_RUNDOWN_' + rundownId,
625625
name: 'Default Rundown',
626626

627-
created: getCurrentTime(),
628-
modified: getCurrentTime(),
627+
created: Date.now(),
628+
modified: Date.now(),
629629
importVersions: {
630630
studio: '',
631631
showStyleBase: '',

meteor/__mocks__/helpers/lib.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as _ from 'underscore'
2-
import { LogLevel, ProtectedString } from '../../lib/lib'
2+
import { LogLevel, ProtectedString } from '../../server/lib/tempLib'
33
import { AsyncOnlyMongoCollection } from '../../server/collections/collection'
44
import { getLogLevel, setLogLevel } from '../../server/logging'
55

0 commit comments

Comments
 (0)