@manojkmfsi/monodog 1.2.0 → 1.2.1

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.
@@ -16,26 +16,6 @@ const npm_publish_service_1 = require("../services/npm-publish-service");
16
16
  const fs_1 = __importDefault(require("fs"));
17
17
  const path_1 = __importDefault(require("path"));
18
18
  const router = (0, express_1.Router)();
19
- /**
20
- * GET /api/releases/packages
21
- * Get list of packages available in workspace
22
- */
23
- router.get('/packages', async (req, res) => {
24
- try {
25
- const packages = publish_controller_1.publishController.getAvailablePackages(process.cwd());
26
- res.json({
27
- success: true,
28
- packages,
29
- count: packages.length,
30
- });
31
- }
32
- catch (error) {
33
- res.status(500).json({
34
- success: false,
35
- error: error instanceof Error ? error.message : 'Unknown error',
36
- });
37
- }
38
- });
39
19
  /**
40
20
  * POST /api/releases/analyze
41
21
  * Analyze changes for packages without publishing
@@ -8,10 +8,63 @@ Object.defineProperty(exports, "__esModule", { value: true });
8
8
  exports.changeTrackerService = exports.ChangeTrackerService = void 0;
9
9
  const child_process_1 = require("child_process");
10
10
  const util_1 = require("util");
11
+ const client_1 = require("@prisma/client");
11
12
  // NOTE: ChangeTrack and CommitChange types will be imported from @prisma/client after DB integration
12
13
  // Currently using inline types below for service implementation
13
14
  const execAsync = (0, util_1.promisify)(child_process_1.exec);
15
+ const prisma = new client_1.PrismaClient();
14
16
  class ChangeTrackerService {
17
+ /**
18
+ * Save a ChangeTrack record and its related commits to the database
19
+ */
20
+ async saveChangeTrack(result) {
21
+ // Save ChangeTrack
22
+ const changeTrack = await prisma.changeTrack.create({
23
+ data: {
24
+ packageName: result.packageName,
25
+ packageVersion: result.currentVersion,
26
+ detectionMethod: 'git',
27
+ detectionTimestamp: new Date(),
28
+ filesChanged: JSON.stringify(result.filesChanged.map(f => f.path)),
29
+ linesAdded: result.filesChanged.reduce((sum, f) => sum + (f.linesAdded || 0), 0),
30
+ linesRemoved: result.filesChanged.reduce((sum, f) => sum + (f.linesRemoved || 0), 0),
31
+ changeType: result.changeType,
32
+ affectedDependents: JSON.stringify(result.affectedDependents),
33
+ isReleaseReady: result.isReleaseReady,
34
+ lastAnalyzedCommit: result.commits[0]?.hash || '',
35
+ previousVersion: result.currentVersion,
36
+ proposedVersion: result.proposedVersion,
37
+ // createdAt, updatedAt auto
38
+ },
39
+ });
40
+ // Save related commits
41
+ for (const commit of result.commits) {
42
+ await prisma.commitChange.create({
43
+ data: {
44
+ changeTrackId: changeTrack.id,
45
+ hash: commit.hash,
46
+ message: commit.message,
47
+ author: commit.author,
48
+ authorEmail: commit.authorEmail,
49
+ type: commit.type,
50
+ scope: commit.scope,
51
+ isBreaking: commit.isBreaking,
52
+ bodyText: commit.body,
53
+ committedAt: commit.committedAt,
54
+ },
55
+ });
56
+ }
57
+ }
58
+ /**
59
+ * Load the latest ChangeTrack for a package
60
+ */
61
+ async getLatestChangeTrack(packageName) {
62
+ return prisma.changeTrack.findFirst({
63
+ where: { packageName },
64
+ orderBy: { createdAt: 'desc' },
65
+ include: { commits: true },
66
+ });
67
+ }
15
68
  /**
16
69
  * Analyze changes for a package since last release
17
70
  */
@@ -25,7 +78,7 @@ class ChangeTrackerService {
25
78
  const changeType = this.determineChangeType(commits);
26
79
  // 4. Identify affected dependents
27
80
  const affectedDependents = await this.identifyAffectedDependents(packageName);
28
- return {
81
+ const result = {
29
82
  packageName,
30
83
  currentVersion,
31
84
  changeType,
@@ -35,6 +88,9 @@ class ChangeTrackerService {
35
88
  proposedVersion: this.calculateNextVersion(currentVersion, changeType),
36
89
  isReleaseReady: changeType !== 'none',
37
90
  };
91
+ // Save to DB
92
+ await this.saveChangeTrack(result);
93
+ return result;
38
94
  }
39
95
  catch (error) {
40
96
  console.error(`Failed to analyze changes for ${packageName}:`, error);
@@ -161,12 +161,6 @@ class NpmPublishService {
161
161
  const integrity = this.calculateSRI(tarballData);
162
162
  const pkgJsonPath = (0, path_1.join)('package.json');
163
163
  const pkgJson = JSON.parse(await readFileAsync((0, path_1.join)(tarballPath, '..', pkgJsonPath), 'utf8'));
164
- // const tarballBuffer = await fs.readFile(tarballPath, null, (err, data) => {
165
- // if (err) {
166
- // throw new Error(`Failed to read tarball for upload: ${err.message}`);
167
- // }
168
- // return data;
169
- // });
170
164
  const doc = {
171
165
  _id: packageName,
172
166
  name: packageName,
@@ -194,21 +188,6 @@ class NpmPublishService {
194
188
  },
195
189
  },
196
190
  };
197
- // Prepare document for npm registry
198
- // const doc = {
199
- // _id: `${packageName}@${version}`,
200
- // name: packageName,
201
- // version,
202
- // description: pkgJson.description || '',
203
- // dist: {
204
- // tarball: `${registry}/${packageName}/-/${basename(tarballPath)}`,
205
- // shasum,
206
- // integrity,
207
- // },
208
- // // Add minimal required metadata
209
- // _rev: '',
210
- // dependencies: {},
211
- // };
212
191
  const encodedName = packageName.replace('/', '%2f');
213
192
  // Publish via npm registry REST API
214
193
  const response = await fetch(`${registry}/${encodedName}`, {
@@ -191,13 +191,6 @@ class PublishController {
191
191
  getAllPipelines() {
192
192
  return Array.from(this.pipelines.values());
193
193
  }
194
- /**
195
- * Get list of available packages
196
- */
197
- getAvailablePackages(workspacePath) {
198
- // Would scan packages directory and return available packages
199
- return [];
200
- }
201
194
  /**
202
195
  * Get detailed pipeline information
203
196
  */
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.publishPipelineService = exports.PublishPipelineService = void 0;
4
+ const client_1 = require("@prisma/client");
5
+ const prisma = new client_1.PrismaClient();
6
+ class PublishPipelineService {
7
+ /**
8
+ * Create a new publish pipeline record
9
+ */
10
+ async createPipeline(data) {
11
+ return prisma.publishPipeline.create({ data: data });
12
+ }
13
+ /**
14
+ * Update a publish pipeline record
15
+ */
16
+ async updatePipeline(id, data) {
17
+ return prisma.publishPipeline.update({ where: { id }, data: data });
18
+ }
19
+ /**
20
+ * Get a publish pipeline by ID
21
+ */
22
+ async getPipeline(id) {
23
+ return prisma.publishPipeline.findUnique({ where: { id } });
24
+ }
25
+ /**
26
+ * List all pipelines (optionally filter by status)
27
+ */
28
+ async listPipelines(status) {
29
+ return prisma.publishPipeline.findMany({
30
+ where: status ? { status } : undefined,
31
+ orderBy: { createdAt: 'desc' },
32
+ });
33
+ }
34
+ /**
35
+ * Add a publish result to a pipeline
36
+ */
37
+ async addPublishResult(pipelineId, result) {
38
+ return prisma.publishResult.create({
39
+ data: {
40
+ ...result,
41
+ publishPipelineId: pipelineId,
42
+ },
43
+ });
44
+ }
45
+ /**
46
+ * Get all results for a pipeline
47
+ */
48
+ async getResultsForPipeline(pipelineId) {
49
+ return prisma.publishResult.findMany({
50
+ where: { publishPipelineId: pipelineId },
51
+ orderBy: { newVersion: 'desc' },
52
+ });
53
+ }
54
+ /**
55
+ * Log a token usage event
56
+ */
57
+ async logTokenUsage(data) {
58
+ return prisma.tokenUsageLog.create({ data: data });
59
+ }
60
+ }
61
+ exports.PublishPipelineService = PublishPipelineService;
62
+ exports.publishPipelineService = new PublishPipelineService();
package/dist/setup.js CHANGED
File without changes