From cd234798008868df13447ea97654b7e278dd746f Mon Sep 17 00:00:00 2001 From: Alex <12097569+nialexsan@users.noreply.github.com> Date: Fri, 27 Sep 2024 11:05:42 -0400 Subject: [PATCH] Add `ignoreConflicts` flag for `config.load` --- .changeset/small-schools-guess.md | 5 +++++ package-lock.json | 28 ++++++++++++++-------------- package.json | 3 ++- packages/config/src/config.ts | 24 +++++++++++++++++++----- 4 files changed, 40 insertions(+), 20 deletions(-) create mode 100644 .changeset/small-schools-guess.md diff --git a/.changeset/small-schools-guess.md b/.changeset/small-schools-guess.md new file mode 100644 index 000000000..c405b4cd0 --- /dev/null +++ b/.changeset/small-schools-guess.md @@ -0,0 +1,5 @@ +--- +"@onflow/config": minor +--- + +Add `ignoreConflicts` flag to `config.load` diff --git a/package-lock.json b/package-lock.json index c0e355cee..de84d15d5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -28758,16 +28758,16 @@ }, "packages/fcl": { "name": "@onflow/fcl", - "version": "1.12.0-alpha.1", + "version": "1.12.0-alpha.3", "license": "Apache-2.0", "dependencies": { "@babel/runtime": "^7.18.6", "@onflow/config": "1.4.1", - "@onflow/fcl-core": "1.11.0-alpha.1", - "@onflow/fcl-wc": "5.2.0-alpha.1", + "@onflow/fcl-core": "1.11.0-alpha.3", + "@onflow/fcl-wc": "5.2.0-alpha.3", "@onflow/interaction": "0.0.11", "@onflow/rlp": "1.2.2", - "@onflow/sdk": "1.5.2-alpha.1", + "@onflow/sdk": "1.5.2-alpha.2", "@onflow/types": "1.4.0", "@onflow/util-actor": "1.3.3", "@onflow/util-address": "1.2.2", @@ -28828,7 +28828,7 @@ }, "packages/fcl-core": { "name": "@onflow/fcl-core", - "version": "1.11.0-alpha.1", + "version": "1.11.0-alpha.3", "license": "Apache-2.0", "dependencies": { "@babel/runtime": "^7.18.6", @@ -28836,7 +28836,7 @@ "@onflow/config": "1.4.1", "@onflow/interaction": "0.0.11", "@onflow/rlp": "1.2.2", - "@onflow/sdk": "1.5.2-alpha.1", + "@onflow/sdk": "1.5.2-alpha.2", "@onflow/types": "1.4.0", "@onflow/util-actor": "1.3.3", "@onflow/util-address": "1.2.2", @@ -28893,15 +28893,15 @@ }, "packages/fcl-react-native": { "name": "@onflow/fcl-react-native", - "version": "1.9.4-alpha.1", + "version": "1.9.4-alpha.3", "license": "Apache-2.0", "dependencies": { "@babel/runtime": "^7.18.6", "@onflow/config": "1.4.1", - "@onflow/fcl-core": "1.11.0-alpha.1", + "@onflow/fcl-core": "1.11.0-alpha.3", "@onflow/interaction": "0.0.11", "@onflow/rlp": "1.2.2", - "@onflow/sdk": "1.5.2-alpha.1", + "@onflow/sdk": "1.5.2-alpha.2", "@onflow/types": "1.4.0", "@onflow/util-actor": "1.3.3", "@onflow/util-address": "1.2.2", @@ -28946,7 +28946,7 @@ }, "packages/fcl-wc": { "name": "@onflow/fcl-wc", - "version": "5.2.0-alpha.1", + "version": "5.2.0-alpha.3", "license": "Apache-2.0", "dependencies": { "@babel/runtime": "^7.18.9", @@ -28966,7 +28966,7 @@ "jest": "^29.5.0" }, "peerDependencies": { - "@onflow/fcl-core": "1.11.0-alpha.1" + "@onflow/fcl-core": "1.11.0-alpha.3" } }, "packages/fcl/node_modules/@onflow/fcl-wc/node_modules/@onflow/config": { @@ -29475,7 +29475,7 @@ }, "packages/sdk": { "name": "@onflow/sdk", - "version": "1.5.2-alpha.1", + "version": "1.5.2-alpha.2", "license": "Apache-2.0", "dependencies": { "@babel/runtime": "^7.18.6", @@ -29530,7 +29530,7 @@ }, "devDependencies": { "@onflow/fcl-bundle": "1.5.0", - "@onflow/sdk": "1.5.2-alpha.1", + "@onflow/sdk": "1.5.2-alpha.2", "jest": "^29.5.0" } }, @@ -29577,7 +29577,7 @@ "devDependencies": { "@onflow/fcl-bundle": "1.5.0", "@onflow/rlp": "1.2.2", - "@onflow/sdk": "1.5.2-alpha.1", + "@onflow/sdk": "1.5.2-alpha.2", "@onflow/types": "1.4.0", "jest": "^29.5.0" } diff --git a/package.json b/package.json index 494725cd1..87ec9a31a 100644 --- a/package.json +++ b/package.json @@ -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": { diff --git a/packages/config/src/config.ts b/packages/config/src/config.ts index 1711c0b6d..72492d054 100644 --- a/packages/config/src/config.ts +++ b/packages/config/src/config.ts @@ -175,10 +175,19 @@ async function resetConfig(oldConfig: Record) { * @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 | Record[] -}) { +async function load( + data: { + flowJSON: Record | Record[] + }, + { + ignoreConflicts = false, + }: { + ignoreConflicts?: boolean + } = {} +) { const network: string = await get("flow.network") const cleanedNetwork = cleanNetwork(network) const {flowJSON} = data @@ -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.`, @@ -226,7 +239,8 @@ async function load(data: { ) if ( systemExistingContractConfigKeyValue && - systemExistingContractConfigKeyValue !== value + systemExistingContractConfigKeyValue !== value && + !ignoreConflicts ) { logger.log({ title: "Contract Placeholder Conflict Detected",