Skip to content

Commit

Permalink
Add ignoreConflicts flag for config.load
Browse files Browse the repository at this point in the history
  • Loading branch information
nialexsan authored and jribbink committed Sep 27, 2024
1 parent 7c93eaa commit cd23479
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 20 deletions.
5 changes: 5 additions & 0 deletions .changeset/small-schools-guess.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@onflow/config": minor
---

Add `ignoreConflicts` flag to `config.load`
28 changes: 14 additions & 14 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"release": "npm run build && npm run changeset publish",
"changeset": "changeset",
"clear": "find . -name node_modules -type d -prune -exec rm -rf '{}' + && find . -name dist -type d -prune -exec rm -rf '{}' +",
"prettier:check": "prettier --check ."
"prettier:check": "prettier --check .",
"prettier": "prettier --write ."
},
"name": "fcl-js",
"devDependencies": {
Expand Down
24 changes: 19 additions & 5 deletions packages/config/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,19 @@ async function resetConfig(oldConfig: Record<string, unknown>) {
* @description Takes in flow.json or array of flow.json files and creates contract placeholders
* @param data - The data to load
* @param data.flowJSON - The flow.json or array of flow.json files
* @param options - override flag
* @param options.ignoreConflicts - ignore conflicts and override config
*/
async function load(data: {
flowJSON: Record<string, unknown> | Record<string, unknown>[]
}) {
async function load(
data: {
flowJSON: Record<string, unknown> | Record<string, unknown>[]
},
{
ignoreConflicts = false,
}: {
ignoreConflicts?: boolean
} = {}
) {
const network: string = await get("flow.network")
const cleanedNetwork = cleanNetwork(network)
const {flowJSON} = data
Expand Down Expand Up @@ -210,7 +219,11 @@ async function load(data: {
)) {
const contractConfigKey = `0x${key}`
const existingContractConfigKey = await get(contractConfigKey)
if (existingContractConfigKey && existingContractConfigKey !== value) {
if (
existingContractConfigKey &&
existingContractConfigKey !== value &&
!ignoreConflicts
) {
logger.log({
title: "Contract Placeholder Conflict Detected",
message: `A generated contract placeholder from config.load conflicts with a placeholder you've set manually in config have the same name.`,
Expand All @@ -226,7 +239,8 @@ async function load(data: {
)
if (
systemExistingContractConfigKeyValue &&
systemExistingContractConfigKeyValue !== value
systemExistingContractConfigKeyValue !== value &&
!ignoreConflicts
) {
logger.log({
title: "Contract Placeholder Conflict Detected",
Expand Down

0 comments on commit cd23479

Please sign in to comment.