@flytedesk/app-kit 0.1.1 → 0.1.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flytedesk/app-kit",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Shared platform kit for flytedesk apps: flytedesk-id auth (BFF/OIDC client) and a Postgres-native trace/audit layer.",
5
5
  "type": "module",
6
6
  "license": "UNLICENSED",
@@ -24,7 +24,8 @@
24
24
  },
25
25
  "files": [
26
26
  "dist",
27
- "prisma"
27
+ "prisma",
28
+ "scripts"
28
29
  ],
29
30
  "bin": {
30
31
  "trace-sync": "./dist/cli/trace-sync.js"
@@ -0,0 +1,121 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+
4
+ /**
5
+ * DEC-45 workaround.
6
+ *
7
+ * typescript-eslint@8.x throws at *import* time (not just at type-check time) when the
8
+ * "typescript" package it resolves is a 7.x release:
9
+ * "typescript-eslint does not support TS 7.0."
10
+ * see https://github.com/typescript-eslint/typescript-eslint/issues/10940
11
+ *
12
+ * This project's real `typescript` devDependency stays on ^7.0.2 (used for `tsc`
13
+ * build/typecheck — no shim needed there). To let `eslint .` run at all in the
14
+ * meantime, every package in typescript-eslint's own dependency graph
15
+ * (typescript-eslint itself, each @typescript-eslint/* package, and ts-api-utils) gets
16
+ * its own private node_modules/typescript pointing at `@typescript/typescript6` (a
17
+ * TS-6-API-compatible build, also a devDependency here), so `require('typescript')`
18
+ * from inside any of them resolves to something typescript-eslint accepts — without
19
+ * touching what the rest of the project (tsc, etc.) resolves "typescript" to.
20
+ *
21
+ * npm may hoist these packages to the top of node_modules or nest them under
22
+ * typescript-eslint/node_modules depending on the resolved tree, so this walks
23
+ * node_modules looking for every matching package directory rather than assuming one
24
+ * fixed location.
25
+ *
26
+ * Delete this script, the postinstall hook, and the @typescript/typescript6
27
+ * devDependency once typescript-eslint ships real TS 7.1 API support and the
28
+ * eslint.config.js `strictTypeChecked`/`stylisticTypeChecked` configs come back.
29
+ */
30
+
31
+ const fs = require("node:fs");
32
+ const path = require("node:path");
33
+
34
+ const root = path.join(__dirname, "..");
35
+
36
+ // This is a `prepare` script — npm also runs it for a plain "npm install" of THIS
37
+ // package as an ordinary dependency inside someone else's node_modules, not only for
38
+ // local dev in this repo's own working copy (see the changeset that added this guard:
39
+ // renaming postinstall -> prepare alone was NOT sufficient, contrary to what npm's own
40
+ // docs on "prepare" imply). There is nothing for this shim to do in that case — the
41
+ // `@typescript/typescript6` devDependency it patches in is never installed for
42
+ // consumers either way — so detect "installed as a dependency" (this package's parent
43
+ // directory is literally named node_modules) and exit immediately, before even
44
+ // touching the filesystem walk below.
45
+ if (path.basename(path.resolve(root, "..")) === "node_modules") {
46
+ process.exit(0);
47
+ }
48
+
49
+ const nodeModules = path.join(root, "node_modules");
50
+ const source = path.join(nodeModules, "@typescript", "typescript6");
51
+
52
+ const isTarget = (name) =>
53
+ name === "typescript-eslint" ||
54
+ name === "ts-api-utils" ||
55
+ name.startsWith("@typescript-eslint/");
56
+
57
+ if (!fs.existsSync(source)) {
58
+ console.warn(
59
+ "[eslint-ts6-shim] @typescript/typescript6 is not installed — skipping (is it in devDependencies?)",
60
+ );
61
+ process.exit(0);
62
+ }
63
+
64
+ /** Find every `node_modules/<pkg>` directory (scoped or not) under `dir`, recursing into
65
+ * nested node_modules too, so hoisted and non-hoisted copies both get patched. */
66
+ function findPackageDirs(dir, depth = 0) {
67
+ const found = [];
68
+ if (depth > 6) return found;
69
+ let entries;
70
+ try {
71
+ entries = fs.readdirSync(dir, { withFileTypes: true });
72
+ } catch {
73
+ return found;
74
+ }
75
+ for (const entry of entries) {
76
+ if (!entry.isDirectory()) continue;
77
+ if (entry.name.startsWith(".")) continue;
78
+ const full = path.join(dir, entry.name);
79
+ if (entry.name.startsWith("@")) {
80
+ // scoped: recurse one level for the actual package names
81
+ found.push(...findPackageDirs(full, depth + 1));
82
+ continue;
83
+ }
84
+ found.push(full);
85
+ const nested = path.join(full, "node_modules");
86
+ if (fs.existsSync(nested)) {
87
+ found.push(...findPackageDirs(nested, depth + 1));
88
+ }
89
+ }
90
+ return found;
91
+ }
92
+
93
+ const targets = findPackageDirs(nodeModules).filter((dir) => {
94
+ const name = path
95
+ .relative(nodeModules, dir)
96
+ .split(path.sep)
97
+ .slice(-2)
98
+ .join("/");
99
+ const base = path.basename(dir);
100
+ return isTarget(base) || isTarget(name);
101
+ });
102
+
103
+ let patched = 0;
104
+ for (const pkgDir of targets) {
105
+ const shimTarget = path.join(pkgDir, "node_modules", "typescript");
106
+ fs.rmSync(shimTarget, { recursive: true, force: true });
107
+ fs.mkdirSync(path.dirname(shimTarget), { recursive: true });
108
+ fs.cpSync(source, shimTarget, { recursive: true });
109
+ patched += 1;
110
+ }
111
+
112
+ if (patched === 0) {
113
+ console.warn(
114
+ "[eslint-ts6-shim] found no typescript-eslint packages to patch — skipping",
115
+ );
116
+ process.exit(0);
117
+ }
118
+
119
+ console.log(
120
+ `[eslint-ts6-shim] linked TS6-API shim into ${patched} typescript-eslint package(s)`,
121
+ );