Skip to content

Commit

Permalink
fix: address problems uncovered when testing deprecating Hashicups (#377
Browse files Browse the repository at this point in the history
)

Reverts #376 because I deduced the problem was introduced in a different
place.

Also attempts to address problems with the Go and NPM deprecation steps
that I couldn't test until after releasing Hashicups.
  • Loading branch information
xiehan authored Dec 19, 2023
1 parent 3aa7823 commit b99b7f4
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 33 deletions.
10 changes: 7 additions & 3 deletions src/deprecate-packages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,12 @@ export class DeprecatePackages {
`// but these will not be compatible with newer versions of CDK for Terraform and are not eligible for commercial support.`,
`// You can continue to use the ${providerName} provider in your CDK for Terraform projects with newer versions of CDKTF,`,
`// but you will need to generate the bindings locally. See https://cdk.tf/imports for details.`,
].join("\n");
``,
].join("\\n");

const deprecationStep: JobStep = {
name: "Mark the Go module as deprecated",
run: `find '.repo/dist/go' -mindepth 2 -maxdepth 4 -type f -name 'go.mod' | xargs sed -i '1s|^|${deprecationMessageForGo} \n|'`,
run: `find '.repo/dist/go' -mindepth 2 -maxdepth 4 -type f -name 'go.mod' | xargs sed -i '1s|^|${deprecationMessageForGo}|'`,
continueOnError: true, // @TODO remove this once we confirm it to be working
};
if (isDeprecated) {
Expand Down Expand Up @@ -70,7 +71,10 @@ export class DeprecatePackages {
{
name: "Deprecate the package on NPM",
if: "steps.check_status.outputs.is_deprecated",
run: `npm deprecate ${packageInfo.npm.name} "${deprecationMessageForNPM}"`,
run: [
'npm set "//$NPM_REGISTRY/:_authToken=$NPM_TOKEN"',
`npm deprecate ${packageInfo.npm.name} "${deprecationMessageForNPM}"`,
].join("\n"),
env: {
NPM_REGISTRY: project.package.npmRegistry,
NPM_TOKEN:
Expand Down
17 changes: 1 addition & 16 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -392,10 +392,10 @@ export class CdktfProviderProject extends cdk.JsiiProject {
],
});

const releaseTask = this.tasks.tryFind("release")!;
if (!isDeprecated) {
new ShouldReleaseScriptFile(this, {});

const releaseTask = this.tasks.tryFind("release")!;
this.removeTask("release");
this.addTask("release", {
description: releaseTask.description,
Expand All @@ -420,21 +420,6 @@ export class CdktfProviderProject extends cdk.JsiiProject {
gitRemoteJob.name +=
" or cancel via faking a SHA if release was cancelled";
}
if (isDeprecated) {
// It's not clear to me why, but 'unbump' doesn't seem to have an effect and `npx projen release` fails
// This isn't a very elegant solution but I also don't feel like fighting Projen over an edge case
const releaseTaskSteps = releaseTask.steps;
releaseTaskSteps.splice(-1, 0, {
exec: "git checkout HEAD -- package.json",
});

this.removeTask("release");
this.addTask("release", {
description: releaseTask.description,
steps: releaseTaskSteps,
env: (releaseTask as any)._env,
});
}

// Submodule documentation generation
this.gitignore.exclude("API.md"); // ignore the old file, we now generate it in the docs folder
Expand Down
27 changes: 13 additions & 14 deletions test/__snapshots__/index.test.ts.snap

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

0 comments on commit b99b7f4

Please sign in to comment.