create-rsc-kit 0.19.0 → 0.20.1
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/git.d.ts +2 -0
- package/dist/git.js +6 -0
- package/dist/index.js +14 -2
- package/dist/templates.js +2 -1
- package/package.json +1 -1
package/dist/git.d.ts
ADDED
package/dist/git.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { spawnSync } from 'node:child_process';
|
|
2
|
+
/** Whether `dir` is already inside a git work tree - its own, or a parent's. */
|
|
3
|
+
export function insideRepository(dir) {
|
|
4
|
+
const result = spawnSync('git', ['rev-parse', '--is-inside-work-tree'], { cwd: dir, stdio: 'pipe' });
|
|
5
|
+
return result.status === 0 && String(result.stdout).trim() === 'true';
|
|
6
|
+
}
|
package/dist/index.js
CHANGED
|
@@ -9,6 +9,7 @@ import { existsSync, mkdirSync, readdirSync, writeFileSync } from 'node:fs';
|
|
|
9
9
|
import { dirname, join, resolve } from 'node:path';
|
|
10
10
|
import { fileURLToPath } from 'node:url';
|
|
11
11
|
import { spawnSync } from 'node:child_process';
|
|
12
|
+
import { insideRepository } from './git.js';
|
|
12
13
|
import { randomBytes } from 'node:crypto';
|
|
13
14
|
import { argv, exit, stdout } from 'node:process';
|
|
14
15
|
import { DEFAULT_COMPILER, HELP, HOSTS, publishedCore, assertInsideCwd, assertUsableName, defaultCore, parseArgs, VALIDATIONS } from './options.js';
|
|
@@ -48,8 +49,19 @@ catch (error) {
|
|
|
48
49
|
stdout.write(`\n${bold('Cannot scaffold here.')}\n ${error.message}\n\n`);
|
|
49
50
|
exit(1);
|
|
50
51
|
}
|
|
51
|
-
|
|
52
|
-
|
|
52
|
+
// Not inside a repository that already exists. A new app scaffolded into a
|
|
53
|
+
// monorepo's apps/ got a repository of its own, nested and empty, and the
|
|
54
|
+
// monorepo then refused to add the directory - git reads a nested .git as a
|
|
55
|
+
// submodule with nothing in it. The new files belong to the repository that
|
|
56
|
+
// is there.
|
|
57
|
+
if (options.git) {
|
|
58
|
+
if (insideRepository(options.dir)) {
|
|
59
|
+
stdout.write(`\n${dim('Inside a git repository already; not creating another.')}\n`);
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
run('git', ['init', '--quiet'], options.dir);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
53
65
|
if (options.install) {
|
|
54
66
|
stdout.write(`\n${dim('Installing dependencies…')}\n`);
|
|
55
67
|
const pm = options.host === 'node' ? 'npm' : 'bun';
|
package/dist/templates.js
CHANGED
|
@@ -806,7 +806,8 @@ not render.
|
|
|
806
806
|
|
|
807
807
|
A directory with a \`page.tsx\` is a route, so \`src/app/about/page.tsx\` is
|
|
808
808
|
\`/about\` with nothing to register. \`[slug]\` is a parameter, and
|
|
809
|
-
\`middleware.ts\` runs before anything at or below it renders
|
|
809
|
+
\`middleware.ts\` runs before anything at or below it renders; its default export is one
|
|
810
|
+
check or a list of them, run in order and stopping at the first refusal.
|
|
810
811
|
|
|
811
812
|
\`.rsc-kit/\` is the build's: the route types that make \`href\` checkable, and
|
|
812
813
|
the ambient declarations. Rewritten every build, and gitignored.
|