Skip to content
This repository has been archived by the owner on Aug 28, 2024. It is now read-only.

Commit

Permalink
chore: code style
Browse files Browse the repository at this point in the history
  • Loading branch information
hanspagel committed Jul 23, 2024
1 parent 09792ac commit 871bada
Show file tree
Hide file tree
Showing 15 changed files with 129 additions and 107 deletions.
20 changes: 10 additions & 10 deletions .changeset/config.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json",
"changelog": "@changesets/cli/changelog",
"commit": ["@changesets/cli/commit", { "skipCI": false }],
"fixed": [],
"linked": [],
"access": "public",
"baseBranch": "main",
"updateInternalDependencies": "patch",
"ignore": ["demo"]
}
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json",
"changelog": "@changesets/cli/changelog",
"commit": ["@changesets/cli/commit", { "skipCI": false }],
"fixed": [],
"linked": [],
"access": "public",
"baseBranch": "main",
"updateInternalDependencies": "patch",
"ignore": ["demo"]
}
2 changes: 1 addition & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
"tabWidth": 2,
"semi": false,
"singleQuote": true
}
}
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ npm install @scalar/snippetz
import { snippetz } from '@scalar/snippetz'

const snippet = snippetz().print('node', 'undici', {
url: 'https://example.com'
url: 'https://example.com',
})

/* Output */
Expand Down Expand Up @@ -73,7 +73,7 @@ const snippet = snippetz().hasPlugin('node', 'undici')
import { undici } from '@scalar/snippetz-plugin-undici'

const source = undici({
url: 'https://example.com'
url: 'https://example.com',
})

console.log(source.code)
Expand Down Expand Up @@ -118,4 +118,4 @@ Contributions are welcome! Read [`CONTRIBUTING`](https://github.com/scalar/snipp

## License

The source code in this repository is licensed under [MIT](https://github.com/scalar/snippetz/blob/main/LICENSE).
The source code in this repository is licensed under [MIT](https://github.com/scalar/snippetz/blob/main/LICENSE).
7 changes: 5 additions & 2 deletions demo/index.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
<!doctype html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Snippetz / Opinionated HTTP Snippets</title>
<link rel="icon" href="data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 100 100%22><text y=%22.9em%22 font-size=%2290%22>🌐</text></svg>">
<link
rel="icon"
href="data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 100 100%22><text y=%22.9em%22 font-size=%2290%22>🌐</text></svg>"
/>
</head>
<body>
<div id="app"></div>
Expand Down
33 changes: 22 additions & 11 deletions demo/src/components/CodeExample.vue
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
<script setup lang="ts">
import { ref, watch, onMounted } from 'vue'
import { snippetz } from '@scalar/snippetz'
import { objectToString, type ClientId, type TargetId } from '@scalar/snippetz-core'
import {
objectToString,
type ClientId,
type TargetId,
} from '@scalar/snippetz-core'
import { getHighlighter } from 'shikiji'
const props = defineProps<{
target: TargetId,
client: ClientId,
request: any,
target: TargetId
client: ClientId
request: any
}>()
const code = ref('')
Expand All @@ -25,7 +29,8 @@ async function renderExample() {
langs: ['javascript', 'json'],
})
const example = `/* Snippetz */
const example =
`/* Snippetz */
import { snippetz } from '@scalar/snippetz'
Expand All @@ -37,11 +42,17 @@ const snippet = snippetz().print('${props.target}', '${props.client}', request)
// ` + code.value.split(`\n`).join(`\n// `)
highlightedConfiguration.value = shiki.codeToHtml(JSON.stringify(props.request, null, 2), { lang: 'json', theme: 'vitesse-dark' })
highlightedResult.value = shiki.codeToHtml(code.value, { lang: 'javascript', theme: 'vitesse-dark' })
highlightedConfiguration.value = shiki.codeToHtml(
JSON.stringify(props.request, null, 2),
{ lang: 'json', theme: 'vitesse-dark' }
)
highlightedResult.value = shiki.codeToHtml(code.value, {
lang: 'javascript',
theme: 'vitesse-dark',
})
highlightedExample.value = shiki.codeToHtml(example, {
lang: 'javascript',
theme: 'vitesse-dark'
theme: 'vitesse-dark',
})
}
Expand All @@ -54,9 +65,9 @@ watch(props, renderExample)

<template>
<div class="code-block">
<div class="code-block-content">
<div class="source" v-html="highlightedExample" />
</div>
<div class="code-block-content">
<div class="source" v-html="highlightedExample" />
</div>
</div>
</template>

Expand Down
22 changes: 11 additions & 11 deletions packages/snippetz-core/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"extends": "../../tsconfig.json",
"include": ["src"],
"exclude": ["dist", "test", "vite.config.ts", "**/*.test.ts"],
"compilerOptions": {
"declaration": true,
"declarationMap": true,
"emitDeclarationOnly": true,
"outDir": "dist/",
"allowSyntheticDefaultImports": true
}
}
"extends": "../../tsconfig.json",
"include": ["src"],
"exclude": ["dist", "test", "vite.config.ts", "**/*.test.ts"],
"compilerOptions": {
"declaration": true,
"declarationMap": true,
"emitDeclarationOnly": true,
"outDir": "dist/",
"allowSyntheticDefaultImports": true
}
}
22 changes: 11 additions & 11 deletions packages/snippetz-plugin-js-fetch/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"extends": "../../tsconfig.json",
"include": ["src"],
"exclude": ["dist", "test", "vite.config.ts", "**/*.test.ts"],
"compilerOptions": {
"declaration": true,
"declarationMap": true,
"emitDeclarationOnly": true,
"outDir": "dist/",
"allowSyntheticDefaultImports": true
}
}
"extends": "../../tsconfig.json",
"include": ["src"],
"exclude": ["dist", "test", "vite.config.ts", "**/*.test.ts"],
"compilerOptions": {
"declaration": true,
"declarationMap": true,
"emitDeclarationOnly": true,
"outDir": "dist/",
"allowSyntheticDefaultImports": true
}
}
2 changes: 1 addition & 1 deletion packages/snippetz-plugin-js-ofetch/src/ofetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export function ofetch(request?: Partial<Request>): Source {
? arrayToObject(normalizedRequest.queryString)
: undefined
)

if (searchParams.size) {
options.query = {}
searchParams.forEach((value, key) => {
Expand Down
22 changes: 11 additions & 11 deletions packages/snippetz-plugin-js-ofetch/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"extends": "../../tsconfig.json",
"include": ["src"],
"exclude": ["dist", "test", "vite.config.ts", "**/*.test.ts"],
"compilerOptions": {
"declaration": true,
"declarationMap": true,
"emitDeclarationOnly": true,
"outDir": "dist/",
"allowSyntheticDefaultImports": true
}
}
"extends": "../../tsconfig.json",
"include": ["src"],
"exclude": ["dist", "test", "vite.config.ts", "**/*.test.ts"],
"compilerOptions": {
"declaration": true,
"declarationMap": true,
"emitDeclarationOnly": true,
"outDir": "dist/",
"allowSyntheticDefaultImports": true
}
}
22 changes: 11 additions & 11 deletions packages/snippetz-plugin-node-fetch/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"extends": "../../tsconfig.json",
"include": ["src"],
"exclude": ["dist", "test", "vite.config.ts", "**/*.test.ts"],
"compilerOptions": {
"declaration": true,
"declarationMap": true,
"emitDeclarationOnly": true,
"outDir": "dist/",
"allowSyntheticDefaultImports": true
}
}
"extends": "../../tsconfig.json",
"include": ["src"],
"exclude": ["dist", "test", "vite.config.ts", "**/*.test.ts"],
"compilerOptions": {
"declaration": true,
"declarationMap": true,
"emitDeclarationOnly": true,
"outDir": "dist/",
"allowSyntheticDefaultImports": true
}
}
22 changes: 11 additions & 11 deletions packages/snippetz-plugin-node-ofetch/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"extends": "../../tsconfig.json",
"include": ["src"],
"exclude": ["dist", "test", "vite.config.ts", "**/*.test.ts"],
"compilerOptions": {
"declaration": true,
"declarationMap": true,
"emitDeclarationOnly": true,
"outDir": "dist/",
"allowSyntheticDefaultImports": true
}
}
"extends": "../../tsconfig.json",
"include": ["src"],
"exclude": ["dist", "test", "vite.config.ts", "**/*.test.ts"],
"compilerOptions": {
"declaration": true,
"declarationMap": true,
"emitDeclarationOnly": true,
"outDir": "dist/",
"allowSyntheticDefaultImports": true
}
}
4 changes: 3 additions & 1 deletion packages/snippetz-plugin-node-undici/src/undici.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ export function undici(request?: Partial<Request>): Source {

// JSON
if (normalizedRequest.postData.mimeType === 'application/json') {
options.body = `JSON.stringify(${objectToString(JSON.parse(options.body))})`
options.body = `JSON.stringify(${objectToString(
JSON.parse(options.body)
)})`
}
}

Expand Down
22 changes: 11 additions & 11 deletions packages/snippetz-plugin-node-undici/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"extends": "../../tsconfig.json",
"include": ["src"],
"exclude": ["dist", "test", "vite.config.ts", "**/*.test.ts"],
"compilerOptions": {
"declaration": true,
"declarationMap": true,
"emitDeclarationOnly": true,
"outDir": "dist/",
"allowSyntheticDefaultImports": true
}
}
"extends": "../../tsconfig.json",
"include": ["src"],
"exclude": ["dist", "test", "vite.config.ts", "**/*.test.ts"],
"compilerOptions": {
"declaration": true,
"declarationMap": true,
"emitDeclarationOnly": true,
"outDir": "dist/",
"allowSyntheticDefaultImports": true
}
}
8 changes: 7 additions & 1 deletion packages/snippetz/src/snippetz.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,13 @@ const { statusCode, body } = await request('https://example.com')`)
expect(targets).toStrictEqual(['node', 'js'])

const clients = snippetz().clients()
expect(clients).toStrictEqual(['undici', 'fetch', 'fetch', 'ofetch', 'ofetch'])
expect(clients).toStrictEqual([
'undici',
'fetch',
'fetch',
'ofetch',
'ofetch',
])
})
})

Expand Down
22 changes: 11 additions & 11 deletions packages/snippetz/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"extends": "../../tsconfig.json",
"include": ["src"],
"exclude": ["dist", "test", "vite.config.ts", "**/*.test.ts"],
"compilerOptions": {
"declaration": true,
"declarationMap": true,
"emitDeclarationOnly": true,
"outDir": "dist/",
"allowSyntheticDefaultImports": true
}
}
"extends": "../../tsconfig.json",
"include": ["src"],
"exclude": ["dist", "test", "vite.config.ts", "**/*.test.ts"],
"compilerOptions": {
"declaration": true,
"declarationMap": true,
"emitDeclarationOnly": true,
"outDir": "dist/",
"allowSyntheticDefaultImports": true
}
}

0 comments on commit 871bada

Please sign in to comment.