@eldrforge/commands-publish 0.1.1 → 0.1.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eldrforge/commands-publish",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Publishing workflow commands for kodrdriv (development, publish, release)",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
@@ -40,13 +40,13 @@
40
40
  "author": "Tim O'Brien <tobrien@discursive.com>",
41
41
  "license": "Apache-2.0",
42
42
  "dependencies": {
43
- "@eldrforge/core": "^0.1.0",
44
- "@eldrforge/commands-git": "^0.1.0",
45
- "@eldrforge/commands-tree": "^0.1.0",
46
- "@eldrforge/git-tools": "^0.1.16",
47
- "@eldrforge/github-tools": "^0.1.18",
48
- "@eldrforge/ai-service": "^0.1.17",
49
- "@eldrforge/shared": "^0.1.6",
43
+ "@eldrforge/core": "^0.1.1",
44
+ "@eldrforge/commands-git": "^0.1.2",
45
+ "@eldrforge/commands-tree": "^0.1.1",
46
+ "@eldrforge/git-tools": "^0.1.17",
47
+ "@eldrforge/github-tools": "^0.1.19",
48
+ "@eldrforge/ai-service": "^0.1.18",
49
+ "@eldrforge/shared": "^0.1.7",
50
50
  "@riotprompt/riotprompt": "^0.0.10",
51
51
  "openai": "^6.3.0",
52
52
  "semver": "^7.6.0",
@@ -73,4 +73,3 @@
73
73
  "vitest": "^4.0.13"
74
74
  }
75
75
  }
76
-
@@ -1,214 +0,0 @@
1
- import { getDryRunLogger } from '@eldrforge/core';
2
- import { run, safeJsonParse } from '@eldrforge/git-tools';
3
- import '@eldrforge/commands-git';
4
- import { createStorage } from '@eldrforge/shared';
5
- import 'fs/promises';
6
- import path from 'path';
7
- import 'child_process';
8
- import 'os';
9
-
10
- /**
11
- * Update inter-project dependencies in package.json based on current tree state
12
- */ const updateInterProjectDependencies$1 = async (packageDir, scope, isDryRun, logger)=>{
13
- const storage = createStorage();
14
- const packageJsonPath = path.join(packageDir, 'package.json');
15
- if (!await storage.exists(packageJsonPath)) {
16
- logger.verbose('No package.json found, skipping dependency updates');
17
- return {
18
- hasChanges: false,
19
- updated: []
20
- };
21
- }
22
- const updated = [];
23
- let hasChanges = false;
24
- try {
25
- const packageJsonContent = await storage.readFile(packageJsonPath, 'utf-8');
26
- const packageJson = safeJsonParse(packageJsonContent, packageJsonPath);
27
- const sectionsToUpdate = [
28
- 'dependencies',
29
- 'devDependencies',
30
- 'peerDependencies'
31
- ];
32
- // Collect all dependencies matching the scope
33
- const depsToUpdate = [];
34
- for (const section of sectionsToUpdate){
35
- const deps = packageJson[section];
36
- if (deps) {
37
- for (const [depName, depVersion] of Object.entries(deps)){
38
- if (depName.startsWith(scope)) {
39
- depsToUpdate.push({
40
- section,
41
- name: depName,
42
- currentVersion: depVersion
43
- });
44
- }
45
- }
46
- }
47
- }
48
- if (depsToUpdate.length === 0) {
49
- logger.info(`UPDATES_NO_DEPS_FOUND: No dependencies matching scope | Scope: ${scope} | Package Dir: ${packageDir} | Status: No updates needed`);
50
- return {
51
- hasChanges: false,
52
- updated: []
53
- };
54
- }
55
- logger.info(`UPDATES_DEPS_FOUND: Found dependencies matching scope | Scope: ${scope} | Count: ${depsToUpdate.length} | Action: Will check and update versions`);
56
- // For each dependency, find its package.json and get the current version
57
- for (const dep of depsToUpdate){
58
- try {
59
- // Look for package in parent directories or node_modules
60
- let depVersion = null;
61
- // First try to find in tree (sibling packages)
62
- const parentDir = path.dirname(packageDir);
63
- const siblingPackageJson = path.join(parentDir, dep.name.split('/').pop(), 'package.json');
64
- if (await storage.exists(siblingPackageJson)) {
65
- const siblingContent = await storage.readFile(siblingPackageJson, 'utf-8');
66
- const siblingPackage = safeJsonParse(siblingContent, siblingPackageJson);
67
- if (siblingPackage.name === dep.name) {
68
- depVersion = siblingPackage.version;
69
- logger.verbose(`Found ${dep.name}@${depVersion} in tree`);
70
- }
71
- }
72
- // Fall back to npm to get latest published version
73
- if (!depVersion) {
74
- try {
75
- const { stdout } = await run(`npm view ${dep.name} version`);
76
- depVersion = stdout.trim();
77
- logger.verbose(`Found ${dep.name}@${depVersion} on npm`);
78
- } catch {
79
- logger.warn(`UPDATES_VERSION_NOT_FOUND: Could not find version for dependency | Dependency: ${dep.name} | Action: Skipping | Reason: Not found in tree or npm`);
80
- continue;
81
- }
82
- }
83
- const newVersion = `^${depVersion}`;
84
- if (dep.currentVersion !== newVersion) {
85
- if (isDryRun) {
86
- logger.info(`UPDATES_WOULD_UPDATE: Would update dependency | Mode: dry-run | Section: ${dep.section} | Dependency: ${dep.name} | Current: ${dep.currentVersion} | New: ${newVersion}`);
87
- } else {
88
- logger.info(`UPDATES_UPDATING: Updating dependency version | Section: ${dep.section} | Dependency: ${dep.name} | Current: ${dep.currentVersion} | New: ${newVersion}`);
89
- packageJson[dep.section][dep.name] = newVersion;
90
- }
91
- hasChanges = true;
92
- updated.push(`${dep.name}: ${dep.currentVersion} → ${newVersion}`);
93
- }
94
- } catch (error) {
95
- logger.warn(`UPDATES_DEP_UPDATE_FAILED: Failed to update dependency | Dependency: ${dep.name} | Error: ${error.message}`);
96
- }
97
- }
98
- if (hasChanges && !isDryRun) {
99
- await storage.writeFile(packageJsonPath, JSON.stringify(packageJson, null, 2) + '\n', 'utf-8');
100
- logger.info(`UPDATES_PACKAGE_COMPLETE: Updated dependencies in package.json | Count: ${updated.length} | File: package.json | Status: saved`);
101
- }
102
- } catch (error) {
103
- logger.warn(`UPDATES_INTER_PROJECT_FAILED: Failed to update inter-project dependencies | Error: ${error.message} | Impact: Dependencies not updated`);
104
- }
105
- return {
106
- hasChanges,
107
- updated
108
- };
109
- };
110
- /**
111
- * Execute the updates command
112
- */ const execute$2 = async (runConfig)=>{
113
- var _runConfig_updates, _runConfig_updates1, _runConfig_tree;
114
- const isDryRun = runConfig.dryRun || false;
115
- const logger = getDryRunLogger(isDryRun);
116
- // Check if this is inter-project mode
117
- const interProjectMode = ((_runConfig_updates = runConfig.updates) === null || _runConfig_updates === void 0 ? void 0 : _runConfig_updates.interProject) || false;
118
- if (interProjectMode) {
119
- var _runConfig_updates2;
120
- // Inter-project dependency update mode
121
- const scope = (_runConfig_updates2 = runConfig.updates) === null || _runConfig_updates2 === void 0 ? void 0 : _runConfig_updates2.scope;
122
- if (!scope) {
123
- throw new Error('Scope parameter is required for inter-project updates. Usage: kodrdriv updates --inter-project <scope>');
124
- }
125
- if (!scope.startsWith('@')) {
126
- throw new Error(`Invalid scope "${scope}". Scope must start with @ (e.g., "@fjell")`);
127
- }
128
- logger.info(`UPDATES_INTER_PROJECT_STARTING: Updating inter-project dependencies | Scope: ${scope} | Type: inter-project | Purpose: Sync dependency versions`);
129
- const result = await updateInterProjectDependencies$1(process.cwd(), scope, isDryRun, logger);
130
- if (result.hasChanges && !isDryRun) {
131
- logger.info('UPDATES_NPM_INSTALL: Running npm install to update lock file | Command: npm install | Purpose: Synchronize package-lock.json with changes');
132
- try {
133
- await run('npm install');
134
- logger.info('UPDATES_LOCK_FILE_UPDATED: Lock file updated successfully | File: package-lock.json | Status: synchronized');
135
- } catch (error) {
136
- logger.error(`UPDATES_NPM_INSTALL_FAILED: Failed to run npm install | Error: ${error.message} | Impact: Lock file not updated`);
137
- throw new Error(`Failed to update lock file: ${error.message}`);
138
- }
139
- }
140
- if (result.updated.length > 0) {
141
- logger.info(`UPDATES_INTER_PROJECT_COMPLETE: Updated inter-project dependencies | Count: ${result.updated.length} | Status: completed`);
142
- result.updated.forEach((update)=>logger.info(`UPDATES_DEP_UPDATED: ${update}`));
143
- } else {
144
- logger.info('UPDATES_INTER_PROJECT_NONE: No inter-project dependency updates needed | Status: All dependencies current');
145
- }
146
- return `Updated ${result.updated.length} inter-project dependencies`;
147
- }
148
- // Original scope-based npm-check-updates mode
149
- const scope = ((_runConfig_updates1 = runConfig.updates) === null || _runConfig_updates1 === void 0 ? void 0 : _runConfig_updates1.scope) || ((_runConfig_tree = runConfig.tree) === null || _runConfig_tree === void 0 ? void 0 : _runConfig_tree.packageArgument);
150
- if (!scope) {
151
- throw new Error('Scope parameter is required. Usage: kodrdriv updates <scope> or kodrdriv updates --inter-project <scope>');
152
- }
153
- // Validate that scope looks like a valid npm scope (starts with @)
154
- if (!scope.startsWith('@')) {
155
- throw new Error(`Invalid scope "${scope}". Scope must start with @ (e.g., "@fjell")`);
156
- }
157
- logger.info(`UPDATES_NCU_STARTING: Running npm-check-updates for scope | Scope: ${scope} | Tool: npm-check-updates | Purpose: Find outdated dependencies`);
158
- // Build the npm-check-updates command
159
- const ncuCommand = `npx npm-check-updates '/${scope.replace('@', '^@')}//' -u`;
160
- logger.info(`UPDATES_NCU_EXECUTING: Executing npm-check-updates command | Command: ${ncuCommand} | Scope: ${scope}`);
161
- try {
162
- if (isDryRun) {
163
- logger.info(`Would run: ${ncuCommand}`);
164
- logger.info('Would run: npm install');
165
- return `Would update dependencies matching ${scope} scope`;
166
- }
167
- // Execute npm-check-updates
168
- const result = await run(ncuCommand);
169
- if (result.stdout) {
170
- logger.info('UPDATES_NCU_OUTPUT: npm-check-updates output | Status: completed');
171
- result.stdout.split('\n').forEach((line)=>{
172
- if (line.trim()) {
173
- logger.info(` ${line}`);
174
- }
175
- });
176
- }
177
- if (result.stderr) {
178
- logger.info('UPDATES_NCU_WARNINGS: npm-check-updates produced warnings | Type: warnings');
179
- result.stderr.split('\n').forEach((line)=>{
180
- if (line.trim()) {
181
- logger.info(` ${line}`);
182
- }
183
- });
184
- }
185
- // Check if package.json was actually modified
186
- const hasUpdates = result.stdout && !result.stdout.includes('All dependencies match the latest package versions');
187
- if (hasUpdates) {
188
- logger.info('UPDATES_NCU_INSTALL: Running npm install after ncu updates | Command: npm install | Purpose: Update lock file with new versions');
189
- try {
190
- const installResult = await run('npm install');
191
- if (installResult.stdout) {
192
- logger.verbose('npm install output:');
193
- installResult.stdout.split('\n').forEach((line)=>{
194
- if (line.trim()) {
195
- logger.verbose(` ${line}`);
196
- }
197
- });
198
- }
199
- logger.info('UPDATES_NCU_LOCK_UPDATED: Lock file updated successfully after ncu | File: package-lock.json | Status: synchronized');
200
- } catch (installError) {
201
- logger.error(`UPDATES_NCU_INSTALL_FAILED: Failed to run npm install after ncu | Error: ${installError.message} | Impact: Lock file not synchronized`);
202
- throw new Error(`Failed to update lock file after dependency updates: ${installError.message}`);
203
- }
204
- }
205
- logger.info(`UPDATES_NCU_SUCCESS: Successfully updated dependencies | Scope: ${scope} | Status: completed | Files: package.json, package-lock.json`);
206
- return `Updated dependencies matching ${scope} scope`;
207
- } catch (error) {
208
- logger.error(`UPDATES_NCU_FAILED: Failed to run npm-check-updates | Scope: ${scope} | Error: ${error.message} | Impact: Dependencies not updated`);
209
- throw new Error(`Failed to update dependencies: ${error.message}`);
210
- }
211
- };
212
-
213
- export { execute$2 as updates };
214
- //# sourceMappingURL=index-D-RqK3Aj.js.map