@contractkit/plugin-typescript 0.19.1 → 0.20.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/.turbo/turbo-build$colon$ci.log +6 -6
- package/.turbo/turbo-test$colon$ci.log +12 -12
- package/CHANGELOG.md +15 -0
- package/coverage/clover.xml +223 -219
- package/coverage/coverage-final.json +1 -1
- package/coverage/index.html +15 -15
- package/coverage/src/codegen-contract.ts.html +1 -1
- package/coverage/src/codegen-operation.ts.html +1 -1
- package/coverage/src/codegen-plain-types.ts.html +1 -1
- package/coverage/src/codegen-sdk.ts.html +1 -1
- package/coverage/src/index.html +14 -14
- package/coverage/src/index.ts.html +53 -14
- package/coverage/src/path-utils.ts.html +1 -1
- package/coverage/src/ts-render.ts.html +1 -1
- package/coverage/tests/helpers.ts.html +1 -1
- package/coverage/tests/index.html +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +15 -5
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- package/src/index.ts +17 -4
- package/tests/codegen-server.test.ts +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contractkit/plugin-typescript",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.20.0",
|
|
4
4
|
"description": "ContractKit built-in plugin: TypeScript codegen (SDK clients, Koa routers, Zod schemas, plain types)",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Marooned Software",
|
|
@@ -26,11 +26,11 @@
|
|
|
26
26
|
".": "./dist/index.js"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@contractkit/core": "0.
|
|
29
|
+
"@contractkit/core": "0.16.0"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@repo/config-
|
|
33
|
-
"@repo/config-
|
|
32
|
+
"@repo/config-typescript": "0.1.0",
|
|
33
|
+
"@repo/config-eslint": "0.3.1"
|
|
34
34
|
},
|
|
35
35
|
"scripts": {
|
|
36
36
|
"build": "tsup src/index.ts --format esm --sourcemap --dts && tsc --emitDeclarationOnly --declaration",
|
package/src/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { resolve, join, relative, dirname, basename } from 'node:path';
|
|
2
|
-
import { existsSync, readFileSync, rmSync, readdirSync, rmdirSync } from 'node:fs';
|
|
2
|
+
import { existsSync, readFileSync, writeFileSync, mkdirSync, rmSync, readdirSync, rmdirSync } from 'node:fs';
|
|
3
3
|
import { generateContract } from './codegen-contract.js';
|
|
4
4
|
import { generateOp } from './codegen-operation.js';
|
|
5
5
|
import type {
|
|
@@ -16,6 +16,7 @@ import {
|
|
|
16
16
|
runIncrementalCodegen,
|
|
17
17
|
parseIncrementalManifest,
|
|
18
18
|
emptyIncrementalManifest,
|
|
19
|
+
serializeIncrementalManifest,
|
|
19
20
|
hashFingerprint,
|
|
20
21
|
collectTransitiveModelRefs,
|
|
21
22
|
collectTypeRefs,
|
|
@@ -99,7 +100,8 @@ export interface TypescriptPluginConfig {
|
|
|
99
100
|
/** Bumped when the codegen output shape changes in a way that should bust every per-file fingerprint. */
|
|
100
101
|
export const TYPESCRIPT_CODEGEN_VERSION = '1';
|
|
101
102
|
|
|
102
|
-
|
|
103
|
+
/** Filename for the persisted TypeScript manifest under the CLI cache directory. */
|
|
104
|
+
const CACHE_MANIFEST_FILENAME = 'typescript-manifest.json';
|
|
103
105
|
|
|
104
106
|
// ─── Plugin entry points ──────────────────────────────────────────────────
|
|
105
107
|
|
|
@@ -137,7 +139,7 @@ async function runTypescriptCodegen(
|
|
|
137
139
|
config: TypescriptPluginConfig,
|
|
138
140
|
rootDir: string,
|
|
139
141
|
): Promise<void> {
|
|
140
|
-
const manifestPath = resolve(
|
|
142
|
+
const manifestPath = resolve(ctx.cacheDir, CACHE_MANIFEST_FILENAME);
|
|
141
143
|
const prevManifest: IncrementalManifest = ctx.cacheEnabled ? readManifest(manifestPath) : emptyIncrementalManifest(TYPESCRIPT_CODEGEN_VERSION);
|
|
142
144
|
|
|
143
145
|
const units: IncrementalUnit[] = [];
|
|
@@ -150,7 +152,6 @@ async function runTypescriptCodegen(
|
|
|
150
152
|
|
|
151
153
|
const result = runIncrementalCodegen({
|
|
152
154
|
codegenVersion: TYPESCRIPT_CODEGEN_VERSION,
|
|
153
|
-
manifestFilename: manifestPath,
|
|
154
155
|
prevManifest,
|
|
155
156
|
globalFiles,
|
|
156
157
|
units,
|
|
@@ -163,6 +164,8 @@ async function runTypescriptCodegen(
|
|
|
163
164
|
for (const { relativePath, content } of result.filesToWrite) {
|
|
164
165
|
ctx.emitFile(relativePath, content);
|
|
165
166
|
}
|
|
167
|
+
|
|
168
|
+
writeManifest(manifestPath, result.manifest);
|
|
166
169
|
}
|
|
167
170
|
|
|
168
171
|
// ─── Cross-file dependency analysis ────────────────────────────────────────
|
|
@@ -752,6 +755,16 @@ function readManifest(manifestPath: string): IncrementalManifest {
|
|
|
752
755
|
}
|
|
753
756
|
}
|
|
754
757
|
|
|
758
|
+
/** Write the manifest to `manifestPath`. Creates parent dirs as needed. Errors are swallowed so a broken cache never blocks the build. */
|
|
759
|
+
function writeManifest(manifestPath: string, manifest: IncrementalManifest): void {
|
|
760
|
+
try {
|
|
761
|
+
mkdirSync(dirname(manifestPath), { recursive: true });
|
|
762
|
+
writeFileSync(manifestPath, serializeIncrementalManifest(manifest), 'utf-8');
|
|
763
|
+
} catch {
|
|
764
|
+
// best-effort
|
|
765
|
+
}
|
|
766
|
+
}
|
|
767
|
+
|
|
755
768
|
function deleteStalePaths(absPaths: string[]): void {
|
|
756
769
|
if (absPaths.length === 0) return;
|
|
757
770
|
const removedDirs = new Set<string>();
|
|
@@ -11,6 +11,7 @@ function makeCtx(rootDir = '/project', options: Record<string, unknown> = {}): P
|
|
|
11
11
|
rootDir,
|
|
12
12
|
options,
|
|
13
13
|
cacheEnabled: true,
|
|
14
|
+
cacheDir: `${rootDir}/.contractkit/cache`,
|
|
14
15
|
emitFile: (outPath: string, content: string) => {
|
|
15
16
|
emitted.set(outPath, content);
|
|
16
17
|
},
|