@akanjs/devkit 3.3.0-rc.11 → 3.3.0-rc.13

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.
Files changed (56) hide show
  1. package/CHANGELOG.md +51 -0
  2. package/DEV_RUNTIME_KNOBS.md +1 -1
  3. package/akanConfig/akanConfig.ts +4 -4
  4. package/app/applicationBuildRunner.test.ts +272 -0
  5. package/app/applicationBuildRunner.ts +87 -2
  6. package/artifact/implicitRootLayoutRender.test.tsx +4 -1
  7. package/codeAgent/skills/akan-err/SKILL.md +11 -2
  8. package/codeAgent/skills/akan-page/SKILL.md +4 -14
  9. package/codeAgent/skills/akan-runtime/SKILL.md +20 -0
  10. package/docs/apiReference.test.ts +9 -0
  11. package/docs/apiReference.ts +14 -0
  12. package/executors/workspaceExecutor.ts +7 -4
  13. package/frontendBuild/clientEntryDiscovery.test.ts +35 -0
  14. package/frontendBuild/clientEntryDiscovery.ts +14 -1
  15. package/lint/__fixtures__/no-arbitrary-color/every-color-function/bad.tsx +11 -0
  16. package/lint/__fixtures__/no-arbitrary-color/every-color-function/good.tsx +2 -0
  17. package/lint/__fixtures__/no-daisyui-legacy-class/every-class/bad.tsx +34 -0
  18. package/lint/__fixtures__/no-daisyui-legacy-class/every-class/good.tsx +2 -0
  19. package/lint/__fixtures__/no-inline-color/every-color-function/bad.tsx +10 -0
  20. package/lint/__fixtures__/no-inline-color/every-color-function/good.tsx +2 -0
  21. package/lint/__fixtures__/no-raw-palette-class/every-palette/bad.tsx +22 -0
  22. package/lint/__fixtures__/no-raw-palette-class/every-palette/good.tsx +2 -0
  23. package/lint/biomeCheck.test.ts +145 -0
  24. package/lint/biomeCheck.ts +131 -0
  25. package/lint/no-arbitrary-color.grit +5 -0
  26. package/lint/no-conditional-st-hook.grit +5 -1
  27. package/lint/no-daisyui-legacy-class.grit +8 -0
  28. package/lint/no-document-cookie.grit +3 -0
  29. package/lint/no-inline-color.grit +10 -2
  30. package/lint/no-oversized-list-limit.grit +2 -0
  31. package/lint/no-raw-palette-class.grit +7 -0
  32. package/lint/no-unpublished-form-setter.grit +2 -0
  33. package/lint/no-web-only-api-outside-webkit.grit +5 -0
  34. package/lint/no-web-storage.grit +3 -0
  35. package/lint/withheldEnvFile.ts +17 -0
  36. package/mobile/serverBundleSecrets.ts +43 -0
  37. package/package.json +3 -3
  38. package/test/secretEnvFixture.ts +134 -0
  39. package/transforms/secretEnvDeclaration.test.ts +208 -0
  40. package/transforms/secretEnvDeclaration.ts +213 -0
  41. package/transforms/secretEnvFile.test.ts +117 -0
  42. package/transforms/secretEnvFile.ts +113 -0
  43. package/transforms/secretEnvName.test.ts +54 -0
  44. package/transforms/secretEnvName.ts +29 -0
  45. package/transforms/secretEnvSource.test.ts +148 -0
  46. package/transforms/secretEnvSource.ts +166 -0
  47. package/transforms/serverEnvEvaluationError.ts +11 -0
  48. package/transforms/serverEnvPlugin.test.ts +2 -1
  49. package/transforms/serverEnvPlugin.ts +13 -0
  50. package/transforms/serverEnvProfile.test.ts +115 -2
  51. package/transforms/serverEnvProfile.ts +117 -40
  52. package/transforms/serverEnvSecrets.test.ts +292 -0
  53. package/typecheck/projectTypecheck.test.ts +29 -0
  54. package/typecheck/typeChecker.test.ts +49 -0
  55. package/typecheck/typeChecker.ts +9 -7
  56. package/typecheck/withheldDiagnostics.ts +41 -0
@@ -4,6 +4,7 @@ import chalk from "chalk";
4
4
  import * as ts from "typescript";
5
5
 
6
6
  import type { Executor } from "../executors";
7
+ import { WithheldDiagnostics } from "./withheldDiagnostics";
7
8
 
8
9
  export interface ProjectTypecheckResult {
9
10
  configPath: string;
@@ -93,7 +94,7 @@ export class TypeChecker {
93
94
  : diagnostic.category === ts.DiagnosticCategory.Warning
94
95
  ? (["warning", chalk.yellow, "⚠️"] as const)
95
96
  : (["suggestion", chalk.blue, "💡"] as const);
96
- const message = ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n");
97
+ const message = WithheldDiagnostics.message(diagnostic);
97
98
  const tsCode = chalk.dim(`(TS${diagnostic.code})`);
98
99
 
99
100
  if (diagnostic.file && diagnostic.start !== undefined) {
@@ -103,7 +104,7 @@ export class TypeChecker {
103
104
  output.push(` ${chalk.gray("at")} ${fileName}:${chalk.bold(`${line + 1}:${character + 1}`)}`);
104
105
 
105
106
  const sourceLines = diagnostic.file.text.split("\n");
106
- if (line < sourceLines.length) {
107
+ if (!WithheldDiagnostics.applies(diagnostic) && line < sourceLines.length) {
107
108
  const sourceLine = sourceLines[line];
108
109
  const lineNumber = (line + 1).toString().padStart(5, " ");
109
110
 
@@ -139,10 +140,10 @@ export class TypeChecker {
139
140
  const details = diagnostics.map((diagnostic) => {
140
141
  if (diagnostic.file && diagnostic.start !== undefined) {
141
142
  const { line, character } = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start);
142
- const message = ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n");
143
+ const message = WithheldDiagnostics.message(diagnostic);
143
144
 
144
145
  const lines = sourceFile.text.split("\n");
145
- const codeSnippet = line < lines.length ? lines[line] : undefined;
146
+ const codeSnippet = line < lines.length && !WithheldDiagnostics.applies(diagnostic) ? lines[line] : undefined;
146
147
  return { line: line + 1, column: character + 1, message, code: diagnostic.code, codeSnippet };
147
148
  }
148
149
 
@@ -238,16 +239,17 @@ export class TypeChecker {
238
239
  col: position ? position.character + 1 : 0,
239
240
  code: `TS${diagnostic.code}`,
240
241
  severity: diagnostic.category === ts.DiagnosticCategory.Error ? "error" : "warning",
241
- message: ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n"),
242
+ message: WithheldDiagnostics.message(diagnostic),
242
243
  };
243
244
  });
244
245
  }
245
246
 
246
247
  static formatDiagnosticMessages(diagnostics: ts.Diagnostic[]): string {
247
- return ts.formatDiagnosticsWithColorAndContext(diagnostics, {
248
+ const host: ts.FormatDiagnosticsHost = {
248
249
  getCanonicalFileName: (fileName) => fileName,
249
250
  getCurrentDirectory: () => process.cwd(),
250
251
  getNewLine: () => ts.sys.newLine,
251
- });
252
+ };
253
+ return diagnostics.map((diagnostic) => WithheldDiagnostics.format(diagnostic, host)).join("");
252
254
  }
253
255
  }
@@ -0,0 +1,41 @@
1
+ import * as path from "node:path";
2
+ import * as ts from "typescript";
3
+ import { WithheldEnvFile } from "../lint/withheldEnvFile";
4
+
5
+ //? A TypeScript message quotes the literal too: `Type '"abc"' is not assignable`.
6
+ export class WithheldDiagnostics {
7
+ static readonly note = WithheldEnvFile.note;
8
+
9
+ static isWithheld(fileName: string | undefined) {
10
+ return WithheldEnvFile.isEnvFile(fileName);
11
+ }
12
+
13
+ static applies(diagnostic: ts.Diagnostic) {
14
+ return WithheldDiagnostics.isWithheld(diagnostic.file?.fileName);
15
+ }
16
+
17
+ static message(diagnostic: ts.Diagnostic) {
18
+ return WithheldDiagnostics.applies(diagnostic)
19
+ ? WithheldDiagnostics.note
20
+ : ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n");
21
+ }
22
+
23
+ static format(diagnostic: ts.Diagnostic, host: ts.FormatDiagnosticsHost) {
24
+ const related = diagnostic.relatedInformation?.filter(
25
+ ({ file }) => !WithheldDiagnostics.isWithheld(file?.fileName),
26
+ );
27
+ if (!WithheldDiagnostics.applies(diagnostic))
28
+ return ts.formatDiagnosticsWithColorAndContext(
29
+ [
30
+ related?.length === diagnostic.relatedInformation?.length
31
+ ? diagnostic
32
+ : { ...diagnostic, relatedInformation: related },
33
+ ],
34
+ host,
35
+ );
36
+ const { file, start } = diagnostic;
37
+ const at = file && start !== undefined ? file.getLineAndCharacterOfPosition(start) : { line: -1, character: -1 };
38
+ const name = path.relative(host.getCurrentDirectory(), file?.fileName ?? "");
39
+ return `${name}:${at.line + 1}:${at.character + 1} - error TS${diagnostic.code}: ${WithheldDiagnostics.note}${host.getNewLine()}`;
40
+ }
41
+ }