Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
UnJSを使って軽率にCLIを作ってみたらめちゃくちゃ便利だった / create CLI w...
Search
にー兄さん
July 26, 2024
Programming
1.9k
4
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
UnJSを使って軽率にCLIを作ってみたらめちゃくちゃ便利だった / create CLI with UnJS
v-tokyo 12でLT登壇したスライド資料です
Web版:
https://drumath2237.github.io/slides-create-cli-with-unjs/
にー兄さん
July 26, 2024
More Decks by にー兄さん
See All by にー兄さん
ついにAuraも登場したのでJetpack XR SDKについて今一度語りたい / i wanna talk about xreal aura
drumath2237
0
38
『Ground Truth: How We Create Geometrically Accurate Reconstructions (Niantic Spatial Blog)』 を読む / read Ground Truth: How We Create Geometrically Accurate Reconstructions
drumath2237
0
74
この時代にOSS開発に向き合ってみる / face the oss development in this era
drumath2237
0
58
プログラマの職能が代替可能になりつつあるこの時代でプログラムと向き合う修行を積む / dedicating myself to the discipline of programming
drumath2237
0
110
個人的3D Gaussian Splattingニュースをご紹介 / sharing 3d gaussian splatting news
drumath2237
0
640
Jetpack XR SDKから紐解くAndroid XR開発と技術選定のヒント / about-androidxr-and-jetpack-xr-sdk
drumath2237
1
840
XRエンジニアの視点から XRのイマと社会実装の実現について考える / thinking-about-xr-popularization
drumath2237
0
95
軽率にプログラミング言語のシンタックスについて考えてみよう / lets-think-about-programming-lang-syntax
drumath2237
0
150
エンジニアが軽率に趣味から始める、OSS貢献を軸とした個人活動 / oss-contribution-as-a-hoby-project
drumath2237
0
110
Other Decks in Programming
See All in Programming
Pythonの実行はどこまで賢くなったのか? CPythonとPyPyから見る最適化のしくみ
curekoshimizu
4
2.4k
初めての模倣学習とVLA
natsutan
0
420
書籍「プロフェッショナルAI駆動開発」紹介スライド
juntaromatsumoto
0
910
思考垂れ流し開発 ~音声入力 × AIエージェント × 開発ハーネスによる試行錯誤~
npostring
0
730
PyO3 で既存 Python 評価器を Rust core 化する ー wasm-bindgen でブラウザにも配るための設計
kdash
1
220
信頼性の目標を誰も求めてない
shubox
0
470
Hono + Inertia + React で LP を構築した話
oukayuka
2
200
What We Talk About When We Talk About XP
m_seki
2
120
Foundry Localでエージェント開発
seosoft
0
100
Gmail/Google DriveをトリガーにAIエージェントを動かそう! / Run AI agents with Gmail/Google Drive as triggers!
har1101
3
460
Go 1.27 における memory allocation の高速化
andpad
0
370
AI駆動開発にグラフDBを重ねてみた
satoshi256kbyte
2
640
Featured
See All Featured
Building a Scalable Design System with Sketch
lauravandoore
463
34k
Building Experiences: Design Systems, User Experience, and Full Site Editing
marktimemedia
0
590
The State of eCommerce SEO: How to Win in Today's Products SERPs - #SEOweek
aleyda
2
11k
職位にかかわらず全員がリーダーシップを発揮するチーム作り / Building a team where everyone can demonstrate leadership regardless of position
madoxten
69
65k
Technical Leadership for Architectural Decision Making
baasie
3
550
Neural Spatial Audio Processing for Sound Field Analysis and Control
skoyamalab
0
440
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
6.1k
A Tale of Four Properties
chriscoyier
163
24k
How to audit for AI Accessibility on your Front & Back End
davetheseo
0
520
Marketing to machines
jonoalderson
1
5.7k
Designing for Performance
lara
611
70k
Unlocking the hidden potential of vector embeddings in international SEO
frankvandijk
0
910
Transcript
UnJSを使って軽率に CLIを作ってみたら めちゃくちゃ便利だった にー兄さん@ninisan_drumath v-tokyo #21
にー兄さん ソフトウェアエンジニア@HoloLab inc. Babylon.js勉強会運営 Iwaken Lab. 好きなもの Babylon.js / WebXR
Device API / C# ねこ / コーヒー / ウィスキー / ギター アカウント @ninisan_drumath @drumath2237
本日の話 個人開発しているCLIでUnJSを使ってみた どんなパッケージを使ったのか、用途別にご紹介 UnJSのパッケージが気になっている方に刺さると嬉しいです
アジェンダ 1. はじめに 2. 使用したUnJSパッケージ 3. おわりに
はじめに
create-babylon-app とは Babylon.jsのプロジェクトを簡単に作成 するためのCLI コマンドラインから質問に答えるとプロ ジェクトができ、そのまま開発できる手 軽さが売り お手元のターミナルでぜひ試してみてくだ さい! GitHub:
https://github.com/drumath2237/create- babylon-app npm create babylon-app
create-babylon-appの要件 1. 作成するプロジェクト名を指定 2. テンプレートを選択 3. 設定を反映したプロジェクトを作成 create-viteやNuxt CLIの動作に近いので参考にしている。
UnJSとは UnJSは、Nuxt 開発チームが中心となっ て開発・メンテナンスされている、あら ゆるJavaScriptフレームワーク上で統一 的に動作するユーティリティーツール・ ライブラリ群です。 つまりUnJSはパッケージそのものではな く、パッケージ群のこと。 2024/07/26時点で63個ものパッケージが
提供されていてすごい 1. 『UnJS にどんなツールがあるのか、上位30件すべて紹 介してみた(前編)』より ↩︎ [1]
UnJSを使ってみたい 便利なパッケージがたくさんあるんだなぁ 自分でメンテしているCLIに使えないか な…? 当初はcitty目当てで調べ始めた GANGANさんのツイートを発見
使用したUnJSパッケージ
使用したパッケージ一覧 unbuild citty jiti consola giget pkg-types
citty Elegant CLI Builder いわゆるCLIフレームワーク的なものだと思 う コマンドライン引数やサブコマンドなど、 いい感じに設定できて良さげ 今回は run
に処理を書いただけだけど、自 動で --help などに対応してくれるのはう れしい Nuxt CLIの中身を見ると使い方が分かりや すい import { defineCommand, runMain } from "citty"; const main = defineCommand({ meta: { name: "hello", version: "1.0.0", description: "My Awesome CLI App", }, args: { name: { type: "positional", description: "Your name", required: true, }, }, run({ args }) { console.log(`Hi, ${args.name}!`); }, }); runMain(main);
None
giget Download templates and git repositories with pleasure! GitHubなどからファイルをごそっとダウン ロードしてローカルに展開できる
Scaffoldingツールにはもってこいのツール 内部でnypmも使っているので、ダウンロー ドした後にnpmやpnpmで依存解決も可能 使用例 特定のディレクトリも指定できる const { dir: appDir } = await downloadTemplate( `${githubRepoUrlBase}/${templateName}`, { dir: projectName, install: doInstall, }, ); const githubRepoUrlBase = "gh:drumath2237/create const templateName = `${buildTool}-${language}`;
pkg-types Node.js utilities and TypeScript definitions for package.json and tsconfig.json
ディレクトリやファイルパスを指定して package.json や tsconfig をを読み書きできる 自前で書いてもいいけど、型がついたりするのでいい感じ // パッケージ名を変更 const packageJson = await readPackageJSON(appDir); if (packageJson.name) { packageJson.name = projectName; const jsonPath = path.resolve(appDir, "package.json"); await writePackageJSON(jsonPath, packageJson); }
jiti Runtime TypeScript and ESM support for Node.js 開発中にビルドせずに動作を確認するとき に使用
もともとはvite-nodeを使っていたが なんとなく移行してみた 特殊な使い方はしておらず、シンプルにts ファイルを指定して実行するだけ unbuild A unified javascript build system ビルドツールの選択肢はいろいろある中で 元々はtscでコンパイルした.cjsを bin に指 定して動かしていた バンドルなども考慮したいと思い移行 Zero Configでも普通に動くし、 build.config.ts にビルド設定を記述可能 pnpm exec jiti src/run.ts import { defineBuildConfig } from "unbuild"; export default defineBuildConfig({ entries: ["./src/index.ts"], });
おわりに
None
参考文献 UnJS https://unjs.io/ create-babylon-app v1.0に向けたアプデ作業 https://zenn.dev/drumath2237/scraps/b085d5f90b65f3 drumath2237/create-babylon-app https://github.com/drumath2237/create-babylon-app