1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

お題は不問!Qiita Engineer Festa 2024で記事投稿!
Qiita Engineer Festa20242024年7月17日まで開催中!

importmapのhelpで出てくるコマンドを試してみた

Last updated at Posted at 2024-06-24

はじめに

railsのimportmapを使っていて、そういえばpin以外にどういうコマンド使えるのかと思ったので、使ってみたいと思います。

importmapのコマンド

importmap help [COMMAND]

利用可能なコマンド、または指定された特定のコマンドの詳細な説明を表示する。
利用可能なコマンドを表示

$ docker compose run --rm web ./bin/importmap help

Commands:
  importmap audit              # Run a security audit
  importmap help [COMMAND]     # Describe available commands or one specific command
  importmap json               # Show the full importmap in json
  importmap outdated           # Check for outdated packages
  importmap packages           # Print out packages with version numbers
  importmap pin [*PACKAGES]    # Pin new packages
  importmap unpin [*PACKAGES]  # Unpin existing packages
  importmap update             # Update outdated package pins

指定された特定のコマンドの詳細な説明を表示

$  docker compose run --rm web ./bin/importmap help pin

Usage:
  importmap pin [*PACKAGES]

Options:
  -e, [--env=ENV]    
                     # Default: production
  -f, [--from=FROM]  
                     # Default: jspm

Pin new packages

importmap audit

プロジェクト内の依存関係に潜在的なセキュリティ問題がないかチェック

$ docker compose run --rm web ./bin/importmap audit

No vulnerable packages found

importmap json

importmapの全内容をJSON形式で表示

$ docker compose run --rm web ./bin/importmap json

{
  "imports": {
    "application": "/assets/application-f3e871e7be89ccb0adccd09d1fb0f2c5f0583d0626142906e3b227e5641284be.js",
    "@hotwired/turbo-rails": "/assets/turbo.min-918a6cf2f2be8ed9555c9a11eee69c7dc2f01770802815576efc931876b327fb.js",
    "@hotwired/stimulus": "/assets/stimulus.min-dd364f16ec9504dfb72672295637a1c8838773b01c0b441bd41008124c407894.js",
    "@hotwired/stimulus-loading": "/assets/stimulus-loading-3576ce92b149ad5d6959438c6f291e2426c86df3b874c525b30faad51b0d96b3.js",
    "bootstrap": "/assets/bootstrap.min-158d51560e04dda7c718c1c8f31e72d6c2eef7028a80a158043380b15e6b5aef.js",
    "controllers/application": "/assets/controllers/application-368d98631bccbf2349e0d4f8269afb3fe9625118341966de054759d96ea86c7e.js",
    "controllers/hello_controller": "/assets/controllers/hello_controller-549135e8e7c683a538c3d6d517339ba470fcfb79d62f738a0a089ba41851a554.js",
    "controllers": "/assets/controllers/index-2db729dddcc5b979110e98de4b6720f83f91a123172e87281d5a58410fc43806.js"
  }
}

importmap outdated

更新が必要なパッケージのリストを表示

$ docker compose run --rm web ./bin/importmap outdated

No outdated packages found

importmap packages

プロジェクト内で使用されているすべてのパッケージの一覧が表示

$ docker compose run --rm web ./bin/importmap packages

jquery 3.7.1

importmap pin [*PACKAGES]

新しいパッケージを固定する

$  docker compose run --rm web ./bin/importmap pin jquery

Pinning "jquery" to vendor/javascript/jquery.js via download from https://ga.jspm.io/npm:jquery@3.7.1/dist/jquery.js

importmap unpin [*PACKAGES]

既存のパッケージの固定を解除する

$ docker compose run --rm web ./bin/importmap unpin jquery

Unpinning and removing "jquery"

importmap update

古くなったパッケージpinを更新

$ docker compose run --rm web ./bin/importmap update

No outdated packages found

終わりに

使ったことのないコマンドがほとんどでしたが、有用そうなコマンドがいくつかあったので試せてよかったです。

1
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
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?