aboutsummaryrefslogtreecommitdiff
path: root/lib/mix/tasks/vendor.ex
blob: 06e3aa5c4073d19a2adb38bdfbba7139ac54297c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
defmodule Mix.Tasks.Vendor do
  use Mix.Task

  @impl Mix.Task
  def run([]) do
    {_, 0} = System.cmd("npm", ~w(install --include=dev))

    File.cp_r!("node_modules/video.js/dist", "priv/static/video.js")
    File.cp_r!("node_modules/video.js/LICENSE", "priv/static/video.js/LICENSE")

    {_, 0} = System.cmd("npx", ~w(parcel build --target discord-embedded-app-sdk))

    discord_readme_path = "priv/static/discord-embedded-app-sdk/README.md"

    File.cp_r!(
      "node_modules/@discord/embedded-app-sdk/LICENSE.md",
      discord_readme_path
    )

    File.write!(
      discord_readme_path,
      """
      This directory contains a bundled version of https://github.com/discord/embedded-app-sdk/
      See lib/mix/tasks/vendor.ex for how it was generated. The license for the \
      original library is reproduced below:\n
      """ <> File.read!(discord_readme_path)
    )

    nil
  end
end