in projenrc/abstract/pdk-project.ts [48:179]
constructor(options: PDKProjectOptions) {
const name = `${PDK_NAMESPACE}${options.name}`;
super({
...options,
packageManager: NodePackageManager.PNPM,
projenCommand: NodePackageUtils.command.projen(NodePackageManager.PNPM),
stability: options.stability || Stability.EXPERIMENTAL,
github: false,
depsUpgrade: false,
sampleCode: false,
docgen: false,
prettier: true,
releaseToNpm: options.releaseToNpm ?? false,
projenDevDependency: false,
jsiiVersion: "*",
srcdir: "src",
testdir: "test",
name,
packageName: name,
outdir: `packages/${options.name}`,
gitignore: [...(options.gitignore || []), "LICENSE_THIRD_PARTY"],
disableTsconfigDev: false,
disableTsconfig: true,
publishToPypi: {
distName: "aws_pdk",
module: "aws_pdk",
},
publishToMaven: {
mavenEndpoint: "https://aws.oss.sonatype.org",
mavenGroupId: "software.aws",
mavenArtifactId: "pdk",
javaPackage: "software.aws.pdk",
},
});
this.preCompileTask.prependExec("rm -f tsconfig.json");
this.postCompileTask.prependExec("rm -f tsconfig.json");
this.packageTask.reset();
this.options = options;
if (
options.stability &&
!Object.values(Stability).find((f) => f === options.stability)
) {
throw new Error(`stability must be one of: ${Object.values(Stability)}`);
}
if (this.deps.all.find((dep) => AWS_PDK === dep.name)) {
throw new Error("PDK Projects cannot have a dependency on the @aws/pdk!");
}
if (!this.parent) {
throw new Error("parent must be provided!");
}
if (options.sampleCode !== false) {
new SampleDir(this, this.srcdir, {
files: {
"index.ts": "// export * from 'my-construct';",
},
});
new SampleDir(this, this.testdir, {
files: {
".gitkeep": "// Delete me once tests are added",
},
});
}
if (options.eslint !== false) {
this.eslint?.addIgnorePattern("scripts/**/*.ts");
const eslintTask = this.tasks.tryFind("eslint");
eslintTask?.reset(
`eslint --ext .ts,.tsx \${CI:-'--fix'} --no-error-on-unmatched-pattern ${this.srcdir} ${this.testdir}`,
{ receiveArgs: true }
);
eslintTask && this.testTask.spawn(eslintTask);
this.addTask("eslint-staged", {
description: "Run eslint against the staged files only",
steps: [
{
exec: "eslint --fix --no-error-on-unmatched-pattern $(git diff --name-only --relative --staged HEAD . | grep -E '.(ts|tsx)$' | grep -v 'samples/*' | xargs)",
},
],
});
this.packageTask.spawn(eslintTask!);
}
if (options.jest !== false) {
const jestTask =
this.jest &&
this.addTask("jest", {
exec: [
"jest",
"--passWithNoTests",
// Only update snapshot locally
"${CI:-'--updateSnapshot'}",
// Always run in band for nx runner (nx run-many)
"${NX_WORKSPACE_ROOT:+'--runInBand'}",
].join(" "),
receiveArgs: true,
});
this.testTask.reset();
jestTask && this.testTask.spawn(jestTask);
// Most PDK tests rely on projen's test behaviour of synthing to a temporary directory
// See: https://github.com/projen/projen/issues/2947
this.testTask.env("PROJEN_SELF_TEST", "true");
}
if (options.releaseToNpm !== true) {
this.tasks.tryFind("package-all")?.reset();
}
if (!!options.publishConfig) {
this.package.addField("publishConfig", {
access: "public",
...options.publishConfig,
});
}
this.nx = NxProject.ensure(this);
options.nx && this.nx.merge(options.nx);
options.docgen !== false && new PDKDocgen(this);
// Suppress JSII upgrade warnings
this.tasks.addEnvironment("JSII_SUPPRESS_UPGRADE_PROMPT", "true");
this.generateReadme(options.name);
}