Skip to content

Commit 46f524c

Browse files
fix: linting issues
1 parent 24ca072 commit 46f524c

File tree

3 files changed

+61
-47
lines changed

3 files changed

+61
-47
lines changed

.github/scripts/aggregate-passport-metadata.js

100644100755
Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#!/usr/bin/env node
22

3+
'use strict';
4+
35
const fs = require('fs');
46
const path = require('path');
57

@@ -10,20 +12,25 @@ const OUTPUT_FILE = path.join(OUTPUT_DIR, 'passport-features.json');
1012
const FEATURES_JSON_PATH = path.join(PASSPORT_ROOT, 'features.json');
1113

1214
// Ensure output directory exists
13-
if (!fs.existsSync(OUTPUT_DIR)) {
14-
fs.mkdirSync(OUTPUT_DIR, { recursive: true });
15+
try {
16+
if (!fs.existsSync(OUTPUT_DIR)) {
17+
fs.mkdirSync(OUTPUT_DIR, { recursive: true });
18+
}
19+
} catch (error) {
20+
console.error(`Error creating output directory: ${error.message}`);
21+
process.exit(1);
1522
}
1623

1724
console.log('Processing Passport features metadata...');
1825

1926
// Load features.json to map script files to feature names
20-
let featuresMap = {};
27+
const featuresMap = {};
2128
try {
2229
const featuresContent = fs.readFileSync(FEATURES_JSON_PATH, 'utf8');
2330
const featuresJson = JSON.parse(featuresContent);
2431

2532
// Create mapping of script filename to feature name
26-
featuresJson.features.forEach(feature => {
33+
featuresJson.features.forEach((feature) => {
2734
const [featureName, scriptFile] = Object.entries(feature)[0];
2835
// Store both the full filename and just the filename without path
2936
featuresMap[scriptFile] = featureName;
@@ -47,7 +54,7 @@ const findMetadataFiles = () => {
4754
try {
4855
const files = fs.readdirSync(dir);
4956

50-
files.forEach(file => {
57+
files.forEach((file) => {
5158
const filePath = path.join(dir, file);
5259

5360
try {
@@ -75,7 +82,7 @@ const findMetadataFiles = () => {
7582
const processMetadataFiles = (metadataFiles) => {
7683
const featuresObject = {};
7784

78-
metadataFiles.forEach(metadataFile => {
85+
metadataFiles.forEach((metadataFile) => {
7986
console.log(`Processing ${metadataFile}`);
8087

8188
// Extract feature directory
@@ -89,7 +96,7 @@ const processMetadataFiles = (metadataFiles) => {
8996
try {
9097
// Look for any script file in this directory
9198
const dirFiles = fs.readdirSync(featureDir);
92-
const scriptFiles = dirFiles.filter(file => file.endsWith('.cs'));
99+
const scriptFiles = dirFiles.filter((file) => file.endsWith('.cs'));
93100

94101
// Try to match any script file to our feature map
95102
let found = false;
@@ -154,11 +161,20 @@ const processMetadataFiles = (metadataFiles) => {
154161
return featuresObject;
155162
};
156163

157-
// Main execution
158-
const metadataFiles = findMetadataFiles();
159-
const features = processMetadataFiles(metadataFiles);
160-
161-
// Create the final passport-features.json
162-
fs.writeFileSync(OUTPUT_FILE, JSON.stringify(features, null, 2));
164+
try {
165+
// Main execution
166+
const metadataFiles = findMetadataFiles();
167+
168+
if (metadataFiles.length === 0) {
169+
console.warn('No metadata files found. Output file will be empty.');
170+
}
171+
172+
const features = processMetadataFiles(metadataFiles);
163173

164-
console.log(`Created ${OUTPUT_FILE}`);
174+
// Create the final passport-features.json
175+
fs.writeFileSync(OUTPUT_FILE, JSON.stringify(features, null, 2));
176+
console.log(`Created ${OUTPUT_FILE}`);
177+
} catch (error) {
178+
console.error(`Fatal error: ${error.message}`);
179+
process.exit(1);
180+
}

.github/scripts/process-passport-tutorials.sh

100644100755
Lines changed: 30 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -4,76 +4,74 @@ set -e
44
set -x
55

66
# Directory where docs repo is cloned
7-
DOCS_REPO_DIR=${CLONE_DIR:-"./imx-docs"}
7+
DOCS_REPO_DIR="${CLONE_DIR:-"./imx-docs"}"
88

99
# Root of the Passport features
1010
PASSPORT_ROOT="./sample/Assets/Scripts/Passport"
1111

1212
echo "Processing Passport tutorials..."
1313

1414
# Load features.json to map script files to feature names
15-
FEATURES_JSON="$PASSPORT_ROOT/features.json"
16-
if [ ! -f "$FEATURES_JSON" ]; then
17-
echo "Error: features.json not found at $FEATURES_JSON"
15+
FEATURES_JSON="${PASSPORT_ROOT}/features.json"
16+
if [ ! -f "${FEATURES_JSON}" ]; then
17+
echo "Error: features.json not found at ${FEATURES_JSON}"
1818
exit 1
1919
fi
2020

2121
# Create _tutorials directory in docs repo
22-
TUTORIALS_DIR="$DOCS_REPO_DIR/docs/main/example/zkEVM/passport-examples/_tutorials"
23-
mkdir -p "$TUTORIALS_DIR"
22+
TUTORIALS_DIR="${DOCS_REPO_DIR}/docs/main/example/zkEVM/passport-examples/_tutorials"
23+
mkdir -p "${TUTORIALS_DIR}"
2424

25-
# Find all tutorial.md files
26-
TUTORIAL_FILES=$(find "$PASSPORT_ROOT" -name "tutorial.md" -type f)
27-
28-
# Process null-delimited filenames
29-
find "$PASSPORT_ROOT" -name "tutorial.md" -type f -print0 | while IFS= read -r -d '' TUTORIAL_FILE; do
30-
echo "Processing $TUTORIAL_FILE"
25+
# Process null-delimited filenames
26+
find "${PASSPORT_ROOT}" -name "tutorial.md" -type f -print0 | while IFS= read -r -d '' TUTORIAL_FILE; do
27+
echo "Processing ${TUTORIAL_FILE}"
3128

3229
# Extract feature directory
33-
FEATURE_DIR=$(dirname "$TUTORIAL_FILE")
30+
FEATURE_DIR=$(dirname "${TUTORIAL_FILE}")
3431

3532
# Try to find script file in this directory
36-
SCRIPT_FILE=$(find "$FEATURE_DIR" -name "*.cs" -type f -print0 | xargs -0 -n1 echo | head -n 1)
37-
if [ -z "$SCRIPT_FILE" ]; then
38-
echo "Warning: No script file found in $FEATURE_DIR, using directory name"
39-
FEATURE_NAME=$(basename "$FEATURE_DIR")
33+
SCRIPT_FILE=$(find "${FEATURE_DIR}" -name "*.cs" -type f -print0 | xargs -0 -n1 echo | head -n 1)
34+
35+
if [ -z "${SCRIPT_FILE}" ]; then
36+
echo "Warning: No script file found in ${FEATURE_DIR}, using directory name"
37+
FEATURE_NAME=$(basename "${FEATURE_DIR}")
4038
else
4139
# Extract script filename
42-
SCRIPT_FILENAME=$(basename "$SCRIPT_FILE")
40+
SCRIPT_FILENAME=$(basename "${SCRIPT_FILE}")
4341

4442
# Look up the feature name in features.json
4543
# Extract feature name with error handling
46-
if ! FEATURE_NAME=$(jq -r ".features[] | to_entries[] | select(.value == \"$SCRIPT_FILENAME\") | .key" "$FEATURES_JSON" 2>/dev/null); then
44+
if ! FEATURE_NAME=$(jq -r ".features[] | to_entries[] | select(.value == \"${SCRIPT_FILENAME}\") | .key" "${FEATURES_JSON}" 2>/dev/null); then
4745
echo "Warning: Error parsing features.json with jq, using directory name"
48-
FEATURE_NAME=$(basename "$FEATURE_DIR")
46+
FEATURE_NAME=$(basename "${FEATURE_DIR}")
4947
fi
5048

5149
# If not found in features.json, fallback to directory name
52-
if [ -z "$FEATURE_NAME" ] || [ "$FEATURE_NAME" == "null" ]; then
53-
echo "Warning: Feature for script $SCRIPT_FILENAME not found in features.json, using directory name"
54-
FEATURE_NAME=$(basename "$FEATURE_DIR")
50+
if [ -z "${FEATURE_NAME}" ] || [ "${FEATURE_NAME}" == "null" ]; then
51+
echo "Warning: Feature for script ${SCRIPT_FILENAME} not found in features.json, using directory name"
52+
FEATURE_NAME=$(basename "${FEATURE_DIR}")
5553
fi
5654
fi
5755

58-
echo "Feature name: $FEATURE_NAME"
56+
echo "Feature name: ${FEATURE_NAME}"
5957

6058
# Copy and rename tutorial file
61-
cp "$TUTORIAL_FILE" "$TUTORIALS_DIR/${FEATURE_NAME}.md"
62-
echo "Copied $TUTORIAL_FILE to $TUTORIALS_DIR/${FEATURE_NAME}.md"
59+
cp "${TUTORIAL_FILE}" "${TUTORIALS_DIR}/${FEATURE_NAME}.md"
60+
echo "Copied ${TUTORIAL_FILE} to ${TUTORIALS_DIR}/${FEATURE_NAME}.md"
6361
done
6462

6563
# Copy the generated JSON file
6664
JSON_FILE="./_parsed/passport-features.json"
67-
if [ -f "$JSON_FILE" ]; then
65+
if [ -f "${JSON_FILE}" ]; then
6866
# Create directory for JSON file if it doesn't exist
69-
JSON_DIR="$DOCS_REPO_DIR/docs/main/example/zkEVM/passport-examples"
70-
mkdir -p "$JSON_DIR"
67+
JSON_DIR="${DOCS_REPO_DIR}/docs/main/example/zkEVM/passport-examples"
68+
mkdir -p "${JSON_DIR}"
7169

7270
# Copy JSON file
73-
cp "$JSON_FILE" "$JSON_DIR/passport-features.json"
74-
echo "Copied $JSON_FILE to $JSON_DIR/passport-features.json"
71+
cp "${JSON_FILE}" "${JSON_DIR}/passport-features.json"
72+
echo "Copied ${JSON_FILE} to ${JSON_DIR}/passport-features.json"
7573
else
76-
echo "Warning: No passport-features.json found at $JSON_FILE"
74+
echo "Warning: No passport-features.json found at ${JSON_FILE}"
7775
fi
7876

7977
echo "Passport tutorial processing complete."

sample/Assets/Scripts/Passport/Login/tutorial.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
</div>
66

7-
Passport Login enables users to authenticate with the Immutable Passport service. This feature demonstrates how to implement user authentication in your Unity game using two different authentication methods: PKCE (Proof Key for Code Exchange) and Device Code Auth
7+
Passport Login enables users to authenticate with the Immutable Passport service. This feature demonstrates how to implement user authentication in your Unity game using two different authentication methods: PKCE (Proof Key for Code Exchange) and Device Code Auth.
88

99
<div class="button-component">
1010

0 commit comments

Comments
 (0)