constructor()

in projenrc/projects/type-safe-api-project.ts [16:125]


  constructor(parent: Project) {
    super({
      parent,
      author: "AWS APJ COPE",
      authorAddress: "apj-cope@amazon.com",
      defaultReleaseBranch: "mainline",
      name: "type-safe-api",
      keywords: [
        "aws",
        "pdk",
        "projen",
        "openapi",
        "smithy",
        "api",
        "type-safe",
      ],
      repositoryUrl: "https://github.com/aws/aws-pdk",
      devDeps: [
        "@types/fs-extra",
        "@types/lodash",
        "aws-cdk-lib",
        "cdk-nag",
        "constructs",
        "projen",
        "@aws-sdk/client-s3",
        "@aws-sdk/client-apigatewayv2",
        `${PDK_NAMESPACE}monorepo@^0.x`,
        "@apidevtools/swagger-parser@10.1.0", // Used by scripts
        "ts-command-line-args@2.4.2", // Used by scripts
        "@faker-js/faker@8.1.0", // Used by scripts
        "reregexp@1.6.1", // Used by scripts
        "ejs@3.1.10", // Used by scripts
        "@types/ejs@3.1.5", // Used by scripts
        "parse-openapi@0.0.1", // Used by scripts
        "minimatch@10.0.1", // Used by scripts
        "esbuild",
      ],
      deps: [
        `${PDK_NAMESPACE}pdk-nag@^0.x`,
        `${PDK_NAMESPACE}monorepo@^0.x`,
        "fs-extra",
      ],
      bundledDeps: ["fs-extra", "lodash", "log4js", "openapi-types"],
      peerDeps: ["aws-cdk-lib", "cdk-nag", "constructs", "projen"],
      stability: Stability.STABLE,
      eslintOptions: {
        dirs: ["src"],
      },
      jestOptions: {
        jestConfig: {
          globalSetup: "<rootDir>/jest.setup.ts",
        },
      },
      publishConfig: {
        executableFiles: [
          "scripts/type-safe-api/run.js",
          "scripts/type-safe-api/custom/gradle-wrapper/gradlew",
          "scripts/type-safe-api/custom/gradle-wrapper/gradlew.bat",
        ],
      },
      bin: {
        "type-safe-api": "scripts/type-safe-api/run.js",
      },
    });

    this.gitignore.exclude("tmp\\.*");
    this.eslint?.addRules({ "import/no-unresolved": ["off"] });
    this.tsconfigEslint!.addInclude("scripts");

    // Depend on the smithy transformer project
    const smithyAsyncTransformer = parent.subprojects.find(
      (p) => p.name === SmithyAsyncTransformerProject.NAME
    )! as JavaProject;
    NxProject.of(this)?.addImplicitDependency(smithyAsyncTransformer);

    // Copy the transformer jar into the script dir
    const smithyAsyncTransformerJar =
      "scripts/type-safe-api/custom/smithy-async-transformer/aws-pdk-smithy-async-transformer.jar";
    this.preCompileTask.exec(
      `cp ${path.join(
        path.relative(this.outdir, smithyAsyncTransformer.outdir),
        ...[
          smithyAsyncTransformer.distdir,
          ...smithyAsyncTransformer.pom.groupId.split("."),
          smithyAsyncTransformer.pom.artifactId,
          smithyAsyncTransformer.pom.version,
          `${smithyAsyncTransformer.pom.artifactId}-${smithyAsyncTransformer.pom.version}.jar`,
        ]
      )} ${smithyAsyncTransformerJar}`
    );
    NxProject.of(this)?.addBuildTargetFiles(
      [],
      [`{projectRoot}/${smithyAsyncTransformerJar}`]
    );
    this.gitignore.addPatterns(smithyAsyncTransformerJar);

    // Build the "run" script
    const runScript = "scripts/type-safe-api/run";
    this.preCompileTask.exec(
      `esbuild --bundle ${runScript}.ts --platform=node --outfile=${runScript}.js`
    );
    this.preCompileTask.exec(`chmod +x ${runScript}.js`);
    NxProject.of(this)?.addBuildTargetFiles(
      [],
      [`{projectRoot}/${runScript}.js`]
    );
    this.gitignore.addPatterns(`${runScript}.js`);

    this.generateInterfaces();
  }