From 7692c9984dc572c27970e69987bf7306c378e7ca Mon Sep 17 00:00:00 2001 From: Ruchi Anand Date: Mon, 15 Sep 2025 15:57:25 +0530 Subject: [PATCH 01/23] added workflow --- .github/workflows/css-variables-sync.yml | 26 ++++ scripts/validate-css-variables.js | 162 +++++++++++++++++++++++ 2 files changed, 188 insertions(+) create mode 100644 .github/workflows/css-variables-sync.yml create mode 100644 scripts/validate-css-variables.js diff --git a/.github/workflows/css-variables-sync.yml b/.github/workflows/css-variables-sync.yml new file mode 100644 index 000000000..2bbce83dd --- /dev/null +++ b/.github/workflows/css-variables-sync.yml @@ -0,0 +1,26 @@ +name: CSS Variables Validation + +on: + pull_request: + paths: + - 'src/css-variables.ts' + +jobs: + validate: + runs-on: self-hosted + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Checkout theme builder repo + uses: actions/checkout@v2 + with: + repository: ${{ secrets.THEME_BUILDER_REPO }} + path: theme-builder + ref: release + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Validate CSS variables + run: | + node scripts/validate-css-variables.js "$(cat theme-builder/src/data/sdkVariable.ts)" diff --git a/scripts/validate-css-variables.js b/scripts/validate-css-variables.js new file mode 100644 index 000000000..c72e55e1c --- /dev/null +++ b/scripts/validate-css-variables.js @@ -0,0 +1,162 @@ +#!/usr/bin/env node + +/** + * Script to validate CSS variables consistency between repositories + * This script extracts CSS variable names from the TypeScript interface + * and compares them with the implementation in another repository + */ + +const fs = require('fs'); +const path = require('path'); + +/** + * Extract CSS variable names from the TypeScript interface + * @param {string} filePath - Path to the css-variables.ts file + * @returns {string[]} Array of CSS variable names + */ +function extractVariablesFromInterface(filePath) { + try { + const content = fs.readFileSync(filePath, 'utf8'); + + // Extract variable names using regex + const variableRegex = /'--ts-var-[^']+'/g; + const matches = content.match(variableRegex); + + if (!matches) { + console.error('No CSS variables found in the interface file'); + return []; + } + + // Remove quotes and sort for consistent comparison + return matches.map(match => match.replace(/'/g, '')).sort(); + } catch (error) { + console.error(`Error reading interface file: ${error.message}`); + return []; + } +} + +/** + * Extract CSS variable names from the implementation object + * @param {string} content - Content of the implementation file + * @returns {string[]} Array of CSS variable names + */ +function extractVariablesFromImplementation(content) { + try { + // Extract variable names from object keys + const variableRegex = /'--ts-var-[^']+':/g; + const matches = content.match(variableRegex); + + if (!matches) { + console.error('No CSS variables found in the implementation'); + return []; + } + + // Remove quotes and colon, then sort for consistent comparison + return matches.map(match => match.replace(/[':]/g, '')).sort(); + } catch (error) { + console.error(`Error parsing implementation: ${error.message}`); + return []; + } +} + +/** + * Compare two arrays of CSS variables and report differences + * @param {string[]} interfaceVars - Variables from TypeScript interface + * @param {string[]} implementationVars - Variables from implementation + * @returns {object} Comparison result + */ +function compareVariables(interfaceVars, implementationVars) { + const missingInImplementation = interfaceVars.filter(varName => !implementationVars.includes(varName)); + const extraInImplementation = implementationVars.filter(varName => !interfaceVars.includes(varName)); + + return { + interfaceCount: interfaceVars.length, + implementationCount: implementationVars.length, + missingInImplementation, + extraInImplementation, + isConsistent: missingInImplementation.length === 0 && extraInImplementation.length === 0 + }; +} + +/** + * Main validation function + */ +function validateCSSVariables() { + console.log('šŸ” Validating CSS variables consistency...\n'); + + // Path to the interface file + const interfacePath = path.join(__dirname, '..', 'src', 'css-variables.ts'); + + // Check if interface file exists + if (!fs.existsSync(interfacePath)) { + console.error(`āŒ Interface file not found: ${interfacePath}`); + process.exit(1); + } + + // Extract variables from interface + const interfaceVars = extractVariablesFromInterface(interfacePath); + console.log(`šŸ“‹ Found ${interfaceVars.length} variables in TypeScript interface`); + + // Get implementation content from command line argument or environment + const implementationContent = process.argv[2] || process.env.CSS_VARS_IMPLEMENTATION; + + if (!implementationContent) { + console.log('āš ļø No implementation content provided. Use:'); + console.log(' node validate-css-variables.js "implementation content"'); + console.log(' or set CSS_VARS_IMPLEMENTATION environment variable'); + console.log('\nšŸ“‹ Variables in interface:'); + interfaceVars.forEach(varName => console.log(` - ${varName}`)); + return; + } + + // Extract variables from implementation + const implementationVars = extractVariablesFromImplementation(implementationContent); + console.log(`šŸ”§ Found ${implementationVars.length} variables in implementation`); + + // Compare variables + const comparison = compareVariables(interfaceVars, implementationVars); + + console.log('\nšŸ“Š Comparison Results:'); + console.log(` Interface variables: ${comparison.interfaceCount}`); + console.log(` Implementation variables: ${comparison.implementationCount}`); + + if (comparison.isConsistent) { + console.log('\nāœ… CSS variables are consistent between repositories!'); + process.exit(0); + } else { + console.log('\nāŒ CSS variables are NOT consistent:'); + + if (comparison.missingInImplementation.length > 0) { + console.log('\nšŸ”“ Missing in implementation:'); + comparison.missingInImplementation.forEach(varName => { + console.log(` - ${varName}`); + }); + } + + if (comparison.extraInImplementation.length > 0) { + console.log('\n🟔 Extra in implementation:'); + comparison.extraInImplementation.forEach(varName => { + console.log(` - ${varName}`); + }); + } + + console.log('\nšŸ’” To fix this:'); + console.log(' 1. Add missing variables to the implementation'); + console.log(' 2. Remove extra variables from the implementation'); + console.log(' 3. Or update the TypeScript interface if needed'); + + process.exit(1); + } +} + +// Run validation if this script is executed directly +if (require.main === module) { + validateCSSVariables(); +} + +module.exports = { + extractVariablesFromInterface, + extractVariablesFromImplementation, + compareVariables, + validateCSSVariables +}; From c49d9d61b0c7df4d3076224c4ef77ac977b9ee2f Mon Sep 17 00:00:00 2001 From: Ruchi Anand Date: Mon, 15 Sep 2025 16:01:42 +0530 Subject: [PATCH 02/23] fixed changes --- .github/workflows/css-variables-sync.yml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/css-variables-sync.yml b/.github/workflows/css-variables-sync.yml index 2bbce83dd..4027ec4f9 100644 --- a/.github/workflows/css-variables-sync.yml +++ b/.github/workflows/css-variables-sync.yml @@ -1,4 +1,4 @@ -name: CSS Variables Validation +name: CSS Variables Sync Check on: pull_request: @@ -7,12 +7,17 @@ on: jobs: validate: - runs-on: self-hosted + runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 with: fetch-depth: 0 + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '20' + - name: Checkout theme builder repo uses: actions/checkout@v2 with: From f7f9c81c52232e103abc699871ec2fddde8b9711 Mon Sep 17 00:00:00 2001 From: Ruchi Anand Date: Mon, 15 Sep 2025 16:16:12 +0530 Subject: [PATCH 03/23] added in main.yml --- .github/workflows/main.yml | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 1f820b0f9..f1cc4e6f3 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -64,3 +64,30 @@ jobs: # Create new package release - name: Publish dev package run: npx pkg-pr-new publish + + # CSS Variables validation job + css-validation: + runs-on: ubuntu-latest + # Only run if css-variables.ts is modified + if: contains(github.event.head_commit.modified, 'src/css-variables.ts') || contains(github.event.pull_request.changed_files, 'src/css-variables.ts') + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '20' + + - name: Checkout theme builder repo + uses: actions/checkout@v2 + with: + repository: ${{ secrets.THEME_BUILDER_REPO }} + path: theme-builder + ref: release + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Validate CSS variables + run: | + node scripts/validate-css-variables.js "$(cat theme-builder/src/data/sdkVariable.ts)" From 734d9778824ad4668e6eb0a55d320289f3a66e21 Mon Sep 17 00:00:00 2001 From: Ruchi Anand Date: Mon, 15 Sep 2025 16:24:14 +0530 Subject: [PATCH 04/23] fixed workflow --- .github/workflows/main.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f1cc4e6f3..cdaca20c6 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -68,8 +68,6 @@ jobs: # CSS Variables validation job css-validation: runs-on: ubuntu-latest - # Only run if css-variables.ts is modified - if: contains(github.event.head_commit.modified, 'src/css-variables.ts') || contains(github.event.pull_request.changed_files, 'src/css-variables.ts') steps: - uses: actions/checkout@v2 with: From a3bdbcee26da2a855b25c1d789032bf23490d999 Mon Sep 17 00:00:00 2001 From: Ruchi Anand Date: Mon, 15 Sep 2025 16:31:45 +0530 Subject: [PATCH 05/23] fixed workflow --- .github/workflows/main.yml | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index cdaca20c6..25d831420 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -78,14 +78,33 @@ jobs: with: node-version: '20' + - name: Debug repository access + run: | + echo "šŸ” Testing repository access..." + if [ -z "${{ secrets.THEME_BUILDER_REPO }}" ]; then + echo "āŒ THEME_BUILDER_REPO secret is not set" + echo "Please set THEME_BUILDER_REPO secret to: thoughtspot/Thoughtspot-theme-builder" + exit 1 + else + echo "āœ… THEME_BUILDER_REPO secret is set to: ${{ secrets.THEME_BUILDER_REPO }}" + if [ "${{ secrets.THEME_BUILDER_REPO }}" != "thoughtspot/Thoughtspot-theme-builder" ]; then + echo "āš ļø Warning: Expected 'thoughtspot/Thoughtspot-theme-builder' but got '${{ secrets.THEME_BUILDER_REPO }}'" + fi + fi + - name: Checkout theme builder repo uses: actions/checkout@v2 with: - repository: ${{ secrets.THEME_BUILDER_REPO }} + repository: thoughtspot/Thoughtspot-theme-builder path: theme-builder ref: release token: ${{ secrets.GITHUB_TOKEN }} - name: Validate CSS variables run: | + echo "šŸ” Starting CSS variables validation..." + echo "šŸ“ Checking theme builder file..." + ls -la theme-builder/src/data/sdkVariable.ts + echo "šŸ“‹ Running validation..." node scripts/validate-css-variables.js "$(cat theme-builder/src/data/sdkVariable.ts)" + echo "āœ… Validation completed!" From 4264a6f444d298fa5359efa3f33cd7737b78bdef Mon Sep 17 00:00:00 2001 From: Ruchi Anand Date: Mon, 15 Sep 2025 16:33:16 +0530 Subject: [PATCH 06/23] fixed workflow --- .github/workflows/main.yml | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 25d831420..5b754bc96 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -78,20 +78,6 @@ jobs: with: node-version: '20' - - name: Debug repository access - run: | - echo "šŸ” Testing repository access..." - if [ -z "${{ secrets.THEME_BUILDER_REPO }}" ]; then - echo "āŒ THEME_BUILDER_REPO secret is not set" - echo "Please set THEME_BUILDER_REPO secret to: thoughtspot/Thoughtspot-theme-builder" - exit 1 - else - echo "āœ… THEME_BUILDER_REPO secret is set to: ${{ secrets.THEME_BUILDER_REPO }}" - if [ "${{ secrets.THEME_BUILDER_REPO }}" != "thoughtspot/Thoughtspot-theme-builder" ]; then - echo "āš ļø Warning: Expected 'thoughtspot/Thoughtspot-theme-builder' but got '${{ secrets.THEME_BUILDER_REPO }}'" - fi - fi - - name: Checkout theme builder repo uses: actions/checkout@v2 with: From bc67408b9d04cb78faf41f31d2856be6ce7ea984 Mon Sep 17 00:00:00 2001 From: Ruchi Anand Date: Mon, 15 Sep 2025 16:57:50 +0530 Subject: [PATCH 07/23] fix 1 --- .github/workflows/css-variables-sync.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/css-variables-sync.yml b/.github/workflows/css-variables-sync.yml index 4027ec4f9..a32d9f40c 100644 --- a/.github/workflows/css-variables-sync.yml +++ b/.github/workflows/css-variables-sync.yml @@ -21,10 +21,10 @@ jobs: - name: Checkout theme builder repo uses: actions/checkout@v2 with: - repository: ${{ secrets.THEME_BUILDER_REPO }} + repository: thoughtspot/Thoughtspot-theme-builder path: theme-builder ref: release - token: ${{ secrets.GITHUB_TOKEN }} + token: ${{ secrets.THEME_BUILDER_TOKEN }} - name: Validate CSS variables run: | From a8a4174b508bc87526fd68ad4d365872d6d53942 Mon Sep 17 00:00:00 2001 From: Ruchi Anand Date: Mon, 15 Sep 2025 17:00:10 +0530 Subject: [PATCH 08/23] fix 2 --- .github/workflows/css-variables-sync.yml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/.github/workflows/css-variables-sync.yml b/.github/workflows/css-variables-sync.yml index a32d9f40c..8440c7c96 100644 --- a/.github/workflows/css-variables-sync.yml +++ b/.github/workflows/css-variables-sync.yml @@ -18,6 +18,25 @@ jobs: with: node-version: '20' + - name: Test repository access + run: | + echo "šŸ” Testing repository access..." + echo "Repository: thoughtspot/Thoughtspot-theme-builder" + echo "Branch: release" + + # Test if we can access the repository + if curl -s -H "Authorization: token ${{ secrets.THEME_BUILDER_TOKEN }}" \ + "https://api.github.com/repos/thoughtspot/Thoughtspot-theme-builder" | grep -q "full_name"; then + echo "āœ… Repository access confirmed" + else + echo "āŒ Cannot access repository. Possible issues:" + echo "1. Repository name is incorrect" + echo "2. Repository is under different organization" + echo "3. Token doesn't have access to this repository" + echo "4. Repository doesn't exist" + exit 1 + fi + - name: Checkout theme builder repo uses: actions/checkout@v2 with: From c3314ba5749990b51c16d8642bb523347e4ed6cb Mon Sep 17 00:00:00 2001 From: Ruchi Anand Date: Mon, 15 Sep 2025 17:03:22 +0530 Subject: [PATCH 09/23] fix 3 --- .github/workflows/css-variables-sync.yml | 35 ++++++++++++++++++------ 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/.github/workflows/css-variables-sync.yml b/.github/workflows/css-variables-sync.yml index 8440c7c96..642db77e2 100644 --- a/.github/workflows/css-variables-sync.yml +++ b/.github/workflows/css-variables-sync.yml @@ -24,16 +24,35 @@ jobs: echo "Repository: thoughtspot/Thoughtspot-theme-builder" echo "Branch: release" - # Test if we can access the repository - if curl -s -H "Authorization: token ${{ secrets.THEME_BUILDER_TOKEN }}" \ - "https://api.github.com/repos/thoughtspot/Thoughtspot-theme-builder" | grep -q "full_name"; then + # Test repository access + RESPONSE=$(curl -s -H "Authorization: token ${{ secrets.THEME_BUILDER_TOKEN }}" \ + "https://api.github.com/repos/thoughtspot/Thoughtspot-theme-builder") + + if echo "$RESPONSE" | grep -q "full_name"; then echo "āœ… Repository access confirmed" + + # Test branch access + BRANCH_RESPONSE=$(curl -s -H "Authorization: token ${{ secrets.THEME_BUILDER_TOKEN }}" \ + "https://api.github.com/repos/thoughtspot/Thoughtspot-theme-builder/branches/release") + + if echo "$BRANCH_RESPONSE" | grep -q "name"; then + echo "āœ… Release branch access confirmed" + else + echo "āŒ Release branch not found or not accessible" + echo "Available branches:" + curl -s -H "Authorization: token ${{ secrets.THEME_BUILDER_TOKEN }}" \ + "https://api.github.com/repos/thoughtspot/Thoughtspot-theme-builder/branches" | \ + jq -r '.[].name' 2>/dev/null || echo "Could not fetch branches" + exit 1 + fi else - echo "āŒ Cannot access repository. Possible issues:" - echo "1. Repository name is incorrect" - echo "2. Repository is under different organization" - echo "3. Token doesn't have access to this repository" - echo "4. Repository doesn't exist" + echo "āŒ Cannot access repository. Response:" + echo "$RESPONSE" + echo "" + echo "Possible issues:" + echo "1. Token doesn't have access to this repository" + echo "2. Token is invalid or expired" + echo "3. Repository permissions issue" exit 1 fi From 8fd06c97182df14b6a7925b56cd47c242cc01706 Mon Sep 17 00:00:00 2001 From: Ruchi Anand Date: Mon, 15 Sep 2025 17:05:40 +0530 Subject: [PATCH 10/23] fix 4 --- .github/workflows/main.yml | 50 +++++++++++++++++++++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5b754bc96..0f059dfde 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -78,13 +78,61 @@ jobs: with: node-version: '20' + - name: Test repository access + run: | + echo "šŸ” Testing repository access..." + echo "Repository: thoughtspot/Thoughtspot-theme-builder" + echo "Branch: release" + echo "Token present: ${{ secrets.THEME_BUILDER_TOKEN != '' }}" + + # Test repository access + echo "Making API call to GitHub..." + RESPONSE=$(curl -s -H "Authorization: token ${{ secrets.THEME_BUILDER_TOKEN }}" \ + "https://api.github.com/repos/thoughtspot/Thoughtspot-theme-builder") + + echo "API Response:" + echo "$RESPONSE" + echo "" + + if echo "$RESPONSE" | grep -q "full_name"; then + echo "āœ… Repository access confirmed" + + # Test branch access + echo "Testing branch access..." + BRANCH_RESPONSE=$(curl -s -H "Authorization: token ${{ secrets.THEME_BUILDER_TOKEN }}" \ + "https://api.github.com/repos/thoughtspot/Thoughtspot-theme-builder/branches/release") + + echo "Branch API Response:" + echo "$BRANCH_RESPONSE" + echo "" + + if echo "$BRANCH_RESPONSE" | grep -q "name"; then + echo "āœ… Release branch access confirmed" + else + echo "āŒ Release branch not found or not accessible" + echo "Available branches:" + curl -s -H "Authorization: token ${{ secrets.THEME_BUILDER_TOKEN }}" \ + "https://api.github.com/repos/thoughtspot/Thoughtspot-theme-builder/branches" | \ + jq -r '.[].name' 2>/dev/null || echo "Could not fetch branches" + exit 1 + fi + else + echo "āŒ Cannot access repository" + echo "Possible issues:" + echo "1. Token doesn't have access to this repository" + echo "2. Token is invalid or expired" + echo "3. Repository permissions issue" + echo "4. Repository doesn't exist" + exit 1 + fi + - name: Checkout theme builder repo uses: actions/checkout@v2 with: repository: thoughtspot/Thoughtspot-theme-builder path: theme-builder ref: release - token: ${{ secrets.GITHUB_TOKEN }} + token: ${{ secrets.THEME_BUILDER_TOKEN }} - name: Validate CSS variables run: | From 38c3eb5fb70988be502082e0eb264ff8461bb39f Mon Sep 17 00:00:00 2001 From: Ruchi Anand Date: Mon, 15 Sep 2025 17:13:30 +0530 Subject: [PATCH 11/23] fix 5 --- .github/workflows/main.yml | 76 +++++++++++++------------------------- 1 file changed, 26 insertions(+), 50 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 0f059dfde..8309a2b35 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -78,54 +78,6 @@ jobs: with: node-version: '20' - - name: Test repository access - run: | - echo "šŸ” Testing repository access..." - echo "Repository: thoughtspot/Thoughtspot-theme-builder" - echo "Branch: release" - echo "Token present: ${{ secrets.THEME_BUILDER_TOKEN != '' }}" - - # Test repository access - echo "Making API call to GitHub..." - RESPONSE=$(curl -s -H "Authorization: token ${{ secrets.THEME_BUILDER_TOKEN }}" \ - "https://api.github.com/repos/thoughtspot/Thoughtspot-theme-builder") - - echo "API Response:" - echo "$RESPONSE" - echo "" - - if echo "$RESPONSE" | grep -q "full_name"; then - echo "āœ… Repository access confirmed" - - # Test branch access - echo "Testing branch access..." - BRANCH_RESPONSE=$(curl -s -H "Authorization: token ${{ secrets.THEME_BUILDER_TOKEN }}" \ - "https://api.github.com/repos/thoughtspot/Thoughtspot-theme-builder/branches/release") - - echo "Branch API Response:" - echo "$BRANCH_RESPONSE" - echo "" - - if echo "$BRANCH_RESPONSE" | grep -q "name"; then - echo "āœ… Release branch access confirmed" - else - echo "āŒ Release branch not found or not accessible" - echo "Available branches:" - curl -s -H "Authorization: token ${{ secrets.THEME_BUILDER_TOKEN }}" \ - "https://api.github.com/repos/thoughtspot/Thoughtspot-theme-builder/branches" | \ - jq -r '.[].name' 2>/dev/null || echo "Could not fetch branches" - exit 1 - fi - else - echo "āŒ Cannot access repository" - echo "Possible issues:" - echo "1. Token doesn't have access to this repository" - echo "2. Token is invalid or expired" - echo "3. Repository permissions issue" - echo "4. Repository doesn't exist" - exit 1 - fi - - name: Checkout theme builder repo uses: actions/checkout@v2 with: @@ -133,12 +85,36 @@ jobs: path: theme-builder ref: release token: ${{ secrets.THEME_BUILDER_TOKEN }} + fetch-depth: 1 + + - name: Verify checkout and file access + run: | + echo "šŸ” Verifying checkout..." + echo "Current directory: $(pwd)" + echo "Theme builder directory contents:" + ls -la theme-builder/ || echo "Theme builder directory not found" + echo "" + + echo "Checking for the target file..." + if [ -f "theme-builder/src/data/sdkVariable.ts" ]; then + echo "āœ… Found target file: theme-builder/src/data/sdkVariable.ts" + echo "File size: $(wc -c < theme-builder/src/data/sdkVariable.ts) bytes" + echo "First few lines:" + head -5 theme-builder/src/data/sdkVariable.ts + else + echo "āŒ Target file not found: theme-builder/src/data/sdkVariable.ts" + echo "Available files in src/data/:" + ls -la theme-builder/src/data/ 2>/dev/null || echo "src/data directory not found" + echo "" + echo "Available files in src/:" + ls -la theme-builder/src/ 2>/dev/null || echo "src directory not found" + exit 1 + fi - name: Validate CSS variables run: | echo "šŸ” Starting CSS variables validation..." - echo "šŸ“ Checking theme builder file..." - ls -la theme-builder/src/data/sdkVariable.ts + echo "šŸ“ Using theme builder file: theme-builder/src/data/sdkVariable.ts" echo "šŸ“‹ Running validation..." node scripts/validate-css-variables.js "$(cat theme-builder/src/data/sdkVariable.ts)" echo "āœ… Validation completed!" From 7b36bba215eedae733a3a4d6288306dcd3e5d602 Mon Sep 17 00:00:00 2001 From: Ruchi Anand Date: Mon, 15 Sep 2025 17:15:57 +0530 Subject: [PATCH 12/23] fix 6 --- .github/workflows/main.yml | 60 +++++++++++++++++++++++++++----------- 1 file changed, 43 insertions(+), 17 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 8309a2b35..8d35f7a00 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -83,38 +83,64 @@ jobs: with: repository: thoughtspot/Thoughtspot-theme-builder path: theme-builder - ref: release + ref: main token: ${{ secrets.THEME_BUILDER_TOKEN }} fetch-depth: 1 - name: Verify checkout and file access run: | - echo "šŸ” Verifying checkout..." + echo "šŸ” Verifying checkout from main branch..." echo "Current directory: $(pwd)" echo "Theme builder directory contents:" ls -la theme-builder/ || echo "Theme builder directory not found" echo "" - echo "Checking for the target file..." - if [ -f "theme-builder/src/data/sdkVariable.ts" ]; then - echo "āœ… Found target file: theme-builder/src/data/sdkVariable.ts" - echo "File size: $(wc -c < theme-builder/src/data/sdkVariable.ts) bytes" - echo "First few lines:" - head -5 theme-builder/src/data/sdkVariable.ts - else - echo "āŒ Target file not found: theme-builder/src/data/sdkVariable.ts" - echo "Available files in src/data/:" - ls -la theme-builder/src/data/ 2>/dev/null || echo "src/data directory not found" - echo "" - echo "Available files in src/:" - ls -la theme-builder/src/ 2>/dev/null || echo "src directory not found" + echo "Available files in src/:" + ls -la theme-builder/src/ 2>/dev/null || echo "src directory not found" + echo "" + + echo "Searching for sdkVariable files..." + find theme-builder -name "*sdkVariable*" -type f 2>/dev/null || echo "No sdkVariable files found" + echo "" + + echo "Searching for any .ts files in src/:" + find theme-builder/src -name "*.ts" -type f 2>/dev/null || echo "No .ts files found in src/" + echo "" + + echo "Searching for data directory..." + find theme-builder -name "data" -type d 2>/dev/null || echo "No data directory found" + echo "" + + # Try to find the file with different possible names + POSSIBLE_FILES=( + "theme-builder/src/data/sdkVariable.ts" + "theme-builder/src/sdkVariable.ts" + "theme-builder/sdkVariable.ts" + "theme-builder/src/variables.ts" + "theme-builder/src/css-variables.ts" + ) + + FOUND_FILE="" + for file in "${POSSIBLE_FILES[@]}"; do + if [ -f "$file" ]; then + echo "āœ… Found file: $file" + FOUND_FILE="$file" + break + fi + done + + if [ -z "$FOUND_FILE" ]; then + echo "āŒ Could not find the target file with any expected name" + echo "Please check the repository structure and update the file path" exit 1 fi + + echo "FILE_PATH=$FOUND_FILE" >> $GITHUB_ENV - name: Validate CSS variables run: | echo "šŸ” Starting CSS variables validation..." - echo "šŸ“ Using theme builder file: theme-builder/src/data/sdkVariable.ts" + echo "šŸ“ Using theme builder file: ${{ env.FILE_PATH }}" echo "šŸ“‹ Running validation..." - node scripts/validate-css-variables.js "$(cat theme-builder/src/data/sdkVariable.ts)" + node scripts/validate-css-variables.js "$(cat ${{ env.FILE_PATH }})" echo "āœ… Validation completed!" From cd3e4c1d417a39764c9b569bfede83c8f2609d1d Mon Sep 17 00:00:00 2001 From: Ruchi Anand Date: Mon, 15 Sep 2025 17:18:15 +0530 Subject: [PATCH 13/23] added new var --- src/css-variables.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/css-variables.ts b/src/css-variables.ts index ac28149dd..ee84b1350 100644 --- a/src/css-variables.ts +++ b/src/css-variables.ts @@ -8,6 +8,11 @@ export interface CustomCssVariables { */ '--ts-var-root-background'?: string; + /** + * TEST VARIABLE - This should cause validation to fail + */ + '--ts-var-test-variable'?: string; + /** * Color of the text on application pages. */ From 92d6fb633c26621b8804e0b5fac2f682c5366e8e Mon Sep 17 00:00:00 2001 From: Ruchi Anand Date: Mon, 15 Sep 2025 17:19:47 +0530 Subject: [PATCH 14/23] fix 7 --- .github/workflows/main.yml | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 8d35f7a00..700c438cc 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -141,6 +141,15 @@ jobs: run: | echo "šŸ” Starting CSS variables validation..." echo "šŸ“ Using theme builder file: ${{ env.FILE_PATH }}" - echo "šŸ“‹ Running validation..." - node scripts/validate-css-variables.js "$(cat ${{ env.FILE_PATH }})" - echo "āœ… Validation completed!" + + # Check if the file exists + if [ -f "${{ env.FILE_PATH }}" ]; then + echo "āœ… File exists, running validation..." + node scripts/validate-css-variables.js "$(cat ${{ env.FILE_PATH }})" + echo "āœ… Validation completed!" + else + echo "āŒ File not found: ${{ env.FILE_PATH }}" + echo "Available files in theme-builder:" + find theme-builder -name "*.ts" -type f 2>/dev/null || echo "No .ts files found" + exit 1 + fi From 6c9b93f6e12dbd4a58e4e322451367dbcc45d674 Mon Sep 17 00:00:00 2001 From: Ruchi Anand Date: Mon, 15 Sep 2025 17:25:58 +0530 Subject: [PATCH 15/23] fix 8 --- .github/workflows/main.yml | 69 ++++++++----------------------- scripts/validate-css-variables.js | 8 ++++ 2 files changed, 25 insertions(+), 52 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 700c438cc..b48a6da9e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -95,61 +95,26 @@ jobs: ls -la theme-builder/ || echo "Theme builder directory not found" echo "" - echo "Available files in src/:" - ls -la theme-builder/src/ 2>/dev/null || echo "src directory not found" - echo "" - - echo "Searching for sdkVariable files..." - find theme-builder -name "*sdkVariable*" -type f 2>/dev/null || echo "No sdkVariable files found" - echo "" - - echo "Searching for any .ts files in src/:" - find theme-builder/src -name "*.ts" -type f 2>/dev/null || echo "No .ts files found in src/" - echo "" - - echo "Searching for data directory..." - find theme-builder -name "data" -type d 2>/dev/null || echo "No data directory found" - echo "" - - # Try to find the file with different possible names - POSSIBLE_FILES=( - "theme-builder/src/data/sdkVariable.ts" - "theme-builder/src/sdkVariable.ts" - "theme-builder/sdkVariable.ts" - "theme-builder/src/variables.ts" - "theme-builder/src/css-variables.ts" - ) - - FOUND_FILE="" - for file in "${POSSIBLE_FILES[@]}"; do - if [ -f "$file" ]; then - echo "āœ… Found file: $file" - FOUND_FILE="$file" - break - fi - done - - if [ -z "$FOUND_FILE" ]; then - echo "āŒ Could not find the target file with any expected name" - echo "Please check the repository structure and update the file path" + echo "Checking for the target file..." + if [ -f "theme-builder/src/data/sdkVariable.ts" ]; then + echo "āœ… Found target file: theme-builder/src/data/sdkVariable.ts" + echo "File size: $(wc -c < theme-builder/src/data/sdkVariable.ts) bytes" + echo "First few lines:" + head -5 theme-builder/src/data/sdkVariable.ts + else + echo "āŒ Target file not found: theme-builder/src/data/sdkVariable.ts" + echo "Available files in src/:" + ls -la theme-builder/src/ 2>/dev/null || echo "src directory not found" + echo "" + echo "Searching for sdkVariable files..." + find theme-builder -name "*sdkVariable*" -type f 2>/dev/null || echo "No sdkVariable files found" exit 1 fi - - echo "FILE_PATH=$FOUND_FILE" >> $GITHUB_ENV - name: Validate CSS variables run: | echo "šŸ” Starting CSS variables validation..." - echo "šŸ“ Using theme builder file: ${{ env.FILE_PATH }}" - - # Check if the file exists - if [ -f "${{ env.FILE_PATH }}" ]; then - echo "āœ… File exists, running validation..." - node scripts/validate-css-variables.js "$(cat ${{ env.FILE_PATH }})" - echo "āœ… Validation completed!" - else - echo "āŒ File not found: ${{ env.FILE_PATH }}" - echo "Available files in theme-builder:" - find theme-builder -name "*.ts" -type f 2>/dev/null || echo "No .ts files found" - exit 1 - fi + echo "šŸ“ Using theme builder file: theme-builder/src/data/sdkVariable.ts" + echo "šŸ“‹ Running validation..." + node scripts/validate-css-variables.js "$(cat theme-builder/src/data/sdkVariable.ts)" + echo "āœ… Validation completed!" diff --git a/scripts/validate-css-variables.js b/scripts/validate-css-variables.js index c72e55e1c..3884f438c 100644 --- a/scripts/validate-css-variables.js +++ b/scripts/validate-css-variables.js @@ -83,15 +83,21 @@ function compareVariables(interfaceVars, implementationVars) { */ function validateCSSVariables() { console.log('šŸ” Validating CSS variables consistency...\n'); + console.log('šŸ“ Script location:', __filename); + console.log('šŸ“ Working directory:', process.cwd()); + console.log('šŸ“ Command line arguments:', process.argv); + console.log(''); // Path to the interface file const interfacePath = path.join(__dirname, '..', 'src', 'css-variables.ts'); + console.log('šŸ“ Interface file path:', interfacePath); // Check if interface file exists if (!fs.existsSync(interfacePath)) { console.error(`āŒ Interface file not found: ${interfacePath}`); process.exit(1); } + console.log('āœ… Interface file exists'); // Extract variables from interface const interfaceVars = extractVariablesFromInterface(interfacePath); @@ -99,6 +105,8 @@ function validateCSSVariables() { // Get implementation content from command line argument or environment const implementationContent = process.argv[2] || process.env.CSS_VARS_IMPLEMENTATION; + console.log('šŸ“ Implementation content length:', implementationContent ? implementationContent.length : 'undefined'); + console.log('šŸ“ Implementation content preview:', implementationContent ? implementationContent.substring(0, 200) + '...' : 'undefined'); if (!implementationContent) { console.log('āš ļø No implementation content provided. Use:'); From 3066ed45ac434431fc7cc51c5349b1b7f456a042 Mon Sep 17 00:00:00 2001 From: Ruchi Anand Date: Mon, 15 Sep 2025 17:28:28 +0530 Subject: [PATCH 16/23] fix 9 --- .github/workflows/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b48a6da9e..e5fdfb65d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -114,7 +114,7 @@ jobs: - name: Validate CSS variables run: | echo "šŸ” Starting CSS variables validation..." - echo "šŸ“ Using theme builder file: theme-builder/src/data/sdkVariable.ts" + echo "šŸ“ Using theme builder file: ./src/data/sdkVariable.ts" echo "šŸ“‹ Running validation..." - node scripts/validate-css-variables.js "$(cat theme-builder/src/data/sdkVariable.ts)" + node scripts/validate-css-variables.js "$(cat ./src/data/sdkVariable.ts)" echo "āœ… Validation completed!" From db2c883ca03d581c539556e9a15468fd8f86ba85 Mon Sep 17 00:00:00 2001 From: Ruchi Anand Date: Mon, 15 Sep 2025 17:30:47 +0530 Subject: [PATCH 17/23] fix 10 --- .github/workflows/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e5fdfb65d..b48a6da9e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -114,7 +114,7 @@ jobs: - name: Validate CSS variables run: | echo "šŸ” Starting CSS variables validation..." - echo "šŸ“ Using theme builder file: ./src/data/sdkVariable.ts" + echo "šŸ“ Using theme builder file: theme-builder/src/data/sdkVariable.ts" echo "šŸ“‹ Running validation..." - node scripts/validate-css-variables.js "$(cat ./src/data/sdkVariable.ts)" + node scripts/validate-css-variables.js "$(cat theme-builder/src/data/sdkVariable.ts)" echo "āœ… Validation completed!" From dd4367deede53390a56031084cf75265bd490be1 Mon Sep 17 00:00:00 2001 From: Ruchi Anand Date: Mon, 15 Sep 2025 17:32:03 +0530 Subject: [PATCH 18/23] removing esisting --- src/css-variables.ts | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/css-variables.ts b/src/css-variables.ts index ee84b1350..692d98141 100644 --- a/src/css-variables.ts +++ b/src/css-variables.ts @@ -3,15 +3,6 @@ * are the only allowed variables possible. */ export interface CustomCssVariables { - /** - * Background color of the Liveboard, visualization, Search, and Answer pages. - */ - '--ts-var-root-background'?: string; - - /** - * TEST VARIABLE - This should cause validation to fail - */ - '--ts-var-test-variable'?: string; /** * Color of the text on application pages. From fcb85abd6b05dbc20adb83e1221529313c615a16 Mon Sep 17 00:00:00 2001 From: Ruchi Anand Date: Mon, 15 Sep 2025 17:33:41 +0530 Subject: [PATCH 19/23] fixed with correct variables --- src/css-variables.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/css-variables.ts b/src/css-variables.ts index 692d98141..ac28149dd 100644 --- a/src/css-variables.ts +++ b/src/css-variables.ts @@ -3,6 +3,10 @@ * are the only allowed variables possible. */ export interface CustomCssVariables { + /** + * Background color of the Liveboard, visualization, Search, and Answer pages. + */ + '--ts-var-root-background'?: string; /** * Color of the text on application pages. From 0a02986ed357f8aa8b6ff868ce734cf6138fce65 Mon Sep 17 00:00:00 2001 From: Ruchi Anand Date: Mon, 15 Sep 2025 17:37:38 +0530 Subject: [PATCH 20/23] added workflow --- .../workflows/css-variables-validation.yml | 47 ++++++++++++++++ .github/workflows/main.yml | 53 ------------------- 2 files changed, 47 insertions(+), 53 deletions(-) create mode 100644 .github/workflows/css-variables-validation.yml diff --git a/.github/workflows/css-variables-validation.yml b/.github/workflows/css-variables-validation.yml new file mode 100644 index 000000000..41ada7a42 --- /dev/null +++ b/.github/workflows/css-variables-validation.yml @@ -0,0 +1,47 @@ +name: CSS Variables Validation + +on: + pull_request: + paths: + - 'src/css-variables.ts' + workflow_dispatch: # Allow manual triggering + +jobs: + validate-css-variables: + runs-on: ubuntu-latest + steps: + - name: Checkout current repository + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '20' + + - name: Checkout theme builder repository + uses: actions/checkout@v2 + with: + repository: thoughtspot/Thoughtspot-theme-builder + path: theme-builder + ref: main + token: ${{ secrets.THEME_BUILDER_TOKEN }} + fetch-depth: 1 + + - name: Verify theme builder file access + run: | + echo "šŸ” Verifying theme builder file access..." + echo "āœ… Theme builder file: theme-builder/src/data/sdkVariable.ts" + echo "File size: $(wc -c < theme-builder/src/data/sdkVariable.ts) bytes" + + - name: Validate CSS variables consistency + run: | + echo "šŸ” Starting CSS variables validation..." + echo "Interface file: src/css-variables.ts" + echo "Implementation file: theme-builder/src/data/sdkVariable.ts" + echo "Running validation..." + + node scripts/validate-css-variables.js "$(cat theme-builder/src/data/sdkVariable.ts)" + + echo "āœ… CSS variables validation completed successfully!" diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b48a6da9e..d00aed5d8 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -65,56 +65,3 @@ jobs: - name: Publish dev package run: npx pkg-pr-new publish - # CSS Variables validation job - css-validation: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - - name: Setup Node.js - uses: actions/setup-node@v4 - with: - node-version: '20' - - - name: Checkout theme builder repo - uses: actions/checkout@v2 - with: - repository: thoughtspot/Thoughtspot-theme-builder - path: theme-builder - ref: main - token: ${{ secrets.THEME_BUILDER_TOKEN }} - fetch-depth: 1 - - - name: Verify checkout and file access - run: | - echo "šŸ” Verifying checkout from main branch..." - echo "Current directory: $(pwd)" - echo "Theme builder directory contents:" - ls -la theme-builder/ || echo "Theme builder directory not found" - echo "" - - echo "Checking for the target file..." - if [ -f "theme-builder/src/data/sdkVariable.ts" ]; then - echo "āœ… Found target file: theme-builder/src/data/sdkVariable.ts" - echo "File size: $(wc -c < theme-builder/src/data/sdkVariable.ts) bytes" - echo "First few lines:" - head -5 theme-builder/src/data/sdkVariable.ts - else - echo "āŒ Target file not found: theme-builder/src/data/sdkVariable.ts" - echo "Available files in src/:" - ls -la theme-builder/src/ 2>/dev/null || echo "src directory not found" - echo "" - echo "Searching for sdkVariable files..." - find theme-builder -name "*sdkVariable*" -type f 2>/dev/null || echo "No sdkVariable files found" - exit 1 - fi - - - name: Validate CSS variables - run: | - echo "šŸ” Starting CSS variables validation..." - echo "šŸ“ Using theme builder file: theme-builder/src/data/sdkVariable.ts" - echo "šŸ“‹ Running validation..." - node scripts/validate-css-variables.js "$(cat theme-builder/src/data/sdkVariable.ts)" - echo "āœ… Validation completed!" From 860f2af91c20b4c9661f7eb90e2c826c8c541aec Mon Sep 17 00:00:00 2001 From: Ruchi Anand Date: Mon, 15 Sep 2025 17:42:06 +0530 Subject: [PATCH 21/23] fixed all --- .github/workflows/css-variables-sync.yml | 69 ------------------- .../workflows/css-variables-validation.yml | 14 ++-- .github/workflows/main.yml | 1 - scripts/validate-css-variables.js | 39 ++--------- 4 files changed, 11 insertions(+), 112 deletions(-) delete mode 100644 .github/workflows/css-variables-sync.yml diff --git a/.github/workflows/css-variables-sync.yml b/.github/workflows/css-variables-sync.yml deleted file mode 100644 index 642db77e2..000000000 --- a/.github/workflows/css-variables-sync.yml +++ /dev/null @@ -1,69 +0,0 @@ -name: CSS Variables Sync Check - -on: - pull_request: - paths: - - 'src/css-variables.ts' - -jobs: - validate: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - - name: Setup Node.js - uses: actions/setup-node@v4 - with: - node-version: '20' - - - name: Test repository access - run: | - echo "šŸ” Testing repository access..." - echo "Repository: thoughtspot/Thoughtspot-theme-builder" - echo "Branch: release" - - # Test repository access - RESPONSE=$(curl -s -H "Authorization: token ${{ secrets.THEME_BUILDER_TOKEN }}" \ - "https://api.github.com/repos/thoughtspot/Thoughtspot-theme-builder") - - if echo "$RESPONSE" | grep -q "full_name"; then - echo "āœ… Repository access confirmed" - - # Test branch access - BRANCH_RESPONSE=$(curl -s -H "Authorization: token ${{ secrets.THEME_BUILDER_TOKEN }}" \ - "https://api.github.com/repos/thoughtspot/Thoughtspot-theme-builder/branches/release") - - if echo "$BRANCH_RESPONSE" | grep -q "name"; then - echo "āœ… Release branch access confirmed" - else - echo "āŒ Release branch not found or not accessible" - echo "Available branches:" - curl -s -H "Authorization: token ${{ secrets.THEME_BUILDER_TOKEN }}" \ - "https://api.github.com/repos/thoughtspot/Thoughtspot-theme-builder/branches" | \ - jq -r '.[].name' 2>/dev/null || echo "Could not fetch branches" - exit 1 - fi - else - echo "āŒ Cannot access repository. Response:" - echo "$RESPONSE" - echo "" - echo "Possible issues:" - echo "1. Token doesn't have access to this repository" - echo "2. Token is invalid or expired" - echo "3. Repository permissions issue" - exit 1 - fi - - - name: Checkout theme builder repo - uses: actions/checkout@v2 - with: - repository: thoughtspot/Thoughtspot-theme-builder - path: theme-builder - ref: release - token: ${{ secrets.THEME_BUILDER_TOKEN }} - - - name: Validate CSS variables - run: | - node scripts/validate-css-variables.js "$(cat theme-builder/src/data/sdkVariable.ts)" diff --git a/.github/workflows/css-variables-validation.yml b/.github/workflows/css-variables-validation.yml index 41ada7a42..8b16dd372 100644 --- a/.github/workflows/css-variables-validation.yml +++ b/.github/workflows/css-variables-validation.yml @@ -4,7 +4,7 @@ on: pull_request: paths: - 'src/css-variables.ts' - workflow_dispatch: # Allow manual triggering + workflow_dispatch: jobs: validate-css-variables: @@ -31,17 +31,11 @@ jobs: - name: Verify theme builder file access run: | - echo "šŸ” Verifying theme builder file access..." - echo "āœ… Theme builder file: theme-builder/src/data/sdkVariable.ts" - echo "File size: $(wc -c < theme-builder/src/data/sdkVariable.ts) bytes" + echo "Verifying theme builder file access..." + echo "Theme builder file: theme-builder/src/data/sdkVariable.ts" - name: Validate CSS variables consistency run: | - echo "šŸ” Starting CSS variables validation..." - echo "Interface file: src/css-variables.ts" - echo "Implementation file: theme-builder/src/data/sdkVariable.ts" echo "Running validation..." - node scripts/validate-css-variables.js "$(cat theme-builder/src/data/sdkVariable.ts)" - - echo "āœ… CSS variables validation completed successfully!" + echo "CSS variables validation completed successfully!" diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d00aed5d8..1f820b0f9 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -64,4 +64,3 @@ jobs: # Create new package release - name: Publish dev package run: npx pkg-pr-new publish - diff --git a/scripts/validate-css-variables.js b/scripts/validate-css-variables.js index 3884f438c..be4ed0faf 100644 --- a/scripts/validate-css-variables.js +++ b/scripts/validate-css-variables.js @@ -82,77 +82,52 @@ function compareVariables(interfaceVars, implementationVars) { * Main validation function */ function validateCSSVariables() { - console.log('šŸ” Validating CSS variables consistency...\n'); - console.log('šŸ“ Script location:', __filename); - console.log('šŸ“ Working directory:', process.cwd()); - console.log('šŸ“ Command line arguments:', process.argv); - console.log(''); - // Path to the interface file const interfacePath = path.join(__dirname, '..', 'src', 'css-variables.ts'); - console.log('šŸ“ Interface file path:', interfacePath); // Check if interface file exists if (!fs.existsSync(interfacePath)) { console.error(`āŒ Interface file not found: ${interfacePath}`); process.exit(1); } - console.log('āœ… Interface file exists'); // Extract variables from interface const interfaceVars = extractVariablesFromInterface(interfacePath); - console.log(`šŸ“‹ Found ${interfaceVars.length} variables in TypeScript interface`); // Get implementation content from command line argument or environment const implementationContent = process.argv[2] || process.env.CSS_VARS_IMPLEMENTATION; - console.log('šŸ“ Implementation content length:', implementationContent ? implementationContent.length : 'undefined'); - console.log('šŸ“ Implementation content preview:', implementationContent ? implementationContent.substring(0, 200) + '...' : 'undefined'); if (!implementationContent) { - console.log('āš ļø No implementation content provided. Use:'); - console.log(' node validate-css-variables.js "implementation content"'); - console.log(' or set CSS_VARS_IMPLEMENTATION environment variable'); - console.log('\nšŸ“‹ Variables in interface:'); - interfaceVars.forEach(varName => console.log(` - ${varName}`)); + console.log('āš ļø No implementation content provided'); return; } // Extract variables from implementation const implementationVars = extractVariablesFromImplementation(implementationContent); - console.log(`šŸ”§ Found ${implementationVars.length} variables in implementation`); // Compare variables const comparison = compareVariables(interfaceVars, implementationVars); - console.log('\nšŸ“Š Comparison Results:'); - console.log(` Interface variables: ${comparison.interfaceCount}`); - console.log(` Implementation variables: ${comparison.implementationCount}`); - if (comparison.isConsistent) { - console.log('\nāœ… CSS variables are consistent between repositories!'); + console.log('āœ… CSS variables are consistent'); process.exit(0); } else { - console.log('\nāŒ CSS variables are NOT consistent:'); + console.log('āŒ CSS variables are NOT consistent:'); if (comparison.missingInImplementation.length > 0) { - console.log('\nšŸ”“ Missing in implementation:'); + console.log('Missing in implementation:'); comparison.missingInImplementation.forEach(varName => { - console.log(` - ${varName}`); + console.log(` - ${varName}`); }); } if (comparison.extraInImplementation.length > 0) { - console.log('\n🟔 Extra in implementation:'); + console.log('Extra in implementation:'); comparison.extraInImplementation.forEach(varName => { - console.log(` - ${varName}`); + console.log(` - ${varName}`); }); } - console.log('\nšŸ’” To fix this:'); - console.log(' 1. Add missing variables to the implementation'); - console.log(' 2. Remove extra variables from the implementation'); - console.log(' 3. Or update the TypeScript interface if needed'); - process.exit(1); } } From 0b3eef48e358d250ca29319318c7498135b5c02f Mon Sep 17 00:00:00 2001 From: Ruchi Anand Date: Thu, 20 Nov 2025 10:08:32 +0530 Subject: [PATCH 22/23] code refactoring --- scripts/validate-css-variables.js | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/scripts/validate-css-variables.js b/scripts/validate-css-variables.js index be4ed0faf..35b589133 100644 --- a/scripts/validate-css-variables.js +++ b/scripts/validate-css-variables.js @@ -43,7 +43,7 @@ function extractVariablesFromInterface(filePath) { function extractVariablesFromImplementation(content) { try { // Extract variable names from object keys - const variableRegex = /'--ts-var-[^']+':/g; + const variableRegex = /'--ts-var-[^']+'\s*:/g; const matches = content.match(variableRegex); if (!matches) { @@ -52,7 +52,7 @@ function extractVariablesFromImplementation(content) { } // Remove quotes and colon, then sort for consistent comparison - return matches.map(match => match.replace(/[':]/g, '')).sort(); + return matches.map(match => match.replace(/[':]/g, '').trim()).sort(); } catch (error) { console.error(`Error parsing implementation: ${error.message}`); return []; @@ -66,8 +66,10 @@ function extractVariablesFromImplementation(content) { * @returns {object} Comparison result */ function compareVariables(interfaceVars, implementationVars) { - const missingInImplementation = interfaceVars.filter(varName => !implementationVars.includes(varName)); - const extraInImplementation = implementationVars.filter(varName => !interfaceVars.includes(varName)); + const implementationSet = new Set(implementationVars); + const interfaceSet = new Set(interfaceVars); + const missingInImplementation = interfaceVars.filter(varName => !implementationSet.has(varName)); + const extraInImplementation = implementationVars.filter(varName => !interfaceSet.has(varName)); return { interfaceCount: interfaceVars.length, @@ -87,32 +89,38 @@ function validateCSSVariables() { // Check if interface file exists if (!fs.existsSync(interfacePath)) { - console.error(`āŒ Interface file not found: ${interfacePath}`); + console.error(`Interface file not found: ${interfacePath}`); process.exit(1); } // Extract variables from interface const interfaceVars = extractVariablesFromInterface(interfacePath); - + if (interfaceVars === null) { + console.error('Error extracting variables from interface'); + process.exit(1); + } // Get implementation content from command line argument or environment const implementationContent = process.argv[2] || process.env.CSS_VARS_IMPLEMENTATION; if (!implementationContent) { - console.log('āš ļø No implementation content provided'); + console.log('No implementation content provided'); return; } // Extract variables from implementation const implementationVars = extractVariablesFromImplementation(implementationContent); - + if (implementationVars === null) { + console.error('Error extracting variables from implementation'); + process.exit(1); + } // Compare variables const comparison = compareVariables(interfaceVars, implementationVars); if (comparison.isConsistent) { - console.log('āœ… CSS variables are consistent'); + console.log('CSS variables are consistent'); process.exit(0); } else { - console.log('āŒ CSS variables are NOT consistent:'); + console.log('CSS variables are NOT consistent:'); if (comparison.missingInImplementation.length > 0) { console.log('Missing in implementation:'); From d830fc2bad3158ac189be0989479abf8f0c178c5 Mon Sep 17 00:00:00 2001 From: Ruchi Anand Date: Thu, 20 Nov 2025 10:28:18 +0530 Subject: [PATCH 23/23] fixed console errors --- scripts/validate-css-variables.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/validate-css-variables.js b/scripts/validate-css-variables.js index 35b589133..71439f092 100644 --- a/scripts/validate-css-variables.js +++ b/scripts/validate-css-variables.js @@ -123,14 +123,14 @@ function validateCSSVariables() { console.log('CSS variables are NOT consistent:'); if (comparison.missingInImplementation.length > 0) { - console.log('Missing in implementation:'); + console.log('Variables missing in Theme builder, please add them to the Theme builder:'); comparison.missingInImplementation.forEach(varName => { console.log(` - ${varName}`); }); } if (comparison.extraInImplementation.length > 0) { - console.log('Extra in implementation:'); + console.log('Variables extra in Theme builder, please remove them from the Theme builder:'); comparison.extraInImplementation.forEach(varName => { console.log(` - ${varName}`); });