version: '{build}'

platform: x86

environment:
  priv_key:
    secure: ek1AH0N8/KF6VoildmkHnu4TY1yBZcptm20AesAOanRSSGLFqkXeRxL80mHSXtiVY8ggtQNsEQR4M69gCiw1OPVWz4OAN6Vg6id6kho9GqYxWCdADbmffSNPB5leksRGjGmkAF99WHiOIZrLRUb6Bia91Fe5+SngPhI01GDDUZA2urv9x50uBBhc+kvV0bv7J5TeXDGr7tfZ3J2aL/3tf/WPqBkqjWlGAj99HTWpkIiQgwaBHoyBvEFD0uHa1BdSmI7PySGabbx4/4zqyGkO38Ce7t/Ntu/dgedzVxlXYfuiXDI8caAPZSVsJ9E2S3VKesZJzHtV9KM/8Xq0RFPythdC/qTvd2e3IAZGudZpgbUHGAHLJnCzn189Zm+Qle8CbbVuPNDcf1B/G/XwEU2MsDXGkF/kFxdeqbHgjzneyns=
  BT_TOKEN:
    secure: VNRwtuHDHJQS0UbCW2WmNSyyRtKhYPC5FCZztllsIygyg3dj5H/YY89UUmPW9vU7
  GH_TOKEN:
    secure: dAqGTWGo387j9Kaot54scDTRWzXGb3DBVPVcOIzQhNAvSt3WCvXA6xBYIFvPH4pQ
  CSC_LINK:
    secure: [encoded data, 5612 characters]
#  npm_config_target: 1.4.10 # 在下面 install 里动态获取
  npm_config_arch: ia32
  npm_config_target_arch: ia32
  npm_config_disturl: https://atom.io/download/atom-shell
  npm_config_runtime: electron
  npm_config_build_from_source: true

cache:
  - node_modules -> package.json
  - '%APPDATA%\npm-cache -> package.json'
  - '%USERPROFILE%\.electron -> package.json'

shallow_clone: true

init:
  # - ps: iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))
  - ps: $fileContent = "-----BEGIN EC PRIVATE KEY-----`n"
  - ps: $fileContent += $env:priv_key.Replace(' ', "`n")
  - ps: $fileContent += "`n-----END EC PRIVATE KEY-----`n"
  - ps: Set-Content c:\users\appveyor\.ssh\id_ecdsa $fileContent

# on_finish:
#  - ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))

install:
  - set PATH=%PATH%;C:\cygwin\bin # curl, tar xz
  - mkdir -p bin
  - curl --location --retry 5 --output aria2-1.29.0-win-32bit-build1.zip https://github.com/aria2/aria2/releases/download/release-1.29.0/aria2-1.29.0-win-32bit-build1.zip
  - unzip -o aria2-1.29.0-win-32bit-build1.zip aria2-1.29.0-win-32bit-build1/aria2c.exe
  - mv aria2-1.29.0-win-32bit-build1/aria2c.exe bin
  - rm -rf aria2-1.29.0-win-32bit-build1 aria2-1.29.0-win-32bit-build1.zip
  - curl --location --retry 5 "http://downloads.sourceforge.net/project/msys2/REPOS/MSYS2/i686/bsdtar-3.2.1-1-i686.pkg.tar.xz" | tar --strip-components=2 -C bin -Jxf - usr/bin/bsdtar.exe
  - curl --location --retry 5 "http://downloads.sourceforge.net/project/msys2/Base/i686/msys2-base-i686-20161025.tar.xz" | tar --strip-components=3 -C bin -Jxf - msys32/usr/bin/msys-2.0.dll msys32/usr/bin/msys-bz2-1.dll msys32/usr/bin/msys-gcc_s-1.dll msys32/usr/bin/msys-iconv-2.dll msys32/usr/bin/msys-lzma-5.dll msys32/usr/bin/msys-lzo2-2.dll msys32/usr/bin/msys-nettle-6.dll msys32/usr/bin/msys-xml2-2.dll msys32/usr/bin/msys-z.dll msys32/usr/bin/sha256sum.exe msys32/usr/bin/msys-intl-8.dll

  - ps: Install-Product node
  - npm show electron version > %temp%\electron-version.txt
  - set /p npm_config_target= < %temp%\electron-version.txt
  - npm install
  - npm prune

build_script:
  - npm run dist
