trm-client 7.0.2 → 7.1.0
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/changelog.txt +8 -0
- package/dist/command/AbstractCommand.d.ts +2 -1
- package/dist/command/AbstractCommand.js +28 -25
- package/dist/command/implementations/Alias.js +5 -5
- package/dist/command/implementations/DistTag.js +4 -7
- package/dist/command/implementations/Registry.js +4 -7
- package/dist/index.js +6 -6
- package/package.json +1 -1
package/changelog.txt
CHANGED
|
@@ -8,6 +8,14 @@ Legend
|
|
|
8
8
|
+ : added
|
|
9
9
|
- : removed
|
|
10
10
|
|
|
11
|
+
2025-11-10 v7.1.0
|
|
12
|
+
-------------------
|
|
13
|
+
* commands with subcommands
|
|
14
|
+
|
|
15
|
+
2025-11-10 v7.0.3
|
|
16
|
+
-------------------
|
|
17
|
+
* commands with 2+ arguments
|
|
18
|
+
|
|
11
19
|
2025-11-07 v7.0.2
|
|
12
20
|
-------------------
|
|
13
21
|
* deprecate typo
|
|
@@ -6,6 +6,7 @@ import { Package } from "trm-registry-types";
|
|
|
6
6
|
export declare abstract class AbstractCommand {
|
|
7
7
|
protected readonly name: string;
|
|
8
8
|
protected readonly aliases?: string[];
|
|
9
|
+
protected readonly subcommand?: string;
|
|
9
10
|
protected command: Command;
|
|
10
11
|
protected registerOpts: RegisterCommandOpts;
|
|
11
12
|
protected args: any;
|
|
@@ -15,7 +16,7 @@ export declare abstract class AbstractCommand {
|
|
|
15
16
|
private registryAuthFailed;
|
|
16
17
|
private systemPackages;
|
|
17
18
|
private trmDependenciesCheck;
|
|
18
|
-
constructor(program: Command, name: string, aliases?: string[]);
|
|
19
|
+
constructor(program: Command, name: string, aliases?: string[], subcommand?: string);
|
|
19
20
|
getCliVersionStatus(): Promise<CliVersionStatus>;
|
|
20
21
|
getRegistry(): Core.AbstractRegistry;
|
|
21
22
|
hasRegistryAuthData(): boolean;
|
|
@@ -57,13 +57,28 @@ const chalk_1 = __importDefault(require("chalk"));
|
|
|
57
57
|
const prompts_1 = require("./prompts");
|
|
58
58
|
const fs_1 = require("fs");
|
|
59
59
|
class AbstractCommand {
|
|
60
|
-
constructor(program, name, aliases) {
|
|
60
|
+
constructor(program, name, aliases, subcommand) {
|
|
61
61
|
this.name = name;
|
|
62
62
|
this.aliases = aliases;
|
|
63
|
+
this.subcommand = subcommand;
|
|
63
64
|
this.registerOpts = {};
|
|
64
65
|
this.args = {};
|
|
65
66
|
this.registryAuthData = false;
|
|
66
|
-
|
|
67
|
+
const index = program.commands.findIndex(c => c.name() === this.name);
|
|
68
|
+
if (index >= 0) {
|
|
69
|
+
if (subcommand) {
|
|
70
|
+
this.command = program.commands[index];
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
throw new Error(`Command "${this.name}" declared multiple times without subcommand.`);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
this.command = program.command(this.name);
|
|
78
|
+
}
|
|
79
|
+
if (this.subcommand) {
|
|
80
|
+
this.command = this.command.command(this.subcommand);
|
|
81
|
+
}
|
|
67
82
|
if (aliases) {
|
|
68
83
|
this.command.aliases(aliases);
|
|
69
84
|
}
|
|
@@ -209,28 +224,16 @@ class AbstractCommand {
|
|
|
209
224
|
default: throw new Error(`Unknown inquirer type "${type}". Possible values are ${Object.keys(InquirerType_1.InquirerType).map(k => InquirerType_1.InquirerType[k]).join(', ')}.`);
|
|
210
225
|
}
|
|
211
226
|
}
|
|
212
|
-
parseCommandArgs(
|
|
213
|
-
var args =
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
}
|
|
220
|
-
if (typeof (args1) === 'string') {
|
|
221
|
-
const oArg1 = this.command["_args"][0];
|
|
222
|
-
args[oArg1.name()] = args1;
|
|
223
|
-
if (typeof (args2) === 'string') {
|
|
224
|
-
const oArg2 = this.command["_args"][1];
|
|
225
|
-
args[oArg2.name()] = args2;
|
|
226
|
-
}
|
|
227
|
-
else {
|
|
228
|
-
args = Object.assign(Object.assign({}, args), args2);
|
|
227
|
+
parseCommandArgs(argsValues) {
|
|
228
|
+
var args = {};
|
|
229
|
+
const commandOpts = this.command['_optionValues'] || {};
|
|
230
|
+
const commandArgs = this.command["_args"] || [];
|
|
231
|
+
commandArgs.forEach((a, i) => {
|
|
232
|
+
if (typeof (argsValues[i]) === 'string') {
|
|
233
|
+
args[a.name()] = argsValues[i];
|
|
229
234
|
}
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
args = Object.assign(Object.assign({}, args), args1);
|
|
233
|
-
}
|
|
235
|
+
});
|
|
236
|
+
args = Object.assign(Object.assign({}, commandOpts), args);
|
|
234
237
|
args = Object.entries(args).reduce((acc, [key, value]) => {
|
|
235
238
|
const newKey = key.includes(" ") ? key.replace(/ (\w)/g, (_, char) => char.toUpperCase()) : key;
|
|
236
239
|
acc[newKey] = value;
|
|
@@ -304,9 +307,9 @@ class AbstractCommand {
|
|
|
304
307
|
catch (_a) { }
|
|
305
308
|
}
|
|
306
309
|
}
|
|
307
|
-
execute(
|
|
310
|
+
execute(...args) {
|
|
308
311
|
return __awaiter(this, void 0, void 0, function* () {
|
|
309
|
-
this.args = this.parseCommandArgs(
|
|
312
|
+
this.args = this.parseCommandArgs(args);
|
|
310
313
|
this.onArgs();
|
|
311
314
|
var exitCode;
|
|
312
315
|
try {
|
|
@@ -17,16 +17,16 @@ const systemAlias_1 = require("../../systemAlias");
|
|
|
17
17
|
const utils_1 = require("../../utils");
|
|
18
18
|
class Alias extends AbstractCommand_1.AbstractCommand {
|
|
19
19
|
init() {
|
|
20
|
-
if (this.
|
|
20
|
+
if (this.subcommand === 'create') {
|
|
21
21
|
this.command.description(`Create a new system alias.`);
|
|
22
22
|
this.command.argument(`<alias>`, `Alias name.`);
|
|
23
23
|
}
|
|
24
|
-
else if (this.
|
|
24
|
+
else if (this.subcommand === 'delete') {
|
|
25
25
|
this.command.description(`Delete a system alias.`);
|
|
26
26
|
this.command.argument(`<alias>`, `Alias name.`);
|
|
27
27
|
}
|
|
28
28
|
else {
|
|
29
|
-
this.command.description(`
|
|
29
|
+
this.command.description(`Manage system aliases.`);
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
view(alias) {
|
|
@@ -87,10 +87,10 @@ class Alias extends AbstractCommand_1.AbstractCommand {
|
|
|
87
87
|
}
|
|
88
88
|
handler() {
|
|
89
89
|
return __awaiter(this, void 0, void 0, function* () {
|
|
90
|
-
if (this.
|
|
90
|
+
if (this.subcommand === 'create') {
|
|
91
91
|
yield (0, prompts_1.createAlias)(this.args.alias);
|
|
92
92
|
}
|
|
93
|
-
else if (this.
|
|
93
|
+
else if (this.subcommand === 'delete') {
|
|
94
94
|
yield (0, prompts_1.deleteAlias)(this.args.alias);
|
|
95
95
|
}
|
|
96
96
|
else {
|
|
@@ -14,13 +14,13 @@ const AbstractCommand_1 = require("../AbstractCommand");
|
|
|
14
14
|
class DistTag extends AbstractCommand_1.AbstractCommand {
|
|
15
15
|
init() {
|
|
16
16
|
this.registerOpts.requiresRegistry = true;
|
|
17
|
-
if (this.
|
|
17
|
+
if (this.subcommand === 'add') {
|
|
18
18
|
this.command.description(`Tag a release.`);
|
|
19
19
|
this.command.argument(`<package>`, `Name of the package.`);
|
|
20
20
|
this.command.argument(`<version>`, `Release version of the package.`);
|
|
21
21
|
this.command.argument(`<tag>`, `Tag to assign to release.`);
|
|
22
22
|
}
|
|
23
|
-
else if (this.
|
|
23
|
+
else if (this.subcommand === 'rm') {
|
|
24
24
|
this.command.description(`Remove tag from a release.`);
|
|
25
25
|
this.command.argument(`<package>`, `Name of the package.`);
|
|
26
26
|
this.command.argument(`<tag>`, `Tag to remove.`);
|
|
@@ -28,20 +28,17 @@ class DistTag extends AbstractCommand_1.AbstractCommand {
|
|
|
28
28
|
}
|
|
29
29
|
handler() {
|
|
30
30
|
return __awaiter(this, void 0, void 0, function* () {
|
|
31
|
-
if (this.
|
|
31
|
+
if (this.subcommand === 'add') {
|
|
32
32
|
yield this.getRegistry().addDistTag(this.args.package, {
|
|
33
33
|
version: this.args.version,
|
|
34
34
|
tag: this.args.tag
|
|
35
35
|
});
|
|
36
36
|
}
|
|
37
|
-
else if (this.
|
|
37
|
+
else if (this.subcommand === 'rm') {
|
|
38
38
|
yield this.getRegistry().rmDistTag(this.args.package, {
|
|
39
39
|
tag: this.args.tag
|
|
40
40
|
});
|
|
41
41
|
}
|
|
42
|
-
else {
|
|
43
|
-
throw new Error(`Unknown command.`);
|
|
44
|
-
}
|
|
45
42
|
});
|
|
46
43
|
}
|
|
47
44
|
}
|
|
@@ -17,11 +17,11 @@ const registryAlias_1 = require("../../registryAlias");
|
|
|
17
17
|
class Registry extends AbstractCommand_1.AbstractCommand {
|
|
18
18
|
init() {
|
|
19
19
|
this.registerOpts.requiresRegistry = true;
|
|
20
|
-
if (this.
|
|
20
|
+
if (this.subcommand === 'add') {
|
|
21
21
|
this.command.description(`Add a new registry.`);
|
|
22
22
|
this.command.argument(`<registry name>`, `Name of the registry to generate. Name "${trm_core_1.PUBLIC_RESERVED_KEYWORD}" and "${trm_core_1.LOCAL_RESERVED_KEYWORD}" are protected and cannot be used.`);
|
|
23
23
|
}
|
|
24
|
-
else if (this.
|
|
24
|
+
else if (this.subcommand === 'rm') {
|
|
25
25
|
this.command.description(`Remove a registry.`);
|
|
26
26
|
this.command.argument(`<registry name>`, `Name of the registry to delete. Registries "${trm_core_1.PUBLIC_RESERVED_KEYWORD}" and "${trm_core_1.LOCAL_RESERVED_KEYWORD}" are protected and cannot be deleted.`);
|
|
27
27
|
}
|
|
@@ -30,7 +30,7 @@ class Registry extends AbstractCommand_1.AbstractCommand {
|
|
|
30
30
|
handler() {
|
|
31
31
|
return __awaiter(this, void 0, void 0, function* () {
|
|
32
32
|
const registryName = this.args.registryName.trim();
|
|
33
|
-
if (this.
|
|
33
|
+
if (this.subcommand === 'add') {
|
|
34
34
|
var endpoint = this.args.endpoint;
|
|
35
35
|
if (registryName.toLowerCase() === trm_core_1.PUBLIC_RESERVED_KEYWORD) {
|
|
36
36
|
throw new Error(`Registry name "${trm_core_1.PUBLIC_RESERVED_KEYWORD}" is a reserved keyword.`);
|
|
@@ -68,7 +68,7 @@ class Registry extends AbstractCommand_1.AbstractCommand {
|
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
|
-
else if (this.
|
|
71
|
+
else if (this.subcommand === 'rm') {
|
|
72
72
|
if (registryName.toLowerCase() === trm_core_1.PUBLIC_RESERVED_KEYWORD) {
|
|
73
73
|
throw new Error(`Registry "${trm_core_1.PUBLIC_RESERVED_KEYWORD}" is protected and cannot be deleted.`);
|
|
74
74
|
}
|
|
@@ -79,9 +79,6 @@ class Registry extends AbstractCommand_1.AbstractCommand {
|
|
|
79
79
|
registryAlias_1.RegistryAlias.delete(registryName);
|
|
80
80
|
trm_commons_1.Logger.success(`Registry "${registryName}" has been removed.`);
|
|
81
81
|
}
|
|
82
|
-
else {
|
|
83
|
-
throw new Error(`Unknown command.`);
|
|
84
|
-
}
|
|
85
82
|
});
|
|
86
83
|
}
|
|
87
84
|
}
|
package/dist/index.js
CHANGED
|
@@ -23,17 +23,17 @@ Public registry at https://trmregistry.com/
|
|
|
23
23
|
.version((0, utils_1.getClientVersion)());
|
|
24
24
|
new implementations_1.Ping(program, 'ping').register();
|
|
25
25
|
new implementations_1.Info(program, 'info').register();
|
|
26
|
-
new implementations_1.Registry(program, 'registry add').register();
|
|
27
|
-
new implementations_1.Registry(program, 'registry rm').register();
|
|
26
|
+
new implementations_1.Registry(program, 'registry', null, 'add').register();
|
|
27
|
+
new implementations_1.Registry(program, 'registry', null, 'rm').register();
|
|
28
28
|
new implementations_1.Login(program, 'login').register();
|
|
29
29
|
new implementations_1.WhoAmI(program, 'whoami').register();
|
|
30
30
|
new implementations_1.Logout(program, 'logout').register();
|
|
31
|
-
new implementations_1.Alias(program, 'alias create').register();
|
|
32
|
-
new implementations_1.Alias(program, 'alias delete').register();
|
|
33
31
|
new implementations_1.Alias(program, 'alias').register();
|
|
32
|
+
new implementations_1.Alias(program, 'alias', null, 'create').register();
|
|
33
|
+
new implementations_1.Alias(program, 'alias', null, 'delete').register();
|
|
34
34
|
new implementations_1.Publish(program, 'publish').register();
|
|
35
|
-
new implementations_1.DistTag(program, 'dist-tag add').register();
|
|
36
|
-
new implementations_1.DistTag(program, 'dist-tag rm').register();
|
|
35
|
+
new implementations_1.DistTag(program, 'dist-tag', null, 'add').register();
|
|
36
|
+
new implementations_1.DistTag(program, 'dist-tag', null, 'rm').register();
|
|
37
37
|
new implementations_1.Publish(program, 'pack', ['export']).register();
|
|
38
38
|
new implementations_1.Lock(program, 'lock', ['lock-file']).register();
|
|
39
39
|
new implementations_1.Unpublish(program, 'unpublish').register();
|