@glpkg/cli 0.2.3 → 0.3.11
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/dist/cli.js +14 -11
- package/dist/cli.js.map +1 -1
- package/dist/commands/cleanup-registry.d.ts +6 -0
- package/dist/commands/cleanup-registry.d.ts.map +1 -0
- package/dist/commands/cleanup-registry.js +27 -0
- package/dist/commands/cleanup-registry.js.map +1 -0
- package/dist/commands/config.js +126 -97
- package/dist/commands/config.js.map +1 -1
- package/dist/commands/index.d.ts +2 -0
- package/dist/commands/index.d.ts.map +1 -1
- package/dist/commands/index.js +7 -13
- package/dist/commands/index.js.map +1 -1
- package/dist/commands/install.d.ts.map +1 -1
- package/dist/commands/install.js +98 -124
- package/dist/commands/install.js.map +1 -1
- package/dist/commands/license.js +12 -18
- package/dist/commands/license.js.map +1 -1
- package/dist/commands/publish.d.ts.map +1 -1
- package/dist/commands/publish.js +126 -159
- package/dist/commands/publish.js.map +1 -1
- package/dist/commands/repo.js +79 -118
- package/dist/commands/repo.js.map +1 -1
- package/dist/commands/setup-registry.d.ts +6 -0
- package/dist/commands/setup-registry.d.ts.map +1 -0
- package/dist/commands/setup-registry.js +48 -0
- package/dist/commands/setup-registry.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -7
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/cli.js
CHANGED
|
@@ -1,22 +1,25 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
"use strict";
|
|
3
2
|
/**
|
|
4
3
|
* glpkg - GitLab Package Manager CLI
|
|
5
4
|
*/
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const
|
|
5
|
+
import { Command } from 'commander';
|
|
6
|
+
import { createRequire } from 'module';
|
|
7
|
+
import { configCommand, installCommand, publishCommand, licenseCommand, repoCommand, setupRegistryCommand, cleanupRegistryCommand } from './commands/index.js';
|
|
8
|
+
const require = createRequire(import.meta.url);
|
|
9
|
+
const { version } = require('../package.json');
|
|
10
|
+
const program = new Command();
|
|
10
11
|
program
|
|
11
12
|
.name('glpkg')
|
|
12
13
|
.description('GitLab Package Manager - Install and publish packages')
|
|
13
|
-
.version(
|
|
14
|
+
.version(version);
|
|
14
15
|
// Register commands
|
|
15
|
-
program.addCommand(
|
|
16
|
-
program.addCommand(
|
|
17
|
-
program.addCommand(
|
|
18
|
-
program.addCommand(
|
|
19
|
-
program.addCommand(
|
|
16
|
+
program.addCommand(installCommand);
|
|
17
|
+
program.addCommand(publishCommand);
|
|
18
|
+
program.addCommand(configCommand);
|
|
19
|
+
program.addCommand(licenseCommand);
|
|
20
|
+
program.addCommand(repoCommand);
|
|
21
|
+
program.addCommand(setupRegistryCommand);
|
|
22
|
+
program.addCommand(cleanupRegistryCommand);
|
|
20
23
|
// Parse arguments
|
|
21
24
|
program.parse();
|
|
22
25
|
// Show help if no command
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,cAAc,EAAE,cAAc,EAAE,WAAW,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAE/J,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC/C,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;AAE/C,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;AAE9B,OAAO;KACJ,IAAI,CAAC,OAAO,CAAC;KACb,WAAW,CAAC,uDAAuD,CAAC;KACpE,OAAO,CAAC,OAAO,CAAC,CAAC;AAEpB,oBAAoB;AACpB,OAAO,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC;AACnC,OAAO,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC;AACnC,OAAO,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;AAClC,OAAO,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC;AACnC,OAAO,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;AAChC,OAAO,CAAC,UAAU,CAAC,oBAAoB,CAAC,CAAC;AACzC,OAAO,CAAC,UAAU,CAAC,sBAAsB,CAAC,CAAC;AAE3C,kBAAkB;AAClB,OAAO,CAAC,KAAK,EAAE,CAAC;AAEhB,0BAA0B;AAC1B,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;IAClC,OAAO,CAAC,UAAU,EAAE,CAAC;AACvB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cleanup-registry.d.ts","sourceRoot":"","sources":["../../src/commands/cleanup-registry.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAMpC,eAAO,MAAM,sBAAsB,SAoB/B,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cleanup Registry Command - Remove glpkg-generated .npmrc
|
|
3
|
+
*/
|
|
4
|
+
import { Command } from 'commander';
|
|
5
|
+
import * as fs from 'fs';
|
|
6
|
+
import * as path from 'path';
|
|
7
|
+
const NPMRC_MARKER = '# generated by glpkg';
|
|
8
|
+
export const cleanupRegistryCommand = new Command('cleanup-registry')
|
|
9
|
+
.description('Remove glpkg-generated .npmrc file')
|
|
10
|
+
.action(() => {
|
|
11
|
+
try {
|
|
12
|
+
const npmrcPath = path.join(process.cwd(), '.npmrc');
|
|
13
|
+
if (!fs.existsSync(npmrcPath)) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
const content = fs.readFileSync(npmrcPath, 'utf-8');
|
|
17
|
+
const firstLine = content.split('\n')[0];
|
|
18
|
+
// Only delete if first line starts with our marker
|
|
19
|
+
if (firstLine.startsWith(NPMRC_MARKER)) {
|
|
20
|
+
fs.unlinkSync(npmrcPath);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
catch {
|
|
24
|
+
// Ignore errors silently
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
//# sourceMappingURL=cleanup-registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cleanup-registry.js","sourceRoot":"","sources":["../../src/commands/cleanup-registry.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAE7B,MAAM,YAAY,GAAG,sBAAsB,CAAC;AAE5C,MAAM,CAAC,MAAM,sBAAsB,GAAG,IAAI,OAAO,CAAC,kBAAkB,CAAC;KAClE,WAAW,CAAC,oCAAoC,CAAC;KACjD,MAAM,CAAC,GAAG,EAAE;IACX,IAAI,CAAC;QACH,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,QAAQ,CAAC,CAAC;QAErD,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;YAC9B,OAAO;QACT,CAAC;QAED,MAAM,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;QACpD,MAAM,SAAS,GAAG,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;QAEzC,mDAAmD;QACnD,IAAI,SAAS,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE,CAAC;YACvC,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;QAC3B,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,yBAAyB;IAC3B,CAAC;AACH,CAAC,CAAC,CAAC"}
|
package/dist/commands/config.js
CHANGED
|
@@ -1,78 +1,72 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
2
|
* Config Command - Manage configuration
|
|
4
3
|
*/
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const commander_1 = require("commander");
|
|
11
|
-
const chalk_1 = __importDefault(require("chalk"));
|
|
12
|
-
const core_1 = require("@glpkg/core");
|
|
13
|
-
const adapters_npm_1 = require("@glpkg/adapters.npm");
|
|
14
|
-
exports.configCommand = new commander_1.Command('config')
|
|
4
|
+
import { Command } from 'commander';
|
|
5
|
+
import chalk from 'chalk';
|
|
6
|
+
import { createTokenManager, createConfigManager, createClient, createProxyClient, } from '@glpkg/core';
|
|
7
|
+
import { createNpmrcManager } from '@glpkg/adapters.npm';
|
|
8
|
+
export const configCommand = new Command('config')
|
|
15
9
|
.description('Manage glpkg configuration');
|
|
16
10
|
// ============================================================================
|
|
17
11
|
// Token Commands
|
|
18
12
|
// ============================================================================
|
|
19
13
|
// glpkg config save <token>
|
|
20
|
-
|
|
14
|
+
configCommand
|
|
21
15
|
.command('save <token>')
|
|
22
16
|
.description('Save GitLab token')
|
|
23
17
|
.action((token) => {
|
|
24
18
|
try {
|
|
25
|
-
const tokenManager =
|
|
19
|
+
const tokenManager = createTokenManager();
|
|
26
20
|
tokenManager.saveToken(token);
|
|
27
|
-
console.log(
|
|
21
|
+
console.log(chalk.green('✓'), 'Token saved successfully');
|
|
28
22
|
}
|
|
29
23
|
catch (error) {
|
|
30
|
-
console.error(
|
|
24
|
+
console.error(chalk.red('✗'), 'Failed to save token:', error.message);
|
|
31
25
|
process.exit(1);
|
|
32
26
|
}
|
|
33
27
|
});
|
|
34
28
|
// glpkg config check
|
|
35
|
-
|
|
29
|
+
configCommand
|
|
36
30
|
.command('check')
|
|
37
31
|
.description('Check if token is configured')
|
|
38
32
|
.action(() => {
|
|
39
|
-
const tokenManager =
|
|
33
|
+
const tokenManager = createTokenManager();
|
|
40
34
|
if (tokenManager.hasToken()) {
|
|
41
|
-
console.log(
|
|
35
|
+
console.log(chalk.green('✓'), 'Token is configured');
|
|
42
36
|
}
|
|
43
37
|
else {
|
|
44
|
-
console.log(
|
|
45
|
-
console.log(
|
|
38
|
+
console.log(chalk.yellow('✗'), 'No token found');
|
|
39
|
+
console.log(chalk.gray(' Run: glpkg config save <token>'));
|
|
46
40
|
process.exit(1);
|
|
47
41
|
}
|
|
48
42
|
});
|
|
49
43
|
// glpkg config get
|
|
50
|
-
|
|
44
|
+
configCommand
|
|
51
45
|
.command('get')
|
|
52
46
|
.description('Get saved token')
|
|
53
47
|
.action(() => {
|
|
54
|
-
const tokenManager =
|
|
48
|
+
const tokenManager = createTokenManager();
|
|
55
49
|
const token = tokenManager.getToken();
|
|
56
50
|
if (token) {
|
|
57
51
|
console.log(token);
|
|
58
52
|
}
|
|
59
53
|
else {
|
|
60
|
-
console.error(
|
|
54
|
+
console.error(chalk.red('✗'), 'No token found');
|
|
61
55
|
process.exit(1);
|
|
62
56
|
}
|
|
63
57
|
});
|
|
64
58
|
// glpkg config remove
|
|
65
|
-
|
|
59
|
+
configCommand
|
|
66
60
|
.command('remove')
|
|
67
61
|
.description('Remove saved token')
|
|
68
62
|
.action(() => {
|
|
69
63
|
try {
|
|
70
|
-
const tokenManager =
|
|
64
|
+
const tokenManager = createTokenManager();
|
|
71
65
|
tokenManager.removeToken();
|
|
72
|
-
console.log(
|
|
66
|
+
console.log(chalk.green('✓'), 'Token removed');
|
|
73
67
|
}
|
|
74
68
|
catch (error) {
|
|
75
|
-
console.error(
|
|
69
|
+
console.error(chalk.red('✗'), 'Failed to remove token:', error.message);
|
|
76
70
|
process.exit(1);
|
|
77
71
|
}
|
|
78
72
|
});
|
|
@@ -80,18 +74,18 @@ exports.configCommand
|
|
|
80
74
|
// Scope Commands
|
|
81
75
|
// ============================================================================
|
|
82
76
|
// glpkg config scope set <scope> <group>
|
|
83
|
-
|
|
77
|
+
configCommand
|
|
84
78
|
.command('scope:set <scope> <group>')
|
|
85
79
|
.description('Map a scope to a GitLab group')
|
|
86
80
|
.option('--host <host>', 'GitLab host', 'gitlab.com')
|
|
87
81
|
.option('--no-npmrc', 'Skip updating .npmrc')
|
|
88
82
|
.action(async (scope, group, options) => {
|
|
89
83
|
try {
|
|
90
|
-
const tokenManager =
|
|
91
|
-
const configManager =
|
|
84
|
+
const tokenManager = createTokenManager();
|
|
85
|
+
const configManager = createConfigManager();
|
|
92
86
|
const token = tokenManager.resolveTokenOrNull();
|
|
93
|
-
console.log(
|
|
94
|
-
const client =
|
|
87
|
+
console.log(chalk.gray('○'), `Looking up group "${group}" on ${options.host}...`);
|
|
88
|
+
const client = createClient({ host: options.host, token: token || undefined });
|
|
95
89
|
const groupInfo = await client.getGroup(group);
|
|
96
90
|
const registryUrl = client.buildGroupRegistryUrl(groupInfo.id, 'npm');
|
|
97
91
|
configManager.saveScopeMapping({
|
|
@@ -102,63 +96,63 @@ exports.configCommand
|
|
|
102
96
|
registryUrl,
|
|
103
97
|
createdAt: new Date().toISOString(),
|
|
104
98
|
});
|
|
105
|
-
console.log(
|
|
99
|
+
console.log(chalk.green('✓'), `Scope mapping saved: ${scope} → ${group} (ID: ${groupInfo.id})`);
|
|
106
100
|
// Also update .npmrc for npm compatibility
|
|
107
101
|
if (options.npmrc !== false) {
|
|
108
|
-
const npmrcManager =
|
|
102
|
+
const npmrcManager = createNpmrcManager();
|
|
109
103
|
const normalizedScope = scope.startsWith('@') ? scope : `@${scope}`;
|
|
110
104
|
npmrcManager.addScopeRegistry(normalizedScope, registryUrl);
|
|
111
105
|
npmrcManager.addAuthToken(registryUrl);
|
|
112
|
-
console.log(
|
|
106
|
+
console.log(chalk.green('✓'), `Updated .npmrc: ${normalizedScope} → ${registryUrl}`);
|
|
113
107
|
}
|
|
114
108
|
}
|
|
115
109
|
catch (error) {
|
|
116
|
-
console.error(
|
|
110
|
+
console.error(chalk.red('✗'), 'Failed to set scope:', error.message);
|
|
117
111
|
process.exit(1);
|
|
118
112
|
}
|
|
119
113
|
});
|
|
120
114
|
// glpkg config scope get <scope>
|
|
121
|
-
|
|
115
|
+
configCommand
|
|
122
116
|
.command('scope:get <scope>')
|
|
123
117
|
.description('Get scope mapping')
|
|
124
118
|
.action((scope) => {
|
|
125
|
-
const configManager =
|
|
119
|
+
const configManager = createConfigManager();
|
|
126
120
|
const mapping = configManager.getScopeMapping(scope);
|
|
127
121
|
if (mapping) {
|
|
128
122
|
console.log(JSON.stringify(mapping, null, 2));
|
|
129
123
|
}
|
|
130
124
|
else {
|
|
131
|
-
console.error(
|
|
125
|
+
console.error(chalk.red('✗'), `Scope not found: ${scope}`);
|
|
132
126
|
process.exit(1);
|
|
133
127
|
}
|
|
134
128
|
});
|
|
135
129
|
// glpkg config scope list
|
|
136
|
-
|
|
130
|
+
configCommand
|
|
137
131
|
.command('scope:list')
|
|
138
132
|
.description('List all scope mappings')
|
|
139
133
|
.action(() => {
|
|
140
|
-
const configManager =
|
|
134
|
+
const configManager = createConfigManager();
|
|
141
135
|
const scopes = configManager.getAllScopes();
|
|
142
136
|
if (scopes.length === 0) {
|
|
143
|
-
console.log(
|
|
137
|
+
console.log(chalk.gray('No scope mappings found'));
|
|
144
138
|
}
|
|
145
139
|
else {
|
|
146
140
|
for (const mapping of scopes) {
|
|
147
|
-
console.log(
|
|
141
|
+
console.log(chalk.cyan(`@${mapping.scope}`), '→', mapping.group, chalk.gray(`(ID: ${mapping.groupId})`));
|
|
148
142
|
}
|
|
149
143
|
}
|
|
150
144
|
});
|
|
151
145
|
// glpkg config scope remove <scope>
|
|
152
|
-
|
|
146
|
+
configCommand
|
|
153
147
|
.command('scope:remove <scope>')
|
|
154
148
|
.description('Remove scope mapping')
|
|
155
149
|
.action((scope) => {
|
|
156
|
-
const configManager =
|
|
150
|
+
const configManager = createConfigManager();
|
|
157
151
|
if (configManager.removeScopeMapping(scope)) {
|
|
158
|
-
console.log(
|
|
152
|
+
console.log(chalk.green('✓'), `Scope mapping removed: ${scope}`);
|
|
159
153
|
}
|
|
160
154
|
else {
|
|
161
|
-
console.error(
|
|
155
|
+
console.error(chalk.red('✗'), `Scope not found: ${scope}`);
|
|
162
156
|
process.exit(1);
|
|
163
157
|
}
|
|
164
158
|
});
|
|
@@ -166,50 +160,50 @@ exports.configCommand
|
|
|
166
160
|
// Package Commands
|
|
167
161
|
// ============================================================================
|
|
168
162
|
// glpkg config pkg:list
|
|
169
|
-
|
|
163
|
+
configCommand
|
|
170
164
|
.command('pkg:list')
|
|
171
165
|
.description('List all registered packages')
|
|
172
166
|
.option('-g, --group <group>', 'Filter by group')
|
|
173
167
|
.action((options) => {
|
|
174
|
-
const configManager =
|
|
168
|
+
const configManager = createConfigManager();
|
|
175
169
|
const packages = options.group
|
|
176
170
|
? configManager.searchPackagesByGroup(options.group)
|
|
177
171
|
: configManager.getAllPackages();
|
|
178
172
|
if (packages.length === 0) {
|
|
179
|
-
console.log(
|
|
173
|
+
console.log(chalk.gray('No packages found'));
|
|
180
174
|
}
|
|
181
175
|
else {
|
|
182
176
|
for (const pkg of packages) {
|
|
183
|
-
console.log(
|
|
177
|
+
console.log(chalk.cyan(pkg.packageName), chalk.gray(`(${pkg.registryType})`), pkg.projectPath ? chalk.gray(`→ ${pkg.projectPath}`) : '');
|
|
184
178
|
}
|
|
185
179
|
}
|
|
186
180
|
});
|
|
187
181
|
// glpkg config pkg:get <name>
|
|
188
|
-
|
|
182
|
+
configCommand
|
|
189
183
|
.command('pkg:get <name>')
|
|
190
184
|
.description('Get package info')
|
|
191
185
|
.action((name) => {
|
|
192
|
-
const configManager =
|
|
186
|
+
const configManager = createConfigManager();
|
|
193
187
|
const info = configManager.getPackageInfo(name);
|
|
194
188
|
if (info) {
|
|
195
189
|
console.log(JSON.stringify(info, null, 2));
|
|
196
190
|
}
|
|
197
191
|
else {
|
|
198
|
-
console.error(
|
|
192
|
+
console.error(chalk.red('✗'), `Package not found: ${name}`);
|
|
199
193
|
process.exit(1);
|
|
200
194
|
}
|
|
201
195
|
});
|
|
202
196
|
// glpkg config pkg:remove <name>
|
|
203
|
-
|
|
197
|
+
configCommand
|
|
204
198
|
.command('pkg:remove <name>')
|
|
205
199
|
.description('Remove package info')
|
|
206
200
|
.action((name) => {
|
|
207
|
-
const configManager =
|
|
201
|
+
const configManager = createConfigManager();
|
|
208
202
|
if (configManager.removePackageInfo(name)) {
|
|
209
|
-
console.log(
|
|
203
|
+
console.log(chalk.green('✓'), `Package removed: ${name}`);
|
|
210
204
|
}
|
|
211
205
|
else {
|
|
212
|
-
console.error(
|
|
206
|
+
console.error(chalk.red('✗'), `Package not found: ${name}`);
|
|
213
207
|
process.exit(1);
|
|
214
208
|
}
|
|
215
209
|
});
|
|
@@ -217,73 +211,108 @@ exports.configCommand
|
|
|
217
211
|
// Proxy Commands
|
|
218
212
|
// ============================================================================
|
|
219
213
|
// glpkg config proxy:set <url>
|
|
220
|
-
|
|
214
|
+
configCommand
|
|
221
215
|
.command('proxy:set <url>')
|
|
222
216
|
.description('Set registry proxy URL')
|
|
223
217
|
.action((url) => {
|
|
224
218
|
try {
|
|
225
|
-
const configManager =
|
|
219
|
+
const configManager = createConfigManager();
|
|
226
220
|
configManager.setProxyUrl(url);
|
|
227
|
-
console.log(
|
|
221
|
+
console.log(chalk.green('✓'), `Proxy URL set: ${url}`);
|
|
228
222
|
}
|
|
229
223
|
catch (error) {
|
|
230
|
-
console.error(
|
|
224
|
+
console.error(chalk.red('✗'), 'Failed to set proxy URL:', error.message);
|
|
231
225
|
process.exit(1);
|
|
232
226
|
}
|
|
233
227
|
});
|
|
234
228
|
// glpkg config proxy:enable
|
|
235
|
-
|
|
229
|
+
configCommand
|
|
236
230
|
.command('proxy:enable')
|
|
237
231
|
.description('Enable registry proxy')
|
|
238
232
|
.action(() => {
|
|
239
|
-
const configManager =
|
|
233
|
+
const configManager = createConfigManager();
|
|
240
234
|
const config = configManager.getProxyConfig();
|
|
241
235
|
if (!config.url) {
|
|
242
|
-
console.error(
|
|
236
|
+
console.error(chalk.red('✗'), 'Proxy URL not set. Run: glpkg config proxy:set <url>');
|
|
243
237
|
process.exit(1);
|
|
244
238
|
}
|
|
245
239
|
configManager.enableProxy();
|
|
246
|
-
console.log(
|
|
240
|
+
console.log(chalk.green('✓'), 'Proxy enabled');
|
|
247
241
|
});
|
|
248
242
|
// glpkg config proxy:disable
|
|
249
|
-
|
|
243
|
+
configCommand
|
|
250
244
|
.command('proxy:disable')
|
|
251
245
|
.description('Disable registry proxy')
|
|
252
246
|
.action(() => {
|
|
253
|
-
const configManager =
|
|
247
|
+
const configManager = createConfigManager();
|
|
254
248
|
configManager.disableProxy();
|
|
255
|
-
console.log(
|
|
249
|
+
console.log(chalk.green('✓'), 'Proxy disabled');
|
|
256
250
|
});
|
|
257
251
|
// glpkg config proxy:status
|
|
258
|
-
|
|
252
|
+
configCommand
|
|
259
253
|
.command('proxy:status')
|
|
260
254
|
.description('Show proxy status')
|
|
261
255
|
.option('--check', 'Check proxy health')
|
|
262
256
|
.action(async (options) => {
|
|
263
|
-
const configManager =
|
|
257
|
+
const configManager = createConfigManager();
|
|
264
258
|
const config = configManager.getProxyConfig();
|
|
265
|
-
console.log(
|
|
266
|
-
console.log(` URL: ${config.url ||
|
|
267
|
-
console.log(` Enabled: ${config.enabled ?
|
|
259
|
+
console.log(chalk.bold('Proxy Configuration:'));
|
|
260
|
+
console.log(` URL: ${config.url || chalk.gray('(not set)')}`);
|
|
261
|
+
console.log(` Enabled: ${config.enabled ? chalk.green('yes') : chalk.gray('no')}`);
|
|
268
262
|
if (options.check && config.url) {
|
|
269
263
|
console.log();
|
|
270
|
-
console.log(
|
|
264
|
+
console.log(chalk.gray('○'), 'Checking proxy health...');
|
|
271
265
|
try {
|
|
272
|
-
const proxyClient =
|
|
266
|
+
const proxyClient = createProxyClient({ proxyUrl: config.url });
|
|
273
267
|
const healthy = await proxyClient.healthCheck();
|
|
274
268
|
if (healthy) {
|
|
275
|
-
console.log(
|
|
269
|
+
console.log(chalk.green('✓'), 'Proxy is healthy');
|
|
276
270
|
}
|
|
277
271
|
else {
|
|
278
|
-
console.log(
|
|
272
|
+
console.log(chalk.red('✗'), 'Proxy is not responding');
|
|
279
273
|
}
|
|
280
274
|
}
|
|
281
275
|
catch (error) {
|
|
282
|
-
console.log(
|
|
276
|
+
console.log(chalk.red('✗'), 'Failed to check proxy:', error.message);
|
|
283
277
|
}
|
|
284
278
|
}
|
|
285
279
|
});
|
|
286
280
|
// ============================================================================
|
|
281
|
+
// Hooks Commands
|
|
282
|
+
// ============================================================================
|
|
283
|
+
// glpkg config hooks:enable
|
|
284
|
+
configCommand
|
|
285
|
+
.command('hooks:enable')
|
|
286
|
+
.description('Enable automatic hooks injection in package.json')
|
|
287
|
+
.action(() => {
|
|
288
|
+
const configManager = createConfigManager();
|
|
289
|
+
configManager.setHooksEnabled(true);
|
|
290
|
+
console.log(chalk.green('✓'), 'Hooks injection enabled');
|
|
291
|
+
});
|
|
292
|
+
// glpkg config hooks:disable
|
|
293
|
+
configCommand
|
|
294
|
+
.command('hooks:disable')
|
|
295
|
+
.description('Disable automatic hooks injection in package.json')
|
|
296
|
+
.action(() => {
|
|
297
|
+
const configManager = createConfigManager();
|
|
298
|
+
configManager.setHooksEnabled(false);
|
|
299
|
+
console.log(chalk.green('✓'), 'Hooks injection disabled');
|
|
300
|
+
});
|
|
301
|
+
// glpkg config hooks:status
|
|
302
|
+
configCommand
|
|
303
|
+
.command('hooks:status')
|
|
304
|
+
.description('Show hooks injection status')
|
|
305
|
+
.action(() => {
|
|
306
|
+
const configManager = createConfigManager();
|
|
307
|
+
const enabled = configManager.getHooksEnabled();
|
|
308
|
+
if (enabled) {
|
|
309
|
+
console.log(chalk.green('✓'), 'Hooks injection is', chalk.green('enabled'));
|
|
310
|
+
}
|
|
311
|
+
else {
|
|
312
|
+
console.log(chalk.gray('○'), 'Hooks injection is', chalk.gray('disabled'));
|
|
313
|
+
}
|
|
314
|
+
});
|
|
315
|
+
// ============================================================================
|
|
287
316
|
// Defaults Commands
|
|
288
317
|
// ============================================================================
|
|
289
318
|
const VALID_DEFAULT_KEYS = [
|
|
@@ -330,56 +359,56 @@ function formatDefaultValue(value) {
|
|
|
330
359
|
return String(value);
|
|
331
360
|
}
|
|
332
361
|
// glpkg config defaults [key] [value]
|
|
333
|
-
|
|
362
|
+
configCommand
|
|
334
363
|
.command('defaults [key] [value]')
|
|
335
364
|
.description('View or set default configuration values')
|
|
336
365
|
.option('--reset <key>', 'Reset a specific default to its built-in value')
|
|
337
366
|
.option('--reset-all', 'Reset all defaults to built-in values')
|
|
338
367
|
.action((key, value, options) => {
|
|
339
|
-
const configManager =
|
|
368
|
+
const configManager = createConfigManager();
|
|
340
369
|
// Handle --reset-all
|
|
341
370
|
if (options.resetAll) {
|
|
342
371
|
configManager.resetAllDefaults();
|
|
343
|
-
console.log(
|
|
372
|
+
console.log(chalk.green('✓'), 'All defaults reset to built-in values');
|
|
344
373
|
return;
|
|
345
374
|
}
|
|
346
375
|
// Handle --reset <key>
|
|
347
376
|
if (options.reset) {
|
|
348
377
|
if (!isValidDefaultKey(options.reset)) {
|
|
349
|
-
console.error(
|
|
350
|
-
console.log(
|
|
378
|
+
console.error(chalk.red('✗'), `Invalid key: ${options.reset}`);
|
|
379
|
+
console.log(chalk.gray('Valid keys:'), VALID_DEFAULT_KEYS.join(', '));
|
|
351
380
|
process.exit(1);
|
|
352
381
|
}
|
|
353
382
|
if (configManager.resetDefault(options.reset)) {
|
|
354
|
-
console.log(
|
|
383
|
+
console.log(chalk.green('✓'), `Reset ${options.reset} to built-in default: ${DEFAULT_VALUES[options.reset]}`);
|
|
355
384
|
}
|
|
356
385
|
else {
|
|
357
|
-
console.log(
|
|
386
|
+
console.log(chalk.gray('○'), `${options.reset} was not set (already using built-in default)`);
|
|
358
387
|
}
|
|
359
388
|
return;
|
|
360
389
|
}
|
|
361
390
|
// No key: show all defaults
|
|
362
391
|
if (!key) {
|
|
363
392
|
const defaults = configManager.getDefaults();
|
|
364
|
-
console.log(
|
|
393
|
+
console.log(chalk.bold('Default Configuration:'));
|
|
365
394
|
console.log();
|
|
366
395
|
for (const k of VALID_DEFAULT_KEYS) {
|
|
367
396
|
const currentValue = configManager.getDefault(k);
|
|
368
397
|
const isSet = currentValue !== undefined;
|
|
369
398
|
const displayValue = isSet ? formatDefaultValue(currentValue) : DEFAULT_VALUES[k];
|
|
370
|
-
const status = isSet ?
|
|
371
|
-
console.log(` ${
|
|
399
|
+
const status = isSet ? chalk.cyan(displayValue) : chalk.gray(displayValue + ' (built-in)');
|
|
400
|
+
console.log(` ${chalk.white(k.padEnd(20))} ${status}`);
|
|
372
401
|
}
|
|
373
402
|
console.log();
|
|
374
|
-
console.log(
|
|
375
|
-
console.log(
|
|
376
|
-
console.log(
|
|
403
|
+
console.log(chalk.gray('Set a value:'), 'glpkg config defaults <key> <value>');
|
|
404
|
+
console.log(chalk.gray('Reset a value:'), 'glpkg config defaults --reset <key>');
|
|
405
|
+
console.log(chalk.gray('Reset all:'), 'glpkg config defaults --reset-all');
|
|
377
406
|
return;
|
|
378
407
|
}
|
|
379
408
|
// Key provided: get or set
|
|
380
409
|
if (!isValidDefaultKey(key)) {
|
|
381
|
-
console.error(
|
|
382
|
-
console.log(
|
|
410
|
+
console.error(chalk.red('✗'), `Invalid key: ${key}`);
|
|
411
|
+
console.log(chalk.gray('Valid keys:'), VALID_DEFAULT_KEYS.join(', '));
|
|
383
412
|
process.exit(1);
|
|
384
413
|
}
|
|
385
414
|
// No value: show current value
|
|
@@ -389,7 +418,7 @@ exports.configCommand
|
|
|
389
418
|
console.log(formatDefaultValue(currentValue));
|
|
390
419
|
}
|
|
391
420
|
else {
|
|
392
|
-
console.log(
|
|
421
|
+
console.log(chalk.gray(`(not set, built-in: ${DEFAULT_VALUES[key]})`));
|
|
393
422
|
}
|
|
394
423
|
return;
|
|
395
424
|
}
|
|
@@ -397,10 +426,10 @@ exports.configCommand
|
|
|
397
426
|
try {
|
|
398
427
|
const parsedValue = parseDefaultValue(key, value);
|
|
399
428
|
configManager.setDefault(key, parsedValue);
|
|
400
|
-
console.log(
|
|
429
|
+
console.log(chalk.green('✓'), `Set ${key} = ${formatDefaultValue(parsedValue)}`);
|
|
401
430
|
}
|
|
402
431
|
catch (error) {
|
|
403
|
-
console.error(
|
|
432
|
+
console.error(chalk.red('✗'), error.message);
|
|
404
433
|
process.exit(1);
|
|
405
434
|
}
|
|
406
435
|
});
|