Skip to content

Commit 0fd80e1

Browse files
authored
chore: update run-rosetta.sh (#18127)
This point of this PR is to streamline the docs build in `run-rosetta.sh`. We now utilize the npm package [`cdk-generate-synthetic-examples`](https://github.com/cdklabs/cdk-generate-synthetic-examples) owned by yours truly. We also run `rosetta extract` twice, to properly translate generated examples. We purposefully ignore infused examples for this step. In addition, we remove the `generate-examples` project ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent a15250e commit 0fd80e1

29 files changed

+65
-3291
lines changed

pack.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ scripts/run-rosetta.sh --infuse --pkgs-from $TMPDIR/jsii.txt
4242
echo "Packaging jsii modules" >&2
4343
$PACMAK \
4444
--verbose \
45-
--rosetta-tablet samples.tabl.json \
4645
$(cat $TMPDIR/jsii.txt)
4746

4847
# Non-jsii packaging, which means running 'package' in every individual

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@
2727
"lerna": "^4.0.0",
2828
"patch-package": "^6.4.7",
2929
"standard-version": "^9.3.2",
30-
"typescript": "~3.9.10"
30+
"typescript": "~3.9.10",
31+
"cdk-generate-synthetic-examples": "^0.1.1"
3132
},
3233
"resolutions": {
3334
"string-width": "^4.2.3"

scripts/run-rosetta.sh

Lines changed: 18 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
# 2. Run `rosetta infuse` to traverse all examples we have, and copy them
1313
# to classes that don't have an example yet.
1414
#
15-
# 3. Run `tools/@aws-cdk/generate-examples` to find all types that *still*
16-
# don't have examples associated with tme, and generate synthetic examples.
15+
# 3. Run `cdk-generate-synthetic-examples` to find all types that *still*
16+
# don't have associated examples, and generate synthetic examples.
1717
#
1818
# If you already have a file with a list of all the JSII package directories
1919
# in it, pass it as the first argument. Otherwise, this script will run
@@ -55,45 +55,37 @@ if [[ "${jsii_pkgs_file}" = "" ]]; then
5555
fi
5656

5757
rosetta_cache_file=$HOME/.s3buildcache/rosetta-cache.tabl.json
58-
rosetta_cache_opts=""
59-
genexample_cache_opts=""
60-
if [[ -f $rosetta_cache_file ]]; then
61-
rosetta_cache_opts="--cache-from ${rosetta_cache_file}"
62-
genexample_cache_opts="--cache-from ${rosetta_cache_file}"
58+
extract_opts=""
59+
if $infuse; then
60+
extract_opts="--infuse"
6361
fi
6462

6563
#----------------------------------------------------------------------
6664

6765
# Compile examples with respect to "decdk" directory, as all packages will
6866
# be symlinked there so they can all be included.
6967
echo "💎 Extracting code samples" >&2
70-
$ROSETTA \
68+
time $ROSETTA extract \
7169
--compile \
7270
--verbose \
73-
--output samples.tabl.json \
74-
$rosetta_cache_opts \
71+
--cache ${rosetta_cache_file} \
7572
--directory packages/decdk \
73+
${extract_opts} \
7674
$(cat $jsii_pkgs_file)
7775

78-
7976
if $infuse; then
80-
echo "💎 Infusing examples back into assemblies" >&2
81-
$ROSETTA infuse \
82-
--verbose \
83-
samples.tabl.json \
84-
$(cat $jsii_pkgs_file)
85-
8677
echo "💎 Generating synthetic examples for the remainder" >&2
87-
time $scriptdir/../tools/@aws-cdk/generate-examples/bin/generate-examples \
88-
$genexample_cache_opts \
89-
--append-to samples.tabl.json \
78+
time npx cdk-generate-synthetic-examples \
9079
$(cat $jsii_pkgs_file)
9180

81+
time $ROSETTA extract \
82+
--compile \
83+
--verbose \
84+
--cache ${rosetta_cache_file} \
85+
--directory packages/decdk \
86+
$(cat $jsii_pkgs_file)
9287
fi
9388

94-
#----------------------------------------------------------------------
95-
96-
if [[ -d $(dirname $rosetta_cache_file) ]]; then
97-
# If the cache directory is available, copy the current tablet into it
98-
cp samples.tabl.json $rosetta_cache_file
99-
fi
89+
time $ROSETTA trim-cache \
90+
${rosetta_cache_file} \
91+
$(cat $jsii_pkgs_file)

tools/@aws-cdk/generate-examples/.eslintrc.js

Lines changed: 0 additions & 3 deletions
This file was deleted.

tools/@aws-cdk/generate-examples/.gitignore

Lines changed: 0 additions & 10 deletions
This file was deleted.

tools/@aws-cdk/generate-examples/.npmignore

Lines changed: 0 additions & 14 deletions
This file was deleted.

tools/@aws-cdk/generate-examples/LICENSE

Lines changed: 0 additions & 201 deletions
This file was deleted.

tools/@aws-cdk/generate-examples/NOTICE

Lines changed: 0 additions & 2 deletions
This file was deleted.

tools/@aws-cdk/generate-examples/README.md

Lines changed: 0 additions & 9 deletions
This file was deleted.

tools/@aws-cdk/generate-examples/bin/generate-examples

Lines changed: 0 additions & 2 deletions
This file was deleted.

tools/@aws-cdk/generate-examples/bin/generate-examples.ts

Lines changed: 0 additions & 54 deletions
This file was deleted.

0 commit comments

Comments
 (0)