Skip to content

Commit b377208

Browse files
committed
chore: change names of scripts, to align better with established patterns in rest of the world
1 parent 23b7ecc commit b377208

4 files changed

Lines changed: 67 additions & 45 deletions

File tree

DEVELOPER.md

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,13 @@ Follow these instructions to start up Sofie Core in development mode. (For produ
3030
git clone -b main https://github.com/Sofie-Automation/sofie-core.git
3131
cd sofie-core
3232
yarn
33-
yarn start
33+
yarn dev # Install and build all packages, then start in dev mode with file watching
34+
35+
# Or
36+
37+
yarn
38+
yarn build # Install and build all packages
39+
yarn start # Start Sofie Core (no file watching)
3440
```
3541

3642
> 💡 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.
@@ -60,22 +66,23 @@ The Sofie ui (served by Vite) can be accessed at `http://localhost:3005`. The me
6066
4. Start development mode
6167

6268
```bash
63-
yarn dev
69+
yarn dev # Install and build all packages, then start in dev mode with file watching
6470
```
6571

6672
5. In another window, start the playout-gateway. You will need to manually restart this upon making changes
6773

6874
```bash
6975
cd sofie-core/packages/playout-gateway
70-
yarn buildstart
76+
yarn build # If needed
77+
yarn start
7178
```
7279

7380
### Lowering memory, CPU footprint in development
7481

75-
If you find yourself in a situation where running Sofie in development mode is too heavy, but you're not planning on modifying any of the low-level packages in the `packages` directory, you may want to run Sofie in the _UI-only mode_, in which only meteor and the ui will be rebuilt and type-checked on modification:
82+
If you find yourself in a situation where running Sofie in development mode is too heavy, but you're not planning on modifying any of the low-level packages in the `packages` directory, you may want to run Sofie without file watching and type-checking.
7683

7784
```bash
78-
yarn dev --ui-only
85+
yarn start # Start Sofie Core (no file watching, requires a `yarn build` first)
7986
```
8087

8188
### Dealing with Strange Errors
@@ -84,7 +91,7 @@ If you get any strange errors (such as the application crashing, "Unable to reso
8491

8592
```bash
8693
yarn reset # Removes all installed dependencies and build artifacts
87-
yarn start # Set up, install and run in dev mode
94+
yarn dev # Set up, install and run in dev mode
8895
```
8996

9097
## Editing the Code

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@
77
"node": ">=22.20.0"
88
},
99
"scripts": {
10+
"dev": "yarn build && yarn start --watch",
11+
"build": "run install-and-build",
12+
"start": "node ./scripts/run.mjs",
1013
"prepare": "husky",
1114
"postinstall": "run install:packages && run install:meteor",
1215
"install:meteor": "yarn restart:meteor && cd meteor && meteor --version && meteor npm install -g yarn && node ../scripts/fix-windows-yarn.js && yarn install",
1316
"install:packages": "cd packages && yarn install",
14-
"start": "yarn install && run install-and-build && run dev",
1517
"install-and-build": "node ./scripts/install-and-build.mjs",
16-
"dev": "node ./scripts/run.mjs",
1718
"restart:meteor": "node ./scripts/meteor-force-restart.js",
1819
"build:packages": "cd packages && run build",
1920
"test:packages": "cd packages && run test",

scripts/lib.js

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,23 +23,24 @@ Options:
2323
--db-list List all available database directories and show which is active
2424
2525
Examples:
26-
yarn start # Install, build, then run in dev mode
27-
yarn dev # Run in normal dev mode (requires prior build)
28-
yarn dev --db-list # List all available databases
29-
yarn dev --db=testing # Use a separate database for testing
30-
yarn dev --db=demo # Switch to demo database
31-
yarn dev --ui-only # Only watch UI, skip backend packages
32-
yarn dev --inspect-meteor # Debug Meteor with inspector
26+
yarn dev # Install, build, then run start with --watch
27+
yarn start # Run in normal dev mode (requires prior build)
28+
yarn start --watch # Run in dev mode with file watching
29+
yarn start --db-list # List all available databases
30+
yarn start --db=testing # Use a separate database for testing
31+
yarn start --db=demo # Switch to demo database
32+
yarn start --inspect-meteor # Debug Meteor with inspector
3333
yarn start --db=demo # Install, build, and run with demo database
3434
`);
3535
process.exit(0);
3636
}
3737

3838
// Parse --db=name option
39-
const dbArg = args.find(arg => arg.startsWith('--db='));
40-
const dbName = dbArg ? dbArg.split('=')[1] : null;
39+
const dbArg = args.find((arg) => arg.startsWith("--db="));
40+
const dbName = dbArg ? dbArg.split("=")[1] : null;
4141

4242
const config = {
43+
watchMode: args.indexOf("--watch") >= 0 || false,
4344
uiOnly: args.indexOf("--ui-only") >= 0 || false,
4445
inspectMeteor: args.indexOf("--inspect-meteor") >= 0 || false,
4546
verbose: args.indexOf("--verbose") >= 0 || false,

scripts/run.mjs

Lines changed: 41 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ function joinCommand(...parts) {
1111
function watchPackages() {
1212
return [
1313
{
14-
command: 'yarn watch --preserveWatchOutput',
14+
command: "yarn watch --preserveWatchOutput",
1515
cwd: "packages",
1616
name: "TSC",
1717
prefixColor: "red",
@@ -33,21 +33,21 @@ function watchWorker() {
3333
function watchMeteor() {
3434
const settingsFileExists = fs.existsSync("meteor-settings.json");
3535
if (settingsFileExists) {
36-
console.log('Found meteor-settings.json')
36+
console.log("Found meteor-settings.json");
3737
} else {
38-
console.log('No meteor-settings.json')
38+
console.log("No meteor-settings.json");
3939
}
4040

4141
// If a ROOT_URL is defined, meteor will serve under that. We should use the same for vite, to get the correct proxying
42-
const rootUrl = process.env.ROOT_URL ? new URL(process.env.ROOT_URL) : null
42+
const rootUrl = process.env.ROOT_URL ? new URL(process.env.ROOT_URL) : null;
4343

4444
return [
4545
{
4646
command: joinCommand(
47-
'yarn debug',
47+
"yarn debug",
4848
config.inspectMeteor ? " --inspect" : "",
4949
config.verbose ? " --verbose" : "",
50-
settingsFileExists ? " --settings ../meteor-settings.json" : ""
50+
settingsFileExists ? " --settings ../meteor-settings.json" : "",
5151
),
5252
cwd: "meteor",
5353
name: "METEOR",
@@ -59,7 +59,8 @@ function watchMeteor() {
5959
name: "VITE",
6060
prefixColor: "yellow",
6161
env: {
62-
SOFIE_BASE_PATH: rootUrl && rootUrl.pathname.length > 1 ? rootUrl.pathname : '',
62+
SOFIE_BASE_PATH:
63+
rootUrl && rootUrl.pathname.length > 1 ? rootUrl.pathname : "",
6364
},
6465
},
6566
];
@@ -73,11 +74,11 @@ function hr() {
7374
}
7475

7576
function listDatabases() {
76-
const meteorLocalDir = path.join('meteor', '.meteor', 'local');
77-
const dbLink = path.join(meteorLocalDir, 'db');
77+
const meteorLocalDir = path.join("meteor", ".meteor", "local");
78+
const dbLink = path.join(meteorLocalDir, "db");
7879

7980
if (!fs.existsSync(meteorLocalDir)) {
80-
console.log('No databases found (meteor/.meteor/local does not exist yet)');
81+
console.log("No databases found (meteor/.meteor/local does not exist yet)");
8182
return;
8283
}
8384

@@ -92,35 +93,39 @@ function listDatabases() {
9293
currentDb = match[1];
9394
}
9495
} else {
95-
currentDb = '(unnamed - real directory)';
96+
currentDb = "(unnamed - real directory)";
9697
}
9798
}
9899

99100
// List all db.* directories
100101
const files = fs.readdirSync(meteorLocalDir);
101102
const dbDirs = files
102-
.filter(file => file.startsWith('db.') && fs.lstatSync(path.join(meteorLocalDir, file)).isDirectory())
103-
.map(file => file.substring(3));
104-
105-
console.log('\nAvailable databases:');
103+
.filter(
104+
(file) =>
105+
file.startsWith("db.") &&
106+
fs.lstatSync(path.join(meteorLocalDir, file)).isDirectory(),
107+
)
108+
.map((file) => file.substring(3));
109+
110+
console.log("\nAvailable databases:");
106111
if (dbDirs.length === 0) {
107-
console.log(' (none found)');
112+
console.log(" (none found)");
108113
} else {
109-
dbDirs.sort().forEach(db => {
110-
const marker = db === currentDb ? ' ← current' : '';
114+
dbDirs.sort().forEach((db) => {
115+
const marker = db === currentDb ? " ← current" : "";
111116
console.log(` ${db}${marker}`);
112117
});
113118
}
114119

115120
if (currentDb && !dbDirs.includes(currentDb)) {
116121
console.log(`\nCurrent: ${currentDb}`);
117122
}
118-
console.log('');
123+
console.log("");
119124
}
120125

121126
function switchDatabase(dbName) {
122-
const meteorLocalDir = path.join('meteor', '.meteor', 'local');
123-
const dbLink = path.join(meteorLocalDir, 'db');
127+
const meteorLocalDir = path.join("meteor", ".meteor", "local");
128+
const dbLink = path.join(meteorLocalDir, "db");
124129
const dbTarget = path.join(meteorLocalDir, `db.${dbName}`);
125130

126131
// Check if we're already using this database
@@ -148,21 +153,29 @@ function switchDatabase(dbName) {
148153
fs.unlinkSync(dbLink);
149154
} else {
150155
// It's a real directory - back it up with timestamp
151-
const defaultDb = path.join(meteorLocalDir, 'db.default');
156+
const defaultDb = path.join(meteorLocalDir, "db.default");
152157
if (!fs.existsSync(defaultDb)) {
153158
console.log(`Backing up existing database to: default`);
154159
fs.renameSync(dbLink, defaultDb);
155160
} else {
156161
// Default already exists, create timestamped backup instead of deleting
157-
const timestamp = new Date().toISOString().replace(/[:.]/g, '-').substring(0, 19);
162+
const timestamp = new Date()
163+
.toISOString()
164+
.replace(/[:.]/g, "-")
165+
.substring(0, 19);
158166
let backupName = path.join(meteorLocalDir, `db.backup.${timestamp}`);
159167
// Ensure unique backup name
160168
let suffix = 0;
161169
while (fs.existsSync(backupName)) {
162170
suffix++;
163-
backupName = path.join(meteorLocalDir, `db.backup.${timestamp}.${suffix}`);
171+
backupName = path.join(
172+
meteorLocalDir,
173+
`db.backup.${timestamp}.${suffix}`,
174+
);
164175
}
165-
console.log(`Backing up existing database to: ${path.basename(backupName)}`);
176+
console.log(
177+
`Backing up existing database to: ${path.basename(backupName)}`,
178+
);
166179
fs.renameSync(dbLink, backupName);
167180
}
168181
}
@@ -193,15 +206,15 @@ try {
193206
console.log(hr());
194207
await concurrently(
195208
[
196-
...(config.uiOnly ? [] : watchPackages()),
197-
...(config.uiOnly ? [] : watchWorker()),
209+
...(config.watchMode ? watchPackages() : []),
210+
...(config.watchMode ? watchWorker() : []),
198211
...watchMeteor(),
199212
],
200213
{
201214
prefix: "name",
202215
killOthers: ["failure", "success"],
203216
restartTries: 0,
204-
}
217+
},
205218
).result;
206219
} catch (e) {
207220
console.error(e.message);

0 commit comments

Comments
 (0)