@glpkg/cli 0.2.1 → 0.3.10

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 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
- Object.defineProperty(exports, "__esModule", { value: true });
7
- const commander_1 = require("commander");
8
- const index_js_1 = require("./commands/index.js");
9
- const program = new commander_1.Command();
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('0.1.0');
14
+ .version(version);
14
15
  // Register commands
15
- program.addCommand(index_js_1.installCommand);
16
- program.addCommand(index_js_1.publishCommand);
17
- program.addCommand(index_js_1.configCommand);
18
- program.addCommand(index_js_1.licenseCommand);
19
- program.addCommand(index_js_1.repoCommand);
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":";;AACA;;GAEG;;AAEH,yCAAoC;AACpC,kDAAiH;AAEjH,MAAM,OAAO,GAAG,IAAI,mBAAO,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,yBAAc,CAAC,CAAC;AACnC,OAAO,CAAC,UAAU,CAAC,yBAAc,CAAC,CAAC;AACnC,OAAO,CAAC,UAAU,CAAC,wBAAa,CAAC,CAAC;AAClC,OAAO,CAAC,UAAU,CAAC,yBAAc,CAAC,CAAC;AACnC,OAAO,CAAC,UAAU,CAAC,sBAAW,CAAC,CAAC;AAEhC,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"}
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,6 @@
1
+ /**
2
+ * Cleanup Registry Command - Remove glpkg-generated .npmrc
3
+ */
4
+ import { Command } from 'commander';
5
+ export declare const cleanupRegistryCommand: Command;
6
+ //# sourceMappingURL=cleanup-registry.d.ts.map
@@ -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"}
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/commands/config.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAUpC,eAAO,MAAM,aAAa,SACkB,CAAC"}
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/commands/config.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAYpC,eAAO,MAAM,aAAa,SACkB,CAAC"}
@@ -1,78 +1,72 @@
1
- "use strict";
2
1
  /**
3
2
  * Config Command - Manage configuration
4
3
  */
5
- var __importDefault = (this && this.__importDefault) || function (mod) {
6
- return (mod && mod.__esModule) ? mod : { "default": mod };
7
- };
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.configCommand = void 0;
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
- exports.configCommand
14
+ configCommand
21
15
  .command('save <token>')
22
16
  .description('Save GitLab token')
23
17
  .action((token) => {
24
18
  try {
25
- const tokenManager = (0, core_1.createTokenManager)();
19
+ const tokenManager = createTokenManager();
26
20
  tokenManager.saveToken(token);
27
- console.log(chalk_1.default.green('✓'), 'Token saved successfully');
21
+ console.log(chalk.green('✓'), 'Token saved successfully');
28
22
  }
29
23
  catch (error) {
30
- console.error(chalk_1.default.red('✗'), 'Failed to save token:', error.message);
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
- exports.configCommand
29
+ configCommand
36
30
  .command('check')
37
31
  .description('Check if token is configured')
38
32
  .action(() => {
39
- const tokenManager = (0, core_1.createTokenManager)();
33
+ const tokenManager = createTokenManager();
40
34
  if (tokenManager.hasToken()) {
41
- console.log(chalk_1.default.green('✓'), 'Token is configured');
35
+ console.log(chalk.green('✓'), 'Token is configured');
42
36
  }
43
37
  else {
44
- console.log(chalk_1.default.yellow('✗'), 'No token found');
45
- console.log(chalk_1.default.gray(' Run: glpkg config save <token>'));
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
- exports.configCommand
44
+ configCommand
51
45
  .command('get')
52
46
  .description('Get saved token')
53
47
  .action(() => {
54
- const tokenManager = (0, core_1.createTokenManager)();
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(chalk_1.default.red('✗'), 'No token found');
54
+ console.error(chalk.red('✗'), 'No token found');
61
55
  process.exit(1);
62
56
  }
63
57
  });
64
58
  // glpkg config remove
65
- exports.configCommand
59
+ configCommand
66
60
  .command('remove')
67
61
  .description('Remove saved token')
68
62
  .action(() => {
69
63
  try {
70
- const tokenManager = (0, core_1.createTokenManager)();
64
+ const tokenManager = createTokenManager();
71
65
  tokenManager.removeToken();
72
- console.log(chalk_1.default.green('✓'), 'Token removed');
66
+ console.log(chalk.green('✓'), 'Token removed');
73
67
  }
74
68
  catch (error) {
75
- console.error(chalk_1.default.red('✗'), 'Failed to remove token:', error.message);
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
- exports.configCommand
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 = (0, core_1.createTokenManager)();
91
- const configManager = (0, core_1.createConfigManager)();
84
+ const tokenManager = createTokenManager();
85
+ const configManager = createConfigManager();
92
86
  const token = tokenManager.resolveTokenOrNull();
93
- console.log(chalk_1.default.gray('○'), `Looking up group "${group}" on ${options.host}...`);
94
- const client = (0, core_1.createClient)({ host: options.host, token: token || undefined });
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(chalk_1.default.green('✓'), `Scope mapping saved: ${scope} → ${group} (ID: ${groupInfo.id})`);
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 = (0, adapters_npm_1.createNpmrcManager)();
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(chalk_1.default.green('✓'), `Updated .npmrc: ${normalizedScope} → ${registryUrl}`);
106
+ console.log(chalk.green('✓'), `Updated .npmrc: ${normalizedScope} → ${registryUrl}`);
113
107
  }
114
108
  }
115
109
  catch (error) {
116
- console.error(chalk_1.default.red('✗'), 'Failed to set scope:', error.message);
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
- exports.configCommand
115
+ configCommand
122
116
  .command('scope:get <scope>')
123
117
  .description('Get scope mapping')
124
118
  .action((scope) => {
125
- const configManager = (0, core_1.createConfigManager)();
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(chalk_1.default.red('✗'), `Scope not found: ${scope}`);
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
- exports.configCommand
130
+ configCommand
137
131
  .command('scope:list')
138
132
  .description('List all scope mappings')
139
133
  .action(() => {
140
- const configManager = (0, core_1.createConfigManager)();
134
+ const configManager = createConfigManager();
141
135
  const scopes = configManager.getAllScopes();
142
136
  if (scopes.length === 0) {
143
- console.log(chalk_1.default.gray('No scope mappings found'));
137
+ console.log(chalk.gray('No scope mappings found'));
144
138
  }
145
139
  else {
146
140
  for (const mapping of scopes) {
147
- console.log(chalk_1.default.cyan(`@${mapping.scope}`), '→', mapping.group, chalk_1.default.gray(`(ID: ${mapping.groupId})`));
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
- exports.configCommand
146
+ configCommand
153
147
  .command('scope:remove <scope>')
154
148
  .description('Remove scope mapping')
155
149
  .action((scope) => {
156
- const configManager = (0, core_1.createConfigManager)();
150
+ const configManager = createConfigManager();
157
151
  if (configManager.removeScopeMapping(scope)) {
158
- console.log(chalk_1.default.green('✓'), `Scope mapping removed: ${scope}`);
152
+ console.log(chalk.green('✓'), `Scope mapping removed: ${scope}`);
159
153
  }
160
154
  else {
161
- console.error(chalk_1.default.red('✗'), `Scope not found: ${scope}`);
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
- exports.configCommand
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 = (0, core_1.createConfigManager)();
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(chalk_1.default.gray('No packages found'));
173
+ console.log(chalk.gray('No packages found'));
180
174
  }
181
175
  else {
182
176
  for (const pkg of packages) {
183
- console.log(chalk_1.default.cyan(pkg.packageName), chalk_1.default.gray(`(${pkg.registryType})`), pkg.projectPath ? chalk_1.default.gray(`→ ${pkg.projectPath}`) : '');
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
- exports.configCommand
182
+ configCommand
189
183
  .command('pkg:get <name>')
190
184
  .description('Get package info')
191
185
  .action((name) => {
192
- const configManager = (0, core_1.createConfigManager)();
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(chalk_1.default.red('✗'), `Package not found: ${name}`);
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
- exports.configCommand
197
+ configCommand
204
198
  .command('pkg:remove <name>')
205
199
  .description('Remove package info')
206
200
  .action((name) => {
207
- const configManager = (0, core_1.createConfigManager)();
201
+ const configManager = createConfigManager();
208
202
  if (configManager.removePackageInfo(name)) {
209
- console.log(chalk_1.default.green('✓'), `Package removed: ${name}`);
203
+ console.log(chalk.green('✓'), `Package removed: ${name}`);
210
204
  }
211
205
  else {
212
- console.error(chalk_1.default.red('✗'), `Package not found: ${name}`);
206
+ console.error(chalk.red('✗'), `Package not found: ${name}`);
213
207
  process.exit(1);
214
208
  }
215
209
  });
@@ -217,70 +211,226 @@ exports.configCommand
217
211
  // Proxy Commands
218
212
  // ============================================================================
219
213
  // glpkg config proxy:set <url>
220
- exports.configCommand
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 = (0, core_1.createConfigManager)();
219
+ const configManager = createConfigManager();
226
220
  configManager.setProxyUrl(url);
227
- console.log(chalk_1.default.green('✓'), `Proxy URL set: ${url}`);
221
+ console.log(chalk.green('✓'), `Proxy URL set: ${url}`);
228
222
  }
229
223
  catch (error) {
230
- console.error(chalk_1.default.red('✗'), 'Failed to set proxy URL:', error.message);
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
- exports.configCommand
229
+ configCommand
236
230
  .command('proxy:enable')
237
231
  .description('Enable registry proxy')
238
232
  .action(() => {
239
- const configManager = (0, core_1.createConfigManager)();
233
+ const configManager = createConfigManager();
240
234
  const config = configManager.getProxyConfig();
241
235
  if (!config.url) {
242
- console.error(chalk_1.default.red('✗'), 'Proxy URL not set. Run: glpkg config proxy:set <url>');
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(chalk_1.default.green('✓'), 'Proxy enabled');
240
+ console.log(chalk.green('✓'), 'Proxy enabled');
247
241
  });
248
242
  // glpkg config proxy:disable
249
- exports.configCommand
243
+ configCommand
250
244
  .command('proxy:disable')
251
245
  .description('Disable registry proxy')
252
246
  .action(() => {
253
- const configManager = (0, core_1.createConfigManager)();
247
+ const configManager = createConfigManager();
254
248
  configManager.disableProxy();
255
- console.log(chalk_1.default.green('✓'), 'Proxy disabled');
249
+ console.log(chalk.green('✓'), 'Proxy disabled');
256
250
  });
257
251
  // glpkg config proxy:status
258
- exports.configCommand
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 = (0, core_1.createConfigManager)();
257
+ const configManager = createConfigManager();
264
258
  const config = configManager.getProxyConfig();
265
- console.log(chalk_1.default.bold('Proxy Configuration:'));
266
- console.log(` URL: ${config.url || chalk_1.default.gray('(not set)')}`);
267
- console.log(` Enabled: ${config.enabled ? chalk_1.default.green('yes') : chalk_1.default.gray('no')}`);
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(chalk_1.default.gray('○'), 'Checking proxy health...');
264
+ console.log(chalk.gray('○'), 'Checking proxy health...');
271
265
  try {
272
- const proxyClient = (0, core_1.createProxyClient)({ proxyUrl: config.url });
266
+ const proxyClient = createProxyClient({ proxyUrl: config.url });
273
267
  const healthy = await proxyClient.healthCheck();
274
268
  if (healthy) {
275
- console.log(chalk_1.default.green('✓'), 'Proxy is healthy');
269
+ console.log(chalk.green('✓'), 'Proxy is healthy');
276
270
  }
277
271
  else {
278
- console.log(chalk_1.default.red('✗'), 'Proxy is not responding');
272
+ console.log(chalk.red('✗'), 'Proxy is not responding');
279
273
  }
280
274
  }
281
275
  catch (error) {
282
- console.log(chalk_1.default.red('✗'), 'Failed to check proxy:', error.message);
276
+ console.log(chalk.red('✗'), 'Failed to check proxy:', error.message);
283
277
  }
284
278
  }
285
279
  });
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
+ // ============================================================================
316
+ // Defaults Commands
317
+ // ============================================================================
318
+ const VALID_DEFAULT_KEYS = [
319
+ 'host',
320
+ 'repo.visibility',
321
+ 'repo.createGroups',
322
+ 'publish.gitTag',
323
+ 'publish.push',
324
+ ];
325
+ const DEFAULT_VALUES = {
326
+ 'host': 'gitlab.com',
327
+ 'repo.visibility': 'private',
328
+ 'repo.createGroups': 'false',
329
+ 'publish.gitTag': 'true',
330
+ 'publish.push': 'true',
331
+ };
332
+ function isValidDefaultKey(key) {
333
+ return VALID_DEFAULT_KEYS.includes(key);
334
+ }
335
+ function parseDefaultValue(key, value) {
336
+ switch (key) {
337
+ case 'host':
338
+ return value;
339
+ case 'repo.visibility':
340
+ if (!['private', 'internal', 'public'].includes(value)) {
341
+ throw new Error(`Invalid visibility: ${value}. Must be: private, internal, public`);
342
+ }
343
+ return value;
344
+ case 'repo.createGroups':
345
+ case 'publish.gitTag':
346
+ case 'publish.push':
347
+ if (!['true', 'false'].includes(value.toLowerCase())) {
348
+ throw new Error(`Invalid boolean value: ${value}. Must be: true, false`);
349
+ }
350
+ return value.toLowerCase() === 'true';
351
+ default:
352
+ return value;
353
+ }
354
+ }
355
+ function formatDefaultValue(value) {
356
+ if (typeof value === 'boolean') {
357
+ return value ? 'true' : 'false';
358
+ }
359
+ return String(value);
360
+ }
361
+ // glpkg config defaults [key] [value]
362
+ configCommand
363
+ .command('defaults [key] [value]')
364
+ .description('View or set default configuration values')
365
+ .option('--reset <key>', 'Reset a specific default to its built-in value')
366
+ .option('--reset-all', 'Reset all defaults to built-in values')
367
+ .action((key, value, options) => {
368
+ const configManager = createConfigManager();
369
+ // Handle --reset-all
370
+ if (options.resetAll) {
371
+ configManager.resetAllDefaults();
372
+ console.log(chalk.green('✓'), 'All defaults reset to built-in values');
373
+ return;
374
+ }
375
+ // Handle --reset <key>
376
+ if (options.reset) {
377
+ if (!isValidDefaultKey(options.reset)) {
378
+ console.error(chalk.red('✗'), `Invalid key: ${options.reset}`);
379
+ console.log(chalk.gray('Valid keys:'), VALID_DEFAULT_KEYS.join(', '));
380
+ process.exit(1);
381
+ }
382
+ if (configManager.resetDefault(options.reset)) {
383
+ console.log(chalk.green('✓'), `Reset ${options.reset} to built-in default: ${DEFAULT_VALUES[options.reset]}`);
384
+ }
385
+ else {
386
+ console.log(chalk.gray('○'), `${options.reset} was not set (already using built-in default)`);
387
+ }
388
+ return;
389
+ }
390
+ // No key: show all defaults
391
+ if (!key) {
392
+ const defaults = configManager.getDefaults();
393
+ console.log(chalk.bold('Default Configuration:'));
394
+ console.log();
395
+ for (const k of VALID_DEFAULT_KEYS) {
396
+ const currentValue = configManager.getDefault(k);
397
+ const isSet = currentValue !== undefined;
398
+ const displayValue = isSet ? formatDefaultValue(currentValue) : DEFAULT_VALUES[k];
399
+ const status = isSet ? chalk.cyan(displayValue) : chalk.gray(displayValue + ' (built-in)');
400
+ console.log(` ${chalk.white(k.padEnd(20))} ${status}`);
401
+ }
402
+ 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');
406
+ return;
407
+ }
408
+ // Key provided: get or set
409
+ if (!isValidDefaultKey(key)) {
410
+ console.error(chalk.red('✗'), `Invalid key: ${key}`);
411
+ console.log(chalk.gray('Valid keys:'), VALID_DEFAULT_KEYS.join(', '));
412
+ process.exit(1);
413
+ }
414
+ // No value: show current value
415
+ if (value === undefined) {
416
+ const currentValue = configManager.getDefault(key);
417
+ if (currentValue !== undefined) {
418
+ console.log(formatDefaultValue(currentValue));
419
+ }
420
+ else {
421
+ console.log(chalk.gray(`(not set, built-in: ${DEFAULT_VALUES[key]})`));
422
+ }
423
+ return;
424
+ }
425
+ // Set value
426
+ try {
427
+ const parsedValue = parseDefaultValue(key, value);
428
+ configManager.setDefault(key, parsedValue);
429
+ console.log(chalk.green('✓'), `Set ${key} = ${formatDefaultValue(parsedValue)}`);
430
+ }
431
+ catch (error) {
432
+ console.error(chalk.red('✗'), error.message);
433
+ process.exit(1);
434
+ }
435
+ });
286
436
  //# sourceMappingURL=config.js.map