Skip to content

Commit

Permalink
fix: Remove console warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
janjakubnanista committed Feb 13, 2024
1 parent b215fef commit f4bac23
Show file tree
Hide file tree
Showing 13 changed files with 60 additions and 16 deletions.
3 changes: 3 additions & 0 deletions packages/build-lz-options/tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,8 @@ export default defineConfig({
env: {
NODE_ENV: 'production',
},
esbuildOptions: (options) => {
options.drop = ['console', 'debugger']
},
external: ['yoga-layout-prebuilt'],
})
3 changes: 3 additions & 0 deletions packages/create-lz-oapp/tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,8 @@ export default defineConfig({
env: {
NODE_ENV: 'production',
},
esbuildOptions: (options) => {
options.drop = ['console', 'debugger']
},
external: ['yoga-layout-prebuilt'],
})
4 changes: 2 additions & 2 deletions packages/io-devtools/src/stdio/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ let DEFAULT_LOG_LEVEL = LogLevel.info
*/
export const setDefaultLogLevel = (level: string) => {
if (!isLogLevel(level)) {
console.warn(
`Invalid log level specified: ${level}. Ignoring and keeping the current value of ${DEFAULT_LOG_LEVEL}`
process.stderr.write(
`Invalid log level specified: ${level}. Ignoring and keeping the current value of ${DEFAULT_LOG_LEVEL}\n`
)

return
Expand Down
3 changes: 3 additions & 0 deletions packages/toolbox-hardhat/tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,7 @@ export default defineConfig({
splitting: false,
treeshake: true,
format: ['esm', 'cjs'],
esbuildOptions: (options) => {
options.drop = ['console', 'debugger']
},
})
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,10 @@ const action: ActionType<TaskArgs> = async ({ logLevel = 'info', networks: netwo
},
}

console.log(
`${localNetworkName}(${localEid}) -> ${remoteNetworkName}(${remoteEid})\n`,
printJson(config)
)
process.stdout.write(`${localNetworkName}(${localEid}) -> ${remoteNetworkName}(${remoteEid})\n`)
process.stdout.write(`${printJson(config)}\n`)
} else {
console.log(
process.stdout.write(
printRecord({
localNetworkName,
remoteNetworkName,
Expand All @@ -110,6 +108,7 @@ const action: ActionType<TaskArgs> = async ({ logLevel = 'info', networks: netwo
receiveUlnConfig,
})
)
process.stdout.write('\n')
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,14 @@ const action: ActionType<TaskArgs> = async ({ logLevel = 'info', networks: netwo

configs[localNetworkName]![remoteNetworkName] = executorDstConfig

console.log(
process.stdout.write(
printRecord({
localNetworkName,
remoteNetworkName,
executorDstConfig,
})
)
process.stdout.write('\n')
}
}
return configs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ const action: ActionType<TaskArgs> = async ({ logLevel = 'info', oappConfig }) =
receiveUlnConfig: receiveOAppUlnConfig,
}

console.log(
process.stdout.write(
printCrossTable(
[
{
Expand Down Expand Up @@ -103,6 +103,7 @@ const action: ActionType<TaskArgs> = async ({ logLevel = 'info', oappConfig }) =
['', 'Custom OApp Config', 'Default OApp Config', 'Active OApp Config']
)
)
process.stdout.write('\n')
}
}
return configs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,10 @@ const action: ActionType<TaskArgs> = async ({ oappConfig: oappConfigPath, logLev
return connectionsForCurrentRow
})

console.log(
process.stdout.write(
printCrossTable(enforcedOptsNetworkMatrix, ['from → to', ...points.map(({ networkName }) => networkName)])
)
process.stdout.write(`\n`)

return enforcedOptions
} catch (error) {
Expand Down
9 changes: 5 additions & 4 deletions packages/ua-devtools-evm-hardhat/src/tasks/oapp/peers.get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,13 @@ const action: ActionType<TaskArgs> = async ({ oappConfig: oappConfigPath, logLev
return connectionsForCurrentRow
})

console.log(
process.stdout.write(
printCrossTable(peerNetworkMatrix, ['from → to', ...points.map(({ networkName }) => networkName)], true)
)
console.log(` ${printBoolean(true)} - Connected`)
console.log(` ${printBoolean(false)} - Not Connected`)
console.log(` ${printBoolean(undefined)} - Ignored`)
process.stdout.write('\n')
process.stdout.write(` ${printBoolean(true)} - Connected\n`)
process.stdout.write(` ${printBoolean(false)} - Not Connected\n`)
process.stdout.write(` ${printBoolean(undefined)} - Ignored\n`)

return peers
} catch (error) {
Expand Down
3 changes: 3 additions & 0 deletions packages/ua-devtools-evm-hardhat/tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,8 @@ export default defineConfig([
splitting: false,
treeshake: true,
format: ['esm', 'cjs'],
esbuildOptions: (options) => {
options.drop = ['console', 'debugger']
},
},
])
2 changes: 1 addition & 1 deletion packages/verify-contract/src/common/licenses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const findLicenseType = (sourceCode: string): LicenseType => {

if (licenseName == null) return LicenseType.None
if (!(licenseName in LicenseType)) {
console.warn('Found unknown SPDX license identifier: %s', licenseName)
process.stderr.write(`Found unknown SPDX license identifier: ${licenseName}`)
}

return LicenseType[licenseName as keyof typeof LicenseType]
Expand Down
14 changes: 13 additions & 1 deletion tests-user/tests/build-lz-options.bats
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@

# This will be run at the start of this testing suite,
# similar to beforeAll() in jest
setup() {
# Load bats-assert and bats-support
load "../lib/bats-support/load.bash"
load "../lib/bats-assert/load.bash"
}

@test "should output version" {
npx --yes build-lz-options --version
}

@test "should not have a bigint-buffer warning" {
run npx --yes build-lz-options --version

refute_output --partial "bigint: Failed to load bindings, pure JS will be used"
}
17 changes: 17 additions & 0 deletions tests-user/tests/create-lz-oapp.bats
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ teardown() {
npx --yes create-lz-oapp --version
}

@test "should not have a bigint-buffer warning" {
run npx --yes create-lz-oapp --version

refute_output --partial "bigint: Failed to load bindings, pure JS will be used"
}

@test "should fail if --destination is missing in CI mode" {
run npx --yes create-lz-oapp --ci --example oft

Expand Down Expand Up @@ -114,6 +120,17 @@ teardown() {
assert_output --partial "insufficient funds for intrinsic transaction cost"
}

@test "should not have a bigint-buffer warning when deploying" {
local DESTINATION="$PROJECTS_DIRECTORY/pnpm-oft"
local MNEMONIC="test test test test test test test test test test test junk"

npx --yes create-lz-oapp --ci --example oft --destination $DESTINATION --package-manager pnpm
cd "$DESTINATION"

MNEMONIC=$MNEMONIC run pnpm hardhat deploy --network sepolia
refute_output --partial "bigint: Failed to load bindings, pure JS will be used"
}

@test "should work with pnpm & oapp example in CI mode" {
local DESTINATION="$PROJECTS_DIRECTORY/pnpm-oapp"

Expand Down

0 comments on commit f4bac23

Please sign in to comment.