Skip to content

Some projen configuration recommendations #662

Description

@mrgrain

Hi! projen maintainer here! I saw your PR here to workaround some recent issues you had with projen. Firstly, sorry about that! The task shell change was a big one and unfortunately not without issues.

While I was investigating the issue, I found some minor things you could improve in your projen config. Just sharing in case you want to fix them. Hope this is useful to you. Feel free to close and ignore!


project.tasks.shell = TaskShell.system();

Not needed anymore, once this upstream PR is released projen/projen#4854


githubActions.set(
"peter-evans/create-pull-request",
"peter-evans/create-pull-request@22a9089034f40e5a961c8808d113e2c98fb63676", // v7
);

githubActions.set(
"actions/setup-node",
"actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444", // v5
);

Some actions now publish immutable releases. Might be easier for users to look at an immutable tag.


// Use a protected environment for the upgrade workflow to access the environment secrets
project.github?.tryFindWorkflow("upgrade")?.file?.patch(
JsonPatch.add("/jobs/pr/environment", {
name: "protected-main-env",
}),
);

Instead, add this to your credentials and the environment will automatically be filled whenever the credentials are used:

      projenCredentials: github.GithubCredentials.fromApp({
        appIdSecret: "GH_APP_ID",
        privateKeySecret: "GH_APP_PRIVATE_KEY",
        environment: "protected-main-env",
      }),

project.github?.tryFindWorkflow("upgrade")?.file?.patch(
JsonPatch.add("/jobs/upgrade/steps/1", {
name: "Enable Corepack",
run: "corepack enable",
}),
);

Can be removed, since corepack is now automatically enabled by projen. Currently you enable it twice.


project.github?.tryFindWorkflow("upgrade")?.file?.patch(
JsonPatch.add("/jobs/upgrade/steps/5/env", {
YARN_ENABLE_IMMUTABLE_INSTALLS: "false",
}),
);

Similar, this is now also handled by projen natively (but set in the task, not the workflow) and can be removed.


projenTasks.addDeletionOverride("tasks.clobber");
projenTasks.addDeletionOverride("tasks.test:update");
projenTasks.addDeletionOverride("tasks.release");
projenTasks.addDeletionOverride("tasks.bump");
projenTasks.addDeletionOverride("tasks.compat");
projenTasks.addDeletionOverride("tasks.test:compile");

const npmScripts = project.tryFindObjectFile("package.json")!;
npmScripts.addDeletionOverride("scripts.clobber");
npmScripts.addDeletionOverride("scripts.test:update");
npmScripts.addDeletionOverride("scripts.release");
npmScripts.addDeletionOverride("scripts.bump");
npmScripts.addDeletionOverride("scripts.compat");
projenTasks.addDeletionOverride("scripts.test:compile");

Some of these are seemingly not working today, but the easiest way to completely remove a task everywhere is:

project.tasks.removeTask("clobber");

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions