Skip to content

Commit

Permalink
chore: add fallback scenario - if process.version is missing we check…
Browse files Browse the repository at this point in the history
… package.json for `engines.node` and remove non-semver characters
  • Loading branch information
RobertPechaCZ committed Nov 21, 2024
1 parent 115c70c commit 57bcd36
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/commands/sites/utils/prepareGitHubActionsIntegration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { getDeploymentWorkflowYamlLocation } from './getDeploymentWorkflowYamlLo
import { initializeDeploymentWorkflowDirectory } from './initializeDeploymentWorkflowDirectory';
import { requestDeploymentWorkflowInstallCommand } from './requestDeploymentWorkflowInstallCommand';
import { saveDeploymentWorkflowYaml } from './saveDeploymentWorkflowYaml';
import { loadJSONFromPackageRoot } from '../../../utils/json';

export const ghWorkflowFilename = 'fleek-deploy.yaml';
export const ghActionsWorflowsDirectory = joinPath(
Expand All @@ -34,9 +35,20 @@ export const prepareGitHubActionsIntegration = async ({
fleekConfigPath,
output,
}: PrepareGitHubActionsIntegrationArgs) => {
let nodeSemver = process.version;

if (!nodeSemver) {
try {
nodeSemver = loadJSONFromPackageRoot('package.json').engines.node.replace(
/[^0-9\.]+/,
'',
);
} catch {}
}

const installCommand = await requestDeploymentWorkflowInstallCommand();
const yamlContent = generateDeploymentWorkflowYaml({
nodeVersion: parseSemver(process.version)?.major ?? 18,
nodeVersion: parseSemver(nodeSemver)?.major ?? 18,
fleekConfigPath,
installCommand,
});
Expand Down

0 comments on commit 57bcd36

Please sign in to comment.