@karaoke-cms/create 0.6.2 → 0.6.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/karaoke-create-vault/.obsidian/app.json +14 -0
- package/karaoke-create-vault/.obsidian/appearance.json +1 -0
- package/karaoke-create-vault/.obsidian/community-plugins.json +4 -0
- package/karaoke-create-vault/.obsidian/core-plugins.json +33 -0
- package/karaoke-create-vault/.obsidian/plugins/folder-notes/data.json +131 -0
- package/karaoke-create-vault/.obsidian/plugins/folder-notes/main.js +9190 -0
- package/karaoke-create-vault/.obsidian/plugins/folder-notes/manifest.json +12 -0
- package/karaoke-create-vault/.obsidian/plugins/folder-notes/styles.css +355 -0
- package/karaoke-create-vault/.obsidian/plugins/templater-obsidian/main.js +45 -0
- package/karaoke-create-vault/.obsidian/plugins/templater-obsidian/manifest.json +11 -0
- package/karaoke-create-vault/.obsidian/plugins/templater-obsidian/styles.css +226 -0
- package/karaoke-create-vault/blog/draft-post.md +15 -0
- package/karaoke-create-vault/blog/hello-world.md +26 -0
- package/karaoke-create-vault/docs/getting-started.md +49 -0
- package/karaoke-create-vault/docs/testing.md +0 -0
- package/karaoke-create-vault/karaoke-cms/config/collections.yaml +10 -0
- package/karaoke-create-vault/karaoke-cms/manual/configuration.md +77 -0
- package/karaoke-create-vault/karaoke-cms/manual/content.md +38 -0
- package/karaoke-create-vault/karaoke-cms/manual/deployment.md +46 -0
- package/karaoke-create-vault/karaoke-cms/manual/index.md +41 -0
- package/karaoke-create-vault/karaoke-cms/manual/privacy.md +37 -0
- package/karaoke-create-vault/karaoke-cms/templates/blog-header.md +9 -0
- package/karaoke-create-vault/karaoke-cms/templates/docs-header.md +9 -0
- package/karaoke-create-vault/karaoke-cms/templates/index-by-foldernote.md +8 -0
- package/package.json +3 -2
- package/src/index.js +29 -11
- package/src/templates.js +21 -72
package/src/index.js
CHANGED
|
@@ -7,12 +7,13 @@
|
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import { createInterface } from 'readline';
|
|
10
|
-
import { existsSync, mkdirSync, writeFileSync, readFileSync } from 'fs';
|
|
10
|
+
import { existsSync, mkdirSync, writeFileSync, readFileSync, cpSync } from 'fs';
|
|
11
11
|
import { join, resolve } from 'path';
|
|
12
|
+
import { fileURLToPath } from 'url';
|
|
13
|
+
import { spawnSync } from 'child_process';
|
|
12
14
|
import {
|
|
13
15
|
packageJson, astroConfig, karaokeConfig, contentConfig,
|
|
14
|
-
envDts, tsConfig, gitignore, cloudflareRedirects,
|
|
15
|
-
helloWorld, draftPost, gettingStarted,
|
|
16
|
+
envDts, tsConfig, gitignore, envDefault, cloudflareRedirects,
|
|
16
17
|
} from './templates.js';
|
|
17
18
|
|
|
18
19
|
// ── ANSI helpers ─────────────────────────────────────────────────────────────
|
|
@@ -128,13 +129,10 @@ async function main() {
|
|
|
128
129
|
// ── Scaffold ────────────────────────────────────────────────────────────────
|
|
129
130
|
console.log(`\n Scaffolding ${BOLD}${dir}${R}...\n`);
|
|
130
131
|
|
|
131
|
-
const date = new Date().toISOString().split('T')[0];
|
|
132
|
-
|
|
133
132
|
mkdirSync(join(targetDir, 'src'), { recursive: true });
|
|
134
|
-
mkdirSync(join(targetDir, 'content/blog'), { recursive: true });
|
|
135
|
-
mkdirSync(join(targetDir, 'content/docs'), { recursive: true });
|
|
136
133
|
mkdirSync(join(targetDir, 'public'), { recursive: true });
|
|
137
134
|
|
|
135
|
+
// Config and project files from templates
|
|
138
136
|
const files = {
|
|
139
137
|
'package.json': packageJson({ name: dir, astroVersion }),
|
|
140
138
|
'astro.config.mjs': astroConfig({ siteUrl }),
|
|
@@ -143,10 +141,8 @@ async function main() {
|
|
|
143
141
|
'src/env.d.ts': envDts(),
|
|
144
142
|
'tsconfig.json': tsConfig(),
|
|
145
143
|
'.gitignore': gitignore(),
|
|
144
|
+
'.env.default': envDefault(),
|
|
146
145
|
'public/_redirects': cloudflareRedirects(),
|
|
147
|
-
'content/blog/hello-world.md': helloWorld({ date }),
|
|
148
|
-
'content/blog/draft-post.md': draftPost({ date }),
|
|
149
|
-
'content/docs/getting-started.md': gettingStarted({ date }),
|
|
150
146
|
};
|
|
151
147
|
|
|
152
148
|
for (const [file, content] of Object.entries(files)) {
|
|
@@ -154,13 +150,35 @@ async function main() {
|
|
|
154
150
|
console.log(` ${GREEN}+${R} ${file}`);
|
|
155
151
|
}
|
|
156
152
|
|
|
153
|
+
// Vault content: copy the real Obsidian vault into vault/ subdirectory
|
|
154
|
+
const vaultSrc = fileURLToPath(new URL('../karaoke-create-vault', import.meta.url));
|
|
155
|
+
cpSync(vaultSrc, join(targetDir, 'vault'), { recursive: true });
|
|
156
|
+
console.log(` ${GREEN}+${R} vault/ (Obsidian vault)`);
|
|
157
|
+
|
|
158
|
+
// ── Git init ────────────────────────────────────────────────────────────────
|
|
159
|
+
const gitOk = (() => {
|
|
160
|
+
const run = (args) => spawnSync('git', args, { cwd: targetDir, encoding: 'utf8' }).status === 0;
|
|
161
|
+
return (
|
|
162
|
+
run(['init']) &&
|
|
163
|
+
run(['add', '-A']) &&
|
|
164
|
+
run(['-c', 'user.name=karaoke-cms', '-c', 'user.email=setup@karaoke-cms.org',
|
|
165
|
+
'commit', '-m', 'chore: initial karaoke-cms setup'])
|
|
166
|
+
);
|
|
167
|
+
})();
|
|
168
|
+
|
|
169
|
+
if (gitOk) {
|
|
170
|
+
console.log(` ${GREEN}+${R} git repository initialized`);
|
|
171
|
+
} else {
|
|
172
|
+
console.log(` ${GRAY} (git init skipped — install git and run it manually)${R}`);
|
|
173
|
+
}
|
|
174
|
+
|
|
157
175
|
// ── Done ────────────────────────────────────────────────────────────────────
|
|
158
176
|
console.log(`\n${GREEN}✓${R} Done! Created ${BOLD}${dir}/${R}\n`);
|
|
159
177
|
console.log(` Next steps:\n`);
|
|
160
178
|
console.log(` ${CYAN}cd ${dir}${R}`);
|
|
161
179
|
console.log(` ${CYAN}npm install${R}`);
|
|
162
180
|
console.log(` ${CYAN}npm run dev${R} ${GRAY}→ http://localhost:4321${R}\n`);
|
|
163
|
-
console.log(` ${GRAY}Open ${BOLD}${dir}/${R}${GRAY} in Obsidian
|
|
181
|
+
console.log(` ${GRAY}Open ${BOLD}${dir}/vault/${R}${GRAY} in Obsidian to write content.${R}\n`);
|
|
164
182
|
}
|
|
165
183
|
|
|
166
184
|
main().catch(err => {
|
package/src/templates.js
CHANGED
|
@@ -66,8 +66,12 @@ export function karaokeConfig({ title, description, theme, search, comments }) {
|
|
|
66
66
|
: '';
|
|
67
67
|
|
|
68
68
|
return `import type { KaraokeConfig } from '@karaoke-cms/astro';
|
|
69
|
+
import { loadEnv } from '@karaoke-cms/astro/env';
|
|
70
|
+
|
|
71
|
+
const env = loadEnv(new URL('.', import.meta.url));
|
|
69
72
|
|
|
70
73
|
const config: KaraokeConfig = {
|
|
74
|
+
vault: env.KARAOKE_VAULT,
|
|
71
75
|
title: ${JSON.stringify(title)},
|
|
72
76
|
description: ${JSON.stringify(description)},
|
|
73
77
|
theme: ${JSON.stringify(theme)},${modulesStr}
|
|
@@ -79,8 +83,11 @@ export default config;
|
|
|
79
83
|
|
|
80
84
|
export function contentConfig() {
|
|
81
85
|
return `import { makeCollections } from '@karaoke-cms/astro/collections';
|
|
86
|
+
import { loadEnv } from '@karaoke-cms/astro/env';
|
|
87
|
+
|
|
88
|
+
const env = loadEnv(new URL('..', import.meta.url));
|
|
82
89
|
|
|
83
|
-
export const collections = makeCollections(new URL('..', import.meta.url));
|
|
90
|
+
export const collections = makeCollections(new URL('..', import.meta.url), env.KARAOKE_VAULT);
|
|
84
91
|
`;
|
|
85
92
|
}
|
|
86
93
|
|
|
@@ -103,82 +110,24 @@ node_modules/
|
|
|
103
110
|
dist/
|
|
104
111
|
.astro/
|
|
105
112
|
.env
|
|
106
|
-
.env
|
|
113
|
+
.env.local
|
|
114
|
+
.env.*.local
|
|
115
|
+
# Obsidian workspace state (personal, not shared)
|
|
116
|
+
.obsidian/workspace.json
|
|
117
|
+
.obsidian/workspace-mobile.json
|
|
107
118
|
`;
|
|
108
119
|
}
|
|
109
120
|
|
|
110
|
-
export function
|
|
111
|
-
return
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
return `---
|
|
117
|
-
title: "Hello World"
|
|
118
|
-
publish: true
|
|
119
|
-
date: ${date}
|
|
120
|
-
author: "The Team"
|
|
121
|
-
description: "Our first published post."
|
|
122
|
-
---
|
|
123
|
-
|
|
124
|
-
Welcome! This post has \`publish: true\` so it appears on the site.
|
|
125
|
-
|
|
126
|
-
## How publishing works
|
|
127
|
-
|
|
128
|
-
1. Write Markdown in Obsidian (or any editor)
|
|
129
|
-
2. Add \`publish: true\` to the frontmatter when ready to share
|
|
130
|
-
3. Push to \`main\` — GitHub Actions builds and deploys automatically
|
|
131
|
-
|
|
132
|
-
Posts without \`publish: true\` stay private in your vault.
|
|
121
|
+
export function envDefault() {
|
|
122
|
+
return `# Obsidian vault location — open this folder in Obsidian to write content.
|
|
123
|
+
# Override in .env (gitignored) to point to a vault elsewhere on your machine.
|
|
124
|
+
# Absolute path: KARAOKE_VAULT=/Users/you/Obsidian/my-vault
|
|
125
|
+
# Relative path: KARAOKE_VAULT=../my-obsidian-vault
|
|
126
|
+
KARAOKE_VAULT=./vault/
|
|
133
127
|
`;
|
|
134
128
|
}
|
|
135
129
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
return `---
|
|
139
|
-
title: "Draft Post"
|
|
140
|
-
publish: false
|
|
141
|
-
date: ${date}
|
|
142
|
-
---
|
|
143
|
-
|
|
144
|
-
This post has \`publish: false\`. It lives in your vault but never appears on the site.
|
|
145
|
-
|
|
146
|
-
Change it to \`publish: true\` when you're ready to share it.
|
|
147
|
-
`;
|
|
130
|
+
export function cloudflareRedirects() {
|
|
131
|
+
return `/* /404.html 404\n`;
|
|
148
132
|
}
|
|
149
133
|
|
|
150
|
-
/** @param {{ date: string }} opts */
|
|
151
|
-
export function gettingStarted({ date }) {
|
|
152
|
-
return `---
|
|
153
|
-
title: "Getting Started"
|
|
154
|
-
publish: true
|
|
155
|
-
date: ${date}
|
|
156
|
-
description: "How to set up and use your karaoke-cms site."
|
|
157
|
-
---
|
|
158
|
-
|
|
159
|
-
## Setup
|
|
160
|
-
|
|
161
|
-
1. Open this folder in Obsidian as a vault
|
|
162
|
-
2. Edit \`karaoke.config.ts\` — set your title, theme, and modules
|
|
163
|
-
3. Set your Cloudflare Pages URL in \`astro.config.mjs\`
|
|
164
|
-
4. Push to \`main\` — your site is live
|
|
165
|
-
|
|
166
|
-
## Writing content
|
|
167
|
-
|
|
168
|
-
- Blog posts go in \`content/blog/\`
|
|
169
|
-
- Documentation goes in \`content/docs/\`
|
|
170
|
-
- Set \`publish: true\` to make a file public
|
|
171
|
-
|
|
172
|
-
## Frontmatter reference
|
|
173
|
-
|
|
174
|
-
\`\`\`yaml
|
|
175
|
-
---
|
|
176
|
-
title: "My Post" # required
|
|
177
|
-
publish: true # required to appear on site
|
|
178
|
-
date: 2026-01-15 # optional, YYYY-MM-DD
|
|
179
|
-
author: "Name" # optional
|
|
180
|
-
description: "..." # optional, used in OG tags and RSS
|
|
181
|
-
---
|
|
182
|
-
\`\`\`
|
|
183
|
-
`;
|
|
184
|
-
}
|