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

Ignore default solidity contract tests when using extensions #158

Merged
merged 2 commits into from
Nov 26, 2024

Conversation

technophile-04
Copy link
Collaborator

Description:

We no longer copy test directory when extension being used has contracts dir.

Helpful for scaffold-eth/create-eth-extensions#29 (comment).

So there will be 3 cases:

  1. Extension has both contracts + test dir:
    • We just copy test dir from extension and we don't copy default test/YourContract.ts since we want yarn test running out of the box.
  2. Extension has contract dir but don't provide any test directory (eg: erc-20 extensions)
    • In this case we just create a empty test directory with (.gitkeep) file so that person using extension know where to add test file for his contracts.
  3. Extension doesn't have contract dir:
    • In this case we copy default contracts dir and test/YourContract.ts in final instance.

@technophile-04
Copy link
Collaborator Author

technophile-04 commented Nov 23, 2024

Ohh just noticed an error while doing :

 yarn cli ../test-erc-20 -s hardhat -e erc-20

I get the below error:

Error formatting because `No matches found: "./test/**/*.ts"`
create-eth on  ignore-contract-tests-extensions [$] is 📦 v0.0.61 via  v22.11.0
❯ yarn cli ../test-erc-20 -s hardhat -e erc-20

 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 | Create Scaffold-ETH 2 app |
 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+



✔ 📁 Create project directory /Users/shivbhonde/Desktop/github/test-erc-20
✔ 🚀 Creating a new Scaffold-ETH 2 app in ../test-erc-20 with the scaffold-eth/create-eth-extensions:erc-20 extension
✔ 📦 Installing dependencies with yarn, this could take a while
✖ Failed to create directory
◼ 📡 Initializing Git repository
ERROR Error occurred Error: Failed to create directory
    at prettierFormat (file:///Users/shivbhonde/Desktop/github/create-eth/dist/cli.js:538:15)
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
    at async Task.run (file:///Users/shivbhonde/Desktop/github/create-eth/node_modules/listr2/dist/index.js:2056:11) {
  [cause]: Error: Command failed with exit code 1: yarn format
  No matches found: "./test/**/*.ts"
  .eslintrc.json 14ms (unchanged)
  .prettierrc.js 9ms
  app/blockexplorer/_components/AddressCodeTab.tsx 15ms (unchanged)
  app/blockexplorer/_components/AddressComponent.tsx 8ms (unchanged)
  app/blockexplorer/_components/AddressLogsTab.tsx 5ms (unchanged)
  app/blockexplorer/_components/AddressStorageTab.tsx 10ms (unchanged)
  app/blockexplorer/_components/BackButton.tsx 2ms (unchanged)
  app/blockexplorer/_components/ContractTabs.tsx 11ms (unchanged)
  app/blockexplorer/_components/index.tsx 1ms (unchanged)
  app/blockexplorer/_components/PaginationButton.tsx 4ms (unchanged)
  app/blockexplorer/_components/SearchBar.tsx 4ms (unchanged)
  app/blockexplorer/_components/TransactionHash.tsx 4ms (unchanged)
  app/blockexplorer/_components/TransactionsTable.tsx 7ms (unchanged)
  app/blockexplorer/address/[address]/page.tsx 8ms
  app/blockexplorer/layout.tsx 3ms (unchanged)
  app/blockexplorer/page.tsx 6ms (unchanged)
  app/blockexplorer/transaction/_components/TransactionComp.tsx 9ms (unchanged)
  app/blockexplorer/transaction/[txHash]/page.tsx 2ms (unchanged)
  app/debug/_components/contract/ContractInput.tsx 6ms (unchanged)
  app/debug/_components/contract/ContractReadMethods.tsx 4ms (unchanged)
  app/debug/_components/contract/ContractUI.tsx 4ms (unchanged)
  app/debug/_components/contract/ContractVariables.tsx 3ms (unchanged)
  app/debug/_components/contract/ContractWriteMethods.tsx 3ms (unchanged)
  app/debug/_components/contract/DisplayVariable.tsx 3ms (unchanged)
  app/debug/_components/contract/index.tsx 1ms (unchanged)
  app/debug/_components/contract/InheritanceTooltip.tsx 1ms (unchanged)
  app/debug/_components/contract/ReadOnlyFunctionForm.tsx 4ms (unchanged)
  app/debug/_components/contract/Tuple.tsx 4ms (unchanged)
  app/debug/_components/contract/TupleArray.tsx 8ms (unchanged)
  app/debug/_components/contract/TxReceipt.tsx 3ms (unchanged)
  app/debug/_components/contract/utilsContract.tsx 7ms (unchanged)
  app/debug/_components/contract/utilsDisplay.tsx 5ms (unchanged)
  app/debug/_components/contract/WriteOnlyFunctionForm.tsx 6ms (unchanged)
  app/debug/_components/DebugContracts.tsx 3ms (unchanged)
  app/debug/page.tsx 2ms (unchanged)
  app/erc20/page.tsx 5ms (unchanged)
  app/layout.tsx 1ms
  app/page.tsx 2ms
  components/assets/BuidlGuidlLogo.tsx 0ms (unchanged)
  components/Footer.tsx 4ms (unchanged)
  components/Header.tsx 4ms
  components/scaffold-eth/Address/Address.tsx 7ms (unchanged)
  components/scaffold-eth/Address/AddressCopyIcon.tsx 1ms (unchanged)
  components/scaffold-eth/Address/AddressLinkWrapper.tsx 1ms (unchanged)
  components/scaffold-eth/Balance.tsx 3ms (unchanged)
  components/scaffold-eth/BlockieAvatar.tsx 1ms (unchanged)
  components/scaffold-eth/Faucet.tsx 5ms (unchanged)
  components/scaffold-eth/FaucetButton.tsx 3ms (unchanged)
  components/scaffold-eth/index.tsx 0ms (unchanged)
  components/scaffold-eth/Input/AddressInput.tsx 4ms (unchanged)
  components/scaffold-eth/Input/Bytes32Input.tsx 1ms (unchanged)
  components/scaffold-eth/Input/BytesInput.tsx 1ms (unchanged)
  components/scaffold-eth/Input/EtherInput.tsx 4ms (unchanged)
  components/scaffold-eth/Input/index.ts 0ms (unchanged)
  components/scaffold-eth/Input/InputBase.tsx 3ms (unchanged)
  components/scaffold-eth/Input/IntegerInput.tsx 2ms (unchanged)
  components/scaffold-eth/Input/utils.ts 3ms (unchanged)
  components/scaffold-eth/RainbowKitCustomConnectButton/AddressInfoDropdown.tsx 5ms (unchanged)
  components/scaffold-eth/RainbowKitCustomConnectButton/AddressQRCodeModal.tsx 2ms (unchanged)
  components/scaffold-eth/RainbowKitCustomConnectButton/index.tsx 2ms (unchanged)
  components/scaffold-eth/RainbowKitCustomConnectButton/NetworkOptions.tsx 2ms (unchanged)
  components/scaffold-eth/RainbowKitCustomConnectButton/WrongNetworkDropdown.tsx 1ms (unchanged)
  components/ScaffoldEthAppWithProviders.tsx 2ms
  components/SwitchTheme.tsx 2ms (unchanged)
  components/ThemeProvider.tsx 1ms (unchanged)
  hooks/scaffold-eth/index.ts 1ms (unchanged)
  hooks/scaffold-eth/useAnimationConfig.ts 1ms (unchanged)
  hooks/scaffold-eth/useContractLogs.ts 2ms (unchanged)
  hooks/scaffold-eth/useDeployedContractInfo.ts 2ms (unchanged)
  hooks/scaffold-eth/useDisplayUsdMode.ts 1ms (unchanged)
  hooks/scaffold-eth/useFetchBlocks.ts 6ms (unchanged)
  hooks/scaffold-eth/useInitializeNativeCurrencyPrice.ts 1ms (unchanged)
  hooks/scaffold-eth/useNetworkColor.ts 1ms (unchanged)
  hooks/scaffold-eth/useOutsideClick.ts 1ms (unchanged)
  hooks/scaffold-eth/useScaffoldContract.ts 2ms (unchanged)
  hooks/scaffold-eth/useScaffoldEventHistory.ts 6ms (unchanged)
  hooks/scaffold-eth/useScaffoldReadContract.ts 3ms (unchanged)
  hooks/scaffold-eth/useScaffoldWatchContractEvent.ts 2ms (unchanged)
  hooks/scaffold-eth/useScaffoldWriteContract.ts 5ms (unchanged)
  hooks/scaffold-eth/useTargetNetwork.ts 3ms (unchanged)
  hooks/scaffold-eth/useTransactor.tsx 5ms (unchanged)
  hooks/scaffold-eth/useWatchBalance.ts 2ms (unchanged)
  next-env.d.ts 1ms (unchanged)
  next.config.js 2ms
  package.json 1ms (unchanged)
  postcss.config.js 0ms (unchanged)
  public/manifest.json 1ms (unchanged)
  scaffold.config.ts 1ms (unchanged)
  services/store/store.ts 2ms (unchanged)
  services/web3/wagmiConfig.tsx 2ms (unchanged)
  services/web3/wagmiConnectors.tsx 2ms (unchanged)
  styles/globals.css 9ms (unchanged)
  tailwind.config.js 2ms
  tsconfig.json 0ms (unchanged)
  types/abitype/abi.d.ts 2ms (unchanged)
  types/react-copy-to-clipboard/react-copy-to-clipboard.d.ts 2ms (unchanged)
  utils/scaffold-eth/block.ts 1ms (unchanged)
  utils/scaffold-eth/common.ts 1ms (unchanged)
  utils/scaffold-eth/contract.ts 11ms (unchanged)
  utils/scaffold-eth/contractsData.ts 1ms (unchanged)
  utils/scaffold-eth/decodeTxData.ts 4ms (unchanged)
  utils/scaffold-eth/fetchPriceFromUniswap.ts 3ms (unchanged)
  utils/scaffold-eth/getMetadata.ts 2ms (unchanged)
  utils/scaffold-eth/getParsedError.ts 2ms (unchanged)
  utils/scaffold-eth/index.ts 1ms (unchanged)
  utils/scaffold-eth/networks.ts 5ms (unchanged)
  utils/scaffold-eth/notification.tsx 4ms (unchanged)
  vercel.json 1ms (unchanged)
      at makeError (file:///Users/shivbhonde/Desktop/github/create-eth/node_modules/execa/lib/error.js:59:11)
      at handlePromise (file:///Users/shivbhonde/Desktop/github/create-eth/node_modules/execa/index.js:124:26)
      at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
      at async prettierFormat (file:///Users/shivbhonde/Desktop/github/create-eth/dist/cli.js:532:24)
      at async Task.run (file:///Users/shivbhonde/Desktop/github/create-eth/node_modules/listr2/dist/index.js:2056:11) {
    shortMessage: 'Command failed with exit code 1: yarn format',
    command: 'yarn format',
    escapedCommand: 'yarn format',
    exitCode: 1,
    signal: undefined,
    signalDescription: undefined,
    stdout: '.eslintrc.json 14ms (unchanged)\n' +
      '.prettierrc.js 9ms\n' +
      'app/blockexplorer/_components/AddressCodeTab.tsx 15ms (unchanged)\n' +
      'app/blockexplorer/_components/AddressComponent.tsx 8ms (unchanged)\n' +
      'app/blockexplorer/_components/AddressLogsTab.tsx 5ms (unchanged)\n' +
      'app/blockexplorer/_components/AddressStorageTab.tsx 10ms (unchanged)\n' +
      'app/blockexplorer/_components/BackButton.tsx 2ms (unchanged)\n' +
      'app/blockexplorer/_components/ContractTabs.tsx 11ms (unchanged)\n' +
      'app/blockexplorer/_components/index.tsx 1ms (unchanged)\n' +
      'app/blockexplorer/_components/PaginationButton.tsx 4ms (unchanged)\n' +
      'app/blockexplorer/_components/SearchBar.tsx 4ms (unchanged)\n' +
      'app/blockexplorer/_components/TransactionHash.tsx 4ms (unchanged)\n' +
      'app/blockexplorer/_components/TransactionsTable.tsx 7ms (unchanged)\n' +
      'app/blockexplorer/address/[address]/page.tsx 8ms\n' +
      'app/blockexplorer/layout.tsx 3ms (unchanged)\n' +
      'app/blockexplorer/page.tsx 6ms (unchanged)\n' +
      'app/blockexplorer/transaction/_components/TransactionComp.tsx 9ms (unchanged)\n' +
      'app/blockexplorer/transaction/[txHash]/page.tsx 2ms (unchanged)\n' +
      'app/debug/_components/contract/ContractInput.tsx 6ms (unchanged)\n' +
      'app/debug/_components/contract/ContractReadMethods.tsx 4ms (unchanged)\n' +
      'app/debug/_components/contract/ContractUI.tsx 4ms (unchanged)\n' +
      'app/debug/_components/contract/ContractVariables.tsx 3ms (unchanged)\n' +
      'app/debug/_components/contract/ContractWriteMethods.tsx 3ms (unchanged)\n' +
      'app/debug/_components/contract/DisplayVariable.tsx 3ms (unchanged)\n' +
      'app/debug/_components/contract/index.tsx 1ms (unchanged)\n' +
      'app/debug/_components/contract/InheritanceTooltip.tsx 1ms (unchanged)\n' +
      'app/debug/_components/contract/ReadOnlyFunctionForm.tsx 4ms (unchanged)\n' +
      'app/debug/_components/contract/Tuple.tsx 4ms (unchanged)\n' +
      'app/debug/_components/contract/TupleArray.tsx 8ms (unchanged)\n' +
      'app/debug/_components/contract/TxReceipt.tsx 3ms (unchanged)\n' +
      'app/debug/_components/contract/utilsContract.tsx 7ms (unchanged)\n' +
      'app/debug/_components/contract/utilsDisplay.tsx 5ms (unchanged)\n' +
      'app/debug/_components/contract/WriteOnlyFunctionForm.tsx 6ms (unchanged)\n' +
      'app/debug/_components/DebugContracts.tsx 3ms (unchanged)\n' +
      'app/debug/page.tsx 2ms (unchanged)\n' +
      'app/erc20/page.tsx 5ms (unchanged)\n' +
      'app/layout.tsx 1ms\n' +
      'app/page.tsx 2ms\n' +
      'components/assets/BuidlGuidlLogo.tsx 0ms (unchanged)\n' +
      'components/Footer.tsx 4ms (unchanged)\n' +
      'components/Header.tsx 4ms\n' +
      'components/scaffold-eth/Address/Address.tsx 7ms (unchanged)\n' +
      'components/scaffold-eth/Address/AddressCopyIcon.tsx 1ms (unchanged)\n' +
      'components/scaffold-eth/Address/AddressLinkWrapper.tsx 1ms (unchanged)\n' +
      'components/scaffold-eth/Balance.tsx 3ms (unchanged)\n' +
      'components/scaffold-eth/BlockieAvatar.tsx 1ms (unchanged)\n' +
      'components/scaffold-eth/Faucet.tsx 5ms (unchanged)\n' +
      'components/scaffold-eth/FaucetButton.tsx 3ms (unchanged)\n' +
      'components/scaffold-eth/index.tsx 0ms (unchanged)\n' +
      'components/scaffold-eth/Input/AddressInput.tsx 4ms (unchanged)\n' +
      'components/scaffold-eth/Input/Bytes32Input.tsx 1ms (unchanged)\n' +
      'components/scaffold-eth/Input/BytesInput.tsx 1ms (unchanged)\n' +
      'components/scaffold-eth/Input/EtherInput.tsx 4ms (unchanged)\n' +
      'components/scaffold-eth/Input/index.ts 0ms (unchanged)\n' +
      'components/scaffold-eth/Input/InputBase.tsx 3ms (unchanged)\n' +
      'components/scaffold-eth/Input/IntegerInput.tsx 2ms (unchanged)\n' +
      'components/scaffold-eth/Input/utils.ts 3ms (unchanged)\n' +
      'components/scaffold-eth/RainbowKitCustomConnectButton/AddressInfoDropdown.tsx 5ms (unchanged)\n' +
      'components/scaffold-eth/RainbowKitCustomConnectButton/AddressQRCodeModal.tsx 2ms (unchanged)\n' +
      'components/scaffold-eth/RainbowKitCustomConnectButton/index.tsx 2ms (unchanged)\n' +
      'components/scaffold-eth/RainbowKitCustomConnectButton/NetworkOptions.tsx 2ms (unchanged)\n' +
      'components/scaffold-eth/RainbowKitCustomConnectButton/WrongNetworkDropdown.tsx 1ms (unchanged)\n' +
      'components/ScaffoldEthAppWithProviders.tsx 2ms\n' +
      'components/SwitchTheme.tsx 2ms (unchanged)\n' +
      'components/ThemeProvider.tsx 1ms (unchanged)\n' +
      'hooks/scaffold-eth/index.ts 1ms (unchanged)\n' +
      'hooks/scaffold-eth/useAnimationConfig.ts 1ms (unchanged)\n' +
      'hooks/scaffold-eth/useContractLogs.ts 2ms (unchanged)\n' +
      'hooks/scaffold-eth/useDeployedContractInfo.ts 2ms (unchanged)\n' +
      'hooks/scaffold-eth/useDisplayUsdMode.ts 1ms (unchanged)\n' +
      'hooks/scaffold-eth/useFetchBlocks.ts 6ms (unchanged)\n' +
      'hooks/scaffold-eth/useInitializeNativeCurrencyPrice.ts 1ms (unchanged)\n' +
      'hooks/scaffold-eth/useNetworkColor.ts 1ms (unchanged)\n' +
      'hooks/scaffold-eth/useOutsideClick.ts 1ms (unchanged)\n' +
      'hooks/scaffold-eth/useScaffoldContract.ts 2ms (unchanged)\n' +
      'hooks/scaffold-eth/useScaffoldEventHistory.ts 6ms (unchanged)\n' +
      'hooks/scaffold-eth/useScaffoldReadContract.ts 3ms (unchanged)\n' +
      'hooks/scaffold-eth/useScaffoldWatchContractEvent.ts 2ms (unchanged)\n' +
      'hooks/scaffold-eth/useScaffoldWriteContract.ts 5ms (unchanged)\n' +
      'hooks/scaffold-eth/useTargetNetwork.ts 3ms (unchanged)\n' +
      'hooks/scaffold-eth/useTransactor.tsx 5ms (unchanged)\n' +
      'hooks/scaffold-eth/useWatchBalance.ts 2ms (unchanged)\n' +
      'next-env.d.ts 1ms (unchanged)\n' +
      'next.config.js 2ms\n' +
      'package.json 1ms (unchanged)\n' +
      'postcss.config.js 0ms (unchanged)\n' +
      'public/manifest.json 1ms (unchanged)\n' +
      'scaffold.config.ts 1ms (unchanged)\n' +
      'services/store/store.ts 2ms (unchanged)\n' +
      'services/web3/wagmiConfig.tsx 2ms (unchanged)\n' +
      'services/web3/wagmiConnectors.tsx 2ms (unchanged)\n' +
      'styles/globals.css 9ms (unchanged)\n' +
      'tailwind.config.js 2ms\n' +
      'tsconfig.json 0ms (unchanged)\n' +
      'types/abitype/abi.d.ts 2ms (unchanged)\n' +
      'types/react-copy-to-clipboard/react-copy-to-clipboard.d.ts 2ms (unchanged)\n' +
      'utils/scaffold-eth/block.ts 1ms (unchanged)\n' +
      'utils/scaffold-eth/common.ts 1ms (unchanged)\n' +
      'utils/scaffold-eth/contract.ts 11ms (unchanged)\n' +
      'utils/scaffold-eth/contractsData.ts 1ms (unchanged)\n' +
      'utils/scaffold-eth/decodeTxData.ts 4ms (unchanged)\n' +
      'utils/scaffold-eth/fetchPriceFromUniswap.ts 3ms (unchanged)\n' +
      'utils/scaffold-eth/getMetadata.ts 2ms (unchanged)\n' +
      'utils/scaffold-eth/getParsedError.ts 2ms (unchanged)\n' +
      'utils/scaffold-eth/index.ts 1ms (unchanged)\n' +
      'utils/scaffold-eth/networks.ts 5ms (unchanged)\n' +
      'utils/scaffold-eth/notification.tsx 4ms (unchanged)\n' +
      'vercel.json 1ms (unchanged)',
    stderr: 'No matches found: "./test/**/*.ts"',
    failed: true,
    timedOut: false,
    isCanceled: false,
    killed: false
  }
}
Uh oh! 😕 Sorry about that! Exiting...

The reason for above error since there is no file in hardaht/test/*.ts file prettier is trying to find it because of forcefully prettier --write ./*.ts ./deploy/**/*.ts ./scripts/**/*.ts ./test/**/*.ts and weird part of prettier is if it's not able to find that file it throws error and cli breaks.

There is --no-error-on-unmatched-pattern flag since we have hardcoded ./test/**/*.ts it doesn't work.

Just created a https://github.com/scaffold-eth/scaffold-eth-2/pull/994/files to solve this. Once that is merged. Will backmerge it here 🙌

@rin-st
Copy link
Member

rin-st commented Nov 25, 2024

GJ!

For me it also works except the case when there's is a contract but not test. Will retest when mentioned PR will be merged here

@technophile-04
Copy link
Collaborator Author

For me it also works except the case when there's is a contract but not test. Will retest when mentioned PR will be merged here

Ohh yeah just merged main and it shall work correctly now

@rin-st
Copy link
Member

rin-st commented Nov 25, 2024

It works great now!

One nit (not critical at all): .gitkeep file is created in all 3 cases but I think it's ok

Thank you for fixing this!

@technophile-04
Copy link
Collaborator Author

One nit (not critical at all): .gitkeep file is created in all 3 cases but I think it's ok

yeah lol I felt the same but it felt like simplest and minimal path. we could have explicit logic in cli working it self but maybe not worth it I feel and .gitkeep seems fine

@carletex carletex merged commit eaa39fc into main Nov 26, 2024
1 check passed
@carletex carletex deleted the ignore-contract-tests-extensions branch November 26, 2024 17:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants