Skip to content

Commit b381cdb

Browse files
authored
Merge pull request #30 from VariableThe/fix-onboarding-update
Fix: Force-update onboarding docs for existing users
2 parents 6dfaeae + 32a2a87 commit b381cdb

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

electron/onboarding.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,16 @@ import path from 'node:path'
22
import fs from 'node:fs'
33

44
export function initializeOnboarding(NOTES_DIR: string, COMMANDS_DIR: string) {
5-
function writeCommandFile(name: string, content: string) {
5+
function writeCommandFile(name: string, content: string, forceMatch?: string) {
66
const filePath = path.join(COMMANDS_DIR, name)
7-
if (!fs.existsSync(filePath)) {
7+
if (fs.existsSync(filePath)) {
8+
if (forceMatch) {
9+
const existingContent = fs.readFileSync(filePath, 'utf-8')
10+
if (!existingContent.includes(forceMatch)) {
11+
fs.writeFileSync(filePath, content)
12+
}
13+
}
14+
} else {
815
fs.writeFileSync(filePath, content)
916
}
1017
}
@@ -26,7 +33,8 @@ export function initializeOnboarding(NOTES_DIR: string, COMMANDS_DIR: string) {
2633

2734
writeCommandFile(
2835
'markdown.md',
29-
`# Markdown & Code\n\nPaperCache supports full markdown with seamless inline editing.\n\n## Highlighting\nSelect text and press \`Cmd+H\` to highlight it.\n*Example use:* ==This text is highlighted!==\n\n## Code Snippets\nYou can write code snippets inside triple backticks \`\`\` and specify the language name right after the backticks for syntax highlighting.\n*Example use:*\n\`\`\`javascript\nfunction greet(name) {\n return "Hello, " + name + "!";\n}\n\`\`\`\n*(Tip: Click the copy button in the top right of the code block to copy its contents!)*\n\n## Horizontal Rules\nType \`---\` on a new line to create a beautiful horizontal divider.\n*Example use:*\n\n---\n\n## Inline AI Assistance\nTo use the AI, first grab a free API key from [OpenRouter](https://openrouter.ai/keys) and paste it into Settings (\`Cmd+Shift+S\`).\n\nType \`/ai <prompt>\` and press enter to summon an AI assistant directly into your document.\nYou can also type \`/ctx <prompt>\` to automatically include the entire note's text in your prompt! AI responses are highlighted with a distinct background so you can easily distinguish them from your own writing.\n*Example use:*\n\`/ai Write a python function to reverse a string\`\n\nNext: [Formats & Colors](/file commands/formats.md)\n`
36+
`# Markdown & Code\n\nPaperCache supports full markdown with seamless inline editing.\n\n## Highlighting\nSelect text and press \`Cmd+H\` to highlight it.\n*Example use:* ==This text is highlighted!==\n\n## Code Snippets\nYou can write code snippets inside triple backticks \`\`\` and specify the language name right after the backticks for syntax highlighting.\n*Example use:*\n\`\`\`javascript\nfunction greet(name) {\n return "Hello, " + name + "!";\n}\n\`\`\`\n*(Tip: Click the copy button in the top right of the code block to copy its contents!)*\n\n## Horizontal Rules\nType \`---\` on a new line to create a beautiful horizontal divider.\n*Example use:*\n\n---\n\n## Inline AI Assistance\nTo use the AI, first grab a free API key from [OpenRouter](https://openrouter.ai/keys) and paste it into Settings (\`Cmd+Shift+S\`).\n\nType \`/ai <prompt>\` and press enter to summon an AI assistant directly into your document.\nYou can also type \`/ctx <prompt>\` to automatically include the entire note's text in your prompt! AI responses are highlighted with a distinct background so you can easily distinguish them from your own writing.\n*Example use:*\n\`/ai Write a python function to reverse a string\`\n\nNext: [Formats & Colors](/file commands/formats.md)\n`,
37+
'OpenRouter'
3038
)
3139

3240
writeCommandFile(

0 commit comments

Comments
 (0)