-
Notifications
You must be signed in to change notification settings - Fork 19
Working with dependencies and tooling
As a blueprint author, you might need to add packages to your blueprint, such as @amazon-codecatalyst/blueprint-component.environments
. You need to update the projen.ts
file with that package, and then regenerate the configuration of your project with Projen. Projen acts as the project model for each blueprint codebase, which provides the ability to push backwards-compatible tooling updates by changing the way that the model renders configuration files. The package.json
file is a file that is partially owned by the Projen model. Projen acknowledges dependency versions included in the package.json file, but other options need to originate from the model.
To add a dependency and update a projenrc.ts
file
- In the
projen.ts
file, navigate to thedeps
section. - Add the dependency you want to use in your blueprint.
- Use the following command to regenerate the configuration of your project:
yarn projen && yarn
After a Yarn update, you might get the following error regarding a repository parameter:
Type 'SourceRepository' is missing the following properties from type 'SourceRepository': synthesisSteps, addSynthesisStep
The error is due a dependency mismatch that happens when one component relies on a newer version of another component, but the relying component is pinned to an older version. The error can be fixed by making all your components rely on the same version so that the version synchronized between them. It’s best to keep al blueprint-vended packages under the same latest version (0.0.x
), unless you’re certain about how you’re handling the versions. The following example shows how the package.json
file can be configured so all the dependencies rely on the same version:
...
"@caws-blueprint-component/caws-environments": "^0.1.12345",
"@caws-blueprint-component/caws-source-repositories": "^0.1.12345",
"@caws-blueprint-component/caws-workflows": "^0.1.12345",
"@caws-blueprint-component/caws-workspaces": "^0.1.12345",
"@caws-blueprint-util/blueprint-utils": "^0.1.12345",
...
"@caws-blueprint/blueprints.blueprint": "*",
After configuring the versions for all dependencies, use the following command:
yarn install
Blueprints use Yarn for tooling. Using npm and Yarn will cause tooling problems because the way that dependency trees are resolved by each is different. To avoid such issues, it’s best to use Yarn only.
If you accidentally installed dependencies using npm, you can remove the generated package-lock.json
file, and make sure your .projenrc.ts
file is updated with the dependencies you need. You regenerate the configuration of your project with Projen.
Use the following to regenerate from the model:
yarn projen
After making sure your .projenrc.ts file is updated with the necessary dependencies, use the following command:
yarn
Occasionally, you might want to upgrade your tooling and components to bring in new features available. You’re recommended to keep all the components on the same version unless you’re certain about how you’re handling the versions. Versions are synchronized between components, so the same versions for all components ensures proper dependency between them.
Use the following command to upgrade utils and components from the root of a custom blueprint’s repository:
yarn upgrade @amazon-codecatalyst/*
Use the following command if you’re not using a monorepo:
yarn upgrade —pattern @amazon-codecatalyst/*
Other options you can use to upgrade tooling and components:
- Use
npm view @caws-blueprint-component/<some-component>
to get the latest version. - Manually increase to the latest version by setting the version in your package.json file and using the following command:
yarn
. All components and utils should have the same version.