runDaily.js 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. // @ts-check
  2. /*---------------------------------------------------------------------------------------------
  3. * Copyright (c) Microsoft Corporation. All rights reserved.
  4. * Licensed under the MIT License. See License.txt in the project root for license information.
  5. *--------------------------------------------------------------------------------------------*/
  6. const { execSync } = require("child_process");
  7. const { join } = require("path");
  8. const { readFileSync, writeFileSync } = require("fs");
  9. const fetch = require("node-fetch");
  10. try {
  11. // Update to the daily build
  12. execSync("npm install --save typescript@next")
  13. // Update the dts files
  14. execSync("npm run import-typescript")
  15. // Sync the versions
  16. const packagePath = join(__dirname, "../package.json")
  17. const package = JSON.parse(readFileSync(packagePath, "utf8"))
  18. const tsPackagePath = join(__dirname, "../node_modules/typescript/package.json")
  19. const tsPackage = JSON.parse(readFileSync(tsPackagePath, "utf8"))
  20. // Set the monaco-typescript version to directly match the typescript nightly version
  21. package.version = tsPackage.version
  22. writeFileSync(packagePath, JSON.stringify(package), "utf8")
  23. // Update the dts files
  24. execSync("npm run compile")
  25. } catch (error) {
  26. // If it fails, post a message into the TS teams bot channel
  27. const teamsURL = process.env.TEAMS_INCOMING_WEBHOOK_URL
  28. if(!teamsURL) return
  29. const message = {
  30. "@type": "MessageCard",
  31. "@context": "https://schema.org/extensions",
  32. summary: "Issue with Monaco-TypeScript daily build",
  33. themeColor: "0078D7",
  34. title: 'Issue opened: "Push notifications not working"',
  35. sections: [
  36. {
  37. activityTitle: "Azure Pipelines",
  38. activitySubtitle: "9/13/2016, 11:46am",
  39. activityImage:
  40. "https://avatars2.githubusercontent.com/ml/1303?s=140&v=4",
  41. facts: [
  42. {
  43. name: "Error:",
  44. value: error.name
  45. },
  46. {
  47. name: "Description:",
  48. value: error.message || error.description
  49. }
  50. ]
  51. }
  52. ],
  53. potentialAction: [
  54. {
  55. "@type": "OpenUri",
  56. name: "View in Pipelines",
  57. targets: [
  58. {
  59. os: "default",
  60. uri: "https://link.com"
  61. }
  62. ]
  63. }
  64. ]
  65. };
  66. fetch(teamsURL, {
  67. method: "post",
  68. body: JSON.stringify(message),
  69. headers: { "Content-Type": "application/json" }
  70. });
  71. }