Skip to content

Commit 220e3d0

Browse files
fix target generation
1 parent 2d70bb7 commit 220e3d0

10 files changed

Lines changed: 8 additions & 226501 deletions

File tree

packages/ui-extensions/docs/surfaces/checkout/build-docs-targets-json.mjs

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,10 @@ import {
1111
const __filename = fileURLToPath(import.meta.url);
1212
const __dirname = path.dirname(__filename);
1313

14-
// Find the generated_docs_data.json file to determine output location
14+
// Find the generated_docs_data_v2.json file to determine output location
1515
function findGeneratedDocsPath() {
1616
const generatedDir = path.join(__dirname, 'generated');
1717

18-
// Look for generated_docs_data.json recursively
1918
function findFile(dir) {
2019
const files = fs.readdirSync(dir);
2120
for (const file of files) {
@@ -24,7 +23,7 @@ function findGeneratedDocsPath() {
2423
if (stat.isDirectory()) {
2524
const result = findFile(fullPath);
2625
if (result) return result;
27-
} else if (file === 'generated_docs_data.json') {
26+
} else if (file === 'generated_docs_data_v2.json') {
2827
return path.dirname(fullPath);
2928
}
3029
}
@@ -35,28 +34,10 @@ function findGeneratedDocsPath() {
3534
return docsPath || generatedDir; // Fallback to generated root if not found
3635
}
3736

38-
// Accept an API version argument (e.g. 2026-04-rc) to output targets.json into
39-
// a versioned directory matching the customer-account pattern.
40-
// Falls back to the directory containing generated_docs_data.json if not provided.
41-
const apiVersion = process.argv[2];
42-
43-
function resolveOutputPath() {
44-
if (apiVersion) {
45-
return path.join(
46-
__dirname,
47-
'generated',
48-
'checkout_ui_extensions',
49-
apiVersion,
50-
'targets.json',
51-
);
52-
}
53-
return path.join(findGeneratedDocsPath(), 'targets.json');
54-
}
55-
5637
// Configuration for checkout surface
5738
const config = {
5839
basePath: path.join(__dirname, '../../../src/surfaces/checkout'),
59-
outputPath: resolveOutputPath(),
40+
outputPath: path.join(findGeneratedDocsPath(), 'targets.json'),
6041
componentTypesPath: null,
6142
hasComponentTypes: false,
6243
};

packages/ui-extensions/docs/surfaces/checkout/build-docs.sh

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ else
3333
echo "Building docs for '$API_VERSION' checkout UI extensions API."
3434
fi
3535

36+
# Wipe the generated directory so stale files from previous runs don't linger.
37+
echo "Cleaning ./$DOCS_PATH/generated..."
38+
rm -rf ./$DOCS_PATH/generated
39+
3640
COMPILE_DOCS="yarn generate-docs --overridePath ./$DOCS_PATH/typeOverride.json --input ./$SRC_PATH --output ./$DOCS_PATH/generated"
3741

3842
# Copy all .d.ts files in components directory to .ts files so they can be picked up by the generate-docs tool
@@ -87,7 +91,7 @@ if [ $sed_exit -ne 0 ]; then
8791
fi
8892

8993
# Generate targets.json (extension targets + APIs + components mapping)
90-
node ./$DOCS_PATH/build-docs-targets-json.mjs $API_VERSION
94+
node ./$DOCS_PATH/build-docs-targets-json.mjs
9195
targets_exit=$?
9296
if [ $targets_exit -ne 0 ]; then
9397
fail_and_exit $targets_exit
@@ -106,12 +110,6 @@ if [ -d $SHOPIFY_DEV_PATH ]; then
106110
mkdir -p $SHOPIFY_DEV_DEST
107111
cp ./$DOCS_PATH/generated/* $SHOPIFY_DEV_DEST
108112

109-
# Also copy the versioned targets.json generated by build-docs-targets-json.mjs
110-
VERSIONED_TARGETS=./$DOCS_PATH/generated/checkout_ui_extensions/$API_VERSION/targets.json
111-
if [ -f "$VERSIONED_TARGETS" ]; then
112-
cp "$VERSIONED_TARGETS" $SHOPIFY_DEV_DEST/targets.json
113-
fi
114-
115113
# Replace 'latest' with the exact API version in relative doc links
116114
run_sed \
117115
"s/\/docs\/api\/checkout-ui-extensions\/latest/\/docs\/api\/checkout-ui-extensions\/$API_VERSION/gi" \

0 commit comments

Comments
 (0)