@intranefr/superbackend 1.6.7 → 1.7.8
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/.beads/.br_history/issues.20260314_212352_900045509.jsonl +0 -0
- package/.beads/.br_history/issues.20260314_212352_900045509.jsonl.meta.json +1 -0
- package/.beads/.br_history/issues.20260314_212353_087140743.jsonl +1 -0
- package/.beads/.br_history/issues.20260314_212353_087140743.jsonl.meta.json +1 -0
- package/.beads/.br_history/issues.20260314_212353_285881504.jsonl +2 -0
- package/.beads/.br_history/issues.20260314_212353_285881504.jsonl.meta.json +1 -0
- package/.beads/.br_history/issues.20260314_212353_473915419.jsonl +3 -0
- package/.beads/.br_history/issues.20260314_212353_473915419.jsonl.meta.json +1 -0
- package/.beads/.br_history/issues.20260314_212353_659476307.jsonl +4 -0
- package/.beads/.br_history/issues.20260314_212353_659476307.jsonl.meta.json +1 -0
- package/.beads/.br_history/issues.20260314_212353_869998925.jsonl +5 -0
- package/.beads/.br_history/issues.20260314_212353_869998925.jsonl.meta.json +1 -0
- package/.beads/.br_history/issues.20260314_212354_054785029.jsonl +6 -0
- package/.beads/.br_history/issues.20260314_212354_054785029.jsonl.meta.json +1 -0
- package/.beads/.br_history/issues.20260314_213336_175893691.jsonl +7 -0
- package/.beads/.br_history/issues.20260314_213336_175893691.jsonl.meta.json +1 -0
- package/.beads/.br_history/issues.20260314_213336_338509797.jsonl +7 -0
- package/.beads/.br_history/issues.20260314_213336_338509797.jsonl.meta.json +1 -0
- package/.beads/.br_history/issues.20260314_213336_515443192.jsonl +7 -0
- package/.beads/.br_history/issues.20260314_213336_515443192.jsonl.meta.json +1 -0
- package/.beads/.br_history/issues.20260314_213336_676417592.jsonl +7 -0
- package/.beads/.br_history/issues.20260314_213336_676417592.jsonl.meta.json +1 -0
- package/.beads/.br_history/issues.20260314_213336_839182422.jsonl +7 -0
- package/.beads/.br_history/issues.20260314_213336_839182422.jsonl.meta.json +1 -0
- package/.beads/.br_history/issues.20260314_213337_004349113.jsonl +7 -0
- package/.beads/.br_history/issues.20260314_213337_004349113.jsonl.meta.json +1 -0
- package/.beads/.br_history/issues.20260314_213337_179824080.jsonl +7 -0
- package/.beads/.br_history/issues.20260314_213337_179824080.jsonl.meta.json +1 -0
- package/.beads/.br_history/issues.20260314_213701_705075332.jsonl +7 -0
- package/.beads/.br_history/issues.20260314_213701_705075332.jsonl.meta.json +1 -0
- package/.beads/.br_history/issues.20260314_213706_783128702.jsonl +8 -0
- package/.beads/.br_history/issues.20260314_213706_783128702.jsonl.meta.json +1 -0
- package/.beads/config.yaml +4 -0
- package/.beads/issues.jsonl +8 -0
- package/.beads/metadata.json +4 -0
- package/.env.example +8 -0
- package/autochangelog/.env.example +36 -0
- package/autochangelog/README.md +412 -0
- package/autochangelog/config/database.js +27 -0
- package/autochangelog/package.json +47 -0
- package/autochangelog/public/landing.html +581 -0
- package/autochangelog/server.js +104 -0
- package/autochangelog/src/app.js +181 -0
- package/autochangelog/src/config/database.js +26 -0
- package/autochangelog/src/controllers/auth.js +488 -0
- package/autochangelog/src/controllers/changelog.js +682 -0
- package/autochangelog/src/controllers/project.js +580 -0
- package/autochangelog/src/controllers/repository.js +780 -0
- package/autochangelog/src/middleware/auth.js +386 -0
- package/autochangelog/src/models/Changelog.js +443 -0
- package/autochangelog/src/models/Project.js +226 -0
- package/autochangelog/src/models/Repository.js +366 -0
- package/autochangelog/src/models/User.js +223 -0
- package/autochangelog/src/routes/auth.routes.js +32 -0
- package/autochangelog/src/routes/changelog.routes.js +42 -0
- package/autochangelog/src/routes/github-auth.routes.js +102 -0
- package/autochangelog/src/routes/project.routes.js +50 -0
- package/autochangelog/src/routes/repository.routes.js +54 -0
- package/autochangelog/src/services/changelog.js +722 -0
- package/autochangelog/src/services/github.js +243 -0
- package/autochangelog/utils/logger.js +77 -0
- package/autochangelog/views/404.ejs +18 -0
- package/autochangelog/views/dashboard.ejs +596 -0
- package/autochangelog/views/index.ejs +231 -0
- package/autochangelog/views/layouts/main.ejs +44 -0
- package/autochangelog/views/login.ejs +104 -0
- package/autochangelog/views/partials/footer.ejs +20 -0
- package/autochangelog/views/partials/navbar.ejs +51 -0
- package/autochangelog/views/register.ejs +109 -0
- package/autochangelog-cli/README.md +266 -0
- package/autochangelog-cli/bin/autochangelog +120 -0
- package/autochangelog-cli/package.json +46 -0
- package/autochangelog-cli/src/cli/commands/auth.js +291 -0
- package/autochangelog-cli/src/cli/commands/changelog.js +619 -0
- package/autochangelog-cli/src/cli/commands/project.js +427 -0
- package/autochangelog-cli/src/cli/commands/repo.js +557 -0
- package/autochangelog-cli/src/cli/commands/stats.js +706 -0
- package/autochangelog-cli/src/cli/utils/config.js +277 -0
- package/autochangelog-cli/src/cli/utils/errors.js +307 -0
- package/autochangelog-cli/src/cli/utils/logger.js +75 -0
- package/autochangelog-cli/src/cli/utils/output.js +357 -0
- package/package.json +9 -3
- package/plugins/supercli/README.md +108 -0
- package/plugins/supercli/plugin.json +123 -0
- package/server.js +1 -1
- package/src/cli/api.js +380 -0
- package/src/cli/direct/agent-utils.js +61 -0
- package/src/cli/direct/cli-utils.js +112 -0
- package/src/cli/direct/data-seeding.js +307 -0
- package/src/cli/direct/db-admin.js +84 -0
- package/src/cli/direct/db-advanced.js +372 -0
- package/src/cli/direct/db-utils.js +558 -0
- package/src/cli/direct/help.js +195 -0
- package/src/cli/direct/migration.js +107 -0
- package/src/cli/direct/rbac-advanced.js +132 -0
- package/src/cli/direct/resources-additional.js +400 -0
- package/src/cli/direct/resources-cms-advanced.js +173 -0
- package/src/cli/direct/resources-cms.js +247 -0
- package/src/cli/direct/resources-core.js +253 -0
- package/src/cli/direct/resources-execution.js +367 -0
- package/src/cli/direct/resources-health.js +152 -0
- package/src/cli/direct/resources-integrations.js +182 -0
- package/src/cli/direct/resources-logs.js +204 -0
- package/src/cli/direct/resources-org-rbac.js +187 -0
- package/src/cli/direct/resources-system.js +236 -0
- package/src/cli/direct.js +556 -0
- package/src/controllers/admin.controller.js +4 -0
- package/src/controllers/auth.controller.js +148 -1
- package/src/controllers/waitingList.controller.js +130 -1
- package/src/models/RbacRole.js +1 -1
- package/src/models/User.js +39 -5
- package/src/routes/auth.routes.js +6 -0
- package/src/routes/waitingList.routes.js +12 -2
- package/src/routes/waitingListAdmin.routes.js +3 -0
- package/src/services/email.service.js +1 -0
- package/src/services/github.service.js +255 -0
- package/src/services/rateLimiter.service.js +29 -1
- package/src/services/waitingListJson.service.js +32 -3
- package/views/admin-waiting-list.ejs +386 -3
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
const { Command } = require('commander');
|
|
2
|
+
const chalk = require('chalk');
|
|
3
|
+
const inquirer = require('inquirer');
|
|
4
|
+
const { output } = require('../utils/output');
|
|
5
|
+
const { handleCliError, validateRequiredArgs, ERROR_CODES } = require('../utils/errors');
|
|
6
|
+
const { loadConfig, saveConfig, getAuthToken, setAuthToken, clearAuthToken, isAuthenticated } = require('../utils/config');
|
|
7
|
+
const { setupLogger } = require('../utils/logger');
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Authentication commands for AutoChangelog CLI
|
|
11
|
+
* Handles GitHub OAuth authentication and token management
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
function setupAuthCommands(program) {
|
|
15
|
+
const auth = program
|
|
16
|
+
.command('auth')
|
|
17
|
+
.description('Authentication management');
|
|
18
|
+
|
|
19
|
+
// Login command
|
|
20
|
+
auth
|
|
21
|
+
.command('login')
|
|
22
|
+
.description('Authenticate with GitHub')
|
|
23
|
+
.option('--token <token>', 'GitHub personal access token')
|
|
24
|
+
.option('--client-id <id>', 'GitHub OAuth App client ID')
|
|
25
|
+
.option('--client-secret <secret>', 'GitHub OAuth App client secret')
|
|
26
|
+
.action(async (options) => {
|
|
27
|
+
const logger = setupLogger();
|
|
28
|
+
const config = loadConfig();
|
|
29
|
+
|
|
30
|
+
try {
|
|
31
|
+
// Check if already authenticated
|
|
32
|
+
if (isAuthenticated()) {
|
|
33
|
+
output.success('Already authenticated');
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
let token;
|
|
38
|
+
|
|
39
|
+
if (options.token) {
|
|
40
|
+
// Use provided token
|
|
41
|
+
token = options.token;
|
|
42
|
+
} else if (options.clientId && options.clientSecret) {
|
|
43
|
+
// Use OAuth flow
|
|
44
|
+
token = await performOAuthFlow(options.clientId, options.clientSecret, logger);
|
|
45
|
+
} else {
|
|
46
|
+
// Interactive mode
|
|
47
|
+
token = await interactiveLogin(logger);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (token) {
|
|
51
|
+
// Validate token
|
|
52
|
+
const isValid = await validateToken(token, logger);
|
|
53
|
+
|
|
54
|
+
if (isValid) {
|
|
55
|
+
setAuthToken(token);
|
|
56
|
+
output.success('Authentication successful');
|
|
57
|
+
|
|
58
|
+
// Save additional config if provided
|
|
59
|
+
if (options.clientId) {
|
|
60
|
+
saveConfig({ github_client_id: options.clientId });
|
|
61
|
+
}
|
|
62
|
+
if (options.clientSecret) {
|
|
63
|
+
saveConfig({ github_client_secret: options.clientSecret });
|
|
64
|
+
}
|
|
65
|
+
} else {
|
|
66
|
+
output.error('Invalid GitHub token. Please check your token permissions.');
|
|
67
|
+
process.exit(ERROR_CODES.AUTHENTICATION_FAILED);
|
|
68
|
+
}
|
|
69
|
+
} else {
|
|
70
|
+
output.error('Authentication failed');
|
|
71
|
+
process.exit(ERROR_CODES.AUTHENTICATION_FAILED);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
} catch (error) {
|
|
75
|
+
handleCliError(error, output);
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
// Logout command
|
|
80
|
+
auth
|
|
81
|
+
.command('logout')
|
|
82
|
+
.description('Logout and clear authentication')
|
|
83
|
+
.action(async () => {
|
|
84
|
+
try {
|
|
85
|
+
if (!isAuthenticated()) {
|
|
86
|
+
output.warning('Not currently authenticated');
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
clearAuthToken();
|
|
91
|
+
output.success('Logged out successfully');
|
|
92
|
+
} catch (error) {
|
|
93
|
+
handleCliError(error, output);
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
// Status command
|
|
98
|
+
auth
|
|
99
|
+
.command('status')
|
|
100
|
+
.description('Show current authentication status')
|
|
101
|
+
.action(async () => {
|
|
102
|
+
try {
|
|
103
|
+
const token = getAuthToken();
|
|
104
|
+
|
|
105
|
+
if (token) {
|
|
106
|
+
const config = loadConfig();
|
|
107
|
+
const isValid = await validateToken(token);
|
|
108
|
+
|
|
109
|
+
if (isValid) {
|
|
110
|
+
output.output({
|
|
111
|
+
success: true,
|
|
112
|
+
message: 'Authenticated successfully',
|
|
113
|
+
data: {
|
|
114
|
+
authenticated: true,
|
|
115
|
+
token_preview: token.substring(0, 10) + '...',
|
|
116
|
+
client_id: config.github_client_id || 'Not set',
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
} else {
|
|
120
|
+
output.output({
|
|
121
|
+
success: false,
|
|
122
|
+
message: 'Authentication token is invalid',
|
|
123
|
+
data: {
|
|
124
|
+
authenticated: false,
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
} else {
|
|
129
|
+
output.output({
|
|
130
|
+
success: false,
|
|
131
|
+
message: 'Not authenticated',
|
|
132
|
+
data: {
|
|
133
|
+
authenticated: false,
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
} catch (error) {
|
|
138
|
+
handleCliError(error, output);
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
// Token command (get current token)
|
|
143
|
+
auth
|
|
144
|
+
.command('token')
|
|
145
|
+
.description('Get current authentication token')
|
|
146
|
+
.action(async () => {
|
|
147
|
+
try {
|
|
148
|
+
const token = getAuthToken();
|
|
149
|
+
|
|
150
|
+
if (token) {
|
|
151
|
+
const isValid = await validateToken(token);
|
|
152
|
+
|
|
153
|
+
if (isValid) {
|
|
154
|
+
if (output.isJsonMode()) {
|
|
155
|
+
output.output({
|
|
156
|
+
success: true,
|
|
157
|
+
data: {
|
|
158
|
+
token,
|
|
159
|
+
preview: token.substring(0, 10) + '...',
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
} else {
|
|
163
|
+
console.log(chalk.green('Current token:'));
|
|
164
|
+
console.log(chalk.gray(token));
|
|
165
|
+
}
|
|
166
|
+
} else {
|
|
167
|
+
output.error('Current token is invalid');
|
|
168
|
+
process.exit(ERROR_CODES.AUTHENTICATION_FAILED);
|
|
169
|
+
}
|
|
170
|
+
} else {
|
|
171
|
+
output.error('No authentication token found');
|
|
172
|
+
process.exit(ERROR_CODES.AUTHENTICATION_FAILED);
|
|
173
|
+
}
|
|
174
|
+
} catch (error) {
|
|
175
|
+
handleCliError(error, output);
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* Perform OAuth flow for authentication
|
|
182
|
+
* @param {string} clientId - GitHub OAuth App client ID
|
|
183
|
+
* @param {string} clientSecret - GitHub OAuth App client secret
|
|
184
|
+
* @param {Object} logger - Logger instance
|
|
185
|
+
* @returns {Promise<string>} GitHub token
|
|
186
|
+
*/
|
|
187
|
+
async function performOAuthFlow(clientId, clientSecret, logger) {
|
|
188
|
+
const { Octokit } = require('@octokit/rest');
|
|
189
|
+
|
|
190
|
+
logger.info('Starting OAuth flow...');
|
|
191
|
+
|
|
192
|
+
// This is a simplified OAuth flow for CLI
|
|
193
|
+
// In a real implementation, you'd need to handle the full OAuth redirect flow
|
|
194
|
+
console.log(chalk.yellow('Please visit the following URL to authorize AutoChangelog:'));
|
|
195
|
+
console.log(chalk.cyan(`https://github.com/login/oauth/authorize?client_id=${clientId}`));
|
|
196
|
+
console.log('');
|
|
197
|
+
console.log(chalk.gray('After authorization, you will receive an authorization code.'));
|
|
198
|
+
|
|
199
|
+
const answers = await inquirer.prompt([
|
|
200
|
+
{
|
|
201
|
+
type: 'input',
|
|
202
|
+
name: 'code',
|
|
203
|
+
message: 'Enter the authorization code:',
|
|
204
|
+
validate: (input) => input.length > 0 || 'Authorization code is required',
|
|
205
|
+
}
|
|
206
|
+
]);
|
|
207
|
+
|
|
208
|
+
try {
|
|
209
|
+
// Exchange code for token
|
|
210
|
+
const response = await fetch('https://github.com/login/oauth/access_token', {
|
|
211
|
+
method: 'POST',
|
|
212
|
+
headers: {
|
|
213
|
+
'Content-Type': 'application/json',
|
|
214
|
+
'Accept': 'application/json',
|
|
215
|
+
},
|
|
216
|
+
body: JSON.stringify({
|
|
217
|
+
client_id: clientId,
|
|
218
|
+
client_secret: clientSecret,
|
|
219
|
+
code: answers.code,
|
|
220
|
+
}),
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
const data = await response.json();
|
|
224
|
+
|
|
225
|
+
if (data.access_token) {
|
|
226
|
+
return data.access_token;
|
|
227
|
+
} else {
|
|
228
|
+
throw new Error(data.error || 'Failed to exchange code for token');
|
|
229
|
+
}
|
|
230
|
+
} catch (error) {
|
|
231
|
+
throw new Error(`OAuth flow failed: ${error.message}`);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* Interactive login prompt
|
|
237
|
+
* @param {Object} logger - Logger instance
|
|
238
|
+
* @returns {Promise<string>} GitHub token
|
|
239
|
+
*/
|
|
240
|
+
async function interactiveLogin(logger) {
|
|
241
|
+
logger.info('Starting interactive login...');
|
|
242
|
+
|
|
243
|
+
console.log(chalk.blue('To authenticate with GitHub, you need a personal access token.'));
|
|
244
|
+
console.log(chalk.gray('1. Go to https://github.com/settings/tokens'));
|
|
245
|
+
console.log(chalk.gray('2. Click "Generate new token (classic)"'));
|
|
246
|
+
console.log(chalk.gray('3. Select the following scopes:'));
|
|
247
|
+
console.log(chalk.gray(' - repo (Full control of private repositories)'));
|
|
248
|
+
console.log(chalk.gray(' - read:org (Read org and team membership, read org projects)'));
|
|
249
|
+
console.log(chalk.gray('4. Copy the generated token'));
|
|
250
|
+
console.log('');
|
|
251
|
+
|
|
252
|
+
const answers = await inquirer.prompt([
|
|
253
|
+
{
|
|
254
|
+
type: 'password',
|
|
255
|
+
name: 'token',
|
|
256
|
+
message: 'Enter your GitHub personal access token:',
|
|
257
|
+
validate: (input) => input.length > 0 || 'Token is required',
|
|
258
|
+
}
|
|
259
|
+
]);
|
|
260
|
+
|
|
261
|
+
return answers.token;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* Validate GitHub token
|
|
266
|
+
* @param {string} token - GitHub token to validate
|
|
267
|
+
* @param {Object} logger - Logger instance
|
|
268
|
+
* @returns {Promise<boolean>} True if token is valid
|
|
269
|
+
*/
|
|
270
|
+
async function validateToken(token, logger = null) {
|
|
271
|
+
try {
|
|
272
|
+
const { Octokit } = require('@octokit/rest');
|
|
273
|
+
const octokit = new Octokit({ auth: token });
|
|
274
|
+
|
|
275
|
+
// Test the token by making a simple API call
|
|
276
|
+
const { data } = await octokit.rest.users.getAuthenticated();
|
|
277
|
+
|
|
278
|
+
if (logger) {
|
|
279
|
+
logger.info(`Token validated for user: ${data.login}`);
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
return true;
|
|
283
|
+
} catch (error) {
|
|
284
|
+
if (logger) {
|
|
285
|
+
logger.error('Token validation failed:', error.message);
|
|
286
|
+
}
|
|
287
|
+
return false;
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
module.exports = setupAuthCommands;
|