tkeron 4.4.0 → 4.5.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/changelog.md +18 -0
- package/package.json +1 -1
- package/src/init.ts +30 -0
package/changelog.md
CHANGED
|
@@ -1,3 +1,21 @@
|
|
|
1
|
+
# v4.5.0
|
|
2
|
+
|
|
3
|
+
## tsconfig.json Generation on Init
|
|
4
|
+
|
|
5
|
+
### New Features
|
|
6
|
+
|
|
7
|
+
- **Added**: `tk i` now generates a `tsconfig.json` in the project root, allowing the IDE/TypeScript language server to detect `tkeron.d.ts` and provide full autocompletion and type checking for `.com.ts` and `.pre.ts` files
|
|
8
|
+
- New projects receive the full tkeron tsconfig template (`"include": ["websrc/**/*", "tkeron.d.ts"]`)
|
|
9
|
+
- Existing projects with a custom `tsconfig.json` are **not overwritten** — tkeron merges only the required `include` entries (`"websrc/**/*"` and `"tkeron.d.ts"`), preserving all other settings (`compilerOptions`, `exclude`, custom includes, etc.)
|
|
10
|
+
- Duplicate entries are never added
|
|
11
|
+
- `tsconfig.json` is not treated as a tkeron-managed file and does not appear in the overwrite warning
|
|
12
|
+
|
|
13
|
+
### Tests
|
|
14
|
+
|
|
15
|
+
- **Added**: `tests/init.test.ts` — 10 new tests covering tsconfig creation, IDE detection includes, websrc includes, current-directory init, no-warning behavior, merge scenarios (missing entries, no-op when already present, no duplicates, no include field, preserving all existing settings)
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
1
19
|
# v4.4.0
|
|
2
20
|
|
|
3
21
|
## Component Subdirectory Lookup
|
package/package.json
CHANGED
package/src/init.ts
CHANGED
|
@@ -3,6 +3,8 @@ import {
|
|
|
3
3
|
existsSync,
|
|
4
4
|
mkdirSync,
|
|
5
5
|
copyFileSync,
|
|
6
|
+
readFileSync,
|
|
7
|
+
writeFileSync,
|
|
6
8
|
readdirSync,
|
|
7
9
|
rmSync,
|
|
8
10
|
} from "fs";
|
|
@@ -88,10 +90,38 @@ export const init = async (options: InitOptions) => {
|
|
|
88
90
|
throw new Error("tkeron.d.ts not found");
|
|
89
91
|
}
|
|
90
92
|
|
|
93
|
+
const tsconfigPath = join(targetPath, "tsconfig.json");
|
|
94
|
+
let existingTsconfig: Record<string, unknown> | null = null;
|
|
95
|
+
if (isCurrentDir && existsSync(tsconfigPath)) {
|
|
96
|
+
try {
|
|
97
|
+
existingTsconfig = JSON.parse(readFileSync(tsconfigPath, "utf-8"));
|
|
98
|
+
} catch {
|
|
99
|
+
existingTsconfig = null;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
91
103
|
mkdirSync(targetPath, { recursive: true });
|
|
92
104
|
cpSync(templatePath, targetPath, { recursive: true });
|
|
93
105
|
copyFileSync(tkeronDtsPath, join(targetPath, "tkeron.d.ts"));
|
|
94
106
|
|
|
107
|
+
if (existingTsconfig !== null) {
|
|
108
|
+
const templateTsconfig = JSON.parse(readFileSync(tsconfigPath, "utf-8"));
|
|
109
|
+
const requiredIncludes: string[] = Array.isArray(templateTsconfig.include)
|
|
110
|
+
? (templateTsconfig.include as string[])
|
|
111
|
+
: [];
|
|
112
|
+
const existingIncludes: string[] = Array.isArray(existingTsconfig.include)
|
|
113
|
+
? (existingTsconfig.include as string[])
|
|
114
|
+
: [];
|
|
115
|
+
const mergedIncludes = [...existingIncludes];
|
|
116
|
+
for (const entry of requiredIncludes) {
|
|
117
|
+
if (!mergedIncludes.includes(entry)) {
|
|
118
|
+
mergedIncludes.push(entry);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
const merged = { ...existingTsconfig, include: mergedIncludes };
|
|
122
|
+
writeFileSync(tsconfigPath, JSON.stringify(merged, null, 2));
|
|
123
|
+
}
|
|
124
|
+
|
|
95
125
|
const projectDisplayName = isCurrentDir ? basename(targetPath) : projectName;
|
|
96
126
|
log.log(`✓ Created project "${projectDisplayName}"`);
|
|
97
127
|
log.log(`\nNext steps:`);
|