create-rsc-kit 0.45.1 → 0.45.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/dist/init.d.ts CHANGED
@@ -20,6 +20,8 @@ export interface Detected {
20
20
  hasTailwind: boolean;
21
21
  hasTypeScript: boolean;
22
22
  packageJson: Record<string, unknown>;
23
+ /** What package.json was indented with, kept when it is written back. */
24
+ packageJsonIndent: string;
23
25
  }
24
26
  /** What a step did, for the report at the end. */
25
27
  export interface Step {
@@ -31,6 +33,12 @@ export interface Step {
31
33
  export declare function isFreshDirectory(dir: string): boolean;
32
34
  /** The marker that makes this an existing project, or null. */
33
35
  export declare function projectMarker(dir: string): string | null;
36
+ /**
37
+ * The indentation a JSON file already uses, so writing it back changes only
38
+ * what init added. Laravel's package.json is four spaces, and rewriting it at
39
+ * two put every line of the app's own file in the diff.
40
+ */
41
+ export declare function jsonIndent(text: string): string;
34
42
  export declare function detect(dir: string): Detected;
35
43
  /**
36
44
  * A Tailwind stylesheet the project already has, which the app's own
package/dist/init.js CHANGED
@@ -67,12 +67,21 @@ function freshPackageJson(dir) {
67
67
  .replace(/^[._-]+|[-]+$/g, '') || 'app';
68
68
  return { name, private: true, type: 'module' };
69
69
  }
70
+ /**
71
+ * The indentation a JSON file already uses, so writing it back changes only
72
+ * what init added. Laravel's package.json is four spaces, and rewriting it at
73
+ * two put every line of the app's own file in the diff.
74
+ */
75
+ export function jsonIndent(text) {
76
+ return /^[{[][^\S\n]*\n([ \t]+)\S/.exec(text)?.[1] ?? ' ';
77
+ }
70
78
  export function detect(dir) {
71
79
  const pkgPath = join(dir, 'package.json');
72
80
  const createdPackageJson = !existsSync(pkgPath);
81
+ const pkgText = createdPackageJson ? '' : readFileSync(pkgPath, 'utf-8');
73
82
  const packageJson = createdPackageJson
74
83
  ? freshPackageJson(dir)
75
- : JSON.parse(readFileSync(pkgPath, 'utf-8'));
84
+ : JSON.parse(pkgText);
76
85
  const deps = {
77
86
  ...(packageJson.dependencies ?? {}),
78
87
  ...(packageJson.devDependencies ?? {}),
@@ -113,6 +122,7 @@ export function detect(dir) {
113
122
  hasTypeScript: existsSync(join(dir, 'tsconfig.json')),
114
123
  createdPackageJson,
115
124
  packageJson,
125
+ packageJsonIndent: jsonIndent(pkgText),
116
126
  };
117
127
  }
118
128
  /**
@@ -265,8 +275,9 @@ function mergeMcp(dir, o) {
265
275
  return { kind: 'wrote', what: '.mcp.json' };
266
276
  }
267
277
  let existing;
278
+ const text = readFileSync(path, 'utf8');
268
279
  try {
269
- existing = JSON.parse(readFileSync(path, 'utf8'));
280
+ existing = JSON.parse(text);
270
281
  }
271
282
  catch {
272
283
  return { kind: 'skipped', what: '.mcp.json', detail: 'already exists and is not JSON; add the rsc-kit server by hand' };
@@ -276,7 +287,7 @@ function mergeMcp(dir, o) {
276
287
  }
277
288
  const ours = JSON.parse(t.mcp(o)).mcpServers['rsc-kit'];
278
289
  existing.mcpServers = { ...(existing.mcpServers ?? {}), 'rsc-kit': ours };
279
- writeFileSync(path, JSON.stringify(existing, null, 2) + '\n');
290
+ writeFileSync(path, JSON.stringify(existing, null, jsonIndent(text)) + '\n');
280
291
  return { kind: 'merged', what: '.mcp.json', detail: 'added the rsc-kit server beside the others' };
281
292
  }
282
293
  function mergeScripts(o, found) {
@@ -674,7 +685,7 @@ export function initialise(o, found, dir) {
674
685
  ...mergeDependencies(o, found),
675
686
  ...mergeScripts(o, found),
676
687
  ];
677
- writeFileSync(join(dir, 'package.json'), JSON.stringify(found.packageJson, null, 2) + '\n');
688
+ writeFileSync(join(dir, 'package.json'), JSON.stringify(found.packageJson, null, found.packageJsonIndent) + '\n');
678
689
  return steps;
679
690
  }
680
691
  /** Where a Go server listens, unless told otherwise. */
package/dist/templates.js CHANGED
@@ -485,8 +485,8 @@ export default function HomePage() {
485
485
  <Counter />
486
486
 
487
487
  <p${p}>
488
- Edit <code${code}>src/app/page.tsx</code> and the change arrives without
489
- a reload. Add <code${code}>src/app/about/page.tsx</code> and{' '}
488
+ Edit <code${code}>${o.sourceDir}/app/page.tsx</code> and the change arrives without
489
+ a reload. Add <code${code}>${o.sourceDir}/app/about/page.tsx</code> and{' '}
490
490
  <code${code}>/about</code> exists — there is no route table to update.
491
491
  </p>
492
492
  </>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-rsc-kit",
3
- "version": "0.45.1",
3
+ "version": "0.45.3",
4
4
  "type": "module",
5
5
  "description": "Scaffold an RSC app on Bun, Hono, Elysia or Node.",
6
6
  "bin": {