@rrlab/ts-plugin 1.1.3 → 1.1.5-git-c9903ab.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.mjs +14 -2
- package/package.json +7 -7
- package/src/index.ts +11 -2
package/dist/index.mjs
CHANGED
|
@@ -54,7 +54,19 @@ const PRESETS = {
|
|
|
54
54
|
needsNode: true
|
|
55
55
|
}
|
|
56
56
|
};
|
|
57
|
-
|
|
57
|
+
/**
|
|
58
|
+
* A package that depends on `react` (peer included, for a component library)
|
|
59
|
+
* gets the React preset; anything else, a Node.js app. It's the answer `--yes`
|
|
60
|
+
* and a run without a TTY take, and the one the prompt starts on.
|
|
61
|
+
*/
|
|
62
|
+
function defaultPreset(pkg) {
|
|
63
|
+
const { dependencies, devDependencies, peerDependencies } = pkg.packageJson;
|
|
64
|
+
return [
|
|
65
|
+
dependencies,
|
|
66
|
+
devDependencies,
|
|
67
|
+
peerDependencies
|
|
68
|
+
].some((deps) => !!deps && "react" in deps) ? "react" : "no-dom-app";
|
|
69
|
+
}
|
|
58
70
|
async function install(ctx) {
|
|
59
71
|
const scaffoldDecision = await decideScaffold(ctx, {
|
|
60
72
|
label: TSCONFIG,
|
|
@@ -65,7 +77,7 @@ async function install(ctx) {
|
|
|
65
77
|
const presetInfo = PRESETS[await pickPreset(ctx, {
|
|
66
78
|
message: "Which kind of TS project do you need?",
|
|
67
79
|
presets: PRESETS,
|
|
68
|
-
defaultPreset:
|
|
80
|
+
defaultPreset: defaultPreset(ctx.appPkg)
|
|
69
81
|
})];
|
|
70
82
|
const devDependencies = {
|
|
71
83
|
typescript: TOOL_VERSIONS.typescript.install,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rrlab/ts-plugin",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.5-git-c9903ab.0",
|
|
4
4
|
"description": "TypeScript plugin for @rrlab/cli — provides the tsc capability.",
|
|
5
5
|
"homepage": "https://github.com/withvariablelab/dx/tree/main/run-run/ts-plugin#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"directory": "run-run/ts-plugin"
|
|
13
13
|
},
|
|
14
14
|
"license": "MIT",
|
|
15
|
-
"author": "rcrd <
|
|
15
|
+
"author": "rcrd <ricardo@variable.land>",
|
|
16
16
|
"type": "module",
|
|
17
17
|
"exports": {
|
|
18
18
|
".": {
|
|
@@ -30,22 +30,22 @@
|
|
|
30
30
|
"access": "public"
|
|
31
31
|
},
|
|
32
32
|
"engines": {
|
|
33
|
-
"node": ">=
|
|
33
|
+
"node": ">=22.18.0"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"comment-json": "4.2.5",
|
|
37
|
-
"@variablelab/clibuddy": "0.7.
|
|
37
|
+
"@variablelab/clibuddy": "0.7.4"
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|
|
40
40
|
"typescript": ">=5.0.0",
|
|
41
|
-
"@rrlab/cli": "^1.3.
|
|
41
|
+
"@rrlab/cli": "^1.3.6-git-c9903ab.0"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@types/semver": "^7.7.1",
|
|
45
45
|
"semver": "^7.8.1",
|
|
46
46
|
"typescript": "6.0.3",
|
|
47
|
-
"@rrlab/cli": "1.3.
|
|
48
|
-
"@rrlab/tsdown-config": "^0.1.
|
|
47
|
+
"@rrlab/cli": "1.3.6-git-c9903ab.0",
|
|
48
|
+
"@rrlab/tsdown-config": "^0.1.2"
|
|
49
49
|
},
|
|
50
50
|
"scripts": {
|
|
51
51
|
"build": "tsdown",
|
package/src/index.ts
CHANGED
|
@@ -53,7 +53,16 @@ const PRESETS: Record<Preset, PresetInfo> = {
|
|
|
53
53
|
"no-dom-lib": { extendsPath: "@rrlab/ts-config/no-dom/lib", label: "Node.js library", needsNode: true },
|
|
54
54
|
};
|
|
55
55
|
|
|
56
|
-
|
|
56
|
+
/**
|
|
57
|
+
* A package that depends on `react` (peer included, for a component library)
|
|
58
|
+
* gets the React preset; anything else, a Node.js app. It's the answer `--yes`
|
|
59
|
+
* and a run without a TTY take, and the one the prompt starts on.
|
|
60
|
+
*/
|
|
61
|
+
function defaultPreset(pkg: InstallContext["appPkg"]): Preset {
|
|
62
|
+
const { dependencies, devDependencies, peerDependencies } = pkg.packageJson;
|
|
63
|
+
const dependsOnReact = [dependencies, devDependencies, peerDependencies].some((deps) => !!deps && "react" in deps);
|
|
64
|
+
return dependsOnReact ? "react" : "no-dom-app";
|
|
65
|
+
}
|
|
57
66
|
|
|
58
67
|
export async function install(ctx: InstallContext): Promise<InstallResult> {
|
|
59
68
|
const tsconfigPath = path.join(ctx.appPkg.dirPath, TSCONFIG);
|
|
@@ -71,7 +80,7 @@ export async function install(ctx: InstallContext): Promise<InstallResult> {
|
|
|
71
80
|
const preset = await pickPreset(ctx, {
|
|
72
81
|
message: "Which kind of TS project do you need?",
|
|
73
82
|
presets: PRESETS,
|
|
74
|
-
defaultPreset:
|
|
83
|
+
defaultPreset: defaultPreset(ctx.appPkg),
|
|
75
84
|
});
|
|
76
85
|
const presetInfo = PRESETS[preset];
|
|
77
86
|
|