create-rsc-kit 0.1.1 → 0.3.0
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/index.js +2 -2
- package/dist/init.js +2 -2
- package/dist/options.d.ts +13 -2
- package/dist/options.js +34 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -10,7 +10,7 @@ import { dirname, join, resolve } from 'node:path';
|
|
|
10
10
|
import { fileURLToPath } from 'node:url';
|
|
11
11
|
import { spawnSync } from 'node:child_process';
|
|
12
12
|
import { argv, exit, stdout } from 'node:process';
|
|
13
|
-
import { DEFAULT_COMPILER, HELP, HOSTS,
|
|
13
|
+
import { DEFAULT_COMPILER, HELP, HOSTS, publishedCore, assertInsideCwd, assertUsableName, defaultCore, parseArgs, } from './options.js';
|
|
14
14
|
import { Prompter, bold, cyan, dim } from './prompt.js';
|
|
15
15
|
import * as t from './templates.js';
|
|
16
16
|
const flags = parseArgs(argv.slice(2));
|
|
@@ -41,7 +41,7 @@ if (options.install) {
|
|
|
41
41
|
const ok = run(pm, ['install'], options.dir);
|
|
42
42
|
if (!ok) {
|
|
43
43
|
stdout.write(`\n${bold('Dependencies did not install.')} The files are written; run the install yourself.\n` +
|
|
44
|
-
(options.core ===
|
|
44
|
+
(options.core === publishedCore()
|
|
45
45
|
? dim(' @rsc-kit/core may not be published yet — pass --core=file:<path> to use a local checkout.\n')
|
|
46
46
|
: ''));
|
|
47
47
|
}
|
package/dist/init.js
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
12
12
|
import { dirname, join } from 'node:path';
|
|
13
13
|
import { cwd, exit, stdout } from 'node:process';
|
|
14
|
-
import { DEFAULT_COMPILER, parseArgs } from './options.js';
|
|
14
|
+
import { DEFAULT_COMPILER, parseArgs, publishedCore } from './options.js';
|
|
15
15
|
import { Prompter, bold, cyan, dim } from './prompt.js';
|
|
16
16
|
import * as t from './templates.js';
|
|
17
17
|
const HOST_PACKAGES = { hono: 'hono', elysia: 'elysia' };
|
|
@@ -271,7 +271,7 @@ export async function runInit(args) {
|
|
|
271
271
|
sourceDir: flags.sourceDir ?? found.sourceDir ?? 'src',
|
|
272
272
|
install: false,
|
|
273
273
|
git: false,
|
|
274
|
-
core: flags.core ??
|
|
274
|
+
core: flags.core ?? publishedCore(),
|
|
275
275
|
};
|
|
276
276
|
const steps = initialise(options, found, dir);
|
|
277
277
|
const mark = { wrote: cyan('+'), merged: cyan('~'), manual: bold('!'), skipped: dim('·') };
|
package/dist/options.d.ts
CHANGED
|
@@ -29,8 +29,19 @@ export declare const HOSTS: {
|
|
|
29
29
|
* oxc; `--compiler=babel` is there for when the experimental one misbehaves.
|
|
30
30
|
*/
|
|
31
31
|
export declare const DEFAULT_COMPILER: Compiler;
|
|
32
|
-
/**
|
|
33
|
-
|
|
32
|
+
/**
|
|
33
|
+
* The published version range, when there is no checkout to prefer.
|
|
34
|
+
*
|
|
35
|
+
* Derived from this package's own version rather than written down, because a
|
|
36
|
+
* constant here is a second place to remember at release time — and forgetting
|
|
37
|
+
* it is silent. `create-rsc-kit@0.2.0` shipped scaffolding apps that depended
|
|
38
|
+
* on `^0.1.0`, so every new project got the previous engine and nothing said
|
|
39
|
+
* so: the app built, ran, and printed a legend from the older release.
|
|
40
|
+
*
|
|
41
|
+
* The two packages are published in lockstep, so this package's version is the
|
|
42
|
+
* engine's version.
|
|
43
|
+
*/
|
|
44
|
+
export declare function publishedCore(fromDir?: string): string;
|
|
34
45
|
/**
|
|
35
46
|
* What to depend on for the engine.
|
|
36
47
|
*
|
package/dist/options.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { existsSync, readFileSync } from 'node:fs';
|
|
2
2
|
import { dirname, join } from 'node:path';
|
|
3
|
+
import { fileURLToPath } from 'node:url';
|
|
3
4
|
export const HOSTS = [
|
|
4
5
|
{ value: 'bun', label: 'Bun.serve', hint: 'no framework, fastest to start' },
|
|
5
6
|
{ value: 'hono', label: 'Hono', hint: 'also what a Worker or Deno would use' },
|
|
@@ -16,8 +17,38 @@ export const HOSTS = [
|
|
|
16
17
|
* oxc; `--compiler=babel` is there for when the experimental one misbehaves.
|
|
17
18
|
*/
|
|
18
19
|
export const DEFAULT_COMPILER = 'oxc';
|
|
19
|
-
/**
|
|
20
|
-
|
|
20
|
+
/**
|
|
21
|
+
* The published version range, when there is no checkout to prefer.
|
|
22
|
+
*
|
|
23
|
+
* Derived from this package's own version rather than written down, because a
|
|
24
|
+
* constant here is a second place to remember at release time — and forgetting
|
|
25
|
+
* it is silent. `create-rsc-kit@0.2.0` shipped scaffolding apps that depended
|
|
26
|
+
* on `^0.1.0`, so every new project got the previous engine and nothing said
|
|
27
|
+
* so: the app built, ran, and printed a legend from the older release.
|
|
28
|
+
*
|
|
29
|
+
* The two packages are published in lockstep, so this package's version is the
|
|
30
|
+
* engine's version.
|
|
31
|
+
*/
|
|
32
|
+
export function publishedCore(fromDir = dirname(fileURLToPath(import.meta.url))) {
|
|
33
|
+
for (let dir = fromDir, up = 0; up < 4; up++) {
|
|
34
|
+
const manifest = join(dir, 'package.json');
|
|
35
|
+
if (existsSync(manifest)) {
|
|
36
|
+
try {
|
|
37
|
+
const { name, version } = JSON.parse(readFileSync(manifest, 'utf-8'));
|
|
38
|
+
if (name === 'create-rsc-kit' && typeof version === 'string') {
|
|
39
|
+
return `^${version}`;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
catch {
|
|
43
|
+
// Keep walking up.
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
dir = dirname(dir);
|
|
47
|
+
}
|
|
48
|
+
// Unreachable from a published install, and better than pinning a version
|
|
49
|
+
// that will be wrong the moment it is written.
|
|
50
|
+
return 'latest';
|
|
51
|
+
}
|
|
21
52
|
/**
|
|
22
53
|
* What to depend on for the engine.
|
|
23
54
|
*
|
|
@@ -45,7 +76,7 @@ export function defaultCore(fromDir) {
|
|
|
45
76
|
break;
|
|
46
77
|
dir = parent;
|
|
47
78
|
}
|
|
48
|
-
return
|
|
79
|
+
return publishedCore();
|
|
49
80
|
}
|
|
50
81
|
export function parseArgs(argv) {
|
|
51
82
|
const out = {};
|