@forge/manifest 10.0.1-next.7 → 10.1.0-next.8

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,5 +1,11 @@
1
1
  # @forge/manifest
2
2
 
3
+ ## 10.1.0-next.8
4
+
5
+ ### Minor Changes
6
+
7
+ - 46daa27: Added support for default environment variable declaration in the manifest
8
+
3
9
  ## 10.0.1-next.7
4
10
 
5
11
  ### Patch Changes
@@ -1 +1 @@
1
- {"version":3,"file":"environment-variable-interpolator.d.ts","sourceRoot":"","sources":["../../src/interpolator/environment-variable-interpolator.ts"],"names":[],"mappings":"AACA,OAAO,EACL,gBAAgB,EAChB,gBAAgB,EAChB,oBAAoB,EACpB,yBAAyB,EAC1B,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAIpD,qBAAa,oCAAqC,SAAQ,yBAAyB;gBACrE,OAAO,EAAE,MAAM;CAI5B;AAKD,qBAAa,+BAAgC,YAAW,oBAAoB;IAS9D,OAAO,CAAC,QAAQ,CAAC,aAAa;IAR1C,IAAI,EAAE,gBAAgB,CAAyC;IAI/D,6BAA6B,SAAqC;IAElE,OAAO,CAAC,gBAAgB,CAAW;gBAEN,aAAa,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAM;IAInF,WAAW,CAAC,CAAC,EAAE,EAAE,QAAQ,EAAE,EAAE,gBAAgB,CAAC,CAAC,CAAC,GAAG,cAAc;IAKjE,OAAO,CAAC,0BAA0B,CAkBhC;CACH"}
1
+ {"version":3,"file":"environment-variable-interpolator.d.ts","sourceRoot":"","sources":["../../src/interpolator/environment-variable-interpolator.ts"],"names":[],"mappings":"AACA,OAAO,EACL,gBAAgB,EAChB,gBAAgB,EAChB,oBAAoB,EACpB,yBAAyB,EAC1B,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAIpD,qBAAa,oCAAqC,SAAQ,yBAAyB;gBACrE,OAAO,EAAE,MAAM;CAI5B;AAUD,qBAAa,+BAAgC,YAAW,oBAAoB;IAS9D,OAAO,CAAC,QAAQ,CAAC,aAAa;IAR1C,IAAI,EAAE,gBAAgB,CAAyC;IAI/D,6BAA6B,SAAqC;IAElE,OAAO,CAAC,gBAAgB,CAAsB;gBAEjB,aAAa,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAM;IAInF,WAAW,CAAC,CAAC,EAAE,EAAE,QAAQ,EAAE,EAAE,gBAAgB,CAAC,CAAC,CAAC,GAAG,cAAc;IAmBjE,OAAO,CAAC,0BAA0B,CAoBhC;CACH"}
@@ -23,7 +23,22 @@ class EnvironmentVariableInterpolator {
23
23
  this.envVarsToReplace = [];
24
24
  }
25
25
  interpolate({ manifest }) {
26
- this.envVarsToReplace = manifest.environment?.variables ?? [];
26
+ this.envVarsToReplace = [];
27
+ if (manifest.environment && manifest.environment.variables) {
28
+ this.envVarsToReplace = manifest.environment.variables.map((manifestEnvVar) => {
29
+ if (typeof manifestEnvVar === 'string') {
30
+ return {
31
+ key: manifestEnvVar
32
+ };
33
+ }
34
+ else {
35
+ return {
36
+ key: manifestEnvVar.key,
37
+ default: manifestEnvVar.default
38
+ };
39
+ }
40
+ });
41
+ }
27
42
  return (0, yaml_1.parse)(JSON.stringify(manifest), this.environmentVariableReviver);
28
43
  }
29
44
  environmentVariableReviver = (_, value) => {
@@ -31,10 +46,11 @@ class EnvironmentVariableInterpolator {
31
46
  return value;
32
47
  }
33
48
  value = value.replace(this.POSSIBLE_ENVIRONMENT_VARIABLE, (original, envVarName) => {
34
- if (!this.envVarsToReplace.includes(envVarName)) {
49
+ const envVarToReplace = this.envVarsToReplace.find((envVar) => envVar.key === envVarName);
50
+ if (!envVarToReplace) {
35
51
  return original;
36
52
  }
37
- const envVar = this.envVarsRecord[envVarName];
53
+ const envVar = this.envVarsRecord[envVarName] ?? envVarToReplace.default;
38
54
  if (envVar === undefined) {
39
55
  throw new EnvironmentVariableInterpolatorError(text_1.errors.schema.missingEnvironmentVariable(envVarName));
40
56
  }
@@ -27676,8 +27676,16 @@
27676
27676
  "title": "variables",
27677
27677
  "description": "Manifest environment variables",
27678
27678
  "items": {
27679
- "type": "string",
27680
- "pattern": "^[a-zA-Z_][a-zA-Z0-9_]*$"
27679
+ "oneOf": [
27680
+ {
27681
+ "$ref": "#/definitions/EnvVarString",
27682
+ "title": "EnvVarString"
27683
+ },
27684
+ {
27685
+ "$ref": "#/definitions/EnvVarObject",
27686
+ "title": "EnvVarObject"
27687
+ }
27688
+ ]
27681
27689
  }
27682
27690
  }
27683
27691
  }
@@ -27835,6 +27843,28 @@
27835
27843
  }
27836
27844
  }
27837
27845
  },
27846
+ "EnvVarString": {
27847
+ "type": "string",
27848
+ "pattern": "^[a-zA-Z_][a-zA-Z0-9_]*$",
27849
+ "description": "An environment variable name, which can be used in the manifest"
27850
+ },
27851
+ "EnvVarObject": {
27852
+ "type": "object",
27853
+ "additionalProperties": false,
27854
+ "required": [
27855
+ "key", "default"
27856
+ ],
27857
+ "properties": {
27858
+ "key": {
27859
+ "$ref": "#/definitions/EnvVarString",
27860
+ "description": "The name of the environment variable"
27861
+ },
27862
+ "default": {
27863
+ "type": "string",
27864
+ "description": "The default value of the environment variable"
27865
+ }
27866
+ }
27867
+ },
27838
27868
  "AuthProviderPredefined": {
27839
27869
  "type": "object",
27840
27870
  "additionalProperties": false,
@@ -721,10 +721,14 @@ export type OAuth2ScopeName = string;
721
721
  * External authentication providers
722
722
  */
723
723
  export type Auth = (AuthProviderCustom | AuthProviderPredefined)[];
724
+ /**
725
+ * An environment variable name, which can be used in the manifest
726
+ */
727
+ export type EnvVarString = string;
724
728
  /**
725
729
  * Manifest environment variables
726
730
  */
727
- export type Variables = string[];
731
+ export type Variables = (EnvVarString | EnvVarObject)[];
728
732
  export type TranslationsResources = [
729
733
  {
730
734
  key: ForgeSupportedLocaleCode;
@@ -72678,6 +72682,16 @@ export interface AuthProviderPredefined {
72678
72682
  export interface Environment {
72679
72683
  variables?: Variables;
72680
72684
  }
72685
+ export interface EnvVarObject {
72686
+ /**
72687
+ * The name of the environment variable
72688
+ */
72689
+ key: string;
72690
+ /**
72691
+ * The default value of the environment variable
72692
+ */
72693
+ default: string;
72694
+ }
72681
72695
  export interface Translations {
72682
72696
  resources: TranslationsResources;
72683
72697
  fallback: TranslationsFallback;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forge/manifest",
3
- "version": "10.0.1-next.7",
3
+ "version": "10.1.0-next.8",
4
4
  "description": "Definitions and validations of the Forge manifest",
5
5
  "main": "out/index.js",
6
6
  "scripts": {