Skip to content

Commit

Permalink
chore(cli): run cli-integ tests against all supported versions of TS
Browse files Browse the repository at this point in the history
  • Loading branch information
mrgrain committed Dec 6, 2022
1 parent 7690f43 commit 7ee5458
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 10 deletions.
27 changes: 17 additions & 10 deletions packages/aws-cdk/test/integ/init/test-typescript.sh
Expand Up @@ -4,6 +4,7 @@
#------------------------------------------------------------------
set -eu
scriptdir=$(cd $(dirname $0) && pwd)
integdir=$(dirname $scriptdir)
source ${scriptdir}/common.bash

header TypeScript
Expand All @@ -16,18 +17,24 @@ else
templates="$@"
fi

MIN_SUPPORTED_TS_VERSION="3.9"
SUPPORTED_TS_VERSIONS=$(node ${integdir}/typescript-versions.js listTypeScriptVersions ${MIN_SUPPORTED_TS_VERSION})

for template in $templates; do
echo "Trying TypeScript template $template"
for version in $SUPPORTED_TS_VERSIONS; do
echo "Trying TypeScript template $template with TS$version"

setup
setup

cdk init -l typescript $template
npm prune && npm ls # this will fail if we have unmet peer dependencies
npm run build
npm run test
cdk init -l typescript $template
npm install --save typescript@$version
npm prune && npm ls # this will fail if we have unmet peer dependencies
npm run build
npm run test

# Can't run `cdk synth` on libraries
if [[ $template != "lib" ]]; then
cdk synth
fi
# Can't run `cdk synth` on libraries
if [[ $template != "lib" ]]; then
cdk synth
fi
done
done
15 changes: 15 additions & 0 deletions packages/aws-cdk/test/integ/typescript-versions.ts
@@ -0,0 +1,15 @@
import { spawnSync } from 'child_process';

module.exports.listTypeScriptVersions = async function(minSupportedVersion: string) {
const { stdout } = spawnSync('npm', ['--silent', 'view', `typescript@>=${minSupportedVersion}`, 'version', '--json']);

const versions: string[] = JSON.parse(stdout);
const minorVersions = Array.from(new Set(versions.map(v => v.split('.').slice(0, 2).join('.'))));

return minorVersions.join(' ');
};

// eslint-disable-next-line @typescript-eslint/no-require-imports
require('make-runnable/custom')({
printOutputFrame: false,
});

0 comments on commit 7ee5458

Please sign in to comment.