如何使用 NX CLI 将命令转发到 运行-commands?

How to forward command into run-commands using NX CLI?

鉴于我在 angular.json 中有条目使用无服务器 CLI 定义各种命令(作为示例)

"serverless-deploy": {
  "builder": "@nrwl/workspace:run-commands",
  "options": {
    "command": "npx serverless deploy",
    "cwd": "apps/my-app"
  }
},
"serverless-remove": {
  "builder": "@nrwl/workspace:run-commands",
  "options": {
    "command": "npx serverless remove",
    "cwd": "apps/my-app"
  }
}

如何通过减少重复并将其合并为一个条目来改进这一点,以便我可以转发命令?

E.G 是这样的:

"sls": {
  "builder": "@nrwl/workspace:run-commands",
  "options": {
    "command": "npx serverless",
    "cwd": "apps/my-app"
  }
}

然后用 nx 运行 my-app:sls MYCOMMAND 调用它(例如 'deploy' 或 'remove')? 不幸的是,以上方法不起作用,但很想知道这是否可行。

"sls": {
  "builder": "@nrwl/workspace:run-commands",
  "options": {
    "commands": [
      "npx sls {args.cmd}"
    ],
    "cwd": "apps/api",
    "parallel": false
  }
},

nx run api:sls --cmd=deploy