-
Notifications
You must be signed in to change notification settings - Fork 10
feat/light-mode #444
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
base: main
Are you sure you want to change the base?
feat/light-mode #444
Changes from all commits
d52b3b1
956f02b
c8ace7e
38ca2d3
e97641f
9329dcd
0445dc3
e0a2694
5fccbda
e957263
18a4c96
097903d
44ba780
102f365
c04b42c
6f217ab
564f72d
7d2e0d2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,12 @@ pipeline { | |
timestamps() | ||
} | ||
|
||
parameters { | ||
string(name: 'DB_MAIN_EU', defaultValue: '', description: 'The EU database to use for the main branch') | ||
string(name: 'DB_MAIN_US_WEST', defaultValue: '', description: 'The US West database to use for the main branch') | ||
string(name: 'DB_MAIN_US_EAST', defaultValue: '', description: 'The US East database to use for the main branch') | ||
} | ||
|
||
environment { | ||
KV_DEV = credentials('cf-kv-dev') | ||
KV_PROD = credentials('cf-kv-prod') | ||
|
@@ -78,6 +84,27 @@ pipeline { | |
} | ||
} | ||
} | ||
stage("Select master db") { | ||
steps { | ||
script { | ||
env.USE_PARAMS_DB="false" | ||
def setCount = 0 | ||
if (params.DB_MAIN_EU != "") setCount++ | ||
if (params.DB_MAIN_US_WEST != "") setCount++ | ||
if (params.DB_MAIN_US_EAST != "") setCount++ | ||
if (setCount > 0 && setCount < 3) { | ||
error("Only some main db params are set. Please set all or none.") | ||
} | ||
|
||
|
||
if (setCount == 3) { | ||
echo "Using params db" | ||
env.USE_PARAMS_DB = "true" | ||
} | ||
|
||
} | ||
} | ||
} | ||
stage("Branch db") { | ||
steps { | ||
script { | ||
|
@@ -103,12 +130,29 @@ pipeline { | |
error("DB branch name is too long") | ||
} | ||
withCredentials([string(credentialsId: 'tursor_api_token', variable: 'TURSO_API_TOKEN')]) { | ||
echo "prams status $USE_PARAMS_DB" | ||
if (env.USE_PARAMS_DB == "true") { | ||
echo "Using params db" | ||
sh """ | ||
turso org switch angular-love | ||
turso db create eu-${DB_BRANCH_NAME} --from-db $DB_MAIN_EU --group blog-eu | ||
turso db create usw-${DB_BRANCH_NAME} --from-db $DB_MAIN_US_WEST --group blog-us-west | ||
turso db create use-${DB_BRANCH_NAME} --from-db $DB_MAIN_US_EAST --group blog-us-east | ||
""" | ||
} else { | ||
echo "Using normal db" | ||
sh """ | ||
turso org switch angular-love | ||
turso db create eu-${DB_BRANCH_NAME} --from-db $TURSO_EU_DB --group blog-eu | ||
turso db create usw-${DB_BRANCH_NAME} --from-db $TURSO_US_WEST_DB --group blog-us-west | ||
turso db create use-${DB_BRANCH_NAME} --from-db $TURSO_US_EAST_DB --group blog-us-east | ||
""" | ||
|
||
} | ||
|
||
Comment on lines
+133
to
+152
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chainQuote variables and export correct Turso token to harden shell blocks. User-provided params are interpolated unquoted in sh; also ensure CLI gets the right token. Quote all vars and export TURSO_AUTH_TOKEN. Apply this diff: - echo "prams status $USE_PARAMS_DB"
+ echo "params status: $USE_PARAMS_DB"
if (env.USE_PARAMS_DB == "true") {
echo "Using params db"
sh """
- turso org switch angular-love
- turso db create eu-${DB_BRANCH_NAME} --from-db $DB_MAIN_EU --group blog-eu
- turso db create usw-${DB_BRANCH_NAME} --from-db $DB_MAIN_US_WEST --group blog-us-west
- turso db create use-${DB_BRANCH_NAME} --from-db $DB_MAIN_US_EAST --group blog-us-east
+ set -eu
+ export TURSO_AUTH_TOKEN="\${TURSO_API_TOKEN}"
+ turso org switch angular-love
+ turso db create "eu-${DB_BRANCH_NAME}" --from-db "\${DB_MAIN_EU}" --group blog-eu
+ turso db create "usw-${DB_BRANCH_NAME}" --from-db "\${DB_MAIN_US_WEST}" --group blog-us-west
+ turso db create "use-${DB_BRANCH_NAME}" --from-db "\${DB_MAIN_US_EAST}" --group blog-us-east
"""
} else {
echo "Using normal db"
sh """
- turso org switch angular-love
- turso db create eu-${DB_BRANCH_NAME} --from-db $TURSO_EU_DB --group blog-eu
- turso db create usw-${DB_BRANCH_NAME} --from-db $TURSO_US_WEST_DB --group blog-us-west
- turso db create use-${DB_BRANCH_NAME} --from-db $TURSO_US_EAST_DB --group blog-us-east
+ set -eu
+ export TURSO_AUTH_TOKEN="\${TURSO_API_TOKEN}"
+ turso org switch angular-love
+ turso db create "eu-${DB_BRANCH_NAME}" --from-db "\${TURSO_EU_DB}" --group blog-eu
+ turso db create "usw-${DB_BRANCH_NAME}" --from-db "\${TURSO_US_WEST_DB}" --group blog-us-west
+ turso db create "use-${DB_BRANCH_NAME}" --from-db "\${TURSO_US_EAST_DB}" --group blog-us-east
"""
} To confirm the correct env var name used by the Turso CLI, run a quick web check: 🌐 Web query:
💡 Result: The Turso CLI / SDK examples use TURSO_AUTH_TOKEN for database authentication. TURSO_API_TOKEN is used for platform/organization API tokens in some integrations. [1][2] Sources: Enable strict shell mode, quote variables, export Turso CLI auth token, and fix typo 🤖 Prompt for AI Agents
|
||
|
||
sh """ | ||
turso org switch angular-love | ||
turso db create eu-${DB_BRANCH_NAME} --from-db $TURSO_EU_DB --group blog-eu | ||
turso db create usw-${DB_BRANCH_NAME} --from-db $TURSO_US_WEST_DB --group blog-us-west | ||
turso db create use-${DB_BRANCH_NAME} --from-db $TURSO_US_EAST_DB --group blog-us-east | ||
|
||
turso db list -g blog-eu | grep -q "eu-${DB_BRANCH_NAME}" || { echo "EU database not found after creation"; exit 1; } | ||
turso db list -g blog-us-west | grep -q "usw-${DB_BRANCH_NAME}" || { echo "US West database not found after creation"; exit 1; } | ||
turso db list -g blog-us-east | grep -q "use-${DB_BRANCH_NAME}" || { echo "US East database not found after creation"; exit 1; } | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,7 +47,7 @@ const constructUrl = (path, lang) => `/${lang}/${path}`; | |
* @returns {Promise<void>} | ||
*/ | ||
async function fetchArticleRoutes(lang, skip = 0, take = 50) { | ||
const url = `${API_BASE_URL}/articles?skip=${skip}&take=${take}`; | ||
const url = `${API_BASE_URL}/articles?skip=${skip}&take=${take}&showHidden`; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chainVerify intent: SSG now includes hidden articles. Adding Run the following script to check if hidden articles have runtime access controls: 🏁 Script executed: #!/bin/bash
# Description: Check if article detail route or API has access control for hidden articles.
# Search for guards, middleware, or access checks in article detail routes/components
rg -nP --type=ts -C3 '\b(canActivate|guard|isHidden|hidden)\b' \
-g 'apps/blog/**' \
-g 'libs/blog/**' \
-g '!**/*.spec.ts' Length of output: 41824 Prevent exposing hidden articles in SSG 🤖 Prompt for AI Agents
|
||
try { | ||
const { data, total } = await fetch(url, { | ||
headers: { | ||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -38,6 +38,7 @@ app.get('/', async (c) => { | |||||
featuredImageUrl: articles.imageUrl, | ||||||
readingTime: articles.readingTime, | ||||||
publishDate: articles.publishDate, | ||||||
hidden: articles.publishDate, | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Critical: incorrect field mapping for Line 41 maps Apply this diff to fix the mapping: - hidden: articles.publishDate,
+ hidden: articles.isHidden, 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
|
||||||
author: { | ||||||
slug: authors.slug, | ||||||
name: authors.name, | ||||||
|
@@ -50,6 +51,7 @@ app.get('/', async (c) => { | |||||
and( | ||||||
eq(articles.status, ArticleStatus.Publish), | ||||||
eq(articles.language, dbLangMap[c.var.lang]), | ||||||
...showHiddenFilter(articles, queryParams.showHidden), | ||||||
...withCategoryFilters(articles, queryParams.category), | ||||||
), | ||||||
) | ||||||
|
@@ -64,6 +66,7 @@ app.get('/', async (c) => { | |||||
and( | ||||||
eq(articleCounts.lang, dbLangMap[c.var.lang]), | ||||||
eq(articleCounts.status, ArticleStatus.Publish), | ||||||
...showHiddenFilter(articleCounts, queryParams.showHidden), | ||||||
...withCategoryFilters(articleCounts, queryParams.category), | ||||||
), | ||||||
) | ||||||
|
@@ -140,6 +143,13 @@ app.get('/:id/related', async (c) => { | |||||
|
||||||
export default app; | ||||||
|
||||||
function showHiddenFilter( | ||||||
table: typeof articles | typeof articleCounts, | ||||||
showHidden?: string, | ||||||
) { | ||||||
return showHidden !== undefined ? [] : [eq(table.isHidden, false)]; | ||||||
} | ||||||
|
||||||
function withCategoryFilters( | ||||||
table: typeof articles | typeof articleCounts, | ||||||
category?: string, | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add strict validation to prevent shell injection and bad input.
Currently only count-based checks are done; values are neither trimmed nor validated. Whitelist DB names and fail fast.
Apply this diff inside the script block:
📝 Committable suggestion
🤖 Prompt for AI Agents