@adobe/helix-admin-support 2.0.0 → 2.0.2

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.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,17 @@
1
+ ## [2.0.2](https://github.com/adobe/helix-admin-support/compare/v2.0.1...v2.0.2) (2023-04-04)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * validate owner/repo/ref ([#132](https://github.com/adobe/helix-admin-support/issues/132)) ([266a624](https://github.com/adobe/helix-admin-support/commit/266a6240ff1434bf9350c3ca72700297d88e15a8))
7
+
8
+ ## [2.0.1](https://github.com/adobe/helix-admin-support/compare/v2.0.0...v2.0.1) (2023-04-04)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * regression - load fstab from github ([#131](https://github.com/adobe/helix-admin-support/issues/131)) ([389a0be](https://github.com/adobe/helix-admin-support/commit/389a0bef218ae299c3dd83fd30f190ab9cce64fe))
14
+
1
15
  # [2.0.0](https://github.com/adobe/helix-admin-support/compare/v1.6.37...v2.0.0) (2023-04-03)
2
16
 
3
17
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/helix-admin-support",
3
- "version": "2.0.0",
3
+ "version": "2.0.2",
4
4
  "description": "Helix Admin Support Library",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -12,6 +12,7 @@
12
12
  import { logLevelForStatusCode, propagateStatusCode } from '@adobe/helix-shared-utils';
13
13
  import { MountConfig } from '@adobe/helix-shared-config';
14
14
  import { fetchS3 } from './fetch-s3.js';
15
+ import { fetch } from './utils.js';
15
16
 
16
17
  /**
17
18
  * Checks if the response is valid and returns a mount config.
@@ -56,9 +57,24 @@ export async function fetchFstab(ctx, opts, optional) {
56
57
  return null;
57
58
  }
58
59
 
59
- const key = `${owner}/${repo}/main/fstab.yaml`;
60
- const response = await fetchS3(ctx, 'helix-code-bus', key);
61
- return handleResponse(log, response, key, 'code-bus');
60
+ let key = `${owner}/${repo}/main/fstab.yaml`;
61
+ let response = await fetchS3(ctx, 'helix-code-bus', key);
62
+ const cfg = await handleResponse(log, response, key, 'code-bus');
63
+ if (cfg) {
64
+ return cfg;
65
+ }
66
+
67
+ // try loading from github for non helix-3 repos
68
+ const headers = {};
69
+ key = `${owner}/${repo}/main/fstab.yaml`;
70
+ if (ctx.githubToken) {
71
+ headers.authorization = `token ${ctx.githubToken}`;
72
+ }
73
+ response = await fetch(`https://raw.githubusercontent.com/${key}`, {
74
+ cache: 'no-store',
75
+ headers,
76
+ });
77
+ return handleResponse(log, response, key, 'github');
62
78
  };
63
79
 
64
80
  if (!('mountConfig' in attributes)) {
@@ -57,9 +57,13 @@ export async function fetchHelixConfig(ctx, info, optional) {
57
57
  const { owner, repo, ref } = info;
58
58
 
59
59
  if (!('helixConfig' in attributes)) {
60
- const key = `${owner}/${repo}/${ref}/helix-config.json`;
61
- const response = await fetchS3(ctx, 'helix-code-bus', key);
62
- attributes.helixConfig = await handleResponse(log, response, key, 'code-bus');
60
+ if (owner && repo && ref) {
61
+ const key = `${owner}/${repo}/${ref}/helix-config.json`;
62
+ const response = await fetchS3(ctx, 'helix-code-bus', key);
63
+ attributes.helixConfig = await handleResponse(log, response, key, 'code-bus');
64
+ } else {
65
+ attributes.helixConfig = null;
66
+ }
63
67
  }
64
68
 
65
69
  if (attributes.helixConfig || optional) {