diff --git a/package.json b/package.json index 015be4a12e09..11b390d660d9 100644 --- a/package.json +++ b/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", diff --git a/script/cibuild b/script/cibuild index dc2d9d081045..4d43a7f0119a 100755 --- a/script/cibuild +++ b/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') diff --git a/script/create-dist.py b/script/create-dist.py index 3d4b62624eee..4737fc7cd51f 100755 --- a/script/create-dist.py +++ b/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: diff --git a/script/upload.py b/script/upload.py index 8b4cdfcbdf0b..7d689f6cae87 100755 --- a/script/upload.py +++ b/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))