Skip to content
This repository was archived by the owner on Apr 13, 2025. It is now read-only.

Commit 6466945

Browse files
committed
Extract nodecg-io version constants to a extra file
1 parent 7ee8336 commit 6466945

File tree

3 files changed

+44
-36
lines changed

3 files changed

+44
-36
lines changed

src/fsUtils.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@ import * as findUp from "find-up";
44
import { spawn } from "child_process";
55
import { logger } from "./log";
66

7-
export const corePackage = "nodecg-io-core";
8-
export const dashboardPackage = "nodecg-io-dashboard";
9-
export const developmentVersion = "development";
10-
117
/**
128
* Traverses the filesystem and uses {@link isNodeCGDirectory} to find a local nodecg installation.
139
*/

src/install/nodecgIOVersions.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import * as semver from "semver";
2+
3+
export const corePackage = "nodecg-io-core";
4+
export const dashboardPackage = "nodecg-io-dashboard";
5+
export const developmentVersion = "development";
6+
7+
export const corePackages = [corePackage, dashboardPackage];
8+
9+
// To add a new release to this cli do the following (packages need to be already published on npm):
10+
// 1. add a new array under here which has all the services of the release in it (you can use the spread operator with the previous release).
11+
// 2. update supportedNodeCGIORange to include your new nodecg-io version.
12+
// 3. update getServicesForVersion to return the array for the new version.
13+
14+
// prettier-ignore
15+
const version01Services = [
16+
"ahk", "android", "curseforge", "discord", "intellij", "irc", "midi-input", "midi-output", "nanoleaf", "obs",
17+
"philipshue", "rcon", "reddit", "sacn-receiver", "sacn-sender", "serial", "slack", "spotify", "streamdeck",
18+
"streamelements", "telegram", "tiane", "twitch-addons", "twitch-api", "twitch-chat", "twitch-pubsub",
19+
"twitter", "websocket-client", "websocket-server", "xdotool", "youtube",
20+
];
21+
22+
export const supportedNodeCGIORange = new semver.Range("<=0.1");
23+
24+
/**
25+
* Returns you a list of services that are available for the passed nodecg-io version.
26+
* @param version the major.minor nodecg-io version
27+
* @returns all services of the passed version
28+
*/
29+
export function getServicesForVersion(version: string): string[] {
30+
switch (version) {
31+
case "0.1":
32+
return version01Services;
33+
default:
34+
throw new Error(`Don't have any service list for version ${version}. Something might be wrong here.`);
35+
}
36+
}

src/install/prompt.ts

Lines changed: 8 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,16 @@
11
import { Installation, ProductionInstallation } from "../installation";
22
import * as inquirer from "inquirer";
33
import { getHighestPatchVersion, getMinorVersions, NpmPackage } from "../npm";
4-
import { corePackage, dashboardPackage, developmentVersion } from "../fsUtils";
54
import * as semver from "semver";
65
import { logger } from "../log";
7-
8-
const corePackages = [corePackage, dashboardPackage];
9-
10-
// To add a new release to this cli do the following (packages need to be already published on npm):
11-
// 1. add a new array under here which has all the services of the release in it (you can use the spread operator with the previous release).
12-
// 2. update getServicesForVersion to return the array for the new version.
13-
// 3. update supportedNodeCGIORange to include your new nodecg-io version.
14-
15-
// prettier-ignore
16-
const version01Services = [
17-
"ahk", "android", "curseforge", "discord", "intellij", "irc", "midi-input", "midi-output", "nanoleaf", "obs",
18-
"philipshue", "rcon", "reddit", "sacn-receiver", "sacn-sender", "serial", "slack", "spotify", "streamdeck",
19-
"streamelements", "telegram", "tiane", "twitch-addons", "twitch-api", "twitch-chat", "twitch-pubsub",
20-
"twitter", "websocket-client", "websocket-server", "xdotool", "youtube",
21-
];
22-
23-
const supportedNodeCGIORange = new semver.Range("<=0.1");
6+
import {
7+
corePackage,
8+
corePackages,
9+
dashboardPackage,
10+
developmentVersion,
11+
getServicesForVersion,
12+
supportedNodeCGIORange,
13+
} from "./nodecgIOVersions";
2414

2515
interface PromptVersionInput {
2616
version: string;
@@ -115,20 +105,6 @@ async function buildPackageList(version: string, services: string[]): Promise<Np
115105
return await Promise.all(promises);
116106
}
117107

118-
/**
119-
* Returns you a list of services that are available for the passed nodecg-io version.
120-
* @param version the major.minor nodecg-io version
121-
* @returns all services of the passed version
122-
*/
123-
function getServicesForVersion(version: string): string[] {
124-
switch (version) {
125-
case "0.1":
126-
return version01Services;
127-
default:
128-
throw new Error(`Don't have any service list for version ${version}. Something might be wrong here.`);
129-
}
130-
}
131-
132108
/**
133109
* Returns the list of installed services of a production installation.
134110
* @param install the installation info for which you want the list of installed services.

0 commit comments

Comments
 (0)