ask-cli@v2でlambda以外をデプロイする

ask-cliのv2がついにリリースされました。
v1からv2になり、色々変わりましたが、今回はデプロイについてのメモです。

# 一言で
ask-cli@v2でlambda以外をデプロイしたい場合は、
`ask-resources.json` を修正すれば良い。

```
% cat ask-resources.json
{
  "askcliResourcesVersion": "2020-03-31",
  "profiles": {
    "default": {
      "skillMetadata": {
        "src": "./skill-package"
      }
    }
  }
}                                                                       
```


# 説明

v1では deployコマンドに色々オプションがありました。
例えば、modelだけデプロイするには、 `ask deploy -t model` を実行します。


```
% ask -version
1.7.23

% ask deploy -h

  Usage: ask-deploy

  $ ask deploy [--no-wait] [-t|--target <target>] [--force] [-p|--profile <profile>] [--debug]

  Deploys a skill project to your developer account, optionally deploying Lambda code. For example, for a custom skill, your skill.json file, interaction model file, and AWS Lambda function code files will be deployed. For a smart home skill, your skill.json file and code files will be deployed. For a flash briefing skill, only the skill.json file will be deployed.

  If the skill has never been deployed, the ask-cli will create a new skill and a new Lambda function. The newly created skill ID is written to the skill configuration file at $HOME/.ask/config.

  If the skill already exists, ask-cli will update the existing skill, including metadata, sample utterances, and so on, as well as AWS Lambda function resources if applicable. If this skill package has been created by previously downloading an existing skill using "ask clone", and you perform "ask deploy" on the package for the first time, then ask-cli will prompt you to ensure you want to overwrite the existing skill in your account.


  Options:

    --no-wait                asynchronous model deployment
    -t, --target <target>    deploy lambda, model, skill, isp or all of them. Options can only be "all", "lambda", "skill", "isp" or "model".
    --force                  deploy specified skill resources regardless of the eTag check
    -p, --profile <profile>  ask cli profile
    --debug                  ask cli debug mode
    -h, --help               output usage information
```

------

一方、v2にはdeploy targetがありません。
modelやskillはask-cli、lambdaはserverlessで管理している私としては困りました:thinking: 

```
% ask -V
2.10.1

% ask deploy -h
Usage: ask deploy [options]

deploy the skill project

Options:
  --ignore-hash            [OPTIONAL] Forces ASK CLI deploy skill package even if the hash of current skill package
                           folder does not change.
  -p, --profile <profile>  [OPTIONAL] Provides the ASK CLI profile to use. When you don't include this option, ASK CLI
                           uses the default profile.
  --debug                  [OPTIONAL] Enables the ASK CLI  to show debug messages in the output of the command.
  -h, --help               output usage information
```


探してみると回避策がありました！
https://github.com/alexa/ask-cli/issues/205

# やり方
雛形を作ってやってみた。

```
% ask new
Please follow the wizard to start your Alexa skill project ->
? Choose the programming language you will use to code your skill:  NodeJS
? Choose a method to host your skill's backend resources:  self-hosted and manage your own hosting
? Choose a template to start with:  Hello world             Alexa's hello world skill to send the greetings to the world!
? Please type in your skill name:  skill-sample-nodejs-hello-world
? Please type in your folder name for the skill project (alphanumeric):  Helloworld
Project for skill "skill-sample-nodejs-hello-world" is successfully created at /mnt/c/Users/home/develop/Helloworld

Project initialized successfully.

% cd Helloworld
% tree
.
├── LICENSE.txt
├── ask-resources.json
├── lambda
│   ├── index.js
│   ├── package.json
│   └── util.js
└── skill-package
    ├── assets
    │   ├── en-US_largeIcon.png
    │   └── en-US_smallIcon.png
    ├── interactionModels
    │   └── custom
    │       └── en-US.json
    └── skill.json

5 directories, 9 files
```



```ask-resources.jsonのデフォルト

% cat ask-resources.json
{
  "askcliResourcesVersion": "2020-03-31",
  "profiles": {
    "default": {
      "skillMetadata": {
        "src": "./skill-package"
      },
      "code": {
        "default": {
          "src": "./lambda"
        }
      },
      "skillInfrastructure": {
        "userConfig": {
          "runtime": "nodejs10.x",
          "handler": "index.handler"
        }
      }
    }
  }
}                                                                       
```

```ask-resources.jsonを修正
% cat ask-resources.json
{
  "askcliResourcesVersion": "2020-03-31",
  "profiles": {
    "default": {
      "skillMetadata": {
        "src": "./skill-package"
      }
    }
  }
}                                                                       
```

# 最後に
ドキュメント見つけられなかったら、ソース（Github）を直接見ると良いよということでした。