forked from layer5io/layer5
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
247 changed files
with
7,055 additions
and
1,537 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
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,119 @@ | ||
#!/usr/bin/env node | ||
|
||
const fs = require("fs").promises; // Use fs.promises | ||
const csv = require("csvtojson"); | ||
const [major, minor, patch] = process.versions.node.split(".").map(Number); | ||
console.log(`Using Node.js version: ${major}.${minor}.${patch}`); | ||
|
||
const headers = [ | ||
"Theme", | ||
"Category Order", | ||
"Category", | ||
"Function Order", | ||
"Function", | ||
"Feature", | ||
"Subscription Tier", | ||
"Free", | ||
"Team Designer", | ||
"Team Operator", | ||
"Enterprise", | ||
"Exclude", | ||
"Docs", | ||
]; | ||
|
||
|
||
async function processCSV() { | ||
try { | ||
const csvFilePath = process.argv[2] || ".github/build/spreadsheet.csv"; | ||
if (process.argv[2]) { | ||
console.log("Downloading features to: " + process.argv[2]); | ||
} | ||
const rows = await csv({ | ||
noheader: true, | ||
headers: headers, | ||
output: "json", | ||
}).fromFile(csvFilePath); | ||
|
||
const filteredData = rows.map(row => { | ||
try { | ||
const exclude = row["Exclude"]?.toLowerCase(); | ||
const hasXTier = [ | ||
"Free", | ||
"Team Designer", | ||
"Team Operator", | ||
"Enterprise"] | ||
.some(tier => row[tier]?.trim().toLowerCase() === "x"); | ||
// const includeRow = hasXTier && !(exclude && ["x", "X"].includes(exclude.toLowerCase())); | ||
|
||
// if (!includeRow) return null; | ||
if (!exclude) { | ||
return { | ||
theme: row["Theme"], | ||
categoryOrder: row["Category Order"], | ||
category: row["Category"], | ||
functionOrder: row["Function Order"], | ||
function: row["Function"], | ||
feature: row["Feature"], | ||
subscription_tier: row["Subscription Tier"], | ||
comparison_tiers: { | ||
free: row["Free"], | ||
teamDesigner: row["Team Designer"], | ||
teamOperator: row["Team Operator"], | ||
enterprise: row["Enterprise"], | ||
}, | ||
docs: row["Docs"] | ||
}; | ||
} | ||
} catch (error) { | ||
console.error("Error processing row:", row, error); | ||
return null; | ||
} | ||
}).filter(Boolean); | ||
|
||
// Read existing JSON data | ||
// const featuresFile = process.env.FEATURES_FILE; | ||
|
||
const featuresFile = process.argv[3] || "src/sections/Pricing/feature_data.json"; | ||
if (process.argv[3]) { | ||
console.log("Converting CSV to JSON in: " + process.argv[3]); | ||
} | ||
// const featuresFile = "src/sections/Pricing/feature_data.json"; | ||
|
||
|
||
if (await fs.access(featuresFile).then(() => true, () => false)) { | ||
existingData = JSON.parse(await fs.readFile(featuresFile, "utf8")); | ||
} | ||
|
||
// Identify new updates | ||
const newUpdates = filteredData.filter( | ||
newRow => | ||
!existingData.some( | ||
existingRow => | ||
existingRow.function === newRow.function && | ||
existingRow.feature === newRow.feature | ||
) | ||
); | ||
|
||
// Set output for has-updates | ||
// if (newUpdates.length > 0) { | ||
// fs.appendFileSync(process.env.GITHUB_ENV, "has-updates=true\n"); | ||
// } else { | ||
// fs.appendFileSync(process.env.GITHUB_ENV, "has-updates=false\n"); | ||
// } | ||
|
||
// Merge new updates into existing data | ||
const updatedData = [...existingData, ...newUpdates]; | ||
|
||
// Write updated data to file | ||
try { | ||
await fs.writeFile(featuresFile, JSON.stringify(filteredData, null, 2)); | ||
} catch (error) { | ||
console.error("Error writing to feature_data.json:", error); | ||
} | ||
} 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
name: Feature List | ||
|
||
on: | ||
workflow_dispatch: | ||
schedule: | ||
- cron: '0 0 * * *' | ||
|
||
permissions: | ||
contents: write | ||
actions: read | ||
|
||
jobs: | ||
trigger-feature-list: | ||
runs-on: ubuntu-latest | ||
env: | ||
FEATURES_FILE: 'src/sections/Pricing/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: Install Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: 18 | ||
|
||
- 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 | ||
id: commit-changes | ||
uses: stefanzweifel/git-auto-commit-action@v5 | ||
with: | ||
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: 'l5io <[email protected]>' | ||
|
||
call-build-and-deploy--workflow: | ||
needs: | ||
- trigger-feature-list | ||
name: Build and Deploy Site | ||
uses: layer5io/layer5/.github/workflows/build-and-deploy-site.yml@master | ||
secrets: inherit |
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 |
---|---|---|
|
@@ -91,4 +91,7 @@ default.profraw | |
|
||
# Lighthouse CI | ||
.lighthouseci/ | ||
.gitpod.yml | ||
.gitpod.yml | ||
|
||
# Temporary files | ||
spreadsheet.csv |
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
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.