clarinet icon indicating copy to clipboard operation
clarinet copied to clipboard

[Feature] Add deps.ts file for less error prone library upgrades.

Open LNow opened this issue 3 years ago • 4 comments

Right now all test files and any other files that uses some part of Clarinet imports Clarinet library at the top of each file.

For example:

import {
  Account,
  Chain,
  Clarinet,
  Tx,
  types,
} from "https://deno.land/x/[email protected]/index.ts";

It's ok when we have only few files and we know that we won't have to or don't want to upgrade Clarinet library very often. But when we'll have more files suddenly upgrading to new version is a bit challenging, as we have to find every single file with import and update it.

Deno documentation suggests that it can be beneficial to use deps.ts file.

I think that Clarinet should suggest this approach when we create a new project. That way it would teach users a good practice that will save them some time in the future.

We tried it out in CityCoin and I like this solution: https://github.com/citycoins/citycoin/blob/main/deps.ts https://github.com/citycoins/citycoin/blob/bf7e22ff8bf29f74a0a5a60c5b0737c2d1cd18f3/src/client.ts#L1-L5

LNow avatar Jun 24 '21 13:06 LNow

@philipdesmedt, @nieldeckx you may want to try this approach in Arkadiko. I saw that you have quite a lot of test files.

LNow avatar Jun 24 '21 13:06 LNow

@LNow This is a good refactoring. I'll talk to Niel and try this over the next week or so

philiphacks avatar Jun 24 '21 14:06 philiphacks

Interesting, thank you @LNow for this approach!

lgalabru avatar Jun 25 '21 16:06 lgalabru

Great idea, will adopt this as well.

MarvinJanssen avatar Jun 25 '21 19:06 MarvinJanssen