Skip to content

Commit

Permalink
Merge branch 'main' into api-diff
Browse files Browse the repository at this point in the history
  • Loading branch information
david-crespo committed Nov 30, 2023
2 parents 8564df3 + 97be772 commit 102169b
Show file tree
Hide file tree
Showing 7 changed files with 87 additions and 88 deletions.
7 changes: 7 additions & 0 deletions libs/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ export const api = new Api({
host: process.env.NODE_ENV === 'test' ? 'http://testhost' : '',
})

// add the API client to window for use from the browser JS console. requests
// will use the session cookie, same as normal API calls
if (typeof window !== 'undefined') {
// @ts-expect-error
window.oxide = api.methods
}

export type ApiMethods = typeof api.methods

export const useApiQuery = getUseApiQuery(api.methods)
Expand Down
2 changes: 1 addition & 1 deletion libs/ui/lib/date-picker/DateRangePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export function DateRangePicker(props: DateRangePickerProps) {
: 'border-default ring-accent-secondary'
)}
>
<div className={cn('relative flex w-[16rem] items-center px-3 text-sans-md')}>
<div className={cn('relative flex w-[17rem] items-center px-3 text-sans-md')}>
{label}
{state.isInvalid && (
<div className="absolute bottom-0 right-2 top-0 flex items-center text-error">
Expand Down
76 changes: 37 additions & 39 deletions package-lock.json

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

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
"@ianvs/prettier-plugin-sort-imports": "^4.1.1",
"@ladle/react": "^3.2.1",
"@mswjs/http-middleware": "^0.8.0",
"@playwright/test": "^1.39.0",
"@playwright/test": "^1.40.1",
"@testing-library/dom": "^9.3.3",
"@testing-library/jest-dom": "^6.1.4",
"@testing-library/react": "^14.0.0",
Expand Down Expand Up @@ -108,7 +108,7 @@
"identity-obj-proxy": "^3.0.0",
"jsdom": "^22.1.0",
"lint-staged": "^14.0.1",
"msw": "^2.0.7",
"msw": "^2.0.9",
"patch-package": "^8.0.0",
"postcss": "^8.2.9",
"postcss-import": "^15.1.0",
Expand All @@ -123,7 +123,7 @@
"tailwindcss": "^3.3.5",
"type-fest": "^4.4.0",
"typescript": "~5.2.2",
"vite": "^5.0.0",
"vite": "^5.0.4",
"vite-plugin-html": "^3.2.0",
"vitest": "^0.34.6"
},
Expand Down
Binary file added public/assets/og-preview-image.webp
Binary file not shown.
63 changes: 19 additions & 44 deletions tools/deno/bump-omicron.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#! /usr/bin/env -S deno run --allow-run --allow-net --allow-read --allow-write
#! /usr/bin/env -S deno run --allow-run --allow-net --allow-read --allow-write --allow-env

/*
* This Source Code Form is subject to the terms of the Mozilla Public
Expand All @@ -9,6 +9,7 @@
*/
import * as flags from 'https://deno.land/[email protected]/flags/mod.ts'
import * as path from 'https://deno.land/[email protected]/path/mod.ts'
import $ from 'https://deno.land/x/[email protected]/mod.ts'

const HELP = `
Update tools/console_version in ../omicron with current console commit
Expand All @@ -33,31 +34,8 @@ const VERSION_FILE = path.join(OMICRON_DIR, 'tools/console_version')
const GH_MISSING = 'GitHub CLI not found. Please install it and try again.'
const VERSION_FILE_MISSING = `Omicron console version file at '${VERSION_FILE}' not found. This script assumes Omicron is cloned in a sibling directory next to Console.`

/** Run shell command, get output as string */
function run(cmd: string, args: string[]): string {
const { success, stdout } = new Deno.Command(cmd, { args, stdout: 'piped' }).outputSync()

if (!success) {
throw Error(`Shell command '${cmd} ${args.join(' ')}' failed`)
}

return new TextDecoder().decode(stdout).trim()
}

function getUploadAssetsWorkflowId() {
return run('gh', [
'run',
'list',
'-L',
'1',
'-w',
'Upload assets to dl.oxide.computer',
'--json',
'databaseId',
'--jq',
'.[0].databaseId',
])
}
const getUploadAssetsWorkflowId = () =>
$`gh run list -L 1 -w 'Upload assets to dl.oxide.computer' --json databaseId --jq '.[0].databaseId'`.text()

/**
* These lines get printed in an Omicron PR, so any references to commits or
Expand Down Expand Up @@ -94,7 +72,7 @@ if (args.help) {
Deno.exit()
}

const newCommit = run('git', ['rev-parse', 'HEAD'])
const newCommit = await $`git rev-parse HEAD`.text()

const shaUrl = `https://dl.oxide.computer/releases/console/${newCommit}.sha256.txt`
const shaResp = await fetch(shaUrl)
Expand All @@ -104,7 +82,7 @@ if (!shaResp.ok) {
`
Failed to fetch console tarball SHA. Either the current commit has not been pushed to origin/main or the CI job that uploads the assets is still running.
Run 'gh run watch ${getUploadAssetsWorkflowId()}' to watch the latest asset upload action.
Run 'gh run watch ${await getUploadAssetsWorkflowId()}' to watch the latest asset upload action.
`
)
console.error('URL:', shaUrl)
Expand All @@ -130,7 +108,7 @@ if (oldCommit === newCommit) {

const commitRange = `${oldCommit.slice(0, 8)}...${newCommit.slice(0, 8)}`

const commits = run('git', ['log', '--graph', '--oneline', commitRange])
const commits = await $`git log --graph --oneline ${commitRange}`.text()
// commits are console commits, so they won't auto-link in omicron
const commitsMarkdown = commits.split('\n').map(linkifyGitLog).join('\n')

Expand Down Expand Up @@ -161,36 +139,33 @@ if (args.dryRun || !confirm('\nMake Omicron PR with these changes?')) {
Deno.exit()
}

try {
run('which', ['gh'])
} catch (_e) {
throw Error(GH_MISSING)
}
if (!$.commandExistsSync('gh')) throw Error(GH_MISSING)

await Deno.writeTextFile(VERSION_FILE, newVersionFile)
console.log('Updated ', VERSION_FILE)

// cd to omicron, pull main, create new branch, commit changes, push, PR it, go back to
// main, delete branch
Deno.chdir(OMICRON_DIR)
run('git', ['checkout', 'main'])
run('git', ['pull'])
run('git', ['checkout', '-b', branchName])
await $`git checkout main`
await $`git pull`
await $`git checkout -b ${branchName}`
console.log('Created branch', branchName)
run('git', ['add', 'tools/console_version'])
run('git', ['commit', '-m', prTitle, '-m', prBody])
run('git', ['push', '--set-upstream', 'origin', branchName])

await $`git add tools/console_version`
await $`git commit -m ${prTitle} -m ${prBody}`
await $`git push --set-upstream origin ${branchName}`
console.log('Committed changes and pushed')

// create PR
const prUrl = run('gh', ['pr', 'create', '--title', prTitle, '--body', prBody])
const prUrl = await $`gh pr create --title ${prTitle} --body ${prBody}`.text()
console.log('PR created:', prUrl)

// set it to auto merge
const prNum = prUrl.match(/\d+$/)![0]
run('gh', ['pr', 'merge', prNum, '--auto', '--squash'])
await $`gh pr merge ${prNum} --auto --squash`
console.log('PR set to auto-merge when CI passes')

run('git', ['checkout', 'main'])
run('git', ['branch', '-D', branchName])
await $`git checkout main`
await $`git branch -D ${branchName}`
console.log('Checked out omicron main, deleted branch', branchName)
21 changes: 20 additions & 1 deletion vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,25 @@ const previewAnalyticsTag = {
},
}

const previewMetaTag = [
{
injectTo: 'head' as const,
tag: 'meta',
attrs: {
property: 'og:image',
content: '/assets/og-preview-image.webp',
},
},
{
injectTo: 'head' as const,
tag: 'meta',
attrs: {
property: 'og:description',
content: 'Preview of the Oxide web console with in-browser mock API',
},
},
]

// see https://vitejs.dev/config/
export default defineConfig(({ mode }) => ({
build: {
Expand All @@ -85,7 +104,7 @@ export default defineConfig(({ mode }) => ({
plugins: [
createHtmlPlugin({
inject: {
tags: process.env.VERCEL ? [previewAnalyticsTag] : [],
tags: process.env.VERCEL ? [previewAnalyticsTag, ...previewMetaTag] : [],
},
}),
react(),
Expand Down

0 comments on commit 102169b

Please sign in to comment.