Browse Source

generate and upload electron.d.ts with each release

Zeke Sikelianos 8 years ago
parent
commit
9a10486514
4 changed files with 11 additions and 0 deletions
  1. 2 0
      package.json
  2. 4 0
      script/cibuild
  3. 4 0
      script/create-dist.py
  4. 1 0
      script/upload.py

+ 2 - 0
package.json

@@ -6,6 +6,7 @@
     "browserify": "^13.1.0",
     "electabul": "~0.0.4",
     "electron-docs-linter": "^2.1.0",
+    "electron-typescript-definitions": "^1.0.0",
     "request": "*",
     "standard": "^8.4.0",
     "standard-markdown": "^2.1.1"
@@ -32,6 +33,7 @@
     "clean": "python ./script/clean.py",
     "clean-build": "python ./script/clean.py --build",
     "coverage": "npm run instrument-code-coverage && npm test -- --use-instrumented-asar",
+    "generate-typescript-definitions": "electron-typescript-definitions --in=out/electron-api.json --out=out/electron.d.ts",
     "instrument-code-coverage": "electabul instrument --input-path ./lib --output-path ./out/coverage/electron.asar",
     "lint": "npm run lint-js && npm run lint-cpp && npm run lint-py && npm run lint-api-docs-js && npm run lint-api-docs",
     "lint-js": "standard && cd spec && standard",

+ 4 - 0
script/cibuild

@@ -81,6 +81,10 @@ def main():
     sys.stderr.write('\nRunning `npm run lint`\n')
     sys.stderr.flush()
     execute([npm, 'run', 'lint'])
+
+    sys.stderr.write('\nRunning `npm run generate-typescript-definitions`\n')
+    sys.stderr.flush()
+    execute([npm, 'run', 'generate-typescript-definitions'])
   if is_release:
     run_script('build.py', ['-c', 'R'])
     run_script('create-dist.py')

+ 4 - 0
script/create-dist.py

@@ -92,6 +92,7 @@ def main():
 
   if PLATFORM != 'win32' and not args.no_api_docs:
     create_api_json_schema()
+    copy_typescript_definitions()
 
   if PLATFORM == 'linux':
     strip_binaries()
@@ -144,6 +145,9 @@ def create_api_json_schema():
            '--version={}'.format(ELECTRON_VERSION.replace('v', ''))],
           env=env)
 
+def copy_typescript_definitions():
+    shutil.copy2(os.path.join(SOURCE_ROOT, 'out', 'electron.d.ts'), DIST_DIR)
+
 def strip_binaries():
   for binary in TARGET_BINARIES[PLATFORM]:
     if binary.endswith('.so') or '.' not in binary:

+ 1 - 0
script/upload.py

@@ -81,6 +81,7 @@ def main():
   if PLATFORM == 'darwin':
     upload_electron(github, release, os.path.join(DIST_DIR,
                     'electron-api.json'))
+    upload_electron(github, release, os.path.join(DIST_DIR, 'electron.d.ts'))
     upload_electron(github, release, os.path.join(DIST_DIR, DSYM_NAME))
   elif PLATFORM == 'win32':
     upload_electron(github, release, os.path.join(DIST_DIR, PDB_NAME))