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 9, 2022
1 parent 84e20f8 commit 57c4a1f
Show file tree
Hide file tree
Showing 2 changed files with 27 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 ${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
10 changes: 10 additions & 0 deletions packages/aws-cdk/test/integ/typescript-versions.ts
@@ -0,0 +1,10 @@
import { spawnSync } from 'child_process';

const minSupportedVersion = process.argv.slice(2, 3);

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('.'))));

process.stdout.write(minorVersions.join(' '));

0 comments on commit 57c4a1f

Please sign in to comment.