@sfdxy/mule-build 1.0.0
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/README.md +301 -0
- package/dist/bin/mule-build.d.ts +8 -0
- package/dist/bin/mule-build.d.ts.map +1 -0
- package/dist/bin/mule-build.js +12 -0
- package/dist/bin/mule-build.js.map +1 -0
- package/dist/src/api/enforce.d.ts +11 -0
- package/dist/src/api/enforce.d.ts.map +1 -0
- package/dist/src/api/enforce.js +58 -0
- package/dist/src/api/enforce.js.map +1 -0
- package/dist/src/api/index.d.ts +12 -0
- package/dist/src/api/index.d.ts.map +1 -0
- package/dist/src/api/index.js +12 -0
- package/dist/src/api/index.js.map +1 -0
- package/dist/src/api/package.d.ts +15 -0
- package/dist/src/api/package.d.ts.map +1 -0
- package/dist/src/api/package.js +242 -0
- package/dist/src/api/package.js.map +1 -0
- package/dist/src/api/release.d.ts +11 -0
- package/dist/src/api/release.d.ts.map +1 -0
- package/dist/src/api/release.js +102 -0
- package/dist/src/api/release.js.map +1 -0
- package/dist/src/api/run.d.ts +11 -0
- package/dist/src/api/run.d.ts.map +1 -0
- package/dist/src/api/run.js +44 -0
- package/dist/src/api/run.js.map +1 -0
- package/dist/src/api/strip.d.ts +11 -0
- package/dist/src/api/strip.d.ts.map +1 -0
- package/dist/src/api/strip.js +57 -0
- package/dist/src/api/strip.js.map +1 -0
- package/dist/src/cli.d.ts +15 -0
- package/dist/src/cli.d.ts.map +1 -0
- package/dist/src/cli.js +174 -0
- package/dist/src/cli.js.map +1 -0
- package/dist/src/config/ConfigLoader.d.ts +19 -0
- package/dist/src/config/ConfigLoader.d.ts.map +1 -0
- package/dist/src/config/ConfigLoader.js +84 -0
- package/dist/src/config/ConfigLoader.js.map +1 -0
- package/dist/src/config/SystemChecker.d.ts +29 -0
- package/dist/src/config/SystemChecker.d.ts.map +1 -0
- package/dist/src/config/SystemChecker.js +85 -0
- package/dist/src/config/SystemChecker.js.map +1 -0
- package/dist/src/config/defaults.d.ts +17 -0
- package/dist/src/config/defaults.d.ts.map +1 -0
- package/dist/src/config/defaults.js +37 -0
- package/dist/src/config/defaults.js.map +1 -0
- package/dist/src/engine/LocalRuntime.d.ts +41 -0
- package/dist/src/engine/LocalRuntime.d.ts.map +1 -0
- package/dist/src/engine/LocalRuntime.js +132 -0
- package/dist/src/engine/LocalRuntime.js.map +1 -0
- package/dist/src/engine/MavenBuilder.d.ts +49 -0
- package/dist/src/engine/MavenBuilder.d.ts.map +1 -0
- package/dist/src/engine/MavenBuilder.js +126 -0
- package/dist/src/engine/MavenBuilder.js.map +1 -0
- package/dist/src/engine/PomParser.d.ts +53 -0
- package/dist/src/engine/PomParser.d.ts.map +1 -0
- package/dist/src/engine/PomParser.js +175 -0
- package/dist/src/engine/PomParser.js.map +1 -0
- package/dist/src/engine/XmlProcessor.d.ts +47 -0
- package/dist/src/engine/XmlProcessor.d.ts.map +1 -0
- package/dist/src/engine/XmlProcessor.js +213 -0
- package/dist/src/engine/XmlProcessor.js.map +1 -0
- package/dist/src/index.d.ts +11 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +13 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/types/index.d.ts +209 -0
- package/dist/src/types/index.d.ts.map +1 -0
- package/dist/src/types/index.js +16 -0
- package/dist/src/types/index.js.map +1 -0
- package/dist/src/utils/exec.d.ts +20 -0
- package/dist/src/utils/exec.d.ts.map +1 -0
- package/dist/src/utils/exec.js +57 -0
- package/dist/src/utils/exec.js.map +1 -0
- package/dist/src/utils/git.d.ts +26 -0
- package/dist/src/utils/git.d.ts.map +1 -0
- package/dist/src/utils/git.js +71 -0
- package/dist/src/utils/git.js.map +1 -0
- package/dist/src/utils/logger.d.ts +21 -0
- package/dist/src/utils/logger.d.ts.map +1 -0
- package/dist/src/utils/logger.js +59 -0
- package/dist/src/utils/logger.js.map +1 -0
- package/package.json +80 -0
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Package API
|
|
3
|
+
*
|
|
4
|
+
* Programmatic interface for building MuleSoft projects.
|
|
5
|
+
*/
|
|
6
|
+
import { existsSync, copyFileSync, writeFileSync, readFileSync, mkdirSync, unlinkSync, rmSync, } from 'fs';
|
|
7
|
+
import { join, basename, relative, dirname } from 'path';
|
|
8
|
+
import { hostname, userInfo } from 'os';
|
|
9
|
+
import { ok, err } from '../types/index.js';
|
|
10
|
+
import { loadConfig, getProfileConfig } from '../config/ConfigLoader.js';
|
|
11
|
+
import { canBuild } from '../config/SystemChecker.js';
|
|
12
|
+
import { stripSecure, enforceSecure, removeSecurePropertiesConfig, getXmlFiles, } from '../engine/XmlProcessor.js';
|
|
13
|
+
import { mavenBuild, findBuiltJar, mavenClean } from '../engine/MavenBuilder.js';
|
|
14
|
+
import { getProjectName, getVersion, setName, backupPom, restorePom } from '../engine/PomParser.js';
|
|
15
|
+
import { logger } from '../utils/logger.js';
|
|
16
|
+
/**
|
|
17
|
+
* Backup XML files from a directory to a backup location
|
|
18
|
+
*/
|
|
19
|
+
function backupXmlFiles(sourceDir, backupDir) {
|
|
20
|
+
const backedUpFiles = [];
|
|
21
|
+
if (!existsSync(sourceDir)) {
|
|
22
|
+
return backedUpFiles;
|
|
23
|
+
}
|
|
24
|
+
// Create backup directory
|
|
25
|
+
mkdirSync(backupDir, { recursive: true });
|
|
26
|
+
// Get all XML files
|
|
27
|
+
const xmlFiles = getXmlFiles(sourceDir);
|
|
28
|
+
for (const file of xmlFiles) {
|
|
29
|
+
const relativePath = relative(sourceDir, file);
|
|
30
|
+
const backupPath = join(backupDir, relativePath);
|
|
31
|
+
// Create subdirectories in backup if needed
|
|
32
|
+
const backupSubDir = dirname(backupPath);
|
|
33
|
+
mkdirSync(backupSubDir, { recursive: true });
|
|
34
|
+
// Copy file to backup
|
|
35
|
+
copyFileSync(file, backupPath);
|
|
36
|
+
backedUpFiles.push(file);
|
|
37
|
+
}
|
|
38
|
+
return backedUpFiles;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Restore XML files from backup
|
|
42
|
+
*/
|
|
43
|
+
function restoreXmlFiles(sourceDir, backupDir) {
|
|
44
|
+
if (!existsSync(backupDir)) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
const xmlFiles = getXmlFiles(backupDir);
|
|
48
|
+
for (const backupFile of xmlFiles) {
|
|
49
|
+
const relativePath = relative(backupDir, backupFile);
|
|
50
|
+
const originalPath = join(sourceDir, relativePath);
|
|
51
|
+
// Restore the file
|
|
52
|
+
copyFileSync(backupFile, originalPath);
|
|
53
|
+
}
|
|
54
|
+
// Clean up backup directory
|
|
55
|
+
try {
|
|
56
|
+
rmSync(backupDir, { recursive: true, force: true });
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
// Ignore cleanup errors
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Build a MuleSoft project package
|
|
64
|
+
*
|
|
65
|
+
* By default, builds without modifying any files.
|
|
66
|
+
* Use `stripSecure: true` to strip secure:: prefixes for local development.
|
|
67
|
+
* Use `environment: 'production'` to enforce secure:: prefixes.
|
|
68
|
+
*/
|
|
69
|
+
export async function packageProject(options = {}) {
|
|
70
|
+
const cwd = options.cwd ?? process.cwd();
|
|
71
|
+
const configChanges = [];
|
|
72
|
+
const muleDir = join(cwd, 'src', 'main', 'mule');
|
|
73
|
+
const backupDir = join(cwd, '.mule-build-backup');
|
|
74
|
+
// Pre-flight check
|
|
75
|
+
const checkResult = await canBuild(cwd);
|
|
76
|
+
if (!checkResult.success) {
|
|
77
|
+
return err(checkResult.error ?? new Error('Build requirements not met'));
|
|
78
|
+
}
|
|
79
|
+
// Load configuration
|
|
80
|
+
const configResult = loadConfig(cwd);
|
|
81
|
+
if (!configResult.success || !configResult.data) {
|
|
82
|
+
return err(configResult.error ?? new Error('Failed to load configuration'));
|
|
83
|
+
}
|
|
84
|
+
const config = configResult.data;
|
|
85
|
+
const profile = options.environment
|
|
86
|
+
? getProfileConfig(config, options.environment)
|
|
87
|
+
: { mavenProfile: undefined, includeSource: options.withSource, secureProperties: undefined };
|
|
88
|
+
// Get project info
|
|
89
|
+
const nameResult = getProjectName(cwd);
|
|
90
|
+
const projectName = nameResult.success && nameResult.data ? nameResult.data : 'mule-app';
|
|
91
|
+
const versionResult = getVersion(cwd);
|
|
92
|
+
const version = options.version ?? (versionResult.success && versionResult.data ? versionResult.data : '1.0.0');
|
|
93
|
+
// Determine build mode
|
|
94
|
+
const buildMode = options.stripSecure
|
|
95
|
+
? 'strip-secure'
|
|
96
|
+
: options.environment === 'production'
|
|
97
|
+
? 'production'
|
|
98
|
+
: 'default';
|
|
99
|
+
logger.info(`Building ${projectName} (mode: ${buildMode})...`);
|
|
100
|
+
// Backup pom.xml
|
|
101
|
+
const pomBackupResult = backupPom(cwd);
|
|
102
|
+
if (!pomBackupResult.success) {
|
|
103
|
+
logger.warn('Could not backup pom.xml, proceeding anyway');
|
|
104
|
+
}
|
|
105
|
+
// Backup XML files before modification (only if stripping)
|
|
106
|
+
let xmlFilesBackedUp = false;
|
|
107
|
+
if (options.stripSecure) {
|
|
108
|
+
logger.step('Backing up XML files...');
|
|
109
|
+
const backedUp = backupXmlFiles(muleDir, backupDir);
|
|
110
|
+
xmlFilesBackedUp = backedUp.length > 0;
|
|
111
|
+
if (xmlFilesBackedUp) {
|
|
112
|
+
logger.debug(`Backed up ${backedUp.length} XML files`);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
try {
|
|
116
|
+
// Clean first
|
|
117
|
+
logger.step('Cleaning previous build...');
|
|
118
|
+
const cleanResult = await mavenClean(cwd);
|
|
119
|
+
if (!cleanResult.success) {
|
|
120
|
+
logger.warn(`Maven clean failed: ${cleanResult.error?.message}, continuing anyway`);
|
|
121
|
+
}
|
|
122
|
+
// Handle stripping for local development (explicit opt-in)
|
|
123
|
+
if (options.stripSecure) {
|
|
124
|
+
logger.step('Stripping secure:: prefixes (--strip-secure)...');
|
|
125
|
+
const stripResult = await stripSecure(muleDir, { cwd });
|
|
126
|
+
if (stripResult.success && stripResult.data) {
|
|
127
|
+
configChanges.push(`Stripped secure:: prefixes from ${stripResult.data.filesProcessed.length} files`);
|
|
128
|
+
configChanges.push(`Total replacements: ${stripResult.data.replacementCount}`);
|
|
129
|
+
}
|
|
130
|
+
// Remove secure-properties:config from global.xml
|
|
131
|
+
const globalXmlPath = join(muleDir, 'global.xml');
|
|
132
|
+
if (existsSync(globalXmlPath)) {
|
|
133
|
+
const content = readFileSync(globalXmlPath, 'utf-8');
|
|
134
|
+
const newContent = removeSecurePropertiesConfig(content);
|
|
135
|
+
if (content !== newContent) {
|
|
136
|
+
writeFileSync(globalXmlPath, newContent);
|
|
137
|
+
configChanges.push('Removed secure-properties:config from global.xml');
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
// Handle production enforcement
|
|
142
|
+
if (options.environment === 'production') {
|
|
143
|
+
logger.step('Validating secure:: enforcement for production...');
|
|
144
|
+
const enforceResult = await enforceSecure(muleDir, { cwd });
|
|
145
|
+
if (enforceResult.success && enforceResult.data && !enforceResult.data.valid) {
|
|
146
|
+
const violations = enforceResult.data.violations;
|
|
147
|
+
logger.error(`Found ${violations.length} unsecured sensitive properties:`);
|
|
148
|
+
for (const v of violations.slice(0, 5)) {
|
|
149
|
+
logger.error(` ${v.file}:${v.line} - ${v.value}`);
|
|
150
|
+
}
|
|
151
|
+
if (violations.length > 5) {
|
|
152
|
+
logger.error(` ... and ${violations.length - 5} more`);
|
|
153
|
+
}
|
|
154
|
+
return err(new Error('Security validation failed. Use secure:: prefix for sensitive properties.'));
|
|
155
|
+
}
|
|
156
|
+
configChanges.push('Validated all sensitive properties have secure:: prefix');
|
|
157
|
+
}
|
|
158
|
+
// Build package name
|
|
159
|
+
const envSuffix = options.environment ? `-${options.environment}` : '';
|
|
160
|
+
const stripSuffix = options.stripSecure && !options.environment ? '-local' : '';
|
|
161
|
+
const envName = `${projectName}${envSuffix}${stripSuffix}-${version}`;
|
|
162
|
+
setName(envName, cwd);
|
|
163
|
+
configChanges.push(`Set package name to: ${envName}`);
|
|
164
|
+
// Run Maven build
|
|
165
|
+
logger.step('Running Maven build...');
|
|
166
|
+
const buildResult = await mavenBuild({
|
|
167
|
+
cwd,
|
|
168
|
+
profile: profile.mavenProfile,
|
|
169
|
+
withSource: options.withSource ?? profile.includeSource ?? false,
|
|
170
|
+
skipTests: options.skipTests ?? false,
|
|
171
|
+
});
|
|
172
|
+
if (!buildResult.success) {
|
|
173
|
+
return err(buildResult.error ?? new Error('Maven build failed'));
|
|
174
|
+
}
|
|
175
|
+
// Find the built JAR
|
|
176
|
+
const jarResult = findBuiltJar(cwd);
|
|
177
|
+
if (!jarResult.success || !jarResult.data) {
|
|
178
|
+
return err(jarResult.error ?? new Error('Could not find built JAR'));
|
|
179
|
+
}
|
|
180
|
+
const jarPath = jarResult.data;
|
|
181
|
+
const originalJarName = basename(jarPath);
|
|
182
|
+
// Copy and rename the JAR
|
|
183
|
+
const timestamp = new Date().toISOString().replace(/[:.]/g, '-').slice(0, 19);
|
|
184
|
+
const finalJarName = `${projectName}${envSuffix}${stripSuffix}-${version}-${timestamp}.jar`;
|
|
185
|
+
const finalJarPath = join(cwd, 'target', finalJarName);
|
|
186
|
+
copyFileSync(jarPath, finalJarPath);
|
|
187
|
+
// Create deployment info
|
|
188
|
+
const deploymentInfo = {
|
|
189
|
+
environment: options.environment,
|
|
190
|
+
packageName: finalJarName,
|
|
191
|
+
version,
|
|
192
|
+
buildDate: new Date().toISOString(),
|
|
193
|
+
builtBy: userInfo().username,
|
|
194
|
+
machine: hostname(),
|
|
195
|
+
configChanges,
|
|
196
|
+
};
|
|
197
|
+
// Write deployment info file
|
|
198
|
+
const infoPath = join(cwd, 'target', 'deployment-info.txt');
|
|
199
|
+
const infoContent = [
|
|
200
|
+
'Package Information:',
|
|
201
|
+
'-------------------',
|
|
202
|
+
`Environment: ${deploymentInfo.environment ?? 'default'}`,
|
|
203
|
+
`Package Name: ${deploymentInfo.packageName}`,
|
|
204
|
+
`Build Date: ${deploymentInfo.buildDate}`,
|
|
205
|
+
`Version: ${deploymentInfo.version}`,
|
|
206
|
+
`Built By: ${deploymentInfo.builtBy}`,
|
|
207
|
+
`Machine: ${deploymentInfo.machine}`,
|
|
208
|
+
'',
|
|
209
|
+
'Configuration Changes Applied:',
|
|
210
|
+
...configChanges.map((c) => `- ${c}`),
|
|
211
|
+
'',
|
|
212
|
+
`Original JAR: ${originalJarName}`,
|
|
213
|
+
`Final Package: ${finalJarName}`,
|
|
214
|
+
].join('\n');
|
|
215
|
+
writeFileSync(infoPath, infoContent);
|
|
216
|
+
logger.success(`Package built successfully: ${finalJarName}`);
|
|
217
|
+
return ok({
|
|
218
|
+
jarPath: finalJarPath,
|
|
219
|
+
deploymentInfo,
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
finally {
|
|
223
|
+
// Restore pom.xml
|
|
224
|
+
restorePom(cwd);
|
|
225
|
+
// Clean up pom.xml backup
|
|
226
|
+
try {
|
|
227
|
+
const pomBackupPath = join(cwd, 'pom.xml.bak');
|
|
228
|
+
if (existsSync(pomBackupPath)) {
|
|
229
|
+
unlinkSync(pomBackupPath);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
catch {
|
|
233
|
+
// Ignore cleanup errors
|
|
234
|
+
}
|
|
235
|
+
// Restore XML files if they were backed up
|
|
236
|
+
if (xmlFilesBackedUp) {
|
|
237
|
+
logger.step('Restoring XML files...');
|
|
238
|
+
restoreXmlFiles(muleDir, backupDir);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
//# sourceMappingURL=package.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"package.js","sourceRoot":"","sources":["../../../src/api/package.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,UAAU,EACV,YAAY,EACZ,aAAa,EACb,YAAY,EACZ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OAAO,EAAE,SAAS,CAAC,CAAC;QACtC,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Release API
|
|
3
|
+
*
|
|
4
|
+
* Programmatic interface for version management and releases.
|
|
5
|
+
*/
|
|
6
|
+
import { Result, ReleaseOptions, ReleaseResult } from '../types/index.js';
|
|
7
|
+
/**
|
|
8
|
+
* Bump version and create a release
|
|
9
|
+
*/
|
|
10
|
+
export declare function releaseVersion(options: ReleaseOptions): Promise<Result<ReleaseResult>>;
|
|
11
|
+
//# sourceMappingURL=release.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"release.d.ts","sourceRoot":"","sources":["../../../src/api/release.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,MAAM,EAAW,cAAc,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAOnF;;GAEG;AACH,wBAAsB,cAAc,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,CAoG5F"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Release API
|
|
3
|
+
*
|
|
4
|
+
* Programmatic interface for version management and releases.
|
|
5
|
+
*/
|
|
6
|
+
import * as semver from 'semver';
|
|
7
|
+
import { ok, err } from '../types/index.js';
|
|
8
|
+
import { canBuild } from '../config/SystemChecker.js';
|
|
9
|
+
import { packageProject } from './package.js';
|
|
10
|
+
import { getVersion, setVersion } from '../engine/PomParser.js';
|
|
11
|
+
import { isGitRepo, isWorkingTreeClean, commit, createTag, pushWithTags } from '../utils/git.js';
|
|
12
|
+
import { logger } from '../utils/logger.js';
|
|
13
|
+
/**
|
|
14
|
+
* Bump version and create a release
|
|
15
|
+
*/
|
|
16
|
+
export async function releaseVersion(options) {
|
|
17
|
+
const cwd = options.cwd ?? process.cwd();
|
|
18
|
+
const shouldTag = options.tag !== false;
|
|
19
|
+
const shouldPush = options.push !== false;
|
|
20
|
+
// Pre-flight checks
|
|
21
|
+
const buildCheck = await canBuild(cwd);
|
|
22
|
+
if (!buildCheck.success) {
|
|
23
|
+
return err(buildCheck.error ?? new Error('Build requirements not met'));
|
|
24
|
+
}
|
|
25
|
+
// Check git repository
|
|
26
|
+
const isRepo = await isGitRepo(cwd);
|
|
27
|
+
if (!isRepo) {
|
|
28
|
+
return err(new Error('Not a git repository'));
|
|
29
|
+
}
|
|
30
|
+
// Check for clean working tree
|
|
31
|
+
const isClean = await isWorkingTreeClean(cwd);
|
|
32
|
+
if (!isClean) {
|
|
33
|
+
return err(new Error('Working tree is not clean. Commit or stash changes first.'));
|
|
34
|
+
}
|
|
35
|
+
// Get current version
|
|
36
|
+
const currentVersionResult = getVersion(cwd);
|
|
37
|
+
if (!currentVersionResult.success || !currentVersionResult.data) {
|
|
38
|
+
return err(currentVersionResult.error ?? new Error('Could not read current version'));
|
|
39
|
+
}
|
|
40
|
+
const currentVersion = currentVersionResult.data;
|
|
41
|
+
// Bump version
|
|
42
|
+
const newVersion = semver.inc(currentVersion, options.bump);
|
|
43
|
+
if (!newVersion) {
|
|
44
|
+
return err(new Error(`Invalid version: ${currentVersion}`));
|
|
45
|
+
}
|
|
46
|
+
logger.info(`Bumping version: ${currentVersion} → ${newVersion}`);
|
|
47
|
+
// Update pom.xml
|
|
48
|
+
const updateResult = setVersion(newVersion, cwd);
|
|
49
|
+
if (!updateResult.success) {
|
|
50
|
+
return err(updateResult.error ?? new Error('Failed to update version in pom.xml'));
|
|
51
|
+
}
|
|
52
|
+
logger.success(`Updated pom.xml version to ${newVersion}`);
|
|
53
|
+
// Build production package
|
|
54
|
+
logger.step('Building production package...');
|
|
55
|
+
const packageResult = await packageProject({
|
|
56
|
+
environment: 'production',
|
|
57
|
+
version: newVersion,
|
|
58
|
+
cwd,
|
|
59
|
+
});
|
|
60
|
+
if (!packageResult.success) {
|
|
61
|
+
// Rollback version change
|
|
62
|
+
setVersion(currentVersion, cwd);
|
|
63
|
+
return err(packageResult.error ?? new Error('Production build failed'));
|
|
64
|
+
}
|
|
65
|
+
// Commit changes
|
|
66
|
+
logger.step('Committing changes...');
|
|
67
|
+
const commitMessage = `Release v${newVersion}`;
|
|
68
|
+
const commitResult = await commit(commitMessage, cwd);
|
|
69
|
+
if (!commitResult.success) {
|
|
70
|
+
return err(commitResult.error ?? new Error('Failed to commit changes'));
|
|
71
|
+
}
|
|
72
|
+
// Create tag
|
|
73
|
+
let tagName;
|
|
74
|
+
if (shouldTag) {
|
|
75
|
+
tagName = `v${newVersion}`;
|
|
76
|
+
logger.step(`Creating tag: ${tagName}...`);
|
|
77
|
+
const tagResult = await createTag(tagName, `Release ${newVersion}`, cwd);
|
|
78
|
+
if (!tagResult.success) {
|
|
79
|
+
return err(tagResult.error ?? new Error('Failed to create tag'));
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
// Push to remote
|
|
83
|
+
let pushed = false;
|
|
84
|
+
if (shouldPush) {
|
|
85
|
+
logger.step('Pushing to remote...');
|
|
86
|
+
const pushResult = await pushWithTags(cwd);
|
|
87
|
+
if (!pushResult.success) {
|
|
88
|
+
logger.warn(`Push failed: ${pushResult.error?.message}. You can push manually.`);
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
pushed = true;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
logger.success(`Released version ${newVersion}`);
|
|
95
|
+
return ok({
|
|
96
|
+
previousVersion: currentVersion,
|
|
97
|
+
newVersion,
|
|
98
|
+
tagName,
|
|
99
|
+
pushed,
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=release.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"release.js","sourceRoot":"","sources":["../../../src/api/release.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AACjC,OAAO,EAAU,EA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IAAI,CAAC;QAChB,CAAC;IACH,CAAC;IAED,MAAM,CAAC,OAAO,CAAC,oBAAoB,UAAU,EAAE,CAAC,CAAC;IAEjD,OAAO,EAAE,CAAC;QACR,eAAe,EAAE,cAAc;QAC/B,UAAU;QACV,OAAO;QACP,MAAM;KACP,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Run API
|
|
3
|
+
*
|
|
4
|
+
* Programmatic interface for local Mule development.
|
|
5
|
+
*/
|
|
6
|
+
import { Result, RunOptions, RunResult } from '../types/index.js';
|
|
7
|
+
/**
|
|
8
|
+
* Build and deploy to local Mule runtime
|
|
9
|
+
*/
|
|
10
|
+
export declare function runLocal(options?: RunOptions): Promise<Result<RunResult>>;
|
|
11
|
+
//# sourceMappingURL=run.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../../src/api/run.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,MAAM,EAAW,UAAU,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAM3E;;GAEG;AACH,wBAAsB,QAAQ,CAAC,OAAO,GAAE,UAAe,GAAG,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAuCnF"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Run API
|
|
3
|
+
*
|
|
4
|
+
* Programmatic interface for local Mule development.
|
|
5
|
+
*/
|
|
6
|
+
import { ok, err } from '../types/index.js';
|
|
7
|
+
import { canRun } from '../config/SystemChecker.js';
|
|
8
|
+
import { packageProject } from './package.js';
|
|
9
|
+
import { deployToLocal } from '../engine/LocalRuntime.js';
|
|
10
|
+
import { logger } from '../utils/logger.js';
|
|
11
|
+
/**
|
|
12
|
+
* Build and deploy to local Mule runtime
|
|
13
|
+
*/
|
|
14
|
+
export async function runLocal(options = {}) {
|
|
15
|
+
const cwd = options.cwd ?? process.cwd();
|
|
16
|
+
// Pre-flight check
|
|
17
|
+
const checkResult = await canRun(cwd);
|
|
18
|
+
if (!checkResult.success) {
|
|
19
|
+
return err(checkResult.error ?? new Error('Run requirements not met'));
|
|
20
|
+
}
|
|
21
|
+
logger.info('Building and deploying to local Mule runtime...');
|
|
22
|
+
// Build with stripped secure prefixes for local development
|
|
23
|
+
const packageResult = await packageProject({
|
|
24
|
+
stripSecure: true, // Strip secure:: for local runtime
|
|
25
|
+
skipTests: true, // Skip tests for local development
|
|
26
|
+
cwd,
|
|
27
|
+
});
|
|
28
|
+
if (!packageResult.success || !packageResult.data) {
|
|
29
|
+
return err(packageResult.error ?? new Error('Package build failed'));
|
|
30
|
+
}
|
|
31
|
+
const jarPath = packageResult.data.jarPath;
|
|
32
|
+
// Deploy to local runtime
|
|
33
|
+
const deployResult = await deployToLocal(jarPath);
|
|
34
|
+
if (!deployResult.success || !deployResult.data) {
|
|
35
|
+
return err(deployResult.error ?? new Error('Deployment failed'));
|
|
36
|
+
}
|
|
37
|
+
logger.success('Application deployed successfully');
|
|
38
|
+
logger.info(deployResult.data.message);
|
|
39
|
+
if (options.debug) {
|
|
40
|
+
logger.info('Debug mode enabled. Connect remote debugger to port 5005.');
|
|
41
|
+
}
|
|
42
|
+
return ok(deployResult.data);
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=run.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run.js","sourceRoot":"","sources":["../../../src/api/run.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAU,EAAE,EAAE,GAAG,EAAyB,MAAM,mBAAmB,CAAC;AAC3E,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAE,MAAM,EAAE,MAAM,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EvC,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;QAClB,MAAM,CAAC,IAAI,CAAC,2DAA2D,CAAC,CAAC;IAC3E,CAAC;IAED,OAAO,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;AAC/B,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Strip API
|
|
3
|
+
*
|
|
4
|
+
* Programmatic interface for stripping secure:: prefixes.
|
|
5
|
+
*/
|
|
6
|
+
import { Result, StripOptions, StripResult } from '../types/index.js';
|
|
7
|
+
/**
|
|
8
|
+
* Strip secure:: prefixes from files
|
|
9
|
+
*/
|
|
10
|
+
export declare function stripSecure(options?: StripOptions): Promise<Result<StripResult>>;
|
|
11
|
+
//# sourceMappingURL=strip.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"strip.d.ts","sourceRoot":"","sources":["../../../src/api/strip.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,EAAE,MAAM,EAAW,YAAY,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAI/E;;GAEG;AACH,wBAAsB,WAAW,CAAC,OAAO,GAAE,YAAiB,GAAG,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,CA8C1F"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Strip API
|
|
3
|
+
*
|
|
4
|
+
* Programmatic interface for stripping secure:: prefixes.
|
|
5
|
+
*/
|
|
6
|
+
import { join } from 'path';
|
|
7
|
+
import { existsSync } from 'fs';
|
|
8
|
+
import { ok, err } from '../types/index.js';
|
|
9
|
+
import { stripSecure as stripSecureEngine } from '../engine/XmlProcessor.js';
|
|
10
|
+
import { logger } from '../utils/logger.js';
|
|
11
|
+
/**
|
|
12
|
+
* Strip secure:: prefixes from files
|
|
13
|
+
*/
|
|
14
|
+
export async function stripSecure(options = {}) {
|
|
15
|
+
const cwd = options.cwd ?? process.cwd();
|
|
16
|
+
// Determine target
|
|
17
|
+
let target;
|
|
18
|
+
if (options.file) {
|
|
19
|
+
target = options.file.startsWith('/') ? options.file : join(cwd, options.file);
|
|
20
|
+
if (!existsSync(target)) {
|
|
21
|
+
return err(new Error(`File not found: ${target}`));
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
else if (options.directory) {
|
|
25
|
+
target = options.directory.startsWith('/') ? options.directory : join(cwd, options.directory);
|
|
26
|
+
if (!existsSync(target)) {
|
|
27
|
+
return err(new Error(`Directory not found: ${target}`));
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
// Default to src/main/mule
|
|
32
|
+
target = join(cwd, 'src', 'main', 'mule');
|
|
33
|
+
if (!existsSync(target)) {
|
|
34
|
+
return err(new Error(`Default directory not found: ${target}`));
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
if (options.dryRun) {
|
|
38
|
+
logger.info('Running in dry-run mode. No files will be modified.');
|
|
39
|
+
}
|
|
40
|
+
const result = await stripSecureEngine(target, {
|
|
41
|
+
dryRun: options.dryRun,
|
|
42
|
+
cwd,
|
|
43
|
+
});
|
|
44
|
+
if (!result.success || !result.data) {
|
|
45
|
+
return err(result.error ?? new Error('Strip operation failed'));
|
|
46
|
+
}
|
|
47
|
+
if (options.dryRun) {
|
|
48
|
+
logger.info(`Would process ${result.data.filesProcessed.length} files`);
|
|
49
|
+
logger.info(`Would make ${result.data.replacementCount} replacements`);
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
logger.success(`Processed ${result.data.filesProcessed.length} files`);
|
|
53
|
+
logger.success(`Made ${result.data.replacementCount} replacements`);
|
|
54
|
+
}
|
|
55
|
+
return ok(result.data);
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=strip.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"strip.js","sourceRoot":"","sources":["../../../src/api/strip.ts"],"names":[],"mappings":"AAAA;;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
|
|
2
|
+
* Mule-Build CLI
|
|
3
|
+
*
|
|
4
|
+
* Command-line interface for MuleSoft build automation.
|
|
5
|
+
*/
|
|
6
|
+
import { Command } from 'commander';
|
|
7
|
+
/**
|
|
8
|
+
* Create and configure the CLI program
|
|
9
|
+
*/
|
|
10
|
+
export declare function createProgram(): Command;
|
|
11
|
+
/**
|
|
12
|
+
* Run the CLI
|
|
13
|
+
*/
|
|
14
|
+
export declare function run(args?: string[]): Promise<void>;
|
|
15
|
+
//# sourceMappingURL=cli.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../src/cli.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAcpC;;GAEG;AACH,wBAAgB,aAAa,IAAI,OAAO,CA8JvC;AAED;;GAEG;AACH,wBAAsB,GAAG,CAAC,IAAI,GAAE,MAAM,EAAiB,GAAG,OAAO,CAAC,IAAI,CAAC,CAGtE"}
|