Skip to content

Commit ede053e

Browse files
committed
build(ui-alerts,console): make documentation preview builds show console logs
INSTUI-4522
1 parent f345a58 commit ede053e

File tree

4 files changed

+22
-1
lines changed

4 files changed

+22
-1
lines changed

.github/workflows/preview.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ jobs:
2424
- name: Build docs-app
2525
run: npm run build:docs
2626
if: github.event.action != 'closed'
27+
env: # ← ADD THIS SECTION ←
28+
IS_PREVIEW: 'true'
29+
NODE_ENV: 'production'
2730
- uses: rossjrw/pr-preview-action@v1
2831
with:
2932
source-dir: ./packages/__docs__/__build__

packages/__docs__/webpack.config.mjs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,11 @@ const config = merge(baseConfig, {
7979
template: './src/index.html',
8080
chunks: ['main'],
8181
}),
82+
new webpack.DefinePlugin({
83+
'process.env.NODE_ENV': JSON.stringify(ENV),
84+
'process.env.IS_PREVIEW': JSON.stringify(IS_PREVIEW),
85+
'process.env.DEBUG': JSON.stringify(DEBUG),
86+
}),
8287
],
8388
optimization: {
8489
usedExports: true,

packages/console/src/console.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,18 @@ function logMessage(
5555
message: string,
5656
...args: unknown[]
5757
) {
58-
if (process.env.NODE_ENV !== 'production' && !condition) {
58+
const isGitHubPreview =
59+
process.env.GITHUB_ACTIONS === 'true' &&
60+
process.env.GITHUB_EVENT_NAME === 'pull_request'
61+
62+
// const shouldShowLogs =
63+
// process.env.NODE_ENV !== 'production' ||
64+
// isGitHubPreview ||
65+
// process.env.IS_PREVIEW === 'true'
66+
67+
console.log(process.env.IS_PREVIEW, 'is it true')
68+
69+
if (isGitHubPreview && !condition) {
5970
if (typeof console[level] === 'function') {
6071
const renderStack = withRenderStack ? getRenderStack() : ''
6172
//@ts-expect-error level can be 'constructor' which is not callable

packages/ui-alerts/src/Alert/index.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ import {
4343
} from '@instructure/ui-icons'
4444
import { Transition } from '@instructure/ui-motion'
4545
import { logError as error } from '@instructure/console'
46+
import { logWarn as warn } from '@instructure/console'
4647
import { withStyle } from '@instructure/emotion'
4748

4849
import generateStyle from './styles'
@@ -308,6 +309,7 @@ class Alert extends Component<AlertProps, AlertState> {
308309
}
309310

310311
render() {
312+
warn(false, 'I am Dorka')
311313
const liveRegion = this.getLiveRegion()
312314
const screenReaderContent = liveRegion
313315
? this.createScreenReaderPortal(liveRegion)

0 commit comments

Comments
 (0)