@intranefr/superbackend 1.7.7 → 1.7.9
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 +8 -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,427 @@
|
|
|
1
|
+
const { Command } = require('commander');
|
|
2
|
+
const chalk = require('chalk');
|
|
3
|
+
const { output } = require('../utils/output');
|
|
4
|
+
const { handleCliError, validateRequiredArgs, ERROR_CODES } = require('../utils/errors');
|
|
5
|
+
const { loadConfig, getAuthToken } = require('../utils/config');
|
|
6
|
+
const { setupLogger } = require('../utils/logger');
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Project management commands for AutoChangelog CLI
|
|
10
|
+
* Handles project CRUD operations and management
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
function setupProjectCommands(program) {
|
|
14
|
+
const project = program
|
|
15
|
+
.command('project')
|
|
16
|
+
.description('Project management');
|
|
17
|
+
|
|
18
|
+
// Create project command
|
|
19
|
+
project
|
|
20
|
+
.command('create')
|
|
21
|
+
.description('Create a new project')
|
|
22
|
+
.option('--name <name>', 'Project name')
|
|
23
|
+
.option('--description <description>', 'Project description')
|
|
24
|
+
.option('--plan <plan>', 'Subscription plan (free, pro, enterprise)', 'free')
|
|
25
|
+
.action(async (options) => {
|
|
26
|
+
const logger = setupLogger();
|
|
27
|
+
const config = loadConfig();
|
|
28
|
+
|
|
29
|
+
try {
|
|
30
|
+
validateRequiredArgs(options, ['name'], output);
|
|
31
|
+
|
|
32
|
+
const token = getAuthToken();
|
|
33
|
+
if (!token) {
|
|
34
|
+
output.error('Not authenticated. Run "autochangelog auth login" first.');
|
|
35
|
+
process.exit(ERROR_CODES.AUTHENTICATION_FAILED);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const projectData = {
|
|
39
|
+
name: options.name,
|
|
40
|
+
description: options.description || '',
|
|
41
|
+
plan: options.plan,
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const result = await createProject(projectData, token, logger);
|
|
45
|
+
|
|
46
|
+
output.output({
|
|
47
|
+
success: true,
|
|
48
|
+
message: 'Project created successfully',
|
|
49
|
+
data: result,
|
|
50
|
+
metadata: {
|
|
51
|
+
timestamp: new Date().toISOString(),
|
|
52
|
+
action: 'project_create',
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
} catch (error) {
|
|
57
|
+
handleCliError(error, output);
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
// List projects command
|
|
62
|
+
project
|
|
63
|
+
.command('list')
|
|
64
|
+
.description('List all projects')
|
|
65
|
+
.option('--limit <limit>', 'Limit number of results', parseInt)
|
|
66
|
+
.option('--offset <offset>', 'Offset for pagination', parseInt)
|
|
67
|
+
.action(async (options) => {
|
|
68
|
+
const logger = setupLogger();
|
|
69
|
+
|
|
70
|
+
try {
|
|
71
|
+
const token = getAuthToken();
|
|
72
|
+
if (!token) {
|
|
73
|
+
output.error('Not authenticated. Run "autochangelog auth login" first.');
|
|
74
|
+
process.exit(ERROR_CODES.AUTHENTICATION_FAILED);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const result = await listProjects(options, token, logger);
|
|
78
|
+
|
|
79
|
+
if (output.isJsonMode()) {
|
|
80
|
+
output.output({
|
|
81
|
+
success: true,
|
|
82
|
+
data: result,
|
|
83
|
+
metadata: {
|
|
84
|
+
total: result.length,
|
|
85
|
+
limit: options.limit,
|
|
86
|
+
offset: options.offset || 0,
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
} else {
|
|
90
|
+
if (result.length === 0) {
|
|
91
|
+
output.info('No projects found');
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
output.info(`Found ${result.length} project(s):`);
|
|
96
|
+
console.log('');
|
|
97
|
+
|
|
98
|
+
const headers = ['ID', 'Name', 'Plan', 'Repositories', 'Created'];
|
|
99
|
+
const rows = result.map(project => [
|
|
100
|
+
project.id || project._id,
|
|
101
|
+
project.name,
|
|
102
|
+
project.plan,
|
|
103
|
+
project.repositoryCount || 0,
|
|
104
|
+
new Date(project.createdAt).toLocaleDateString(),
|
|
105
|
+
]);
|
|
106
|
+
|
|
107
|
+
output.table(headers, rows);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
} catch (error) {
|
|
111
|
+
handleCliError(error, output);
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
// Get project details command
|
|
116
|
+
project
|
|
117
|
+
.command('get <id>')
|
|
118
|
+
.description('Get project details')
|
|
119
|
+
.action(async (id) => {
|
|
120
|
+
const logger = setupLogger();
|
|
121
|
+
|
|
122
|
+
try {
|
|
123
|
+
const token = getAuthToken();
|
|
124
|
+
if (!token) {
|
|
125
|
+
output.error('Not authenticated. Run "autochangelog auth login" first.');
|
|
126
|
+
process.exit(ERROR_CODES.AUTHENTICATION_FAILED);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
const result = await getProject(id, token, logger);
|
|
130
|
+
|
|
131
|
+
output.output({
|
|
132
|
+
success: true,
|
|
133
|
+
message: 'Project details retrieved',
|
|
134
|
+
data: result,
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
} catch (error) {
|
|
138
|
+
handleCliError(error, output);
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
// Update project command
|
|
143
|
+
project
|
|
144
|
+
.command('update <id>')
|
|
145
|
+
.description('Update project')
|
|
146
|
+
.option('--name <name>', 'Project name')
|
|
147
|
+
.option('--description <description>', 'Project description')
|
|
148
|
+
.option('--plan <plan>', 'Subscription plan')
|
|
149
|
+
.action(async (id, options) => {
|
|
150
|
+
const logger = setupLogger();
|
|
151
|
+
|
|
152
|
+
try {
|
|
153
|
+
const token = getAuthToken();
|
|
154
|
+
if (!token) {
|
|
155
|
+
output.error('Not authenticated. Run "autochangelog auth login" first.');
|
|
156
|
+
process.exit(ERROR_CODES.AUTHENTICATION_FAILED);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
const updateData = {};
|
|
160
|
+
if (options.name) updateData.name = options.name;
|
|
161
|
+
if (options.description) updateData.description = options.description;
|
|
162
|
+
if (options.plan) updateData.plan = options.plan;
|
|
163
|
+
|
|
164
|
+
if (Object.keys(updateData).length === 0) {
|
|
165
|
+
output.error('No update data provided. Use --name, --description, or --plan');
|
|
166
|
+
process.exit(ERROR_CODES.INVALID_ARGUMENT);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
const result = await updateProject(id, updateData, token, logger);
|
|
170
|
+
|
|
171
|
+
output.output({
|
|
172
|
+
success: true,
|
|
173
|
+
message: 'Project updated successfully',
|
|
174
|
+
data: result,
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
} catch (error) {
|
|
178
|
+
handleCliError(error, output);
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
// Delete project command
|
|
183
|
+
project
|
|
184
|
+
.command('delete <id>')
|
|
185
|
+
.description('Delete a project')
|
|
186
|
+
.option('--force', 'Skip confirmation prompt')
|
|
187
|
+
.action(async (id, options) => {
|
|
188
|
+
const logger = setupLogger();
|
|
189
|
+
|
|
190
|
+
try {
|
|
191
|
+
const token = getAuthToken();
|
|
192
|
+
if (!token) {
|
|
193
|
+
output.error('Not authenticated. Run "autochangelog auth login" first.');
|
|
194
|
+
process.exit(ERROR_CODES.AUTHENTICATION_FAILED);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
// Confirmation prompt (skip if --force)
|
|
198
|
+
if (!options.force) {
|
|
199
|
+
const inquirer = require('inquirer');
|
|
200
|
+
const answers = await inquirer.prompt([
|
|
201
|
+
{
|
|
202
|
+
type: 'confirm',
|
|
203
|
+
name: 'confirm',
|
|
204
|
+
message: `Are you sure you want to delete project ${id}? This action cannot be undone.`,
|
|
205
|
+
default: false,
|
|
206
|
+
}
|
|
207
|
+
]);
|
|
208
|
+
|
|
209
|
+
if (!answers.confirm) {
|
|
210
|
+
output.info('Operation cancelled');
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
await deleteProject(id, token, logger);
|
|
216
|
+
|
|
217
|
+
output.success(`Project ${id} deleted successfully`);
|
|
218
|
+
|
|
219
|
+
} catch (error) {
|
|
220
|
+
handleCliError(error, output);
|
|
221
|
+
}
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* Create a new project
|
|
227
|
+
* @param {Object} projectData - Project data
|
|
228
|
+
* @param {string} token - Authentication token
|
|
229
|
+
* @param {Object} logger - Logger instance
|
|
230
|
+
* @returns {Promise<Object>} Created project
|
|
231
|
+
*/
|
|
232
|
+
async function createProject(projectData, token, logger) {
|
|
233
|
+
try {
|
|
234
|
+
// Import the Project model directly from the backend
|
|
235
|
+
const mongoose = require('mongoose');
|
|
236
|
+
const Project = require('../../autochangelog/src/models/Project');
|
|
237
|
+
|
|
238
|
+
// Connect to database
|
|
239
|
+
await mongoose.connect(loadConfig().mongodb_uri);
|
|
240
|
+
|
|
241
|
+
// Create project
|
|
242
|
+
const project = new Project({
|
|
243
|
+
...projectData,
|
|
244
|
+
createdAt: new Date(),
|
|
245
|
+
updatedAt: new Date(),
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
await project.save();
|
|
249
|
+
|
|
250
|
+
logger.info(`Project created: ${project.name} (${project._id})`);
|
|
251
|
+
|
|
252
|
+
return {
|
|
253
|
+
id: project._id,
|
|
254
|
+
name: project.name,
|
|
255
|
+
description: project.description,
|
|
256
|
+
plan: project.plan,
|
|
257
|
+
createdAt: project.createdAt,
|
|
258
|
+
updatedAt: project.updatedAt,
|
|
259
|
+
};
|
|
260
|
+
|
|
261
|
+
} catch (error) {
|
|
262
|
+
throw error;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* List projects
|
|
268
|
+
* @param {Object} options - Query options
|
|
269
|
+
* @param {string} token - Authentication token
|
|
270
|
+
* @param {Object} logger - Logger instance
|
|
271
|
+
* @returns {Promise<Array>} List of projects
|
|
272
|
+
*/
|
|
273
|
+
async function listProjects(options, token, logger) {
|
|
274
|
+
try {
|
|
275
|
+
const mongoose = require('mongoose');
|
|
276
|
+
const Project = require('../../autochangelog/src/models/Project');
|
|
277
|
+
|
|
278
|
+
await mongoose.connect(loadConfig().mongodb_uri);
|
|
279
|
+
|
|
280
|
+
const query = {};
|
|
281
|
+
const limit = options.limit || 50;
|
|
282
|
+
const offset = options.offset || 0;
|
|
283
|
+
|
|
284
|
+
const projects = await Project.find(query)
|
|
285
|
+
.sort({ createdAt: -1 })
|
|
286
|
+
.skip(offset)
|
|
287
|
+
.limit(limit)
|
|
288
|
+
.lean();
|
|
289
|
+
|
|
290
|
+
logger.info(`Retrieved ${projects.length} projects`);
|
|
291
|
+
|
|
292
|
+
return projects.map(project => ({
|
|
293
|
+
id: project._id,
|
|
294
|
+
name: project.name,
|
|
295
|
+
description: project.description,
|
|
296
|
+
plan: project.plan,
|
|
297
|
+
createdAt: project.createdAt,
|
|
298
|
+
updatedAt: project.updatedAt,
|
|
299
|
+
repositoryCount: project.repositoryCount || 0,
|
|
300
|
+
}));
|
|
301
|
+
|
|
302
|
+
} catch (error) {
|
|
303
|
+
throw error;
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
/**
|
|
308
|
+
* Get project details
|
|
309
|
+
* @param {string} id - Project ID
|
|
310
|
+
* @param {string} token - Authentication token
|
|
311
|
+
* @param {Object} logger - Logger instance
|
|
312
|
+
* @returns {Promise<Object>} Project details
|
|
313
|
+
*/
|
|
314
|
+
async function getProject(id, token, logger) {
|
|
315
|
+
try {
|
|
316
|
+
const mongoose = require('mongoose');
|
|
317
|
+
const Project = require('../../autochangelog/src/models/Project');
|
|
318
|
+
|
|
319
|
+
await mongoose.connect(loadConfig().mongodb_uri);
|
|
320
|
+
|
|
321
|
+
const project = await Project.findById(id).lean();
|
|
322
|
+
|
|
323
|
+
if (!project) {
|
|
324
|
+
const error = new Error('Project not found');
|
|
325
|
+
error.code = ERROR_CODES.RESOURCE_NOT_FOUND;
|
|
326
|
+
error.type = 'resource_not_found';
|
|
327
|
+
throw error;
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
logger.info(`Retrieved project details: ${project.name}`);
|
|
331
|
+
|
|
332
|
+
return {
|
|
333
|
+
id: project._id,
|
|
334
|
+
name: project.name,
|
|
335
|
+
description: project.description,
|
|
336
|
+
plan: project.plan,
|
|
337
|
+
createdAt: project.createdAt,
|
|
338
|
+
updatedAt: project.updatedAt,
|
|
339
|
+
repositoryCount: project.repositoryCount || 0,
|
|
340
|
+
usage: {
|
|
341
|
+
changelogCount: project.changelogCount || 0,
|
|
342
|
+
repositoryCount: project.repositoryCount || 0,
|
|
343
|
+
lastActivity: project.lastActivity,
|
|
344
|
+
}
|
|
345
|
+
};
|
|
346
|
+
|
|
347
|
+
} catch (error) {
|
|
348
|
+
throw error;
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
/**
|
|
353
|
+
* Update project
|
|
354
|
+
* @param {string} id - Project ID
|
|
355
|
+
* @param {Object} updateData - Update data
|
|
356
|
+
* @param {string} token - Authentication token
|
|
357
|
+
* @param {Object} logger - Logger instance
|
|
358
|
+
* @returns {Promise<Object>} Updated project
|
|
359
|
+
*/
|
|
360
|
+
async function updateProject(id, updateData, token, logger) {
|
|
361
|
+
try {
|
|
362
|
+
const mongoose = require('mongoose');
|
|
363
|
+
const Project = require('../../autochangelog/src/models/Project');
|
|
364
|
+
|
|
365
|
+
await mongoose.connect(loadConfig().mongodb_uri);
|
|
366
|
+
|
|
367
|
+
updateData.updatedAt = new Date();
|
|
368
|
+
|
|
369
|
+
const project = await Project.findByIdAndUpdate(
|
|
370
|
+
id,
|
|
371
|
+
updateData,
|
|
372
|
+
{ new: true, runValidators: true }
|
|
373
|
+
).lean();
|
|
374
|
+
|
|
375
|
+
if (!project) {
|
|
376
|
+
const error = new Error('Project not found');
|
|
377
|
+
error.code = ERROR_CODES.RESOURCE_NOT_FOUND;
|
|
378
|
+
error.type = 'resource_not_found';
|
|
379
|
+
throw error;
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
logger.info(`Project updated: ${project.name}`);
|
|
383
|
+
|
|
384
|
+
return {
|
|
385
|
+
id: project._id,
|
|
386
|
+
name: project.name,
|
|
387
|
+
description: project.description,
|
|
388
|
+
plan: project.plan,
|
|
389
|
+
createdAt: project.createdAt,
|
|
390
|
+
updatedAt: project.updatedAt,
|
|
391
|
+
};
|
|
392
|
+
|
|
393
|
+
} catch (error) {
|
|
394
|
+
throw error;
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
/**
|
|
399
|
+
* Delete project
|
|
400
|
+
* @param {string} id - Project ID
|
|
401
|
+
* @param {string} token - Authentication token
|
|
402
|
+
* @param {Object} logger - Logger instance
|
|
403
|
+
*/
|
|
404
|
+
async function deleteProject(id, token, logger) {
|
|
405
|
+
try {
|
|
406
|
+
const mongoose = require('mongoose');
|
|
407
|
+
const Project = require('../../autochangelog/src/models/Project');
|
|
408
|
+
|
|
409
|
+
await mongoose.connect(loadConfig().mongodb_uri);
|
|
410
|
+
|
|
411
|
+
const project = await Project.findByIdAndDelete(id);
|
|
412
|
+
|
|
413
|
+
if (!project) {
|
|
414
|
+
const error = new Error('Project not found');
|
|
415
|
+
error.code = ERROR_CODES.RESOURCE_NOT_FOUND;
|
|
416
|
+
error.type = 'resource_not_found';
|
|
417
|
+
throw error;
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
logger.info(`Project deleted: ${project.name}`);
|
|
421
|
+
|
|
422
|
+
} catch (error) {
|
|
423
|
+
throw error;
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
module.exports = setupProjectCommands;
|