-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat!: separate
onSuccess
events for the Fuels CLI (#2433)
* feat: emit the `build` and `deploy` events during `fuels dev` * chore: added `onBuild`, `onDeploy`, `onDev` and `onNode` hooks * chore: lintfix * chore: updated changeset * chore: updated changeset * chore: lintfix * chore: update event handler structure * chore: updated `onFailure` hook --------- Co-authored-by: Peter Smith <peter@blueoceancomputing.co.uk> Co-authored-by: Anderson Arboleya <anderson@arboleya.me> Co-authored-by: Chad Nehemiah <chad.nehemiah94@gmail.com>
- Loading branch information
1 parent
f11df8c
commit e159582
Showing
14 changed files
with
228 additions
and
64 deletions.
There are no files selected for viewing
This file contains 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 @@ | ||
--- | ||
"fuels": minor | ||
--- | ||
|
||
feat!: separate `onSuccess` events for the Fuels CLI |
This file contains 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 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 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,48 @@ | ||
import { fuelsConfig } from '../../../../test/fixtures/fuels.config'; | ||
import { mockLogger } from '../../../../test/utils/mockLogger'; | ||
|
||
import { build } from '.'; | ||
import * as buildSwayProgramsMod from './buildSwayPrograms'; | ||
import * as generateTypesMod from './generateTypes'; | ||
|
||
/** | ||
* @group node | ||
*/ | ||
describe('build', () => { | ||
const mockAll = () => { | ||
const { log } = mockLogger(); | ||
|
||
const onBuild = vi.fn(); | ||
|
||
const buildSwayPrograms = vi | ||
.spyOn(buildSwayProgramsMod, 'buildSwayPrograms') | ||
.mockResolvedValue(); | ||
const generateTypes = vi.spyOn(generateTypesMod, 'generateTypes').mockResolvedValue(); | ||
|
||
return { | ||
onBuild, | ||
log, | ||
buildSwayPrograms, | ||
generateTypes, | ||
}; | ||
}; | ||
|
||
test('should build sway programs and generate types', async () => { | ||
const { log, buildSwayPrograms, generateTypes } = mockAll(); | ||
|
||
await build(fuelsConfig); | ||
|
||
expect(log).toHaveBeenCalledWith('Building..'); | ||
expect(buildSwayPrograms).toHaveBeenCalled(); | ||
expect(generateTypes).toHaveBeenCalled(); | ||
}); | ||
|
||
test('should call onBuild callback', async () => { | ||
const { onBuild } = mockAll(); | ||
const config = { ...fuelsConfig, onBuild }; | ||
|
||
await build(config); | ||
|
||
expect(onBuild).toHaveBeenCalledWith(config); | ||
}); | ||
}); |
This file contains 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 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,40 @@ | ||
import type { Provider } from '@fuel-ts/account'; | ||
import { Wallet } from '@fuel-ts/account'; | ||
import { FUEL_NETWORK_URL } from '@fuel-ts/account/configs'; | ||
|
||
import { fuelsConfig } from '../../../../test/fixtures/fuels.config'; | ||
import type { DeployedContract } from '../../types'; | ||
|
||
import { deploy } from '.'; | ||
import * as createWalletMod from './createWallet'; | ||
import * as saveContractIdsMod from './saveContractIds'; | ||
|
||
/** | ||
* @group node | ||
*/ | ||
describe('deploy', () => { | ||
const mockAll = () => { | ||
const onDeploy = vi.fn(); | ||
|
||
const provider = { url: FUEL_NETWORK_URL } as Provider; | ||
const wallet = Wallet.fromPrivateKey('0x01', provider); | ||
const createWallet = vi.spyOn(createWalletMod, 'createWallet').mockResolvedValue(wallet); | ||
|
||
vi.spyOn(saveContractIdsMod, 'saveContractIds').mockResolvedValue(); | ||
|
||
return { | ||
onDeploy, | ||
createWallet, | ||
}; | ||
}; | ||
|
||
test('should call onDeploy callback', async () => { | ||
const { onDeploy } = mockAll(); | ||
const expectedContracts: DeployedContract[] = []; | ||
const config = { ...fuelsConfig, contracts: [], onDeploy }; | ||
|
||
await deploy(config); | ||
|
||
expect(onDeploy).toHaveBeenCalledWith(config, expectedContracts); | ||
}); | ||
}); |
This file contains 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 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 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 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 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
Oops, something went wrong.