LoginSignup
2
0

More than 3 years have passed since last update.

Dartのパッケージマネージャーのpubにはinitコマンドがない

Last updated at Posted at 2019-09-17

Dartのパッケージマネージャーのpubにはinitコマンドがない

タイトル通りなのですが、Dartのパッケージマネージャーのpubにはinitコマンドがありません。

npmに慣れていた僕としては、pub initでpubspec.yamlが生成されると嬉しいのですが、どうもpub initのissueが上がるたびに閉じられているようなので、pub initを追加する気はあまりないようです。

じゃあnpm init相当のことをしたいときに何を使うのかというと、stagehandを使うようです。

Stagehand

Stagehandとは

StagehandとはDartのプロジェクトの雛形を作成するものです。
なのでnpm initとは直接対応していません。

Stagehandのインストール

$ pub global activate stagehand

Stagehandの使い方

カレントディレクトリに雛形を生成するので、ディレクトリを作成して移動した後stagehandコマンドを使います。

$ mkdir hoge
$ cd hoge
$ stagehand console-full

ただのhelpオプションですが、テンプレート一覧を確認するのによく使うことになるかと思います。

stagehand -h

Stagehandのテンプレート一覧

console-full - A command-line application sample.
package-simple - A starting point for Dart libraries or applications.
server-shelf - A web server built using the shelf package.
web-angular - A web app with material design components.
web-simple - A web app that uses only core Dart libraries.
web-stagexl - A starting point for 2D animation and games.

stagehandより

終わりに

個人的にはpub initコマンドやpub addコマンドなどが欲しいです。

結構pub initpub add関連のissueが閉じられていたのが気になりました。

おまけ

pub init, pub addが欲しい方は、publicanというものを使うと良いかもしれません(使えるのか試してません)。
もし使えなかったら、自前でラッパーを作っても良いと思います。

参考

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0