tkeron 4.3.1 → 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 +39 -0
- package/package.json +1 -1
- package/src/init.ts +30 -0
- package/src/processCom.ts +16 -9
- package/src/processComMd.ts +12 -9
- package/src/processComTs.ts +12 -9
package/changelog.md
CHANGED
|
@@ -1,3 +1,42 @@
|
|
|
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
|
+
|
|
19
|
+
# v4.4.0
|
|
20
|
+
|
|
21
|
+
## Component Subdirectory Lookup
|
|
22
|
+
|
|
23
|
+
### New Features
|
|
24
|
+
|
|
25
|
+
- **Added**: Components (`.com.html`, `.com.md`, `.com.ts`) are now resolved via glob search (`**/${tagName}.com.*`) across any subdirectory of `rootDir`, not just at the exact root path
|
|
26
|
+
- `currentDir` (same directory as the referencing HTML file) retains the highest priority
|
|
27
|
+
- If not found locally, tkeron glob-searches all subdirectories of `rootDir` recursively
|
|
28
|
+
- First glob match is used when multiple subdirectory matches exist
|
|
29
|
+
- The error message for hyphen-less component names now correctly reports the path found via glob
|
|
30
|
+
|
|
31
|
+
### Tests
|
|
32
|
+
|
|
33
|
+
- **Added**: `tests/processCom.test.ts` — 4 new tests covering subdirectory lookup for `.com.html`
|
|
34
|
+
- **Added**: `tests/processComMd.test.ts` — 3 new tests covering subdirectory lookup for `.com.md`
|
|
35
|
+
- **Added**: `tests/processComTs.test.ts` — 3 new tests covering subdirectory lookup for `.com.ts`
|
|
36
|
+
- **Updated**: `tests/examples.test.ts` — updated assertions to match glob-based component resolution
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
1
40
|
# v4.3.1
|
|
2
41
|
|
|
3
42
|
## Bug Fixes
|
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:`);
|
package/src/processCom.ts
CHANGED
|
@@ -83,11 +83,12 @@ const processComponents = async (
|
|
|
83
83
|
if (tagName) {
|
|
84
84
|
if (!tagName.includes("-")) {
|
|
85
85
|
const localPath = join(currentDir, `${tagName}.com.html`);
|
|
86
|
-
const
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
)
|
|
86
|
+
const globMatches = getFilePaths(
|
|
87
|
+
rootDir,
|
|
88
|
+
`**/${tagName}.com.html`,
|
|
89
|
+
true,
|
|
90
|
+
);
|
|
91
|
+
if ((await Bun.file(localPath).exists()) || globMatches.length > 0) {
|
|
91
92
|
log.error(
|
|
92
93
|
`\n❌ Error: Component name '${tagName}' must contain at least one hyphen.`,
|
|
93
94
|
);
|
|
@@ -96,7 +97,7 @@ const processComponents = async (
|
|
|
96
97
|
` Rename '${tagName}.com.html' to 'tk-${tagName}.com.html' or similar.`,
|
|
97
98
|
);
|
|
98
99
|
log.error(
|
|
99
|
-
` File: ${(await Bun.file(localPath).exists()) ? localPath :
|
|
100
|
+
` File: ${(await Bun.file(localPath).exists()) ? localPath : globMatches[0]}\n`,
|
|
100
101
|
);
|
|
101
102
|
throw new Error(
|
|
102
103
|
`Component name '${tagName}' must contain at least one hyphen`,
|
|
@@ -104,14 +105,20 @@ const processComponents = async (
|
|
|
104
105
|
}
|
|
105
106
|
} else {
|
|
106
107
|
const localPath = join(currentDir, `${tagName}.com.html`);
|
|
107
|
-
const rootPath = join(rootDir, `${tagName}.com.html`);
|
|
108
108
|
|
|
109
109
|
let componentPath: string | null = null;
|
|
110
110
|
|
|
111
111
|
if (await Bun.file(localPath).exists()) {
|
|
112
112
|
componentPath = localPath;
|
|
113
|
-
} else
|
|
114
|
-
|
|
113
|
+
} else {
|
|
114
|
+
const globMatches = getFilePaths(
|
|
115
|
+
rootDir,
|
|
116
|
+
`**/${tagName}.com.html`,
|
|
117
|
+
true,
|
|
118
|
+
);
|
|
119
|
+
if (globMatches.length > 0) {
|
|
120
|
+
componentPath = globMatches[0];
|
|
121
|
+
}
|
|
115
122
|
}
|
|
116
123
|
|
|
117
124
|
if (componentPath) {
|
package/src/processComMd.ts
CHANGED
|
@@ -83,11 +83,8 @@ const processComponents = async (
|
|
|
83
83
|
if (tagName) {
|
|
84
84
|
if (!tagName.includes("-")) {
|
|
85
85
|
const localPath = join(currentDir, `${tagName}.com.md`);
|
|
86
|
-
const
|
|
87
|
-
if (
|
|
88
|
-
(await Bun.file(localPath).exists()) ||
|
|
89
|
-
(await Bun.file(rootPath).exists())
|
|
90
|
-
) {
|
|
86
|
+
const globMatches = getFilePaths(rootDir, `**/${tagName}.com.md`, true);
|
|
87
|
+
if ((await Bun.file(localPath).exists()) || globMatches.length > 0) {
|
|
91
88
|
log.error(
|
|
92
89
|
`\n❌ Error: Component name '${tagName}' must contain at least one hyphen.`,
|
|
93
90
|
);
|
|
@@ -96,7 +93,7 @@ const processComponents = async (
|
|
|
96
93
|
` Rename '${tagName}.com.md' to 'tk-${tagName}.com.md' or similar.`,
|
|
97
94
|
);
|
|
98
95
|
log.error(
|
|
99
|
-
` File: ${(await Bun.file(localPath).exists()) ? localPath :
|
|
96
|
+
` File: ${(await Bun.file(localPath).exists()) ? localPath : globMatches[0]}\n`,
|
|
100
97
|
);
|
|
101
98
|
throw new Error(
|
|
102
99
|
`Component name '${tagName}' must contain at least one hyphen`,
|
|
@@ -104,14 +101,20 @@ const processComponents = async (
|
|
|
104
101
|
}
|
|
105
102
|
} else {
|
|
106
103
|
const localPath = join(currentDir, `${tagName}.com.md`);
|
|
107
|
-
const rootPath = join(rootDir, `${tagName}.com.md`);
|
|
108
104
|
|
|
109
105
|
let componentPath: string | null = null;
|
|
110
106
|
|
|
111
107
|
if (await Bun.file(localPath).exists()) {
|
|
112
108
|
componentPath = localPath;
|
|
113
|
-
} else
|
|
114
|
-
|
|
109
|
+
} else {
|
|
110
|
+
const globMatches = getFilePaths(
|
|
111
|
+
rootDir,
|
|
112
|
+
`**/${tagName}.com.md`,
|
|
113
|
+
true,
|
|
114
|
+
);
|
|
115
|
+
if (globMatches.length > 0) {
|
|
116
|
+
componentPath = globMatches[0];
|
|
117
|
+
}
|
|
115
118
|
}
|
|
116
119
|
|
|
117
120
|
if (componentPath) {
|
package/src/processComTs.ts
CHANGED
|
@@ -85,11 +85,8 @@ const processComponentsTs = async (
|
|
|
85
85
|
if (tagName) {
|
|
86
86
|
if (!tagName.includes("-")) {
|
|
87
87
|
const localPath = join(currentDir, `${tagName}.com.ts`);
|
|
88
|
-
const
|
|
89
|
-
if (
|
|
90
|
-
(await Bun.file(localPath).exists()) ||
|
|
91
|
-
(await Bun.file(rootPath).exists())
|
|
92
|
-
) {
|
|
88
|
+
const globMatches = getFilePaths(rootDir, `**/${tagName}.com.ts`, true);
|
|
89
|
+
if ((await Bun.file(localPath).exists()) || globMatches.length > 0) {
|
|
93
90
|
log.error(
|
|
94
91
|
`\n❌ Error: Component name '${tagName}' must contain at least one hyphen.`,
|
|
95
92
|
);
|
|
@@ -98,7 +95,7 @@ const processComponentsTs = async (
|
|
|
98
95
|
` Rename '${tagName}.com.ts' to 'tk-${tagName}.com.ts' or similar.`,
|
|
99
96
|
);
|
|
100
97
|
log.error(
|
|
101
|
-
` File: ${(await Bun.file(localPath).exists()) ? localPath :
|
|
98
|
+
` File: ${(await Bun.file(localPath).exists()) ? localPath : globMatches[0]}\n`,
|
|
102
99
|
);
|
|
103
100
|
throw new Error(
|
|
104
101
|
`Component name '${tagName}' must contain at least one hyphen`,
|
|
@@ -106,14 +103,20 @@ const processComponentsTs = async (
|
|
|
106
103
|
}
|
|
107
104
|
} else {
|
|
108
105
|
const localPath = join(currentDir, `${tagName}.com.ts`);
|
|
109
|
-
const rootPath = join(rootDir, `${tagName}.com.ts`);
|
|
110
106
|
|
|
111
107
|
let componentPath: string | null = null;
|
|
112
108
|
|
|
113
109
|
if (await Bun.file(localPath).exists()) {
|
|
114
110
|
componentPath = localPath;
|
|
115
|
-
} else
|
|
116
|
-
|
|
111
|
+
} else {
|
|
112
|
+
const globMatches = getFilePaths(
|
|
113
|
+
rootDir,
|
|
114
|
+
`**/${tagName}.com.ts`,
|
|
115
|
+
true,
|
|
116
|
+
);
|
|
117
|
+
if (globMatches.length > 0) {
|
|
118
|
+
componentPath = globMatches[0];
|
|
119
|
+
}
|
|
117
120
|
}
|
|
118
121
|
|
|
119
122
|
if (componentPath) {
|