diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 000000000..6a697a746 --- /dev/null +++ b/.eslintrc.json @@ -0,0 +1,339 @@ +// ~~ Generated by projen. To modify, edit .projenrc.ts and run "npx projen". +{ + "env": { + "jest": true, + "node": true + }, + "root": true, + "plugins": [ + "@typescript-eslint", + "import", + "@stylistic", + "@cdklabs", + "jest", + "jsdoc" + ], + "parser": "@typescript-eslint/parser", + "parserOptions": { + "ecmaVersion": 2018, + "sourceType": "module", + "project": "./tsconfig.dev.json" + }, + "extends": [ + "plugin:import/typescript", + "plugin:jest/recommended" + ], + "settings": { + "import/parsers": { + "@typescript-eslint/parser": [ + ".ts", + ".tsx" + ] + }, + "import/resolver": { + "node": {}, + "typescript": { + "project": "./tsconfig.dev.json", + "alwaysTryTypes": true + } + } + }, + "ignorePatterns": [ + "*.js", + "*.d.ts", + "node_modules/", + "*.generated.ts", + "coverage", + "*.generated.ts", + "!.projenrc.ts", + "!projenrc/**/*.ts" + ], + "rules": { + "indent": [ + "off" + ], + "@stylistic/indent": [ + "error", + 2 + ], + "quotes": [ + "error", + "single", + { + "avoidEscape": true + } + ], + "comma-dangle": [ + "error", + "always-multiline" + ], + "comma-spacing": [ + "error", + { + "before": false, + "after": true + } + ], + "no-multi-spaces": [ + "error", + { + "ignoreEOLComments": false + } + ], + "array-bracket-spacing": [ + "error", + "never" + ], + "array-bracket-newline": [ + "error", + "consistent" + ], + "object-curly-spacing": [ + "error", + "always" + ], + "object-curly-newline": [ + "error", + { + "multiline": true, + "consistent": true + } + ], + "object-property-newline": [ + "error", + { + "allowAllPropertiesOnSameLine": true + } + ], + "keyword-spacing": [ + "error" + ], + "brace-style": [ + "error", + "1tbs", + { + "allowSingleLine": true + } + ], + "space-before-blocks": "error", + "curly": [ + "error", + "multi-line", + "consistent" + ], + "@stylistic/member-delimiter-style": [ + "error" + ], + "semi": [ + "error", + "always" + ], + "max-len": [ + "error", + { + "code": 150, + "ignoreUrls": true, + "ignoreStrings": true, + "ignoreTemplateLiterals": true, + "ignoreComments": true, + "ignoreRegExpLiterals": true + } + ], + "quote-props": [ + "error", + "consistent-as-needed" + ], + "@typescript-eslint/no-require-imports": [ + "error" + ], + "import/no-extraneous-dependencies": [ + "error", + { + "devDependencies": [ + "**/projenrc/**", + "**/.projenrc.ts/**", + ".projenrc.ts", + "projenrc/**/*.ts" + ], + "optionalDependencies": false, + "peerDependencies": true + } + ], + "import/no-unresolved": [ + "error" + ], + "import/order": [ + "error", + { + "groups": [ + "builtin", + "external" + ], + "alphabetize": { + "order": "asc", + "caseInsensitive": true + } + } + ], + "import/no-duplicates": [ + "error" + ], + "no-shadow": [ + "off" + ], + "@typescript-eslint/no-shadow": [ + "error" + ], + "key-spacing": [ + "error" + ], + "no-multiple-empty-lines": [ + "error", + { + "max": 1 + } + ], + "@typescript-eslint/no-floating-promises": [ + "error" + ], + "no-return-await": "off", + "@typescript-eslint/return-await": "error", + "no-trailing-spaces": [ + "error" + ], + "dot-notation": [ + "error" + ], + "no-bitwise": [ + "error" + ], + "@typescript-eslint/member-ordering": [ + "error", + { + "default": [ + "public-static-field", + "public-static-method", + "protected-static-field", + "protected-static-method", + "private-static-field", + "private-static-method", + "field", + "constructor", + "method" + ] + } + ], + "@cdklabs/no-core-construct": [ + "error" + ], + "@cdklabs/invalid-cfn-imports": [ + "error" + ], + "@cdklabs/no-literal-partition": [ + "error" + ], + "@cdklabs/no-invalid-path": [ + "error" + ], + "@cdklabs/promiseall-no-unbounded-parallelism": [ + "error" + ], + "no-throw-literal": [ + "error" + ], + "@stylistic/comma-dangle": [ + "error", + "always-multiline" + ], + "@stylistic/no-extra-semi": [ + "error" + ], + "eol-last": [ + "error", + "always" + ], + "@stylistic/spaced-comment": [ + "error", + "always", + { + "exceptions": [ + "/", + "*" + ], + "markers": [ + "/" + ] + } + ], + "@stylistic/padded-blocks": [ + "error", + { + "classes": "never", + "blocks": "never", + "switches": "never" + } + ], + "jsdoc/require-param-description": [ + "error" + ], + "jsdoc/require-property-description": [ + "error" + ], + "jsdoc/require-returns-description": [ + "error" + ], + "jsdoc/check-alignment": [ + "error" + ], + "no-restricted-imports": [ + "error", + { + "paths": [ + { + "name": "punycode", + "message": "Package 'punycode' has to be imported with trailing slash, see warning in https://github.com/bestiejs/punycode.js#installation" + } + ], + "patterns": [ + "!punycode/" + ] + } + ], + "no-duplicate-imports": [ + "error" + ], + "no-console": [ + "error" + ], + "no-restricted-syntax": [ + "error", + { + "selector": "CallExpression:matches([callee.name='createHash'], [callee.property.name='createHash']) Literal[value='md5']", + "message": "Use the md5hash() function from the core library if you want md5" + } + ], + "jest/expect-expect": "off", + "jest/no-conditional-expect": "off", + "jest/no-done-callback": "off", + "jest/no-standalone-expect": "off", + "jest/valid-expect": "off", + "jest/valid-title": "off", + "jest/no-identical-title": "off", + "jest/no-disabled-tests": "error", + "jest/no-focused-tests": "error", + "prettier/prettier": [ + "off" + ] + }, + "overrides": [ + { + "files": [ + ".projenrc.ts" + ], + "rules": { + "@typescript-eslint/no-require-imports": "off", + "import/no-extraneous-dependencies": "off" + } + } + ] +} diff --git a/.gitattributes b/.gitattributes index f3c7e7852..0001d2d56 100644 --- a/.gitattributes +++ b/.gitattributes @@ -2,6 +2,7 @@ * text=auto eol=lf *.snap linguist-generated +/.eslintrc.json linguist-generated /.gitattributes linguist-generated /.github/dependabot.yml linguist-generated /.github/pull_request_template.md linguist-generated diff --git a/.gitignore b/.gitignore index a62d14711..b77d722d0 100644 --- a/.gitignore +++ b/.gitignore @@ -44,6 +44,7 @@ jspm_packages/ !/aws-cdk-cli.code-workspace /.nx !/nx.json +!/.eslintrc.json !/.github/dependabot.yml !/.github/workflows/integ.yml !/.projenrc.ts diff --git a/.npmignore b/.npmignore index 7271086a6..e1d696477 100644 --- a/.npmignore +++ b/.npmignore @@ -15,6 +15,7 @@ dist /.projenrc.js tsconfig.tsbuildinfo /.nx +/.eslintrc.json .eslintrc.js *.ts !*.d.ts diff --git a/.projen/deps.json b/.projen/deps.json index 1d0bd1727..2c4666797 100644 --- a/.projen/deps.json +++ b/.projen/deps.json @@ -1,5 +1,18 @@ { "dependencies": [ + { + "name": "@aws-sdk/client-s3", + "version": "3.741", + "type": "build" + }, + { + "name": "@aws-sdk/credential-providers", + "type": "build" + }, + { + "name": "@aws-sdk/lib-storage", + "type": "build" + }, { "name": "@cdklabs/eslint-plugin", "type": "build" @@ -32,6 +45,10 @@ "version": "^10.0.0", "type": "build" }, + { + "name": "eslint-import-resolver-typescript", + "type": "build" + }, { "name": "eslint-plugin-import", "type": "build" @@ -44,6 +61,15 @@ "name": "eslint-plugin-jsdoc", "type": "build" }, + { + "name": "eslint", + "version": "^9", + "type": "build" + }, + { + "name": "glob", + "type": "build" + }, { "name": "nx", "type": "build" @@ -57,6 +83,10 @@ "name": "projen", "type": "build" }, + { + "name": "semver", + "type": "build" + }, { "name": "ts-node", "type": "build" diff --git a/.projen/files.json b/.projen/files.json index 02d1ea8d0..eb5598b37 100644 --- a/.projen/files.json +++ b/.projen/files.json @@ -1,5 +1,6 @@ { "files": [ + ".eslintrc.json", ".gitattributes", ".github/dependabot.yml", ".github/pull_request_template.md", diff --git a/.projen/tasks.json b/.projen/tasks.json index 781bd55ec..7318f238d 100644 --- a/.projen/tasks.json +++ b/.projen/tasks.json @@ -61,6 +61,19 @@ } ] }, + "eslint": { + "name": "eslint", + "description": "Runs eslint against the codebase", + "env": { + "ESLINT_USE_FLAT_CONFIG": "false" + }, + "steps": [ + { + "exec": "eslint --ext .ts,.tsx --fix --no-error-on-unmatched-pattern $@ projenrc .projenrc.ts", + "receiveArgs": true + } + ] + }, "install": { "name": "install", "description": "Install project dependencies and update lockfile (non-frozen)", @@ -131,6 +144,9 @@ "steps": [ { "exec": "yarn workspaces run test" + }, + { + "spawn": "eslint" } ] }, diff --git a/.projenrc.ts b/.projenrc.ts index d7ce8aac0..ec2d5e81c 100644 --- a/.projenrc.ts +++ b/.projenrc.ts @@ -1,13 +1,13 @@ -import * as pj from 'projen'; import { yarn, CdkCliIntegTestsWorkflow } from 'cdklabs-projen-project-types'; +import * as pj from 'projen'; +import { Stability } from 'projen/lib/cdk'; +import { BundleCli } from './projenrc/bundle'; import { ESLINT_RULES } from './projenrc/eslint'; import { JsiiBuild } from './projenrc/jsii'; -import { BundleCli } from './projenrc/bundle'; -import { Stability } from 'projen/lib/cdk'; // 5.7 sometimes gives a weird error in `ts-jest` in `@aws-cdk/cli-lib-alpha` // https://github.com/microsoft/TypeScript/issues/60159 -const TYPESCRIPT_VERSION = "5.6"; +const TYPESCRIPT_VERSION = '5.6'; /** * Projen depends on TypeScript-eslint 7 by default. @@ -29,7 +29,7 @@ function configureProject(x: A): A { '@cdklabs/eslint-plugin', 'eslint-plugin-import', 'eslint-plugin-jest', - "eslint-plugin-jsdoc", + 'eslint-plugin-jsdoc', ); x.eslint?.addPlugins( '@typescript-eslint', @@ -113,70 +113,85 @@ function sharedJestConfig(): pj.javascript.JestConfigOptions { }; } -const repo = configureProject( - new yarn.Monorepo({ - projenrcTs: true, - name: 'aws-cdk-cli', - description: "Monorepo for the AWS CDK's CLI", - repository: 'https://github.com/aws/aws-cdk-cli', - - defaultReleaseBranch: 'main', - devDeps: [ - 'cdklabs-projen-project-types@^0.1.220', - ], - vscodeWorkspace: true, - vscodeWorkspaceOptions: { - includeRootWorkspace: true, - }, - nx: true, +const repoProject = new yarn.Monorepo({ + projenrcTs: true, + name: 'aws-cdk-cli', + description: "Monorepo for the AWS CDK's CLI", + repository: 'https://github.com/aws/aws-cdk-cli', + + defaultReleaseBranch: 'main', + devDeps: [ + 'cdklabs-projen-project-types@^0.1.220', + 'glob', + 'semver', + `@aws-sdk/client-s3@${CLI_SDK_V3_RANGE}`, + '@aws-sdk/credential-providers', + '@aws-sdk/lib-storage', + ], + vscodeWorkspace: true, + vscodeWorkspaceOptions: { + includeRootWorkspace: true, + }, + nx: true, - eslintOptions: { - dirs: ['lib'], - devdirs: ['test'], - }, + eslintOptions: { + dirs: ['lib'], + devdirs: ['test'], + }, - workflowNodeVersion: 'lts/*', - workflowRunsOn, - gitignore: ['.DS_Store'], + workflowNodeVersion: 'lts/*', + workflowRunsOn, + gitignore: ['.DS_Store'], - autoApproveUpgrades: true, - autoApproveOptions: { - allowedUsernames: ['aws-cdk-automation', 'dependabot[bot]'], - }, + autoApproveUpgrades: true, + autoApproveOptions: { + allowedUsernames: ['aws-cdk-automation', 'dependabot[bot]'], + }, - release: true, - releaseOptions: { - publishToNpm: true, - releaseTrigger: pj.release.ReleaseTrigger.workflowDispatch(), - }, + release: true, + releaseOptions: { + publishToNpm: true, + releaseTrigger: pj.release.ReleaseTrigger.workflowDispatch(), + }, - githubOptions: { - mergify: false, - mergeQueue: true, - pullRequestLintOptions: { - contributorStatement: "By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license", - contributorStatementOptions: { - exemptUsers: ["aws-cdk-automation", "dependabot[bot]"], - }, - semanticTitleOptions: { - types: ['feat', 'fix', 'chore', 'refactor', 'test', 'docs', 'revert'], - }, + githubOptions: { + mergify: false, + mergeQueue: true, + pullRequestLintOptions: { + contributorStatement: 'By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license', + contributorStatementOptions: { + exemptUsers: ['aws-cdk-automation', 'dependabot[bot]'], + }, + semanticTitleOptions: { + types: ['feat', 'fix', 'chore', 'refactor', 'test', 'docs', 'revert'], }, }, - buildWorkflowOptions: { - preBuildSteps: [ - // Need this for the init tests - { - name: 'Set git identity', - run: [ - 'git config --global user.name "aws-cdk-cli"', - 'git config --global user.email "noreply@example.com"', - ].join('\n'), - }, - ], - }, - }), -); + }, + buildWorkflowOptions: { + preBuildSteps: [ + // Need this for the init tests + { + name: 'Set git identity', + run: [ + 'git config --global user.name "aws-cdk-cli"', + 'git config --global user.email "noreply@example.com"', + ].join('\n'), + }, + ], + }, +}); + +// Eslint for projen config +// @ts-ignore +repoProject.eslint = new pj.javascript.Eslint(repoProject, { + tsconfigPath: `./${repoProject.tsconfigDev.fileName}`, + dirs: [], + devdirs: ['projenrc', '.projenrc.ts'], + fileExtensions: ['.ts', '.tsx'], + lintProjenRc: false, +}); + +const repo = configureProject(repoProject); interface GenericProps { private?: boolean; @@ -211,7 +226,7 @@ function genericCdkProps(props: GenericProps = {}) { }, typescriptVersion: TYPESCRIPT_VERSION, checkLicenses: props.private ? undefined : { - allow: ['Apache-2.0', 'MIT', 'ISC'] + allow: ['Apache-2.0', 'MIT', 'ISC'], }, ...props, } satisfies Partial; @@ -231,7 +246,7 @@ const cloudAssemblySchema = configureProject( disableTsconfig: true, // Append a specific version string for testing - nextVersionCommand: `tsx ../../../projenrc/next-version.ts majorFromRevision:schema/version.json maybeRc`, + nextVersionCommand: 'tsx ../../../projenrc/next-version.ts majorFromRevision:schema/version.json maybeRc', }), ); @@ -259,7 +274,7 @@ new JsiiBuild(cloudAssemblySchema, { 'Framework :: AWS CDK :: 2', ], publishToGo: { - moduleName: `github.com/cdklabs/cloud-assembly-schema-go`, + moduleName: 'github.com/cdklabs/cloud-assembly-schema-go', }, composite: true, }); @@ -300,7 +315,7 @@ const cloudFormationDiff = configureProject( }, // Append a specific version string for testing - nextVersionCommand: `tsx ../../../projenrc/next-version.ts maybeRc`, + nextVersionCommand: 'tsx ../../../projenrc/next-version.ts maybeRc', }), ); @@ -333,7 +348,7 @@ const cxApi = overrideEslint( "lint": "cdk-lint && madge --circular --extensions js lib", */ - /* +/* "awscdkio": { "announce": false }, @@ -522,7 +537,7 @@ const cdkAssets = configureProject( majorVersion: 3, // Append a specific version string for testing - nextVersionCommand: `tsx ../../projenrc/next-version.ts maybeRc`, + nextVersionCommand: 'tsx ../../projenrc/next-version.ts maybeRc', }), ); @@ -656,7 +671,7 @@ const cli = configureProject( 'strip-ansi@^6', 'table', 'uuid', - 'wrap-ansi@^7', // Last non-ESM version + 'wrap-ansi@^7', // Last non-ESM version 'yaml@^1', 'yargs@^15', ], @@ -689,7 +704,7 @@ const cli = configureProject( }, // Append a specific version string for testing - nextVersionCommand: `tsx ../../projenrc/next-version.ts maybeRc`, + nextVersionCommand: 'tsx ../../projenrc/next-version.ts maybeRc', }), ); @@ -698,9 +713,9 @@ cli.eslint?.addRules({ '@cdklabs/no-throw-default-error': ['error'], }); cli.eslint?.addOverride({ - files: ["./test/**"], + files: ['./test/**'], rules: { - "@cdklabs/no-throw-default-error": "off", + '@cdklabs/no-throw-default-error': 'off', }, }); @@ -719,44 +734,44 @@ cli.gitignore.addPatterns(...ADDITIONAL_CLI_IGNORE_PATTERNS); // People should not have imported from the `aws-cdk` package, but they have in the past. // We have identified all locations that are currently used, are maintaining a backwards compat // layer for those. Future imports will be rejected. -cli.package.addField("exports", { +cli.package.addField('exports', { // package.json is always reasonable - "./package.json": "./package.json", - "./build-info.json": "./build-info.json", + './package.json': './package.json', + './build-info.json': './build-info.json', // The rest is legacy - ".": "./lib/legacy-exports.js", - "./bin/cdk": "./bin/cdk", - "./lib/api/bootstrap/bootstrap-template.yaml": "./lib/api/bootstrap/bootstrap-template.yaml", - "./lib/util": "./lib/legacy-exports.js", - "./lib": "./lib/legacy-exports.js", - "./lib/api/plugin": "./lib/legacy-exports.js", - "./lib/util/content-hash": "./lib/legacy-exports.js", - "./lib/settings": "./lib/legacy-exports.js", - "./lib/api/bootstrap": "./lib/legacy-exports.js", - "./lib/api/cxapp/cloud-assembly": "./lib/legacy-exports.js", - "./lib/api/cxapp/cloud-executable": "./lib/legacy-exports.js", - "./lib/api/cxapp/exec": "./lib/legacy-exports.js", - "./lib/diff": "./lib/legacy-exports.js", - "./lib/api/util/string-manipulation": "./lib/legacy-exports.js", - "./lib/util/console-formatters": "./lib/legacy-exports.js", - "./lib/util/tracing": "./lib/legacy-exports.js", - "./lib/commands/docs": "./lib/legacy-exports.js", - "./lib/api/hotswap/common": "./lib/legacy-exports.js", - "./lib/util/objects": "./lib/legacy-exports.js", - "./lib/api/deployments": "./lib/legacy-exports.js", - "./lib/util/directories": "./lib/legacy-exports.js", - "./lib/version": "./lib/legacy-exports.js", - "./lib/init": "./lib/legacy-exports.js", - "./lib/api/aws-auth/cached": "./lib/legacy-exports.js", - "./lib/api/deploy-stack": "./lib/legacy-exports.js", - "./lib/api/evaluate-cloudformation-template": "./lib/legacy-exports.js", - "./lib/api/aws-auth/credential-plugins": "./lib/legacy-exports.js", - "./lib/api/aws-auth/awscli-compatible": "./lib/legacy-exports.js", - "./lib/notices": "./lib/legacy-exports.js", - "./lib/index": "./lib/legacy-exports.js", - "./lib/api/aws-auth/index.js": "./lib/legacy-exports.js", - "./lib/api/aws-auth": "./lib/legacy-exports.js", - "./lib/logging": "./lib/legacy-exports.js" + '.': './lib/legacy-exports.js', + './bin/cdk': './bin/cdk', + './lib/api/bootstrap/bootstrap-template.yaml': './lib/api/bootstrap/bootstrap-template.yaml', + './lib/util': './lib/legacy-exports.js', + './lib': './lib/legacy-exports.js', + './lib/api/plugin': './lib/legacy-exports.js', + './lib/util/content-hash': './lib/legacy-exports.js', + './lib/settings': './lib/legacy-exports.js', + './lib/api/bootstrap': './lib/legacy-exports.js', + './lib/api/cxapp/cloud-assembly': './lib/legacy-exports.js', + './lib/api/cxapp/cloud-executable': './lib/legacy-exports.js', + './lib/api/cxapp/exec': './lib/legacy-exports.js', + './lib/diff': './lib/legacy-exports.js', + './lib/api/util/string-manipulation': './lib/legacy-exports.js', + './lib/util/console-formatters': './lib/legacy-exports.js', + './lib/util/tracing': './lib/legacy-exports.js', + './lib/commands/docs': './lib/legacy-exports.js', + './lib/api/hotswap/common': './lib/legacy-exports.js', + './lib/util/objects': './lib/legacy-exports.js', + './lib/api/deployments': './lib/legacy-exports.js', + './lib/util/directories': './lib/legacy-exports.js', + './lib/version': './lib/legacy-exports.js', + './lib/init': './lib/legacy-exports.js', + './lib/api/aws-auth/cached': './lib/legacy-exports.js', + './lib/api/deploy-stack': './lib/legacy-exports.js', + './lib/api/evaluate-cloudformation-template': './lib/legacy-exports.js', + './lib/api/aws-auth/credential-plugins': './lib/legacy-exports.js', + './lib/api/aws-auth/awscli-compatible': './lib/legacy-exports.js', + './lib/notices': './lib/legacy-exports.js', + './lib/index': './lib/legacy-exports.js', + './lib/api/aws-auth/index.js': './lib/legacy-exports.js', + './lib/api/aws-auth': './lib/legacy-exports.js', + './lib/logging': './lib/legacy-exports.js', }); cli.gitignore.addPatterns('build-info.json'); @@ -767,8 +782,8 @@ cli.preCompileTask.prependExec('./generate.sh'); cli.preCompileTask.prependExec('ts-node scripts/user-input-gen.ts'); const includeCliResourcesCommands = [ - `cp $(node -p 'require.resolve("cdk-from-cfn/index_bg.wasm")') ./lib/`, - `cp $(node -p 'require.resolve("@aws-cdk/aws-service-spec/db.json.gz")') ./`, + 'cp $(node -p \'require.resolve("cdk-from-cfn/index_bg.wasm")\') ./lib/', + 'cp $(node -p \'require.resolve("@aws-cdk/aws-service-spec/db.json.gz")\') ./', ]; for (const resourceCommand of includeCliResourcesCommands) { @@ -779,9 +794,9 @@ Object.assign(cli.jest?.config ?? {}, { coveragePathIgnorePatterns: [ ...(cli.jest?.config.coveragePathIgnorePatterns ?? []), // Mostly wrappers around the SDK, which get mocked in unit tests - "/lib/api/aws-auth/sdk.ts", + '/lib/api/aws-auth/sdk.ts', ], - setupFilesAfterEnv: ["/test/jest-setup-after-env.ts"], + setupFilesAfterEnv: ['/test/jest-setup-after-env.ts'], }); new BundleCli(cli, { @@ -791,33 +806,33 @@ new BundleCli(cli, { ], }, allowedLicenses: [ - "Apache-2.0", - "MIT", - "BSD-3-Clause", - "ISC", - "BSD-2-Clause", - "0BSD", - "MIT OR Apache-2.0", + 'Apache-2.0', + 'MIT', + 'BSD-3-Clause', + 'ISC', + 'BSD-2-Clause', + '0BSD', + 'MIT OR Apache-2.0', ], - dontAttribute: "^@aws-cdk/|^@cdklabs/|^cdk-assets$|^cdk-cli-wrapper$", - test: "bin/cdk --version", + dontAttribute: '^@aws-cdk/|^@cdklabs/|^cdk-assets$|^cdk-cli-wrapper$', + test: 'bin/cdk --version', entryPoints: [ - "lib/index.js" + 'lib/index.js', ], minifyWhitespace: true, }); // Exclude takes precedence over include for (const tsconfig of [cli.tsconfig, cli.tsconfigDev]) { - tsconfig?.addExclude("lib/init-templates/*/typescript/*/*.template.ts"); - tsconfig?.addExclude("test/integ/cli/sam_cdk_integ_app/**/*"); - tsconfig?.addExclude("vendor/**/*"); + tsconfig?.addExclude('lib/init-templates/*/typescript/*/*.template.ts'); + tsconfig?.addExclude('test/integ/cli/sam_cdk_integ_app/**/*'); + tsconfig?.addExclude('vendor/**/*'); } ////////////////////////////////////////////////////////////////////// const CLI_LIB_EXCLUDE_PATTERNS = [ - "lib/init-templates/*/typescript/*/*.template.ts", + 'lib/init-templates/*/typescript/*/*.template.ts', ]; const cliLib = configureProject( @@ -854,26 +869,26 @@ cliLib.gitignore.addPatterns( new JsiiBuild(cliLib, { jsiiVersion: TYPESCRIPT_VERSION, publishToNuget: { - dotNetNamespace: "Amazon.CDK.Cli.Lib.Alpha", - "packageId": "Amazon.CDK.Cli.Lib.Alpha", - "iconUrl": "https://raw.githubusercontent.com/aws/aws-cdk/main/logo/default-256-dark.png" + dotNetNamespace: 'Amazon.CDK.Cli.Lib.Alpha', + packageId: 'Amazon.CDK.Cli.Lib.Alpha', + iconUrl: 'https://raw.githubusercontent.com/aws/aws-cdk/main/logo/default-256-dark.png', }, publishToMaven: { - javaPackage: "software.amazon.awscdk.cli.lib.alpha", - "mavenGroupId": "software.amazon.awscdk", - "mavenArtifactId": "cdk-cli-lib-alpha" + javaPackage: 'software.amazon.awscdk.cli.lib.alpha', + mavenGroupId: 'software.amazon.awscdk', + mavenArtifactId: 'cdk-cli-lib-alpha', }, publishToPypi: { - "distName": "aws-cdk.cli-lib-alpha", - "module": "aws_cdk.cli_lib_alpha", + distName: 'aws-cdk.cli-lib-alpha', + module: 'aws_cdk.cli_lib_alpha', }, pypiClassifiers: [ - "Framework :: AWS CDK", - "Framework :: AWS CDK :: 2" + 'Framework :: AWS CDK', + 'Framework :: AWS CDK :: 2', ], publishToGo: { - "moduleName": "github.com/aws/aws-cdk-go", - "packageName": "awscdkclilibalpha" + moduleName: 'github.com/aws/aws-cdk-go', + packageName: 'awscdkclilibalpha', }, rosettaStrict: true, stability: Stability.EXPERIMENTAL, @@ -887,7 +902,7 @@ cliLib.postCompileTask.exec('mkdir -p ./lib/api/bootstrap/ && cp ../../aws-cdk/l for (const resourceCommand of includeCliResourcesCommands) { cliLib.postCompileTask.exec(resourceCommand); } -cliLib.postCompileTask.exec(`cp $(node -p 'require.resolve("aws-cdk/build-info.json")') .`); +cliLib.postCompileTask.exec('cp $(node -p \'require.resolve("aws-cdk/build-info.json")\') .'); cliLib.postCompileTask.exec('esbuild --bundle lib/index.ts --target=node18 --platform=node --external:fsevents --minify-whitespace --outfile=lib/main.js'); cliLib.postCompileTask.exec('node ./lib/main.js >/dev/null /dev/null 2>/dev/null /dev/null 2>/dev/null /dev/null 2>/dev/null /dev/null 2>/dev/null ({ 'package-ecosystem': pkgEco, - directory: '/', - schedule: { interval: 'weekly' }, - labels: ['auto-approve'], + 'directory': '/', + 'schedule': { interval: 'weekly' }, + 'labels': ['auto-approve'], 'open-pull-requests-limit': 5, })), }, diff --git a/package.json b/package.json index 6e3484264..4eecf6a37 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,7 @@ "clobber": "npx projen clobber", "compile": "npx projen compile", "default": "npx projen default", + "eslint": "npx projen eslint", "package": "npx projen package", "post-upgrade": "npx projen post-upgrade", "release": "npx projen release", @@ -19,6 +20,9 @@ "projen": "npx projen" }, "devDependencies": { + "@aws-sdk/client-s3": "3.741", + "@aws-sdk/credential-providers": "^3.750.0", + "@aws-sdk/lib-storage": "^3.750.0", "@cdklabs/eslint-plugin": "^1.3.2", "@stylistic/eslint-plugin": "^2.13.0", "@types/node": "^22.13.4", @@ -26,12 +30,16 @@ "@typescript-eslint/parser": "^8", "cdklabs-projen-project-types": "^0.1.220", "constructs": "^10.0.0", + "eslint": "^9", + "eslint-import-resolver-typescript": "^3.8.2", "eslint-plugin-import": "^2.31.0", "eslint-plugin-jest": "^28.11.0", "eslint-plugin-jsdoc": "^50.6.3", + "glob": "^11.0.1", "nx": "^20.4.5", "prettier": "^2.8", "projen": "^0.91.12", + "semver": "^7.7.1", "ts-node": "^10.9.2", "typescript": "^5.7.3" }, diff --git a/packages/@aws-cdk/cdk-build-tools/.eslintrc.json b/packages/@aws-cdk/cdk-build-tools/.eslintrc.json index bb1114eb1..d65ae59f9 100644 --- a/packages/@aws-cdk/cdk-build-tools/.eslintrc.json +++ b/packages/@aws-cdk/cdk-build-tools/.eslintrc.json @@ -55,10 +55,11 @@ "error", { "devDependencies": [ - "**/build-tools/**", - "**/test/**" + "**/test/**", + "**/build-tools/**" ], - "optionalDependencies": false + "optionalDependencies": false, + "peerDependencies": true } ], "import/no-unresolved": [ diff --git a/packages/@aws-cdk/cdk-cli-wrapper/.eslintrc.json b/packages/@aws-cdk/cdk-cli-wrapper/.eslintrc.json index bb1114eb1..d65ae59f9 100644 --- a/packages/@aws-cdk/cdk-cli-wrapper/.eslintrc.json +++ b/packages/@aws-cdk/cdk-cli-wrapper/.eslintrc.json @@ -55,10 +55,11 @@ "error", { "devDependencies": [ - "**/build-tools/**", - "**/test/**" + "**/test/**", + "**/build-tools/**" ], - "optionalDependencies": false + "optionalDependencies": false, + "peerDependencies": true } ], "import/no-unresolved": [ diff --git a/packages/@aws-cdk/cli-lib-alpha/.eslintrc.json b/packages/@aws-cdk/cli-lib-alpha/.eslintrc.json index 59081278a..2c8cc03e8 100644 --- a/packages/@aws-cdk/cli-lib-alpha/.eslintrc.json +++ b/packages/@aws-cdk/cli-lib-alpha/.eslintrc.json @@ -52,10 +52,11 @@ "error", { "devDependencies": [ - "**/build-tools/**", - "**/test/**" + "**/test/**", + "**/build-tools/**" ], - "optionalDependencies": false + "optionalDependencies": false, + "peerDependencies": true } ], "import/no-unresolved": [ diff --git a/packages/@aws-cdk/cli-plugin-contract/.eslintrc.json b/packages/@aws-cdk/cli-plugin-contract/.eslintrc.json index bb1114eb1..d65ae59f9 100644 --- a/packages/@aws-cdk/cli-plugin-contract/.eslintrc.json +++ b/packages/@aws-cdk/cli-plugin-contract/.eslintrc.json @@ -55,10 +55,11 @@ "error", { "devDependencies": [ - "**/build-tools/**", - "**/test/**" + "**/test/**", + "**/build-tools/**" ], - "optionalDependencies": false + "optionalDependencies": false, + "peerDependencies": true } ], "import/no-unresolved": [ diff --git a/packages/@aws-cdk/cloud-assembly-schema/.eslintrc.json b/packages/@aws-cdk/cloud-assembly-schema/.eslintrc.json index bb1114eb1..d65ae59f9 100644 --- a/packages/@aws-cdk/cloud-assembly-schema/.eslintrc.json +++ b/packages/@aws-cdk/cloud-assembly-schema/.eslintrc.json @@ -55,10 +55,11 @@ "error", { "devDependencies": [ - "**/build-tools/**", - "**/test/**" + "**/test/**", + "**/build-tools/**" ], - "optionalDependencies": false + "optionalDependencies": false, + "peerDependencies": true } ], "import/no-unresolved": [ diff --git a/packages/@aws-cdk/cloudformation-diff/.eslintrc.json b/packages/@aws-cdk/cloudformation-diff/.eslintrc.json index bb1114eb1..d65ae59f9 100644 --- a/packages/@aws-cdk/cloudformation-diff/.eslintrc.json +++ b/packages/@aws-cdk/cloudformation-diff/.eslintrc.json @@ -55,10 +55,11 @@ "error", { "devDependencies": [ - "**/build-tools/**", - "**/test/**" + "**/test/**", + "**/build-tools/**" ], - "optionalDependencies": false + "optionalDependencies": false, + "peerDependencies": true } ], "import/no-unresolved": [ diff --git a/packages/@aws-cdk/node-bundle/.eslintrc.json b/packages/@aws-cdk/node-bundle/.eslintrc.json index fffe010da..73ce760f7 100644 --- a/packages/@aws-cdk/node-bundle/.eslintrc.json +++ b/packages/@aws-cdk/node-bundle/.eslintrc.json @@ -55,10 +55,11 @@ "error", { "devDependencies": [ - "**/build-tools/**", - "**/test/**" + "**/test/**", + "**/build-tools/**" ], - "optionalDependencies": false + "optionalDependencies": false, + "peerDependencies": true } ], "import/no-unresolved": [ diff --git a/packages/@aws-cdk/toolkit-lib/.eslintrc.json b/packages/@aws-cdk/toolkit-lib/.eslintrc.json index e87248629..e907a9e7f 100644 --- a/packages/@aws-cdk/toolkit-lib/.eslintrc.json +++ b/packages/@aws-cdk/toolkit-lib/.eslintrc.json @@ -52,10 +52,11 @@ "error", { "devDependencies": [ - "**/build-tools/**", - "**/test/**" + "**/test/**", + "**/build-tools/**" ], - "optionalDependencies": false + "optionalDependencies": false, + "peerDependencies": true } ], "import/no-unresolved": [ diff --git a/packages/@aws-cdk/user-input-gen/.eslintrc.json b/packages/@aws-cdk/user-input-gen/.eslintrc.json index bb1114eb1..d65ae59f9 100644 --- a/packages/@aws-cdk/user-input-gen/.eslintrc.json +++ b/packages/@aws-cdk/user-input-gen/.eslintrc.json @@ -55,10 +55,11 @@ "error", { "devDependencies": [ - "**/build-tools/**", - "**/test/**" + "**/test/**", + "**/build-tools/**" ], - "optionalDependencies": false + "optionalDependencies": false, + "peerDependencies": true } ], "import/no-unresolved": [ diff --git a/packages/@aws-cdk/yarn-cling/.eslintrc.json b/packages/@aws-cdk/yarn-cling/.eslintrc.json index bb1114eb1..d65ae59f9 100644 --- a/packages/@aws-cdk/yarn-cling/.eslintrc.json +++ b/packages/@aws-cdk/yarn-cling/.eslintrc.json @@ -55,10 +55,11 @@ "error", { "devDependencies": [ - "**/build-tools/**", - "**/test/**" + "**/test/**", + "**/build-tools/**" ], - "optionalDependencies": false + "optionalDependencies": false, + "peerDependencies": true } ], "import/no-unresolved": [ diff --git a/packages/aws-cdk/.eslintrc.json b/packages/aws-cdk/.eslintrc.json index 1bb022e6f..2eefee123 100644 --- a/packages/aws-cdk/.eslintrc.json +++ b/packages/aws-cdk/.eslintrc.json @@ -53,10 +53,11 @@ "error", { "devDependencies": [ - "**/build-tools/**", - "**/test/**" + "**/test/**", + "**/build-tools/**" ], - "optionalDependencies": false + "optionalDependencies": false, + "peerDependencies": true } ], "import/no-unresolved": [ diff --git a/packages/cdk-assets/.eslintrc.json b/packages/cdk-assets/.eslintrc.json index bd279d486..329f4c360 100644 --- a/packages/cdk-assets/.eslintrc.json +++ b/packages/cdk-assets/.eslintrc.json @@ -55,10 +55,11 @@ "error", { "devDependencies": [ - "**/build-tools/**", - "**/test/**" + "**/test/**", + "**/build-tools/**" ], - "optionalDependencies": false + "optionalDependencies": false, + "peerDependencies": true } ], "import/no-unresolved": [ diff --git a/packages/cdk/.eslintrc.json b/packages/cdk/.eslintrc.json index bb1114eb1..d65ae59f9 100644 --- a/packages/cdk/.eslintrc.json +++ b/packages/cdk/.eslintrc.json @@ -55,10 +55,11 @@ "error", { "devDependencies": [ - "**/build-tools/**", - "**/test/**" + "**/test/**", + "**/build-tools/**" ], - "optionalDependencies": false + "optionalDependencies": false, + "peerDependencies": true } ], "import/no-unresolved": [ diff --git a/projenrc/build-standalone-zip.task.ts b/projenrc/build-standalone-zip.task.ts index 897371785..8f6d65f1a 100644 --- a/projenrc/build-standalone-zip.task.ts +++ b/projenrc/build-standalone-zip.task.ts @@ -1,8 +1,8 @@ import * as cp from 'child_process'; import { promises as fs } from 'fs'; import * as os from 'os'; -import * as util from 'util'; import * as path from 'path'; +import * as util from 'util'; import * as glob_ from 'glob'; const glob = util.promisify(glob_.glob); @@ -11,6 +11,8 @@ async function main() { const outdir = await fs.mkdtemp(path.join(os.tmpdir(), 'bundling')); try { const pkgs = ['aws-cdk']; + // this is a build task, so we are safe either way + // eslint-disable-next-line @cdklabs/promiseall-no-unbounded-parallelism const deps = await Promise.all(pkgs.map(async (p) => [p, await glob(`packages/${p}/dist/js/*.tgz`)] as const)); for (const [name, xs] of deps) { if (xs.length !== 1) { @@ -43,6 +45,8 @@ async function main() { } main().catch(e => { + // this is effectively a mini-cli + // eslint-disable-next-line no-console console.error(e); process.exitCode = 1; -}); \ No newline at end of file +}); diff --git a/projenrc/bundle.ts b/projenrc/bundle.ts index cfa2de8f3..a9b44de94 100644 --- a/projenrc/bundle.ts +++ b/projenrc/bundle.ts @@ -111,7 +111,6 @@ export interface Externals { } - export class BundleCli extends pj.Component { constructor(project: pj.Project, options: BundleProps) { super(project); @@ -160,4 +159,4 @@ export class BundleCli extends pj.Component { */ function quoteShellArg(x: string) { return `'${x.replace(/'/g, "'\\''")}'`; -} \ No newline at end of file +} diff --git a/projenrc/eslint.ts b/projenrc/eslint.ts index 4d85c1ec2..5a4081b3d 100644 --- a/projenrc/eslint.ts +++ b/projenrc/eslint.ts @@ -2,11 +2,11 @@ export const ESLINT_RULES = { '@cdklabs/no-core-construct': ['error'], '@cdklabs/invalid-cfn-imports': ['error'], '@cdklabs/no-literal-partition': ['error'], - '@cdklabs/no-invalid-path': [ 'error' ], - '@cdklabs/promiseall-no-unbounded-parallelism': [ 'error' ], + '@cdklabs/no-invalid-path': ['error'], + '@cdklabs/promiseall-no-unbounded-parallelism': ['error'], // Error handling - 'no-throw-literal': [ 'error' ], + 'no-throw-literal': ['error'], // Require use of the `import { foo } from 'bar';` form instead of `import foo = require('bar');` '@typescript-eslint/no-require-imports': ['error'], @@ -29,8 +29,8 @@ export const ESLINT_RULES = { 'space-before-blocks': 'error', // require space before blocks 'curly': ['error', 'multi-line', 'consistent'], // require curly braces for multiline control statements 'eol-last': ['error', 'always'], // require a newline a the end of files - '@stylistic/spaced-comment': ['error', 'always', { 'exceptions': ['/', '*'], 'markers': ['/'] }], // require a whitespace at the beginninng of each comment - '@stylistic/padded-blocks': ['error', { 'classes': 'never', 'blocks': 'never', 'switches': 'never'}], + '@stylistic/spaced-comment': ['error', 'always', { exceptions: ['/', '*'], markers: ['/'] }], // require a whitespace at the beginninng of each comment + '@stylistic/padded-blocks': ['error', { classes: 'never', blocks: 'never', switches: 'never' }], // JSDoc 'jsdoc/require-param-description': ['error'], @@ -38,18 +38,6 @@ export const ESLINT_RULES = { 'jsdoc/require-returns-description': ['error'], 'jsdoc/check-alignment': ['error'], - // Require all imported dependencies are actually declared in package.json - 'import/no-extraneous-dependencies': [ - 'error', - { - devDependencies: [ // Only allow importing devDependencies from: - '**/build-tools/**', // --> Build tools - '**/test/**', // --> Unit tests - ], - optionalDependencies: false, // Disallow importing optional dependencies (those shouldn't be in use in the project) - }, - ], - // Require all imported libraries actually resolve (!!required for import/no-extraneous-dependencies to work!!) 'import/no-unresolved': ['error'], @@ -65,7 +53,7 @@ export const ESLINT_RULES = { paths: [ { name: 'punycode', - message: `Package 'punycode' has to be imported with trailing slash, see warning in https://github.com/bestiejs/punycode.js#installation`, + message: 'Package \'punycode\' has to be imported with trailing slash, see warning in https://github.com/bestiejs/punycode.js#installation', }, ], patterns: ['!punycode/'], @@ -89,7 +77,7 @@ export const ESLINT_RULES = { 'quote-props': ['error', 'consistent-as-needed'], // No multiple empty lines - 'no-multiple-empty-lines': ['error', { 'max': 1 }], + 'no-multiple-empty-lines': ['error', { max: 1 }], // Max line lengths 'max-len': ['error', { @@ -122,13 +110,13 @@ export const ESLINT_RULES = { 'no-bitwise': ['error'], // No more md5, will break in FIPS environments - "no-restricted-syntax": [ - "error", + 'no-restricted-syntax': [ + 'error', { // Both qualified and unqualified calls - "selector": "CallExpression:matches([callee.name='createHash'], [callee.property.name='createHash']) Literal[value='md5']", - "message": "Use the md5hash() function from the core library if you want md5" - } + selector: "CallExpression:matches([callee.name='createHash'], [callee.property.name='createHash']) Literal[value='md5']", + message: 'Use the md5hash() function from the core library if you want md5', + }, ], // Oh ho ho naming. Everyone's favorite topic! @@ -177,13 +165,13 @@ export const ESLINT_RULES = { }], // Overrides for plugin:jest/recommended - "jest/expect-expect": "off", - "jest/no-conditional-expect": "off", - "jest/no-done-callback": "off", // Far too many of these in the codebase. - "jest/no-standalone-expect": "off", // nodeunitShim confuses this check. - "jest/valid-expect": "off", // expect from '@aws-cdk/assert' can take a second argument - "jest/valid-title": "off", // A little over-zealous with test('test foo') being an error. - "jest/no-identical-title": "off", // TEMPORARY - Disabling this until https://github.com/jest-community/eslint-plugin-jest/issues/836 is resolved + 'jest/expect-expect': 'off', + 'jest/no-conditional-expect': 'off', + 'jest/no-done-callback': 'off', // Far too many of these in the codebase. + 'jest/no-standalone-expect': 'off', // nodeunitShim confuses this check. + 'jest/valid-expect': 'off', // expect from '@aws-cdk/assert' can take a second argument + 'jest/valid-title': 'off', // A little over-zealous with test('test foo') being an error. + 'jest/no-identical-title': 'off', // TEMPORARY - Disabling this until https://github.com/jest-community/eslint-plugin-jest/issues/836 is resolved 'jest/no-disabled-tests': 'error', // Skipped tests are easily missed in PR reviews 'jest/no-focused-tests': 'error', // Focused tests are easily missed in PR reviews }; diff --git a/projenrc/jsii.ts b/projenrc/jsii.ts index 7d437dedc..ff299c202 100644 --- a/projenrc/jsii.ts +++ b/projenrc/jsii.ts @@ -1,3 +1,4 @@ +import { yarn } from 'cdklabs-projen-project-types'; import * as pj from 'projen'; import { Stability } from 'projen/lib/cdk'; import { WorkflowSteps } from 'projen/lib/github'; @@ -5,8 +6,6 @@ import { Job, JobPermission, Step, Tools } from 'projen/lib/github/workflows-mod import { NodePackageManager } from 'projen/lib/javascript'; import { CommonPublishOptions, NpmPublishOptions } from 'projen/lib/release'; -import { yarn } from 'cdklabs-projen-project-types'; - export interface JsiiBuildOptions { /** * Publish to maven @@ -135,7 +134,7 @@ export class JsiiBuild extends pj.Component { public readonly packageAllTask: pj.Task; private readonly packageJsTask: pj.Task; private readonly tsProject: pj.typescript.TypeScriptProject; - private readonly monoProject: yarn.TypeScriptWorkspace + private readonly monoProject: yarn.TypeScriptWorkspace; private readonly monorepoRelease: yarn.MonorepoRelease; constructor(project: yarn.TypeScriptWorkspace, options: JsiiBuildOptions) { @@ -173,12 +172,12 @@ export class JsiiBuild extends pj.Component { const compressAssembly = options.compressAssembly ?? false; // this is an unhelpful warning - const jsiiFlags = ["--silence-warnings=reserved-word"]; + const jsiiFlags = ['--silence-warnings=reserved-word']; if (compressAssembly) { - jsiiFlags.push("--compress-assembly"); + jsiiFlags.push('--compress-assembly'); } - const compatIgnore = options.compatIgnore ?? ".compatignore"; + const compatIgnore = options.compatIgnore ?? '.compatignore'; tsProject.addFields({ stability: options.stability ?? Stability.STABLE }); @@ -186,8 +185,8 @@ export class JsiiBuild extends pj.Component { tsProject.addFields({ deprecated: true }); } - const compatTask = tsProject.addTask("compat", { - description: "Perform API compatibility check against latest version", + const compatTask = tsProject.addTask('compat', { + description: 'Perform API compatibility check against latest version', exec: `jsii-diff npm:$(node -p "require(\'./package.json\').name") -k --ignore-file ${compatIgnore} || (echo "\nUNEXPECTED BREAKING CHANGES: add keys such as \'removed:constructs.Node.of\' to ${compatIgnore} to skip.\n" && exit 1)`, }); @@ -196,29 +195,29 @@ export class JsiiBuild extends pj.Component { tsProject.compileTask.spawn(compatTask); } - tsProject.compileTask.reset(["jsii", ...jsiiFlags].join(" ")); - tsProject.watchTask.reset(["jsii", "-w", ...jsiiFlags].join(" ")); + tsProject.compileTask.reset(['jsii', ...jsiiFlags].join(' ')); + tsProject.watchTask.reset(['jsii', '-w', ...jsiiFlags].join(' ')); // Create a new package:all task, it will be filled with language targets later - this.packageAllTask = tsProject.addTask("package-all", { - description: "Packages artifacts for all target languages", + this.packageAllTask = tsProject.addTask('package-all', { + description: 'Packages artifacts for all target languages', }); // in jsii we consider the entire repo (post build) as the build artifact // which is then used to create the language bindings in separate jobs. // we achieve this by doing a checkout and overwrite with the files from the js package. - this.packageJsTask = this.addPackagingTask("js"); + this.packageJsTask = this.addPackagingTask('js'); // When running inside CI we initially only package js. Other targets are packaged in separate jobs. // Outside of CI (i.e locally) we simply package all targets. tsProject.packageTask.reset(); tsProject.packageTask.spawn(this.packageJsTask, { // Only run in CI - condition: `node -e "if (!process.env.CI) process.exit(1)"`, + condition: 'node -e "if (!process.env.CI) process.exit(1)"', }); tsProject.packageTask.spawn(this.packageAllTask, { // Don't run in CI - condition: `node -e "if (process.env.CI) process.exit(1)"`, + condition: 'node -e "if (process.env.CI) process.exit(1)"', }); const targets: Record = {}; @@ -259,8 +258,8 @@ export class JsiiBuild extends pj.Component { // No support for CodeArtifact here // codeArtifactOptions: tsProject.codeArtifactOptions, }; - this.addTargetToBuild("js", this.packageJsTask, extraJobOptions); - this.addTargetToRelease("js", this.packageJsTask, npmjs); + this.addTargetToBuild('js', this.packageJsTask, extraJobOptions); + this.addTargetToRelease('js', this.packageJsTask, npmjs); const maven = options.publishToMaven; if (maven) { @@ -272,9 +271,9 @@ export class JsiiBuild extends pj.Component { }, }; - const task = this.addPackagingTask("java"); - this.addTargetToBuild("java", task, extraJobOptions); - this.addTargetToRelease("java", task, maven); + const task = this.addPackagingTask('java'); + this.addTargetToBuild('java', task, extraJobOptions); + this.addTargetToRelease('java', task, maven); } const pypi = options.publishToPypi; @@ -284,9 +283,9 @@ export class JsiiBuild extends pj.Component { module: pypi.module, }; - const task = this.addPackagingTask("python"); - this.addTargetToBuild("python", task, extraJobOptions); - this.addTargetToRelease("python", task, pypi); + const task = this.addPackagingTask('python'); + this.addTargetToBuild('python', task, extraJobOptions); + this.addTargetToRelease('python', task, pypi); } const nuget = options.publishToNuget; @@ -297,9 +296,9 @@ export class JsiiBuild extends pj.Component { iconUrl: nuget.iconUrl, }; - const task = this.addPackagingTask("dotnet"); - this.addTargetToBuild("dotnet", task, extraJobOptions); - this.addTargetToRelease("dotnet", task, nuget); + const task = this.addPackagingTask('dotnet'); + this.addTargetToBuild('dotnet', task, extraJobOptions); + this.addTargetToRelease('dotnet', task, nuget); } const golang = options.publishToGo; @@ -310,31 +309,31 @@ export class JsiiBuild extends pj.Component { versionSuffix: golang.versionSuffix, }; - const task = this.addPackagingTask("go"); - this.addTargetToBuild("go", task, extraJobOptions); - this.addTargetToRelease("go", task, golang); + const task = this.addPackagingTask('go'); + this.addTargetToBuild('go', task, extraJobOptions); + this.addTargetToRelease('go', task, golang); } const jsiiSuffix = - options.jsiiVersion === "*" + options.jsiiVersion === '*' ? // If jsiiVersion is "*", don't specify anything so the user can manage. - "" + '' : // Otherwise, use `jsiiVersion` or fall back to `5.7` - `@${options.jsiiVersion ?? "5.7"}`; + `@${options.jsiiVersion ?? '5.7'}`; tsProject.addDevDeps( `jsii${jsiiSuffix}`, `jsii-rosetta${jsiiSuffix}`, - "jsii-diff", - "jsii-pacmak" + 'jsii-diff', + 'jsii-pacmak', ); - tsProject.gitignore.exclude(".jsii", "tsconfig.json"); - tsProject.npmignore?.include(".jsii"); + tsProject.gitignore.exclude('.jsii', 'tsconfig.json'); + tsProject.npmignore?.include('.jsii'); if (options.docgen ?? true) { // If jsiiVersion is "*", don't specify anything so the user can manage. // Otherwise use a version that is compatible with all supported jsii releases. - const docgenVersion = options.jsiiVersion === "*" ? "*" : "^10.5.0"; + const docgenVersion = options.jsiiVersion === '*' ? '*' : '^10.5.0'; new pj.cdk.JsiiDocgen(tsProject, { version: docgenVersion, filePath: options.docgenFilePath, @@ -366,8 +365,6 @@ export class JsiiBuild extends pj.Component { /** * Adds a target language to the release workflow. - * @param language - * @returns */ private addTargetToRelease( language: JsiiPacmakTarget, @@ -377,7 +374,7 @@ export class JsiiBuild extends pj.Component { | pj.cdk.JsiiDotNetTarget | pj.cdk.JsiiGoTarget | pj.cdk.JsiiJavaTarget - | NpmPublishOptions + | NpmPublishOptions, ) { const release = this.monorepoRelease.workspaceRelease(this.monoProject); @@ -407,13 +404,11 @@ export class JsiiBuild extends pj.Component { /** * Adds a target language to the build workflow - * @param language - * @returns */ private addTargetToBuild( language: JsiiPacmakTarget, packTask: pj.Task, - extraJobOptions: Partial + extraJobOptions: Partial, ) { if (!this.tsProject.buildWorkflow) { return; @@ -423,14 +418,14 @@ export class JsiiBuild extends pj.Component { this.tsProject.buildWorkflow.addPostBuildJob(`package-${language}`, { ...pj.filteredRunsOnOptions( extraJobOptions.runsOn, - extraJobOptions.runsOnGroup + extraJobOptions.runsOnGroup, ), permissions: { contents: JobPermission.READ, }, tools: { // FIXME: We should get this from a global GitHub component - node: { version: (this.tsProject as any).nodeVersion ?? "lts/*" }, + node: { version: (this.tsProject as any).nodeVersion ?? 'lts/*' }, ...pacmak.publishTools, }, steps: [ @@ -453,7 +448,7 @@ export class JsiiBuild extends pj.Component { const packageTargetTask = this.tsProject.tasks.addTask(`package:${language}`, { description: `Create ${language} language bindings`, }); - const commandParts = ["jsii-pacmak", "-v"]; + const commandParts = ['jsii-pacmak', '-v']; if (this.tsProject.package.packageManager === NodePackageManager.PNPM) { commandParts.push("--pack-command 'pnpm pack'"); @@ -461,7 +456,7 @@ export class JsiiBuild extends pj.Component { commandParts.push(`--target ${language}`); - packageTargetTask.exec(commandParts.join(" ")); + packageTargetTask.exec(commandParts.join(' ')); this.packageAllTask.spawn(packageTargetTask); return packageTargetTask; @@ -469,12 +464,12 @@ export class JsiiBuild extends pj.Component { private pacmakForLanguage( target: JsiiPacmakTarget, - packTask: pj.Task + packTask: pj.Task, ): { - publishTools: Tools; - bootstrapSteps: Array; - packagingSteps: Array; - } { + publishTools: Tools; + bootstrapSteps: Array; + packagingSteps: Array; + } { const bootstrapSteps: Array = []; const packagingSteps: Array = []; @@ -482,29 +477,29 @@ export class JsiiBuild extends pj.Component { bootstrapSteps.push(...(this.tsProject as any).workflowBootstrapSteps); if (this.tsProject.package.packageManager === NodePackageManager.PNPM) { bootstrapSteps.push({ - name: "Setup pnpm", - uses: "pnpm/action-setup@v3", + name: 'Setup pnpm', + uses: 'pnpm/action-setup@v3', with: { version: this.tsProject.package.pnpmVersion }, }); } else if (this.tsProject.package.packageManager === NodePackageManager.BUN) { bootstrapSteps.push({ - name: "Setup bun", - uses: "oven-sh/setup-bun@v1", + name: 'Setup bun', + uses: 'oven-sh/setup-bun@v1', }); } // Installation steps before packaging, but after checkout packagingSteps.push( { - name: "Install Dependencies", + name: 'Install Dependencies', run: `cd ${REPO_TEMP_DIRECTORY} && ${this.tsProject.package.installCommand}`, }, { - name: "Extract build artifact", + name: 'Extract build artifact', run: `tar --strip-components=1 -xzvf ${this.tsProject.artifactsDirectory}/js/*.tgz -C ${REPO_TEMP_DIRECTORY}`, }, { - name: `Move build artifact out of the way`, + name: 'Move build artifact out of the way', run: `mv ${this.tsProject.artifactsDirectory} ${BUILD_ARTIFACT_OLD_DIR}`, }, { @@ -514,7 +509,7 @@ export class JsiiBuild extends pj.Component { { name: `Collect ${target} artifact`, run: `mv ${REPO_TEMP_DIRECTORY}/${this.tsProject.artifactsDirectory} ${this.tsProject.artifactsDirectory}`, - } + }, ); return { @@ -527,38 +522,38 @@ export class JsiiBuild extends pj.Component { type PublishTo = keyof pj.release.Publisher & ( - | "publishToNpm" - | "publishToMaven" - | "publishToPyPi" - | "publishToNuget" - | "publishToGo" + | 'publishToNpm' + | 'publishToMaven' + | 'publishToPyPi' + | 'publishToNuget' + | 'publishToGo' ); type PublishToTarget = { [K in JsiiPacmakTarget]: PublishTo }; const publishTo: PublishToTarget = { - js: "publishToNpm", - java: "publishToMaven", - python: "publishToPyPi", - dotnet: "publishToNuget", - go: "publishToGo", + js: 'publishToNpm', + java: 'publishToMaven', + python: 'publishToPyPi', + dotnet: 'publishToNuget', + go: 'publishToGo', }; -export type JsiiPacmakTarget = "js" | "go" | "java" | "python" | "dotnet"; +export type JsiiPacmakTarget = 'js' | 'go' | 'java' | 'python' | 'dotnet'; /** * GitHub workflow job steps for setting up the tools required for various JSII targets. */ export const JSII_TOOLCHAIN: Record = { js: {}, - java: { java: { version: "11" } }, - python: { python: { version: "3.x" } }, - go: { go: { version: "^1.18.0" } }, - dotnet: { dotnet: { version: "6.x" } }, + java: { java: { version: '11' } }, + python: { python: { version: '3.x' } }, + go: { go: { version: '^1.18.0' } }, + dotnet: { dotnet: { version: '6.x' } }, }; -const REPO_TEMP_DIRECTORY = ".repo"; -const BUILD_ARTIFACT_OLD_DIR = "dist.old"; +const REPO_TEMP_DIRECTORY = '.repo'; +const BUILD_ARTIFACT_OLD_DIR = 'dist.old'; -export const PULL_REQUEST_REF = "${{ github.event.pull_request.head.ref }}"; +export const PULL_REQUEST_REF = '${{ github.event.pull_request.head.ref }}'; export const PULL_REQUEST_REPOSITORY = - "${{ github.event.pull_request.head.repo.full_name }}"; \ No newline at end of file + '${{ github.event.pull_request.head.repo.full_name }}'; diff --git a/projenrc/next-version.ts b/projenrc/next-version.ts index d03e962ab..3bf58b468 100644 --- a/projenrc/next-version.ts +++ b/projenrc/next-version.ts @@ -61,11 +61,15 @@ async function main() { } if (version !== (process.env.VERSION ?? '')) { + // this is a cli + // eslint-disable-next-line no-console console.log(version); } } main().catch((error) => { + // this is a cli + // eslint-disable-next-line no-console console.error(error); process.exitCode = 1; }); diff --git a/projenrc/publish-to-adc.task.ts b/projenrc/publish-to-adc.task.ts index 3549b49be..2dfe913c3 100644 --- a/projenrc/publish-to-adc.task.ts +++ b/projenrc/publish-to-adc.task.ts @@ -1,7 +1,7 @@ -import { S3 } from '@aws-sdk/client-s3'; import { createReadStream } from 'fs'; +import { S3 } from '@aws-sdk/client-s3'; +import { fromTemporaryCredentials, fromNodeProviderChain } from '@aws-sdk/credential-providers'; import { Upload } from '@aws-sdk/lib-storage'; -import { fromTemporaryCredentials, fromNodeProviderChain } from '@aws-sdk/credential-providers'; /** * Takes files from `dist/standalone` and moves them to specific ADC buckets @@ -32,6 +32,8 @@ async function main() { for (const bucket of TARGET_BUCKETS.split(' ')) { // This value is secret-ish, mask it out + // this is a cli + // eslint-disable-next-line no-console console.log(`::add-mask::${bucket}`); const upload = new Upload({ @@ -48,6 +50,8 @@ async function main() { } main().catch(e => { + // this is a cli + // eslint-disable-next-line no-console console.error(e); process.exitCode = 1; -}); \ No newline at end of file +});