FuelLabs / fuels-ts

Fuel Network Typescript SDK
https://docs.fuel.network/docs/fuels-ts/
Apache License 2.0
44.04k stars 1.35k forks source link

Improve paths validation/expansion on `fuels init` command #3406

Open arboleya opened 3 days ago

arboleya commented 3 days ago

When running this:

mkdir temp && cd temp && \
  pnpm init && pnpm add fuels && \
  forc new --contract counter && \
  pnpm fuels init --contracts ./counter/* --output ./sway-types && \
  cat fuels.config.ts

We end up with:

// fuels.config.ts
import { createConfig } from 'fuels';

export default createConfig({
  contracts: [
        'counter/Forc.toml',
  ],
  output: './src/sway-types',
});

Notes:

  1. If you try to build the resulting project with pnpn fuels build, you'll get an error
  2. The contract's path should be counter and not counter/Forc.toml
  3. Perhaps this is caused by using a wildcard in ./counter/* during the init command — note that the counter directory does not contains other/multiple contracts inside of it. It is the contract.

We should review the path's validation and expansion and improve tests around this.

arboleya commented 3 days ago

cc @bajpai244