Skip to content

Commit 4842957

Browse files
committed
refactor: replace logger with stdout.write in scaffold/cache commands
Replace @pgpmjs/logger usage with plain process.stdout.write and process.stderr.write in the init/workspace, init/module, and cache commands. This keeps testing cleaner by avoiding the Logger's colored prefixes and formatting. Files changed: - pgpm/cli/src/commands/init/workspace.ts - pgpm/cli/src/commands/init/module.ts - pgpm/cli/src/commands/cache.ts
1 parent 0b4147d commit 4842957

File tree

3 files changed

+6
-16
lines changed

3 files changed

+6
-16
lines changed

pgpm/cli/src/commands/cache.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
1-
import { Logger } from '@pgpmjs/logger';
21
import { CLIOptions, Inquirerer } from 'inquirerer';
32
import { CacheManager } from 'create-gen-app';
43
import { cliExitWithError } from '../utils/cli-error';
54

6-
const log = new Logger('cache');
7-
85
const cacheUsageText = `
96
Cache Command:
107
@@ -35,8 +32,7 @@ export default async (
3532
const cacheManager = new CacheManager({ toolName });
3633

3734
cacheManager.clearAll();
38-
log.success(`Cleared template cache for "${toolName}".`);
39-
log.debug(`Cache location: ${cacheManager.getReposDir()}`);
35+
process.stdout.write(`Cleared template cache for "${toolName}".\n`);
4036

4137
return argv;
4238
};

pgpm/cli/src/commands/init/module.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
import { DEFAULT_TEMPLATE_REPO, DEFAULT_TEMPLATE_TOOL_NAME, PgpmPackage, sluggify } from '@pgpmjs/core';
2-
import { Logger } from '@pgpmjs/logger';
32
import { errors } from '@pgpmjs/types';
43
import { Inquirerer, OptionValue, Question } from 'inquirerer';
54

6-
const log = new Logger('module-init');
7-
85
export default async function runModuleSetup(
96
argv: Partial<Record<string, any>>,
107
prompter: Inquirerer
@@ -14,12 +11,12 @@ export default async function runModuleSetup(
1411
const project = new PgpmPackage(cwd);
1512

1613
if (!project.workspacePath) {
17-
log.error('Not inside a PGPM workspace.');
14+
process.stderr.write('Not inside a PGPM workspace.\n');
1815
throw errors.NOT_IN_WORKSPACE({});
1916
}
2017

2118
if (!project.isInsideAllowedDirs(cwd) && !project.isInWorkspace() && !project.isParentOfAllowedDirs(cwd)) {
22-
log.error('You must be inside the workspace root or a parent directory of modules (like packages/).');
19+
process.stderr.write('You must be inside the workspace root or a parent directory of modules (like packages/).\n');
2320
throw errors.NOT_IN_WORKSPACE_MODULE({});
2421
}
2522

@@ -74,6 +71,6 @@ export default async function runModuleSetup(
7471
noTty: Boolean((argv as any).noTty || argv['no-tty'] || process.env.CI === 'true')
7572
});
7673

77-
log.success(`Initialized module: ${modName}`);
74+
process.stdout.write(`Initialized module: ${modName}\n`);
7875
return { ...argv, ...answers };
7976
}

pgpm/cli/src/commands/init/workspace.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
import { DEFAULT_TEMPLATE_REPO, DEFAULT_TEMPLATE_TOOL_NAME, scaffoldTemplate, sluggify } from '@pgpmjs/core';
2-
import { Logger } from '@pgpmjs/logger';
32
import { Inquirerer, Question, registerDefaultResolver } from 'inquirerer';
43
import path from 'path';
54

6-
const log = new Logger('workspace-init');
7-
85
export default async function runWorkspaceSetup(
96
argv: Partial<Record<string, any>>,
107
prompter: Inquirerer
@@ -52,8 +49,8 @@ export default async function runWorkspaceSetup(
5249
const cacheMessage = scaffoldResult.cacheUsed
5350
? `Using cached templates from ${scaffoldResult.templateDir}`
5451
: `Fetched templates into ${scaffoldResult.templateDir}`;
55-
log.success(cacheMessage);
56-
log.success('Workspace templates rendered.');
52+
process.stdout.write(`${cacheMessage}\n`);
53+
process.stdout.write('Workspace templates rendered.\n');
5754

5855
return { ...argv, ...answers, cwd: targetPath };
5956
}

0 commit comments

Comments
 (0)