-
-
Notifications
You must be signed in to change notification settings - Fork 3k
refactor(cli): info #14609
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+1,482
−395
Merged
refactor(cli): info #14609
Changes from all commits
Commits
Show all changes
49 commits
Select commit
Hold shift + click to select a range
757e868
refactor(cli): info
florian-lefebvre 74908ca
Merge branch 'main' into refactor/cli-info
florian-lefebvre 997042a
feat: change abstraction
florian-lefebvre 86fd0b6
feat: wiring
florian-lefebvre 9595356
feat: package managers
florian-lefebvre e571f29
feat: formatter
florian-lefebvre aa96e4e
wip
florian-lefebvre 3d2b471
Merge branch 'main' into refactor/cli-info
florian-lefebvre b0d4025
fix: build
florian-lefebvre 29bc8b6
fix: misc
florian-lefebvre e7e9160
fix: copy to clipboard without styles
florian-lefebvre 1f95d34
feat: unify
florian-lefebvre 6763db7
feat: move
florian-lefebvre 1eac498
Merge branch 'main' into refactor/cli-info
florian-lefebvre 572f3e1
chore: format
florian-lefebvre 6f09256
feat: misc
florian-lefebvre 52d7655
Merge branch 'main' into refactor/cli-info
florian-lefebvre 6fb919c
fix: build
florian-lefebvre a607b92
fix: tests
florian-lefebvre 537030d
Merge branch 'main' into refactor/cli-info
florian-lefebvre aae49fc
fix: test
florian-lefebvre 2d6fa7c
fix: db tests
florian-lefebvre c960238
fix: test
florian-lefebvre e96b67f
feat: improve perf
florian-lefebvre ac96b46
fix
florian-lefebvre 8264e47
Merge branch 'main' into refactor/cli-info
florian-lefebvre fcd9816
Merge branch 'main' into refactor/cli-info
florian-lefebvre 5835582
Merge branch 'main' into refactor/cli-info
florian-lefebvre 68ec32b
chore: comment
florian-lefebvre 22e4269
feat: new abstraction
florian-lefebvre 7e31d56
feat: test
florian-lefebvre fd14128
feat: test
florian-lefebvre 32409c5
chore: format
florian-lefebvre 7e965ab
Merge branch 'main' into refactor/cli-info
florian-lefebvre 28e5698
feat: tests
florian-lefebvre 7600655
fix: tests
florian-lefebvre 2acaaf6
Merge branch 'main' into refactor/cli-info
florian-lefebvre a395292
feat: add tests
florian-lefebvre 4b5d5eb
Merge branch 'main' into refactor/cli-info
florian-lefebvre 1726423
fix: test
florian-lefebvre 83fc29f
feat: add tests
florian-lefebvre 1d4c8c2
feat: add tests
florian-lefebvre 945e94d
feat: add tests
florian-lefebvre ee5332a
chore: changeset
florian-lefebvre 1ded1f7
feedback
florian-lefebvre ee13ad6
error handling
florian-lefebvre 43767d8
document
florian-lefebvre bb5dcb9
feat: rename
florian-lefebvre 9dc1805
fix: lint
florian-lefebvre File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| 'astro': patch | ||
| --- | ||
|
|
||
| Improves `astro info` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| import type { CommandExecutor } from '../../definitions.js'; | ||
| import type { PackageManager, PackageManagerUserAgentProvider } from '../definitions.js'; | ||
|
|
||
| interface Options { | ||
| packageManagerUserAgentProvider: PackageManagerUserAgentProvider; | ||
| commandExecutor: CommandExecutor; | ||
| } | ||
|
|
||
| export async function getPackageManager({ | ||
| packageManagerUserAgentProvider, | ||
| commandExecutor, | ||
| }: Options): Promise<PackageManager> { | ||
| const userAgent = packageManagerUserAgentProvider.getUserAgent(); | ||
| if (!userAgent) { | ||
| const { createNoopPackageManager } = await import('../infra/noop-package-manager.js'); | ||
| return createNoopPackageManager(); | ||
| } | ||
| const specifier = userAgent.split(' ')[0]; | ||
| const _name = specifier.substring(0, specifier.lastIndexOf('/')); | ||
| const name = _name === 'npminstall' ? 'cnpm' : _name; | ||
|
|
||
| switch (name) { | ||
| case 'pnpm': { | ||
| const { createPnpmPackageManager } = await import('../infra/pnpm-package-manager.js'); | ||
| return createPnpmPackageManager({ commandExecutor }); | ||
| } | ||
| case 'npm': { | ||
| const { createNpmPackageManager } = await import('../infra/npm-package-manager.js'); | ||
| return createNpmPackageManager({ commandExecutor }); | ||
| } | ||
| case 'yarn': { | ||
| const { createYarnPackageManager } = await import('../infra/yarn-package-manager.js'); | ||
| return createYarnPackageManager({ commandExecutor }); | ||
| } | ||
| case 'bun': { | ||
| const { createBunPackageManager } = await import('../infra/bun-package-manager.js'); | ||
| return createBunPackageManager(); | ||
| } | ||
| default: { | ||
| const { createNoopPackageManager } = await import('../infra/noop-package-manager.js'); | ||
| return createNoopPackageManager(); | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| import type { Logger } from '../../../core/logger/core.js'; | ||
| import { defineCommand } from '../../domain/command.js'; | ||
| import type { Clipboard, DebugInfoFormatter, DebugInfoProvider } from '../definitions.js'; | ||
|
|
||
| interface Options { | ||
| debugInfoProvider: DebugInfoProvider; | ||
| getDebugInfoFormatter: (options: { pretty: boolean }) => DebugInfoFormatter; | ||
| logger: Logger; | ||
| clipboard: Clipboard; | ||
| } | ||
|
|
||
| export const infoCommand = defineCommand({ | ||
| help: { | ||
| commandName: 'astro info', | ||
| tables: { | ||
| Flags: [ | ||
| ['--help (-h)', 'See all available flags.'], | ||
| ['--copy', 'Force copy of the output.'], | ||
| ], | ||
| }, | ||
| description: | ||
| 'Reports useful information about your current Astro environment. Useful for providing information when opening an issue.', | ||
| }, | ||
| async run({ debugInfoProvider, getDebugInfoFormatter, logger, clipboard }: Options) { | ||
| const debugInfo = await debugInfoProvider.get(); | ||
| logger.info('SKIP_FORMAT', getDebugInfoFormatter({ pretty: true }).format(debugInfo)); | ||
| await clipboard.copy(getDebugInfoFormatter({ pretty: false }).format(debugInfo)); | ||
| }, | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| import type { AstroConfig } from '../../types/public/index.js'; | ||
| import type { DebugInfo } from './domain/debug-info.js'; | ||
|
|
||
| export interface DebugInfoProvider { | ||
| get: () => Promise<DebugInfo>; | ||
| } | ||
|
|
||
| export interface DebugInfoFormatter { | ||
| format: (info: DebugInfo) => string; | ||
| } | ||
|
|
||
| export interface Clipboard { | ||
| copy: (text: string) => Promise<void>; | ||
| } | ||
|
|
||
| export interface PackageManager { | ||
| getName: () => string; | ||
| getPackageVersion: (name: string) => Promise<string | undefined>; | ||
| } | ||
|
|
||
| export interface AstroConfigResolver { | ||
| resolve: () => Promise<AstroConfig>; | ||
| } | ||
|
|
||
| export interface Prompt { | ||
| confirm: (input: { message: string; defaultValue?: boolean }) => Promise<boolean>; | ||
| } | ||
|
|
||
| export interface PackageManagerUserAgentProvider { | ||
| getUserAgent: () => string | null; | ||
| } | ||
|
|
||
| export interface NodeVersionProvider { | ||
| get: () => string; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export type DebugInfo = Array<[string, string | Array<string>]>; | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this go to
info/definitions.ts?Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think so. Currently the structure I've been following is:
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't documented anywhere:
You raised a similar PR for fonts now, and I would expect the same infrastructure. Should address this comment first?
i.e. you explained to me the folder structure, but I still don't understand why
debug-info.tsmust be here... honestly, it's all foggy. Maybe let's raise a PR that explains this folder/business logic structure.Not a blocker, but something you should consider
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, I'll make a follow up PR with guidelines