@typecek/cli 0.0.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/LICENSE +21 -0
- package/dist/bin.d.ts +3 -0
- package/dist/bin.d.ts.map +1 -0
- package/dist/bin.js +6 -0
- package/dist/bin.js.map +1 -0
- package/dist/commands/clean.d.ts +2 -0
- package/dist/commands/clean.d.ts.map +1 -0
- package/dist/commands/clean.js +21 -0
- package/dist/commands/clean.js.map +1 -0
- package/dist/commands/compile.d.ts +4 -0
- package/dist/commands/compile.d.ts.map +1 -0
- package/dist/commands/compile.js +173 -0
- package/dist/commands/compile.js.map +1 -0
- package/dist/commands/help.d.ts +2 -0
- package/dist/commands/help.d.ts.map +1 -0
- package/dist/commands/help.js +20 -0
- package/dist/commands/help.js.map +1 -0
- package/dist/commands/init.d.ts +2 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +78 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/list.d.ts +2 -0
- package/dist/commands/list.d.ts.map +1 -0
- package/dist/commands/list.js +61 -0
- package/dist/commands/list.js.map +1 -0
- package/dist/commands/watch.d.ts +2 -0
- package/dist/commands/watch.d.ts.map +1 -0
- package/dist/commands/watch.js +46 -0
- package/dist/commands/watch.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +40 -0
- package/dist/index.js.map +1 -0
- package/package.json +31 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Typecek Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/bin.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bin.d.ts","sourceRoot":"","sources":["../src/bin.ts"],"names":[],"mappings":""}
|
package/dist/bin.js
ADDED
package/dist/bin.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bin.js","sourceRoot":"","sources":["../src/bin.ts"],"names":[],"mappings":";;;AAEA,yCAAkC;AAElC,IAAA,eAAI,EAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clean.d.ts","sourceRoot":"","sources":["../../src/commands/clean.ts"],"names":[],"mappings":"AAIA,wBAAgB,KAAK,IAAI,IAAI,CAU5B"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.clean = clean;
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const compile_js_1 = require("./compile.js");
|
|
10
|
+
function clean() {
|
|
11
|
+
const projectRoot = (0, compile_js_1.findTsconfigRoot)();
|
|
12
|
+
const typecekDir = path_1.default.join(projectRoot, ".typecek");
|
|
13
|
+
if (fs_1.default.existsSync(typecekDir)) {
|
|
14
|
+
fs_1.default.rmSync(typecekDir, { recursive: true, force: true });
|
|
15
|
+
console.log("Removed .typecek/ directory.");
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
console.log("Nothing to clean — .typecek/ does not exist.");
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=clean.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clean.js","sourceRoot":"","sources":["../../src/commands/clean.ts"],"names":[],"mappings":";;;;;AAIA,sBAUC;AAdD,4CAAoB;AACpB,gDAAwB;AACxB,6CAAgD;AAEhD,SAAgB,KAAK;IACnB,MAAM,WAAW,GAAG,IAAA,6BAAgB,GAAE,CAAC;IACvC,MAAM,UAAU,GAAG,cAAI,CAAC,IAAI,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC;IAEtD,IAAI,YAAE,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;QAC9B,YAAE,CAAC,MAAM,CAAC,UAAU,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;QACxD,OAAO,CAAC,GAAG,CAAC,8BAA8B,CAAC,CAAC;IAC9C,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,GAAG,CAAC,8CAA8C,CAAC,CAAC;IAC9D,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compile.d.ts","sourceRoot":"","sources":["../../src/commands/compile.ts"],"names":[],"mappings":"AAYA,wBAAgB,gBAAgB,IAAI,MAAM,CAOzC;AAED,wBAAgB,cAAc,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAoB1D;AA+DD,wBAAgB,UAAU,CAAC,SAAS,UAAQ,GAAG,IAAI,CA0FlD"}
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.findTsconfigRoot = findTsconfigRoot;
|
|
7
|
+
exports.findSourceRoot = findSourceRoot;
|
|
8
|
+
exports.compileAll = compileAll;
|
|
9
|
+
const fs_1 = __importDefault(require("fs"));
|
|
10
|
+
const path_1 = __importDefault(require("path"));
|
|
11
|
+
const compiler_1 = require("@typecek/compiler");
|
|
12
|
+
// ANSI color helpers
|
|
13
|
+
const red = (s) => `\x1b[31m${s}\x1b[0m`;
|
|
14
|
+
const yellow = (s) => `\x1b[33m${s}\x1b[0m`;
|
|
15
|
+
const cyan = (s) => `\x1b[36m${s}\x1b[0m`;
|
|
16
|
+
const dim = (s) => `\x1b[2m${s}\x1b[0m`;
|
|
17
|
+
const bold = (s) => `\x1b[1m${s}\x1b[0m`;
|
|
18
|
+
function findTsconfigRoot() {
|
|
19
|
+
let dir = process.cwd();
|
|
20
|
+
while (dir !== path_1.default.dirname(dir)) {
|
|
21
|
+
if (fs_1.default.existsSync(path_1.default.join(dir, "tsconfig.json")))
|
|
22
|
+
return dir;
|
|
23
|
+
dir = path_1.default.dirname(dir);
|
|
24
|
+
}
|
|
25
|
+
return process.cwd();
|
|
26
|
+
}
|
|
27
|
+
function findSourceRoot(projectRoot) {
|
|
28
|
+
const tsconfigPath = path_1.default.join(projectRoot, "tsconfig.json");
|
|
29
|
+
if (fs_1.default.existsSync(tsconfigPath)) {
|
|
30
|
+
try {
|
|
31
|
+
const tsconfig = JSON.parse(fs_1.default.readFileSync(tsconfigPath, "utf-8"));
|
|
32
|
+
const rootDir = tsconfig.compilerOptions?.rootDir;
|
|
33
|
+
if (rootDir)
|
|
34
|
+
return path_1.default.resolve(projectRoot, rootDir);
|
|
35
|
+
const include = tsconfig.include;
|
|
36
|
+
if (Array.isArray(include) && include.length > 0) {
|
|
37
|
+
const first = include[0].replace(/\/\*\*.*$/, "");
|
|
38
|
+
return path_1.default.resolve(projectRoot, first);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
catch {
|
|
42
|
+
// fall through
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
// Default to src/ or project root
|
|
46
|
+
const srcDir = path_1.default.join(projectRoot, "src");
|
|
47
|
+
if (fs_1.default.existsSync(srcDir))
|
|
48
|
+
return srcDir;
|
|
49
|
+
return projectRoot;
|
|
50
|
+
}
|
|
51
|
+
function findTemplateFiles(dir) {
|
|
52
|
+
const results = [];
|
|
53
|
+
function walk(currentDir) {
|
|
54
|
+
const entries = fs_1.default.readdirSync(currentDir, { withFileTypes: true });
|
|
55
|
+
for (const entry of entries) {
|
|
56
|
+
const fullPath = path_1.default.join(currentDir, entry.name);
|
|
57
|
+
if (entry.isDirectory()) {
|
|
58
|
+
if (entry.name === "node_modules" || entry.name === ".typecek" || entry.name.startsWith("."))
|
|
59
|
+
continue;
|
|
60
|
+
walk(fullPath);
|
|
61
|
+
}
|
|
62
|
+
else if (entry.name.endsWith(".tc")) {
|
|
63
|
+
results.push(fullPath);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
walk(dir);
|
|
68
|
+
return results;
|
|
69
|
+
}
|
|
70
|
+
function formatDiagnostic(diag, templatePath, sourceLines) {
|
|
71
|
+
const isError = diag.severity === "error";
|
|
72
|
+
const color = isError ? red : yellow;
|
|
73
|
+
const label = isError ? red("error") : yellow("warning");
|
|
74
|
+
// file:line:col — clickable in terminals
|
|
75
|
+
const location = cyan(`${templatePath}:${diag.line + 1}:${diag.column + 1}`);
|
|
76
|
+
let out = `\n${location} - ${label}${bold(":")} ${diag.message}\n`;
|
|
77
|
+
// Show the source line with underline
|
|
78
|
+
const sourceLine = sourceLines[diag.line];
|
|
79
|
+
if (sourceLine !== undefined) {
|
|
80
|
+
const lineNum = String(diag.line + 1);
|
|
81
|
+
const gutter = dim(`${lineNum} | `);
|
|
82
|
+
out += `${gutter}${sourceLine}\n`;
|
|
83
|
+
const underlineLen = Math.max(diag.length, 1);
|
|
84
|
+
const padding = " ".repeat(lineNum.length + 3 + diag.column);
|
|
85
|
+
out += `${padding}${color("~".repeat(underlineLen))}\n`;
|
|
86
|
+
}
|
|
87
|
+
return out;
|
|
88
|
+
}
|
|
89
|
+
function formatSimpleError(message, templatePath, line, column) {
|
|
90
|
+
const loc = line !== undefined
|
|
91
|
+
? cyan(`${templatePath}:${line + 1}:${(column ?? 0) + 1}`)
|
|
92
|
+
: cyan(templatePath);
|
|
93
|
+
return `\n${loc} - ${red("error")}${bold(":")} ${message}\n`;
|
|
94
|
+
}
|
|
95
|
+
function compileAll(checkOnly = false) {
|
|
96
|
+
const projectRoot = findTsconfigRoot();
|
|
97
|
+
const sourceRoot = findSourceRoot(projectRoot);
|
|
98
|
+
const typecekDir = path_1.default.join(projectRoot, ".typecek");
|
|
99
|
+
const templateFiles = findTemplateFiles(sourceRoot);
|
|
100
|
+
if (templateFiles.length === 0) {
|
|
101
|
+
console.log("No .tc template files found.");
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
let errors = 0;
|
|
105
|
+
// Track which templates are layouts and which reference layouts
|
|
106
|
+
const compiledTemplates = new Map();
|
|
107
|
+
for (const templatePath of templateFiles) {
|
|
108
|
+
const relativePath = path_1.default.relative(sourceRoot, templatePath);
|
|
109
|
+
const outputRelative = relativePath.replace(/\.tc$/, ".ts");
|
|
110
|
+
const outputPath = path_1.default.join(typecekDir, outputRelative);
|
|
111
|
+
try {
|
|
112
|
+
const template = fs_1.default.readFileSync(templatePath, "utf-8");
|
|
113
|
+
const sourceLines = template.split("\n");
|
|
114
|
+
const result = (0, compiler_1.compile)({
|
|
115
|
+
template,
|
|
116
|
+
filename: path_1.default.basename(templatePath),
|
|
117
|
+
templatePath,
|
|
118
|
+
typecheck: true,
|
|
119
|
+
});
|
|
120
|
+
compiledTemplates.set(templatePath, {
|
|
121
|
+
relativePath,
|
|
122
|
+
isLayout: result.isLayout,
|
|
123
|
+
layoutDeps: result.layoutDeps,
|
|
124
|
+
});
|
|
125
|
+
if (result.diagnostics.length > 0) {
|
|
126
|
+
for (const diag of result.diagnostics) {
|
|
127
|
+
console.error(formatDiagnostic(diag, relativePath, sourceLines));
|
|
128
|
+
if (diag.severity === "error")
|
|
129
|
+
errors++;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
if (!checkOnly) {
|
|
133
|
+
const outputDir = path_1.default.dirname(outputPath);
|
|
134
|
+
fs_1.default.mkdirSync(outputDir, { recursive: true });
|
|
135
|
+
fs_1.default.writeFileSync(outputPath, result.code);
|
|
136
|
+
}
|
|
137
|
+
const diagCount = result.diagnostics.filter((d) => d.severity === "error").length;
|
|
138
|
+
if (diagCount === 0) {
|
|
139
|
+
console.log(` ${checkOnly ? "checked" : "compiled"} ${relativePath}`);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
catch (err) {
|
|
143
|
+
errors++;
|
|
144
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
145
|
+
// ParseError has line/column info
|
|
146
|
+
const parseErr = err;
|
|
147
|
+
console.error(formatSimpleError(message, relativePath, parseErr.line, parseErr.column));
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
// Validate layout usage
|
|
151
|
+
const layoutFiles = new Set();
|
|
152
|
+
for (const [filePath, info] of compiledTemplates) {
|
|
153
|
+
if (info.isLayout)
|
|
154
|
+
layoutFiles.add(filePath);
|
|
155
|
+
}
|
|
156
|
+
for (const [filePath, info] of compiledTemplates) {
|
|
157
|
+
// Check that {{#layout}} references point to templates with {{@content}}
|
|
158
|
+
for (const dep of info.layoutDeps) {
|
|
159
|
+
const resolvedDep = path_1.default.resolve(path_1.default.dirname(filePath), dep + ".tc");
|
|
160
|
+
const depInfo = compiledTemplates.get(resolvedDep);
|
|
161
|
+
if (depInfo && !depInfo.isLayout) {
|
|
162
|
+
errors++;
|
|
163
|
+
console.error(formatSimpleError(`layout "${dep}" does not contain {{@content}}`, info.relativePath));
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
const errorSummary = errors > 0 ? red(`${errors} error(s)`) : `${errors} error(s)`;
|
|
168
|
+
console.log(`\n${templateFiles.length} template(s), ${errorSummary}.`);
|
|
169
|
+
if (errors > 0) {
|
|
170
|
+
process.exitCode = 1;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
//# sourceMappingURL=compile.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compile.js","sourceRoot":"","sources":["../../src/commands/compile.ts"],"names":[],"mappings":";;;;;AAYA,4CAOC;AAED,wCAoBC;AA+DD,gCA0FC;AAlMD,4CAAoB;AACpB,gDAAwB;AACxB,gDAA4C;AAG5C,qBAAqB;AACrB,MAAM,GAAG,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,WAAW,CAAC,SAAS,CAAC;AACjD,MAAM,MAAM,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,WAAW,CAAC,SAAS,CAAC;AACpD,MAAM,IAAI,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,WAAW,CAAC,SAAS,CAAC;AAClD,MAAM,GAAG,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC;AAChD,MAAM,IAAI,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC;AAEjD,SAAgB,gBAAgB;IAC9B,IAAI,GAAG,GA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GAAG,MAAM,WAAW,CAAC;IACnF,OAAO,CAAC,GAAG,CAAC,KAAK,aAAa,CAAC,MAAM,iBAAiB,YAAY,GAAG,CAAC,CAAC;IAEvE,IAAI,MAAM,GAAG,CAAC,EAAE,CAAC;QACf,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;IACvB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"help.d.ts","sourceRoot":"","sources":["../../src/commands/help.ts"],"names":[],"mappings":"AAAA,wBAAgB,IAAI,IAAI,IAAI,CAe3B"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.help = help;
|
|
4
|
+
function help() {
|
|
5
|
+
console.log(`
|
|
6
|
+
typecek — typed templating for TypeScript
|
|
7
|
+
|
|
8
|
+
Usage: typecek <command> (or typecku <command>)
|
|
9
|
+
|
|
10
|
+
Commands:
|
|
11
|
+
init Set up tsconfig.json and .gitignore for Typecek
|
|
12
|
+
compile Compile all .tc templates to .typecek/ directory
|
|
13
|
+
check Type-check templates without generating output
|
|
14
|
+
watch Watch for changes and recompile automatically
|
|
15
|
+
clean Remove the .typecek/ directory (alias: clear)
|
|
16
|
+
list Show all templates and their associated types
|
|
17
|
+
help Show this help message
|
|
18
|
+
`.trim());
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=help.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"help.js","sourceRoot":"","sources":["../../src/commands/help.ts"],"names":[],"mappings":";;AAAA,oBAeC;AAfD,SAAgB,IAAI;IAClB,OAAO,CAAC,GAAG,CAAC;;;;;;;;;;;;;CAab,CAAC,IAAI,EAAE,CAAC,CAAC;AACV,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AAGA,wBAAgB,IAAI,IAAI,IAAI,CA4E3B"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.init = init;
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
function init() {
|
|
10
|
+
const cwd = process.cwd();
|
|
11
|
+
const tsconfigPath = path_1.default.join(cwd, "tsconfig.json");
|
|
12
|
+
const gitignorePath = path_1.default.join(cwd, ".gitignore");
|
|
13
|
+
// Update tsconfig.json
|
|
14
|
+
if (!fs_1.default.existsSync(tsconfigPath)) {
|
|
15
|
+
console.error("tsconfig.json not found in current directory.");
|
|
16
|
+
process.exitCode = 1;
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
const tsconfig = JSON.parse(fs_1.default.readFileSync(tsconfigPath, "utf-8"));
|
|
20
|
+
const compilerOptions = tsconfig.compilerOptions ?? {};
|
|
21
|
+
const rootDirs = compilerOptions.rootDirs ?? [];
|
|
22
|
+
let tsconfigChanged = false;
|
|
23
|
+
// Add .typecek to rootDirs
|
|
24
|
+
if (!rootDirs.includes("./.typecek")) {
|
|
25
|
+
rootDirs.push("./.typecek");
|
|
26
|
+
compilerOptions.rootDirs = rootDirs;
|
|
27
|
+
tsconfig.compilerOptions = compilerOptions;
|
|
28
|
+
tsconfigChanged = true;
|
|
29
|
+
}
|
|
30
|
+
// Ensure rootDirs has the source dir too
|
|
31
|
+
const rootDir = compilerOptions.rootDir ?? "./src";
|
|
32
|
+
if (!rootDirs.includes(rootDir) && !rootDirs.includes(rootDir.replace(/^\.\//, ""))) {
|
|
33
|
+
rootDirs.unshift(rootDir);
|
|
34
|
+
tsconfigChanged = true;
|
|
35
|
+
}
|
|
36
|
+
// Remove rootDir — it conflicts with rootDirs when .typecek/ files are outside it
|
|
37
|
+
if (compilerOptions.rootDir) {
|
|
38
|
+
delete compilerOptions.rootDir;
|
|
39
|
+
tsconfigChanged = true;
|
|
40
|
+
}
|
|
41
|
+
// Ensure include covers .typecek/
|
|
42
|
+
const include = tsconfig.include ?? [];
|
|
43
|
+
const hasTypecekInclude = include.some((p) => p.startsWith(".typecek"));
|
|
44
|
+
if (!hasTypecekInclude) {
|
|
45
|
+
include.push(".typecek/**/*.ts");
|
|
46
|
+
tsconfig.include = include;
|
|
47
|
+
tsconfigChanged = true;
|
|
48
|
+
}
|
|
49
|
+
if (tsconfigChanged) {
|
|
50
|
+
fs_1.default.writeFileSync(tsconfigPath, JSON.stringify(tsconfig, null, 2) + "\n");
|
|
51
|
+
console.log("Updated tsconfig.json.");
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
console.log("tsconfig.json already configured.");
|
|
55
|
+
}
|
|
56
|
+
// Update .gitignore
|
|
57
|
+
if (fs_1.default.existsSync(gitignorePath)) {
|
|
58
|
+
const content = fs_1.default.readFileSync(gitignorePath, "utf-8");
|
|
59
|
+
if (!content.includes(".typecek")) {
|
|
60
|
+
fs_1.default.appendFileSync(gitignorePath, "\n# Typecek compiled output\n.typecek/\n");
|
|
61
|
+
console.log("Added .typecek/ to .gitignore.");
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
console.log(".gitignore already includes .typecek/.");
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
fs_1.default.writeFileSync(gitignorePath, "# Typecek compiled output\n.typecek/\n");
|
|
69
|
+
console.log("Created .gitignore with .typecek/.");
|
|
70
|
+
}
|
|
71
|
+
// Create .typecek directory
|
|
72
|
+
const typecekDir = path_1.default.join(cwd, ".typecek");
|
|
73
|
+
if (!fs_1.default.existsSync(typecekDir)) {
|
|
74
|
+
fs_1.default.mkdirSync(typecekDir, { recursive: true });
|
|
75
|
+
}
|
|
76
|
+
console.log("Typecek initialized.");
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=init.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init.js","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":";;;;;AAGA,oBA4EC;AA/ED,4CAAoB;AACpB,gDAAwB;AAExB,SAAgB,IAAI;IAClB,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;IAC1B,MAAM,YAAY,GAAG,cAAI,CAAC,IAAI,CAAC,GAAG,EAAE,eAAe,CAAC,CAAC;IACrD,MAAM,aAAa,GAAG,cAAI,CAAC,IAAI,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC;IAEnD,uBAAuB;IACvB,IAAI,CAAC,YAAE,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE,CAAC;QACjC,OAAO,CAAC,KAAK,CAAC,+CAA+C,CAAC,CAAC;QAC/D,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;QACrB,OAAO;IACT,CAAC;IAED,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,YAAE,CAAC,YAAY,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC,CAAC;IACpE,MAAM,eAAe,GAAG,QAAQ,CAAC,eAAe,IAAI,EAAE,CAAC;IACvD,MAAM,QAAQ,GAAa,eAAe,CAAC,QAAQ,IAAI,EAAE,CAAC;IAE1D,IAAI,eAAe,GAAG,KAAK,CAAC;IAE5B,2BAA2B;IAC3B,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,YAAY,CAAC,EAAE,CAAC;QACrC,QAAQ,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QAC5B,eAAe,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACpC,QAAQ,CAAC,eAAe,GAAG,eAAe,CAAC;QAC3C,eAAe,GAAG,IAAI,CAAC;IACzB,CAAC;IAED,yCAAyC;IACzC,MAAM,OAAO,GAAG,eAAe,C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AC,CAAC;QACxD,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC;YAClC,YAAE,CAAC,cAAc,CAAC,aAAa,EAAE,0CAA0C,CAAC,CAAC;YAC7E,OAAO,CAAC,GAAG,CAAC,gCAAgC,CAAC,CAAC;QAChD,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,GAAG,CAAC,wCAAwC,CAAC,CAAC;QACxD,CAAC;IACH,CAAC;SAAM,CAAC;QACN,YAAE,CAAC,aAAa,CAAC,aAAa,EAAE,wCAAwC,CAAC,CAAC;QAC1E,OAAO,CAAC,GAAG,CAAC,oCAAoC,CAAC,CAAC;IACpD,CAAC;IAED,4BAA4B;IAC5B,MAAM,UAAU,GAAG,cAAI,CAAC,IAAI,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;IAC9C,IAAI,CAAC,YAAE,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;QAC/B,YAAE,CAAC,SAAS,CAAC,UAAU,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAChD,CAAC;IAED,OAAO,CAAC,GAAG,CAAC,sBAAsB,CAAC,CAAC;AACtC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../src/commands/list.ts"],"names":[],"mappings":"AAMA,wBAAgB,IAAI,IAAI,IAAI,CAuB3B"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.list = list;
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const compile_js_1 = require("./compile.js");
|
|
10
|
+
const TYPE_DIRECTIVE_RE = /\{\{#import\s+(\w+)\s+from\s+["']([^"']+)["']\s*\}\}/;
|
|
11
|
+
function list() {
|
|
12
|
+
const projectRoot = (0, compile_js_1.findTsconfigRoot)();
|
|
13
|
+
const sourceRoot = (0, compile_js_1.findSourceRoot)(projectRoot);
|
|
14
|
+
const templateFiles = findTemplateFilesRecursive(sourceRoot);
|
|
15
|
+
if (templateFiles.length === 0) {
|
|
16
|
+
console.log("No .tc template files found.");
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
console.log(`Found ${templateFiles.length} template(s):\n`);
|
|
20
|
+
for (const templatePath of templateFiles) {
|
|
21
|
+
const relativePath = path_1.default.relative(projectRoot, templatePath);
|
|
22
|
+
const firstLine = readFirstLine(templatePath);
|
|
23
|
+
const match = firstLine ? TYPE_DIRECTIVE_RE.exec(firstLine) : null;
|
|
24
|
+
if (match) {
|
|
25
|
+
console.log(` ${relativePath} → ${match[1]} from "${match[2]}"`);
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
console.log(` ${relativePath} → (no type directive)`);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
function readFirstLine(filePath) {
|
|
33
|
+
try {
|
|
34
|
+
const content = fs_1.default.readFileSync(filePath, "utf-8");
|
|
35
|
+
const newlineIndex = content.indexOf("\n");
|
|
36
|
+
return newlineIndex === -1 ? content : content.slice(0, newlineIndex);
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
function findTemplateFilesRecursive(dir) {
|
|
43
|
+
const results = [];
|
|
44
|
+
function walk(currentDir) {
|
|
45
|
+
const entries = fs_1.default.readdirSync(currentDir, { withFileTypes: true });
|
|
46
|
+
for (const entry of entries) {
|
|
47
|
+
const fullPath = path_1.default.join(currentDir, entry.name);
|
|
48
|
+
if (entry.isDirectory()) {
|
|
49
|
+
if (entry.name === "node_modules" || entry.name.startsWith("."))
|
|
50
|
+
continue;
|
|
51
|
+
walk(fullPath);
|
|
52
|
+
}
|
|
53
|
+
else if (entry.name.endsWith(".tc")) {
|
|
54
|
+
results.push(fullPath);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
walk(dir);
|
|
59
|
+
return results;
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=list.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list.js","sourceRoot":"","sources":["../../src/commands/list.ts"],"names":[],"mappings":";;;;;AAMA,oBAuBC;AA7BD,4CAAoB;AACpB,gDAAwB;AACxB,6CAAgE;AAEhE,MAAM,iBAAiB,GAAG,sDAAsD,CAAC;AAEjF,SAAgB,IAAI;IAClB,MAAM,WAAW,GAAG,IAAA,6BAAgB,GAAE,CAAC;IACvC,MAAM,UAAU,GAAG,IAAA,2BAAc,EAAC,WAAW,CAAC,CAAC;IAC/C,MAAM,aAAa,GAAG,0BAA0B,CAAC,UAAU,CAAC,CAAC;IAE7D,IAAI,aAAa,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC/B,OAAO,CAAC,GAAG,CAAC,8BAA8B,CAAC,CAAC;QAC5C,OAAO;IACT,CAAC;IAED,OAAO,CAAC,GAAG,CAAC,SAAS,aAAa,CAAC,MAAM,iBAAiB,CAAC,CAAC;IAE5D,KAAK,MAAM,YAAY,IAAI,aAAa,EAAE,CAAC;QACzC,MAAM,YAAY,GAAG,cAAI,CAAC,QAAQ,CAAC,WAAW,EAAE,YAAY,CAAC,CAAC;QAC9D,MAAM,SAAS,GAAG,aAAa,CAAC,YAAY,CAAC,CAAC;QAC9C,MAAM,KAAK,GAAG,SAAS,CAAC,CAAC,CAAC,iBAAiB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;QAEnE,IAAI,KAAK,EAAE,CAAC;YACV,OAAO,CAAC,GAAG,CAAC,KAAK,YAAY,QAAQ,KAAK,CAAC,CAAC,CA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C,QAAQ,CAAC,CAAC;YACzB,CAAC;QACH,CAAC;IACH,CAAC;IAED,IAAI,CAAC,GAAG,CAAC,CAAC;IACV,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"watch.d.ts","sourceRoot":"","sources":["../../src/commands/watch.ts"],"names":[],"mappings":"AAKA,wBAAgB,KAAK,IAAI,IAAI,CAuC5B"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.watch = watch;
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const compiler_1 = require("@typecek/compiler");
|
|
10
|
+
const compile_js_1 = require("./compile.js");
|
|
11
|
+
function watch() {
|
|
12
|
+
const projectRoot = (0, compile_js_1.findTsconfigRoot)();
|
|
13
|
+
const sourceRoot = (0, compile_js_1.findSourceRoot)(projectRoot);
|
|
14
|
+
const typecekDir = path_1.default.join(projectRoot, ".typecek");
|
|
15
|
+
console.log(`Watching for .tc file changes in ${path_1.default.relative(process.cwd(), sourceRoot) || "."}...`);
|
|
16
|
+
console.log("Press Ctrl+C to stop.\n");
|
|
17
|
+
fs_1.default.watch(sourceRoot, { recursive: true }, (eventType, filename) => {
|
|
18
|
+
if (!filename || !filename.endsWith(".tc"))
|
|
19
|
+
return;
|
|
20
|
+
const templatePath = path_1.default.join(sourceRoot, filename);
|
|
21
|
+
const relativePath = filename;
|
|
22
|
+
const outputRelative = relativePath.replace(/\.tc$/, ".ts");
|
|
23
|
+
const outputPath = path_1.default.join(typecekDir, outputRelative);
|
|
24
|
+
// Handle deletion
|
|
25
|
+
if (!fs_1.default.existsSync(templatePath)) {
|
|
26
|
+
if (fs_1.default.existsSync(outputPath)) {
|
|
27
|
+
fs_1.default.unlinkSync(outputPath);
|
|
28
|
+
console.log(` deleted ${relativePath}`);
|
|
29
|
+
}
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
// Compile
|
|
33
|
+
try {
|
|
34
|
+
const template = fs_1.default.readFileSync(templatePath, "utf-8");
|
|
35
|
+
const result = (0, compiler_1.compile)({ template, filename: path_1.default.basename(templatePath) });
|
|
36
|
+
const outputDir = path_1.default.dirname(outputPath);
|
|
37
|
+
fs_1.default.mkdirSync(outputDir, { recursive: true });
|
|
38
|
+
fs_1.default.writeFileSync(outputPath, result.code);
|
|
39
|
+
console.log(` compiled ${relativePath}`);
|
|
40
|
+
}
|
|
41
|
+
catch (err) {
|
|
42
|
+
console.error(` error in ${relativePath}: ${err instanceof Error ? err.message : err}`);
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=watch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"watch.js","sourceRoot":"","sources":["../../src/commands/watch.ts"],"names":[],"mappings":";;;;;AAKA,sBAuCC;AA5CD,4CAAoB;AACpB,gDAAwB;AACxB,gDAA4C;AAC5C,6CAAgE;AAEhE,SAAgB,KAAK;IACnB,MAAM,WAAW,GAAG,IAAA,6BAAgB,GAAE,CAAC;IACvC,MAAM,UAAU,GAAG,IAAA,2BAAc,EAAC,WAAW,CAAC,CAAC;IAC/C,MAAM,UAAU,GAAG,cAAI,CAAC,IAAI,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC;IAEtD,OAAO,CAAC,GAAG,CAAC,oCAAoC,cAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,UAAU,CAAC,IAAI,GAAG,KAAK,CAAC,CAAC;IACtG,OAAO,CAAC,GAAG,CAAC,yBAAyB,CAAC,CAAC;IAEvC,YAAE,CAAC,KAAK,CAAC,UAAU,EAAE,EA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EAAE,CAAC,CAAC;QAC5C,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,OAAO,CAAC,KAAK,CAAC,cAAc,YAAY,KAAK,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC;QAC3F,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAOA,wBAAgB,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,IAAI,CA8BzC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.main = main;
|
|
4
|
+
const init_js_1 = require("./commands/init.js");
|
|
5
|
+
const compile_js_1 = require("./commands/compile.js");
|
|
6
|
+
const clean_js_1 = require("./commands/clean.js");
|
|
7
|
+
const list_js_1 = require("./commands/list.js");
|
|
8
|
+
const watch_js_1 = require("./commands/watch.js");
|
|
9
|
+
const help_js_1 = require("./commands/help.js");
|
|
10
|
+
function main(args) {
|
|
11
|
+
const command = args[0] ?? "help";
|
|
12
|
+
switch (command) {
|
|
13
|
+
case "init":
|
|
14
|
+
(0, init_js_1.init)();
|
|
15
|
+
break;
|
|
16
|
+
case "compile":
|
|
17
|
+
(0, compile_js_1.compileAll)(false);
|
|
18
|
+
break;
|
|
19
|
+
case "check":
|
|
20
|
+
(0, compile_js_1.compileAll)(true);
|
|
21
|
+
break;
|
|
22
|
+
case "watch":
|
|
23
|
+
(0, watch_js_1.watch)();
|
|
24
|
+
break;
|
|
25
|
+
case "clean":
|
|
26
|
+
case "clear":
|
|
27
|
+
(0, clean_js_1.clean)();
|
|
28
|
+
break;
|
|
29
|
+
case "list":
|
|
30
|
+
(0, list_js_1.list)();
|
|
31
|
+
break;
|
|
32
|
+
case "help":
|
|
33
|
+
(0, help_js_1.help)();
|
|
34
|
+
break;
|
|
35
|
+
default:
|
|
36
|
+
console.error(`typecek: unknown command "${command}". Run "typecek help" for usage.`);
|
|
37
|
+
process.exitCode = 1;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;AAOA,oBA8BC;AArCD,gDAA0C;AAC1C,sDAAmD;AACnD,kDAA4C;AAC5C,gDAA0C;AAC1C,kDAA4C;AAC5C,gDAA0C;AAE1C,SAAgB,IAAI,CAAC,IAAc;IACjC,MAAM,OAAO,GAAG,IAAI,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC;IAElC,QAAQ,OAAO,EAAE,CAAC;QAChB,KAAK,MAAM;YACT,IAAA,cAAI,GAAE,CAAC;YACP,MAAM;QACR,KAAK,SAAS;YACZ,IAAA,uBAAU,EAAC,KAAK,CAAC,CAAC;YAClB,MAAM;QACR,KAAK,OAAO;YACV,IAAA,uBAAU,EAAC,IAAI,CAAC,CAAC;YACjB,MAAM;QACR,KAAK,OAAO;YACV,IAAA,gBAAK,GAAE,CAAC;YACR,MAAM;QACR,KAAK,OAAO,CAAC;QACb,KAAK,OAAO;YACV,IAAA,gBAAK,GAAE,CAAC;YACR,MAAM;QACR,KAAK,MAAM;YACT,IAAA,cAAI,GAAE,CAAC;YACP,MAAM;QACR,KAAK,MAAM;YACT,IAAA,cAAI,GAAE,CAAC;YACP,MAAM;QACR;YACE,OAAO,CAAC,KAAK,CAAC,6BAA6B,OAAO,kCAAkC,CAAC,CAAC;YACtF,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;IACzB,CAAC;AACH,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@typecek/cli",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "CLI for Typecek",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"bin": {
|
|
8
|
+
"typecek": "dist/bin.js",
|
|
9
|
+
"typecku": "dist/bin.js"
|
|
10
|
+
},
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"@typecek/core": "0.0.1",
|
|
13
|
+
"@typecek/compiler": "0.0.1"
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist"
|
|
17
|
+
],
|
|
18
|
+
"license": "MIT",
|
|
19
|
+
"publishConfig": {
|
|
20
|
+
"access": "public"
|
|
21
|
+
},
|
|
22
|
+
"repository": {
|
|
23
|
+
"type": "git",
|
|
24
|
+
"url": "https://github.com/rousek/typecek",
|
|
25
|
+
"directory": "packages/cli"
|
|
26
|
+
},
|
|
27
|
+
"scripts": {
|
|
28
|
+
"build": "tsc -b",
|
|
29
|
+
"clean": "rm -rf dist *.tsbuildinfo"
|
|
30
|
+
}
|
|
31
|
+
}
|