generated from layer5io/layer5-repo-template
-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #424 from SAHU-01/master
[UI] Subscription tier position relocated
- Loading branch information
Showing
13 changed files
with
961 additions
and
1,459 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
#!/usr/bin/env node | ||
const fs = require("fs").promises; | ||
const csv = require("csvtojson"); | ||
|
||
const headers = [ | ||
"Theme", | ||
"Category Order", | ||
"Category", | ||
"Function Order", | ||
"Function", | ||
"Feature", | ||
"Subscription Tier", | ||
"Free", | ||
"Team Designer", | ||
"Team Operator", | ||
"Enterprise", | ||
"Exclude", | ||
"Docs", | ||
]; | ||
|
||
async function processCSV() { | ||
try { | ||
// Default paths, can be overridden by command line arguments | ||
const csvFilePath = process.argv[2] || ".github/build/spreadsheet.csv"; | ||
const featuresFile = process.argv[3] || "data/feature_data.json"; | ||
|
||
// Log file paths if custom paths are provided | ||
if (process.argv[2]) { | ||
console.log("Reading features from: " + process.argv[2]); | ||
} | ||
if (process.argv[3]) { | ||
console.log("Outputting JSON to: " + process.argv[3]); | ||
} | ||
|
||
// Read CSV and parse | ||
const rows = await csv({ | ||
noheader: true, | ||
headers: headers, | ||
output: "json", | ||
}).fromFile(csvFilePath); | ||
|
||
// Filter and transform rows | ||
const filteredData = rows | ||
.filter(row => { | ||
// Only include rows with a non-empty docs column | ||
const docsValue = row["Docs"]?.trim(); | ||
return docsValue && docsValue !== ""; | ||
}) | ||
.map(row => { | ||
// Transform row to desired structure | ||
return { | ||
theme: row["Theme"]?.trim(), | ||
categoryOrder: row["Category Order"]?.trim(), | ||
category: row["Category"]?.trim(), | ||
functionOrder: row["Function Order"]?.trim(), | ||
function: row["Function"]?.trim(), | ||
feature: row["Feature"]?.trim(), | ||
subscriptionTier: row["Subscription Tier"]?.trim(), | ||
comparisonTiers: { | ||
free: row["Free"]?.trim().toLowerCase() === 'x', | ||
teamDesigner: row["Team Designer"]?.trim().toLowerCase() === 'x', | ||
teamOperator: row["Team Operator"]?.trim().toLowerCase() === 'x', | ||
enterprise: row["Enterprise"]?.trim().toLowerCase() === 'x' | ||
}, | ||
docs: row["Docs"]?.trim() | ||
}; | ||
}); | ||
|
||
// Write filtered data to JSON file | ||
try { | ||
await fs.writeFile( | ||
featuresFile, | ||
JSON.stringify(filteredData, null, 2) | ||
); | ||
console.log(`Successfully wrote ${filteredData.length} features to ${featuresFile}`); | ||
} catch (error) { | ||
console.error("Error writing to features JSON file:", error); | ||
process.exit(1); | ||
} | ||
|
||
} catch (error) { | ||
console.error("Error processing CSV:", error); | ||
process.exit(1); | ||
} | ||
} | ||
|
||
processCSV(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,85 +1,51 @@ | ||
name: Feature List Update | ||
name: Feature List | ||
|
||
on: | ||
workflow_dispatch: | ||
schedule: | ||
- cron: '0 0 * * *' # Run every night at midnight UTC | ||
workflow_dispatch: | ||
- cron: '0 0 * * *' | ||
|
||
permissions: | ||
contents: write | ||
actions: read | ||
|
||
jobs: | ||
check-and-update-features: | ||
trigger-feature-list: | ||
runs-on: ubuntu-latest | ||
env: | ||
FEATURES_FILE: 'data/features.json' | ||
FEATURES_FILE: 'data/feature_data.json' | ||
SPREADSHEET_URL: 'https://docs.google.com/spreadsheets/d/e/2PACX-1vQwzrUSKfuSRcpkp7sJTw1cSB63s4HCjYLJeGPWECsvqn222hjaaONQlN4X8auKvlaB0es3BqV5rQyz/pub?gid=1153419764&single=true&output=csv' | ||
|
||
steps: | ||
- name: Checkout current repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Restore cache | ||
id: cache-sha | ||
uses: actions/cache@v3 | ||
- name: Install Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
path: .sha-cache | ||
key: feature-data-sha | ||
restore-keys: | | ||
feature-data-sha | ||
node-version: 18 | ||
|
||
- name: Check for updates in source repository | ||
id: check-updates | ||
uses: actions/github-script@v7 | ||
with: | ||
script: | | ||
const { data: sourceFile } = await github.rest.repos.getContent({ | ||
owner: 'layer5labs', | ||
repo: 'meshery-extensions-packages', | ||
path: 'feature_data.json', | ||
ref: 'master' | ||
}); | ||
// Store the latest commit SHA | ||
const latestSHA = sourceFile.sha; | ||
const fs = require('fs'); | ||
// Check if we have a previous SHA | ||
let hasUpdates = true; | ||
const shaCachePath = '.sha-cache/latest-sha'; | ||
if (fs.existsSync(shaCachePath)) { | ||
const lastSHA = fs.readFileSync(shaCachePath, 'utf8'); | ||
hasUpdates = lastSHA !== latestSHA; | ||
} | ||
if (hasUpdates) { | ||
// Save the new SHA | ||
fs.mkdirSync('.sha-cache', { recursive: true }); | ||
fs.writeFileSync(shaCachePath, latestSHA); | ||
// Decode and save the content | ||
const content = Buffer.from(sourceFile.content, 'base64').toString('utf8'); | ||
// Create data directory if it doesn't exist | ||
fs.mkdirSync('data', { recursive: true }); | ||
// Write the new content | ||
fs.writeFileSync(process.env.FEATURES_FILE, content); | ||
core.setOutput('has-updates', 'true'); | ||
} else { | ||
core.setOutput('has-updates', 'false'); | ||
} | ||
- name: Install dependencies | ||
run: | | ||
npm install csvtojson --legacy-peer-deps | ||
- name: Fetch spreadsheet and process updates | ||
run: | | ||
# Download the spreadsheet | ||
curl -L $SPREADSHEET_URL -o .github/build/spreadsheet.csv | ||
ls -al | ||
# Process the CSV, filter data, and append to feature_data.json | ||
node .github/build/features-to-json.js | ||
- name: Commit changes | ||
if: steps.check-updates.outputs.has-updates == 'true' | ||
id: commit-changes | ||
uses: stefanzweifel/git-auto-commit-action@v5 | ||
with: | ||
commit_message: "Updated feature data from source repository" | ||
commit_message: "Updated feature data from spreadsheet" | ||
file_pattern: ${{ env.FEATURES_FILE }} | ||
branch: master | ||
commit_options: "--signoff" | ||
commit_user_name: l5io | ||
commit_user_email: [email protected] | ||
commit_author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com> | ||
commit_author: 'l5io <l5io@users.noreply.github.com>' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
name: Pricing List | ||
on: | ||
workflow_dispatch: | ||
inputs: | ||
spreadsheet_uri: | ||
description: Link of the spreadsheet containing subscription details. | ||
type: string | ||
default: https://docs.google.com/spreadsheets/d/1Ck_5q7U_vLSIDTtplugG3pCVC5zugXgTHtO7T7-yL8g/pub?output=csv | ||
schedule: | ||
- cron: "0 0 * * *" | ||
jobs: | ||
fetch-pricing-list: | ||
name: Fetch Pricing List | ||
if: github.repository == 'layer5io/docs' | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- name: Check out code | ||
uses: actions/checkout@v4 | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
fetch-depth: 1 | ||
- name: Set spreadsheet_uri as environment variable | ||
run: echo "spreadsheet_uri=https://docs.google.com/spreadsheets/d/1Ck_5q7U_vLSIDTtplugG3pCVC5zugXgTHtO7T7-yL8g/pub?output=csv" >> $GITHUB_ENV | ||
if: inputs.spreadsheet_uri != '' | ||
echo "spreadsheet_uri=${{ inputs.spreadsheet_uri }}" >> $GITHUB_ENV | ||
|
||
- name: Dump pricing list from the spreadsheet | ||
run: | | ||
curl -L $spreadsheet_uri -o "./pricing-list.csv"; | ||
- name: Create data folder | ||
run: | | ||
[ ! -d "./static/data/csv" ] && mkdir -p "./static/data/csv"; | ||
mv pricing-list.csv static/data/csv/pricing-list.csv; | ||
- name: Commit changes | ||
uses: stefanzweifel/git-auto-commit-action@v5 | ||
with: | ||
commit_message: Updated pricing-list data. | ||
branch: master | ||
commit_options: "--signoff" | ||
commit_user_name: l5io | ||
commit_user_email: [email protected] | ||
commit_author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>author of the commit that triggered the run |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,4 +22,4 @@ | |
margin-top: map-get($spacers, 5) !important; | ||
padding-top: map-get($spacers, 3) !important; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.