@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.
- package/aiEditor.ts +304 -0
- package/akanApp/akanApp.host.ts +393 -0
- package/akanApp/index.ts +1 -0
- package/akanConfig/akanConfig.test.ts +236 -0
- package/akanConfig/akanConfig.ts +384 -0
- package/akanConfig/index.ts +2 -0
- package/akanConfig/types.ts +23 -0
- package/applicationBuildReporter.ts +69 -0
- package/applicationBuildRunner.ts +302 -0
- package/applicationReleasePackager.ts +206 -0
- package/artifact/implicitRootLayout.ts +155 -0
- package/artifact/index.ts +1 -0
- package/artifact/routeSeedIndex.test.ts +98 -0
- package/artifact/routeSeedIndex.ts +130 -0
- package/auth.ts +41 -0
- package/builder.ts +164 -0
- package/capacitor.base.config.ts +88 -0
- package/capacitorApp.ts +440 -0
- package/commandDecorators/argMeta.ts +102 -0
- package/commandDecorators/command.ts +343 -0
- package/commandDecorators/commandBuilder.ts +224 -0
- package/commandDecorators/commandDecorators.test.ts +212 -0
- package/commandDecorators/commandMeta.ts +7 -0
- package/commandDecorators/dependencyBuilder.ts +100 -0
- package/{esm/src/commandDecorators/helpFormatter.js → commandDecorators/helpFormatter.ts} +100 -47
- package/{esm/src/commandDecorators/index.js → commandDecorators/index.ts} +4 -2
- package/commandDecorators/targetMeta.ts +31 -0
- package/commandDecorators/types.ts +10 -0
- package/constants.ts +25 -0
- package/createTunnel.ts +36 -0
- package/dependencyScanner.ts +357 -0
- package/devkitUtils.test.ts +259 -0
- package/executors.test.ts +315 -0
- package/executors.ts +1390 -0
- package/{esm/src/extractDeps.js → extractDeps.ts} +26 -20
- package/{esm/src/fileEditor.js → fileEditor.ts} +51 -32
- package/fileSys.ts +39 -0
- package/frontendBuild/allRoutesBuilder.ts +103 -0
- package/frontendBuild/buildRouteClient.test.ts +190 -0
- package/frontendBuild/clientBuildTypes.ts +114 -0
- package/frontendBuild/clientEntriesBundler.ts +303 -0
- package/frontendBuild/clientEntryDiscovery.ts +199 -0
- package/frontendBuild/csrArtifactBuilder.ts +237 -0
- package/frontendBuild/cssCompiler.ts +286 -0
- package/frontendBuild/cssImportResolver.ts +116 -0
- package/frontendBuild/fontOptimizer.ts +427 -0
- package/frontendBuild/frontendBuild.test.ts +204 -0
- package/frontendBuild/hmrChangeClassifier.ts +28 -0
- package/frontendBuild/hmrWatcher.ts +102 -0
- package/frontendBuild/index.ts +18 -0
- package/frontendBuild/pagesBundleBuilder.ts +137 -0
- package/frontendBuild/pagesEntrySourceGenerator.ts +37 -0
- package/frontendBuild/precompressArtifacts.ts +59 -0
- package/frontendBuild/routeClientBuilder.ts +290 -0
- package/frontendBuild/routesManifestArtifactSerializer.ts +62 -0
- package/frontendBuild/ssrBaseArtifactBuilder.ts +139 -0
- package/frontendBuild/vendorSpecifiers.ts +16 -0
- package/frontendBuild/watchRootResolver.ts +28 -0
- package/getCredentials.ts +19 -0
- package/getDirname.ts +3 -0
- package/getModelFileData.ts +59 -0
- package/getRelatedCnsts.ts +313 -0
- package/guideline.ts +19 -0
- package/incrementalBuilder/incrementalBuilder.host.test.ts +51 -0
- package/incrementalBuilder/incrementalBuilder.host.ts +152 -0
- package/incrementalBuilder/incrementalBuilder.proc.ts +331 -0
- package/incrementalBuilder/index.ts +1 -0
- package/{esm/src/index.js → index.ts} +28 -15
- package/lint/no-deep-internal-import.grit +25 -0
- package/lint/no-import-client-functions.grit +32 -0
- package/lint/no-import-external-library.grit +21 -0
- package/lint/no-js-private-class-method.grit +42 -0
- package/lint/no-use-client-in-server.grit +7 -0
- package/lint/non-scalar-props-restricted.grit +13 -0
- package/linter.ts +271 -0
- package/mobile/index.ts +1 -0
- package/mobile/mobileTarget.test.ts +53 -0
- package/mobile/mobileTarget.ts +88 -0
- package/package.json +48 -31
- package/prompter.ts +72 -0
- package/scanInfo.ts +606 -0
- package/selectModel.ts +11 -0
- package/{esm/src/spinner.js → spinner.ts} +22 -28
- package/{esm/src/capacitorApp.js → src/capacitorApp.ts} +82 -81
- package/sshTunnel.ts +152 -0
- package/{esm/src/streamAi.js → streamAi.ts} +18 -12
- package/transforms/barrelAnalyzer.ts +278 -0
- package/transforms/barrelImportsPlugin.ts +504 -0
- package/transforms/externalizeFrameworkPlugin.ts +185 -0
- package/transforms/index.ts +5 -0
- package/transforms/rscUseClientTransform.ts +59 -0
- package/transforms/transforms.test.ts +208 -0
- package/transforms/useClientBundlePlugin.ts +47 -0
- package/tsconfig.json +37 -0
- package/typeChecker.ts +264 -0
- package/types.ts +44 -0
- package/ui/MultiScrollList.tsx +242 -0
- package/ui/ScrollList.tsx +107 -0
- package/ui/index.ts +2 -0
- package/{esm/src/uploadRelease.js → uploadRelease.ts} +50 -34
- package/{esm/src/useStdoutDimensions.js → useStdoutDimensions.ts} +5 -5
- package/README.md +0 -1
- package/cjs/index.js +0 -21
- package/cjs/src/aiEditor.js +0 -311
- package/cjs/src/auth.js +0 -72
- package/cjs/src/builder.js +0 -114
- package/cjs/src/capacitorApp.js +0 -313
- package/cjs/src/commandDecorators/argMeta.js +0 -88
- package/cjs/src/commandDecorators/command.js +0 -324
- package/cjs/src/commandDecorators/commandMeta.js +0 -30
- package/cjs/src/commandDecorators/helpFormatter.js +0 -211
- package/cjs/src/commandDecorators/index.js +0 -31
- package/cjs/src/commandDecorators/targetMeta.js +0 -57
- package/cjs/src/commandDecorators/types.js +0 -15
- package/cjs/src/constants.js +0 -46
- package/cjs/src/createTunnel.js +0 -49
- package/cjs/src/dependencyScanner.js +0 -220
- package/cjs/src/executors.js +0 -964
- package/cjs/src/extractDeps.js +0 -103
- package/cjs/src/fileEditor.js +0 -120
- package/cjs/src/getCredentials.js +0 -44
- package/cjs/src/getDirname.js +0 -38
- package/cjs/src/getModelFileData.js +0 -66
- package/cjs/src/getRelatedCnsts.js +0 -260
- package/cjs/src/guideline.js +0 -15
- package/cjs/src/index.js +0 -65
- package/cjs/src/linter.js +0 -238
- package/cjs/src/prompter.js +0 -85
- package/cjs/src/scanInfo.js +0 -491
- package/cjs/src/selectModel.js +0 -46
- package/cjs/src/spinner.js +0 -93
- package/cjs/src/streamAi.js +0 -62
- package/cjs/src/typeChecker.js +0 -207
- package/cjs/src/types.js +0 -15
- package/cjs/src/uploadRelease.js +0 -112
- package/cjs/src/useStdoutDimensions.js +0 -43
- package/esm/index.js +0 -1
- package/esm/src/aiEditor.js +0 -282
- package/esm/src/auth.js +0 -42
- package/esm/src/builder.js +0 -81
- package/esm/src/commandDecorators/argMeta.js +0 -54
- package/esm/src/commandDecorators/command.js +0 -290
- package/esm/src/commandDecorators/commandMeta.js +0 -7
- package/esm/src/commandDecorators/targetMeta.js +0 -33
- package/esm/src/commandDecorators/types.js +0 -0
- package/esm/src/constants.js +0 -17
- package/esm/src/createTunnel.js +0 -26
- package/esm/src/dependencyScanner.js +0 -187
- package/esm/src/executors.js +0 -928
- package/esm/src/getCredentials.js +0 -11
- package/esm/src/getDirname.js +0 -5
- package/esm/src/getModelFileData.js +0 -33
- package/esm/src/getRelatedCnsts.js +0 -221
- package/esm/src/guideline.js +0 -0
- package/esm/src/linter.js +0 -205
- package/esm/src/prompter.js +0 -51
- package/esm/src/scanInfo.js +0 -455
- package/esm/src/selectModel.js +0 -13
- package/esm/src/typeChecker.js +0 -174
- package/esm/src/types.js +0 -0
- package/index.d.ts +0 -1
- package/src/aiEditor.d.ts +0 -50
- package/src/auth.d.ts +0 -9
- package/src/builder.d.ts +0 -18
- package/src/capacitorApp.d.ts +0 -39
- package/src/commandDecorators/argMeta.d.ts +0 -67
- package/src/commandDecorators/command.d.ts +0 -2
- package/src/commandDecorators/commandMeta.d.ts +0 -2
- package/src/commandDecorators/helpFormatter.d.ts +0 -3
- package/src/commandDecorators/index.d.ts +0 -6
- package/src/commandDecorators/targetMeta.d.ts +0 -19
- package/src/commandDecorators/types.d.ts +0 -1
- package/src/constants.d.ts +0 -26
- package/src/createTunnel.d.ts +0 -8
- package/src/dependencyScanner.d.ts +0 -23
- package/src/executors.d.ts +0 -296
- package/src/extractDeps.d.ts +0 -7
- package/src/fileEditor.d.ts +0 -16
- package/src/getCredentials.d.ts +0 -12
- package/src/getDirname.d.ts +0 -1
- package/src/getModelFileData.d.ts +0 -16
- package/src/getRelatedCnsts.d.ts +0 -53
- package/src/guideline.d.ts +0 -19
- package/src/index.d.ts +0 -23
- package/src/linter.d.ts +0 -109
- package/src/prompter.d.ts +0 -14
- package/src/scanInfo.d.ts +0 -82
- package/src/selectModel.d.ts +0 -1
- package/src/spinner.d.ts +0 -20
- package/src/streamAi.d.ts +0 -6
- package/src/typeChecker.d.ts +0 -52
- package/src/types.d.ts +0 -31
- package/src/uploadRelease.d.ts +0 -10
- 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
|
-
};
|