@akanjs/devkit 1.0.20 → 2.1.0-rc.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.
Files changed (195) hide show
  1. package/README.ko.md +65 -0
  2. package/README.md +62 -6
  3. package/aiEditor.ts +304 -0
  4. package/akanApp/akanApp.host.ts +393 -0
  5. package/akanApp/index.ts +1 -0
  6. package/akanConfig/akanConfig.test.ts +236 -0
  7. package/akanConfig/akanConfig.ts +384 -0
  8. package/akanConfig/index.ts +2 -0
  9. package/akanConfig/types.ts +23 -0
  10. package/applicationBuildReporter.ts +69 -0
  11. package/applicationBuildRunner.ts +302 -0
  12. package/applicationReleasePackager.ts +206 -0
  13. package/artifact/implicitRootLayout.ts +155 -0
  14. package/artifact/index.ts +1 -0
  15. package/artifact/routeSeedIndex.test.ts +98 -0
  16. package/artifact/routeSeedIndex.ts +130 -0
  17. package/auth.ts +41 -0
  18. package/builder.ts +164 -0
  19. package/capacitor.base.config.ts +88 -0
  20. package/capacitorApp.ts +440 -0
  21. package/commandDecorators/argMeta.ts +102 -0
  22. package/commandDecorators/command.ts +351 -0
  23. package/commandDecorators/commandBuilder.ts +224 -0
  24. package/commandDecorators/commandDecorators.test.ts +212 -0
  25. package/commandDecorators/commandMeta.ts +7 -0
  26. package/commandDecorators/dependencyBuilder.ts +100 -0
  27. package/{esm/src/commandDecorators/helpFormatter.js → commandDecorators/helpFormatter.ts} +100 -47
  28. package/{esm/src/commandDecorators/index.js → commandDecorators/index.ts} +4 -2
  29. package/commandDecorators/targetMeta.ts +31 -0
  30. package/commandDecorators/types.ts +10 -0
  31. package/constants.ts +25 -0
  32. package/createTunnel.ts +36 -0
  33. package/dependencyScanner.ts +357 -0
  34. package/devkitUtils.test.ts +259 -0
  35. package/executors.test.ts +315 -0
  36. package/executors.ts +1390 -0
  37. package/{esm/src/extractDeps.js → extractDeps.ts} +26 -20
  38. package/{esm/src/fileEditor.js → fileEditor.ts} +51 -32
  39. package/fileSys.ts +39 -0
  40. package/frontendBuild/allRoutesBuilder.ts +103 -0
  41. package/frontendBuild/buildRouteClient.test.ts +190 -0
  42. package/frontendBuild/clientBuildTypes.ts +114 -0
  43. package/frontendBuild/clientEntriesBundler.ts +303 -0
  44. package/frontendBuild/clientEntryDiscovery.ts +199 -0
  45. package/frontendBuild/csrArtifactBuilder.ts +237 -0
  46. package/frontendBuild/cssCompiler.ts +286 -0
  47. package/frontendBuild/cssImportResolver.ts +116 -0
  48. package/frontendBuild/fontOptimizer.ts +427 -0
  49. package/frontendBuild/frontendBuild.test.ts +204 -0
  50. package/frontendBuild/hmrChangeClassifier.ts +28 -0
  51. package/frontendBuild/hmrWatcher.ts +102 -0
  52. package/frontendBuild/index.ts +18 -0
  53. package/frontendBuild/pagesBundleBuilder.ts +137 -0
  54. package/frontendBuild/pagesEntrySourceGenerator.ts +37 -0
  55. package/frontendBuild/precompressArtifacts.ts +59 -0
  56. package/frontendBuild/routeClientBuilder.ts +290 -0
  57. package/frontendBuild/routesManifestArtifactSerializer.ts +62 -0
  58. package/frontendBuild/ssrBaseArtifactBuilder.ts +139 -0
  59. package/frontendBuild/vendorSpecifiers.ts +16 -0
  60. package/frontendBuild/watchRootResolver.ts +28 -0
  61. package/getCredentials.ts +19 -0
  62. package/getDirname.ts +3 -0
  63. package/getModelFileData.ts +59 -0
  64. package/getRelatedCnsts.ts +313 -0
  65. package/guideline.ts +19 -0
  66. package/incrementalBuilder/incrementalBuilder.host.test.ts +51 -0
  67. package/incrementalBuilder/incrementalBuilder.host.ts +152 -0
  68. package/incrementalBuilder/incrementalBuilder.proc.ts +331 -0
  69. package/incrementalBuilder/index.ts +1 -0
  70. package/{esm/src/index.js → index.ts} +28 -15
  71. package/lint/no-deep-internal-import.grit +25 -0
  72. package/lint/no-import-client-functions.grit +32 -0
  73. package/lint/no-import-external-library.grit +21 -0
  74. package/lint/no-js-private-class-method.grit +42 -0
  75. package/lint/no-use-client-in-server.grit +7 -0
  76. package/lint/non-scalar-props-restricted.grit +13 -0
  77. package/linter.ts +271 -0
  78. package/mobile/index.ts +1 -0
  79. package/mobile/mobileTarget.test.ts +53 -0
  80. package/mobile/mobileTarget.ts +88 -0
  81. package/package.json +48 -31
  82. package/prompter.ts +72 -0
  83. package/scanInfo.ts +606 -0
  84. package/selectModel.ts +11 -0
  85. package/{esm/src/spinner.js → spinner.ts} +22 -28
  86. package/{esm/src/capacitorApp.js → src/capacitorApp.ts} +82 -81
  87. package/sshTunnel.ts +152 -0
  88. package/{esm/src/streamAi.js → streamAi.ts} +18 -12
  89. package/transforms/barrelAnalyzer.ts +278 -0
  90. package/transforms/barrelImportsPlugin.ts +504 -0
  91. package/transforms/externalizeFrameworkPlugin.ts +185 -0
  92. package/transforms/index.ts +5 -0
  93. package/transforms/rscUseClientTransform.ts +59 -0
  94. package/transforms/transforms.test.ts +208 -0
  95. package/transforms/useClientBundlePlugin.ts +47 -0
  96. package/tsconfig.json +37 -0
  97. package/typeChecker.ts +264 -0
  98. package/types.ts +44 -0
  99. package/ui/MultiScrollList.tsx +242 -0
  100. package/ui/ScrollList.tsx +107 -0
  101. package/ui/index.ts +2 -0
  102. package/{esm/src/uploadRelease.js → uploadRelease.ts} +50 -34
  103. package/{esm/src/useStdoutDimensions.js → useStdoutDimensions.ts} +5 -5
  104. package/cjs/index.js +0 -21
  105. package/cjs/src/aiEditor.js +0 -311
  106. package/cjs/src/auth.js +0 -72
  107. package/cjs/src/builder.js +0 -114
  108. package/cjs/src/capacitorApp.js +0 -313
  109. package/cjs/src/commandDecorators/argMeta.js +0 -88
  110. package/cjs/src/commandDecorators/command.js +0 -324
  111. package/cjs/src/commandDecorators/commandMeta.js +0 -30
  112. package/cjs/src/commandDecorators/helpFormatter.js +0 -211
  113. package/cjs/src/commandDecorators/index.js +0 -31
  114. package/cjs/src/commandDecorators/targetMeta.js +0 -57
  115. package/cjs/src/commandDecorators/types.js +0 -15
  116. package/cjs/src/constants.js +0 -46
  117. package/cjs/src/createTunnel.js +0 -49
  118. package/cjs/src/dependencyScanner.js +0 -220
  119. package/cjs/src/executors.js +0 -964
  120. package/cjs/src/extractDeps.js +0 -103
  121. package/cjs/src/fileEditor.js +0 -120
  122. package/cjs/src/getCredentials.js +0 -44
  123. package/cjs/src/getDirname.js +0 -38
  124. package/cjs/src/getModelFileData.js +0 -66
  125. package/cjs/src/getRelatedCnsts.js +0 -260
  126. package/cjs/src/guideline.js +0 -15
  127. package/cjs/src/index.js +0 -65
  128. package/cjs/src/linter.js +0 -238
  129. package/cjs/src/prompter.js +0 -85
  130. package/cjs/src/scanInfo.js +0 -491
  131. package/cjs/src/selectModel.js +0 -46
  132. package/cjs/src/spinner.js +0 -93
  133. package/cjs/src/streamAi.js +0 -62
  134. package/cjs/src/typeChecker.js +0 -207
  135. package/cjs/src/types.js +0 -15
  136. package/cjs/src/uploadRelease.js +0 -112
  137. package/cjs/src/useStdoutDimensions.js +0 -43
  138. package/esm/index.js +0 -1
  139. package/esm/src/aiEditor.js +0 -282
  140. package/esm/src/auth.js +0 -42
  141. package/esm/src/builder.js +0 -81
  142. package/esm/src/commandDecorators/argMeta.js +0 -54
  143. package/esm/src/commandDecorators/command.js +0 -290
  144. package/esm/src/commandDecorators/commandMeta.js +0 -7
  145. package/esm/src/commandDecorators/targetMeta.js +0 -33
  146. package/esm/src/commandDecorators/types.js +0 -0
  147. package/esm/src/constants.js +0 -17
  148. package/esm/src/createTunnel.js +0 -26
  149. package/esm/src/dependencyScanner.js +0 -187
  150. package/esm/src/executors.js +0 -928
  151. package/esm/src/getCredentials.js +0 -11
  152. package/esm/src/getDirname.js +0 -5
  153. package/esm/src/getModelFileData.js +0 -33
  154. package/esm/src/getRelatedCnsts.js +0 -221
  155. package/esm/src/guideline.js +0 -0
  156. package/esm/src/linter.js +0 -205
  157. package/esm/src/prompter.js +0 -51
  158. package/esm/src/scanInfo.js +0 -455
  159. package/esm/src/selectModel.js +0 -13
  160. package/esm/src/typeChecker.js +0 -174
  161. package/esm/src/types.js +0 -0
  162. package/index.d.ts +0 -1
  163. package/src/aiEditor.d.ts +0 -50
  164. package/src/auth.d.ts +0 -9
  165. package/src/builder.d.ts +0 -18
  166. package/src/capacitorApp.d.ts +0 -39
  167. package/src/commandDecorators/argMeta.d.ts +0 -67
  168. package/src/commandDecorators/command.d.ts +0 -2
  169. package/src/commandDecorators/commandMeta.d.ts +0 -2
  170. package/src/commandDecorators/helpFormatter.d.ts +0 -3
  171. package/src/commandDecorators/index.d.ts +0 -6
  172. package/src/commandDecorators/targetMeta.d.ts +0 -19
  173. package/src/commandDecorators/types.d.ts +0 -1
  174. package/src/constants.d.ts +0 -26
  175. package/src/createTunnel.d.ts +0 -8
  176. package/src/dependencyScanner.d.ts +0 -23
  177. package/src/executors.d.ts +0 -296
  178. package/src/extractDeps.d.ts +0 -7
  179. package/src/fileEditor.d.ts +0 -16
  180. package/src/getCredentials.d.ts +0 -12
  181. package/src/getDirname.d.ts +0 -1
  182. package/src/getModelFileData.d.ts +0 -16
  183. package/src/getRelatedCnsts.d.ts +0 -53
  184. package/src/guideline.d.ts +0 -19
  185. package/src/index.d.ts +0 -23
  186. package/src/linter.d.ts +0 -109
  187. package/src/prompter.d.ts +0 -14
  188. package/src/scanInfo.d.ts +0 -82
  189. package/src/selectModel.d.ts +0 -1
  190. package/src/spinner.d.ts +0 -20
  191. package/src/streamAi.d.ts +0 -6
  192. package/src/typeChecker.d.ts +0 -52
  193. package/src/types.d.ts +0 -31
  194. package/src/uploadRelease.d.ts +0 -10
  195. 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
- };