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

Commit 7ee8336

Browse files
committed
Update todos and document a couple functions
1 parent 9c1b42a commit 7ee8336

File tree

6 files changed

+32
-5
lines changed

6 files changed

+32
-5
lines changed

README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ Here's a brief overview of the available commands. More indepth usage guides of
2626

2727
Installs nodecg-io to your current nodecg installation into a sub-directory called `nodecg-io`. Allows you to select which released version you want or if you wish to get a development install.
2828

29-
<!-- TODO: mention that it saves the state and allows for editing by rerunning. Mention updating -->
30-
3129
A production install fetches tarballs of the needed packages from the official npm registry, unpacks them, creates a `package.json` with all packages in a npm v7 workspace configuration and installs dependencies that way.
3230

3331
A development install clones the official git repository (`master`), installs dependencies, bootstraps all packages using lerna and builds all packages.

src/install/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import * as os from "os";
1010
import { logger } from "../log";
1111
import { requireNpmV7 } from "../npm";
1212

13-
// TODO: remove nodecg-io directory if installation was aborted?
13+
// TODO: remove nodecg-io directory if initial installation was aborted?
1414

1515
export const installModule: CommandModule<unknown, { concurrency: number }> = {
1616
command: "install",

src/install/production.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,13 @@ export function diffPackages(
6060
}
6161

6262
// TODO: handle when e.g. core upgrades and removes nodecg-io-core directory. Need to re-download dashboard because it got deleted (or don't delete it).
63+
64+
/**
65+
* Removes a list of packages from a production nodecg-io install.
66+
* @param pkgs the packages that should be removed
67+
* @param state the current installation info that will be updated with the removals
68+
* @param nodecgIODir the nodecg-io directory in which the packages will be removed
69+
*/
6370
async function removePackages(pkgs: NpmPackage[], state: ProductionInstallation, nodecgIODir: string): Promise<void> {
6471
for (const pkg of pkgs) {
6572
logger.debug(`Removing package ${pkg.name} (${pkg.version})...`);
@@ -70,6 +77,12 @@ async function removePackages(pkgs: NpmPackage[], state: ProductionInstallation,
7077
logger.info(`Removed ${pkgs.length} packages.`);
7178
}
7279

80+
/**
81+
* Installs a list of packages to a nodecg-io install by fetching, extracting and installing the dependencies.
82+
* @param pkgs the packages that should be installed
83+
* @param state the current install state that will be updated with the newly added packages
84+
* @param nodecgIODir the directory in which nodecg-io is installed an and the new packages should be installed into
85+
*/
7386
async function installPackages(pkgs: NpmPackage[], state: ProductionInstallation, nodecgIODir: string): Promise<void> {
7487
const count = pkgs.length;
7588
logger.info(`Downloading ${count} packages...`);
@@ -97,6 +110,11 @@ async function installPackages(pkgs: NpmPackage[], state: ProductionInstallation
97110
await saveProgress(state, nodecgIODir, pkgs, true);
98111
}
99112

113+
/**
114+
* Fetches and extracts a single package from the official npm registry.
115+
* @param pkg the package to download
116+
* @param nodecgIODir the root directory in which the package with the package path will be fetched into
117+
*/
100118
async function fetchSinglePackage(pkg: NpmPackage, nodecgIODir: string): Promise<void> {
101119
const tarStream = await createNpmPackageReadStream(pkg);
102120
await extractNpmPackageTar(pkg, tarStream, nodecgIODir);
@@ -114,6 +132,11 @@ async function installNpmDependencies(pkgs: NpmPackage[], nodecgIODir: string):
114132
await runNpmInstall(nodecgIODir);
115133
}
116134

135+
/**
136+
* Creates a root package.json file with all packages added as a npm v7 workspace.
137+
* @param pkgs the packages that are installed and should be included in the npm workspace.
138+
* @param nodecgIODir the directory in which nodecg-io is installed
139+
*/
117140
async function writeWorkspacePackageJson(pkgs: NpmPackage[], nodecgIODir: string): Promise<void> {
118141
logger.debug("Creating package.json file for nodecg-io workspace.");
119142

src/install/prompt.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,12 @@ function getServicesForVersion(version: string): string[] {
129129
}
130130
}
131131

132+
/**
133+
* Returns the list of installed services of a production installation.
134+
* @param install the installation info for which you want the list of installed services.
135+
* @param targetVersion the version of nodecg-io that is installed
136+
* @returns the list of installed services (simpleName of the packages without the nodecg-io- prefix)
137+
*/
132138
function getServicesFromInstall(install: ProductionInstallation, targetVersion: string): string[] {
133139
const availableServices = getServicesForVersion(targetVersion);
134140

src/installation.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export type Installation = DevelopmentInstallation | ProductionInstallation;
99

1010
/**
1111
* A develop version of nodecg-io that is cloned directly form the git repository.
12+
* This is the current WIP everything may break version.
1213
*/
1314
export interface DevelopmentInstallation {
1415
dev: true;
@@ -19,6 +20,7 @@ export interface DevelopmentInstallation {
1920

2021
/**
2122
* A production install using released tarballs of the packages from npm.
23+
* This is a version from a release.
2224
*/
2325
export interface ProductionInstallation {
2426
dev: false;

src/npm.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,6 @@ export async function extractNpmPackageTar(
128128
* @param path the path where a package.json is present
129129
*/
130130
export async function runNpmInstall(path: string): Promise<void> {
131-
// TODO: npm seems to completely ignore --prod flag when installing inside a workspace.
132-
// Is this intentional or is this a bug? Increases install sizes for us because nodecg is huge and a devDependency.
133131
await executeCommand("npm", ["install", "--prod"], path);
134132
}
135133

0 commit comments

Comments
 (0)