@glpkg/registry-cli 0.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/README.md +85 -0
- package/dist/cli/index.d.ts +70 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +161 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +326 -0
- package/dist/cli.js.map +1 -0
- package/dist/core/api.d.ts +94 -0
- package/dist/core/api.d.ts.map +1 -0
- package/dist/core/api.js +404 -0
- package/dist/core/api.js.map +1 -0
- package/dist/core/index.d.ts +29 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +39 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/types.d.ts +175 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/core/types.js +6 -0
- package/dist/core/types.js.map +1 -0
- package/dist/core/utils.d.ts +23 -0
- package/dist/core/utils.d.ts.map +1 -0
- package/dist/core/utils.js +50 -0
- package/dist/core/utils.js.map +1 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +28 -0
- package/dist/index.js.map +1 -0
- package/package.json +50 -0
package/README.md
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
# @glpkg/registry
|
|
2
|
+
|
|
3
|
+
Query GitLab NPM Package Registry - view package info, versions, and search.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
gitlab-install add @glpkg/registry -g
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
# View package information (like npm view)
|
|
15
|
+
gitlab-registry info @scope/package
|
|
16
|
+
gitlab-registry info @scope/package -v 1.0.0 # specific version
|
|
17
|
+
gitlab-registry info @scope/package --json # JSON output
|
|
18
|
+
|
|
19
|
+
# List all versions
|
|
20
|
+
gitlab-registry versions @scope/package
|
|
21
|
+
gitlab-registry v @scope/package # alias
|
|
22
|
+
|
|
23
|
+
# List packages in a scope
|
|
24
|
+
gitlab-registry list --scope @ist
|
|
25
|
+
gitlab-registry ls -s @ist # alias
|
|
26
|
+
|
|
27
|
+
# Search packages
|
|
28
|
+
gitlab-registry search monitor --scope @ist
|
|
29
|
+
gitlab-registry s monitor # alias
|
|
30
|
+
|
|
31
|
+
# Show registered scopes
|
|
32
|
+
gitlab-registry scopes
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Prerequisites
|
|
36
|
+
|
|
37
|
+
1. GitLab token configured:
|
|
38
|
+
```bash
|
|
39
|
+
gitlab-config save glpat-xxx
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
2. Scope registered:
|
|
43
|
+
```bash
|
|
44
|
+
gitlab-config scope add @ist microwiseai
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Commands
|
|
48
|
+
|
|
49
|
+
| Command | Alias | Description |
|
|
50
|
+
|---------|-------|-------------|
|
|
51
|
+
| `info <package>` | `view` | View package information |
|
|
52
|
+
| `versions <package>` | `v` | List all versions |
|
|
53
|
+
| `list` | `ls` | List packages in a scope |
|
|
54
|
+
| `search <query>` | `s` | Search packages by name |
|
|
55
|
+
| `scopes` | - | Show registered scopes |
|
|
56
|
+
|
|
57
|
+
## Options
|
|
58
|
+
|
|
59
|
+
- `--json`: Output as JSON (for info, versions, list, search)
|
|
60
|
+
- `-v, --version`: Specific version to view (for info)
|
|
61
|
+
- `-s, --scope`: Scope to filter (for list, search)
|
|
62
|
+
|
|
63
|
+
## API Usage
|
|
64
|
+
|
|
65
|
+
```typescript
|
|
66
|
+
import { GitLabRegistry } from '@glpkg/registry';
|
|
67
|
+
|
|
68
|
+
const registry = new GitLabRegistry();
|
|
69
|
+
|
|
70
|
+
// Get package info
|
|
71
|
+
const info = await registry.info('@scope/package');
|
|
72
|
+
|
|
73
|
+
// Get all versions
|
|
74
|
+
const versions = await registry.versions('@scope/package');
|
|
75
|
+
|
|
76
|
+
// List packages
|
|
77
|
+
const packages = await registry.list({ scope: '@scope' });
|
|
78
|
+
|
|
79
|
+
// Search
|
|
80
|
+
const results = await registry.search('query', { scope: '@scope' });
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## License
|
|
84
|
+
|
|
85
|
+
MIT
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI module - Node.js dependencies allowed (@glpkg/config, etc.)
|
|
3
|
+
*
|
|
4
|
+
* This module wraps GitLabRegistryCore with @glpkg/config integration.
|
|
5
|
+
*/
|
|
6
|
+
import { SourceType, PackageInfoDisplay, VersionInfoDisplay, GitLabPackage, SearchResult } from '../core/index.js';
|
|
7
|
+
export { SourceType, GitLabPackage, NpmPackageMetadata, NpmVersionMetadata, PackageInfoDisplay, VersionInfoDisplay, SearchResult, VerifyPublishedOptions, VerifyPublishedResult } from '../core/index.js';
|
|
8
|
+
export { verifyPublished } from '../core/index.js';
|
|
9
|
+
/**
|
|
10
|
+
* GitLab Registry Client with @glpkg/config integration
|
|
11
|
+
*
|
|
12
|
+
* This is a convenience wrapper around GitLabRegistryCore that automatically
|
|
13
|
+
* reads token and scope mappings from @glpkg/config.
|
|
14
|
+
*/
|
|
15
|
+
export declare class GitLabRegistry {
|
|
16
|
+
private core;
|
|
17
|
+
private defaultHost;
|
|
18
|
+
constructor(options?: {
|
|
19
|
+
host?: string;
|
|
20
|
+
});
|
|
21
|
+
/**
|
|
22
|
+
* Resolve group registry info for a package using @glpkg/config
|
|
23
|
+
*/
|
|
24
|
+
private resolveGroupRegistry;
|
|
25
|
+
/**
|
|
26
|
+
* Resolve project registry info for a package using @glpkg/config
|
|
27
|
+
*/
|
|
28
|
+
private resolveProjectRegistry;
|
|
29
|
+
/**
|
|
30
|
+
* Resolve scope info using @glpkg/config
|
|
31
|
+
*/
|
|
32
|
+
private resolveScope;
|
|
33
|
+
/**
|
|
34
|
+
* Extract scope from package name
|
|
35
|
+
*/
|
|
36
|
+
private extractScope;
|
|
37
|
+
/**
|
|
38
|
+
* Get NPM package metadata (like npm view)
|
|
39
|
+
*/
|
|
40
|
+
getPackageMetadata(packageName: string, source?: SourceType): Promise<(import("../core/types.js").NpmPackageMetadata & {
|
|
41
|
+
source?: "project" | "group";
|
|
42
|
+
}) | null>;
|
|
43
|
+
/**
|
|
44
|
+
* Get package info for display (like npm view)
|
|
45
|
+
*/
|
|
46
|
+
info(packageName: string, version?: string, source?: SourceType): Promise<PackageInfoDisplay | null>;
|
|
47
|
+
/**
|
|
48
|
+
* Get all versions of a package
|
|
49
|
+
*/
|
|
50
|
+
versions(packageName: string, source?: SourceType): Promise<VersionInfoDisplay[]>;
|
|
51
|
+
/**
|
|
52
|
+
* List packages in a group
|
|
53
|
+
*/
|
|
54
|
+
list(options?: {
|
|
55
|
+
scope?: string;
|
|
56
|
+
groupId?: number;
|
|
57
|
+
}): Promise<GitLabPackage[]>;
|
|
58
|
+
/**
|
|
59
|
+
* Search packages by name
|
|
60
|
+
*/
|
|
61
|
+
search(query: string, options?: {
|
|
62
|
+
scope?: string;
|
|
63
|
+
}): Promise<SearchResult[]>;
|
|
64
|
+
/**
|
|
65
|
+
* Get available scopes
|
|
66
|
+
*/
|
|
67
|
+
getAvailableScopes(): string[];
|
|
68
|
+
}
|
|
69
|
+
export declare const registry: GitLabRegistry;
|
|
70
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAEL,UAAU,EACV,kBAAkB,EAClB,kBAAkB,EAClB,aAAa,EACb,YAAY,EAEb,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EACL,UAAU,EACV,aAAa,EACb,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,YAAY,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|
+
* CLI module - Node.js dependencies allowed (@glpkg/config, etc.)
|
|
4
|
+
*
|
|
5
|
+
* This module wraps GitLabRegistryCore with @glpkg/config integration.
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.registry = exports.GitLabRegistry = exports.verifyPublished = void 0;
|
|
9
|
+
const config_1 = require("@glpkg/config");
|
|
10
|
+
const index_js_1 = require("../core/index.js");
|
|
11
|
+
// Re-export verifyPublished
|
|
12
|
+
var index_js_2 = require("../core/index.js");
|
|
13
|
+
Object.defineProperty(exports, "verifyPublished", { enumerable: true, get: function () { return index_js_2.verifyPublished; } });
|
|
14
|
+
/**
|
|
15
|
+
* GitLab Registry Client with @glpkg/config integration
|
|
16
|
+
*
|
|
17
|
+
* This is a convenience wrapper around GitLabRegistryCore that automatically
|
|
18
|
+
* reads token and scope mappings from @glpkg/config.
|
|
19
|
+
*/
|
|
20
|
+
class GitLabRegistry {
|
|
21
|
+
core;
|
|
22
|
+
defaultHost;
|
|
23
|
+
constructor(options = {}) {
|
|
24
|
+
this.defaultHost = options.host || 'gitlab.com';
|
|
25
|
+
this.core = new index_js_1.GitLabRegistryCore({
|
|
26
|
+
token: (0, config_1.getToken)() || undefined,
|
|
27
|
+
host: this.defaultHost
|
|
28
|
+
});
|
|
29
|
+
// Set up resolvers using @glpkg/config
|
|
30
|
+
this.core.setGroupRegistryResolver((packageName) => this.resolveGroupRegistry(packageName));
|
|
31
|
+
this.core.setProjectRegistryResolver((packageName) => this.resolveProjectRegistry(packageName));
|
|
32
|
+
this.core.setScopeResolver((scope) => this.resolveScope(scope));
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Resolve group registry info for a package using @glpkg/config
|
|
36
|
+
*/
|
|
37
|
+
resolveGroupRegistry(packageName) {
|
|
38
|
+
// First check if package is registered
|
|
39
|
+
const packageInfo = (0, config_1.getPackageInfo)(packageName);
|
|
40
|
+
if (packageInfo) {
|
|
41
|
+
return {
|
|
42
|
+
url: packageInfo.registryUrl,
|
|
43
|
+
groupId: packageInfo.groupId,
|
|
44
|
+
host: packageInfo.gitlabHost
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
// Fallback to scope mapping
|
|
48
|
+
const scope = this.extractScope(packageName);
|
|
49
|
+
if (scope) {
|
|
50
|
+
const scopeMapping = (0, config_1.getScopeMapping)(scope);
|
|
51
|
+
if (scopeMapping) {
|
|
52
|
+
return {
|
|
53
|
+
url: scopeMapping.registryUrl,
|
|
54
|
+
groupId: scopeMapping.groupId,
|
|
55
|
+
host: scopeMapping.gitlabHost
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Resolve project registry info for a package using @glpkg/config
|
|
63
|
+
*/
|
|
64
|
+
resolveProjectRegistry(packageName) {
|
|
65
|
+
const packageInfo = (0, config_1.getPackageInfo)(packageName);
|
|
66
|
+
if (packageInfo && packageInfo.projectId) {
|
|
67
|
+
const host = packageInfo.gitlabHost || this.defaultHost;
|
|
68
|
+
return {
|
|
69
|
+
url: `https://${host}/api/v4/projects/${packageInfo.projectId}/packages/npm/`,
|
|
70
|
+
projectId: packageInfo.projectId,
|
|
71
|
+
host
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Resolve scope info using @glpkg/config
|
|
78
|
+
*/
|
|
79
|
+
resolveScope(scope) {
|
|
80
|
+
// Get groupId from scope if provided
|
|
81
|
+
if (scope) {
|
|
82
|
+
const scopeMapping = (0, config_1.getScopeMapping)(scope.replace(/^@/, ''));
|
|
83
|
+
if (scopeMapping) {
|
|
84
|
+
return {
|
|
85
|
+
groupId: scopeMapping.groupId,
|
|
86
|
+
host: scopeMapping.gitlabHost
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
// If no scope, try to get from any registered scope
|
|
91
|
+
const allScopes = (0, config_1.getAllScopes)();
|
|
92
|
+
const firstScope = Object.values(allScopes.scopes)[0];
|
|
93
|
+
if (firstScope) {
|
|
94
|
+
return {
|
|
95
|
+
groupId: firstScope.groupId,
|
|
96
|
+
host: firstScope.gitlabHost
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Extract scope from package name
|
|
103
|
+
*/
|
|
104
|
+
extractScope(packageName) {
|
|
105
|
+
if (packageName.startsWith('@')) {
|
|
106
|
+
const slashIndex = packageName.indexOf('/');
|
|
107
|
+
if (slashIndex > 1) {
|
|
108
|
+
return packageName.slice(1, slashIndex);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return null;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Get NPM package metadata (like npm view)
|
|
115
|
+
*/
|
|
116
|
+
async getPackageMetadata(packageName, source = 'both') {
|
|
117
|
+
return this.core.getPackageMetadata(packageName, source);
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Get package info for display (like npm view)
|
|
121
|
+
*/
|
|
122
|
+
async info(packageName, version, source = 'both') {
|
|
123
|
+
return this.core.info(packageName, version, source);
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Get all versions of a package
|
|
127
|
+
*/
|
|
128
|
+
async versions(packageName, source = 'both') {
|
|
129
|
+
return this.core.versions(packageName, source);
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* List packages in a group
|
|
133
|
+
*/
|
|
134
|
+
async list(options = {}) {
|
|
135
|
+
const scopeInfo = this.resolveScope(options.scope);
|
|
136
|
+
if (!options.groupId && !scopeInfo) {
|
|
137
|
+
throw new Error('No group ID found. Register a scope first: gitlab-config scope add @scope group-name');
|
|
138
|
+
}
|
|
139
|
+
return this.core.list({
|
|
140
|
+
groupId: options.groupId || scopeInfo?.groupId,
|
|
141
|
+
host: scopeInfo?.host
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Search packages by name
|
|
146
|
+
*/
|
|
147
|
+
async search(query, options = {}) {
|
|
148
|
+
return this.core.search(query, options);
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Get available scopes
|
|
152
|
+
*/
|
|
153
|
+
getAvailableScopes() {
|
|
154
|
+
const allScopes = (0, config_1.getAllScopes)();
|
|
155
|
+
return Object.keys(allScopes.scopes).map(s => `@${s}`);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
exports.GitLabRegistry = GitLabRegistry;
|
|
159
|
+
// Export singleton instance for convenience
|
|
160
|
+
exports.registry = new GitLabRegistry();
|
|
161
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAEH,0CAAwF;AACxF,+CAQ0B;AAe1B,4BAA4B;AAC5B,6CAAmD;AAA1C,2GAAA,eAAe,OAAA;AAExB;;;;;GAKG;AACH,MAAa,cAAc;IACjB,IAAI,CAAqB;IACzB,WAAW,CAAS;IAE5B,YAAY,UAA6B,EAAE;QACzC,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC,IAAI,IAAI,YAAY,CAAC;QAEhD,IAAI,CAAC,IAAI,GAAG,IAAI,6BAAkB,CAAC;YACjC,KAAK,EAAE,IAAA,iBAAQ,GAAE,IAAI,SAAS;YAC9B,IAAI,EAAE,IAAI,CAAC,WAAW;SACvB,CAAC,CAAC;QAEH,uCAAuC;QACvC,IAAI,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,IAAI,CAAC,oBAAoB,CAAC,WAAW,CAAC,CAAC,CAAC;QAC5F,IAAI,CAAC,IAAI,CAAC,0BAA0B,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,IAAI,CAAC,sBAAsB,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li.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":""}
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,326 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
+
};
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
const commander_1 = require("commander");
|
|
8
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
9
|
+
const index_js_1 = require("./index.js");
|
|
10
|
+
const program = new commander_1.Command();
|
|
11
|
+
program
|
|
12
|
+
.name('gitlab-registry')
|
|
13
|
+
.description('Query GitLab NPM Package Registry')
|
|
14
|
+
.version(require('../package.json').version);
|
|
15
|
+
/**
|
|
16
|
+
* Format source badge
|
|
17
|
+
*/
|
|
18
|
+
function formatSource(source) {
|
|
19
|
+
if (!source)
|
|
20
|
+
return '';
|
|
21
|
+
if (source === 'both')
|
|
22
|
+
return chalk_1.default.bgGreen.white(' PROJECT+GROUP ');
|
|
23
|
+
return source === 'project'
|
|
24
|
+
? chalk_1.default.bgBlue.white(' PROJECT ')
|
|
25
|
+
: chalk_1.default.bgMagenta.white(' GROUP ');
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Format package info for display
|
|
29
|
+
*/
|
|
30
|
+
function displayPackageInfo(info) {
|
|
31
|
+
console.log();
|
|
32
|
+
console.log(chalk_1.default.bold.green(`${info.name}@${info.version}`), info.source ? formatSource(info.source) : '');
|
|
33
|
+
console.log();
|
|
34
|
+
if (info.description) {
|
|
35
|
+
console.log(chalk_1.default.dim('Description:'), info.description);
|
|
36
|
+
}
|
|
37
|
+
if (info.license) {
|
|
38
|
+
console.log(chalk_1.default.dim('License:'), info.license);
|
|
39
|
+
}
|
|
40
|
+
if (info.author) {
|
|
41
|
+
console.log(chalk_1.default.dim('Author:'), info.author);
|
|
42
|
+
}
|
|
43
|
+
if (info.repository) {
|
|
44
|
+
console.log(chalk_1.default.dim('Repository:'), info.repository);
|
|
45
|
+
}
|
|
46
|
+
if (info.publishedAt) {
|
|
47
|
+
const date = new Date(info.publishedAt);
|
|
48
|
+
console.log(chalk_1.default.dim('Published:'), date.toLocaleDateString());
|
|
49
|
+
}
|
|
50
|
+
if (info.source) {
|
|
51
|
+
console.log(chalk_1.default.dim('Source:'), info.source === 'project' ? 'Project Registry' : 'Group Registry');
|
|
52
|
+
}
|
|
53
|
+
if (info.keywords && info.keywords.length > 0) {
|
|
54
|
+
console.log(chalk_1.default.dim('Keywords:'), info.keywords.join(', '));
|
|
55
|
+
}
|
|
56
|
+
if (info.engines) {
|
|
57
|
+
console.log(chalk_1.default.dim('Engines:'));
|
|
58
|
+
for (const [engine, version] of Object.entries(info.engines)) {
|
|
59
|
+
console.log(` ${engine}: ${version}`);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
if (info.distTags && Object.keys(info.distTags).length > 0) {
|
|
63
|
+
console.log();
|
|
64
|
+
console.log(chalk_1.default.dim('Dist Tags:'));
|
|
65
|
+
for (const [tag, version] of Object.entries(info.distTags)) {
|
|
66
|
+
console.log(` ${chalk_1.default.cyan(tag)}: ${version}`);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
if (info.dependencies && Object.keys(info.dependencies).length > 0) {
|
|
70
|
+
console.log();
|
|
71
|
+
console.log(chalk_1.default.dim('Dependencies:'));
|
|
72
|
+
for (const [name, version] of Object.entries(info.dependencies)) {
|
|
73
|
+
console.log(` ${name}: ${chalk_1.default.gray(version)}`);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
if (info.devDependencies && Object.keys(info.devDependencies).length > 0) {
|
|
77
|
+
console.log();
|
|
78
|
+
console.log(chalk_1.default.dim('Dev Dependencies:'));
|
|
79
|
+
for (const [name, version] of Object.entries(info.devDependencies)) {
|
|
80
|
+
console.log(` ${name}: ${chalk_1.default.gray(version)}`);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
console.log();
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Format version list for display
|
|
87
|
+
*/
|
|
88
|
+
function displayVersions(packageName, versions) {
|
|
89
|
+
console.log();
|
|
90
|
+
console.log(chalk_1.default.bold(`${packageName} - ${versions.length} version(s)`));
|
|
91
|
+
console.log();
|
|
92
|
+
for (const v of versions) {
|
|
93
|
+
let line = ` ${chalk_1.default.green(v.version)}`;
|
|
94
|
+
if (v.tag) {
|
|
95
|
+
line += ` ${chalk_1.default.cyan(`[${v.tag}]`)}`;
|
|
96
|
+
}
|
|
97
|
+
if (v.publishedAt) {
|
|
98
|
+
const date = new Date(v.publishedAt);
|
|
99
|
+
line += ` ${chalk_1.default.gray(date.toLocaleDateString())}`;
|
|
100
|
+
}
|
|
101
|
+
if (v.source) {
|
|
102
|
+
if (v.source === 'both') {
|
|
103
|
+
line += ` ${chalk_1.default.green('[P+G]')}`;
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
line += ` ${v.source === 'project' ? chalk_1.default.blue('[P]') : chalk_1.default.magenta('[G]')}`;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
console.log(line);
|
|
110
|
+
}
|
|
111
|
+
console.log();
|
|
112
|
+
console.log(chalk_1.default.dim(' [P] = Project Registry, [G] = Group Registry, [P+G] = Both'));
|
|
113
|
+
console.log();
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Format package list for display
|
|
117
|
+
*/
|
|
118
|
+
function displayList(packages) {
|
|
119
|
+
console.log();
|
|
120
|
+
console.log(chalk_1.default.bold(`Found ${packages.length} package(s)`));
|
|
121
|
+
console.log();
|
|
122
|
+
// Group by name
|
|
123
|
+
const byName = new Map();
|
|
124
|
+
for (const pkg of packages) {
|
|
125
|
+
if (!byName.has(pkg.name)) {
|
|
126
|
+
byName.set(pkg.name, []);
|
|
127
|
+
}
|
|
128
|
+
byName.get(pkg.name).push(pkg);
|
|
129
|
+
}
|
|
130
|
+
for (const [name, versions] of byName) {
|
|
131
|
+
// Get latest version
|
|
132
|
+
const latest = versions.sort((a, b) => new Date(b.publishedAt).getTime() - new Date(a.publishedAt).getTime())[0];
|
|
133
|
+
console.log(` ${chalk_1.default.green(name)} ${chalk_1.default.gray(`v${latest.version}`)}`);
|
|
134
|
+
}
|
|
135
|
+
console.log();
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Format search results for display
|
|
139
|
+
*/
|
|
140
|
+
function displaySearchResults(query, results) {
|
|
141
|
+
console.log();
|
|
142
|
+
if (results.length === 0) {
|
|
143
|
+
console.log(chalk_1.default.yellow(`No packages found matching "${query}"`));
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
console.log(chalk_1.default.bold(`Found ${results.length} package(s) matching "${query}"`));
|
|
147
|
+
console.log();
|
|
148
|
+
for (const result of results) {
|
|
149
|
+
let line = ` ${chalk_1.default.green(result.name)} ${chalk_1.default.gray(`v${result.version}`)}`;
|
|
150
|
+
if (result.description) {
|
|
151
|
+
line += ` - ${result.description}`;
|
|
152
|
+
}
|
|
153
|
+
console.log(line);
|
|
154
|
+
}
|
|
155
|
+
console.log();
|
|
156
|
+
}
|
|
157
|
+
// info command
|
|
158
|
+
program
|
|
159
|
+
.command('info <package>')
|
|
160
|
+
.alias('view')
|
|
161
|
+
.description('View package information (like npm view)')
|
|
162
|
+
.option('-v, --version <version>', 'Specific version to view')
|
|
163
|
+
.option('--source <type>', 'Registry source: project, group, or both (default: both)', 'both')
|
|
164
|
+
.option('--json', 'Output as JSON')
|
|
165
|
+
.action(async (packageName, options) => {
|
|
166
|
+
try {
|
|
167
|
+
const source = options.source;
|
|
168
|
+
if (!['project', 'group', 'both'].includes(source)) {
|
|
169
|
+
console.error(chalk_1.default.red('Error:'), 'Invalid source. Use: project, group, or both');
|
|
170
|
+
process.exit(1);
|
|
171
|
+
}
|
|
172
|
+
const registry = new index_js_1.GitLabRegistry();
|
|
173
|
+
const info = await registry.info(packageName, options.version, source);
|
|
174
|
+
if (!info) {
|
|
175
|
+
console.error(chalk_1.default.red('Error:'), `Package not found: ${packageName}`);
|
|
176
|
+
console.log();
|
|
177
|
+
console.log(chalk_1.default.dim('Make sure:'));
|
|
178
|
+
console.log(chalk_1.default.dim(' 1. The package exists in GitLab registry'));
|
|
179
|
+
console.log(chalk_1.default.dim(' 2. The scope is registered: gitlab-config scope add @scope group-name'));
|
|
180
|
+
console.log(chalk_1.default.dim(' 3. You have a valid token: gitlab-config check'));
|
|
181
|
+
if (source !== 'both') {
|
|
182
|
+
console.log(chalk_1.default.dim(` 4. Try --source both to search all registries`));
|
|
183
|
+
}
|
|
184
|
+
process.exit(1);
|
|
185
|
+
}
|
|
186
|
+
if (options.json) {
|
|
187
|
+
console.log(JSON.stringify(info, null, 2));
|
|
188
|
+
}
|
|
189
|
+
else {
|
|
190
|
+
displayPackageInfo(info);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
catch (error) {
|
|
194
|
+
console.error(chalk_1.default.red('Error:'), error.message);
|
|
195
|
+
process.exit(1);
|
|
196
|
+
}
|
|
197
|
+
});
|
|
198
|
+
// versions command
|
|
199
|
+
program
|
|
200
|
+
.command('versions <package>')
|
|
201
|
+
.alias('v')
|
|
202
|
+
.description('List all versions of a package')
|
|
203
|
+
.option('--source <type>', 'Registry source: project, group, or both (default: both)', 'both')
|
|
204
|
+
.option('--json', 'Output as JSON')
|
|
205
|
+
.action(async (packageName, options) => {
|
|
206
|
+
try {
|
|
207
|
+
const source = options.source;
|
|
208
|
+
if (!['project', 'group', 'both'].includes(source)) {
|
|
209
|
+
console.error(chalk_1.default.red('Error:'), 'Invalid source. Use: project, group, or both');
|
|
210
|
+
process.exit(1);
|
|
211
|
+
}
|
|
212
|
+
const registry = new index_js_1.GitLabRegistry();
|
|
213
|
+
const versions = await registry.versions(packageName, source);
|
|
214
|
+
if (versions.length === 0) {
|
|
215
|
+
console.error(chalk_1.default.red('Error:'), `Package not found: ${packageName}`);
|
|
216
|
+
process.exit(1);
|
|
217
|
+
}
|
|
218
|
+
if (options.json) {
|
|
219
|
+
console.log(JSON.stringify(versions, null, 2));
|
|
220
|
+
}
|
|
221
|
+
else {
|
|
222
|
+
displayVersions(packageName, versions);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
catch (error) {
|
|
226
|
+
console.error(chalk_1.default.red('Error:'), error.message);
|
|
227
|
+
process.exit(1);
|
|
228
|
+
}
|
|
229
|
+
});
|
|
230
|
+
// list command
|
|
231
|
+
program
|
|
232
|
+
.command('list')
|
|
233
|
+
.alias('ls')
|
|
234
|
+
.description('List packages in a group/scope')
|
|
235
|
+
.option('-s, --scope <scope>', 'Scope to list packages from (e.g., @glpkg)')
|
|
236
|
+
.option('--json', 'Output as JSON')
|
|
237
|
+
.action(async (options) => {
|
|
238
|
+
try {
|
|
239
|
+
const registry = new index_js_1.GitLabRegistry();
|
|
240
|
+
// Show available scopes if none specified
|
|
241
|
+
if (!options.scope) {
|
|
242
|
+
const scopes = registry.getAvailableScopes();
|
|
243
|
+
if (scopes.length === 0) {
|
|
244
|
+
console.error(chalk_1.default.red('Error:'), 'No scopes registered');
|
|
245
|
+
console.log();
|
|
246
|
+
console.log(chalk_1.default.dim('Register a scope first:'));
|
|
247
|
+
console.log(chalk_1.default.dim(' gitlab-config scope add @scope group-name'));
|
|
248
|
+
process.exit(1);
|
|
249
|
+
}
|
|
250
|
+
console.log();
|
|
251
|
+
console.log(chalk_1.default.bold('Available scopes:'));
|
|
252
|
+
for (const scope of scopes) {
|
|
253
|
+
console.log(` ${chalk_1.default.cyan(scope)}`);
|
|
254
|
+
}
|
|
255
|
+
console.log();
|
|
256
|
+
console.log(chalk_1.default.dim('Use: gitlab-registry list --scope @scope'));
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
259
|
+
const packages = await registry.list({ scope: options.scope });
|
|
260
|
+
if (options.json) {
|
|
261
|
+
console.log(JSON.stringify(packages, null, 2));
|
|
262
|
+
}
|
|
263
|
+
else {
|
|
264
|
+
displayList(packages.map(p => ({
|
|
265
|
+
name: p.name,
|
|
266
|
+
version: p.version,
|
|
267
|
+
publishedAt: p.created_at
|
|
268
|
+
})));
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
catch (error) {
|
|
272
|
+
console.error(chalk_1.default.red('Error:'), error.message);
|
|
273
|
+
process.exit(1);
|
|
274
|
+
}
|
|
275
|
+
});
|
|
276
|
+
// search command
|
|
277
|
+
program
|
|
278
|
+
.command('search <query>')
|
|
279
|
+
.alias('s')
|
|
280
|
+
.description('Search packages by name')
|
|
281
|
+
.option('-s, --scope <scope>', 'Scope to search in')
|
|
282
|
+
.option('--json', 'Output as JSON')
|
|
283
|
+
.action(async (query, options) => {
|
|
284
|
+
try {
|
|
285
|
+
const registry = new index_js_1.GitLabRegistry();
|
|
286
|
+
const results = await registry.search(query, { scope: options.scope });
|
|
287
|
+
if (options.json) {
|
|
288
|
+
console.log(JSON.stringify(results, null, 2));
|
|
289
|
+
}
|
|
290
|
+
else {
|
|
291
|
+
displaySearchResults(query, results);
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
catch (error) {
|
|
295
|
+
console.error(chalk_1.default.red('Error:'), error.message);
|
|
296
|
+
process.exit(1);
|
|
297
|
+
}
|
|
298
|
+
});
|
|
299
|
+
// scopes command (convenience)
|
|
300
|
+
program
|
|
301
|
+
.command('scopes')
|
|
302
|
+
.description('Show registered scopes')
|
|
303
|
+
.action(() => {
|
|
304
|
+
const registry = new index_js_1.GitLabRegistry();
|
|
305
|
+
const scopes = registry.getAvailableScopes();
|
|
306
|
+
console.log();
|
|
307
|
+
if (scopes.length === 0) {
|
|
308
|
+
console.log(chalk_1.default.yellow('No scopes registered'));
|
|
309
|
+
console.log();
|
|
310
|
+
console.log(chalk_1.default.dim('Register a scope:'));
|
|
311
|
+
console.log(chalk_1.default.dim(' gitlab-config scope add @scope group-name'));
|
|
312
|
+
}
|
|
313
|
+
else {
|
|
314
|
+
console.log(chalk_1.default.bold('Registered scopes:'));
|
|
315
|
+
for (const scope of scopes) {
|
|
316
|
+
console.log(` ${chalk_1.default.cyan(scope)}`);
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
console.log();
|
|
320
|
+
});
|
|
321
|
+
program.parse();
|
|
322
|
+
// Show help if no command
|
|
323
|
+
if (!process.argv.slice(2).length) {
|
|
324
|
+
program.outputHelp();
|
|
325
|
+
}
|
|
326
|
+
//# sourceMappingURL=cli.js.map
|