Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sheet Migration for Pricing PAhe #6107

Merged
merged 16 commits into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
106 changes: 106 additions & 0 deletions .github/build/features-to-json.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
#!/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(`Node.js version: ${major}.${minor}.${patch}`);

const headers = [
"Theme",
"Category",
"Function",
"Feature",
"Subscription Tier",
"Free Tier",
"TeamDesigner Tier",
"TeamOperator Tier",
"Enterprise Tier",
"Pricing Page?",
"Docs",
];


async function processCSV() {
try {
const rows = await csv({
noheader: true,
headers: headers,
output: "json",
}).fromFile("../spreadsheet.csv");

const filteredData = rows.map(row => {
try {
const pricingPage = row["Pricing Page?"]?.toLowerCase() || "";
const hasXTier = [
"Free Tier",
"TeamDesigner Tier",
"TeamOperator Tier",
"Enterprise Tier"]
.some(tier => row[tier]?.trim().toLowerCase() === "x");
const includeRow = hasXTier || (pricingPage && ["x", "X"].includes(pricingPage.toLowerCase()));

if (!includeRow) return null;

return {
theme: row["Theme"],
category: row["Category"],
function: row["Function"],
feature: row["Feature"],
subscription_tier: row["Subscription Tier"],
comparison_tiers: {
free: row["Free Tier"],
teamDesigner: row["TeamDesigner Tier"],
teamOperator: row["TeamOperator Tier"],
enterprise: row["Enterprise Tier"],
},
pricing_page: row["Pricing Page?"],
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 = "src/sections/Pricing/feature_data.json";
let existingData = [];
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();
119 changes: 3 additions & 116 deletions .github/workflows/feature-list.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ jobs:
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=829069645&single=true&output=csv'
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@v3
uses: actions/setup-node@v4
with:
node-version: 18

Expand All @@ -35,120 +35,7 @@ jobs:
curl -L $SPREADSHEET_URL -o spreadsheet.csv

# Process the CSV, filter data, and append to feature_data.json
node -e "
const fs = require('fs');
const csv = require('csvtojson');

const headers = [
'Theme (also: Keychain Name)',
'Category',
'Function',
'Feature',
'Primary Persona',
'Entitlement',
'Subscription Tier',
'Free Comparison Tier',
'TeamDesigner Comparison Tier',
'TeamOperator Comparison Tier',
'Enterprise Comparison Tier',
'Tech',
'Version',
'Engineer',
'Pricing Page?',
'Video?',
'Documented?',
'Anonymous',
'Authorization',
'Team Admin',
'Workspace Admin',
'Org Billing Manager',
'Org Admin',
'Provider Admin',
'Curator',
'MeshMap',
'Keychain ID',
'SQL',
'Key ID',
'Inserted',
'Local Provider',
'Update SQL',
'E2E Test',
];

csv({
noheader: true, // Ignore the first row as headers
headers: headers, // Use our custom headers
output: 'json', // Output as JSON
})
.fromFile('spreadsheet.csv')
.then(rows => {

// Filter data
const filteredData = rows
.map(row => {
const pricingPage = row['Pricing Page?']?.toLowerCase() || '';
const documented = row['Documented?']?.trim() || '';

const includeRow =
(pricingPage && ['x', 'X', 'true'].includes(pricingPage)) ||
(documented.startsWith('https://docs.meshery.io/') ||
documented.startsWith('https://docs.layer5.io/'));
if (!includeRow) return null;

return {
theme: row['Theme (also: Keychain Name)'],
category: row['Category'],
function: row['Function'],
feature: row['Feature'],
subscription_tier: row['Subscription Tier'],
comparison_tiers: {
free: row['Free Comparison Tier'],
teamDesigner: row['TeamDesigner Comparison Tier'],
teamOperator: row['TeamOperator Comparison Tier'],
enterprise: row['Enterprise Comparison Tier'],
},
};
})
.filter(Boolean);

// Read existing JSON data
const featuresFile = process.env.FEATURES_FILE;
let existingData = [];
if (fs.existsSync(featuresFile)) {
existingData = JSON.parse(fs.readFileSync(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 {
fs.writeFileSync(featuresFile, JSON.stringify(updatedData, null, 2));
} catch (error) {
console.error('Error writing to feature_data.json:', error);
}
})
.catch(error => {
console.error('Error processing spreadsheet:', error);
process.exit(1);
});
node build/features-to-json.js
"

- name: Commit changes
Expand Down
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,7 @@ default.profraw

# Lighthouse CI
.lighthouseci/
.gitpod.yml
.gitpod.yml

# Temporary files
spreadsheet.csv
5 changes: 5 additions & 0 deletions src/assets/images/pricing/docs.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions src/sections/General/Navigation/navigation.style.js
Original file line number Diff line number Diff line change
Expand Up @@ -618,6 +618,14 @@ const NavigationWrap = styled.header`
}
.mobile-nav-item {
padding: 1px;
ul:after {
content: "";
display: block;
height: 1px;
width: 40%;
margin: 10px;
background: ${(props) => props.theme.greyC1C1C1ToGreyB3B3B3};
}
.menu-item {
font-size: 16px;
font-weight: 600;
Expand Down
23 changes: 23 additions & 0 deletions src/sections/Pricing/comparison.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,30 @@ h2, h5{
align-items: center;
margin: 1rem 0;
}
.docs{
width:1rem;
height:1rem;
}

.feature-link-container {
display: flex;
align-items: center;
justify-content: space-between;
}

.feature-name {
margin-right: 0.5rem;
}

.feature-link {
color: #00b39f;
text-decoration: none;
font-size: 0.9rem;
}

.feature-link:hover {
text-decoration: underline;
}
`;

const Comparison = () => {
Expand Down
Loading
Loading