Skip to content

Commit

Permalink
revert changes that are for another PR
Browse files Browse the repository at this point in the history
  • Loading branch information
nedsalk committed Jan 3, 2025
1 parent 54f32ef commit 142be12
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 34 deletions.
5 changes: 5 additions & 0 deletions .changeset/spicy-oranges-worry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"fuels": patch
---

fix: enable usage of `0` port for the `fuelCorePort` field
16 changes: 5 additions & 11 deletions apps/docs/src/guide/fuels-cli/commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,11 @@ npx fuels@{{fuels}} help init

```console
Options:
--path <path> Path to project root (default: root of current project)
-w, --workspace <path> Relative dir path to Forc workspace
-c, --contracts [paths...] Relative paths to Contracts
-s, --scripts [paths...] Relative paths to Scripts
-p, --predicates [paths...] Relative paths to Predicates
-o, --output <path> Relative dir path for Typescript generation output
--forc-path <path> Path to the `forc` binary
--fuel-core-path <path> Path to the `fuel-core` binary
--auto-start-fuel-core Auto-starts a `fuel-core` node during `dev` command
--fuel-core-port <port> Port to use when starting a local `fuel-core` node for dev mode
-h, --help Display help
-w, --workspace <path> Relative dir path to Forc workspace
-c, --contracts <path|global> Relative path/globals to Contracts
-s, --scripts <path|global> Relative path/globals to Scripts
-p, --predicates <path|global> Relative path/globals to Predicates
-o, --output <path> Relative dir path for Typescript generation
```

Creating a sample `fuel.config.ts` file:
Expand Down
4 changes: 0 additions & 4 deletions packages/fuels/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,6 @@ export const configureCli = () => {
.option('--forc-path <path>', 'Path to the `forc` binary')
.option('--fuel-core-path <path>', 'Path to the `fuel-core` binary')
.option('--auto-start-fuel-core', 'Auto-starts a `fuel-core` node during `dev` command')
.option(
'--fuel-core-port <port>',
'Port to use when starting a local `fuel-core` node for dev mode'
)
.action(withProgram(command, Commands.init, init));

(command = program.command(Commands.dev))
Expand Down
3 changes: 1 addition & 2 deletions packages/fuels/src/cli/commands/init/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { log } from '../../utils/logger';
export function init(program: Command) {
const options = program.opts();

const { path, autoStartFuelCore, forcPath, fuelCorePath, fuelCorePort } = options;
const { path, autoStartFuelCore, forcPath, fuelCorePath } = options;

let workspace: string | undefined;
let absoluteWorkspace: string | undefined;
Expand Down Expand Up @@ -61,7 +61,6 @@ export function init(program: Command) {
forcPath,
fuelCorePath,
autoStartFuelCore,
fuelCorePort,
});

writeFileSync(fuelsConfigPath, renderedConfig);
Expand Down
3 changes: 0 additions & 3 deletions packages/fuels/src/cli/templates/fuels.config.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ export default createConfig({
{{#if (isDefined autoStartFuelCore)}}
autoStartFuelCore: {{autoStartFuelCore}},
{{/if}}
{{#if (isDefined fuelCorePort)}}
fuelCorePort: {{fuelCorePort}},
{{/if}}
});

/**
Expand Down
1 change: 0 additions & 1 deletion packages/fuels/src/cli/templates/fuels.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ export function renderFuelsConfigTemplate(props: {
forcPath?: string;
fuelCorePath?: string;
autoStartFuelCore?: boolean;
fuelCorePort?: string;
}) {
const renderTemplate = Handlebars.compile(fuelsConfigTemplate, {
strict: true,
Expand Down
12 changes: 0 additions & 12 deletions packages/fuels/test/features/init.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,18 +112,6 @@ describe('init', () => {
expect(fuelsContents).toMatch(`fuelCorePath: 'fuels-core',`);
});

it('should run `init` command with custom fuel-core-port', async () => {
await runInit({
root: paths.root,
workspace: paths.workspaceDir,
output: paths.outputDir,
fuelCorePort: '1234',
});

const fuelsContents = readFileSync(paths.fuelsConfigPath, 'utf-8');
expect(fuelsContents).toMatch(`fuelCorePort: 1234,`);
});

it('should run `init` command and throw for existent config file', async () => {
const { error } = mockLogger();

Expand Down
11 changes: 10 additions & 1 deletion packages/fuels/test/utils/runCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@ export async function runInit(params: InitParams) {
flag(['--forc-path', forcPath], forcPath),
flag(['--fuel-core-path', fuelCorePath], fuelCorePath),
flag(['--auto-start-fuel-core'], autoStartFuelCore),
flag(['--fuel-core-port', fuelCorePort], fuelCorePort),
].flat();

const command = await runCommand(Commands.init, flags);
Expand All @@ -154,6 +153,16 @@ export async function runInit(params: InitParams) {
writeFileSync(configPath, config.replace(search, replace));
}

if (fuelCorePort) {
const configPath = join(root, 'fuels.config.ts');
const config = readFileSync(configPath, 'utf-8');

const search = /(^.*fuelCorePath:.*$)/m;
const replace = `$1\n fuelCorePort: '${fuelCorePort}',`;

writeFileSync(configPath, config.replace(search, replace));
}

return command;
}

Expand Down

0 comments on commit 142be12

Please sign in to comment.