Skip to content

Commit

Permalink
Merge branch 'np/feat/abi-refactor' into ns/feat/abi-parser
Browse files Browse the repository at this point in the history
  • Loading branch information
nedsalk committed Jan 2, 2025
2 parents 7d58e16 + 31ddb12 commit 83cd67f
Show file tree
Hide file tree
Showing 12 changed files with 225 additions and 98 deletions.
5 changes: 5 additions & 0 deletions .changeset/clever-rocks-ring.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"create-fuels": patch
---

fix: test ui script in package's json
5 changes: 5 additions & 0 deletions .changeset/new-toys-approve.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"fuels": patch
---

fix: paths and globals in `fuels init`
4 changes: 4 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ jobs:
- name: Pretest
run: pnpm pretest

- name: Install playwright dependencies
if: matrix.env.name == 'browser'
run: pnpm exec playwright install --with-deps --only-shell chromium

- name: Run Tests - ${{ matrix.env.name }}
run: pnpm test:${{ matrix.env.name }}

Expand Down
4 changes: 2 additions & 2 deletions apps/create-fuels-counter-guide/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"version": "0.1.0",
"type": "module",
"scripts": {
"test:ui": "./test/ui/test-ui.sh",
"test:ui": "sh ./test/ui/test-ui.sh",
"original:dev": "vite",
"original:build": "tsc -b && vite build",
"original:start": "next start",
Expand All @@ -30,7 +30,7 @@
"@vitejs/plugin-react": "^4.3.3",
"@eslint/js": "^9.10.0",
"@types/node": "^22.5.5",
"@playwright/test": "^1.47.2",
"@playwright/test": "^1.49.1",
"@types/react": "^18.3.11",
"@types/react-dom": "^18.3",
"autoprefixer": "^10.4.20",
Expand Down
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
"@internal/fuel-core": "workspace:*",
"@internal/tsup": "workspace:*",
"@istanbuljs/nyc-config-typescript": "^1.0.2",
"@playwright/test": "^1.47.2",
"@playwright/test": "^1.49.1",
"@types/node": "^22.5.5",
"@types/node-fetch": "^2.6.11",
"@types/web": "^0.0.174",
Expand Down Expand Up @@ -124,8 +124,7 @@
"vite-plugin-json5": "^1.1.2",
"vite-plugin-node-polyfills": "^0.22.0",
"vite-plugin-plain-text": "^1.4.2",
"vitest": "~2.0.5",
"webdriverio": "^9.0.9"
"vitest": "~2.0.5"
},
"pnpm": {
"overrides": {
Expand Down
17 changes: 11 additions & 6 deletions packages/fuels/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,21 @@ export const configureCli = () => {

let command: Command;

const desc = `Relative path/globals to `;
const arg = `<path|global>`;

(command = program.command(Commands.init))
.description('Create a sample `fuel.config.ts` file')
.addOption(pathOption)
.option('-w, --workspace <path>', 'Relative dir path to Forc workspace')
.addOption(new Option(`-c, --contracts ${arg}`, `${desc} Contracts`).conflicts('workspace'))
.addOption(new Option(`-s, --scripts ${arg}`, `${desc} Scripts`).conflicts('workspace'))
.addOption(new Option(`-p, --predicates ${arg}`, `${desc} Predicates`).conflicts('workspace'))
.addOption(
new Option(`-c, --contracts [paths...]`, `Relative paths to Contracts`).conflicts('workspace')
)
.addOption(
new Option(`-s, --scripts [paths...]`, `Relative paths to Scripts`).conflicts('workspace')
)
.addOption(
new Option(`-p, --predicates [paths...]`, `Relative paths to Predicates`).conflicts(
'workspace'
)
)
.requiredOption('-o, --output <path>', 'Relative dir path for Typescript generation output')
.option('--forc-path <path>', 'Path to the `forc` binary')
.option('--fuel-core-path <path>', 'Path to the `fuel-core` binary')
Expand Down
49 changes: 49 additions & 0 deletions packages/fuels/test/features/init.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,55 @@ describe('init', () => {
expect(fuelsContents).not.toMatch(`fuelCorePath: 'fuels-core',`);
});

it('should run `init` command with --contracts', async () => {
await runInit({
root: paths.root,
contracts: [paths.contractsBarDir, paths.contractsFooDir],
output: paths.outputDir,
});

const [relativeBarDir, relativeFooDir] = [
paths.contractsBarDir.replace(paths.workspaceDir, 'workspace'),
paths.contractsFooDir.replace(paths.workspaceDir, 'workspace'),
];

expect(existsSync(paths.fuelsConfigPath)).toBeTruthy();
const fuelsContents = readFileSync(paths.fuelsConfigPath, 'utf-8');
expect(fuelsContents).toMatch(/contracts:/);
expect(fuelsContents).toMatch(relativeBarDir);
expect(fuelsContents).toMatch(relativeFooDir);
});

it('should run `init` command with --predicates', async () => {
await runInit({
root: paths.root,
predicates: paths.predicateDir,
output: paths.outputDir,
});

const relativePredicateDir = paths.predicateDir.replace(paths.workspaceDir, 'workspace');

expect(existsSync(paths.fuelsConfigPath)).toBeTruthy();
const fuelsContents = readFileSync(paths.fuelsConfigPath, 'utf-8');
expect(fuelsContents).toMatch(/predicates:/);
expect(fuelsContents).toMatch(relativePredicateDir);
});

it('should run `init` command with --scripts', async () => {
await runInit({
root: paths.root,
scripts: paths.scriptsDir,
output: paths.outputDir,
});

const relativeScriptDir = paths.scriptsDir.replace(paths.workspaceDir, 'workspace');

expect(existsSync(paths.fuelsConfigPath)).toBeTruthy();
const fuelsContents = readFileSync(paths.fuelsConfigPath, 'utf-8');
expect(fuelsContents).toMatch(/scripts:/);
expect(fuelsContents).toMatch(relativeScriptDir);
});

it('should run `init` command using custom binaries', async () => {
await runInit({
root: paths.root,
Expand Down
14 changes: 8 additions & 6 deletions packages/fuels/test/utils/runCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export function bootstrapProject(testFilepath: string) {
const upgradableChunkedContractPath = join(contractsDir, 'upgradable-chunked');

const scriptsDir = join(workspaceDir, 'scripts');
const predicateDir = join(workspaceDir, 'predicate');
const predicateDir = join(workspaceDir, 'predicates');

const outputDir = join(root, 'output');
const outputContractsDir = join(outputDir, 'contracts');
Expand Down Expand Up @@ -93,9 +93,9 @@ export type BaseParams = {

export type InitParams = BaseParams & {
workspace?: string;
contracts?: string;
scripts?: string;
predicates?: string;
contracts?: string | string[];
scripts?: string | string[];
predicates?: string | string[];
output: string;
forcPath?: string;
fuelCorePath?: string;
Expand All @@ -122,8 +122,10 @@ export async function runInit(params: InitParams) {
privateKey,
} = params;

const flag = (flags: (string | undefined)[], value?: string | boolean): string[] =>
value ? (flags as string[]) : [];
const flag = (
flags: (string | string[] | undefined)[],
value?: string | string[] | boolean
): string[] => (value ? (flags.flat() as string[]) : []);

const flags = [
flag(['--path', root], root),
Expand Down
Loading

0 comments on commit 83cd67f

Please sign in to comment.