Skip to content

feat(create-cli): setup wizard architecture#1248

Open
hanna-skryl wants to merge 2 commits intomainfrom
setup-wizard-architecture
Open

feat(create-cli): setup wizard architecture#1248
hanna-skryl wants to merge 2 commits intomainfrom
setup-wizard-architecture

Conversation

@hanna-skryl
Copy link
Collaborator

@hanna-skryl hanna-skryl commented Feb 17, 2026

Closes #1240

Break create-cli's dependency on nx-plugin and rebuild the package around a modular setup wizard. Uses ts-morph for AST-based config generation, @inquirer/prompts for interactive input, and a virtual Tree for buffered file writes with dry-run support.

@github-actions github-actions bot added 📖 Project documentation improvements or additions to the project documentation 🔬 testing writing tests 🛠️ tooling 🧩 create-cli labels Feb 17, 2026
@nx-cloud
Copy link

nx-cloud bot commented Feb 17, 2026

View your CI Pipeline Execution ↗ for commit 3e6bc84

Command Status Duration Result
nx run ci:code-pushup -- merge-diffs --files=/h... ✅ Succeeded 5s View ↗
nx run-many --targets=code-pushup --parallel=fa... ✅ Succeeded 1m 27s View ↗
nx run-many --targets=code-pushup --parallel=fa... ✅ Succeeded 12m 28s View ↗
nx run-many -t unit-test,int-test ✅ Succeeded 2s View ↗

☁️ Nx Cloud last updated this comment at 2026-02-17 18:20:43 UTC

@pkg-pr-new
Copy link

pkg-pr-new bot commented Feb 17, 2026

Open in StackBlitz

@code-pushup/ci

npm i https://pkg.pr.new/code-pushup/cli/@code-pushup/ci@1248

@code-pushup/cli

npm i https://pkg.pr.new/code-pushup/cli/@code-pushup/cli@1248

@code-pushup/create-cli

npm i https://pkg.pr.new/code-pushup/cli/@code-pushup/create-cli@1248

@code-pushup/core

npm i https://pkg.pr.new/code-pushup/cli/@code-pushup/core@1248

@code-pushup/models

npm i https://pkg.pr.new/code-pushup/cli/@code-pushup/models@1248

@code-pushup/nx-plugin

npm i https://pkg.pr.new/code-pushup/cli/@code-pushup/nx-plugin@1248

@code-pushup/axe-plugin

npm i https://pkg.pr.new/code-pushup/cli/@code-pushup/axe-plugin@1248

@code-pushup/coverage-plugin

npm i https://pkg.pr.new/code-pushup/cli/@code-pushup/coverage-plugin@1248

@code-pushup/eslint-plugin

npm i https://pkg.pr.new/code-pushup/cli/@code-pushup/eslint-plugin@1248

@code-pushup/js-packages-plugin

npm i https://pkg.pr.new/code-pushup/cli/@code-pushup/js-packages-plugin@1248

@code-pushup/jsdocs-plugin

npm i https://pkg.pr.new/code-pushup/cli/@code-pushup/jsdocs-plugin@1248

@code-pushup/lighthouse-plugin

npm i https://pkg.pr.new/code-pushup/cli/@code-pushup/lighthouse-plugin@1248

@code-pushup/typescript-plugin

npm i https://pkg.pr.new/code-pushup/cli/@code-pushup/typescript-plugin@1248

@code-pushup/utils

npm i https://pkg.pr.new/code-pushup/cli/@code-pushup/utils@1248

commit: 3e6bc84

@github-actions
Copy link
Contributor

github-actions bot commented Feb 17, 2026

Code PushUp

🤨 Code PushUp report has both improvements and regressions – compared current commit 880b65a with previous commit dd6e35e.

🕵️ See full comparison in Code PushUp portal 🔍

🏷️ Categories

🏷️ Category ⭐ Previous score ⭐ Current score 🔄 Score change
Security 🔴 39 🔴 28 ↓ −10.9
Best Practices 🟢 100 🟢 97 ↓ −3.4
Performance 🔴 36 🔴 33 ↓ −3.2
Updates 🟡 75 🟡 76 ↑ +0.7
Documentation 🟡 53 🟡 53 ↓ −0.1
Code coverage 🟢 93 🟢 93 ↑ +0.1
Bug prevention 🟡 75 🟡 75 ↓ −0.1
Axe Accessibility 🟡 88 🟡 88 ↓ −0.1
Code style 🟢 100 🟢 100
Type Safety 🟡 67 🟡 67
Miscellaneous 🟡 67 🟡 67
Accessibility 🟢 92 🟢 92
SEO 🟢 92 🟢 92
👍 2 groups improved, 👎 4 groups regressed, 👍 5 audits improved, 👎 8 audits regressed, 16 audits changed without impacting score

🗃️ Groups

🔌 Plugin 🗃️ Group ⭐ Previous score ⭐ Current score 🔄 Score change
JS packages npm audit 🔴 39 🔴 28 ↓ −10.9
Lighthouse Best Practices 🟢 100 🟢 97 ↓ −3.4
Lighthouse Performance 🔴 36 🔴 33 ↓ −3.2
JS packages npm outdated dependencies 🟡 75 🟡 76 ↑ +0.7
JSDocs coverage Documentation coverage 🟡 53 🟡 53 ↓ −0.1
Code coverage Code coverage metrics 🟢 93 🟢 93 ↑ +0.1

28 other groups are unchanged.

🛡️ Audits

🔌 Plugin 🛡️ Audit 📏 Previous value 📏 Current value 🔄 Value change
Lighthouse No issues in the Issues panel in Chrome Devtools 🟩 passed 🟥 failed ↓ −100 %
JS packages Vulnerabilities for npm prod dependencies. 🟥 12 vulnerabilities (3 high, 2 moderate, 7 low) 🟥 14 vulnerabilities (3 high, 5 moderate, 6 low) ↑ +16.7 %
Lighthouse Total Blocking Time 🟥 1,630 ms 🟥 3,200 ms ↑ +96.4 %
Lighthouse Time to Interactive 🟥 13.5 s 🟥 15.0 s ↑ +10.8 %
Lighthouse Speed Index 🟥 7.3 s 🟥 7.4 s ↑ +0.6 %
Lighthouse First Contentful Paint 🟥 3.1 s 🟥 3.1 s ↑ +1 %
JS packages Outdated npm prod dependencies. 🟨 20 outdated package versions (6 major, 10 minor, 4 patch) 🟨 21 outdated package versions (6 major, 10 minor, 5 patch) ↑ +5 %
JSDocs coverage Types coverage 🟥 264 undocumented types 🟥 275 undocumented types ↑ +4.2 %
JSDocs coverage Functions coverage 🟥 585 undocumented functions 🟥 590 undocumented functions ↑ +0.9 %
Code coverage Function coverage 🟩 94.4 % 🟩 94.4 % ↑ +0.1 %
Code coverage Branch coverage 🟨 89.2 % 🟨 89.2 % ↑ +0.1 %
JSDocs coverage Variables coverage 🟥 273 undocumented variables 🟥 272 undocumented variables ↓ −0.4 %
Code coverage Line coverage 🟩 92.7 % 🟩 92.7 % ↑ +0.1 %
Lighthouse Avoids enormous network payloads 🟩 Total size was 2,091 KiB 🟩 Total size was 2,160 KiB ↑ +3.3 %
Lighthouse Minimizes main-thread work 🟥 10.3 s 🟥 13.1 s ↑ +27.6 %
Lighthouse JavaScript execution time 🟥 3.0 s 🟥 5.7 s ↑ +88.5 %
Lighthouse Metrics 🟩 100% 🟩 100% ↑ +10.8 %
Lighthouse Server Backend Latencies 🟩 310 ms 🟩 1,590 ms ↑ +407 %
Lighthouse Largest Contentful Paint 🟥 11.6 s 🟥 12.8 s ↑ +10.4 %
Lighthouse Max Potential First Input Delay 🟥 990 ms 🟥 1,490 ms ↑ +50.4 %
Lighthouse Uses efficient cache policy on static assets 🟨 31 resources found 🟨 31 resources found ↓ −0.1 %
Lighthouse Remove duplicate modules in JavaScript bundles 🟥 Potential savings of 93 KiB 🟥 Potential savings of 96 KiB ↑ +40.6 %
Lighthouse Reduce unused JavaScript 🟥 Potential savings of 225 KiB 🟥 Potential savings of 272 KiB ↑ +9 %
Lighthouse Reduce unused CSS 🟥 Potential savings of 111 KiB 🟥 Potential savings of 110 KiB ↓ −6.2 %
Lighthouse Initial server response time was short 🟩 Root document took 510 ms 🟩 Root document took 520 ms ↑ +3.1 %
Lighthouse Network Round Trip Times 🟩 30 ms 🟩 20 ms ↓ −30.9 %
JS packages Vulnerabilities for npm dev dependencies. 🟥 48 vulnerabilities (3 critical, 9 high, 32 moderate, 4 low) 🟥 53 vulnerabilities (3 critical, 9 high, 37 moderate, 4 low) ↑ +10.4 %
Lighthouse Avoids an excessive DOM size 🟥 2,366 elements 🟥 2,367 elements ↑ +0.1 %
Lighthouse Cumulative Layout Shift 🟩 0 🟩 0.001 ↑ +∞ %

649 other audits are unchanged.

@github-actions
Copy link
Contributor

github-actions bot commented Feb 17, 2026

Code PushUp

🥳 Code PushUp report has improved – compared current commit 880b65a with previous commit dd6e35e.

💼 Project create-cli

🥳 Code PushUp report has improved.

🕵️ See full comparison in Code PushUp portal 🔍

🏷️ Category ⭐ Previous score ⭐ Current score 🔄 Score change
Code coverage 🟢 96 🟢 98 ↑ +1.8
Documentation 🟡 64 🟡 64 ↑ +0.7

4 other categories are unchanged.

👍 2 groups improved, 👍 3 audits improved, 2 audits changed without impacting score

🗃️ Groups

🔌 Plugin 🗃️ Group ⭐ Previous score ⭐ Current score 🔄 Score change
Code coverage Code coverage metrics 🟢 96 🟢 98 ↑ +1.8
JSDocs coverage Documentation coverage 🟡 64 🟡 64 ↑ +0.7

13 other groups are unchanged.

🛡️ Audits

🔌 Plugin 🛡️ Audit 📏 Previous value 📏 Current value 🔄 Value change
JSDocs coverage Types coverage 🟥 1 undocumented types 🟥 12 undocumented types ↑ +1100 %
Code coverage Branch coverage 🟨 87.5 % 🟩 93 % ↑ +6.3 %
Code coverage Line coverage 🟩 97 % 🟩 98.2 % ↑ +1.3 %
JSDocs coverage Functions coverage 🟥 6 undocumented functions 🟥 11 undocumented functions ↑ +83.3 %
JSDocs coverage Variables coverage 🟥 5 undocumented variables 🟥 4 undocumented variables ↓ −20 %

438 other audits are unchanged.

💼 Project utils

🥳 Code PushUp report has improved.

🕵️ See full comparison in Code PushUp portal 🔍

🏷️ Category ⭐ Previous score ⭐ Current score 🔄 Score change
Documentation 🟡 60 🟡 60 ↑ +0.1

5 other categories are unchanged.

👍 1 group improved

🗃️ Groups

🔌 Plugin 🗃️ Group ⭐ Previous score ⭐ Current score 🔄 Score change
JSDocs coverage Documentation coverage 🟡 60 🟡 60 ↑ +0.1

14 other groups are unchanged.

🛡️ Audits

All of 444 audits are unchanged.


12 other projects are unchanged.

@hanna-skryl hanna-skryl marked this pull request as ready for review February 17, 2026 18:33
Copy link
Collaborator

@matejchalk matejchalk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks really promising 🙂


```bash
npx init @code-pushup/cli
npx @code-pushup/create-cli
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's use npm init @code-pushup/cli in our documentation examples. The npm init command is commonly used for these setup tools. The package was named @code-pushup/create-cli to be compatible with it.

Comment on lines 18 to 21
'@nx/dependency-checks': [
'error',
{ ignoredDependencies: ['@code-pushup/nx-plugin'] }, // nx-plugin is run via CLI
{ ignoredDependencies: ['@code-pushup/models'] },
],
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would add @code-pushup/models to package.json dependencies instead. It's not strictly necessary at present because there's only a type import, but adding a runtime import would break the installation without being caught by the linter.

.parse();

// TODO: #1244 — provide plugin bindings from registry
await runSetupWizard([], argv as CliArgs);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The argv type is actually inferred by yargs and is assignable to CliArgs, so the type-cast is unnecessary and could mask incompatibilities in the future.

Suggested change
await runSetupWizard([], argv as CliArgs);
await runSetupWizard([], argv);

logger.info('Setup complete.');
logger.newline();
logNextSteps([
['npx code-pushup collect', 'Run your first report'],
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't created a sub-issue for it yet, but I'd like to also add an optional step to configure uploads. This could be useful for users who are already self-hosting the Portal.

Therefore, I would prompt them to run the (implicit) autorun command, so that their report may also be uploaded.

Suggested change
['npx code-pushup collect', 'Run your first report'],
['npx code-pushup', 'Collect your first report'],

Comment on lines +3 to +11
/** Virtual file system that buffers writes in memory until flushed to disk. */
export type Tree = {
root: string;
exists: (filePath: string) => boolean;
read: (filePath: string) => string | null;
write: (filePath: string, content: string) => void;
listChanges: () => FileChange[];
flush: () => Promise<void>;
};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer to use async I/O (node:fs/promises), unless there's a good reason not to. It's non-blocking, which can sometimes be an advantage - e.g., easy parallelization with Promise.all. And I think it's generally useful to have external and potentially slow operations "marked" with awaits.

Comment on lines +64 to +70
function logNextSteps(steps: [string, string][]): void {
const colWidth = Math.max(...steps.map(([label]) => label.length));
logger.info('Next steps:');
steps.forEach(([label, description]) => {
logger.info(` ${label.padEnd(colWidth + COLUMN_GAP)}${description}`);
});
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could use formatAsciiTable with the { borderless: true } option, then it'll calculate the padding for you.

Comment on lines +17 to +20
const pending = new Map<
string,
{ content: string; type: 'CREATE' | 'UPDATE' }
>();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is very much a nitpick and a matter of preference, but you could reference the FileChange type explicitly here.

Suggested change
const pending = new Map<
string,
{ content: string; type: 'CREATE' | 'UPDATE' }
>();
const pending = new Map<FileChange['path'], Omit<FileChange, 'path'>>();

Comment on lines +19 to +22
function buildExportStatement(plugins: PluginCodegenResult[]): string {
const items = plugins.map(({ pluginInit }) => pluginInit).join(', ');
return `export default { plugins: [${items}] } satisfies CoreConfig;`;
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you considered using StatementStructures? It seems a bit more robust than concatenating strings. The plugins could also register their init code as an AST.

Comment on lines +7 to +11
[
"import type { CoreConfig } from '@code-pushup/models';",
'export default { plugins: [] } satisfies CoreConfig;',
'',
].join('\n'),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be more readable to have a separator line between the imports and the config export. 🙏

Comment on lines +59 to +67
expect(generateConfigSource(plugins)).toBe(
[
"import type { CoreConfig } from '@code-pushup/models';",
"import eslintPlugin from '@code-pushup/eslint-plugin';",
"import coveragePlugin from '@code-pushup/coverage-plugin';",
"export default { plugins: [await eslintPlugin(), await coveragePlugin({ reports: [{ resultsPath: 'coverage/lcov.info', pathToProject: '' }] })] } satisfies CoreConfig;",
'',
].join('\n'),
);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This generates quite a long line. Does ts-morph not wrap long lines? If not, we could run prettier on the output.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🧩 create-cli 📖 Project documentation improvements or additions to the project documentation 🔬 testing writing tests 🛠️ tooling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Architecture for setup wizard

2 participants

Comments