Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
125 changes: 125 additions & 0 deletions API.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 12 additions & 1 deletion src/awscdk/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Component, TextFile, awscdk } from 'projen';
import { PROJEN_MARKER } from 'projen/lib/common';
import { NodePackageManager } from 'projen/lib/javascript';
import { PipelineEngine } from '../engine';
import { AwsAssumeRoleStep, PipelineStep, ProjenScriptStep, SimpleCommandStep, StepSequence } from '../steps';
import { AwsAssumeRoleStep, PipelineStep, ProjenScriptStep, SimpleCommandStep, StepSequence, PnpmSetupStep } from '../steps';
import { VersioningConfig, VersioningSetup } from '../versioning';

/**
Expand Down Expand Up @@ -251,6 +251,14 @@ export abstract class CDKPipeline extends Component {

protected provideInstallStep(): PipelineStep {
const seq = new StepSequence(this.project, this.baseOptions.preInstallSteps ?? []);

// Detect and add pnpm setup if needed (GitHub only)
if (this.app.package.packageManager === NodePackageManager.PNPM && this.engineType() === PipelineEngine.GITHUB) {
seq.addSteps(new PnpmSetupStep(this.project, {
version: (this.app.package as any).pnpmVersion,
}));
}

if (this.baseOptions.preInstallCommands) {
seq.addSteps(new SimpleCommandStep(this.project, this.baseOptions.preInstallCommands));
}
Expand Down Expand Up @@ -365,6 +373,9 @@ export abstract class CDKPipeline extends Component {
case NodePackageManager.NPM:
commands.push(`npm install ${packageName}`);
break;
case NodePackageManager.PNPM:
commands.push(`pnpm add ${packageName}`);
break;
default:
throw new Error('No install scripts for packageManager: ' + this.app.package.packageManager);
}
Expand Down
3 changes: 2 additions & 1 deletion src/steps/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ export * from './step';
export * from './artifact-steps';
export * from './aws-assume-role.step';
export * from './registries';
export * from './amplify-deploy.step';
export * from './amplify-deploy.step';
export * from './package-manager-setup.step';
41 changes: 41 additions & 0 deletions src/steps/package-manager-setup.step.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { Project } from 'projen';
import { GithubStepConfig, PipelineStep } from './step';

/**
* Options for the PnpmSetupStep.
*/
export interface PnpmSetupStepOptions {
/**
* The version of pnpm to install.
* If not provided, defaults to '9'.
*/
readonly version?: string;
}

/**
* Step to setup pnpm using the pnpm/action-setup GitHub Action.
*
* This step is automatically injected when a project uses pnpm as its package manager.
* It ensures pnpm is available in the GitHub Actions workflow environment before
* running any install commands.
*/
export class PnpmSetupStep extends PipelineStep {

constructor(project: Project, private options: PnpmSetupStepOptions = {}) {
super(project);
}

public toGithub(): GithubStepConfig {
return {
env: {},
needs: [],
steps: [{
name: 'Setup pnpm',
uses: 'pnpm/action-setup@v4',
with: {
version: this.options.version ?? '9',
},
}],
};
}
}