name: 'Generate Types for Archaeologist Dig'
description: 'Generate Types for Archaeologist Dig'
inputs:
  sha-file:
    description: 'File containing sha'
    required: true
  filename:
    description: 'Filename to write types to'
    required: true
runs:
  using: "composite"
  steps:
  - name: Generating Types for SHA in ${{ inputs.sha-file }}
    shell: bash
    run: |
      export ELECTRON_DIR=$(pwd)
      if [ "${{ inputs.sha-file }}" == ".dig-old" ]; then
        cd /tmp
        git clone https://github.com/electron/electron.git
        cd electron
      fi
      git checkout $(cat $ELECTRON_DIR/${{ inputs.sha-file }})
      node script/yarn.js install --immutable
      echo "#!/usr/bin/env node\nglobal.x=1" > node_modules/typescript/bin/tsc
      node node_modules/.bin/electron-docs-parser --dir=./ --outDir=./ --moduleVersion=0.0.0-development
      node node_modules/.bin/electron-typescript-definitions --api=electron-api.json --outDir=artifacts
      mv artifacts/electron.d.ts $ELECTRON_DIR/artifacts/${{ inputs.filename }}
    working-directory: ./electron
