Skip to content
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

feat: adding fuels info command #2802

Closed
wants to merge 16 commits into from
6 changes: 6 additions & 0 deletions .changeset/proud-pumpkins-sleep.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@fuel-ts/versions": patch
"fuels": patch
---

feat: adding `fuels info` command
9 changes: 8 additions & 1 deletion packages/fuels/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { Command, Option } from 'commander';
import { build } from './cli/commands/build';
import { deploy } from './cli/commands/deploy';
import { dev } from './cli/commands/dev';
import { runInfo } from './cli/commands/info';
import { init } from './cli/commands/init';
import { node } from './cli/commands/node';
import { withBinaryPaths } from './cli/commands/withBinaryPaths';
Expand Down Expand Up @@ -97,9 +98,15 @@ export const configureCli = () => {

// Versions
(command = program.command('versions'))
.description('Check for version incompatibilities')
.description('Checks for version incompatibilities')
.addOption(pathOption)
.action(withBinaryPaths(command, Commands.versions, runVersions));

// Info
(command = program.command('info'))
.description('Prints versions information')
.addOption(pathOption)
.action(withProgram(command, Commands.init, runInfo));

return program;
};
8 changes: 8 additions & 0 deletions packages/fuels/src/cli/commands/info/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { type Command } from 'commander';
import { dir } from 'console';

import { snapshot } from './snapshot';

export function runInfo(_program: Command) {
dir(snapshot);
}
13 changes: 13 additions & 0 deletions packages/fuels/src/cli/commands/info/snapshot.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { versions } from '@fuel-ts/versions';
import { getSystemVersions } from '@fuel-ts/versions/cli-utils';
import os from 'node:os';

export const snapshot = {
sdkVersions: versions,
toolchainVersions: getSystemVersions(),
// fuelupShow: execSync('fuelup show')?.toString('utf8'),
nodeVersion: process.version,
// browserVersion: detectBrowser() ?
osType: os.type(),
osArch: os.arch(),
};
9 changes: 7 additions & 2 deletions packages/fuels/src/cli/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ export enum Commands {
deploy = 'deploy',
dev = 'dev',
init = 'init',
versions = 'versions',
node = 'node',
versions = 'versions',
info = 'info',
}

export type CommandEvent =
Expand All @@ -26,12 +27,16 @@ export type CommandEvent =
type: Commands.init;
data: void;
}
| {
type: Commands.node;
data: void;
}
| {
type: Commands.versions;
data: void;
}
| {
type: Commands.node;
type: Commands.info;
data: void;
};

Expand Down
8 changes: 8 additions & 0 deletions packages/versions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,20 @@
"require": "./dist/cli.js",
"import": "./dist/cli.mjs",
"types": "./dist/cli.d.ts"
},
"./cli-utils": {
"require": "./dist/cli-utils.js",
"import": "./dist/cli-utils.mjs",
"types": "./dist/cli-utils.d.ts"
}
},
"typesVersions": {
"*": {
"cli": [
"./dist/cli.d.ts"
],
"cli-utils": [
"./dist/cli-utils.d.ts"
]
}
},
Expand Down
1 change: 1 addition & 0 deletions packages/versions/src/cli-utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './lib/getSystemVersions';
8 changes: 7 additions & 1 deletion packages/versions/tsup.config.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
import { indexBinAndCliConfig } from '@internal/tsup';

export default indexBinAndCliConfig;
export default {
...indexBinAndCliConfig,
entry: {
...indexBinAndCliConfig.entry,
'cli-utils': 'src/cli-utils.ts',
},
};
1 change: 0 additions & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading