Skip to content

Commit

Permalink
setup for deno
Browse files Browse the repository at this point in the history
  • Loading branch information
kazupon committed Oct 23, 2023
1 parent 805ec89 commit 65be63c
Show file tree
Hide file tree
Showing 9 changed files with 122 additions and 5 deletions.
20 changes: 20 additions & 0 deletions deno/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
The MIT License (MIT)

Copyright (c) 2023 kazuya kawaguchi

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 changes: 24 additions & 0 deletions deno/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# @intlify/hono

[![npm version][npm-version-src]][npm-version-href]
[![npm downloads][npm-downloads-src]][npm-downloads-href]
[![CI][ci-src]][ci-href]

Internationalization middleware & utilities for [Hono](https://hono.dev/)


> [!WARNING]
> **This is WIP 👷
## ©️ License

[MIT](http://opensource.org/licenses/MIT)

<!-- Badges -->

[npm-version-src]: https://img.shields.io/npm/v/@intlify/hono?style=flat&colorA=18181B&colorB=FFAD33
[npm-version-href]: https://npmjs.com/package/@intlify/hono
[npm-downloads-src]: https://img.shields.io/npm/dm/@intlify/hono?style=flat&colorA=18181B&colorB=FFAD33
[npm-downloads-href]: https://npmjs.com/package/@intlify/hono
[ci-src]: https://github.com/intlify/utils/actions/workflows/ci.yml/badge.svg
[ci-href]: https://github.com/intlify/utils/actions/workflows/ci.yml
11 changes: 11 additions & 0 deletions deno/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import type { CoreOptions } from '@intlify/core'
import type { Context, MiddlewareHandler, Next } from 'hono'

export function defineI18nMiddleware(options: CoreOptions = {}): MiddlewareHandler {
// TODO:

return async (ctx: Context, next: Next) => {
// TODO:
await next()
}
}
1 change: 1 addition & 0 deletions deno/mod.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './index.ts'
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
"fix": "npm run format && npm run lint",
"lint": "deno lint",
"format": "deno fmt",
"build": "unbuild",
"build": "unbuild && bun run ./scripts/deno.ts",
"test": "npm run test:type && npm run test:unit",
"test:type": "vitest typecheck --run",
"test:unit": "vitest run",
Expand Down
41 changes: 41 additions & 0 deletions scripts/deno.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { promises as fs } from 'node:fs'
import { resolve } from 'node:path'
import { fileURLToPath } from 'node:url'
import { isExists } from './utils.ts'

const __dirname = fileURLToPath(new URL('.', import.meta.url))

const TARGETS = [
'index.ts',
]

async function main() {
const projectPath = resolve(__dirname, '..')
const sourcePath = resolve(__dirname, '../src')
const destPath = resolve(__dirname, '../deno')

if (!await isExists(destPath)) {
throw new Error(`not found ${destPath}`)
}

console.log('copy some source files to denoland hosting directries 🦕 ...')

// copy docs
for (const p of ['README.md', 'LICENSE']) {
fs.copyFile(resolve(projectPath, p), resolve(destPath, p))
console.log(`${resolve(projectPath, p)} -> ${resolve(destPath, p)}`)
}

// copy source files
for (const target of TARGETS) {
fs.copyFile(resolve(sourcePath, target), resolve(destPath, target))
console.log(`${resolve(sourcePath, target)} -> ${resolve(destPath, target)}`)
}

console.log('... 🦕 done!')
}

main().catch((err) => {
console.error(err)
process.exit(1)
})
10 changes: 10 additions & 0 deletions scripts/utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { constants as FS_CONSTANTS, promises as fs } from 'node:fs'

export async function isExists(path: string) {
try {
await fs.access(path, FS_CONSTANTS.F_OK)
return true
} catch {
return false
}
}
12 changes: 11 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,11 @@
console.log('hello honojs!')
import type { CoreOptions } from '@intlify/core'
import type { Context, MiddlewareHandler, Next } from 'hono'

export function defineI18nMiddleware(_options: CoreOptions = {}): MiddlewareHandler {
// TODO:

return async (_ctx: Context, next: Next) => {
// TODO:
await next()
}
}
6 changes: 3 additions & 3 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,15 @@
// "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */

/* Emit */
// "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
"declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
// "declarationMap": true, /* Create sourcemaps for d.ts files. */
// "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
"emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
// "sourceMap": true, /* Create source map files for emitted JavaScript files. */
// "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
// "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
// "outDir": "./", /* Specify an output folder for all emitted files. */
// "removeComments": true, /* Disable emitting comments. */
// "noEmit": true, /* Disable emitting files from a compilation. */
// "noEmit": true, /* Disable emitting files from a compilation. */
// "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
// "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types. */
// "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
Expand Down

0 comments on commit 65be63c

Please sign in to comment.