Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions src/classes/Runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ export default class Runner {

coloredOutput = true;

dryRun = false;

static workspace = new Map<string, Set<string>>();

constructor(...args: readonly string[]) {
Expand All @@ -56,6 +58,7 @@ export default class Runner {
.option('-nc, --noCache', 'default: false. If true, will skip the cache and execute the target.')
.option('-np, --noPipe', 'default: false. If true, will skip the pipe and execute the target.')
.option('-co, --coloredOutput <color>', 'default: true. If false, will disable colors in the console.', 'true')
.option('-dr, --dryRun', 'default: false. If true, will show what would be built without actually executing builds.')
.addOption(
new Option(
'-l, --logLevel <logLevel>',
Expand Down Expand Up @@ -112,6 +115,9 @@ export default class Runner {
ZENITH_READ_ONLY: true
});
}
if (options.dryRun) {
this.dryRun = true;
}
this.debugLocation = options.debugLocation;
this.worker = options.worker;
this.pipe = options.noPipe ? [] : ConfigHelperInstance.pipe;
Expand Down Expand Up @@ -158,6 +164,7 @@ export default class Runner {
skipPackageJson: this.skipPackageJson,
singleCache: this.singleCache,
noCache: configManagerInstance.getConfigValue('ZENITH_NO_CACHE'),
dryRun: this.dryRun,
...config
};
const buildType = buildConfig.singleCache ? 'single' : 'project';
Expand All @@ -166,7 +173,47 @@ export default class Runner {
if (Runner.workspace.size === 0) {
Runner.workspace = deepCloneMap(Builder.getProjects());
}

if (this.dryRun) {
this.printDryRunInfo(command, Builder.getProjects());
return;
}

Logger.log(2, Builder.outputColor, `Zenith ${command} started.`);
await Builder.build();
}

private printDryRunInfo(command: string, projects: Map<string, Set<string>>): void {
console.log('');
console.log('🔍 [DRY RUN] Build Plan');
console.log('═══════════════════════════════════════');
console.log(` Target: ${command}`);
console.log(` Project filter: ${this.project}`);
console.log(` Skip dependencies: ${this.skipDependencies}`);
console.log(` Only dependencies: ${this.onlyDependencies}`);
console.log(` Single cache: ${this.singleCache}`);
console.log('');
console.log('📦 Projects to be built:');
console.log('───────────────────────────────────────');

const projectList = Array.from(projects.keys());
if (projectList.length === 0) {
console.log(' No projects matched the filter.');
} else {
for (const projectName of projectList) {
const deps = projects.get(projectName);
const depCount = deps ? deps.size : 0;
console.log(` • ${projectName}`);
if (depCount > 0 && !this.skipDependencies) {
console.log(` └─ Dependencies: ${Array.from(deps || []).join(', ')}`);
}
}
}

console.log('');
console.log(`📊 Summary: ${projectList.length} project(s) would be built`);
console.log('');
console.log('💡 Remove --dry-run flag to execute the build.');
console.log('');
}
}
1 change: 1 addition & 0 deletions src/types/BuildTypes.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export interface BuildParams {
skipPackageJson: boolean;
singleCache: boolean;
noCache: boolean;
dryRun?: boolean;
project: string;
workspace: Map<string, Set<string>>;
}
Expand Down
1 change: 1 addition & 0 deletions tsconfig.tsbuildinfo
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"root":["./src/config.ts","./src/index.ts","./src/run.ts","./src/worker.ts","./src/classes/confighelper.ts","./src/classes/hasher.ts","./src/classes/runner.ts","./src/classes/workerhelper.ts","./src/classes/zipper.js","./src/classes/builder/buildhelper.ts","./src/classes/builder/builderfactory.ts","./src/classes/builder/singlebuilder.ts","./src/classes/cache/cachefactory.ts","./src/classes/cache/cacher.ts","./src/classes/cache/hybridcacher.ts","./src/classes/cache/localcacher.ts","./src/classes/cache/remotecacher.ts","./src/commands/graph/graph.ts","./src/commands/graph/runner.ts","./src/commands/graph/server/index.js","./src/libs/unzippedreader.ts","./src/libs/zipexporter.ts","./src/types/buildtypes.d.ts","./src/types/configtypes.d.ts","./src/types/jszip.d.ts","./src/types/remotecachetypes.d.ts","./src/types/index.d.ts","./src/utils/constants.ts","./src/utils/functions.ts","./src/utils/logger.ts"],"version":"5.9.3"}