cosmolo 0.3.1 → 0.3.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/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "cosmolo",
3
- "version": "0.3.1",
3
+ "version": "0.3.3",
4
4
  "type": "module",
5
5
  "bin": {
6
- "cosmolo": "./src/cli/index.ts"
6
+ "cosmolo": "src/cli/index.ts"
7
7
  },
8
8
  "exports": {
9
9
  ".": {
package/src/cli/init.ts CHANGED
@@ -78,15 +78,15 @@ export async function main(): Promise<void> {
78
78
 
79
79
  // ── Mode selection ──────────────────────────────────────────────────────
80
80
  console.log('Choose an initialization mode:\n');
81
- console.log(' A) Full — server routes + Svelte page components');
82
- console.log(' B) Slim — server routes only (bring your own Svelte UI)\n');
81
+ console.log(' 1) Full — server routes + Svelte page components');
82
+ console.log(' 2) Slim — server routes only (bring your own Svelte UI)\n');
83
83
 
84
84
  let modeRaw = '';
85
- while (!['a', 'b'].includes(modeRaw)) {
86
- modeRaw = (await ask(rl, 'Mode [A/B]: ')).trim().toLowerCase();
87
- if (!['a', 'b'].includes(modeRaw)) console.log(' Please enter A or B.');
85
+ while (!['1', '2'].includes(modeRaw)) {
86
+ modeRaw = (await ask(rl, 'Mode [1/2]: ')).trim();
87
+ if (!['1', '2'].includes(modeRaw)) console.log(' Please enter 1 or 2.');
88
88
  }
89
- const mode: 'full' | 'slim' = modeRaw === 'a' ? 'full' : 'slim';
89
+ const mode: 'full' | 'slim' = modeRaw === '1' ? 'full' : 'slim';
90
90
 
91
91
  // ── Adapter selection ───────────────────────────────────────────────────
92
92
  console.log('\nChoose your deployment adapter:\n');
@@ -100,8 +100,6 @@ export async function main(): Promise<void> {
100
100
  }
101
101
  const isSSG = adapterRaw === '1';
102
102
 
103
- rl.close();
104
-
105
103
  // ── Collect files ───────────────────────────────────────────────────────
106
104
  const sharedFiles = collectFiles(path.join(TEMPLATE_DIR, 'shared'));
107
105
  const fullFiles = mode === 'full' ? collectFiles(path.join(TEMPLATE_DIR, 'full')) : [];
@@ -126,20 +124,24 @@ export async function main(): Promise<void> {
126
124
  }
127
125
 
128
126
  if (conflicts.length > 0) {
129
- console.error('\nError: The following files already exist and would be overwritten:\n');
130
- for (const f of conflicts) console.error(` ${f}`);
131
- console.error('\nTo resolve, either:');
132
- console.error(' 1. Remove or rename the conflicting files, then run cosmolo init again.');
133
- console.error(' 2. Manually copy the needed templates from the cosmolo package:');
134
- console.error(` node_modules/cosmolo/templates/shared/`);
135
- if (mode === 'full') console.error(` node_modules/cosmolo/templates/full/`);
136
- if (isSSG) {
137
- console.error('\n For SSG prerendering, add this to src/routes/+layout.ts manually:');
138
- console.error(' export const prerender = true;');
127
+ console.log('\nThe following files already exist:\n');
128
+ for (const f of conflicts) console.log(` ${f}`);
129
+
130
+ let overwriteRaw = '';
131
+ while (!['y', 'n'].includes(overwriteRaw)) {
132
+ overwriteRaw = (await ask(rl, '\nOverwrite all? [y/N]: ')).trim().toLowerCase() || 'n';
133
+ if (!['y', 'n'].includes(overwriteRaw)) console.log(' Please enter y or n.');
134
+ }
135
+
136
+ if (overwriteRaw === 'n') {
137
+ console.log('\nAborted. No files were written.\n');
138
+ rl.close();
139
+ process.exit(0);
139
140
  }
140
- process.exit(1);
141
141
  }
142
142
 
143
+ rl.close();
144
+
143
145
  // ── Write files ─────────────────────────────────────────────────────────
144
146
  for (const [src, rel] of allFiles) {
145
147
  const dest = destPath(rel, PROJECT_ROOT);
@@ -0,0 +1,6 @@
1
+ {
2
+ "tech": {
3
+ "label": "Technology",
4
+ "description": "Articles about software, tools, and the web."
5
+ }
6
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "url": "https://your-site.example.com",
3
+ "name": "Your Site Name",
4
+ "description": "A content site built with Cosmolo.",
5
+ "twitterHandle": "@yourhandle",
6
+ "fallbackCategoryLabel": "Other",
7
+ "articlesPerPage": 10,
8
+ "ogImage": { "mode": "static" },
9
+ "api": { "articleBody": "html" }
10
+ }
@@ -1,10 +1,10 @@
1
1
  import { resolveConfig } from 'cosmolo';
2
2
 
3
3
  const config = resolveConfig({
4
- // articlesDir: 'src/content/articles',
5
- // pagesDir: 'src/content/pages',
6
- // siteConfigPath: 'config/site.json',
7
- // categoriesConfigPath: 'config/categories.json',
4
+ articlesDir: 'src/content/articles',
5
+ pagesDir: 'src/content/pages',
6
+ siteConfigPath: 'config/site.json',
7
+ categoriesConfigPath: 'config/categories.json',
8
8
  });
9
9
 
10
10
  export default config;