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
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 にー兄さん
ついにAuraも登場したのでJetpack XR SDKについて今一度語りたい / i wanna talk about xreal aura
drumath2237
0
39
『Ground Truth: How We Create Geometrically Accurate Reconstructions (Niantic Spatial Blog)』 を読む / read Ground Truth: How We Create Geometrically Accurate Reconstructions
drumath2237
0
76
この時代にOSS開発に向き合ってみる / face the oss development in this era
drumath2237
0
62
プログラマの職能が代替可能になりつつあるこの時代でプログラムと向き合う修行を積む / 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
850
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
異なる設計思想のフレームワークを経験して得た学び
amekuhideki
2
1.5k
『寄り添うラジオ』をAIで作る 体験価値から逆算した、会話しないUXと品質設計
theoriatec2024
3
140
iOS開発×AI駆動開発 〜最近使って便利だったスキルの話〜
nogu66
0
140
週末にAI-DLCを本気で回したら$1,600溶けた
hbashimizu
0
130
LL言語やWebフレームワークのPostgreSQL対応 〜DBの機能がユーザーに届くまで〜
kentaroutakeda
0
140
初心者DevRelとして参加者だった私が、DevRel Talks!#2に登壇するまでにしてきたこと
sokohirai
0
340
DynamoDBの基礎を振り返りながらベクトル検索機能を理解する
musan
3
270
AIを上手に使っていこうとしたら越境せざるを得なくなった話 〜実践1年で見えた境界を越えなければならない理由と進め方〜 / Crossing borders with AI
tomoyakitaura
4
1.1k
新人はどこまで自力でやり、どこからAIに頼るべきか/エンジニア育成に向き合う_先輩たちの悩みと知見共有会
toppan_digital_dev
1
580
Kiroで創り、AgentCoreで繋ぐ!AWSで実践する「AI-DLC」から「AIエージェント統合」までの最新地図
licux
3
370
AgentCore CLI で進化した AWS での AI エージェントの作り方 : 必要な機能を必要な時に
icoxfog417
PRO
1
150
[DroidKaigi 2026] Bring your own phones to Gradle Managed Devices
f2lk
0
110
Featured
See All Featured
Marketing to machines
jonoalderson
1
5.8k
Product Roadmaps are Hard
iamctodd
55
13k
Leading Effective Engineering Teams in the AI Era
addyosmani
9
2.6k
Primal Persuasion: How to Engage the Brain for Learning That Lasts
tmiket
0
450
StorybookのUI Testing Handbookを読んだ
zakiyama
31
6.9k
Building Adaptive Systems
keathley
44
3.2k
Ecommerce SEO: The Keys for Success Now & Beyond - #SERPConf2024
aleyda
1
2.1k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
Redefining SEO in the New Era of Traffic Generation
szymonslowik
1
410
ラッコキーワード サービス紹介資料
rakko
1
4.8M
Digital Ethics as a Driver of Design Innovation
axbom
PRO
1
420
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
47
8.3k
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