Skip to content

Commit

Permalink
Revert "* expose installNodeModule and uninstallNodeModule too, address
Browse files Browse the repository at this point in the history
#408"

This reverts commit 1003d89.
  • Loading branch information
Apollon77 committed Mar 24, 2023
1 parent 9d9af4d commit 34c5b5d
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 127 deletions.
3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,6 @@ Currently, the following **methods** are available:
- `commonTools.pattern2RegEx` - Converts a pattern to match object IDs into a RegEx string that can be used in `new RegExp(...)`
- `commonTools.getAdapterDir` - Finds the adapter directory of a given adapter
- `commonTools.getInstalledInfo` - Get list of all installed adapters and controller version on this host
- `commonTools.isDocker` - Checks if we are running inside a docker container
- `commonTools.installNodeModule` - Installs a node module using npm or a similar package manager
- `commonTools.uninstallNodeModule` - Uninstalls a node module using npm or a similar package manager

And the following **modules** are exposed:

Expand Down
35 changes: 0 additions & 35 deletions build/controllerTools.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,46 +57,11 @@ declare function getInstalledInfo(hostJsControllerVersion?: string): GetInstalle
* Checks if we are running inside a docker container
*/
declare function isDocker(): boolean;
export interface InstallNodeModuleOptions {
unsafePerm?: boolean;
debug?: boolean;
cwd?: string;
}
export interface CommandResult {
/** Whether the command execution was successful */
success: boolean;
/** The exit code of the command execution */
exitCode: number;
/** The captured stdout */
stdout: string;
/** The captured stderr */
stderr: string;
/** The captured stdout and stderr, interleaved like it would appear on the console */
stdall: string;
}
/**
* Installs a node module using npm or a similar package manager
* @param npmUrl Which node module to install
* @param options Options for the installation
*/
export declare function installNodeModule(npmUrl: string, options?: InstallNodeModuleOptions): Promise<CommandResult>;
export interface UninstallNodeModuleOptions {
debug?: boolean;
cwd?: string;
}
/**
* Uninstalls a node module using npm or a similar package manager
* @param packageName Which node module to uninstall
* @param options Options for the installation
*/
export declare function uninstallNodeModule(packageName: string, options?: UninstallNodeModuleOptions): Promise<CommandResult>;
export declare const commonTools: {
pattern2RegEx: typeof pattern2RegEx;
getAdapterDir: typeof getAdapterDir;
getInstalledInfo: typeof getInstalledInfo;
isDocker: typeof isDocker;
installNodeModule: typeof installNodeModule;
uninstallNodeModule: typeof uninstallNodeModule;
password: any;
letsEncrypt: any;
session: any;
Expand Down
35 changes: 1 addition & 34 deletions build/controllerTools.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.commonTools = exports.uninstallNodeModule = exports.installNodeModule = exports.resolveNamedModule = exports.controllerToolsInternal = exports.controllerCommonModulesInternal = void 0;
exports.commonTools = exports.resolveNamedModule = exports.controllerToolsInternal = exports.controllerCommonModulesInternal = void 0;
const path = require("path");
const helpers_1 = require("./helpers");
const utils = require("./utils");
Expand Down Expand Up @@ -125,35 +116,11 @@ function getInstalledInfo(hostJsControllerVersion) {
function isDocker() {
return exports.controllerToolsInternal.isDocker();
}
/**
* Installs a node module using npm or a similar package manager
* @param npmUrl Which node module to install
* @param options Options for the installation
*/
function installNodeModule(npmUrl, options = {}) {
return __awaiter(this, void 0, void 0, function* () {
return exports.controllerToolsInternal.installNodeModule(npmUrl, options);
});
}
exports.installNodeModule = installNodeModule;
/**
* Uninstalls a node module using npm or a similar package manager
* @param packageName Which node module to uninstall
* @param options Options for the installation
*/
function uninstallNodeModule(packageName, options = {}) {
return __awaiter(this, void 0, void 0, function* () {
return exports.controllerToolsInternal.uninstallNodeModule(packageName, options);
});
}
exports.uninstallNodeModule = uninstallNodeModule;
exports.commonTools = {
pattern2RegEx,
getAdapterDir,
getInstalledInfo,
isDocker,
installNodeModule,
uninstallNodeModule,
// TODO: Add more methods from lib/tools.js as needed
password: resolveNamedModule("password"),
letsEncrypt: resolveNamedModule("letsencrypt"),
Expand Down
55 changes: 0 additions & 55 deletions src/controllerTools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,66 +160,11 @@ function isDocker(): boolean {
return controllerToolsInternal.isDocker();
}

export interface InstallNodeModuleOptions {
// Whether the `--unsafe-perm` flag should be used
unsafePerm?: boolean;
// Whether to include `stderr` in the output and increase the loglevel to include more than errors
debug?: boolean;
// Which directory to work in. If none is given, this defaults to ioBroker's root directory.
cwd?: string;
}

export interface CommandResult {
/** Whether the command execution was successful */
success: boolean;
/** The exit code of the command execution */
exitCode: number;
/** The captured stdout */
stdout: string;
/** The captured stderr */
stderr: string;
/** The captured stdout and stderr, interleaved like it would appear on the console */
stdall: string;
}

/**
* Installs a node module using npm or a similar package manager
* @param npmUrl Which node module to install
* @param options Options for the installation
*/
export async function installNodeModule(
npmUrl: string,
options: InstallNodeModuleOptions = {},
): Promise<CommandResult> {
return controllerToolsInternal.installNodeModule(npmUrl, options);
}

export interface UninstallNodeModuleOptions {
// Whether to include `stderr` in the output and increase the loglevel to include more than errors
debug?: boolean;
// Which directory to work in. If none is given, this defaults to ioBroker's root directory.
cwd?: string;
}

/**
* Uninstalls a node module using npm or a similar package manager
* @param packageName Which node module to uninstall
* @param options Options for the installation
*/
export async function uninstallNodeModule(
packageName: string,
options: UninstallNodeModuleOptions = {},
): Promise<CommandResult> {
return controllerToolsInternal.uninstallNodeModule(packageName, options);
}

export const commonTools = {
pattern2RegEx,
getAdapterDir,
getInstalledInfo,
isDocker,
installNodeModule,
uninstallNodeModule,
// TODO: Add more methods from lib/tools.js as needed

password: resolveNamedModule("password"),
Expand Down

0 comments on commit 34c5b5d

Please sign in to comment.