@cbnventures/nova 0.35.0 → 0.37.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 (147) hide show
  1. package/bin/nova.mjs +17 -0
  2. package/build/package.json +3 -2
  3. package/build/scaffold-versions.json +54 -44
  4. package/build/src/cli/generate/github/workflows-blueprint-validate.d.ts +2 -2
  5. package/build/src/cli/generate/github/workflows-blueprint-validate.d.ts.map +1 -1
  6. package/build/src/cli/generate/github/workflows-blueprint-validate.js +116 -3
  7. package/build/src/cli/generate/github/workflows-blueprint-validate.js.map +1 -1
  8. package/build/src/cli/generate/github/workflows-blueprint.d.ts +11 -5
  9. package/build/src/cli/generate/github/workflows-blueprint.d.ts.map +1 -1
  10. package/build/src/cli/generate/github/workflows-blueprint.js +411 -35
  11. package/build/src/cli/generate/github/workflows-blueprint.js.map +1 -1
  12. package/build/src/cli/generate/must-haves/agent-conventions.d.ts.map +1 -1
  13. package/build/src/cli/generate/must-haves/agent-conventions.js +3 -0
  14. package/build/src/cli/generate/must-haves/agent-conventions.js.map +1 -1
  15. package/build/src/cli/generate/must-haves/dotenv.d.ts.map +1 -1
  16. package/build/src/cli/generate/must-haves/dotenv.js +1 -0
  17. package/build/src/cli/generate/must-haves/dotenv.js.map +1 -1
  18. package/build/src/cli/scaffold/app/astro.d.ts.map +1 -1
  19. package/build/src/cli/scaffold/app/astro.js +0 -1
  20. package/build/src/cli/scaffold/app/astro.js.map +1 -1
  21. package/build/src/cli/scaffold/app/vite.d.ts.map +1 -1
  22. package/build/src/cli/scaffold/app/vite.js +0 -1
  23. package/build/src/cli/scaffold/app/vite.js.map +1 -1
  24. package/build/src/cli/scaffold/docs/docusaurus.d.ts.map +1 -1
  25. package/build/src/cli/scaffold/docs/docusaurus.js +0 -1
  26. package/build/src/cli/scaffold/docs/docusaurus.js.map +1 -1
  27. package/build/src/cli/utility/changelog.d.ts.map +1 -1
  28. package/build/src/cli/utility/changelog.js +119 -67
  29. package/build/src/cli/utility/changelog.js.map +1 -1
  30. package/build/src/cli/utility/configure.d.ts.map +1 -1
  31. package/build/src/cli/utility/configure.js +126 -1
  32. package/build/src/cli/utility/configure.js.map +1 -1
  33. package/build/src/lib/corepack.d.ts +2 -2
  34. package/build/src/lib/corepack.d.ts.map +1 -1
  35. package/build/src/lib/corepack.js +16 -6
  36. package/build/src/lib/corepack.js.map +1 -1
  37. package/build/src/lib/docker-packaging.d.ts.map +1 -1
  38. package/build/src/lib/docker-packaging.js +15 -12
  39. package/build/src/lib/docker-packaging.js.map +1 -1
  40. package/build/src/lib/dotenv.d.ts.map +1 -1
  41. package/build/src/lib/dotenv.js +17 -8
  42. package/build/src/lib/dotenv.js.map +1 -1
  43. package/build/src/lib/env-managed-set.d.ts.map +1 -1
  44. package/build/src/lib/env-managed-set.js +55 -11
  45. package/build/src/lib/env-managed-set.js.map +1 -1
  46. package/build/src/lib/env-namespace.d.ts.map +1 -1
  47. package/build/src/lib/env-namespace.js +1 -0
  48. package/build/src/lib/env-namespace.js.map +1 -1
  49. package/build/src/lib/env-profiles.d.ts +3 -0
  50. package/build/src/lib/env-profiles.d.ts.map +1 -0
  51. package/build/src/lib/env-profiles.js +70 -0
  52. package/build/src/lib/env-profiles.js.map +1 -0
  53. package/build/src/lib/env-status.d.ts.map +1 -1
  54. package/build/src/lib/env-status.js +23 -2
  55. package/build/src/lib/env-status.js.map +1 -1
  56. package/build/src/lib/item.d.ts.map +1 -1
  57. package/build/src/lib/item.js +20 -3
  58. package/build/src/lib/item.js.map +1 -1
  59. package/build/src/lib/nova-config.d.ts.map +1 -1
  60. package/build/src/lib/nova-config.js +31 -0
  61. package/build/src/lib/nova-config.js.map +1 -1
  62. package/build/src/lib/regex.d.ts +7 -1
  63. package/build/src/lib/regex.d.ts.map +1 -1
  64. package/build/src/lib/regex.js +7 -1
  65. package/build/src/lib/regex.js.map +1 -1
  66. package/build/src/lib/run-scripts.d.ts.map +1 -1
  67. package/build/src/lib/run-scripts.js +24 -0
  68. package/build/src/lib/run-scripts.js.map +1 -1
  69. package/build/src/lib/scaffold.d.ts.map +1 -1
  70. package/build/src/lib/scaffold.js +7 -0
  71. package/build/src/lib/scaffold.js.map +1 -1
  72. package/build/src/lib/workflow-templates.js +4 -4
  73. package/build/src/lib/workflow-templates.js.map +1 -1
  74. package/build/src/types/cli/generate/github/workflows-blueprint-validate.d.ts +42 -4
  75. package/build/src/types/cli/generate/github/workflows-blueprint.d.ts +193 -17
  76. package/build/src/types/cli/utility/changelog.d.ts +49 -6
  77. package/build/src/types/cli/utility/configure.d.ts +52 -0
  78. package/build/src/types/lib/corepack.d.ts +13 -0
  79. package/build/src/types/lib/docker-packaging.d.ts +2 -0
  80. package/build/src/types/lib/dotenv.d.ts +10 -3
  81. package/build/src/types/lib/env-managed-set.d.ts +15 -0
  82. package/build/src/types/lib/env-namespace.d.ts +5 -0
  83. package/build/src/types/lib/env-profiles.d.ts +67 -0
  84. package/build/src/types/lib/env-status.d.ts +9 -0
  85. package/build/src/types/lib/item.d.ts +20 -3
  86. package/build/src/types/lib/nova-config.d.ts +14 -0
  87. package/build/src/types/lib/regex.d.ts +0 -2
  88. package/build/src/types/lib/run-scripts.d.ts +16 -0
  89. package/build/src/types/lib/scaffold.d.ts +8 -0
  90. package/build/src/types/shared.d.ts +47 -6
  91. package/build/src/types/tests/cli/generate/github/workflows-blueprint-publish-parity.test.d.ts +20 -0
  92. package/build/src/types/tests/cli/generate/github/workflows-blueprint-validate.test.d.ts +22 -0
  93. package/build/src/types/tests/cli/generate/github/workflows-blueprint.test.d.ts +16 -0
  94. package/build/src/types/tests/cli/generate/must-haves/agent-conventions.test.d.ts +40 -0
  95. package/build/src/types/tests/cli/utility/changelog.test.d.ts +48 -45
  96. package/build/src/types/tests/cli/utility/configure.test.d.ts +1 -0
  97. package/build/src/types/tests/cli/utility/run-scripts.test.d.ts +29 -0
  98. package/build/src/types/tests/lib/docker-packaging.test.d.ts +14 -0
  99. package/build/src/types/tests/lib/env-profiles.test.d.ts +20 -0
  100. package/build/templates/generators/must-haves/agent-conventions/AGENTS.md +8 -5
  101. package/build/templates/generators/must-haves/agent-conventions/CLAUDE.md +8 -5
  102. package/build/templates/generators/must-haves/agent-conventions/conventions/csharp.md +6 -6
  103. package/build/templates/generators/must-haves/agent-conventions/conventions/go.md +241 -0
  104. package/build/templates/generators/must-haves/agent-conventions/conventions/nova.md +155 -0
  105. package/build/templates/generators/must-haves/agent-conventions/conventions/python.md +7 -7
  106. package/build/templates/generators/must-haves/agent-conventions/conventions/rust.md +227 -0
  107. package/build/templates/generators/must-haves/agent-conventions/conventions/swift.md +9 -9
  108. package/build/templates/generators/must-haves/agent-conventions/conventions/typescript.md +145 -23
  109. package/build/templates/generators/must-haves/agent-conventions/conventions/universal.md +112 -103
  110. package/build/templates/generators/must-haves/ignore-files/gitignore +1 -0
  111. package/build/templates/scaffold/app/android/package.json +1 -1
  112. package/build/templates/scaffold/app/apple/Sources/App.swift +15 -2
  113. package/build/templates/scaffold/app/apple/Tests/AppTests.swift +14 -2
  114. package/build/templates/scaffold/app/apple/package.json +1 -1
  115. package/build/templates/scaffold/app/apple/project.yml +1 -0
  116. package/build/templates/scaffold/app/astro/package.json +1 -1
  117. package/build/templates/scaffold/app/discord-bot/package.json +1 -1
  118. package/build/templates/scaffold/app/express/package.json +1 -1
  119. package/build/templates/scaffold/app/nextjs/package.json +1 -1
  120. package/build/templates/scaffold/app/vite/package.json +2 -2
  121. package/build/templates/scaffold/app/vite/vite.config.mts +3 -0
  122. package/build/templates/scaffold/docs/docusaurus/package.json +4 -4
  123. package/build/templates/scaffold/docs/docusaurus/static/images/nova.svg +13 -5
  124. package/build/templates/scaffold/docs/docusaurus/vitest.config.mts +9 -0
  125. package/build/templates/scaffold/package/github-action/package.json +1 -1
  126. package/build/templates/scaffold/package/homebridge/package.json +1 -1
  127. package/build/templates/scaffold/package/pfsense/package.json +1 -1
  128. package/build/templates/scaffold/package/pfsense/port/files/usr/local/pkg/[__WORKSPACE_NAME__].inc +10 -0
  129. package/build/templates/scaffold/package/pfsense-root/.github/workflows/pfsense-[__WORKSPACE_NAME__].yml +62 -0
  130. package/build/templates/scaffold-options/app/android-native/.gitattributes +2 -0
  131. package/build/templates/scaffold-options/app/android-native/app/src/main/java/[__ANDROID_PACKAGE_PATH__]/MainActivity.kt +16 -2
  132. package/build/templates/scaffold-options/app/android-native/app/src/main/java/[__ANDROID_PACKAGE_PATH__]/NavigationKeys.kt +7 -1
  133. package/build/templates/scaffold-options/app/android-native/app/src/main/java/[__ANDROID_PACKAGE_PATH__]/data/DataRepository.kt +28 -4
  134. package/build/templates/scaffold-options/app/android-native/app/src/main/java/[__ANDROID_PACKAGE_PATH__]/theme/Color.kt +40 -6
  135. package/build/templates/scaffold-options/app/android-native/app/src/main/java/[__ANDROID_PACKAGE_PATH__]/theme/Theme.kt +22 -1
  136. package/build/templates/scaffold-options/app/android-native/app/src/main/java/[__ANDROID_PACKAGE_PATH__]/theme/Type.kt +8 -2
  137. package/build/templates/scaffold-options/app/android-native/app/src/main/java/[__ANDROID_PACKAGE_PATH__]/ui/main/MainScreenViewModel.kt +42 -6
  138. package/build/templates/scaffold-options/app/android-native/app/src/test/java/[__ANDROID_PACKAGE_PATH__]/ui/main/MainScreenViewModelTest.kt +31 -4
  139. package/build/templates/scaffold-options/app/android-native/gradle/wrapper/gradle-wrapper.jar +0 -0
  140. package/build/templates/scaffold-options/app/android-native/gradlew +189 -113
  141. package/build/templates/scaffold-options/app/android-native/gradlew.bat +79 -51
  142. package/build/templates/scaffold-options/app/astro/cloudflare/public/.assetsignore +15 -0
  143. package/build/templates/scaffold-options/app/web-launchpad/public/favicon.svg +13 -5
  144. package/build/templates/scaffold-options/docker-image/common/dockerignore +2 -0
  145. package/build/templates/scaffold-options/tool/serverless/cloudflare-workers/package.json +1 -1
  146. package/build/templates/scaffold-options/tool/serverless/vercel-functions/package.json +1 -1
  147. package/package.json +3 -2
@@ -6,7 +6,7 @@ import { libEnvNamespace } from '../../../lib/env-namespace.js';
6
6
  import { Runner as LibNovaConfig } from '../../../lib/nova-config.js';
7
7
  import { LIB_REGEX_CHARACTER_BACKSLASH, LIB_REGEX_CHARACTER_BACKTICK, LIB_REGEX_CHARACTER_DOLLAR, LIB_REGEX_CHARACTER_DOUBLE_QUOTE, LIB_REGEX_CHARACTER_FORWARD_SLASH, LIB_REGEX_PATTERN_DOUBLE_QUOTE, LIB_REGEX_PATTERN_LEADING_DOT_SLASH, } from '../../../lib/regex.js';
8
8
  import { getScaffoldVersion } from '../../../lib/scaffold-versions.js';
9
- import { isProjectRoot, pathExists, renameFileWithDate, saveGeneratedFile, } from '../../../lib/utility.js';
9
+ import { isProjectRoot, pathExists, renameFileWithDate, saveGeneratedFile, shellQuote, } from '../../../lib/utility.js';
10
10
  import { Logger } from '../../../toolkit/index.js';
11
11
  import { Runner as Validator } from './workflows-blueprint-validate.js';
12
12
  import { Runner as Variables } from './workflows-blueprint-variables.js';
@@ -58,7 +58,7 @@ export class Runner {
58
58
  }).info('No workflows configured.');
59
59
  return 'completed';
60
60
  }
61
- const validation = Validator.validate(rawWorkflows, workspaces, (config['settings'] === undefined) ? 'semver' : config['settings']['versionStrategy']);
61
+ const validation = Validator.validate(rawWorkflows, workspaces, (config['settings'] === undefined) ? 'semver' : config['settings']['versionStrategy'], environment);
62
62
  const validatedWorkflows = validation['workflows'];
63
63
  for (const diagnosticEntry of validation['diagnostics']) {
64
64
  const diagnostic = diagnosticEntry;
@@ -477,6 +477,9 @@ export class Runner {
477
477
  const runNameParts = [];
478
478
  const triggers = entry['triggers'];
479
479
  const targets = entry['deploy'] ?? [];
480
+ const environmentSelection = entry['environmentSelection'];
481
+ const profileAware = environmentSelection !== undefined;
482
+ const selectedEnvironmentExpression = 'github.event_name == \'workflow_dispatch\' && (inputs.environment || \'staging\') || github.event_name == \'release\' && github.event.release.prerelease && \'staging\' || github.event_name == \'release\' && \'production\' || \'from tag\'';
480
483
  const hasContainerTarget = targets.some((target) => target['to'] === 'docker-hub' || target['to'] === 'ghcr');
481
484
  const containerPlatforms = entry['containerPlatforms'] ?? [
482
485
  'linux/amd64',
@@ -595,19 +598,33 @@ export class Runner {
595
598
  default: '',
596
599
  });
597
600
  }
601
+ if (environmentSelection !== undefined && environmentSelection['manual'] === true) {
602
+ dispatchInputs.push({
603
+ name: 'environment',
604
+ description: 'Deployment environment',
605
+ required: true,
606
+ type: 'choice',
607
+ default: 'staging',
608
+ options: [
609
+ 'staging',
610
+ 'production',
611
+ ],
612
+ });
613
+ }
598
614
  mergedOn.push({
599
615
  event: 'workflow_dispatch',
600
616
  inputs: dispatchInputs,
601
617
  });
602
618
  const publishCondition = [
603
619
  ...publishConditionParts.map((part) => ((part.includes('&&') === true) ? `(${part})` : part)),
604
- '(github.event_name == \'workflow_dispatch\' && !inputs.dry-run)',
620
+ ...((environmentSelection === undefined || environmentSelection['manual'] === true) ? ['(github.event_name == \'workflow_dispatch\' && !inputs.dry-run)'] : []),
605
621
  ].join(' || ');
606
622
  const runNameLabel = [
607
623
  ...runNameParts.map((part) => ((part.includes('&&') === true) ? `(${part})` : part)),
608
624
  '\'manually\'',
609
625
  ].join(' || ');
610
- const runName = `Publishing ${Runner.expr(runNameLabel)}${workflowId}\${{ github.event_name == 'workflow_dispatch' && inputs.dry-run && ' (dry run)' || '' }}`;
626
+ const runNameEnvironmentSuffix = (profileAware === true) ? ` [${Runner.expr(selectedEnvironmentExpression)}]` : '';
627
+ const runName = `Publishing ${Runner.expr(runNameLabel)}${workflowId}${runNameEnvironmentSuffix}\${{ github.event_name == 'workflow_dispatch' && inputs.dry-run && ' (dry run)' || '' }}`;
611
628
  const workflowSettings = entry['with'];
612
629
  const metadata = Variables.getTemplateMetadata('publish');
613
630
  const variables = (metadata === undefined) ? {} : metadata['variables'];
@@ -666,8 +683,16 @@ export class Runner {
666
683
  workingDirectory: Runner.expr('env.ROOT_DIR'),
667
684
  },
668
685
  ];
686
+ const preflightStep = Runner.buildCloudflareEnvironmentPreflight(entry, environment, packageManager);
687
+ const environmentSelectionStep = Runner.buildCloudflareEnvironmentSelectionStep(environmentSelection);
688
+ if (environmentSelectionStep !== undefined) {
689
+ steps.splice(1, 0, environmentSelectionStep);
690
+ }
691
+ if (preflightStep !== undefined) {
692
+ steps.push(preflightStep);
693
+ }
669
694
  for (const scope of scopes) {
670
- const buildValues = Runner.appBuildValues(environment, scope);
695
+ const buildValues = Runner.appBuildValues(environment, scope, profileAware);
671
696
  if (buildValues.length === 0) {
672
697
  continue;
673
698
  }
@@ -675,7 +700,7 @@ export class Runner {
675
700
  name: `Write environment file (${Runner.slugifyWorkingDir(scope)})`,
676
701
  env: buildValues.map((buildValue) => ({
677
702
  key: buildValue['key'],
678
- value: (buildValue['secret'] === true) ? Runner.expr(`secrets.${buildValue['name']}`) : Runner.expr(`vars.${buildValue['name']}`),
703
+ value: Runner.resolveDeliveryValueExpr(buildValue),
679
704
  })),
680
705
  run: Runner.writeEnvRun(buildValues),
681
706
  runBlock: true,
@@ -714,6 +739,8 @@ export class Runner {
714
739
  runBlock: true,
715
740
  });
716
741
  }
742
+ const artifactPreflightPaths = [];
743
+ const artifactUploadSteps = [];
717
744
  for (const target of targets) {
718
745
  const uploadTarget = target;
719
746
  const uploadMetadata = Variables.getTargetMetadata('publish', uploadTarget['to']);
@@ -721,8 +748,9 @@ export class Runner {
721
748
  if (uploadArtifactPaths.length === 0) {
722
749
  continue;
723
750
  }
724
- const uploadWorkingDir = uploadTarget['path'].replace(LIB_REGEX_PATTERN_LEADING_DOT_SLASH, '');
725
- const uploadPath = uploadArtifactPaths.map((artifactPath) => artifactPath.replace('{workingDir}', uploadWorkingDir)).join('\n');
751
+ const uploadWorkingDir = (uploadTarget['path'] === './') ? '.' : uploadTarget['path'].replace(LIB_REGEX_PATTERN_LEADING_DOT_SLASH, '');
752
+ const uploadResolvedArtifactPaths = uploadArtifactPaths.map((artifactPath) => artifactPath.replace('{workingDir}', uploadWorkingDir));
753
+ const uploadPath = uploadResolvedArtifactPaths.join('\n');
726
754
  const artifactName = `build-${uploadTarget['to']}-${Runner.slugifyWorkingDir(uploadTarget['path'])}`;
727
755
  const uploadStep = {
728
756
  name: `Upload build artifacts (${uploadTarget['to']}/${Runner.slugifyWorkingDir(uploadTarget['path'])})`,
@@ -736,6 +764,14 @@ export class Runner {
736
764
  key: 'retention-days',
737
765
  value: 1,
738
766
  },
767
+ {
768
+ key: 'include-hidden-files',
769
+ value: true,
770
+ },
771
+ {
772
+ key: 'if-no-files-found',
773
+ value: 'error',
774
+ },
739
775
  {
740
776
  key: 'path',
741
777
  value: uploadPath,
@@ -743,7 +779,15 @@ export class Runner {
743
779
  },
744
780
  ],
745
781
  };
746
- steps.push(uploadStep);
782
+ for (const uploadResolvedArtifactPath of uploadResolvedArtifactPaths) {
783
+ if (artifactPreflightPaths.includes(uploadResolvedArtifactPath) === false) {
784
+ artifactPreflightPaths.push(uploadResolvedArtifactPath);
785
+ }
786
+ }
787
+ artifactUploadSteps.push(uploadStep);
788
+ }
789
+ if (artifactPreflightPaths.length > 0) {
790
+ steps.push(Runner.buildArtifactPreflightStep('Validate build artifacts', artifactPreflightPaths, Runner.expr('github.workspace')), ...artifactUploadSteps);
747
791
  }
748
792
  if (hasContainerTarget === true) {
749
793
  const containerArtifactSteps = Runner.buildContainerArtifactSteps(containerPlatforms);
@@ -772,6 +816,7 @@ export class Runner {
772
816
  workspace: workspaces[deployTarget['path']],
773
817
  environment,
774
818
  packageManager,
819
+ ...((environmentSelection === undefined) ? {} : { environmentSelection }),
775
820
  };
776
821
  if (deployTarget['to'] === 'npm') {
777
822
  jobs.push(Runner.buildNpmTarget(context));
@@ -779,8 +824,8 @@ export class Runner {
779
824
  else if (deployTarget['to'] === 'github-packages') {
780
825
  jobs.push(Runner.buildGithubPackagesTarget(context));
781
826
  }
782
- else if (deployTarget['to'] === 'cloudflare-pages-docusaurus') {
783
- jobs.push(Runner.buildCloudflarePagesDocusaurusTarget(context));
827
+ else if (deployTarget['to'] === 'cloudflare-pages') {
828
+ jobs.push(Runner.buildCloudflarePagesTarget(context));
784
829
  }
785
830
  else if (deployTarget['to'] === 'cloudflare-workers') {
786
831
  jobs.push(Runner.buildCloudflareWorkersTarget(context));
@@ -791,8 +836,8 @@ export class Runner {
791
836
  else if (deployTarget['to'] === 'ghcr') {
792
837
  jobs.push(Runner.buildGhcrTarget(context));
793
838
  }
794
- else if (deployTarget['to'] === 'github-pages-docusaurus') {
795
- jobs.push(Runner.buildGithubPagesDocusaurusTarget(context));
839
+ else if (deployTarget['to'] === 'github-pages') {
840
+ jobs.push(Runner.buildGithubPagesTarget(context));
796
841
  }
797
842
  else if (deployTarget['to'] === 'github-action') {
798
843
  jobs.push(Runner.buildGithubActionTarget(context));
@@ -827,6 +872,168 @@ export class Runner {
827
872
  jobs,
828
873
  };
829
874
  }
875
+ static buildCloudflareEnvironmentSelectionStep(environmentSelection) {
876
+ if (environmentSelection === undefined) {
877
+ return undefined;
878
+ }
879
+ const lines = [
880
+ 'set -euo pipefail',
881
+ '',
882
+ 'case "$GITHUB_EVENT_NAME" in',
883
+ ' workflow_dispatch)',
884
+ String.raw ` deploy_environment="${'$'}{MANUAL_ENVIRONMENT:-staging}"`,
885
+ ' ;;',
886
+ ' release)',
887
+ ' if [ "$IS_PRERELEASE" = "true" ]; then',
888
+ ' deploy_environment="staging"',
889
+ ' else',
890
+ ' deploy_environment="production"',
891
+ ' fi',
892
+ ' ;;',
893
+ ' push)',
894
+ ' if [[ "$GITHUB_REF_NAME" =~ [0-9]+\\.[0-9]+\\.[0-9]+-[0-9A-Za-z.-]+(\\+[0-9A-Za-z.-]+)?$ ]]; then',
895
+ ' deploy_environment="staging"',
896
+ ' else',
897
+ ' deploy_environment="production"',
898
+ ' fi',
899
+ ' ;;',
900
+ ' *)',
901
+ ' echo "Unable to select a deployment environment for event: $GITHUB_EVENT_NAME" >&2',
902
+ ' exit 1',
903
+ ' ;;',
904
+ 'esac',
905
+ '',
906
+ '{',
907
+ ' echo "DEPLOY_ENVIRONMENT=$deploy_environment"',
908
+ ' echo "CLOUDFLARE_ENV=$deploy_environment"',
909
+ '} >> "$GITHUB_ENV"',
910
+ '',
911
+ 'echo "Selected Cloudflare deployment environment: $deploy_environment"',
912
+ ];
913
+ return {
914
+ name: 'Select Cloudflare deployment environment',
915
+ env: [
916
+ {
917
+ key: 'MANUAL_ENVIRONMENT',
918
+ value: Runner.expr('inputs.environment || \'\''),
919
+ },
920
+ {
921
+ key: 'IS_PRERELEASE',
922
+ value: Runner.expr('github.event.release.prerelease || false'),
923
+ },
924
+ ],
925
+ run: lines.join('\n'),
926
+ runBlock: true,
927
+ };
928
+ }
929
+ static buildCloudflareEnvironmentPreflight(entry, environment, packageManager) {
930
+ if (entry['environmentSelection'] === undefined) {
931
+ return undefined;
932
+ }
933
+ const requiredValues = [];
934
+ const seenValues = new Set();
935
+ const targets = entry['deploy'] ?? [];
936
+ const workflowSettings = entry['with'];
937
+ for (const scope of entry['build'] ?? []) {
938
+ const buildValues = Runner.appBuildValues(environment, scope, true);
939
+ for (const buildValue of buildValues) {
940
+ if (buildValue['defaultValue'] !== undefined) {
941
+ continue;
942
+ }
943
+ const buildExpression = Runner.resolveDeliveryValueExpr(buildValue);
944
+ if (seenValues.has(buildExpression) === true) {
945
+ continue;
946
+ }
947
+ seenValues.add(buildExpression);
948
+ requiredValues.push({
949
+ label: `${scope}:${buildValue['key']}`,
950
+ value: buildExpression,
951
+ });
952
+ }
953
+ }
954
+ for (const target of targets) {
955
+ const runtimeTargetPath = target['path'];
956
+ const runtimeValues = Runner.appRuntimeValues(environment, runtimeTargetPath, true);
957
+ for (const runtimeValue of runtimeValues) {
958
+ if (runtimeValue['defaultValue'] !== undefined) {
959
+ continue;
960
+ }
961
+ const runtimeExpression = Runner.resolveDeliveryValueExpr(runtimeValue);
962
+ if (seenValues.has(runtimeExpression) === true) {
963
+ continue;
964
+ }
965
+ seenValues.add(runtimeExpression);
966
+ requiredValues.push({
967
+ label: `${runtimeTargetPath}:${runtimeValue['key']}`,
968
+ value: runtimeExpression,
969
+ });
970
+ }
971
+ const metadata = Variables.getTargetMetadata('publish', 'cloudflare-workers');
972
+ const variables = (metadata === undefined) ? {} : metadata['variables'];
973
+ const targetSettings = target['with'];
974
+ for (const variableEntry of Object.entries(variables)) {
975
+ const variableName = variableEntry[0];
976
+ const variableMeta = variableEntry[1];
977
+ if (variableMeta['auto'] === true
978
+ || variableMeta['format'] === 'literal'
979
+ || variableMeta['optional'] === true) {
980
+ continue;
981
+ }
982
+ const credentialExpression = Runner.resolveScopedCredExpr(variables, variableName, targetSettings, workflowSettings, environment, runtimeTargetPath, true);
983
+ if (seenValues.has(credentialExpression) === true) {
984
+ continue;
985
+ }
986
+ seenValues.add(credentialExpression);
987
+ requiredValues.push({
988
+ label: `${runtimeTargetPath}:${variableName}`,
989
+ value: credentialExpression,
990
+ });
991
+ }
992
+ }
993
+ const env = [];
994
+ const lines = [
995
+ 'set -euo pipefail',
996
+ '',
997
+ 'if [ "$PUBLISH" = "true" ]; then',
998
+ ' missing=0',
999
+ ];
1000
+ let index = 0;
1001
+ for (const requiredValueEntry of requiredValues) {
1002
+ const requiredValue = requiredValueEntry;
1003
+ index += 1;
1004
+ const envKey = `NOVA_REQUIRED_${index}`;
1005
+ const labelKey = `NOVA_REQUIRED_LABEL_${index}`;
1006
+ env.push({
1007
+ key: envKey,
1008
+ value: requiredValue['value'],
1009
+ });
1010
+ env.push({
1011
+ key: labelKey,
1012
+ value: requiredValue['label'],
1013
+ });
1014
+ lines.push(` if [ -z "\${${envKey}:-}" ]; then`);
1015
+ lines.push(` echo "::error::Missing selected deployment value: \$${labelKey}"`);
1016
+ lines.push(' missing=1');
1017
+ lines.push(' fi');
1018
+ }
1019
+ lines.push(' if [ "$missing" -ne 0 ]; then');
1020
+ lines.push(' exit 1');
1021
+ lines.push(' fi');
1022
+ lines.push('fi');
1023
+ lines.push('');
1024
+ lines.push('echo "Validating Cloudflare environment: $CLOUDFLARE_ENV"');
1025
+ for (const target of targets) {
1026
+ const validationTargetPath = target['path'];
1027
+ const targetSlug = Runner.slugifyWorkingDir(validationTargetPath);
1028
+ lines.push(`(cd ${shellQuote(validationTargetPath)} && ${Runner.corepackExecuteCommand(packageManager, 'wrangler')} types "$RUNNER_TEMP/nova-wrangler-${targetSlug}.d.ts" --env "$CLOUDFLARE_ENV")`);
1029
+ }
1030
+ return {
1031
+ name: 'Validate Cloudflare deployment environment',
1032
+ env,
1033
+ run: lines.join('\n'),
1034
+ runBlock: true,
1035
+ };
1036
+ }
830
1037
  static buildReleaseTrigger() {
831
1038
  return {
832
1039
  event: 'release',
@@ -1034,15 +1241,15 @@ export class Runner {
1034
1241
  ],
1035
1242
  };
1036
1243
  }
1037
- static buildCloudflarePagesDocusaurusTarget(context) {
1244
+ static buildCloudflarePagesTarget(context) {
1038
1245
  const targetSettings = context['targetSettings'];
1039
1246
  const workflowSettings = context['workflowSettings'];
1040
- const metadata = Variables.getTargetMetadata('publish', 'cloudflare-pages-docusaurus');
1247
+ const metadata = Variables.getTargetMetadata('publish', 'cloudflare-pages');
1041
1248
  const variables = (metadata === undefined) ? {} : metadata['variables'];
1042
1249
  const environment = context['environment'];
1043
1250
  const appPath = context['workingDir'];
1044
1251
  return {
1045
- id: `publish-cloudflare-pages-docusaurus-${Runner.slugifyWorkingDir(context['workingDir'])}`,
1252
+ id: `publish-cloudflare-pages-${Runner.slugifyWorkingDir(context['workingDir'])}`,
1046
1253
  needs: context['needs'],
1047
1254
  runsOn: 'ubuntu-latest',
1048
1255
  timeoutMinutes: 10,
@@ -1068,10 +1275,10 @@ export class Runner {
1068
1275
  },
1069
1276
  ],
1070
1277
  },
1071
- {
1072
- name: 'Enable Corepack',
1073
- run: `corepack enable ${context['packageManager']}`,
1074
- },
1278
+ ...((context['packageManager'] === 'npm') ? [] : [{
1279
+ name: 'Install Corepack',
1280
+ run: Runner.corepackBootstrapRun(context['packageManager']),
1281
+ }]),
1075
1282
  {
1076
1283
  name: 'Download build artifacts',
1077
1284
  uses: getScaffoldVersion('workflowActionDownloadArtifact'),
@@ -1118,16 +1325,18 @@ export class Runner {
1118
1325
  const metadata = Variables.getTargetMetadata('publish', 'cloudflare-workers');
1119
1326
  const variables = (metadata === undefined) ? {} : metadata['variables'];
1120
1327
  const environment = context['environment'];
1328
+ const environmentSelection = context['environmentSelection'];
1329
+ const profileAware = environmentSelection !== undefined;
1121
1330
  const appPath = context['workingDir'];
1122
- const runtimeValues = Runner.appRuntimeValues(environment, appPath);
1331
+ const runtimeValues = Runner.appRuntimeValues(environment, appPath, profileAware);
1123
1332
  const deployEnv = [
1124
1333
  {
1125
1334
  key: 'CLOUDFLARE_API_TOKEN',
1126
- value: Runner.resolveScopedCredExpr(variables, 'CLOUDFLARE_API_TOKEN', targetSettings, workflowSettings, environment, appPath),
1335
+ value: Runner.resolveScopedCredExpr(variables, 'CLOUDFLARE_API_TOKEN', targetSettings, workflowSettings, environment, appPath, profileAware),
1127
1336
  },
1128
1337
  {
1129
1338
  key: 'CLOUDFLARE_ACCOUNT_ID',
1130
- value: Runner.resolveScopedCredExpr(variables, 'CLOUDFLARE_ACCOUNT_ID', targetSettings, workflowSettings, environment, appPath),
1339
+ value: Runner.resolveScopedCredExpr(variables, 'CLOUDFLARE_ACCOUNT_ID', targetSettings, workflowSettings, environment, appPath, profileAware),
1131
1340
  },
1132
1341
  ];
1133
1342
  const deployRun = Runner.runScriptCommand(context['packageManager'], 'deploy');
@@ -1177,6 +1386,10 @@ export class Runner {
1177
1386
  workingDirectory: context['workingDir'],
1178
1387
  },
1179
1388
  ];
1389
+ const environmentSelectionStep = Runner.buildCloudflareEnvironmentSelectionStep(environmentSelection);
1390
+ if (environmentSelectionStep !== undefined) {
1391
+ steps.splice(1, 0, environmentSelectionStep);
1392
+ }
1180
1393
  const syncStep = Runner.emitRuntimeSyncStep({
1181
1394
  vendor: 'cloudflare',
1182
1395
  runtimeValues,
@@ -1185,11 +1398,11 @@ export class Runner {
1185
1398
  extraEnv: [
1186
1399
  {
1187
1400
  key: 'CLOUDFLARE_API_TOKEN',
1188
- value: Runner.resolveScopedCredExpr(variables, 'CLOUDFLARE_API_TOKEN', targetSettings, workflowSettings, environment, appPath),
1401
+ value: Runner.resolveScopedCredExpr(variables, 'CLOUDFLARE_API_TOKEN', targetSettings, workflowSettings, environment, appPath, profileAware),
1189
1402
  },
1190
1403
  {
1191
1404
  key: 'CLOUDFLARE_ACCOUNT_ID',
1192
- value: Runner.resolveScopedCredExpr(variables, 'CLOUDFLARE_ACCOUNT_ID', targetSettings, workflowSettings, environment, appPath),
1405
+ value: Runner.resolveScopedCredExpr(variables, 'CLOUDFLARE_ACCOUNT_ID', targetSettings, workflowSettings, environment, appPath, profileAware),
1193
1406
  },
1194
1407
  ],
1195
1408
  });
@@ -1274,10 +1487,10 @@ export class Runner {
1274
1487
  extraPermissions: { 'packages': 'write' },
1275
1488
  });
1276
1489
  }
1277
- static buildGithubPagesDocusaurusTarget(context) {
1490
+ static buildGithubPagesTarget(context) {
1278
1491
  const targetSettings = context['targetSettings'];
1279
1492
  const workflowSettings = context['workflowSettings'];
1280
- const metadata = Variables.getTargetMetadata('publish', 'github-pages-docusaurus');
1493
+ const metadata = Variables.getTargetMetadata('publish', 'github-pages');
1281
1494
  const variables = (metadata === undefined) ? {} : metadata['variables'];
1282
1495
  const pagesStatusRun = [
1283
1496
  `if gh api "repos/${Runner.expr('github.repository')}/pages" > /dev/null 2>&1; then`,
@@ -1289,7 +1502,7 @@ export class Runner {
1289
1502
  'fi',
1290
1503
  ].join('\n');
1291
1504
  return {
1292
- id: `publish-github-pages-docusaurus-${Runner.slugifyWorkingDir(context['workingDir'])}`,
1505
+ id: `publish-github-pages-${Runner.slugifyWorkingDir(context['workingDir'])}`,
1293
1506
  needs: context['needs'],
1294
1507
  runsOn: 'ubuntu-latest',
1295
1508
  timeoutMinutes: 10,
@@ -1666,6 +1879,108 @@ export class Runner {
1666
1879
  steps,
1667
1880
  };
1668
1881
  }
1882
+ static buildArtifactPreflightStep(name, artifactPaths, allowedRoot) {
1883
+ const rootLines = artifactPaths.map((artifactPath) => `validate_artifact_root ${shellQuote(artifactPath)}`);
1884
+ const lines = [
1885
+ 'set -euo pipefail',
1886
+ '',
1887
+ `ALLOWED_ROOT="${allowedRoot}"`,
1888
+ 'ALLOWED_ROOT="$(realpath "$ALLOWED_ROOT")"',
1889
+ 'cd "$ALLOWED_ROOT"',
1890
+ '',
1891
+ 'validate_artifact_root() {',
1892
+ ' local artifact_root="$1"',
1893
+ ' local candidate',
1894
+ ' local candidate_parent',
1895
+ ' local first_file',
1896
+ ' local relative_candidate',
1897
+ ' local resolved_candidate',
1898
+ ' local resolved_root',
1899
+ '',
1900
+ ' if [ ! -e "$artifact_root" ] && [ ! -L "$artifact_root" ]; then',
1901
+ ' echo "Artifact root does not exist: $artifact_root" >&2',
1902
+ ' exit 1',
1903
+ ' fi',
1904
+ '',
1905
+ ' if ! resolved_root="$(realpath "$artifact_root")"; then',
1906
+ ' echo "Artifact root cannot be resolved: $artifact_root" >&2',
1907
+ ' exit 1',
1908
+ ' fi',
1909
+ '',
1910
+ ' case "$resolved_root" in',
1911
+ ' "$ALLOWED_ROOT"|"$ALLOWED_ROOT"/*) ;;',
1912
+ ' *)',
1913
+ ' echo "Artifact root escapes its allowed boundary: $artifact_root -> $resolved_root" >&2',
1914
+ ' exit 1',
1915
+ ' ;;',
1916
+ ' esac',
1917
+ '',
1918
+ ' while IFS= read -r -d \'\' candidate; do',
1919
+ ' if ! resolved_candidate="$(realpath "$candidate")"; then',
1920
+ ' echo "Artifact contains a broken symlink: $candidate" >&2',
1921
+ ' exit 1',
1922
+ ' fi',
1923
+ '',
1924
+ ' case "$resolved_candidate" in',
1925
+ ' "$resolved_root"|"$resolved_root"/*) ;;',
1926
+ ' *)',
1927
+ ' echo "Artifact symlink escapes its root: $candidate -> $resolved_candidate" >&2',
1928
+ ' exit 1',
1929
+ ' ;;',
1930
+ ' esac',
1931
+ '',
1932
+ ' candidate_parent="$(realpath "$(dirname "$candidate")")"',
1933
+ '',
1934
+ ' case "$candidate_parent/" in',
1935
+ ' "$resolved_candidate"/*)',
1936
+ ' echo "Artifact contains a recursive symlink: $candidate -> $resolved_candidate" >&2',
1937
+ ' exit 1',
1938
+ ' ;;',
1939
+ ' esac',
1940
+ ' done < <(find -H "$artifact_root" -type l -print0)',
1941
+ '',
1942
+ ' while IFS= read -r -d \'\' candidate; do',
1943
+ ' if [ "$candidate" = "$artifact_root" ]; then',
1944
+ ' relative_candidate="$(basename "$candidate")"',
1945
+ ' else',
1946
+ [
1947
+ ' relative_candidate="',
1948
+ '$',
1949
+ '{candidate#"$artifact_root"/}"',
1950
+ ].join(''),
1951
+ ' fi',
1952
+ '',
1953
+ ' case "/$relative_candidate" in',
1954
+ ' */.env|*/.env.*|*/.npmrc|*/.netrc|*/.ssh|*/.ssh/*|*/.aws|*/.aws/*|*/.git|*/.git/*)',
1955
+ ' echo "Artifact contains a sensitive hidden path: $candidate" >&2',
1956
+ ' exit 1',
1957
+ ' ;;',
1958
+ ' esac',
1959
+ ' done < <(find -H "$artifact_root" -print0)',
1960
+ '',
1961
+ ' if [ -d "$artifact_root" ]; then',
1962
+ ' if ! first_file="$(find -L "$artifact_root" -type f -print -quit)"; then',
1963
+ ' echo "Artifact root could not be traversed safely: $artifact_root" >&2',
1964
+ ' exit 1',
1965
+ ' fi',
1966
+ ' else',
1967
+ ' first_file="$resolved_root"',
1968
+ ' fi',
1969
+ '',
1970
+ ' if [ -z "$first_file" ]; then',
1971
+ ' echo "Artifact root contains no files: $artifact_root" >&2',
1972
+ ' exit 1',
1973
+ ' fi',
1974
+ '}',
1975
+ '',
1976
+ ...rootLines,
1977
+ ];
1978
+ return {
1979
+ name,
1980
+ run: lines.join('\n'),
1981
+ runBlock: true,
1982
+ };
1983
+ }
1669
1984
  static buildContainerArtifactSteps(platforms) {
1670
1985
  const platformList = platforms.join(',');
1671
1986
  return [
@@ -1720,6 +2035,7 @@ export class Runner {
1720
2035
  name: 'Record OCI digest',
1721
2036
  run: `printf '%s' '${Runner.expr('steps.build-oci.outputs.digest')}' > "$RUNNER_TEMP/container-oci/container-image.digest"`,
1722
2037
  },
2038
+ Runner.buildArtifactPreflightStep('Validate immutable OCI artifact', ['container-oci'], Runner.expr('runner.temp')),
1723
2039
  {
1724
2040
  name: 'Upload immutable OCI artifact',
1725
2041
  uses: getScaffoldVersion('workflowActionUploadArtifact'),
@@ -1732,6 +2048,14 @@ export class Runner {
1732
2048
  key: 'retention-days',
1733
2049
  value: 1,
1734
2050
  },
2051
+ {
2052
+ key: 'include-hidden-files',
2053
+ value: true,
2054
+ },
2055
+ {
2056
+ key: 'if-no-files-found',
2057
+ value: 'error',
2058
+ },
1735
2059
  {
1736
2060
  key: 'path',
1737
2061
  value: `${Runner.expr('runner.temp')}/container-oci`,
@@ -2099,6 +2423,13 @@ export class Runner {
2099
2423
  const workspaceFlags = selectedNames.map((workspaceName) => `--workspace ${workspaceName}`).join(' ');
2100
2424
  return `${packageManager} run ${scriptName} -- ${workspaceFlags}`;
2101
2425
  }
2426
+ static corepackBootstrapRun(packageManager) {
2427
+ const corepackVersion = getScaffoldVersion('corepack');
2428
+ return [
2429
+ `npm install --global corepack@${corepackVersion}`,
2430
+ `corepack enable ${packageManager}`,
2431
+ ].join('\n');
2432
+ }
2102
2433
  static corepackDownloadCommand(packageManager, packageName, commandArguments) {
2103
2434
  if (packageManager === 'npm') {
2104
2435
  return `npx -y ${packageName} ${commandArguments}`;
@@ -2118,8 +2449,11 @@ export class Runner {
2118
2449
  return `yarn exec ${command}`;
2119
2450
  }
2120
2451
  static installPackagesRun(packageManager) {
2452
+ if (packageManager === 'npm') {
2453
+ return 'npm install';
2454
+ }
2121
2455
  return [
2122
- `corepack enable ${packageManager}`,
2456
+ Runner.corepackBootstrapRun(packageManager),
2123
2457
  `${packageManager} install`,
2124
2458
  ].join('\n');
2125
2459
  }
@@ -2226,7 +2560,7 @@ export class Runner {
2226
2560
  ...extraEnv,
2227
2561
  ...runtimeValues.map((value) => ({
2228
2562
  key: value['key'],
2229
- value: (value['secret'] === true) ? Runner.expr(`secrets.${value['name']}`) : Runner.expr(`vars.${value['name']}`),
2563
+ value: Runner.resolveDeliveryValueExpr(value),
2230
2564
  })),
2231
2565
  ];
2232
2566
  const lines = [];
@@ -2288,7 +2622,7 @@ export class Runner {
2288
2622
  workingDirectory: workingDir,
2289
2623
  };
2290
2624
  }
2291
- static appBuildValues(environment, appPath) {
2625
+ static appBuildValues(environment, appPath, profileAware = false) {
2292
2626
  const results = [];
2293
2627
  if (environment === undefined) {
2294
2628
  return results;
@@ -2311,6 +2645,10 @@ export class Runner {
2311
2645
  name: libEnvNamespace.githubName(prefix, variable['key']),
2312
2646
  secret: variable['secret'],
2313
2647
  };
2648
+ if (profileAware === true) {
2649
+ buildValue.stagingName = libEnvNamespace.githubProfileName(prefix, 'staging', variable['key']);
2650
+ buildValue.productionName = libEnvNamespace.githubProfileName(prefix, 'production', variable['key']);
2651
+ }
2314
2652
  if (variable['defaultValue'] !== undefined) {
2315
2653
  buildValue.defaultValue = variable['defaultValue'];
2316
2654
  }
@@ -2318,7 +2656,7 @@ export class Runner {
2318
2656
  }
2319
2657
  return results;
2320
2658
  }
2321
- static appRuntimeValues(environment, appPath) {
2659
+ static appRuntimeValues(environment, appPath, profileAware = false) {
2322
2660
  const results = [];
2323
2661
  if (environment === undefined) {
2324
2662
  return results;
@@ -2336,11 +2674,19 @@ export class Runner {
2336
2674
  if (variable['reach'] !== 'runtime') {
2337
2675
  continue;
2338
2676
  }
2339
- results.push({
2677
+ const runtimeValue = {
2340
2678
  key: variable['key'],
2341
2679
  name: libEnvNamespace.githubName(prefix, variable['key']),
2342
2680
  secret: variable['secret'],
2343
- });
2681
+ };
2682
+ if (profileAware === true) {
2683
+ runtimeValue.stagingName = libEnvNamespace.githubProfileName(prefix, 'staging', variable['key']);
2684
+ runtimeValue.productionName = libEnvNamespace.githubProfileName(prefix, 'production', variable['key']);
2685
+ }
2686
+ if (variable['defaultValue'] !== undefined) {
2687
+ runtimeValue.defaultValue = variable['defaultValue'];
2688
+ }
2689
+ results.push(runtimeValue);
2344
2690
  }
2345
2691
  return results;
2346
2692
  }
@@ -2478,6 +2824,12 @@ export class Runner {
2478
2824
  lines.push(` required: ${Runner.serializeScalar(input['required'])}`);
2479
2825
  lines.push(` type: ${Runner.quote(input['type'])}`);
2480
2826
  lines.push(` default: ${Runner.serializeScalar(input['default'])}`);
2827
+ if (input['options'] !== undefined) {
2828
+ lines.push(' options:');
2829
+ for (const option of input['options']) {
2830
+ lines.push(` - ${Runner.quote(option)}`);
2831
+ }
2832
+ }
2481
2833
  }
2482
2834
  }
2483
2835
  }
@@ -2653,7 +3005,14 @@ export class Runner {
2653
3005
  ].join('');
2654
3006
  return `${dollarBrace}{ ${inner} }}`;
2655
3007
  }
2656
- static resolveScopedCredExpr(variables, variableName, targetSettings, workflowSettings, environment, appPath) {
3008
+ static resolveDeliveryValueExpr(value) {
3009
+ const namespace = (value['secret'] === true) ? 'secrets' : 'vars';
3010
+ if (value['stagingName'] !== undefined && value['productionName'] !== undefined) {
3011
+ return Runner.expr(`env.DEPLOY_ENVIRONMENT == 'staging' && ${namespace}.${value['stagingName']} || ${namespace}.${value['productionName']}`);
3012
+ }
3013
+ return Runner.expr(`${namespace}.${value['name']}`);
3014
+ }
3015
+ static resolveScopedCredExpr(variables, variableName, targetSettings, workflowSettings, environment, appPath, profileAware = false) {
2657
3016
  const variableMeta = variables[variableName] ?? { format: 'literal' };
2658
3017
  const scope = variableMeta['scope'];
2659
3018
  let prefix = undefined;
@@ -2672,8 +3031,25 @@ export class Runner {
2672
3031
  prefix = workspacePrefix;
2673
3032
  }
2674
3033
  }
3034
+ if (profileAware === true) {
3035
+ return Runner.resolveProfiledVariableExpr(variables, variableName, targetSettings, workflowSettings, prefix);
3036
+ }
2675
3037
  return Runner.resolveVariableExpr(variables, variableName, targetSettings, workflowSettings, prefix);
2676
3038
  }
3039
+ static resolveProfiledVariableExpr(variables, variableName, targetSettings, workflowSettings, prefix) {
3040
+ const variableMeta = variables[variableName] ?? { format: 'literal' };
3041
+ const isPrefixable = prefix !== undefined
3042
+ && prefix !== ''
3043
+ && variableMeta['auto'] !== true
3044
+ && variableMeta['format'] !== 'literal';
3045
+ if (isPrefixable === false || prefix === undefined) {
3046
+ return Runner.resolveVariableExpr(variables, variableName, targetSettings, workflowSettings, prefix);
3047
+ }
3048
+ const stagingName = libEnvNamespace.githubProfileName(prefix, 'staging', variableName);
3049
+ const productionName = libEnvNamespace.githubProfileName(prefix, 'production', variableName);
3050
+ const namespace = (variableMeta['format'] === 'secret') ? 'secrets' : 'vars';
3051
+ return Runner.expr(`env.DEPLOY_ENVIRONMENT == 'staging' && ${namespace}.${stagingName} || ${namespace}.${productionName}`);
3052
+ }
2677
3053
  static resolveVariableExpr(variables, variableName, targetSettings, workflowSettings, prefix = undefined) {
2678
3054
  const variableMeta = variables[variableName] ?? { format: 'literal' };
2679
3055
  const isPrefixable = (prefix !== undefined