@nu-art/commando 0.204.92 → 0.204.93
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/shell/interactive/CommandoInteractive.js +1 -1
- package/shell/interactive/InteractiveShell.js +4 -4
- package/{cli → shell/plugins}/basic.d.ts +3 -3
- package/{cli → shell/plugins}/basic.js +4 -4
- package/{cli → shell/plugins}/git.d.ts +5 -5
- package/{cli → shell/plugins}/git.js +6 -6
- package/shell/plugins/nvm.d.ts +12 -0
- package/shell/plugins/nvm.js +52 -0
- package/shell/plugins/pnpm.d.ts +11 -0
- package/shell/plugins/pnpm.js +30 -0
- package/{cli → shell/plugins}/programming.d.ts +3 -3
- package/{cli → shell/plugins}/programming.js +4 -4
- package/shell/plugins/python.d.ts +10 -0
- package/shell/plugins/python.js +30 -0
- package/shell/services/nvm.d.ts +18 -0
- package/{cli → shell/services}/nvm.js +8 -48
- package/{cli → shell/services}/pnpm.d.ts +3 -4
- package/{cli → shell/services}/pnpm.js +4 -19
- package/cli/nvm.d.ts +0 -23
package/package.json
CHANGED
|
@@ -104,7 +104,7 @@ class CommandoInteractive extends BaseCommando_1.BaseCommando {
|
|
|
104
104
|
.append(functionContent)
|
|
105
105
|
.append('pid=$!')
|
|
106
106
|
.append(`echo "${pidUniqueKey}=\${pid}"`)
|
|
107
|
-
.append(`wait \$pid`)
|
|
107
|
+
.append(`wait \$pid`)
|
|
108
108
|
.addLogProcessor(pidLogProcessor)
|
|
109
109
|
.execute(callback);
|
|
110
110
|
}
|
|
@@ -55,17 +55,17 @@ class InteractiveShell extends ts_common_1.Logger {
|
|
|
55
55
|
if (!this.alive)
|
|
56
56
|
return;
|
|
57
57
|
return new Promise((resolve, reject) => {
|
|
58
|
-
|
|
58
|
+
this.logWarning('Killing process');
|
|
59
59
|
this.shell.on('exit', async (code, signal) => {
|
|
60
|
-
|
|
60
|
+
this.logWarning(`Process Killed ${signal}`);
|
|
61
61
|
resolve();
|
|
62
62
|
});
|
|
63
63
|
if (pid) {
|
|
64
|
-
|
|
64
|
+
this.logWarning(`KILLING PID: ${pid}`);
|
|
65
65
|
process.kill(pid, 'SIGINT');
|
|
66
66
|
}
|
|
67
67
|
else {
|
|
68
|
-
|
|
68
|
+
this.logWarning(`KILLING SHELL WITH SIGINT`);
|
|
69
69
|
this.shell.kill('SIGINT');
|
|
70
70
|
}
|
|
71
71
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { BaseCommando } from '../
|
|
2
|
-
import { CliBlock } from '../
|
|
1
|
+
import { BaseCommando } from '../core/BaseCommando';
|
|
2
|
+
import { CliBlock } from '../types';
|
|
3
3
|
type Cli_EchoOptions = {
|
|
4
4
|
escape?: boolean;
|
|
5
5
|
toFile?: {
|
|
@@ -17,7 +17,7 @@ type Cli_CpdirOptions = {
|
|
|
17
17
|
/**
|
|
18
18
|
* Represents a Command Line Interface (CLI) to build and execute shell commands.
|
|
19
19
|
*/
|
|
20
|
-
export declare class
|
|
20
|
+
export declare class Commando_Basic extends BaseCommando {
|
|
21
21
|
/**
|
|
22
22
|
* Changes directory and optionally executes a block of commands in that directory.
|
|
23
23
|
* @param {string} folderName - Name of the directory to change to.
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
const BaseCommando_1 = require("../
|
|
3
|
+
exports.Commando_Basic = void 0;
|
|
4
|
+
const BaseCommando_1 = require("../core/BaseCommando");
|
|
5
5
|
/**
|
|
6
6
|
* Represents a Command Line Interface (CLI) to build and execute shell commands.
|
|
7
7
|
*/
|
|
8
|
-
class
|
|
8
|
+
class Commando_Basic extends BaseCommando_1.BaseCommando {
|
|
9
9
|
/**
|
|
10
10
|
* Changes directory and optionally executes a block of commands in that directory.
|
|
11
11
|
* @param {string} folderName - Name of the directory to change to.
|
|
@@ -94,4 +94,4 @@ class Cli_Basic extends BaseCommando_1.BaseCommando {
|
|
|
94
94
|
return this;
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
|
-
exports.
|
|
97
|
+
exports.Commando_Basic = Commando_Basic;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { BaseCommando } from '../
|
|
4
|
-
declare const Super: import("@nu-art/ts-common").Constructor<BaseCommando &
|
|
1
|
+
import { Commando_Programming } from './programming';
|
|
2
|
+
import { Commando_Basic } from './basic';
|
|
3
|
+
import { BaseCommando } from '../core/BaseCommando';
|
|
4
|
+
declare const Super: import("@nu-art/ts-common").Constructor<BaseCommando & Commando_Programming & Commando_Basic>;
|
|
5
5
|
type GitCloneParams = {
|
|
6
6
|
outputFolder?: string;
|
|
7
7
|
branch?: string;
|
|
@@ -13,7 +13,7 @@ type GitPushParams = {
|
|
|
13
13
|
tags?: boolean;
|
|
14
14
|
force?: boolean;
|
|
15
15
|
};
|
|
16
|
-
export declare class
|
|
16
|
+
export declare class Commando_Git extends Super {
|
|
17
17
|
git: {
|
|
18
18
|
clone: (url: string, options?: GitCloneParams) => this;
|
|
19
19
|
checkout: (branch: string) => this;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.Commando_Git = void 0;
|
|
4
4
|
const programming_1 = require("./programming");
|
|
5
5
|
const basic_1 = require("./basic");
|
|
6
|
-
const class_merger_1 = require("../
|
|
7
|
-
const BaseCommando_1 = require("../
|
|
8
|
-
const Super = (0, class_merger_1.MergeClass)(BaseCommando_1.BaseCommando, programming_1.
|
|
9
|
-
class
|
|
6
|
+
const class_merger_1 = require("../core/class-merger");
|
|
7
|
+
const BaseCommando_1 = require("../core/BaseCommando");
|
|
8
|
+
const Super = (0, class_merger_1.MergeClass)(BaseCommando_1.BaseCommando, programming_1.Commando_Programming, basic_1.Commando_Basic);
|
|
9
|
+
class Commando_Git extends Super {
|
|
10
10
|
constructor() {
|
|
11
11
|
super(...arguments);
|
|
12
12
|
this.git = {
|
|
@@ -122,4 +122,4 @@ class Cli_Git extends Super {
|
|
|
122
122
|
return this;
|
|
123
123
|
}
|
|
124
124
|
}
|
|
125
|
-
exports.
|
|
125
|
+
exports.Commando_Git = Commando_Git;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { BaseCommando } from '../core/BaseCommando';
|
|
2
|
+
import { Commando_Programming } from './programming';
|
|
3
|
+
import { Commando_Basic } from './basic';
|
|
4
|
+
declare const Super: import("@nu-art/ts-common").Constructor<BaseCommando & Commando_Programming & Commando_Basic>;
|
|
5
|
+
export declare class Commando_NVM extends Super {
|
|
6
|
+
applyNVM(): this;
|
|
7
|
+
install(version: string): Promise<this>;
|
|
8
|
+
getVersion(): Promise<string>;
|
|
9
|
+
installNodeVersion(requiredVersion: string): Promise<this>;
|
|
10
|
+
getInstalledNodeVersions: () => Promise<(string | undefined)[]>;
|
|
11
|
+
}
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Commando_NVM = void 0;
|
|
4
|
+
const BaseCommando_1 = require("../core/BaseCommando");
|
|
5
|
+
const programming_1 = require("./programming");
|
|
6
|
+
const class_merger_1 = require("../core/class-merger");
|
|
7
|
+
const basic_1 = require("./basic");
|
|
8
|
+
const ts_common_1 = require("@nu-art/ts-common");
|
|
9
|
+
const tools_1 = require("../tools");
|
|
10
|
+
const Super = (0, class_merger_1.MergeClass)(BaseCommando_1.BaseCommando, programming_1.Commando_Programming, basic_1.Commando_Basic);
|
|
11
|
+
class Commando_NVM extends Super {
|
|
12
|
+
constructor() {
|
|
13
|
+
super(...arguments);
|
|
14
|
+
this.getInstalledNodeVersions = async () => {
|
|
15
|
+
function extractInstalledVersions(rawOutput) {
|
|
16
|
+
const cleanedOutput = (0, tools_1.removeAnsiCodes)(rawOutput);
|
|
17
|
+
const lines = cleanedOutput.split('\n');
|
|
18
|
+
const filteredVersionLines = lines
|
|
19
|
+
.filter(line => !!line && line.match(/v\d+\.\d+\.\d+/) && !line.includes('N/A'));
|
|
20
|
+
return (0, ts_common_1.filterDuplicates)(filteredVersionLines
|
|
21
|
+
.map(line => { var _a; return (_a = line.match(/v(\d+\.\d+\.\d+)/)) === null || _a === void 0 ? void 0 : _a[1]; }));
|
|
22
|
+
}
|
|
23
|
+
const versionsAsString = this.append('nvm ls').execute((stdout) => stdout);
|
|
24
|
+
return extractInstalledVersions((await versionsAsString));
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
applyNVM() {
|
|
28
|
+
this.append('export NVM_DIR="$HOME/.nvm"')
|
|
29
|
+
.append('[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm')
|
|
30
|
+
.append('nvm use');
|
|
31
|
+
return this;
|
|
32
|
+
}
|
|
33
|
+
async install(version) {
|
|
34
|
+
this.append(`curl -o- "https://raw.githubusercontent.com/nvm-sh/nvm/v${version}/install.sh" | bash`);
|
|
35
|
+
await this.execute((stdout, stderr, exitCode) => {
|
|
36
|
+
if (exitCode !== 0)
|
|
37
|
+
throw new ts_common_1.Exception(`Error installing NVM - exit code (${exitCode})`);
|
|
38
|
+
});
|
|
39
|
+
return this;
|
|
40
|
+
}
|
|
41
|
+
async getVersion() {
|
|
42
|
+
return this.if('[[ -x "$(command -v nvm)" ]]', (commando) => {
|
|
43
|
+
commando.append('nvm --version');
|
|
44
|
+
}).execute((stdout) => stdout);
|
|
45
|
+
}
|
|
46
|
+
async installNodeVersion(requiredVersion) {
|
|
47
|
+
await this.append(`nvm install ${requiredVersion}`)
|
|
48
|
+
.execute();
|
|
49
|
+
return this;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
exports.Commando_NVM = Commando_NVM;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { BaseCommando } from '../core/BaseCommando';
|
|
2
|
+
import { Commando_Basic } from './basic';
|
|
3
|
+
import { Commando_Programming } from './programming';
|
|
4
|
+
import { Commando_NVM } from './nvm';
|
|
5
|
+
declare const Super: import("@nu-art/ts-common").Constructor<BaseCommando & Commando_Programming & Commando_Basic & Commando_NVM>;
|
|
6
|
+
export declare class Commando_PNPM extends Super {
|
|
7
|
+
installPackages(): Promise<this>;
|
|
8
|
+
install(version: string): Promise<this>;
|
|
9
|
+
getVersion(): Promise<string>;
|
|
10
|
+
}
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Commando_PNPM = void 0;
|
|
4
|
+
const BaseCommando_1 = require("../core/BaseCommando");
|
|
5
|
+
const class_merger_1 = require("../core/class-merger");
|
|
6
|
+
const basic_1 = require("./basic");
|
|
7
|
+
const programming_1 = require("./programming");
|
|
8
|
+
const nvm_1 = require("./nvm");
|
|
9
|
+
const Super = (0, class_merger_1.MergeClass)(BaseCommando_1.BaseCommando, programming_1.Commando_Programming, basic_1.Commando_Basic, nvm_1.Commando_NVM);
|
|
10
|
+
class Commando_PNPM extends Super {
|
|
11
|
+
async installPackages() {
|
|
12
|
+
await this
|
|
13
|
+
.append(`pnpm store prune`)
|
|
14
|
+
.append(`pnpm install -f --no-frozen-lockfile --prefer-offline false`)
|
|
15
|
+
.execute();
|
|
16
|
+
return this;
|
|
17
|
+
}
|
|
18
|
+
async install(version) {
|
|
19
|
+
await this
|
|
20
|
+
.append(`curl -fsSL "https://get.pnpm.io/install.sh" | env PNPM_VERSION=${version} bash -`)
|
|
21
|
+
.execute();
|
|
22
|
+
return this;
|
|
23
|
+
}
|
|
24
|
+
async getVersion() {
|
|
25
|
+
return this.if('[[ -x "$(command -v pnpm)" ]]', (commando) => {
|
|
26
|
+
commando.append('pnpm --version');
|
|
27
|
+
}).execute(stdout => stdout.trim());
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
exports.Commando_PNPM = Commando_PNPM;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { BaseCommando } from '../
|
|
2
|
-
import { CliBlock } from '../
|
|
3
|
-
export declare class
|
|
1
|
+
import { BaseCommando } from '../core/BaseCommando';
|
|
2
|
+
import { CliBlock } from '../types';
|
|
3
|
+
export declare class Commando_Programming extends BaseCommando {
|
|
4
4
|
/**
|
|
5
5
|
* Constructs an if-else conditional command structure.
|
|
6
6
|
* @param {string} condition - The condition for the if statement.
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
const BaseCommando_1 = require("../
|
|
5
|
-
class
|
|
3
|
+
exports.Commando_Programming = void 0;
|
|
4
|
+
const BaseCommando_1 = require("../core/BaseCommando");
|
|
5
|
+
class Commando_Programming extends BaseCommando_1.BaseCommando {
|
|
6
6
|
/**
|
|
7
7
|
* Constructs an if-else conditional command structure.
|
|
8
8
|
* @param {string} condition - The condition for the if statement.
|
|
@@ -72,4 +72,4 @@ class Cli_Programming extends BaseCommando_1.BaseCommando {
|
|
|
72
72
|
return this;
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
|
-
exports.
|
|
75
|
+
exports.Commando_Programming = Commando_Programming;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { BaseCommando } from '../core/BaseCommando';
|
|
2
|
+
import { Commando_Programming } from './programming';
|
|
3
|
+
import { Commando_Basic } from './basic';
|
|
4
|
+
declare const Super: import("@nu-art/ts-common").Constructor<BaseCommando & Commando_Programming & Commando_Basic>;
|
|
5
|
+
export declare class Commando_Python3 extends Super {
|
|
6
|
+
sourceVenv(venvFolder?: string): this;
|
|
7
|
+
installVenv(venvFolder?: string): Promise<this>;
|
|
8
|
+
installRequirements(pathToRequirementsFile?: string): Promise<this>;
|
|
9
|
+
}
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Commando_Python3 = void 0;
|
|
4
|
+
const BaseCommando_1 = require("../core/BaseCommando");
|
|
5
|
+
const programming_1 = require("./programming");
|
|
6
|
+
const class_merger_1 = require("../core/class-merger");
|
|
7
|
+
const basic_1 = require("./basic");
|
|
8
|
+
const ts_common_1 = require("@nu-art/ts-common");
|
|
9
|
+
const Super = (0, class_merger_1.MergeClass)(BaseCommando_1.BaseCommando, programming_1.Commando_Programming, basic_1.Commando_Basic);
|
|
10
|
+
const DefaultVenvFolder = '.venv';
|
|
11
|
+
class Commando_Python3 extends Super {
|
|
12
|
+
sourceVenv(venvFolder = DefaultVenvFolder) {
|
|
13
|
+
this.append(`source ${venvFolder}/bin/activate`);
|
|
14
|
+
return this;
|
|
15
|
+
}
|
|
16
|
+
async installVenv(venvFolder = DefaultVenvFolder) {
|
|
17
|
+
this.append(`python3 -m venv ${venvFolder}`);
|
|
18
|
+
await this.execute((stdout, stderr, exitCode) => {
|
|
19
|
+
if (exitCode !== 0)
|
|
20
|
+
throw new ts_common_1.Exception(`Error installing VENV - exit code (${exitCode})`);
|
|
21
|
+
});
|
|
22
|
+
return this;
|
|
23
|
+
}
|
|
24
|
+
async installRequirements(pathToRequirementsFile = './requirements.txt') {
|
|
25
|
+
await this.append(`pip3 install -r ${pathToRequirementsFile}`)
|
|
26
|
+
.execute();
|
|
27
|
+
return this;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
exports.Commando_Python3 = Commando_Python3;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Logger } from '@nu-art/ts-common';
|
|
2
|
+
import { Commando_NVM } from '../plugins/nvm';
|
|
3
|
+
export declare class Cli_NVM extends Logger {
|
|
4
|
+
private _expectedVersion;
|
|
5
|
+
private _homeEnvVar;
|
|
6
|
+
constructor();
|
|
7
|
+
get homeEnvVar(): string;
|
|
8
|
+
set homeEnvVar(value: string);
|
|
9
|
+
get expectedVersion(): string;
|
|
10
|
+
set expectedVersion(value: string);
|
|
11
|
+
install: (commando: Commando_NVM) => Promise<boolean | this | undefined>;
|
|
12
|
+
isInstalled: () => boolean;
|
|
13
|
+
getRequiredNode_Version: () => Promise<string>;
|
|
14
|
+
installRequiredVersionIfNeeded: (commando: Commando_NVM) => Promise<boolean>;
|
|
15
|
+
uninstall: () => Promise<void>;
|
|
16
|
+
private installVersion;
|
|
17
|
+
}
|
|
18
|
+
export declare const NVM: Cli_NVM;
|
|
@@ -24,31 +24,24 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.NVM = exports.Cli_NVM = void 0;
|
|
27
|
-
const programming_1 = require("./programming");
|
|
28
|
-
const basic_1 = require("./basic");
|
|
29
27
|
const fs = __importStar(require("fs"));
|
|
30
28
|
const fs_1 = require("fs");
|
|
31
29
|
const path = __importStar(require("path"));
|
|
32
30
|
const ts_common_1 = require("@nu-art/ts-common");
|
|
33
|
-
const Commando_1 = require("../shell/simple/Commando");
|
|
34
|
-
const tools_1 = require("../shell/tools");
|
|
35
|
-
const CommandoInteractive_1 = require("../shell/interactive/CommandoInteractive");
|
|
36
31
|
const CONST__FILE_NVMRC = '.nvmrc';
|
|
37
32
|
class Cli_NVM extends ts_common_1.Logger {
|
|
38
33
|
constructor() {
|
|
39
34
|
super();
|
|
40
35
|
this._expectedVersion = '0.39.7';
|
|
41
36
|
this._homeEnvVar = '$NVM_DIR';
|
|
42
|
-
this.install = async () => {
|
|
37
|
+
this.install = async (commando) => {
|
|
43
38
|
if (this.isInstalled()) {
|
|
44
|
-
const version = (await
|
|
39
|
+
const version = (await commando.getVersion()).trim();
|
|
45
40
|
if (this._expectedVersion === version)
|
|
46
41
|
return;
|
|
47
42
|
await this.uninstall();
|
|
48
43
|
}
|
|
49
|
-
await
|
|
50
|
-
.append(` curl -o- "https://raw.githubusercontent.com/nvm-sh/nvm/v${this._expectedVersion}/install.sh" | bash`)
|
|
51
|
-
.execute();
|
|
44
|
+
await commando.install(this._expectedVersion);
|
|
52
45
|
const rcFile = path.resolve(process.env['HOME'], '.bashrc');
|
|
53
46
|
let rcFileContent = '';
|
|
54
47
|
if (fs.existsSync(rcFile)) {
|
|
@@ -72,28 +65,15 @@ class Cli_NVM extends ts_common_1.Logger {
|
|
|
72
65
|
const content = await fs_1.promises.readFile(absolutePathToNvmrcFile, { encoding: 'utf-8' });
|
|
73
66
|
return content.trim();
|
|
74
67
|
};
|
|
75
|
-
this.installRequiredVersionIfNeeded = async () => {
|
|
68
|
+
this.installRequiredVersionIfNeeded = async (commando) => {
|
|
76
69
|
const requiredVersion = await this.getRequiredNode_Version();
|
|
77
|
-
const installedVersions = await
|
|
70
|
+
const installedVersions = await commando.getInstalledNodeVersions();
|
|
78
71
|
this.logDebug('Found versions:', installedVersions);
|
|
79
72
|
if (installedVersions.includes(requiredVersion))
|
|
80
73
|
return false;
|
|
81
|
-
await this.installVersion(requiredVersion);
|
|
74
|
+
await this.installVersion(commando, requiredVersion);
|
|
82
75
|
return true;
|
|
83
76
|
};
|
|
84
|
-
this.getInstalledNode_Versions = async () => {
|
|
85
|
-
function extractInstalledVersions(rawOutput) {
|
|
86
|
-
const cleanedOutput = (0, tools_1.removeAnsiCodes)(rawOutput);
|
|
87
|
-
const lines = cleanedOutput.split('\n');
|
|
88
|
-
const filteredVersionLines = lines
|
|
89
|
-
.filter(line => !!line && line.match(/v\d+\.\d+\.\d+/) && !line.includes('N/A'));
|
|
90
|
-
return (0, ts_common_1.filterDuplicates)(filteredVersionLines
|
|
91
|
-
.map(line => { var _a; return (_a = line.match(/v(\d+\.\d+\.\d+)/)) === null || _a === void 0 ? void 0 : _a[1]; }));
|
|
92
|
-
}
|
|
93
|
-
return extractInstalledVersions((await this.createCommando()
|
|
94
|
-
.append('nvm ls')
|
|
95
|
-
.execute((stdout) => stdout)));
|
|
96
|
-
};
|
|
97
77
|
this.uninstall = async () => {
|
|
98
78
|
this.logDebug('Uninstalling PNPM');
|
|
99
79
|
const absolutePathToNVM_Home = process.env[this._homeEnvVar];
|
|
@@ -101,10 +81,10 @@ class Cli_NVM extends ts_common_1.Logger {
|
|
|
101
81
|
return;
|
|
102
82
|
fs.rmSync(absolutePathToNVM_Home, { recursive: true, force: true });
|
|
103
83
|
};
|
|
104
|
-
this.installVersion = async (requiredVersion) => {
|
|
84
|
+
this.installVersion = async (commando, requiredVersion) => {
|
|
105
85
|
requiredVersion !== null && requiredVersion !== void 0 ? requiredVersion : (requiredVersion = await this.getRequiredNode_Version());
|
|
106
86
|
this.logDebug(`Installing version: ${requiredVersion}`);
|
|
107
|
-
return
|
|
87
|
+
return commando.installNodeVersion(requiredVersion);
|
|
108
88
|
};
|
|
109
89
|
this.setMinLevel(ts_common_1.LogLevel.Verbose);
|
|
110
90
|
}
|
|
@@ -120,26 +100,6 @@ class Cli_NVM extends ts_common_1.Logger {
|
|
|
120
100
|
set expectedVersion(value) {
|
|
121
101
|
this._expectedVersion = value;
|
|
122
102
|
}
|
|
123
|
-
async getVersion() {
|
|
124
|
-
const commando = Commando_1.Commando.create(programming_1.Cli_Programming, basic_1.Cli_Basic);
|
|
125
|
-
return commando.if('[[ -x "$(command -v nvm)" ]]', (commando) => {
|
|
126
|
-
commando.append('nvm --version');
|
|
127
|
-
}).execute((stdout) => stdout);
|
|
128
|
-
}
|
|
129
|
-
createInteractiveCommando(...plugins) {
|
|
130
|
-
return CommandoInteractive_1.CommandoInteractive.create(...plugins)
|
|
131
|
-
.append('export NVM_DIR="$HOME/.nvm"')
|
|
132
|
-
.append('[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm')
|
|
133
|
-
.append('nvm use');
|
|
134
|
-
}
|
|
135
|
-
createCommando(...plugins) {
|
|
136
|
-
const commando = Commando_1.Commando.create(...plugins);
|
|
137
|
-
commando
|
|
138
|
-
.append('export NVM_DIR="$HOME/.nvm"')
|
|
139
|
-
.append('[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm')
|
|
140
|
-
.append('nvm use');
|
|
141
|
-
return commando;
|
|
142
|
-
}
|
|
143
103
|
}
|
|
144
104
|
exports.Cli_NVM = Cli_NVM;
|
|
145
105
|
exports.NVM = new Cli_NVM();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Logger } from '@nu-art/ts-common';
|
|
2
|
-
import {
|
|
2
|
+
import { Commando_PNPM } from '../plugins/pnpm';
|
|
3
3
|
export declare class Cli_PNPM extends Logger {
|
|
4
4
|
private _expectedVersion;
|
|
5
5
|
private _homeEnvVar;
|
|
@@ -8,10 +8,9 @@ export declare class Cli_PNPM extends Logger {
|
|
|
8
8
|
set homeEnvVar(value: string);
|
|
9
9
|
get expectedVersion(): string;
|
|
10
10
|
set expectedVersion(value: string);
|
|
11
|
-
install: (commando
|
|
11
|
+
install: (commando: Commando_PNPM) => Promise<this | undefined>;
|
|
12
12
|
isInstalled: () => boolean;
|
|
13
|
-
installPackages: (commando
|
|
14
|
-
private getVersion;
|
|
13
|
+
installPackages: (commando: Commando_PNPM) => Promise<Commando_PNPM>;
|
|
15
14
|
uninstall: () => Promise<void>;
|
|
16
15
|
/**
|
|
17
16
|
* Asynchronously creates a workspace file with a list of packages.
|
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PNPM = exports.Cli_PNPM = void 0;
|
|
4
|
-
const programming_1 = require("./programming");
|
|
5
|
-
const basic_1 = require("./basic");
|
|
6
4
|
const fs_1 = require("fs");
|
|
7
5
|
const ts_common_1 = require("@nu-art/ts-common");
|
|
8
|
-
const
|
|
9
|
-
const tools_1 = require("../shell/tools");
|
|
6
|
+
const tools_1 = require("../tools");
|
|
10
7
|
class Cli_PNPM extends ts_common_1.Logger {
|
|
11
8
|
constructor() {
|
|
12
9
|
super();
|
|
@@ -14,24 +11,18 @@ class Cli_PNPM extends ts_common_1.Logger {
|
|
|
14
11
|
this._homeEnvVar = 'PNPM_HOME';
|
|
15
12
|
this.install = async (commando) => {
|
|
16
13
|
if (this.isInstalled()) {
|
|
17
|
-
const version = (await
|
|
14
|
+
const version = (await commando.getVersion());
|
|
18
15
|
if (this._expectedVersion === version)
|
|
19
16
|
return;
|
|
20
17
|
await this.uninstall();
|
|
21
18
|
}
|
|
22
19
|
this.logDebug(`installing PNPM version ${this._expectedVersion}`);
|
|
23
|
-
await
|
|
24
|
-
.append(`curl -fsSL "https://get.pnpm.io/install.sh" | env PNPM_VERSION=${this._expectedVersion} bash -`)
|
|
25
|
-
.execute();
|
|
20
|
+
await commando.install(this._expectedVersion);
|
|
26
21
|
return this;
|
|
27
22
|
};
|
|
28
23
|
this.isInstalled = () => !!process.env[this._homeEnvVar];
|
|
29
24
|
this.installPackages = async (commando) => {
|
|
30
|
-
await
|
|
31
|
-
.append(`pnpm store prune`)
|
|
32
|
-
.append(`pnpm install -f --no-frozen-lockfile --prefer-offline false`)
|
|
33
|
-
.execute();
|
|
34
|
-
return this;
|
|
25
|
+
return await commando.installPackages();
|
|
35
26
|
};
|
|
36
27
|
this.uninstall = async () => {
|
|
37
28
|
this.logDebug('Uninstalling PNPM');
|
|
@@ -76,12 +67,6 @@ class Cli_PNPM extends ts_common_1.Logger {
|
|
|
76
67
|
set expectedVersion(value) {
|
|
77
68
|
this._expectedVersion = value;
|
|
78
69
|
}
|
|
79
|
-
async getVersion() {
|
|
80
|
-
const commando = Commando_1.Commando.create(programming_1.Cli_Programming, basic_1.Cli_Basic);
|
|
81
|
-
return commando.if('[[ -x "$(command -v pnpm)" ]]', (commando) => {
|
|
82
|
-
commando.append('pnpm --version');
|
|
83
|
-
}).execute(stdout => stdout);
|
|
84
|
-
}
|
|
85
70
|
}
|
|
86
71
|
exports.Cli_PNPM = Cli_PNPM;
|
|
87
72
|
exports.PNPM = new Cli_PNPM();
|
package/cli/nvm.d.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { Constructor, Logger } from '@nu-art/ts-common';
|
|
2
|
-
import { Commando } from '../shell/simple/Commando';
|
|
3
|
-
import { CommandoInteractive } from '../shell/interactive/CommandoInteractive';
|
|
4
|
-
export declare class Cli_NVM extends Logger {
|
|
5
|
-
private _expectedVersion;
|
|
6
|
-
private _homeEnvVar;
|
|
7
|
-
constructor();
|
|
8
|
-
get homeEnvVar(): string;
|
|
9
|
-
set homeEnvVar(value: string);
|
|
10
|
-
get expectedVersion(): string;
|
|
11
|
-
set expectedVersion(value: string);
|
|
12
|
-
install: () => Promise<boolean | this | undefined>;
|
|
13
|
-
isInstalled: () => boolean;
|
|
14
|
-
getRequiredNode_Version: () => Promise<string>;
|
|
15
|
-
installRequiredVersionIfNeeded: () => Promise<boolean>;
|
|
16
|
-
getInstalledNode_Versions: () => Promise<(string | undefined)[]>;
|
|
17
|
-
private getVersion;
|
|
18
|
-
uninstall: () => Promise<void>;
|
|
19
|
-
private installVersion;
|
|
20
|
-
createInteractiveCommando<T extends Constructor<any>[]>(...plugins: T): import("../shell/core/class-merger").MergeTypes<[typeof import("../shell/core/BaseCommando").BaseCommando, typeof CommandoInteractive, ...T]> & import("../shell/core/BaseCommando").BaseCommando & CommandoInteractive;
|
|
21
|
-
createCommando<T extends Constructor<any>[]>(...plugins: T): import("../shell/core/class-merger").MergeTypes<[typeof import("../shell/core/BaseCommando").BaseCommando, typeof Commando, ...T]> & import("../shell/core/BaseCommando").BaseCommando & Commando;
|
|
22
|
-
}
|
|
23
|
-
export declare const NVM: Cli_NVM;
|