Snippets:

Timezone

A quick and easy one liner to access the current timezone!

1new Intl.DateTimeFormat().resolvedOptions().timeZone
1new Intl.DateTimeFormat().resolvedOptions().timeZone

Prettify

1// Reference: https://www.totaltypescript.com/concepts/the-prettify-helper
2
3type Prettify<T> = {
4 [K in keyof T]: T[K];
5} & {};
1// Reference: https://www.totaltypescript.com/concepts/the-prettify-helper
2
3type Prettify<T> = {
4 [K in keyof T]: T[K];
5} & {};

yw

1# Bash script to execute a package.json script within a workspace
2yw() {
3 yarn workspace $(yarn workspaces list --json | jq -r .name | fzf) "$@"
4}
5
6# For yarn v1 monorepos, I use ywold:
7ywold() {
8 yarn workspace $(yarn --json workspaces info | jq '.data' -r | jq "[keys][0] []" -r | fzf) $@
9}
1# Bash script to execute a package.json script within a workspace
2yw() {
3 yarn workspace $(yarn workspaces list --json | jq -r .name | fzf) "$@"
4}
5
6# For yarn v1 monorepos, I use ywold:
7ywold() {
8 yarn workspace $(yarn --json workspaces info | jq '.data' -r | jq "[keys][0] []" -r | fzf) $@
9}

Turbo workspace timings

If you work within a monorepo and want to get a breakdown of the time that each workspace takes to run a task (lib:build in the below example), then these three shell commands will do that!

1yarn turbo run lib:build --summarize
2SUMMARY_FILE=$(/bin/ls .turbo/runs/*.json | head -n1)
3cat $SUMMARY_FILE | jq '[.tasks[] | {"taskId": .taskId, "duration": (.execution.endTime - .execution.startTime)}] | sort_by(-.duration)'
1yarn turbo run lib:build --summarize
2SUMMARY_FILE=$(/bin/ls .turbo/runs/*.json | head -n1)
3cat $SUMMARY_FILE | jq '[.tasks[] | {"taskId": .taskId, "duration": (.execution.endTime - .execution.startTime)}] | sort_by(-.duration)'