@netlify/build-info 6.6.1 → 6.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (260) hide show
  1. package/bin.js +1 -1
  2. package/lib/{browser → src/browser}/file-system.d.ts +4 -3
  3. package/lib/{browser → src/browser}/file-system.js +5 -2
  4. package/lib/src/browser/file-system.js.map +1 -0
  5. package/lib/{build-systems → src/build-systems}/bazel.d.ts +1 -2
  6. package/lib/{build-systems → src/build-systems}/bazel.js +5 -2
  7. package/lib/src/build-systems/bazel.js.map +1 -0
  8. package/lib/{build-systems → src/build-systems}/buck.d.ts +1 -2
  9. package/lib/{build-systems → src/build-systems}/buck.js +5 -2
  10. package/lib/src/build-systems/buck.js.map +1 -0
  11. package/lib/src/build-systems/build-system.d.ts +38 -0
  12. package/lib/src/build-systems/build-system.js +30 -0
  13. package/lib/src/build-systems/build-system.js.map +1 -0
  14. package/lib/{build-systems → src/build-systems}/gradle.d.ts +1 -2
  15. package/lib/{build-systems → src/build-systems}/gradle.js +5 -2
  16. package/lib/src/build-systems/gradle.js.map +1 -0
  17. package/lib/src/build-systems/index.d.ts +11 -0
  18. package/lib/src/build-systems/index.js.map +1 -0
  19. package/lib/src/build-systems/lage.js.map +1 -0
  20. package/lib/{build-systems → src/build-systems}/moon.d.ts +1 -2
  21. package/lib/{build-systems → src/build-systems}/moon.js +5 -5
  22. package/lib/src/build-systems/moon.js.map +1 -0
  23. package/lib/{build-systems → src/build-systems}/nix.d.ts +1 -2
  24. package/lib/{build-systems → src/build-systems}/nix.js +5 -2
  25. package/lib/src/build-systems/nix.js.map +1 -0
  26. package/lib/src/build-systems/nrwl.d.ts +15 -0
  27. package/lib/src/build-systems/nrwl.js +73 -0
  28. package/lib/src/build-systems/nrwl.js.map +1 -0
  29. package/lib/{build-systems → src/build-systems}/pants.d.ts +1 -2
  30. package/lib/{build-systems → src/build-systems}/pants.js +5 -2
  31. package/lib/src/build-systems/pants.js.map +1 -0
  32. package/lib/src/build-systems/rush.js.map +1 -0
  33. package/lib/src/build-systems/turbo.js.map +1 -0
  34. package/lib/{file-system.d.ts → src/file-system.d.ts} +9 -17
  35. package/lib/{file-system.js → src/file-system.js} +38 -64
  36. package/lib/src/file-system.js.map +1 -0
  37. package/lib/src/frameworks/angular.d.ts +24 -0
  38. package/lib/src/frameworks/angular.js +23 -0
  39. package/lib/src/frameworks/angular.js.map +1 -0
  40. package/lib/src/frameworks/assemble.d.ts +16 -0
  41. package/lib/src/frameworks/assemble.js +17 -0
  42. package/lib/src/frameworks/assemble.js.map +1 -0
  43. package/lib/src/frameworks/astro.d.ts +25 -0
  44. package/lib/src/frameworks/astro.js +24 -0
  45. package/lib/src/frameworks/astro.js.map +1 -0
  46. package/lib/src/frameworks/blitz.d.ts +23 -0
  47. package/lib/src/frameworks/blitz.js +22 -0
  48. package/lib/src/frameworks/blitz.js.map +1 -0
  49. package/lib/src/frameworks/brunch.d.ts +24 -0
  50. package/lib/src/frameworks/brunch.js +23 -0
  51. package/lib/src/frameworks/brunch.js.map +1 -0
  52. package/lib/src/frameworks/cecil.d.ts +23 -0
  53. package/lib/src/frameworks/cecil.js +22 -0
  54. package/lib/src/frameworks/cecil.js.map +1 -0
  55. package/lib/src/frameworks/docpad.d.ts +18 -0
  56. package/lib/src/frameworks/docpad.js +17 -0
  57. package/lib/src/frameworks/docpad.js.map +1 -0
  58. package/lib/src/frameworks/docusaurus.d.ts +30 -0
  59. package/lib/src/frameworks/docusaurus.js +45 -0
  60. package/lib/src/frameworks/docusaurus.js.map +1 -0
  61. package/lib/src/frameworks/eleventy.d.ts +24 -0
  62. package/lib/src/frameworks/eleventy.js +23 -0
  63. package/lib/src/frameworks/eleventy.js.map +1 -0
  64. package/lib/src/frameworks/ember.d.ts +24 -0
  65. package/lib/src/frameworks/ember.js +23 -0
  66. package/lib/src/frameworks/ember.js.map +1 -0
  67. package/lib/src/frameworks/expo.d.ts +24 -0
  68. package/lib/src/frameworks/expo.js +23 -0
  69. package/lib/src/frameworks/expo.js.map +1 -0
  70. package/lib/src/frameworks/framework.d.ts +187 -0
  71. package/lib/src/frameworks/framework.js +225 -0
  72. package/lib/src/frameworks/framework.js.map +1 -0
  73. package/lib/src/frameworks/gatsby.d.ts +32 -0
  74. package/lib/src/frameworks/gatsby.js +45 -0
  75. package/lib/src/frameworks/gatsby.js.map +1 -0
  76. package/lib/src/frameworks/gridsome.d.ts +24 -0
  77. package/lib/src/frameworks/gridsome.js +23 -0
  78. package/lib/src/frameworks/gridsome.js.map +1 -0
  79. package/lib/src/frameworks/grunt.d.ts +16 -0
  80. package/lib/src/frameworks/grunt.js +17 -0
  81. package/lib/src/frameworks/grunt.js.map +1 -0
  82. package/lib/src/frameworks/gulp.d.ts +16 -0
  83. package/lib/src/frameworks/gulp.js +17 -0
  84. package/lib/src/frameworks/gulp.js.map +1 -0
  85. package/lib/src/frameworks/harp.d.ts +23 -0
  86. package/lib/src/frameworks/harp.js +22 -0
  87. package/lib/src/frameworks/harp.js.map +1 -0
  88. package/lib/src/frameworks/hexo.d.ts +24 -0
  89. package/lib/src/frameworks/hexo.js +23 -0
  90. package/lib/src/frameworks/hexo.js.map +1 -0
  91. package/lib/src/frameworks/hugo.d.ts +23 -0
  92. package/lib/src/frameworks/hugo.js +22 -0
  93. package/lib/src/frameworks/hugo.js.map +1 -0
  94. package/lib/src/frameworks/hydrogen.d.ts +23 -0
  95. package/lib/src/frameworks/hydrogen.js +22 -0
  96. package/lib/src/frameworks/hydrogen.js.map +1 -0
  97. package/lib/src/frameworks/index.d.ts +49 -0
  98. package/lib/src/frameworks/index.js +97 -0
  99. package/lib/src/frameworks/index.js.map +1 -0
  100. package/lib/src/frameworks/jekyll.d.ts +23 -0
  101. package/lib/src/frameworks/jekyll.js +22 -0
  102. package/lib/src/frameworks/jekyll.js.map +1 -0
  103. package/lib/src/frameworks/metalsmith.d.ts +16 -0
  104. package/lib/src/frameworks/metalsmith.js +17 -0
  105. package/lib/src/frameworks/metalsmith.js.map +1 -0
  106. package/lib/src/frameworks/middleman.d.ts +23 -0
  107. package/lib/src/frameworks/middleman.js +22 -0
  108. package/lib/src/frameworks/middleman.js.map +1 -0
  109. package/lib/src/frameworks/next.d.ts +48 -0
  110. package/lib/src/frameworks/next.js +64 -0
  111. package/lib/src/frameworks/next.js.map +1 -0
  112. package/lib/src/frameworks/nuxt.d.ts +25 -0
  113. package/lib/src/frameworks/nuxt.js +41 -0
  114. package/lib/src/frameworks/nuxt.js.map +1 -0
  115. package/lib/src/frameworks/parcel.d.ts +23 -0
  116. package/lib/src/frameworks/parcel.js +22 -0
  117. package/lib/src/frameworks/parcel.js.map +1 -0
  118. package/lib/src/frameworks/phenomic.d.ts +23 -0
  119. package/lib/src/frameworks/phenomic.js +22 -0
  120. package/lib/src/frameworks/phenomic.js.map +1 -0
  121. package/lib/src/frameworks/quasar.d.ts +25 -0
  122. package/lib/src/frameworks/quasar.js +37 -0
  123. package/lib/src/frameworks/quasar.js.map +1 -0
  124. package/lib/src/frameworks/qwik.d.ts +19 -0
  125. package/lib/src/frameworks/qwik.js +18 -0
  126. package/lib/src/frameworks/qwik.js.map +1 -0
  127. package/lib/src/frameworks/react-static.d.ts +24 -0
  128. package/lib/src/frameworks/react-static.js +23 -0
  129. package/lib/src/frameworks/react-static.js.map +1 -0
  130. package/lib/src/frameworks/react.d.ts +28 -0
  131. package/lib/src/frameworks/react.js +24 -0
  132. package/lib/src/frameworks/react.js.map +1 -0
  133. package/lib/src/frameworks/redwoodjs.d.ts +25 -0
  134. package/lib/src/frameworks/redwoodjs.js +27 -0
  135. package/lib/src/frameworks/redwoodjs.js.map +1 -0
  136. package/lib/src/frameworks/remix.d.ts +20 -0
  137. package/lib/src/frameworks/remix.js +21 -0
  138. package/lib/src/frameworks/remix.js.map +1 -0
  139. package/lib/src/frameworks/roots.d.ts +23 -0
  140. package/lib/src/frameworks/roots.js +22 -0
  141. package/lib/src/frameworks/roots.js.map +1 -0
  142. package/lib/src/frameworks/sapper.d.ts +24 -0
  143. package/lib/src/frameworks/sapper.js +23 -0
  144. package/lib/src/frameworks/sapper.js.map +1 -0
  145. package/lib/src/frameworks/solid-start.d.ts +23 -0
  146. package/lib/src/frameworks/solid-start.js +22 -0
  147. package/lib/src/frameworks/solid-start.js.map +1 -0
  148. package/lib/src/frameworks/solid.d.ts +24 -0
  149. package/lib/src/frameworks/solid.js +23 -0
  150. package/lib/src/frameworks/solid.js.map +1 -0
  151. package/lib/src/frameworks/stencil.d.ts +28 -0
  152. package/lib/src/frameworks/stencil.js +27 -0
  153. package/lib/src/frameworks/stencil.js.map +1 -0
  154. package/lib/src/frameworks/svelte-kit.d.ts +24 -0
  155. package/lib/src/frameworks/svelte-kit.js +23 -0
  156. package/lib/src/frameworks/svelte-kit.js.map +1 -0
  157. package/lib/src/frameworks/svelte.d.ts +25 -0
  158. package/lib/src/frameworks/svelte.js +24 -0
  159. package/lib/src/frameworks/svelte.js.map +1 -0
  160. package/lib/src/frameworks/vite.d.ts +24 -0
  161. package/lib/src/frameworks/vite.js +23 -0
  162. package/lib/src/frameworks/vite.js.map +1 -0
  163. package/lib/src/frameworks/vue.d.ts +23 -0
  164. package/lib/src/frameworks/vue.js +22 -0
  165. package/lib/src/frameworks/vue.js.map +1 -0
  166. package/lib/src/frameworks/vuepress.d.ts +23 -0
  167. package/lib/src/frameworks/vuepress.js +22 -0
  168. package/lib/src/frameworks/vuepress.js.map +1 -0
  169. package/lib/src/frameworks/wintersmith.d.ts +24 -0
  170. package/lib/src/frameworks/wintersmith.js +23 -0
  171. package/lib/src/frameworks/wintersmith.js.map +1 -0
  172. package/lib/src/frameworks/wmr.d.ts +23 -0
  173. package/lib/src/frameworks/wmr.js +22 -0
  174. package/lib/src/frameworks/wmr.js.map +1 -0
  175. package/lib/src/frameworks/zola.d.ts +18 -0
  176. package/lib/src/frameworks/zola.js +17 -0
  177. package/lib/src/frameworks/zola.js.map +1 -0
  178. package/lib/src/get-dev-commands.d.ts +2 -0
  179. package/lib/src/get-dev-commands.js +29 -0
  180. package/lib/src/get-dev-commands.js.map +1 -0
  181. package/lib/src/get-framework.d.ts +4 -0
  182. package/lib/src/get-framework.js +16 -0
  183. package/lib/src/get-framework.js.map +1 -0
  184. package/lib/{index.d.ts → src/index.d.ts} +1 -0
  185. package/lib/src/index.js +4 -0
  186. package/lib/src/index.js.map +1 -0
  187. package/lib/src/metrics.js.map +1 -0
  188. package/lib/{node → src/node}/bin.js +4 -1
  189. package/lib/src/node/bin.js.map +1 -0
  190. package/lib/{node → src/node}/file-system.d.ts +2 -1
  191. package/lib/{node → src/node}/file-system.js +3 -5
  192. package/lib/src/node/file-system.js.map +1 -0
  193. package/lib/{node → src/node}/get-build-info.d.ts +3 -3
  194. package/lib/{node → src/node}/get-build-info.js +16 -18
  195. package/lib/src/node/get-build-info.js.map +1 -0
  196. package/lib/src/node/index.d.ts +2 -0
  197. package/lib/src/node/index.js +3 -0
  198. package/lib/src/node/index.js.map +1 -0
  199. package/lib/src/node/metrics.js.map +1 -0
  200. package/lib/{package-managers → src/package-managers}/detect-package-manager.d.ts +6 -2
  201. package/lib/{package-managers → src/package-managers}/detect-package-manager.js +9 -2
  202. package/lib/src/package-managers/detect-package-manager.js.map +1 -0
  203. package/lib/{project.d.ts → src/project.d.ts} +27 -6
  204. package/lib/src/project.js +248 -0
  205. package/lib/src/project.js.map +1 -0
  206. package/lib/src/settings/get-toml-settings.d.ts +15 -0
  207. package/lib/src/settings/get-toml-settings.js +34 -0
  208. package/lib/src/settings/get-toml-settings.js.map +1 -0
  209. package/lib/{workspaces → src/workspaces}/detect-workspace.d.ts +1 -1
  210. package/lib/{workspaces → src/workspaces}/detect-workspace.js +14 -5
  211. package/lib/src/workspaces/detect-workspace.js.map +1 -0
  212. package/lib/src/workspaces/get-workspace-packages.d.ts +20 -0
  213. package/lib/{workspaces → src/workspaces}/get-workspace-packages.js +19 -5
  214. package/lib/src/workspaces/get-workspace-packages.js.map +1 -0
  215. package/lib/tsconfig.build.tsbuildinfo +1 -0
  216. package/package.json +9 -8
  217. package/lib/browser/file-system.js.map +0 -1
  218. package/lib/build-systems/bazel.js.map +0 -1
  219. package/lib/build-systems/buck.js.map +0 -1
  220. package/lib/build-systems/build-system.d.ts +0 -20
  221. package/lib/build-systems/build-system.js +0 -19
  222. package/lib/build-systems/build-system.js.map +0 -1
  223. package/lib/build-systems/gradle.js.map +0 -1
  224. package/lib/build-systems/index.d.ts +0 -2
  225. package/lib/build-systems/index.js.map +0 -1
  226. package/lib/build-systems/lage.js.map +0 -1
  227. package/lib/build-systems/moon.js.map +0 -1
  228. package/lib/build-systems/nix.js.map +0 -1
  229. package/lib/build-systems/nrwl.d.ts +0 -11
  230. package/lib/build-systems/nrwl.js +0 -12
  231. package/lib/build-systems/nrwl.js.map +0 -1
  232. package/lib/build-systems/pants.js.map +0 -1
  233. package/lib/build-systems/rush.js.map +0 -1
  234. package/lib/build-systems/turbo.js.map +0 -1
  235. package/lib/file-system.js.map +0 -1
  236. package/lib/index.js +0 -3
  237. package/lib/index.js.map +0 -1
  238. package/lib/metrics.js.map +0 -1
  239. package/lib/node/bin.js.map +0 -1
  240. package/lib/node/file-system.js.map +0 -1
  241. package/lib/node/get-build-info.js.map +0 -1
  242. package/lib/node/metrics.js.map +0 -1
  243. package/lib/package-managers/detect-package-manager.js.map +0 -1
  244. package/lib/project.js +0 -97
  245. package/lib/project.js.map +0 -1
  246. package/lib/workspaces/detect-workspace.js.map +0 -1
  247. package/lib/workspaces/get-workspace-packages.d.ts +0 -3
  248. package/lib/workspaces/get-workspace-packages.js.map +0 -1
  249. /package/lib/{build-systems → src/build-systems}/index.js +0 -0
  250. /package/lib/{build-systems → src/build-systems}/lage.d.ts +0 -0
  251. /package/lib/{build-systems → src/build-systems}/lage.js +0 -0
  252. /package/lib/{build-systems → src/build-systems}/rush.d.ts +0 -0
  253. /package/lib/{build-systems → src/build-systems}/rush.js +0 -0
  254. /package/lib/{build-systems → src/build-systems}/turbo.d.ts +0 -0
  255. /package/lib/{build-systems → src/build-systems}/turbo.js +0 -0
  256. /package/lib/{metrics.d.ts → src/metrics.d.ts} +0 -0
  257. /package/lib/{metrics.js → src/metrics.js} +0 -0
  258. /package/lib/{node → src/node}/bin.d.ts +0 -0
  259. /package/lib/{node → src/node}/metrics.d.ts +0 -0
  260. /package/lib/{node → src/node}/metrics.js +0 -0
@@ -1,6 +1,7 @@
1
- import { DirType, FileSystem, findUpOptions } from '../file-system.js';
1
+ import { DirType, Environment, FileSystem, findUpOptions } from '../file-system.js';
2
2
  export declare class NodeFS extends FileSystem {
3
3
  constructor();
4
+ getEnvironment(): Environment;
4
5
  isAbsolute(path: string): boolean;
5
6
  dirname(path: string): string;
6
7
  resolve(...paths: string[]): string;
@@ -7,6 +7,9 @@ export class NodeFS extends FileSystem {
7
7
  super();
8
8
  this.cwd = process.cwd();
9
9
  }
10
+ getEnvironment() {
11
+ return "node" /* Environment.Node */;
12
+ }
10
13
  isAbsolute(path) {
11
14
  return isAbsolute(path);
12
15
  }
@@ -47,11 +50,6 @@ export class NodeFS extends FileSystem {
47
50
  }
48
51
  }
49
52
  async readFile(path) {
50
- const storedFile = this.getFile(path);
51
- // no need to read again (just use the already stored file)
52
- if (storedFile?.type === 'text') {
53
- return storedFile.content;
54
- }
55
53
  return (await fs.readFile(resolve(path), 'utf-8')).toString();
56
54
  }
57
55
  /** Node implementation of finding a file or directory by walking up parent directories. */
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-system.js","sourceRoot":"","sources":["../../../src/node/file-system.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,IAAI,CAAA;AACnC,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AAE7E,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAEhD,OAAO,EAAwB,UAAU,EAAiB,MAAM,mBAAmB,CAA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C,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC,CAAA;SAC7G;QAAC,MAAM;YACN,OAAO,EAAE,CAAA;SACV;IACH,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,IAAY;QACzB,OAAO,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAA;IAC/D,CAAC;IAED,2FAA2F;IAC3F,MAAM,CAAC,IAAgC,EAAE,UAAyB,EAAE;QAClE,OAAO,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,CAAA;IAC9B,CAAC;IAED,4FAA4F;IAC5F,cAAc,CAAC,IAAgC,EAAE,UAAyB,EAAE;QAC1E,OAAO,cAAc,CAAC,IAAI,EAAE,OAAO,CAAC,CAAA;IACtC,CAAC;CACF"}
@@ -2,10 +2,10 @@ import { Logger } from '../file-system.js';
2
2
  import { PkgManagerFields } from '../package-managers/detect-package-manager.js';
3
3
  import { WorkspaceInfo } from '../workspaces/detect-workspace.js';
4
4
  export type Info = {
5
- jsWorkspaces?: WorkspaceInfo;
6
- packageManager?: PkgManagerFields;
5
+ jsWorkspaces: WorkspaceInfo | null;
6
+ packageManager: PkgManagerFields | null;
7
7
  frameworks: unknown[];
8
- buildSystems?: {
8
+ buildSystems: {
9
9
  name: string;
10
10
  version?: string | undefined;
11
11
  }[];
@@ -25,27 +25,25 @@ export async function getBuildInfo(config = { featureFlags: {} }) {
25
25
  const fs = new NodeFS();
26
26
  // prevent logging in output as we use the stdout to capture the json
27
27
  fs.logger = new NoopLogger();
28
- const project = new Project(fs, config.projectDir, config.rootDir);
29
- project.setEnvironment(process.env);
30
- let frameworks = [];
31
- try {
32
- // if the framework detection is crashing we should not crash the build info and package-manager detection
33
- frameworks = await listFrameworks({ projectDir: project.baseDirectory });
34
- }
35
- catch (error) {
36
- report(error);
37
- }
28
+ const project = new Project(fs, config.projectDir, config.rootDir)
29
+ .setEnvironment(process.env)
30
+ .setNodeVersion(process.version);
38
31
  const info = {
39
- frameworks,
32
+ packageManager: await project.detectPackageManager(),
33
+ jsWorkspaces: await project.detectWorkspaces(),
34
+ frameworks: [],
40
35
  buildSystems: await project.detectBuildSystem(),
41
36
  };
42
- const pkgJSONPath = await project.getPackageJSON();
43
- // only if we find a root package.json we know this is a javascript workspace
44
- if (Object.keys(pkgJSONPath).length) {
45
- info.packageManager = await project.detectPackageManager();
46
- const workspaceInfo = await project.detectWorkspaces();
47
- if (workspaceInfo) {
48
- info.jsWorkspaces = workspaceInfo;
37
+ if (config.featureFlags?.build_info_new_framework_detection) {
38
+ info.frameworks = (await project.detectFrameworksInPath(project.baseDirectory)) || [];
39
+ }
40
+ else {
41
+ try {
42
+ // if the framework detection is crashing we should not crash the build info and package-manager detection
43
+ info.frameworks = await listFrameworks({ projectDir: project.baseDirectory });
44
+ }
45
+ catch (error) {
46
+ report(error);
49
47
  }
50
48
  }
51
49
  return info;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-build-info.js","sourceRoot":"","sources":["../../../src/node/get-build-info.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAGxD,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAEtC,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAGvC,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AAYzC,qGAAqG;AACrG,MAAM,OAAO,UAAU;IACrB,KAAK;QACH,WAAW;IACb,CAAC;IACD,GAAG;QACD,WAAW;IACb,CAAC;IACD,KAAK;QACH,WAAW;IACb,CAAC;IACD,IAAI;QACF,WAAW;IACb,CAAC;IACD,IAAI;QACF,WAAW;IACb,CAAC;CACF;AAED,6DAA6D;AAC7D,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,SAII,EAAE,YAAY,EAAE,EAAE,EAAE;IAExB,MAAM,EAAE,GAAG,IAAI,MAAM,EAAE,CAAA;IACvB,qEAAqE;IACrE,EAAE,CAAC,MAAM,GAAG,IAAI,UAAU,EAAE,CAAA;IAC5B,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,EAAE,EAAE,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,OAAO,CAAC;SAC/D,cAAc,CAAC,OAAO,CAAC,GAAG,CAAC;SAC3B,cAAc,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;IAElC,MAAM,IAAI,GAAS;QACjB,cAAc,EAAE,MAAM,OAAO,CAAC,oBAAoB,EAAE;QACpD,YAAY,EAAE,MAAM,OAAO,CAAC,gBAAgB,EAAE;QAC9C,UAAU,EAAE,EAAE;QACd,YAAY,EAAE,MAAM,OAAO,CAAC,iBAAiB,EAAE;KAChD,CAAA;IAED,IAAI,MAAM,CAAC,YAAY,EAAE,kCAAkC,EAAE;QAC3D,IAAI,CAAC,UAAU,GAAG,CAAC,MAAM,OAAO,CAAC,sBAAsB,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,IAAI,EAAE,CAAA;KACtF;SAAM;QACL,IAAI;YACF,2GAA2G;YAC3G,IAAI,CAAC,UAAU,GAAG,MAAM,cAAc,CAAC,EAAE,UAAU,EAAE,OAAO,CAAC,aAAa,EAAE,CAAC,CAAA;SAC9E;QAAC,OAAO,KAAK,EAAE;YACd,MAAM,CAAC,KAAK,CAAC,CAAA;SACd;KACF;IAED,OAAO,IAAI,CAAA;AACb,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from './file-system.js';
2
+ export * from './get-build-info.js';
@@ -0,0 +1,3 @@
1
+ export * from './file-system.js';
2
+ export * from './get-build-info.js';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/node/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAA;AAChC,cAAc,qBAAqB,CAAA"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"metrics.js","sourceRoot":"","sources":["../../../src/node/metrics.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAEtC,OAAO,OAAO,MAAM,aAAa,CAAA;AAEjC,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAEhD,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,OAAO,CAAA;AACpC,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,oBAAoB,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AAE9D,MAAM,CAAC,KAAK,UAAU,iBAAiB;IACrC,IAAI;QACF,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAA;QAChE,OAAO,CAAC,KAAK,CAAC;YACZ,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,sBAAsB,IAAI,EAAE;YAChD,UAAU,EAAE,OAAO;YACnB,YAAY,EAAE,YAAY;YAC1B,oBAAoB,EAAE,CAAC,YAAY,CAAC;YACpC,QAAQ,EAAE,EAAE;YACZ,MAAM,EAAE,IAAI,UAAU,EAAE;SACzB,CAAC,CAAA;KACH;IAAC,MAAM;QACN,kCAAkC;KACnC;AACH,CAAC"}
@@ -9,19 +9,23 @@ export type PkgManagerFields = {
9
9
  name: PkgManager;
10
10
  /** The package managers install command */
11
11
  installCommand: string;
12
+ /** The package managers run command prefix */
13
+ runCommand: string;
12
14
  /** The lock file a package manager is using */
13
15
  lockFile: string;
14
16
  /** Environment variable that can be used to force the usage of a package manager even though there is no lock file or a different lock file */
15
17
  forceEnvironment?: string;
16
- /** Flags that should be used for running the install command */
18
+ /** Flags that should be used for running the installation command */
17
19
  installFlags?: string[];
18
20
  /** A list of all cache locations for the package manager */
19
21
  cacheLocations?: string[];
20
22
  };
23
+ /** The definition of all available package managers */
24
+ export declare const AVAILABLE_PACKAGE_MANAGERS: Record<PkgManager, PkgManagerFields>;
21
25
  /**
22
26
  * Detects the used package manager based on
23
27
  * 1. packageManager field
24
28
  * 2. environment variable that forces the usage
25
29
  * 3. a lock file that is present in this directory or up in the tree for workspaces
26
30
  */
27
- export declare const detectPackageManager: (project: Project) => Promise<PkgManagerFields>;
31
+ export declare const detectPackageManager: (project: Project) => Promise<PkgManagerFields | null>;
@@ -1,20 +1,23 @@
1
1
  /** The definition of all available package managers */
2
- const AVAILABLE_PACKAGE_MANAGERS = {
2
+ export const AVAILABLE_PACKAGE_MANAGERS = {
3
3
  ["yarn" /* PkgManager.YARN */]: {
4
4
  name: "yarn" /* PkgManager.YARN */,
5
5
  installCommand: 'yarn install',
6
+ runCommand: 'yarn run',
6
7
  lockFile: 'yarn.lock',
7
8
  forceEnvironment: 'NETLIFY_USE_YARN',
8
9
  },
9
10
  ["pnpm" /* PkgManager.PNPM */]: {
10
11
  name: "pnpm" /* PkgManager.PNPM */,
11
12
  installCommand: 'pnpm install',
13
+ runCommand: 'pnpm run',
12
14
  lockFile: 'pnpm-lock.yaml',
13
15
  forceEnvironment: 'NETLIFY_USE_PNPM',
14
16
  },
15
17
  ["npm" /* PkgManager.NPM */]: {
16
18
  name: "npm" /* PkgManager.NPM */,
17
19
  installCommand: 'npm install',
20
+ runCommand: 'npm run',
18
21
  lockFile: 'package-lock.json',
19
22
  },
20
23
  };
@@ -35,6 +38,10 @@ export const detectPackageManager = async (project) => {
35
38
  cwd: project.baseDirectory,
36
39
  stopAt: project.root,
37
40
  });
41
+ // if there is no package json than there is no package manager to detect
42
+ if (!pkgPaths.length) {
43
+ return null;
44
+ }
38
45
  for (const pkgPath of pkgPaths) {
39
46
  const { packageManager } = await project.fs.readJSON(pkgPath);
40
47
  if (packageManager) {
@@ -60,7 +67,7 @@ export const detectPackageManager = async (project) => {
60
67
  if (lockFilePath) {
61
68
  const lockFile = project.fs.basename(lockFilePath);
62
69
  const pkgManager = lockFileMap[lockFile];
63
- // check if it not got disabled
70
+ // check if it is not got disabled
64
71
  if (!(pkgManager.forceEnvironment && project.getEnv(pkgManager.forceEnvironment) === 'false')) {
65
72
  return pkgManager;
66
73
  }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"detect-package-manager.js","sourceRoot":"","sources":["../../../src/package-managers/detect-package-manager.ts"],"names":[],"mappings":"AA0BA,uDAAuD;AACvD,MAAM,CAAC,MAAM,0BAA0B,GAAyC;IAC9E,8BAAiB,EAAE;QACjB,IAAI,8BAAiB;QACrB,cAAc,EAAE,cAAc;QAC9B,UAAU,EAAE,UAAU;QACtB,QAAQ,EAAE,WAAW;QACrB,gBAAgB,EAAE,kBAAkB;KACrC;IACD,8BAAiB,EAAE;QACjB,IAAI,8BAAiB;QACrB,cAAc,EAAE,cAAc;QAC9B,UAAU,EAAE,UAAU;QACtB,QAAQ,EAAE,gBAAgB;QAC1B,gBAAgB,EAAE,kBAAkB;KACrC;IACD,4BAAgB,EAAE;QAChB,IAAI,4BAAgB;QACpB,cAAc,EAAE,aAAa;QAC7B,UAAU,EAAE,SAAS;QACrB,QAAQ,EAAE,mBAAmB;KAC9B;CACF,CAAA;AAED;;;GAGG;AACH,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,CAAC,0BAA0B,CAAC,CAAC,MAAM,CAClE,CAAC,GAAG,EAAE,UAAU,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,GAAG,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,UAAU,EAAE,CAAC,EACpE,EAAsC,CACvC,CAAA;AAED;;;;;GAKG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,KAAK,EAAE,OAAgB,EAAoC,EAAE;IAC/F,IAAI;QACF,MAAM,QAAQ,GAAG,MAAM,OAAO,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,IAAI,CAAC,CAAC,UAAU,CAAC,gBAAgB,IAAI,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,gBAAgB,CAAC,KAAK,OAAO,CAAC,EAAE;gBAC7F,OAAO,UAAU,CAAA;aAClB;SACF;KACF;IAAC,OAAO,KAAK,EAAE;QACd,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;KACtB;IACD,wBAAwB;IACxB,2DAA2D;IAC3D,OAAO,0BAA0B,4BAAgB,CAAA;AACnD,CAAC,CAAA"}
@@ -1,8 +1,11 @@
1
1
  import type { NotifiableError } from '@bugsnag/js';
2
2
  import type { PackageJson } from 'read-pkg';
3
+ import { SemVer } from 'semver';
3
4
  import type { BuildSystem } from './build-systems/build-system.js';
4
- import type { FileSystem } from './file-system.js';
5
- import type { PkgManagerFields } from './package-managers/detect-package-manager.js';
5
+ import { FileSystem } from './file-system.js';
6
+ import { DetectedFramework } from './frameworks/framework.js';
7
+ import { PkgManagerFields } from './package-managers/detect-package-manager.js';
8
+ import { WorkspaceInfo } from './workspaces/detect-workspace.js';
6
9
  /**
7
10
  * The Project represents a Site in Netlify
8
11
  * The only configuration here needed is the path to the repository root and the optional baseDirectory
@@ -14,9 +17,19 @@ export declare class Project {
14
17
  root?: string;
15
18
  /** An absolute path */
16
19
  baseDirectory: string;
17
- packageManager: PkgManagerFields;
20
+ /** the detected package manager (if null it's not a javascript project, undefined indicates that id did not run yet) */
21
+ packageManager: PkgManagerFields | null;
18
22
  /** an absolute path of the root directory for js workspaces where the most top package.json is located */
19
23
  jsWorkspaceRoot: string;
24
+ workspace: WorkspaceInfo | null;
25
+ /** The detected build-systems */
26
+ buildSystems: BuildSystem[];
27
+ /** The detected frameworks for each path in a project */
28
+ frameworks: Map<string, DetectedFramework[]>;
29
+ /** The current nodeVersion (can be set by node.js environments) */
30
+ private _nodeVersion;
31
+ setNodeVersion(version: string): this;
32
+ getCurrentNodeVersion(): Promise<SemVer | null>;
20
33
  constructor(fs: FileSystem, baseDirectory?: string, root?: string);
21
34
  /** Set's the environment for the project */
22
35
  setEnvironment(env: Record<string, string | undefined>): this;
@@ -24,13 +37,21 @@ export declare class Project {
24
37
  getEnv(key: string): string | undefined;
25
38
  /** Reports an error with additional metadata */
26
39
  report(error: NotifiableError): void;
40
+ /** Retrieve the run command for an npm script */
41
+ getNpmScriptCommand(npmScript: string): string;
27
42
  /** retrieves the root package.json file */
28
43
  getRootPackageJSON(): Promise<PackageJson>;
29
- getPackageJSON(startDirectory?: string): Promise<PackageJson>;
44
+ /** Retrieves the package.json and if one found with it's pkgPath */
45
+ getPackageJSON(startDirectory?: string): Promise<PackageJson & {
46
+ pkgPath: string | null;
47
+ }>;
30
48
  /** Detects the used package Manager */
31
- detectPackageManager(): Promise<PkgManagerFields>;
49
+ detectPackageManager(): Promise<PkgManagerFields | null>;
32
50
  /** Detects the javascript workspace settings */
33
- detectWorkspaces(): Promise<import("./workspaces/detect-workspace.js").WorkspaceInfo | undefined>;
51
+ detectWorkspaces(): Promise<WorkspaceInfo | null>;
34
52
  /** Detects all used build systems */
35
53
  detectBuildSystem(): Promise<BuildSystem[]>;
54
+ /** Detects all used build systems */
55
+ detectFrameworks(): Promise<DetectedFramework[] | null>;
56
+ detectFrameworksInPath(path?: string): Promise<DetectedFramework[]>;
36
57
  }
@@ -0,0 +1,248 @@
1
+ import { coerce, parse } from 'semver';
2
+ import { buildSystems } from './build-systems/index.js';
3
+ import { filterByRelevance } from './frameworks/framework.js';
4
+ import { frameworks } from './frameworks/index.js';
5
+ import { report } from './metrics.js';
6
+ import { AVAILABLE_PACKAGE_MANAGERS, detectPackageManager, } from './package-managers/detect-package-manager.js';
7
+ import { detectWorkspaces } from './workspaces/detect-workspace.js';
8
+ /**
9
+ * The Project represents a Site in Netlify
10
+ * The only configuration here needed is the path to the repository root and the optional baseDirectory
11
+ */
12
+ export class Project {
13
+ fs;
14
+ /** An optional repository root that tells us where to stop looking up */
15
+ root;
16
+ /** An absolute path */
17
+ baseDirectory;
18
+ /** the detected package manager (if null it's not a javascript project, undefined indicates that id did not run yet) */
19
+ packageManager;
20
+ /** an absolute path of the root directory for js workspaces where the most top package.json is located */
21
+ jsWorkspaceRoot;
22
+ /* the detected javascript workspace information (if null it's not a workspace, undefined indicates that id did not run yet) */
23
+ workspace;
24
+ /** The detected build-systems */
25
+ buildSystems;
26
+ /** The detected frameworks for each path in a project */
27
+ frameworks;
28
+ /** a representation of the current environment */
29
+ #environment = {};
30
+ /** The current nodeVersion (can be set by node.js environments) */
31
+ _nodeVersion = null;
32
+ setNodeVersion(version) {
33
+ this._nodeVersion = parse(version);
34
+ return this;
35
+ }
36
+ async getCurrentNodeVersion() {
37
+ if (this._nodeVersion) {
38
+ return this._nodeVersion;
39
+ }
40
+ const nodeEnv = parse(coerce(this.getEnv('NODE_VERSION')), { loose: true });
41
+ if (nodeEnv) {
42
+ return nodeEnv;
43
+ }
44
+ const nvmrc = await this.fs.gracefullyReadFile('.nvmrc');
45
+ if (nvmrc) {
46
+ return parse(coerce(nvmrc, { loose: true }));
47
+ }
48
+ const nodeVersion = await this.fs.gracefullyReadFile('.node_version');
49
+ if (nodeVersion) {
50
+ return parse(coerce(nodeVersion, { loose: true }));
51
+ }
52
+ // TODO: think of returning a default node version
53
+ return null;
54
+ }
55
+ constructor(fs, baseDirectory, root) {
56
+ this.fs = fs;
57
+ this.baseDirectory = fs.resolve(root || '', baseDirectory !== undefined ? baseDirectory : fs.cwd);
58
+ this.root = root ? fs.resolve(fs.cwd, root) : undefined;
59
+ // if the root and the base directory are the same unset the root again as it's not a workspace
60
+ if (this.root === this.baseDirectory) {
61
+ this.root = undefined;
62
+ }
63
+ this.fs.cwd = this.baseDirectory;
64
+ }
65
+ /** Set's the environment for the project */
66
+ setEnvironment(env) {
67
+ this.#environment = env;
68
+ return this;
69
+ }
70
+ /** retrieves an environment variable */
71
+ getEnv(key) {
72
+ return this.#environment[key];
73
+ }
74
+ /** Reports an error with additional metadata */
75
+ report(error) {
76
+ report(error, {
77
+ metadata: {
78
+ build: {
79
+ baseDirectory: this.baseDirectory,
80
+ root: this.root,
81
+ },
82
+ },
83
+ });
84
+ }
85
+ /** Retrieve the run command for an npm script */
86
+ getNpmScriptCommand(npmScript) {
87
+ const runCmd = this.packageManager?.runCommand || AVAILABLE_PACKAGE_MANAGERS.npm.runCommand;
88
+ return `${runCmd} ${npmScript}`;
89
+ }
90
+ /** retrieves the root package.json file */
91
+ async getRootPackageJSON() {
92
+ // get the most upper json file
93
+ const rootJSONPath = (await this.fs.findUpMultiple('package.json', { cwd: this.baseDirectory, stopAt: this.root })).pop();
94
+ if (rootJSONPath) {
95
+ this.jsWorkspaceRoot = this.fs.dirname(rootJSONPath);
96
+ return this.fs.readJSON(rootJSONPath);
97
+ }
98
+ return {};
99
+ }
100
+ /** Retrieves the package.json and if one found with it's pkgPath */
101
+ async getPackageJSON(startDirectory) {
102
+ const pkgPath = await this.fs.findUp('package.json', {
103
+ cwd: startDirectory || this.baseDirectory,
104
+ stopAt: this.root,
105
+ });
106
+ if (pkgPath) {
107
+ const json = await this.fs.readJSON(pkgPath);
108
+ return {
109
+ ...json,
110
+ pkgPath,
111
+ };
112
+ }
113
+ return { pkgPath: null };
114
+ }
115
+ /** Detects the used package Manager */
116
+ async detectPackageManager() {
117
+ // if the packageManager is undefined, the detection was not run.
118
+ // if it is an object or null it has already run
119
+ if (this.packageManager !== undefined) {
120
+ return this.packageManager;
121
+ }
122
+ try {
123
+ this.packageManager = await detectPackageManager(this);
124
+ return this.packageManager;
125
+ }
126
+ catch {
127
+ return null;
128
+ }
129
+ }
130
+ /** Detects the javascript workspace settings */
131
+ async detectWorkspaces() {
132
+ // if the workspace is undefined, the detection was not run.
133
+ // if it is an object or null it has already run
134
+ if (this.workspace !== undefined) {
135
+ return this.workspace;
136
+ }
137
+ // workspaces depend on package manager detection so run it first
138
+ await this.detectPackageManager();
139
+ try {
140
+ this.workspace = await detectWorkspaces(this);
141
+ return this.workspace;
142
+ }
143
+ catch (error) {
144
+ this.report(error);
145
+ return null;
146
+ }
147
+ }
148
+ /** Detects all used build systems */
149
+ async detectBuildSystem() {
150
+ // if the workspace is undefined, the detection was not run.
151
+ if (this.buildSystems !== undefined) {
152
+ return this.buildSystems;
153
+ }
154
+ // build systems depends on workspaces detection
155
+ await this.detectWorkspaces();
156
+ try {
157
+ // on node we can parallelize more
158
+ if (this.fs.getEnvironment() === "node" /* Environment.Node */) {
159
+ const detected = (await Promise.all(buildSystems.map((BuildSystem) => new BuildSystem(this).detect()))).filter(Boolean);
160
+ this.buildSystems = detected;
161
+ }
162
+ else {
163
+ // In the browser perform the detection in series to avoid having the same HTTP request in parallel.
164
+ // It's faster to perform one detection, do all the needed HTTP requests and reuse the results
165
+ // on consecutive runs.
166
+ const detected = [];
167
+ for (const BuildSystem of buildSystems) {
168
+ const res = await new BuildSystem(this).detect();
169
+ if (res) {
170
+ detected.push(res);
171
+ }
172
+ }
173
+ this.buildSystems = detected;
174
+ }
175
+ return this.buildSystems;
176
+ }
177
+ catch (error) {
178
+ this.report(error);
179
+ return [];
180
+ }
181
+ }
182
+ /** Detects all used build systems */
183
+ async detectFrameworks() {
184
+ // if the workspace is undefined, the detection was not run.
185
+ if (this.frameworks !== undefined) {
186
+ return [...this.frameworks.values()].flat();
187
+ }
188
+ try {
189
+ // This needs to be run first
190
+ await this.detectBuildSystem();
191
+ this.frameworks = new Map();
192
+ if (this.workspace?.isRoot) {
193
+ for (const pkg of this.workspace.packages) {
194
+ this.frameworks.set(pkg, await this.detectFrameworksInPath(this.fs.join(this.workspace.rootDir, pkg)));
195
+ }
196
+ }
197
+ else {
198
+ // per default set on ''
199
+ let root = '';
200
+ // if the framework detection was run inside a baseDirectory of a workspace
201
+ // we still want to store the result in the correct package key of the frameworks map
202
+ if (this.workspace) {
203
+ const relBaseDirectory = this.fs.relative(this.workspace.rootDir, this.baseDirectory);
204
+ if (this.workspace.packages.includes(relBaseDirectory)) {
205
+ root = relBaseDirectory;
206
+ }
207
+ }
208
+ this.frameworks.set(root, await this.detectFrameworksInPath());
209
+ }
210
+ return [...this.frameworks.values()].flat();
211
+ }
212
+ catch (error) {
213
+ this.report(error);
214
+ return null;
215
+ }
216
+ }
217
+ async detectFrameworksInPath(path) {
218
+ try {
219
+ let detected = [];
220
+ // on node we can parallelize more
221
+ if (this.fs.getEnvironment() === "node" /* Environment.Node */) {
222
+ detected = (await Promise.all(frameworks.map((Framework) => new Framework(this, path).detect()))).filter(Boolean);
223
+ }
224
+ else {
225
+ // In the browser perform the detection in series to avoid having the same HTTP request in parallel.
226
+ // It's faster to perform one detection, do all the needed HTTP requests and reuse the results
227
+ // on consecutive runs.
228
+ for (const Framework of frameworks) {
229
+ const res = await new Framework(this, path).detect();
230
+ if (res) {
231
+ detected.push(res);
232
+ }
233
+ }
234
+ }
235
+ // sort based on the accuracy and drop un accurate results if something more accurate was found
236
+ // from most accurate to least accurate
237
+ // 1. a npm dependency was specified and matched
238
+ // 2. only a config file was specified and matched
239
+ // 3. an npm dependency was specified but matched over the config file (least accurate)
240
+ // and prefer SSG over build tools
241
+ return filterByRelevance(detected);
242
+ }
243
+ catch {
244
+ return [];
245
+ }
246
+ }
247
+ }
248
+ //# sourceMappingURL=project.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"project.js","sourceRoot":"","sources":["../../src/project.ts"],"names":[],"mappings":"AAEA,OAAO,EAAU,MAAM,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAA;AAG9C,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAEvD,OAAO,EAAqB,iBAAiB,EAAE,MAAM,2BAA2B,CAAA;AAChF,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AACrC,OAAO,EACL,0BAA0B,EAE1B,oBAAoB,GACrB,MAAM,8CAA8C,CAAA;AACrD,OAAO,EAAiB,gBAAgB,EAAE,MAAM,kCAAkC,CAAA;AAClF;;;GAGG;AACH,MA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AAO,iBAAiB,CAAC,QAAQ,CAAC,CAAA;SACnC;QAAC,MAAM;YACN,OAAO,EAAE,CAAA;SACV;IACH,CAAC;CACF"}
@@ -0,0 +1,15 @@
1
+ import { FileSystem } from '../file-system.js';
2
+ export type BuildSettings = {
3
+ cmd: string;
4
+ dir: string;
5
+ framework: string;
6
+ frameworkName: string;
7
+ functions_dir?: string;
8
+ plugins: {
9
+ package: string;
10
+ }[];
11
+ plugins_installed?: undefined;
12
+ plugins_recommended: string[];
13
+ template?: string;
14
+ };
15
+ export declare function getNetlifyTomlSettings(fs: FileSystem, directory: string): Promise<{} | undefined>;
@@ -0,0 +1,34 @@
1
+ import Bugsnag from '@bugsnag/js';
2
+ import { parse } from 'toml';
3
+ const { default: { notify }, } = Bugsnag;
4
+ /** Gracefully parses a toml file and reports errors to bugsnag */
5
+ function gracefulParseToml(content) {
6
+ try {
7
+ return parse(content);
8
+ }
9
+ catch (error) {
10
+ notify(error, (event) => {
11
+ event.context = '@netlify/build-info => gracefullyParseToml => toml.parse';
12
+ event.severity = 'info';
13
+ });
14
+ return {};
15
+ }
16
+ }
17
+ export async function getNetlifyTomlSettings(fs, directory) {
18
+ const tomlFilePath = fs.join(directory, 'netlify.toml');
19
+ try {
20
+ const settings = {};
21
+ const { build, functions, template } = gracefulParseToml(await fs.readFile(tomlFilePath));
22
+ if (build) {
23
+ settings.cmd = build?.command;
24
+ settings.dir = build.publish;
25
+ }
26
+ settings.functions_dir = build?.functions || functions?.directory;
27
+ settings.template = template;
28
+ }
29
+ catch {
30
+ // no toml found
31
+ return {};
32
+ }
33
+ }
34
+ //# sourceMappingURL=get-toml-settings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-toml-settings.js","sourceRoot":"","sources":["../../../src/settings/get-toml-settings.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,aAAa,CAAA;AACjC,OAAO,EAAE,KAAK,EAAE,MAAM,MAAM,CAAA;AAI5B,MAAM,EACJ,OAAO,EAAE,EAAE,MAAM,EAAE,GACpB,GAAG,OAAO,CAAA;AAcX,kEAAkE;AAClE,SAAS,iBAAiB,CAAI,OAAe;IAC3C,IAAI;QACF,OAAO,KAAK,CAAC,OAAO,CAAC,CAAA;KACtB;IAAC,OAAO,KAAK,EAAE;QACd,MAAM,CAAC,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE;YACtB,KAAK,CAAC,OAAO,GAAG,0DAA0D,CAAA;YAC1E,KAAK,CAAC,QAAQ,GAAG,MAAM,CAAA;QACzB,CAAC,CAAC,CAAA;QACF,OAAO,EAAO,CAAA;KACf;AACH,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAAC,EAAc,EAAE,SAAiB;IAC5E,MAAM,YAAY,GAAG,EAAE,CAAC,IAAI,CAAC,SAAS,EAAE,cAAc,CAAC,CAAA;IAEvD,IAAI;QACF,MAAM,QAAQ,GAA2B,EAAE,CAAA;QAC3C,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,iBAAiB,CAAM,MAAM,EAAE,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC,CAAA;QAE9F,IAAI,KAAK,EAAE;YACT,QAAQ,CAAC,GAAG,GAAG,KAAK,EAAE,OAAO,CAAA;YAC7B,QAAQ,CAAC,GAAG,GAAG,KAAK,CAAC,OAAO,CAAA;SAC7B;QAED,QAAQ,CAAC,aAAa,GAAG,KAAK,EAAE,SAAS,IAAI,SAAS,EAAE,SAAS,CAAA;QACjE,QAAQ,CAAC,QAAQ,GAAG,QAAQ,CAAA;KAC7B;IAAC,MAAM;QACN,gBAAgB;QAChB,OAAO,EAAE,CAAA;KACV;AACH,CAAC"}
@@ -19,4 +19,4 @@ export declare function detectNpmOrYarnWorkspaceGlobs(pkgJSON: PackageJson): Pro
19
19
  * If it's a javascript workspace (npm, pnpm, yarn) it will retrieve a list of all
20
20
  * package paths and will indicate if it's the root of the workspace
21
21
  */
22
- export declare function detectWorkspaces(project: Project): Promise<WorkspaceInfo | undefined>;
22
+ export declare function detectWorkspaces(project: Project): Promise<WorkspaceInfo | null>;
@@ -12,8 +12,13 @@ export async function detectPnpmWorkspaceGlobs(project) {
12
12
  if (!workspaceFile) {
13
13
  return [];
14
14
  }
15
- const { packages } = parse(await project.fs.readFile(workspaceFile));
16
- return packages;
15
+ try {
16
+ const { packages } = parse(await project.fs.readFile(workspaceFile));
17
+ return packages;
18
+ }
19
+ catch {
20
+ return [];
21
+ }
17
22
  }
18
23
  /** Get the workspace globs from the package.json file */
19
24
  export async function detectNpmOrYarnWorkspaceGlobs(pkgJSON) {
@@ -30,15 +35,19 @@ export async function detectNpmOrYarnWorkspaceGlobs(pkgJSON) {
30
35
  * package paths and will indicate if it's the root of the workspace
31
36
  */
32
37
  export async function detectWorkspaces(project) {
33
- if (!project.packageManager) {
38
+ if (project.packageManager === undefined) {
34
39
  throw new Error('Please run the packageManager detection before calling the workspace detection!');
35
40
  }
41
+ // if it's null it indicates it was already run without any result so we can omit this here as well
42
+ if (project.packageManager === null) {
43
+ return null;
44
+ }
36
45
  const pkgJSON = await project.getRootPackageJSON();
37
46
  const workspaceGlobs = project.packageManager.name === "pnpm" /* PkgManager.PNPM */
38
47
  ? await detectPnpmWorkspaceGlobs(project)
39
48
  : await detectNpmOrYarnWorkspaceGlobs(pkgJSON);
40
49
  if (workspaceGlobs.length === 0) {
41
- return;
50
+ return null;
42
51
  }
43
52
  const packages = await getWorkspacePackages(project, workspaceGlobs);
44
53
  const isRoot = project.baseDirectory === project.jsWorkspaceRoot;
@@ -46,7 +55,7 @@ export async function detectWorkspaces(project) {
46
55
  // if the current base directory is not part of the detected workspace packages it's not part of this workspace
47
56
  // and therefore return no workspace info
48
57
  if (!isRoot && !packages.includes(relBaseDirectory)) {
49
- return;
58
+ return null;
50
59
  }
51
60
  return {
52
61
  rootDir: project.jsWorkspaceRoot,
@@ -0,0 +1 @@
1
+ {"version":3,"file":"detect-workspace.js","sourceRoot":"","sources":["../../../src/workspaces/detect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