@akanjs/devkit 1.0.19 → 2.1.0-rc.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.
Files changed (194) hide show
  1. package/aiEditor.ts +304 -0
  2. package/akanApp/akanApp.host.ts +393 -0
  3. package/akanApp/index.ts +1 -0
  4. package/akanConfig/akanConfig.test.ts +236 -0
  5. package/akanConfig/akanConfig.ts +384 -0
  6. package/akanConfig/index.ts +2 -0
  7. package/akanConfig/types.ts +23 -0
  8. package/applicationBuildReporter.ts +69 -0
  9. package/applicationBuildRunner.ts +302 -0
  10. package/applicationReleasePackager.ts +206 -0
  11. package/artifact/implicitRootLayout.ts +155 -0
  12. package/artifact/index.ts +1 -0
  13. package/artifact/routeSeedIndex.test.ts +98 -0
  14. package/artifact/routeSeedIndex.ts +130 -0
  15. package/auth.ts +41 -0
  16. package/builder.ts +164 -0
  17. package/capacitor.base.config.ts +88 -0
  18. package/capacitorApp.ts +440 -0
  19. package/commandDecorators/argMeta.ts +102 -0
  20. package/commandDecorators/command.ts +343 -0
  21. package/commandDecorators/commandBuilder.ts +224 -0
  22. package/commandDecorators/commandDecorators.test.ts +212 -0
  23. package/commandDecorators/commandMeta.ts +7 -0
  24. package/commandDecorators/dependencyBuilder.ts +100 -0
  25. package/{esm/src/commandDecorators/helpFormatter.js → commandDecorators/helpFormatter.ts} +100 -47
  26. package/{esm/src/commandDecorators/index.js → commandDecorators/index.ts} +4 -2
  27. package/commandDecorators/targetMeta.ts +31 -0
  28. package/commandDecorators/types.ts +10 -0
  29. package/constants.ts +25 -0
  30. package/createTunnel.ts +36 -0
  31. package/dependencyScanner.ts +357 -0
  32. package/devkitUtils.test.ts +259 -0
  33. package/executors.test.ts +315 -0
  34. package/executors.ts +1390 -0
  35. package/{esm/src/extractDeps.js → extractDeps.ts} +26 -20
  36. package/{esm/src/fileEditor.js → fileEditor.ts} +51 -32
  37. package/fileSys.ts +39 -0
  38. package/frontendBuild/allRoutesBuilder.ts +103 -0
  39. package/frontendBuild/buildRouteClient.test.ts +190 -0
  40. package/frontendBuild/clientBuildTypes.ts +114 -0
  41. package/frontendBuild/clientEntriesBundler.ts +303 -0
  42. package/frontendBuild/clientEntryDiscovery.ts +199 -0
  43. package/frontendBuild/csrArtifactBuilder.ts +237 -0
  44. package/frontendBuild/cssCompiler.ts +286 -0
  45. package/frontendBuild/cssImportResolver.ts +116 -0
  46. package/frontendBuild/fontOptimizer.ts +427 -0
  47. package/frontendBuild/frontendBuild.test.ts +204 -0
  48. package/frontendBuild/hmrChangeClassifier.ts +28 -0
  49. package/frontendBuild/hmrWatcher.ts +102 -0
  50. package/frontendBuild/index.ts +18 -0
  51. package/frontendBuild/pagesBundleBuilder.ts +137 -0
  52. package/frontendBuild/pagesEntrySourceGenerator.ts +37 -0
  53. package/frontendBuild/precompressArtifacts.ts +59 -0
  54. package/frontendBuild/routeClientBuilder.ts +290 -0
  55. package/frontendBuild/routesManifestArtifactSerializer.ts +62 -0
  56. package/frontendBuild/ssrBaseArtifactBuilder.ts +139 -0
  57. package/frontendBuild/vendorSpecifiers.ts +16 -0
  58. package/frontendBuild/watchRootResolver.ts +28 -0
  59. package/getCredentials.ts +19 -0
  60. package/getDirname.ts +3 -0
  61. package/getModelFileData.ts +59 -0
  62. package/getRelatedCnsts.ts +313 -0
  63. package/guideline.ts +19 -0
  64. package/incrementalBuilder/incrementalBuilder.host.test.ts +51 -0
  65. package/incrementalBuilder/incrementalBuilder.host.ts +152 -0
  66. package/incrementalBuilder/incrementalBuilder.proc.ts +331 -0
  67. package/incrementalBuilder/index.ts +1 -0
  68. package/{esm/src/index.js → index.ts} +28 -15
  69. package/lint/no-deep-internal-import.grit +25 -0
  70. package/lint/no-import-client-functions.grit +32 -0
  71. package/lint/no-import-external-library.grit +21 -0
  72. package/lint/no-js-private-class-method.grit +42 -0
  73. package/lint/no-use-client-in-server.grit +7 -0
  74. package/lint/non-scalar-props-restricted.grit +13 -0
  75. package/linter.ts +271 -0
  76. package/mobile/index.ts +1 -0
  77. package/mobile/mobileTarget.test.ts +53 -0
  78. package/mobile/mobileTarget.ts +88 -0
  79. package/package.json +48 -31
  80. package/prompter.ts +72 -0
  81. package/scanInfo.ts +606 -0
  82. package/selectModel.ts +11 -0
  83. package/{esm/src/spinner.js → spinner.ts} +22 -28
  84. package/{esm/src/capacitorApp.js → src/capacitorApp.ts} +82 -81
  85. package/sshTunnel.ts +152 -0
  86. package/{esm/src/streamAi.js → streamAi.ts} +18 -12
  87. package/transforms/barrelAnalyzer.ts +278 -0
  88. package/transforms/barrelImportsPlugin.ts +504 -0
  89. package/transforms/externalizeFrameworkPlugin.ts +185 -0
  90. package/transforms/index.ts +5 -0
  91. package/transforms/rscUseClientTransform.ts +59 -0
  92. package/transforms/transforms.test.ts +208 -0
  93. package/transforms/useClientBundlePlugin.ts +47 -0
  94. package/tsconfig.json +37 -0
  95. package/typeChecker.ts +264 -0
  96. package/types.ts +44 -0
  97. package/ui/MultiScrollList.tsx +242 -0
  98. package/ui/ScrollList.tsx +107 -0
  99. package/ui/index.ts +2 -0
  100. package/{esm/src/uploadRelease.js → uploadRelease.ts} +50 -34
  101. package/{esm/src/useStdoutDimensions.js → useStdoutDimensions.ts} +5 -5
  102. package/README.md +0 -1
  103. package/cjs/index.js +0 -21
  104. package/cjs/src/aiEditor.js +0 -311
  105. package/cjs/src/auth.js +0 -72
  106. package/cjs/src/builder.js +0 -114
  107. package/cjs/src/capacitorApp.js +0 -313
  108. package/cjs/src/commandDecorators/argMeta.js +0 -88
  109. package/cjs/src/commandDecorators/command.js +0 -324
  110. package/cjs/src/commandDecorators/commandMeta.js +0 -30
  111. package/cjs/src/commandDecorators/helpFormatter.js +0 -211
  112. package/cjs/src/commandDecorators/index.js +0 -31
  113. package/cjs/src/commandDecorators/targetMeta.js +0 -57
  114. package/cjs/src/commandDecorators/types.js +0 -15
  115. package/cjs/src/constants.js +0 -46
  116. package/cjs/src/createTunnel.js +0 -49
  117. package/cjs/src/dependencyScanner.js +0 -220
  118. package/cjs/src/executors.js +0 -964
  119. package/cjs/src/extractDeps.js +0 -103
  120. package/cjs/src/fileEditor.js +0 -120
  121. package/cjs/src/getCredentials.js +0 -44
  122. package/cjs/src/getDirname.js +0 -38
  123. package/cjs/src/getModelFileData.js +0 -66
  124. package/cjs/src/getRelatedCnsts.js +0 -260
  125. package/cjs/src/guideline.js +0 -15
  126. package/cjs/src/index.js +0 -65
  127. package/cjs/src/linter.js +0 -238
  128. package/cjs/src/prompter.js +0 -85
  129. package/cjs/src/scanInfo.js +0 -491
  130. package/cjs/src/selectModel.js +0 -46
  131. package/cjs/src/spinner.js +0 -93
  132. package/cjs/src/streamAi.js +0 -62
  133. package/cjs/src/typeChecker.js +0 -207
  134. package/cjs/src/types.js +0 -15
  135. package/cjs/src/uploadRelease.js +0 -112
  136. package/cjs/src/useStdoutDimensions.js +0 -43
  137. package/esm/index.js +0 -1
  138. package/esm/src/aiEditor.js +0 -282
  139. package/esm/src/auth.js +0 -42
  140. package/esm/src/builder.js +0 -81
  141. package/esm/src/commandDecorators/argMeta.js +0 -54
  142. package/esm/src/commandDecorators/command.js +0 -290
  143. package/esm/src/commandDecorators/commandMeta.js +0 -7
  144. package/esm/src/commandDecorators/targetMeta.js +0 -33
  145. package/esm/src/commandDecorators/types.js +0 -0
  146. package/esm/src/constants.js +0 -17
  147. package/esm/src/createTunnel.js +0 -26
  148. package/esm/src/dependencyScanner.js +0 -187
  149. package/esm/src/executors.js +0 -928
  150. package/esm/src/getCredentials.js +0 -11
  151. package/esm/src/getDirname.js +0 -5
  152. package/esm/src/getModelFileData.js +0 -33
  153. package/esm/src/getRelatedCnsts.js +0 -221
  154. package/esm/src/guideline.js +0 -0
  155. package/esm/src/linter.js +0 -205
  156. package/esm/src/prompter.js +0 -51
  157. package/esm/src/scanInfo.js +0 -455
  158. package/esm/src/selectModel.js +0 -13
  159. package/esm/src/typeChecker.js +0 -174
  160. package/esm/src/types.js +0 -0
  161. package/index.d.ts +0 -1
  162. package/src/aiEditor.d.ts +0 -50
  163. package/src/auth.d.ts +0 -9
  164. package/src/builder.d.ts +0 -18
  165. package/src/capacitorApp.d.ts +0 -39
  166. package/src/commandDecorators/argMeta.d.ts +0 -67
  167. package/src/commandDecorators/command.d.ts +0 -2
  168. package/src/commandDecorators/commandMeta.d.ts +0 -2
  169. package/src/commandDecorators/helpFormatter.d.ts +0 -3
  170. package/src/commandDecorators/index.d.ts +0 -6
  171. package/src/commandDecorators/targetMeta.d.ts +0 -19
  172. package/src/commandDecorators/types.d.ts +0 -1
  173. package/src/constants.d.ts +0 -26
  174. package/src/createTunnel.d.ts +0 -8
  175. package/src/dependencyScanner.d.ts +0 -23
  176. package/src/executors.d.ts +0 -296
  177. package/src/extractDeps.d.ts +0 -7
  178. package/src/fileEditor.d.ts +0 -16
  179. package/src/getCredentials.d.ts +0 -12
  180. package/src/getDirname.d.ts +0 -1
  181. package/src/getModelFileData.d.ts +0 -16
  182. package/src/getRelatedCnsts.d.ts +0 -53
  183. package/src/guideline.d.ts +0 -19
  184. package/src/index.d.ts +0 -23
  185. package/src/linter.d.ts +0 -109
  186. package/src/prompter.d.ts +0 -14
  187. package/src/scanInfo.d.ts +0 -82
  188. package/src/selectModel.d.ts +0 -1
  189. package/src/spinner.d.ts +0 -20
  190. package/src/streamAi.d.ts +0 -6
  191. package/src/typeChecker.d.ts +0 -52
  192. package/src/types.d.ts +0 -31
  193. package/src/uploadRelease.d.ts +0 -10
  194. package/src/useStdoutDimensions.d.ts +0 -1
@@ -1,187 +0,0 @@
1
- import * as fs from "fs";
2
- import ignore from "ignore";
3
- import * as path from "path";
4
- import * as ts from "typescript";
5
- class TypeScriptDependencyScanner {
6
- #fileDependencies = /* @__PURE__ */ new Map();
7
- #visitedFiles = /* @__PURE__ */ new Set();
8
- directory;
9
- tsconfig;
10
- rootPackageJson;
11
- ig;
12
- workspaceRoot;
13
- constructor(directory, {
14
- workspaceRoot,
15
- tsconfig,
16
- rootPackageJson,
17
- gitignorePatterns = []
18
- }) {
19
- this.directory = directory;
20
- this.tsconfig = tsconfig;
21
- this.rootPackageJson = rootPackageJson;
22
- this.ig = ignore().add(gitignorePatterns);
23
- this.workspaceRoot = workspaceRoot;
24
- }
25
- async getMonorepoDependencies(projectName) {
26
- const npmSet = new Set(
27
- Object.keys({ ...this.rootPackageJson.dependencies, ...this.rootPackageJson.devDependencies })
28
- );
29
- const pkgPathSet = new Set(
30
- Object.keys(this.tsconfig.compilerOptions.paths ?? {}).filter((path2) => this.tsconfig.compilerOptions.paths?.[path2]?.some((resolve) => resolve.startsWith("pkgs/"))).map((path2) => path2.replace("/*", ""))
31
- );
32
- const libPathSet = new Set(
33
- Object.keys(this.tsconfig.compilerOptions.paths ?? {}).filter((path2) => this.tsconfig.compilerOptions.paths?.[path2]?.some((resolve) => resolve.startsWith("libs/"))).map((path2) => path2.replace("/*", ""))
34
- );
35
- const [npmDepSet, pkgPathDepSet, libPathDepSet] = await this.getImportSets([npmSet, pkgPathSet, libPathSet]);
36
- const pkgDeps = [...pkgPathDepSet].map((path2) => {
37
- const pathSplitLength = path2.split("/").length;
38
- return (this.tsconfig.compilerOptions.paths?.[path2]?.[0] ?? "*").split("/").slice(1, 1 + pathSplitLength).join("/");
39
- });
40
- const libDeps = [...libPathDepSet].map((path2) => {
41
- const pathSplitLength = path2.split("/").length;
42
- return (this.tsconfig.compilerOptions.paths?.[path2]?.[0] ?? "*").split("/").slice(1, 1 + pathSplitLength).join("/");
43
- }).filter((libName) => libName !== projectName);
44
- return { pkgDeps, libDeps, npmDeps: [...npmDepSet] };
45
- }
46
- async getImportSets(depSets) {
47
- const fileDependencies = await this.getDependencies();
48
- const importedDepSets = new Array(depSets.length);
49
- for (let i = 0; i < depSets.length; i++)
50
- importedDepSets[i] = /* @__PURE__ */ new Set();
51
- fileDependencies.forEach((imps) => {
52
- imps.forEach((imp) => {
53
- if (imp.startsWith("."))
54
- return;
55
- const moduleName = imp;
56
- const moduleNameParts = moduleName.split("/");
57
- const subModuleLength = moduleNameParts.length;
58
- for (let i = 0; i < subModuleLength; i++) {
59
- const importName = moduleNameParts.slice(0, i + 1).join("/");
60
- for (let j = 0; j < depSets.length; j++) {
61
- if (depSets[j].has(importName)) {
62
- importedDepSets[j].add(importName);
63
- return;
64
- }
65
- }
66
- }
67
- });
68
- });
69
- return importedDepSets;
70
- }
71
- async getDependencies() {
72
- this.#fileDependencies.clear();
73
- this.#visitedFiles.clear();
74
- const files = await this.#findTypeScriptFiles(this.directory);
75
- for (const file of files)
76
- await this.#analyzeFile(file, this.directory);
77
- return this.#fileDependencies;
78
- }
79
- async #findTypeScriptFiles(directory) {
80
- const files = [];
81
- const processDirectory = async (dir) => {
82
- const entries = await fs.promises.readdir(dir, { withFileTypes: true });
83
- for (const entry of entries) {
84
- const fullPath = path.join(dir, entry.name);
85
- const relativePath = path.relative(this.workspaceRoot, fullPath);
86
- if (this.ig.ignores(relativePath))
87
- continue;
88
- if (entry.isDirectory()) {
89
- if (!["node_modules", "dist", "build", ".git", ".next", "public", "ios", "android"].includes(entry.name))
90
- await processDirectory(fullPath);
91
- } else if (entry.isFile() && (entry.name.endsWith(".ts") || entry.name.endsWith(".tsx")))
92
- files.push(fullPath);
93
- }
94
- };
95
- await processDirectory(directory);
96
- return files;
97
- }
98
- async #analyzeFile(filePath, baseDir) {
99
- if (this.#visitedFiles.has(filePath))
100
- return;
101
- this.#visitedFiles.add(filePath);
102
- try {
103
- const fileContent = await fs.promises.readFile(filePath, "utf-8");
104
- const imports = this.#extractImports(fileContent, filePath);
105
- const resolvedImports = imports.map((importPath) => {
106
- if (importPath.startsWith(".")) {
107
- const resolvedPath = "./" + path.join(path.relative(baseDir, filePath), importPath);
108
- return this.#ensureExtension(resolvedPath);
109
- }
110
- return importPath;
111
- });
112
- const relativePath = path.relative(baseDir, filePath);
113
- this.#fileDependencies.set(relativePath, resolvedImports);
114
- } catch (error) {
115
- }
116
- }
117
- #ensureExtension(filePath) {
118
- if (fs.existsSync(`${filePath}.ts`))
119
- return `${filePath}.ts`;
120
- else if (fs.existsSync(`${filePath}.tsx`))
121
- return `${filePath}.tsx`;
122
- else if (fs.existsSync(filePath))
123
- return filePath;
124
- return `${filePath}.ts`;
125
- }
126
- #extractImports(source, filePath) {
127
- const imports = [];
128
- const sourceFile = ts.createSourceFile(filePath, source, ts.ScriptTarget.Latest, true);
129
- const visit = (node) => {
130
- if (ts.isImportDeclaration(node)) {
131
- const moduleSpecifier = node.moduleSpecifier;
132
- if (ts.isStringLiteral(moduleSpecifier))
133
- imports.push(moduleSpecifier.text);
134
- }
135
- if (ts.isCallExpression(node)) {
136
- if (node.expression.kind === ts.SyntaxKind.ImportKeyword) {
137
- if (node.arguments.length > 0) {
138
- const arg = node.arguments[0];
139
- if (ts.isStringLiteral(arg))
140
- imports.push(arg.text);
141
- }
142
- }
143
- if (ts.isArrowFunction(node.expression)) {
144
- const body = node.expression.body;
145
- if (ts.isCallExpression(body) && body.expression.kind === ts.SyntaxKind.ImportKeyword) {
146
- if (body.arguments.length > 0) {
147
- const arg = body.arguments[0];
148
- if (ts.isStringLiteral(arg))
149
- imports.push(arg.text);
150
- }
151
- }
152
- }
153
- }
154
- ts.forEachChild(node, visit);
155
- };
156
- visit(sourceFile);
157
- return [...new Set(imports)];
158
- }
159
- generateDependencyGraph() {
160
- let graph = "Dependency Graph:\n\n";
161
- for (const [file, imports] of this.#fileDependencies.entries()) {
162
- graph += `${file}:
163
- `;
164
- const projectImports = imports.filter((i) => !i.startsWith("react") && !i.startsWith("@"));
165
- const externalImports = imports.filter((i) => i.startsWith("react") || i.startsWith("@"));
166
- if (projectImports.length > 0) {
167
- graph += " Project dependencies:\n";
168
- projectImports.forEach((imp) => {
169
- graph += ` \u2192 ${imp}
170
- `;
171
- });
172
- }
173
- if (externalImports.length > 0) {
174
- graph += " External dependencies:\n";
175
- externalImports.forEach((imp) => {
176
- graph += ` \u2192 ${imp}
177
- `;
178
- });
179
- }
180
- graph += "\n";
181
- }
182
- return graph;
183
- }
184
- }
185
- export {
186
- TypeScriptDependencyScanner
187
- };