Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
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 にー兄さん
UnityでSystem.Net.WebSocketsなWebSocketサーバが動かないのでUnity Monoのコードを覗いてみた / about implementing websocket server with unity mono
drumath2237
1
90
ついにAuraも登場したのでJetpack XR SDKについて今一度語りたい / i wanna talk about xreal aura
drumath2237
0
41
『Ground Truth: How We Create Geometrically Accurate Reconstructions (Niantic Spatial Blog)』 を読む / read Ground Truth: How We Create Geometrically Accurate Reconstructions
drumath2237
0
77
この時代にOSS開発に向き合ってみる / face the oss development in this era
drumath2237
0
63
プログラマの職能が代替可能になりつつあるこの時代でプログラムと向き合う修行を積む / dedicating myself to the discipline of programming
drumath2237
0
110
個人的3D Gaussian Splattingニュースをご紹介 / sharing 3d gaussian splatting news
drumath2237
0
650
Jetpack XR SDKから紐解くAndroid XR開発と技術選定のヒント / about-androidxr-and-jetpack-xr-sdk
drumath2237
1
860
XRエンジニアの視点から XRのイマと社会実装の実現について考える / thinking-about-xr-popularization
drumath2237
0
98
軽率にプログラミング言語のシンタックスについて考えてみよう / lets-think-about-programming-lang-syntax
drumath2237
0
150
Other Decks in Programming
See All in Programming
iOSDC Japan 2026 - Swiftで作って学ぼう!データベース自作入門
kaseken
2
170
GKE で Pod の見方を変えたら、スケールアウト時の挙動を真に捉えられた話
stkk
0
130
Kiroで創り、AgentCoreで繋ぐ!AWSで実践する「AI-DLC」から「AIエージェント統合」までの最新地図
licux
4
700
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
430
技術的負債を組織課題として解く-増えすぎたマイクロサービスとの戦い-
reimaru
1
2k
Intent as Code
shoppingjaws
6
1k
モデルのリファクタリングが難しいと思ったら、そもそも複雑だったのはビジネス仕様だった ? / is-the-business-domain-the-real-complexity
hatsu38
0
340
Java 27新機能 / Java 27 new features
kishida
2
150
Jetpack Compose メカニズム
skydoves
0
440
Family mrubyの進捗
kishima
1
130
『寄り添うラジオ』をAIで作る 体験価値から逆算した、会話しないUXと品質設計
theoriatec2024
3
180
TiDB Cloudのカスタムコントローラーによるオートスケール対応
takaidohigasi
0
130
Featured
See All Featured
Ruling the World: When Life Gets Gamed
codingconduct
0
330
GraphQLの誤解/rethinking-graphql
sonatard
75
12k
Groundhog Day: Seeking Process in Gaming for Health
codingconduct
0
350
It's Worth the Effort
3n
188
29k
Visual Storytelling: How to be a Superhuman Communicator
reverentgeek
2
660
Practical Orchestrator
shlominoach
192
12k
A better future with KSS
kneath
240
18k
コードの90%をAIが書く世界で何が待っているのか / What awaits us in a world where 90% of the code is written by AI
rkaga
63
46k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4.6k
Are puppies a ranking factor?
jonoalderson
2
3.9k
Bioeconomy Workshop: Dr. Julius Ecuru, Opportunities for a Bioeconomy in West Africa
akademiya2063
PRO
1
360
The SEO identity crisis: Don't let AI make you average
varn
0
560
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