@akanjs/devkit 0.0.43 → 0.0.45
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/index.js +1862 -1807
- package/package.json +1 -1
- package/src/baseDevEnv.d.ts +1 -1
package/index.js
CHANGED
|
@@ -1,696 +1,752 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
29
|
-
mod
|
|
30
|
-
));
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
31
28
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
29
|
+
// pkgs/@akanjs/devkit/index.ts
|
|
30
|
+
var devkit_exports = {};
|
|
31
|
+
__export(devkit_exports, {
|
|
32
|
+
App: () => App,
|
|
33
|
+
AppExecutor: () => AppExecutor,
|
|
34
|
+
CapacitorApp: () => CapacitorApp,
|
|
35
|
+
Commands: () => Commands,
|
|
36
|
+
DistAppExecutor: () => DistAppExecutor,
|
|
37
|
+
DistLibExecutor: () => DistLibExecutor,
|
|
38
|
+
DistPkgExecutor: () => DistPkgExecutor,
|
|
39
|
+
Executor: () => Executor,
|
|
40
|
+
Lib: () => Lib,
|
|
41
|
+
LibExecutor: () => LibExecutor,
|
|
42
|
+
Option: () => Option,
|
|
43
|
+
Pkg: () => Pkg,
|
|
44
|
+
PkgExecutor: () => PkgExecutor,
|
|
45
|
+
Sys: () => Sys,
|
|
46
|
+
SysExecutor: () => SysExecutor,
|
|
47
|
+
Target: () => Target,
|
|
48
|
+
TypeScriptDependencyScanner: () => TypeScriptDependencyScanner,
|
|
49
|
+
Workspace: () => Workspace,
|
|
50
|
+
WorkspaceExecutor: () => WorkspaceExecutor,
|
|
51
|
+
akanCloudBackendUrl: () => akanCloudBackendUrl,
|
|
52
|
+
akanCloudClientUrl: () => akanCloudClientUrl,
|
|
53
|
+
akanCloudHost: () => akanCloudHost,
|
|
54
|
+
argTypes: () => argTypes,
|
|
55
|
+
basePath: () => basePath,
|
|
56
|
+
configPath: () => configPath,
|
|
57
|
+
createTunnel: () => createTunnel,
|
|
58
|
+
defaultAkanGlobalConfig: () => defaultAkanGlobalConfig,
|
|
59
|
+
defaultHostConfig: () => defaultHostConfig,
|
|
60
|
+
extractDependencies: () => extractDependencies,
|
|
61
|
+
getAkanGlobalConfig: () => getAkanGlobalConfig,
|
|
62
|
+
getArgMetas: () => getArgMetas,
|
|
63
|
+
getBaseDevEnv: () => getBaseDevEnv,
|
|
64
|
+
getCredentials: () => getCredentials,
|
|
65
|
+
getDependencies: () => getDependencies,
|
|
66
|
+
getHostConfig: () => getHostConfig,
|
|
67
|
+
getModelFileData: () => getModelFileData,
|
|
68
|
+
getRelatedCnsts: () => getRelatedCnsts,
|
|
69
|
+
getSelf: () => getSelf,
|
|
70
|
+
getSshTunnelOptions: () => getSshTunnelOptions,
|
|
71
|
+
getTargetMetas: () => getTargetMetas,
|
|
72
|
+
installExternalLib: () => installExternalLib,
|
|
73
|
+
internalArgTypes: () => internalArgTypes,
|
|
74
|
+
runCommands: () => runCommands,
|
|
75
|
+
selectModel: () => selectModel,
|
|
76
|
+
setAkanGlobalConfig: () => setAkanGlobalConfig,
|
|
77
|
+
setHostConfig: () => setHostConfig,
|
|
78
|
+
streamAi: () => streamAi,
|
|
79
|
+
uploadRelease: () => uploadRelease
|
|
80
|
+
});
|
|
81
|
+
module.exports = __toCommonJS(devkit_exports);
|
|
82
|
+
|
|
83
|
+
// pkgs/@akanjs/devkit/src/baseDevEnv.ts
|
|
84
|
+
var getBaseDevEnv = () => {
|
|
85
|
+
const appName = process.env.NEXT_PUBLIC_APP_NAME;
|
|
86
|
+
const repoName = process.env.NEXT_PUBLIC_REPO_NAME;
|
|
35
87
|
if (!repoName)
|
|
36
88
|
throw new Error("NEXT_PUBLIC_REPO_NAME is not set");
|
|
37
|
-
|
|
89
|
+
const serveDomain = process.env.NEXT_PUBLIC_SERVE_DOMAIN;
|
|
38
90
|
if (!serveDomain)
|
|
39
91
|
throw new Error("NEXT_PUBLIC_SERVE_DOMAIN is not set");
|
|
40
|
-
|
|
92
|
+
const env = process.env.NEXT_PUBLIC_ENV ?? "debug";
|
|
41
93
|
if (!env)
|
|
42
94
|
throw new Error("NEXT_PUBLIC_ENV is not set");
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
95
|
+
return { ...appName ? { appName } : {}, repoName, serveDomain, env };
|
|
96
|
+
};
|
|
97
|
+
var getSshTunnelOptions = (appName, environment) => {
|
|
98
|
+
const { serveDomain, repoName } = getBaseDevEnv();
|
|
99
|
+
return {
|
|
100
|
+
host: `${appName}-${environment}.${serveDomain}`,
|
|
46
101
|
port: process.env.SSU_TUNNEL_PORT ? parseInt(process.env.SSU_TUNNEL_PORT) : 32767,
|
|
47
102
|
username: process.env.SSU_TUNNEL_USERNAME ?? "root",
|
|
48
103
|
password: process.env.SSU_TUNNEL_PASSWORD ?? repoName
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
// pkgs/@akanjs/devkit/src/createTunnel.ts
|
|
52
|
-
var import_tunnel_ssh = __require("tunnel-ssh");
|
|
53
|
-
var createTunnel = async ({ appName: appName2, environment, port = 27017 }) => {
|
|
54
|
-
const tunnelOptions = { autoClose: true, reconnectOnError: true };
|
|
55
|
-
const sshOptions = getSshTunnelOptions(appName2, environment);
|
|
56
|
-
const serverOptions = { port };
|
|
57
|
-
const forwardOptions = {
|
|
58
|
-
srcAddr: "0.0.0.0",
|
|
59
|
-
srcPort: port,
|
|
60
|
-
dstAddr: `mongo-0.mongo-svc.${appName2}-${environment}`,
|
|
61
|
-
dstPort: 27017
|
|
62
|
-
};
|
|
63
|
-
const [server, client] = await (0, import_tunnel_ssh.createTunnel)(tunnelOptions, serverOptions, sshOptions, forwardOptions);
|
|
64
|
-
return `localhost:${port}`;
|
|
65
104
|
};
|
|
105
|
+
};
|
|
66
106
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
107
|
+
// pkgs/@akanjs/devkit/src/createTunnel.ts
|
|
108
|
+
var import_tunnel_ssh = require("tunnel-ssh");
|
|
109
|
+
var createTunnel = async ({ appName, environment, port = 27017 }) => {
|
|
110
|
+
const tunnelOptions = { autoClose: true, reconnectOnError: true };
|
|
111
|
+
const sshOptions = getSshTunnelOptions(appName, environment);
|
|
112
|
+
const serverOptions = { port };
|
|
113
|
+
const forwardOptions = {
|
|
114
|
+
srcAddr: "0.0.0.0",
|
|
115
|
+
srcPort: port,
|
|
116
|
+
dstAddr: `mongo-0.mongo-svc.${appName}-${environment}`,
|
|
117
|
+
dstPort: 27017
|
|
75
118
|
};
|
|
119
|
+
const [server, client] = await (0, import_tunnel_ssh.createTunnel)(tunnelOptions, serverOptions, sshOptions, forwardOptions);
|
|
120
|
+
return `localhost:${port}`;
|
|
121
|
+
};
|
|
76
122
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
123
|
+
// pkgs/@akanjs/devkit/src/getCredentials.ts
|
|
124
|
+
var import_fs = __toESM(require("fs"));
|
|
125
|
+
var import_js_yaml = __toESM(require("js-yaml"));
|
|
126
|
+
var getCredentials = (app, environment) => {
|
|
127
|
+
const secret = import_js_yaml.default.load(
|
|
128
|
+
import_fs.default.readFileSync(`${app.workspace.workspaceRoot}/infra/app/values/${app.name}-secret.yaml`, "utf-8")
|
|
129
|
+
);
|
|
130
|
+
return secret[environment];
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
// pkgs/@akanjs/devkit/src/getDependencies.ts
|
|
134
|
+
var import_devkit = require("@nx/devkit");
|
|
135
|
+
var addLibDepSet = (depName, { libDepSet, npmDepSet, dependencies }) => {
|
|
136
|
+
const deps = dependencies[depName];
|
|
137
|
+
if (!deps)
|
|
138
|
+
throw new Error(`No dependencies found for project or library ${depName}`);
|
|
139
|
+
for (const dep of deps) {
|
|
140
|
+
if (dep.target.startsWith("npm:"))
|
|
141
|
+
npmDepSet.add(dep.target);
|
|
142
|
+
else if (libDepSet.has(dep.target))
|
|
143
|
+
continue;
|
|
144
|
+
else {
|
|
145
|
+
libDepSet.add(dep.target);
|
|
146
|
+
addLibDepSet(dep.target, { libDepSet, npmDepSet, dependencies });
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
var getDependencies = async (projectName) => {
|
|
151
|
+
const graph = await (0, import_devkit.createProjectGraphAsync)();
|
|
152
|
+
const [libDepSet, npmDepSet] = [/* @__PURE__ */ new Set(), /* @__PURE__ */ new Set()];
|
|
153
|
+
const dependencies = graph.dependencies;
|
|
154
|
+
const projectDeps = dependencies[projectName];
|
|
155
|
+
if (!projectDeps)
|
|
156
|
+
throw new Error(`No dependencies found for project ${projectName}`);
|
|
157
|
+
addLibDepSet(projectName, { libDepSet, npmDepSet, dependencies });
|
|
158
|
+
return {
|
|
159
|
+
libDeps: [...libDepSet.values()],
|
|
160
|
+
npmDeps: [...npmDepSet.values()].map((depName) => depName.replace("npm:", ""))
|
|
106
161
|
};
|
|
162
|
+
};
|
|
107
163
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
164
|
+
// pkgs/@akanjs/devkit/src/uploadRelease.ts
|
|
165
|
+
var import_axios = __toESM(require("axios"));
|
|
166
|
+
var import_form_data = __toESM(require("form-data"));
|
|
167
|
+
var import_fs2 = __toESM(require("fs"));
|
|
168
|
+
var uploadRelease = async (projectName, {
|
|
169
|
+
workspaceRoot,
|
|
170
|
+
environment,
|
|
171
|
+
buildNum,
|
|
172
|
+
platformVersion,
|
|
173
|
+
local
|
|
174
|
+
}) => {
|
|
175
|
+
const basePath2 = local ? "http://localhost:8080/backend" : "https://akasys.akamir.com/backend";
|
|
176
|
+
const buildPath = `${workspaceRoot}/releases/builds/${projectName}-release.tar.gz`;
|
|
177
|
+
const appBuildPath = `${workspaceRoot}/releases/builds/${projectName}-appBuild.zip`;
|
|
178
|
+
const sourcePath = `${workspaceRoot}/releases/sources/${projectName}-source.tar.gz`;
|
|
179
|
+
const formData = new import_form_data.default();
|
|
180
|
+
const build = import_fs2.default.readFileSync(buildPath);
|
|
181
|
+
const source = import_fs2.default.readFileSync(sourcePath);
|
|
182
|
+
const appBuild = import_fs2.default.readFileSync(appBuildPath);
|
|
183
|
+
const buildStat = import_fs2.default.statSync(buildPath);
|
|
184
|
+
const sourceStat = import_fs2.default.statSync(sourcePath);
|
|
185
|
+
const appBuildStat = import_fs2.default.statSync(appBuildPath);
|
|
186
|
+
formData.append("files", build, `${projectName}-release.tar.gz`);
|
|
187
|
+
formData.append("files", source, `${projectName}-source.tar.gz`);
|
|
188
|
+
formData.append("files", appBuild, `${projectName}-appBuild.zip`);
|
|
189
|
+
formData.append(
|
|
190
|
+
"metas",
|
|
191
|
+
JSON.stringify([
|
|
192
|
+
{ lastModifiedAt: buildStat.mtime, size: buildStat.size },
|
|
193
|
+
{ lastModifiedAt: sourceStat.mtime, size: sourceStat.size },
|
|
194
|
+
{ lastModifiedAt: appBuildStat.mtime, size: appBuildStat.size }
|
|
195
|
+
])
|
|
196
|
+
);
|
|
197
|
+
formData.append("type", "release");
|
|
198
|
+
try {
|
|
199
|
+
const [buildFile, sourceFile, appBuildFile] = (await import_axios.default.post(`${basePath2}/file/addFilesRestApi`, formData)).data;
|
|
200
|
+
const major = platformVersion ? parseInt(platformVersion.split(".")[0]) : 1;
|
|
201
|
+
const minor = platformVersion ? parseInt(platformVersion.split(".")[1]) : 0;
|
|
202
|
+
const patch = platformVersion ? parseInt(platformVersion.split(".")[2]) : 0;
|
|
203
|
+
const latestRelease = await import_axios.default.get(
|
|
204
|
+
`${basePath2}/release/findVersionRelease?appName=${projectName}&branch=${environment}&major=${major}&minor=${minor}`
|
|
140
205
|
);
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
);
|
|
150
|
-
const release = (await import_axios.default.post(
|
|
151
|
-
`${basePath2}/release/pushRelease/${projectName}/${environment}/${major}/${minor}/${sourceFile.id}/${buildFile.id}/${appBuildFile.id}`
|
|
152
|
-
)).data;
|
|
153
|
-
return release;
|
|
154
|
-
} catch (e) {
|
|
155
|
-
return null;
|
|
156
|
-
}
|
|
157
|
-
};
|
|
206
|
+
const release = (await import_axios.default.post(
|
|
207
|
+
`${basePath2}/release/pushRelease/${projectName}/${environment}/${major}/${minor}/${sourceFile.id}/${buildFile.id}/${appBuildFile.id}`
|
|
208
|
+
)).data;
|
|
209
|
+
return release;
|
|
210
|
+
} catch (e) {
|
|
211
|
+
return null;
|
|
212
|
+
}
|
|
213
|
+
};
|
|
158
214
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
};
|
|
215
|
+
// pkgs/@akanjs/devkit/src/getModelFileData.ts
|
|
216
|
+
var import_fs3 = __toESM(require("fs"));
|
|
217
|
+
var getModelFileData = (modulePath, modelName) => {
|
|
218
|
+
const moduleType = modulePath.startsWith("apps") ? "app" : "lib";
|
|
219
|
+
const moduleName = modulePath.split("/")[1];
|
|
220
|
+
const constantFilePath = `${modulePath}/lib/${modelName}/${modelName}.constant.ts`;
|
|
221
|
+
const unitFilePath = `${modulePath}/lib/${modelName}/${modelName}.Unit.tsx`;
|
|
222
|
+
const viewFilePath = `${modulePath}/lib/${modelName}/${modelName}.View.tsx`;
|
|
223
|
+
const constantFileStr = import_fs3.default.readFileSync(constantFilePath, "utf8");
|
|
224
|
+
const unitFileStr = import_fs3.default.readFileSync(unitFilePath, "utf8");
|
|
225
|
+
const viewFileStr = import_fs3.default.readFileSync(viewFilePath, "utf8");
|
|
226
|
+
const constantFileLines = constantFileStr.split("\n");
|
|
227
|
+
const importLibNames = constantFileLines.filter((line) => line.startsWith("import { cnst as ")).map((line) => line.split("cnst as ")[1].split(" ")[0]);
|
|
228
|
+
const importLocalPaths = constantFileLines.filter((line) => line.startsWith("import { ") && line.includes('from "../')).map((line) => line.split("from ")[1].split('"')[1]);
|
|
229
|
+
const importModelNames = importLocalPaths.map((path5) => path5.split("/")[1]).filter((name) => !name.startsWith("_"));
|
|
230
|
+
const hasImportScalar = !!importLocalPaths.map((path5) => path5.split("/")[1]).filter((name) => name.startsWith("_")).length;
|
|
231
|
+
return {
|
|
232
|
+
moduleType,
|
|
233
|
+
moduleName,
|
|
234
|
+
modelName,
|
|
235
|
+
constantFilePath,
|
|
236
|
+
unitFilePath,
|
|
237
|
+
viewFilePath,
|
|
238
|
+
importModelNames,
|
|
239
|
+
hasImportScalar,
|
|
240
|
+
importLibNames,
|
|
241
|
+
constantFileStr,
|
|
242
|
+
unitFileStr,
|
|
243
|
+
viewFileStr
|
|
189
244
|
};
|
|
245
|
+
};
|
|
190
246
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
247
|
+
// pkgs/@akanjs/devkit/src/getRelatedCnsts.ts
|
|
248
|
+
var import_fs4 = __toESM(require("fs"));
|
|
249
|
+
var import_ora = __toESM(require("ora"));
|
|
250
|
+
var ts = __toESM(require("typescript"));
|
|
251
|
+
var getRelatedCnsts = (constantFilePath) => {
|
|
252
|
+
const tsConfigPath = `./tsconfig.json`;
|
|
253
|
+
const configFile = ts.readConfigFile(tsConfigPath, (path5) => {
|
|
254
|
+
return ts.sys.readFile(path5);
|
|
255
|
+
});
|
|
256
|
+
const parsedConfig = ts.parseJsonConfigFileContent(
|
|
257
|
+
configFile.config,
|
|
258
|
+
ts.sys,
|
|
259
|
+
import_fs4.default.realpathSync(tsConfigPath).replace(/[^/\\]+$/, "")
|
|
260
|
+
);
|
|
261
|
+
const propertyMap = /* @__PURE__ */ new Map();
|
|
262
|
+
function findPropertyOriginAll(filePath) {
|
|
263
|
+
const program2 = ts.createProgram([filePath], parsedConfig.options);
|
|
264
|
+
const checker = program2.getTypeChecker();
|
|
265
|
+
const source = program2.getSourceFile(filePath);
|
|
266
|
+
if (!source)
|
|
267
|
+
return null;
|
|
268
|
+
function visit(node) {
|
|
210
269
|
if (!source)
|
|
211
|
-
return
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
const
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
const
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
isLibModule: true,
|
|
231
|
-
isImport: false,
|
|
232
|
-
libName: left.text,
|
|
233
|
-
isScalar
|
|
234
|
-
});
|
|
235
|
-
} else
|
|
236
|
-
propertyMap.set(key, {
|
|
237
|
-
filePath: filePath2,
|
|
238
|
-
isLibModule: true,
|
|
239
|
-
isImport: false,
|
|
240
|
-
libName: left.text,
|
|
241
|
-
isScalar
|
|
242
|
-
});
|
|
243
|
-
findPropertyOriginAll(filePath2);
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
} else if (ts.isImportDeclaration(node)) {
|
|
247
|
-
const importPath = node.moduleSpecifier.getText().slice(1, -1);
|
|
248
|
-
if (importPath.startsWith(".")) {
|
|
249
|
-
const resolved = ts.resolveModuleName(importPath, filePath, parsedConfig.options, ts.sys).resolvedModule?.resolvedFileName;
|
|
250
|
-
const moduleName = importPath.split("/").pop()?.split(".")[0] ?? "";
|
|
251
|
-
const property = propertyMap.get(moduleName);
|
|
252
|
-
const isScalar = importPath.includes("_");
|
|
253
|
-
if (moduleName && resolved && (!property || property.filePath !== resolved)) {
|
|
254
|
-
propertyMap.set(moduleName, {
|
|
255
|
-
filePath: resolved,
|
|
256
|
-
isLibModule: false,
|
|
257
|
-
isImport: true,
|
|
270
|
+
return;
|
|
271
|
+
if (ts.isPropertyAccessExpression(node)) {
|
|
272
|
+
const left = node.expression;
|
|
273
|
+
const right = node.name;
|
|
274
|
+
const { line } = ts.getLineAndCharacterOfPosition(source, node.getStart());
|
|
275
|
+
const sourceLines = source.getFullText().split("\n");
|
|
276
|
+
if (ts.isIdentifier(left) && sourceLines.length && (sourceLines[line].includes(`@Field.Prop(() => ${left.text}.${right.text}`) || sourceLines[line].includes(`base.Filter(${left.text}.${right.text},`))) {
|
|
277
|
+
const symbol = checker.getSymbolAtLocation(right);
|
|
278
|
+
if (symbol?.declarations && symbol.declarations.length > 0) {
|
|
279
|
+
const key = symbol.declarations[0].getSourceFile().fileName.split("/").pop()?.split(".")[0] ?? "";
|
|
280
|
+
const property = propertyMap.get(key);
|
|
281
|
+
const isScalar = symbol.declarations[0].getSourceFile().fileName.includes("_");
|
|
282
|
+
const filePath2 = symbol.declarations[0].getSourceFile().fileName.replace(`${ts.sys.getCurrentDirectory()}/`, "");
|
|
283
|
+
if (property) {
|
|
284
|
+
propertyMap.set(`${left.text}.${right.text}`, {
|
|
285
|
+
filePath: filePath2,
|
|
286
|
+
isLibModule: true,
|
|
287
|
+
isImport: false,
|
|
288
|
+
libName: left.text,
|
|
258
289
|
isScalar
|
|
259
290
|
});
|
|
260
|
-
|
|
261
|
-
|
|
291
|
+
} else
|
|
292
|
+
propertyMap.set(key, {
|
|
293
|
+
filePath: filePath2,
|
|
294
|
+
isLibModule: true,
|
|
295
|
+
isImport: false,
|
|
296
|
+
libName: left.text,
|
|
297
|
+
isScalar
|
|
298
|
+
});
|
|
299
|
+
findPropertyOriginAll(filePath2);
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
} else if (ts.isImportDeclaration(node)) {
|
|
303
|
+
const importPath = node.moduleSpecifier.getText().slice(1, -1);
|
|
304
|
+
if (importPath.startsWith(".")) {
|
|
305
|
+
const resolved = ts.resolveModuleName(importPath, filePath, parsedConfig.options, ts.sys).resolvedModule?.resolvedFileName;
|
|
306
|
+
const moduleName = importPath.split("/").pop()?.split(".")[0] ?? "";
|
|
307
|
+
const property = propertyMap.get(moduleName);
|
|
308
|
+
const isScalar = importPath.includes("_");
|
|
309
|
+
if (moduleName && resolved && (!property || property.filePath !== resolved)) {
|
|
310
|
+
propertyMap.set(moduleName, {
|
|
311
|
+
filePath: resolved,
|
|
312
|
+
isLibModule: false,
|
|
313
|
+
isImport: true,
|
|
314
|
+
isScalar
|
|
315
|
+
});
|
|
316
|
+
findPropertyOriginAll(resolved);
|
|
262
317
|
}
|
|
263
318
|
}
|
|
264
|
-
ts.forEachChild(node, visit);
|
|
265
319
|
}
|
|
266
|
-
visit
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
320
|
+
ts.forEachChild(node, visit);
|
|
321
|
+
}
|
|
322
|
+
visit(source);
|
|
323
|
+
return propertyMap;
|
|
324
|
+
}
|
|
325
|
+
function findPropertyOrigin(filePath, aliasName, libName) {
|
|
326
|
+
const program2 = ts.createProgram([filePath], parsedConfig.options);
|
|
327
|
+
const checker = program2.getTypeChecker();
|
|
328
|
+
const source = program2.getSourceFile(filePath);
|
|
329
|
+
const propertyMap2 = /* @__PURE__ */ new Map();
|
|
330
|
+
if (!source)
|
|
331
|
+
return null;
|
|
332
|
+
function visit(node) {
|
|
333
|
+
if (ts.isPropertyAccessExpression(node)) {
|
|
334
|
+
const left = node.expression;
|
|
335
|
+
const right = node.name;
|
|
336
|
+
if (ts.isIdentifier(left) && left.text === aliasName && right.text === libName) {
|
|
337
|
+
const symbol = checker.getSymbolAtLocation(right);
|
|
338
|
+
if (symbol?.declarations && symbol.declarations.length > 0) {
|
|
339
|
+
return symbol.declarations[0].getSourceFile().fileName;
|
|
285
340
|
}
|
|
286
341
|
}
|
|
287
|
-
return ts.forEachChild(node, visit) || null;
|
|
288
342
|
}
|
|
289
|
-
return visit
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
343
|
+
return ts.forEachChild(node, visit) || null;
|
|
344
|
+
}
|
|
345
|
+
return visit(source);
|
|
346
|
+
}
|
|
347
|
+
const spinner = (0, import_ora.default)("Finding property origin...");
|
|
348
|
+
spinner.start();
|
|
349
|
+
const paths = findPropertyOriginAll(constantFilePath);
|
|
350
|
+
spinner.succeed("property origin found.");
|
|
351
|
+
return { paths };
|
|
352
|
+
};
|
|
297
353
|
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
354
|
+
// pkgs/@akanjs/devkit/src/selectModel.ts
|
|
355
|
+
var import_prompts = require("@inquirer/prompts");
|
|
356
|
+
var import_fs5 = __toESM(require("fs"));
|
|
357
|
+
var selectModel = async (modulePath) => {
|
|
358
|
+
const modelNames = import_fs5.default.readdirSync(`${modulePath}/lib`).filter((dir) => !dir.includes(".") && !dir.startsWith("_"));
|
|
359
|
+
const modelName = await (0, import_prompts.select)({
|
|
360
|
+
message: "Select the model to create the unit for",
|
|
361
|
+
choices: modelNames.map((name) => ({ name, value: name }))
|
|
362
|
+
});
|
|
363
|
+
return modelName;
|
|
364
|
+
};
|
|
365
|
+
|
|
366
|
+
// pkgs/@akanjs/devkit/src/streamAi.ts
|
|
367
|
+
var import_prompts2 = require("@langchain/core/prompts");
|
|
368
|
+
var import_runnables = require("@langchain/core/runnables");
|
|
369
|
+
var import_openai = require("@langchain/openai");
|
|
370
|
+
var streamAi = async (question, callback) => {
|
|
371
|
+
const createStreamingModel = (apiKey = process.env.DEEPSEEK_API_KEY) => {
|
|
372
|
+
if (!apiKey)
|
|
373
|
+
throw new Error(`process.env.DEEPSEEK_API_KEY is not set`);
|
|
374
|
+
return new import_openai.ChatOpenAI({
|
|
375
|
+
modelName: "deepseek-reasoner",
|
|
376
|
+
temperature: 0.7,
|
|
377
|
+
streaming: true,
|
|
378
|
+
// Enable streaming
|
|
379
|
+
configuration: { baseURL: "https://api.deepseek.com/v1", apiKey }
|
|
306
380
|
});
|
|
307
|
-
return modelName;
|
|
308
381
|
};
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
streaming: true,
|
|
322
|
-
// Enable streaming
|
|
323
|
-
configuration: { baseURL: "https://api.deepseek.com/v1", apiKey }
|
|
324
|
-
});
|
|
325
|
-
};
|
|
326
|
-
const createProcessingChain = () => {
|
|
327
|
-
return import_runnables.RunnableSequence.from([import_prompts2.PromptTemplate.fromTemplate(`Answer concisely: {question}`), createStreamingModel()]);
|
|
328
|
-
};
|
|
329
|
-
try {
|
|
330
|
-
const chain = createProcessingChain();
|
|
331
|
-
const stream = await chain.stream({ question });
|
|
332
|
-
let fullResponse = "";
|
|
333
|
-
for await (const chunk of stream) {
|
|
334
|
-
const content = chunk.content;
|
|
335
|
-
if (typeof content === "string") {
|
|
336
|
-
fullResponse += content;
|
|
337
|
-
callback(content);
|
|
338
|
-
}
|
|
382
|
+
const createProcessingChain = () => {
|
|
383
|
+
return import_runnables.RunnableSequence.from([import_prompts2.PromptTemplate.fromTemplate(`Answer concisely: {question}`), createStreamingModel()]);
|
|
384
|
+
};
|
|
385
|
+
try {
|
|
386
|
+
const chain = createProcessingChain();
|
|
387
|
+
const stream = await chain.stream({ question });
|
|
388
|
+
let fullResponse = "";
|
|
389
|
+
for await (const chunk of stream) {
|
|
390
|
+
const content = chunk.content;
|
|
391
|
+
if (typeof content === "string") {
|
|
392
|
+
fullResponse += content;
|
|
393
|
+
callback(content);
|
|
339
394
|
}
|
|
340
|
-
return { content: fullResponse };
|
|
341
|
-
} catch (error) {
|
|
342
|
-
throw new Error("Failed to stream response");
|
|
343
395
|
}
|
|
344
|
-
|
|
396
|
+
return { content: fullResponse };
|
|
397
|
+
} catch (error) {
|
|
398
|
+
throw new Error("Failed to stream response");
|
|
399
|
+
}
|
|
400
|
+
};
|
|
345
401
|
|
|
346
|
-
|
|
347
|
-
|
|
402
|
+
// pkgs/@akanjs/common/src/isDayjs.ts
|
|
403
|
+
var import_dayjs = require("dayjs");
|
|
348
404
|
|
|
349
|
-
|
|
350
|
-
|
|
405
|
+
// pkgs/@akanjs/common/src/isQueryEqual.ts
|
|
406
|
+
var import_dayjs2 = __toESM(require("dayjs"));
|
|
351
407
|
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
408
|
+
// pkgs/@akanjs/common/src/isValidDate.ts
|
|
409
|
+
var import_dayjs3 = __toESM(require("dayjs"));
|
|
410
|
+
var import_customParseFormat = __toESM(require("dayjs/plugin/customParseFormat"));
|
|
411
|
+
import_dayjs3.default.extend(import_customParseFormat.default);
|
|
356
412
|
|
|
357
|
-
|
|
358
|
-
|
|
413
|
+
// pkgs/@akanjs/common/src/pluralize.ts
|
|
414
|
+
var import_pluralize = __toESM(require("pluralize"));
|
|
359
415
|
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
416
|
+
// pkgs/@akanjs/common/src/capitalize.ts
|
|
417
|
+
var capitalize = (str) => {
|
|
418
|
+
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
419
|
+
};
|
|
364
420
|
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
421
|
+
// pkgs/@akanjs/common/src/Logger.ts
|
|
422
|
+
var import_dayjs4 = __toESM(require("dayjs"));
|
|
423
|
+
var logLevels = ["trace", "verbose", "debug", "log", "info", "warn", "error"];
|
|
424
|
+
var clc = {
|
|
425
|
+
bold: (text) => `\x1B[1m${text}\x1B[0m`,
|
|
426
|
+
green: (text) => `\x1B[32m${text}\x1B[39m`,
|
|
427
|
+
yellow: (text) => `\x1B[33m${text}\x1B[39m`,
|
|
428
|
+
red: (text) => `\x1B[31m${text}\x1B[39m`,
|
|
429
|
+
magentaBright: (text) => `\x1B[95m${text}\x1B[39m`,
|
|
430
|
+
cyanBright: (text) => `\x1B[96m${text}\x1B[39m`
|
|
431
|
+
};
|
|
432
|
+
var colorizeMap = {
|
|
433
|
+
trace: clc.bold,
|
|
434
|
+
verbose: clc.cyanBright,
|
|
435
|
+
debug: clc.magentaBright,
|
|
436
|
+
log: clc.green,
|
|
437
|
+
info: clc.green,
|
|
438
|
+
warn: clc.yellow,
|
|
439
|
+
error: clc.red
|
|
440
|
+
};
|
|
441
|
+
var Logger = class _Logger {
|
|
442
|
+
static #ignoreCtxSet = /* @__PURE__ */ new Set([
|
|
443
|
+
"InstanceLoader",
|
|
444
|
+
"RoutesResolver",
|
|
445
|
+
"RouterExplorer",
|
|
446
|
+
"NestFactory",
|
|
447
|
+
"WebSocketsController",
|
|
448
|
+
"GraphQLModule",
|
|
449
|
+
"NestApplication"
|
|
450
|
+
]);
|
|
451
|
+
static level = process.env.NEXT_PUBLIC_LOG_LEVEL ?? "log";
|
|
452
|
+
static #levelIdx = logLevels.findIndex((l) => l === process.env.NEXT_PUBLIC_LOG_LEVEL);
|
|
453
|
+
static #startAt = (0, import_dayjs4.default)();
|
|
454
|
+
static setLevel(level) {
|
|
455
|
+
this.level = level;
|
|
456
|
+
this.#levelIdx = logLevels.findIndex((l) => l === level);
|
|
457
|
+
}
|
|
458
|
+
name;
|
|
459
|
+
constructor(name) {
|
|
460
|
+
this.name = name;
|
|
461
|
+
}
|
|
462
|
+
trace(msg, context = "") {
|
|
463
|
+
if (_Logger.#levelIdx <= 0)
|
|
464
|
+
_Logger.#printMessages(this.name ?? "App", msg, context, "trace");
|
|
465
|
+
}
|
|
466
|
+
verbose(msg, context = "") {
|
|
467
|
+
if (_Logger.#levelIdx <= 1)
|
|
468
|
+
_Logger.#printMessages(this.name ?? "App", msg, context, "verbose");
|
|
469
|
+
}
|
|
470
|
+
debug(msg, context = "") {
|
|
471
|
+
if (_Logger.#levelIdx <= 2)
|
|
472
|
+
_Logger.#printMessages(this.name ?? "App", msg, context, "debug");
|
|
473
|
+
}
|
|
474
|
+
log(msg, context = "") {
|
|
475
|
+
if (_Logger.#levelIdx <= 3)
|
|
476
|
+
_Logger.#printMessages(this.name ?? "App", msg, context, "log");
|
|
477
|
+
}
|
|
478
|
+
info(msg, context = "") {
|
|
479
|
+
if (_Logger.#levelIdx <= 4)
|
|
480
|
+
_Logger.#printMessages(this.name ?? "App", msg, context, "info");
|
|
481
|
+
}
|
|
482
|
+
warn(msg, context = "") {
|
|
483
|
+
if (_Logger.#levelIdx <= 5)
|
|
484
|
+
_Logger.#printMessages(this.name ?? "App", msg, context, "warn");
|
|
485
|
+
}
|
|
486
|
+
error(msg, context = "") {
|
|
487
|
+
if (_Logger.#levelIdx <= 6)
|
|
488
|
+
_Logger.#printMessages(this.name ?? "App", msg, context, "error");
|
|
489
|
+
}
|
|
490
|
+
raw(msg, method) {
|
|
491
|
+
_Logger.rawLog(msg, method);
|
|
492
|
+
}
|
|
493
|
+
rawLog(msg, method) {
|
|
494
|
+
_Logger.rawLog(msg, method);
|
|
495
|
+
}
|
|
496
|
+
static trace(msg, context = "") {
|
|
497
|
+
if (_Logger.#levelIdx <= 0)
|
|
498
|
+
_Logger.#printMessages("App", msg, context, "trace");
|
|
499
|
+
}
|
|
500
|
+
static verbose(msg, context = "") {
|
|
501
|
+
if (_Logger.#levelIdx <= 1)
|
|
502
|
+
_Logger.#printMessages("App", msg, context, "verbose");
|
|
503
|
+
}
|
|
504
|
+
static debug(msg, context = "") {
|
|
505
|
+
if (_Logger.#levelIdx <= 2)
|
|
506
|
+
_Logger.#printMessages("App", msg, context, "debug");
|
|
507
|
+
}
|
|
508
|
+
static log(msg, context = "") {
|
|
509
|
+
if (_Logger.#levelIdx <= 3)
|
|
510
|
+
_Logger.#printMessages("App", msg, context, "log");
|
|
511
|
+
}
|
|
512
|
+
static info(msg, context = "") {
|
|
513
|
+
if (_Logger.#levelIdx <= 4)
|
|
514
|
+
_Logger.#printMessages("App", msg, context, "info");
|
|
515
|
+
}
|
|
516
|
+
static warn(msg, context = "") {
|
|
517
|
+
if (_Logger.#levelIdx <= 5)
|
|
518
|
+
_Logger.#printMessages("App", msg, context, "warn");
|
|
519
|
+
}
|
|
520
|
+
static error(msg, context = "") {
|
|
521
|
+
if (_Logger.#levelIdx <= 6)
|
|
522
|
+
_Logger.#printMessages("App", msg, context, "error");
|
|
523
|
+
}
|
|
524
|
+
static #colorize(msg, logLevel) {
|
|
525
|
+
return colorizeMap[logLevel](msg);
|
|
526
|
+
}
|
|
527
|
+
static #printMessages(name, content, context, logLevel, writeStreamType = logLevel === "error" ? "stderr" : "stdout") {
|
|
528
|
+
if (this.#ignoreCtxSet.has(context))
|
|
529
|
+
return;
|
|
530
|
+
const now = (0, import_dayjs4.default)();
|
|
531
|
+
const processMsg = this.#colorize(
|
|
532
|
+
`[${name ?? "App"}] ${global.process?.pid ?? "window"} -`,
|
|
533
|
+
logLevel
|
|
534
|
+
);
|
|
535
|
+
const timestampMsg = now.format("MM/DD/YYYY, HH:mm:ss A");
|
|
536
|
+
const logLevelMsg = this.#colorize(logLevel.toUpperCase().padStart(7, " "), logLevel);
|
|
537
|
+
const contextMsg = context ? clc.yellow(`[${context}] `) : "";
|
|
538
|
+
const contentMsg = this.#colorize(content, logLevel);
|
|
539
|
+
const timeDiffMsg = clc.yellow(`+${now.diff(_Logger.#startAt, "ms")}ms`);
|
|
540
|
+
if (typeof window === "undefined")
|
|
541
|
+
process[writeStreamType].write(
|
|
542
|
+
`${processMsg} ${timestampMsg} ${logLevelMsg} ${contextMsg} ${contentMsg} ${timeDiffMsg}
|
|
487
543
|
`
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
544
|
+
);
|
|
545
|
+
else
|
|
546
|
+
console.log(`${processMsg} ${timestampMsg} ${logLevelMsg} ${contextMsg} ${contentMsg} ${timeDiffMsg}
|
|
491
547
|
`);
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
548
|
+
}
|
|
549
|
+
static rawLog(msg, method) {
|
|
550
|
+
this.raw(`${msg}
|
|
495
551
|
`, method);
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
552
|
+
}
|
|
553
|
+
static raw(msg, method) {
|
|
554
|
+
if (typeof window === "undefined" && method !== "console" && global.process)
|
|
555
|
+
global.process.stdout.write(msg);
|
|
556
|
+
else
|
|
557
|
+
console.log(msg);
|
|
558
|
+
}
|
|
559
|
+
};
|
|
504
560
|
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
561
|
+
// pkgs/@akanjs/config/src/akanConfig.ts
|
|
562
|
+
var import_fs6 = __toESM(require("fs"));
|
|
563
|
+
var import_path2 = __toESM(require("path"));
|
|
508
564
|
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
565
|
+
// pkgs/@akanjs/config/src/baseConfigEnv.ts
|
|
566
|
+
var getBaseConfigEnv = (appName = process.env.NEXT_PUBLIC_APP_NAME) => {
|
|
567
|
+
if (!appName)
|
|
568
|
+
throw new Error("NEXT_PUBLIC_APP_NAME is not set");
|
|
569
|
+
const repoName = process.env.NEXT_PUBLIC_REPO_NAME;
|
|
570
|
+
if (!repoName)
|
|
571
|
+
throw new Error("NEXT_PUBLIC_REPO_NAME is not set");
|
|
572
|
+
const serveDomain = process.env.NEXT_PUBLIC_SERVE_DOMAIN;
|
|
573
|
+
if (!serveDomain)
|
|
574
|
+
throw new Error("NEXT_PUBLIC_SERVE_DOMAIN is not set");
|
|
575
|
+
const env = process.env.NEXT_PUBLIC_ENV ?? "debug";
|
|
576
|
+
if (!env)
|
|
577
|
+
throw new Error("NEXT_PUBLIC_ENV is not set");
|
|
578
|
+
return { appName, repoName, serveDomain, env };
|
|
579
|
+
};
|
|
524
580
|
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
};
|
|
581
|
+
// pkgs/@akanjs/config/src/nextConfig.ts
|
|
582
|
+
var import_bundle_analyzer = __toESM(require("@next/bundle-analyzer"));
|
|
583
|
+
var import_next_pwa = __toESM(require("next-pwa"));
|
|
584
|
+
var import_cache = __toESM(require("next-pwa/cache"));
|
|
585
|
+
var import_path = __toESM(require("path"));
|
|
586
|
+
var composePlugins = (...plugins) => {
|
|
587
|
+
return function(baseConfig) {
|
|
588
|
+
return async function combined(phase, context) {
|
|
589
|
+
let config = baseConfig;
|
|
590
|
+
for (const plugin of plugins) {
|
|
591
|
+
const fn = plugin;
|
|
592
|
+
const configOrFn = fn(config);
|
|
593
|
+
if (typeof configOrFn === "function")
|
|
594
|
+
config = await configOrFn(phase, context);
|
|
595
|
+
else
|
|
596
|
+
config = configOrFn;
|
|
597
|
+
}
|
|
598
|
+
return config;
|
|
544
599
|
};
|
|
545
600
|
};
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
},
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
601
|
+
};
|
|
602
|
+
var commandType = process.env.AKAN_COMMAND_TYPE?.includes("serve") ? "serve" : process.env.AKAN_COMMAND_TYPE?.includes("build") ? "build" : "deploy";
|
|
603
|
+
var withPWA = (0, import_next_pwa.default)({
|
|
604
|
+
dest: "public",
|
|
605
|
+
register: true,
|
|
606
|
+
skipWaiting: true,
|
|
607
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
608
|
+
runtimeCaching: import_cache.default,
|
|
609
|
+
disable: commandType === "serve"
|
|
610
|
+
});
|
|
611
|
+
var devDomain = process.env.NEXT_PUBLIC_SERVE_DOMAIN ?? "akanjs.com";
|
|
612
|
+
var withBase = (appName, config, libs, routes = []) => {
|
|
613
|
+
return composePlugins(
|
|
614
|
+
(0, import_bundle_analyzer.default)({ enabled: process.env.ANALYZE === "true" }),
|
|
615
|
+
...commandType !== "serve" || process.env.USE_PWA === "true" ? [withPWA] : []
|
|
616
|
+
)({
|
|
617
|
+
...config,
|
|
618
|
+
eslint: { ...config.eslint, ignoreDuringBuilds: true },
|
|
619
|
+
env: {
|
|
620
|
+
...config.env,
|
|
621
|
+
basePaths: routes.map(({ basePath: basePath2 }) => basePath2).join(",")
|
|
622
|
+
},
|
|
623
|
+
transpilePackages: [
|
|
624
|
+
"swiper",
|
|
625
|
+
"ssr-window",
|
|
626
|
+
"dom7",
|
|
627
|
+
...libs.map((lib) => `@${lib}`),
|
|
628
|
+
"@akanjs/base",
|
|
629
|
+
"@akanjs/common",
|
|
630
|
+
"@akanjs/next",
|
|
631
|
+
"@akanjs/ui",
|
|
632
|
+
"@akanjs/client",
|
|
633
|
+
"@akanjs/server",
|
|
634
|
+
"@akanjs/service",
|
|
635
|
+
"@akanjs/signal",
|
|
636
|
+
"@akanjs/store",
|
|
637
|
+
"@akanjs/dictionary",
|
|
638
|
+
"@akanjs/constant",
|
|
639
|
+
"@akanjs/config",
|
|
640
|
+
"@akanjs/document"
|
|
641
|
+
],
|
|
642
|
+
reactStrictMode: commandType === "serve" ? false : true,
|
|
643
|
+
experimental: {
|
|
644
|
+
...config.experimental ?? {},
|
|
645
|
+
optimizePackageImports: [
|
|
646
|
+
...[appName, ...libs].map((lib) => [`@${lib}/ui`, `@${lib}/next`, `@${lib}/common`, `@${lib}/client`]).flat(),
|
|
647
|
+
"@contract",
|
|
574
648
|
"@akanjs/next",
|
|
575
|
-
"@akanjs/
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
]).flat().map(({ basePath: basePath2, domain }) => ({
|
|
649
|
-
source: `/:locale/${basePath2}/:path*`,
|
|
649
|
+
"@akanjs/common"
|
|
650
|
+
]
|
|
651
|
+
},
|
|
652
|
+
// modularizeImports: {
|
|
653
|
+
// "react-icons/?(((\\w*)?/?)*)": {
|
|
654
|
+
// transform: "@react-icons/all-files/{{ matches.[1] }}/{{member}}",
|
|
655
|
+
// skipDefaultConversion: true,
|
|
656
|
+
// },
|
|
657
|
+
// lodash: { transform: "lodash/{{member}}", preventFullImport: true },
|
|
658
|
+
// ...Object.fromEntries(
|
|
659
|
+
// [appName, ...libs].reduce(
|
|
660
|
+
// (acc, lib) => [
|
|
661
|
+
// ...acc,
|
|
662
|
+
// [`@${lib}/ui`, { transform: `@${lib}/ui/{{member}}`, skipDefaultConversion: true }],
|
|
663
|
+
// [`@${lib}/next`, { transform: `@${lib}/next/{{member}}`, skipDefaultConversion: true }],
|
|
664
|
+
// [`@${lib}/common`, { transform: `@${lib}/common/{{member}}`, skipDefaultConversion: true }],
|
|
665
|
+
// [`@${lib}/client`, { transform: `@${lib}/lib/{{ camelCase member }}`, skipDefaultConversion: true }],
|
|
666
|
+
// ],
|
|
667
|
+
// [
|
|
668
|
+
// ["@contract", { transform: `@contract/src/{{member}}`, skipDefaultConversion: true }],
|
|
669
|
+
// [`@akanjs/next`, { transform: `@akanjs/next/src/{{member}}`, skipDefaultConversion: true }],
|
|
670
|
+
// [`@akanjs/common`, { transform: `@akanjs/common/src/{{member}}`, skipDefaultConversion: true }],
|
|
671
|
+
// ]
|
|
672
|
+
// )
|
|
673
|
+
// ),
|
|
674
|
+
// ...(config.modularizeImports ?? {}),
|
|
675
|
+
// },
|
|
676
|
+
images: {
|
|
677
|
+
formats: ["image/avif", "image/webp"],
|
|
678
|
+
...config.images ?? {},
|
|
679
|
+
remotePatterns: [
|
|
680
|
+
...config.images?.remotePatterns ?? [],
|
|
681
|
+
...routes.map(({ domains }) => [
|
|
682
|
+
...domains.main?.map((domain) => ({ protocol: "https", hostname: `**.${domain}` })) ?? [],
|
|
683
|
+
...domains.develop?.map((domain) => ({ protocol: "https", hostname: `**.${domain}` })) ?? [],
|
|
684
|
+
...domains.debug?.map((domain) => ({ protocol: "https", hostname: `**.${domain}` })) ?? []
|
|
685
|
+
]).flat(),
|
|
686
|
+
{ protocol: "https", hostname: `**.${devDomain}` }
|
|
687
|
+
]
|
|
688
|
+
},
|
|
689
|
+
webpack: (config2) => {
|
|
690
|
+
config2.resolve.alias.canvas = false;
|
|
691
|
+
config2.resolve.alias.encoding = false;
|
|
692
|
+
if (process.env.USE_AKANJS_PKGS === "true")
|
|
693
|
+
config2.resolve.alias["@akanjs/config"] = import_path.default.resolve(__dirname, "../../../../pkgs/@akanjs/config");
|
|
694
|
+
return config2;
|
|
695
|
+
},
|
|
696
|
+
redirects() {
|
|
697
|
+
return routes.map(({ basePath: basePath2, domains }) => [
|
|
698
|
+
{ basePath: basePath2, domain: `${basePath2}-debug.${devDomain}` },
|
|
699
|
+
{ basePath: basePath2, domain: `${basePath2}-develop.${devDomain}` },
|
|
700
|
+
{ basePath: basePath2, domain: `${basePath2}-main.${devDomain}` },
|
|
701
|
+
...domains.main?.map((domain) => ({ basePath: basePath2, domain })) ?? [],
|
|
702
|
+
...domains.develop?.map((domain) => ({ basePath: basePath2, domain })) ?? [],
|
|
703
|
+
...domains.debug?.map((domain) => ({ basePath: basePath2, domain })) ?? []
|
|
704
|
+
]).flat().map(({ basePath: basePath2, domain }) => ({
|
|
705
|
+
source: `/:locale/${basePath2}/:path*`,
|
|
706
|
+
has: [{ type: "host", value: domain }],
|
|
707
|
+
permanent: true,
|
|
708
|
+
destination: "/:locale/:path*"
|
|
709
|
+
}));
|
|
710
|
+
},
|
|
711
|
+
rewrites() {
|
|
712
|
+
return routes.map(({ basePath: basePath2, domains }) => [
|
|
713
|
+
{ basePath: basePath2, domain: `${basePath2}-debug.${devDomain}` },
|
|
714
|
+
{ basePath: basePath2, domain: `${basePath2}-develop.${devDomain}` },
|
|
715
|
+
{ basePath: basePath2, domain: `${basePath2}-main.${devDomain}` },
|
|
716
|
+
...domains.main?.map((domain) => ({ basePath: basePath2, domain })) ?? [],
|
|
717
|
+
...domains.develop?.map((domain) => ({ basePath: basePath2, domain })) ?? [],
|
|
718
|
+
...domains.debug?.map((domain) => ({ basePath: basePath2, domain })) ?? []
|
|
719
|
+
]).flat().map(({ basePath: basePath2, domain }) => [
|
|
720
|
+
{
|
|
721
|
+
source: "/:locale",
|
|
650
722
|
has: [{ type: "host", value: domain }],
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
...domains.debug?.map((domain) => ({ basePath: basePath2, domain })) ?? []
|
|
663
|
-
]).flat().map(({ basePath: basePath2, domain }) => [
|
|
664
|
-
{
|
|
665
|
-
source: "/:locale",
|
|
666
|
-
has: [{ type: "host", value: domain }],
|
|
667
|
-
destination: `/:locale/${basePath2}`
|
|
668
|
-
},
|
|
669
|
-
{
|
|
670
|
-
source: `/:locale/:path((?!${basePath2}$)(?!admin(?:/|$)).*)`,
|
|
671
|
-
has: [{ type: "host", value: domain }],
|
|
672
|
-
destination: `/:locale/${basePath2}/:path*`
|
|
673
|
-
}
|
|
674
|
-
]).flat();
|
|
675
|
-
}
|
|
676
|
-
});
|
|
677
|
-
};
|
|
723
|
+
destination: `/:locale/${basePath2}`
|
|
724
|
+
},
|
|
725
|
+
{
|
|
726
|
+
source: `/:locale/:path((?!${basePath2}$)(?!admin(?:/|$)).*)`,
|
|
727
|
+
has: [{ type: "host", value: domain }],
|
|
728
|
+
destination: `/:locale/${basePath2}/:path*`
|
|
729
|
+
}
|
|
730
|
+
]).flat();
|
|
731
|
+
}
|
|
732
|
+
});
|
|
733
|
+
};
|
|
678
734
|
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
735
|
+
// pkgs/@akanjs/config/src/akanConfig.ts
|
|
736
|
+
var makeAppConfig = (config, props = {}) => {
|
|
737
|
+
const baseConfigEnv = getBaseConfigEnv(props.appName);
|
|
738
|
+
const {
|
|
739
|
+
appName = baseConfigEnv.appName,
|
|
740
|
+
repoName = baseConfigEnv.repoName,
|
|
741
|
+
serveDomain = baseConfigEnv.serveDomain,
|
|
742
|
+
env = baseConfigEnv.env,
|
|
743
|
+
command = "build"
|
|
744
|
+
} = props;
|
|
745
|
+
return {
|
|
746
|
+
rootLib: config.rootLib,
|
|
747
|
+
libs: config.libs ?? [],
|
|
748
|
+
backend: {
|
|
749
|
+
dockerfile: config.backend?.dockerfile ?? `FROM node:22-slim
|
|
694
750
|
RUN ln -sf /usr/share/zoneinfo/Asia/Seoul /etc/localtime
|
|
695
751
|
RUN apt-get update && apt-get upgrade -y
|
|
696
752
|
RUN apt-get install -y ca-certificates fonts-liberation libappindicator3-1 libasound2 libatk-bridge2.0-0 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgbm1 libgcc1 libglib2.0-0 libgtk-3-0 libnspr4 libnss3 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 lsb-release wget xdg-utils udev
|
|
@@ -705,16 +761,16 @@ RUN npx pnpm i --prod
|
|
|
705
761
|
COPY . .
|
|
706
762
|
ENV PORT 8080
|
|
707
763
|
ENV NODE_OPTIONS=--max_old_space_size=8192
|
|
708
|
-
ENV NEXT_PUBLIC_REPO_NAME=${
|
|
709
|
-
ENV NEXT_PUBLIC_SERVE_DOMAIN=${
|
|
710
|
-
ENV NEXT_PUBLIC_APP_NAME=${
|
|
711
|
-
ENV NEXT_PUBLIC_ENV=${
|
|
764
|
+
ENV NEXT_PUBLIC_REPO_NAME=${repoName}
|
|
765
|
+
ENV NEXT_PUBLIC_SERVE_DOMAIN=${serveDomain}
|
|
766
|
+
ENV NEXT_PUBLIC_APP_NAME=${appName}
|
|
767
|
+
ENV NEXT_PUBLIC_ENV=${env}
|
|
712
768
|
ENV NEXT_PUBLIC_OPERATION_MODE=cloud
|
|
713
769
|
CMD ["node", "main.js"]`,
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
770
|
+
explicitDependencies: config.backend?.explicitDependencies ?? []
|
|
771
|
+
},
|
|
772
|
+
frontend: {
|
|
773
|
+
dockerfile: config.frontend?.dockerfile ?? `FROM node:22-alpine
|
|
718
774
|
RUN ln -sf /usr/share/zoneinfo/Asia/Seoul /etc/localtime
|
|
719
775
|
RUN apk --no-cache add git
|
|
720
776
|
RUN mkdir -p /workspace
|
|
@@ -724,1229 +780,1228 @@ RUN npx pnpm i --prod
|
|
|
724
780
|
COPY . .
|
|
725
781
|
ENV PORT 4200
|
|
726
782
|
ENV NODE_OPTIONS=--max_old_space_size=8192
|
|
727
|
-
ENV NEXT_PUBLIC_REPO_NAME=${
|
|
728
|
-
ENV NEXT_PUBLIC_SERVE_DOMAIN=${
|
|
729
|
-
ENV NEXT_PUBLIC_APP_NAME=${
|
|
730
|
-
ENV NEXT_PUBLIC_ENV=${
|
|
783
|
+
ENV NEXT_PUBLIC_REPO_NAME=${repoName}
|
|
784
|
+
ENV NEXT_PUBLIC_SERVE_DOMAIN=${serveDomain}
|
|
785
|
+
ENV NEXT_PUBLIC_APP_NAME=${appName}
|
|
786
|
+
ENV NEXT_PUBLIC_ENV=${env}
|
|
731
787
|
ENV NEXT_PUBLIC_OPERATION_MODE=cloud
|
|
732
788
|
CMD ["npm", "start"]`,
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
};
|
|
742
|
-
};
|
|
743
|
-
var getAppConfig = async (appRoot, props) => {
|
|
744
|
-
const akanConfigPath = import_path2.default.join(appRoot, "akan.config.ts");
|
|
745
|
-
if (!import_fs6.default.existsSync(akanConfigPath))
|
|
746
|
-
throw new Error(`application akan.config.ts is not found ${appRoot}`);
|
|
747
|
-
const configImp = (await import(`${appRoot}/akan.config.ts`)).default;
|
|
748
|
-
const config = typeof configImp === "function" ? configImp(props) : configImp;
|
|
749
|
-
return makeAppConfig(config, props);
|
|
750
|
-
};
|
|
751
|
-
var makeLibConfig = (config, props = {}) => {
|
|
752
|
-
return {
|
|
753
|
-
rootLib: config.rootLib,
|
|
754
|
-
libs: config.libs ?? [],
|
|
755
|
-
backend: {
|
|
756
|
-
explicitDependencies: config.backend?.explicitDependencies ?? []
|
|
757
|
-
},
|
|
758
|
-
frontend: {
|
|
759
|
-
explicitDependencies: config.frontend?.explicitDependencies ?? []
|
|
760
|
-
}
|
|
761
|
-
};
|
|
762
|
-
};
|
|
763
|
-
var getLibConfig = async (libRoot, props) => {
|
|
764
|
-
const akanConfigPath = import_path2.default.join(libRoot, "akan.config.ts");
|
|
765
|
-
if (!import_fs6.default.existsSync(akanConfigPath))
|
|
766
|
-
throw new Error(`library akan.config.ts is not found ${libRoot}`);
|
|
767
|
-
const configImp = (await import(`${libRoot}/akan.config.ts`)).default;
|
|
768
|
-
const config = typeof configImp === "function" ? configImp(props) : configImp;
|
|
769
|
-
return makeLibConfig(config, props);
|
|
789
|
+
nextConfig: withBase(
|
|
790
|
+
appName,
|
|
791
|
+
config.frontend?.nextConfig ? typeof config.frontend.nextConfig === "function" ? config.frontend.nextConfig() : config.frontend.nextConfig : {},
|
|
792
|
+
config.libs ?? [],
|
|
793
|
+
config.frontend?.routes
|
|
794
|
+
),
|
|
795
|
+
explicitDependencies: config.frontend?.explicitDependencies ?? []
|
|
796
|
+
}
|
|
770
797
|
};
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
798
|
+
};
|
|
799
|
+
var getAppConfig = async (appRoot, props) => {
|
|
800
|
+
const akanConfigPath = import_path2.default.join(appRoot, "akan.config.ts");
|
|
801
|
+
if (!import_fs6.default.existsSync(akanConfigPath))
|
|
802
|
+
throw new Error(`application akan.config.ts is not found ${appRoot}`);
|
|
803
|
+
const configImp = (await import(`${appRoot}/akan.config.ts`)).default;
|
|
804
|
+
const config = typeof configImp === "function" ? configImp(props) : configImp;
|
|
805
|
+
return makeAppConfig(config, props);
|
|
806
|
+
};
|
|
807
|
+
var makeLibConfig = (config, props = {}) => {
|
|
808
|
+
return {
|
|
809
|
+
rootLib: config.rootLib,
|
|
810
|
+
libs: config.libs ?? [],
|
|
811
|
+
backend: {
|
|
812
|
+
explicitDependencies: config.backend?.explicitDependencies ?? []
|
|
782
813
|
},
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
scalars: []
|
|
786
|
-
},
|
|
787
|
-
services: {
|
|
788
|
-
databases: [],
|
|
789
|
-
services: [],
|
|
790
|
-
scalars: []
|
|
791
|
-
},
|
|
792
|
-
signal: {
|
|
793
|
-
databases: [],
|
|
794
|
-
services: [],
|
|
795
|
-
scalars: []
|
|
796
|
-
},
|
|
797
|
-
store: {
|
|
798
|
-
databases: [],
|
|
799
|
-
services: [],
|
|
800
|
-
scalars: []
|
|
801
|
-
},
|
|
802
|
-
components: {
|
|
803
|
-
databases: [],
|
|
804
|
-
services: [],
|
|
805
|
-
scalars: []
|
|
814
|
+
frontend: {
|
|
815
|
+
explicitDependencies: config.frontend?.explicitDependencies ?? []
|
|
806
816
|
}
|
|
807
|
-
}
|
|
817
|
+
};
|
|
818
|
+
};
|
|
819
|
+
var getLibConfig = async (libRoot, props) => {
|
|
820
|
+
const akanConfigPath = import_path2.default.join(libRoot, "akan.config.ts");
|
|
821
|
+
if (!import_fs6.default.existsSync(akanConfigPath))
|
|
822
|
+
throw new Error(`library akan.config.ts is not found ${libRoot}`);
|
|
823
|
+
const configImp = (await import(`${libRoot}/akan.config.ts`)).default;
|
|
824
|
+
const config = typeof configImp === "function" ? configImp(props) : configImp;
|
|
825
|
+
return makeLibConfig(config, props);
|
|
826
|
+
};
|
|
808
827
|
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
828
|
+
// pkgs/@akanjs/config/index.ts
|
|
829
|
+
var getDefaultFileScan = () => ({
|
|
830
|
+
constants: {
|
|
831
|
+
databases: [],
|
|
832
|
+
scalars: []
|
|
833
|
+
},
|
|
834
|
+
dictionary: {
|
|
835
|
+
databases: [],
|
|
836
|
+
services: [],
|
|
837
|
+
scalars: []
|
|
838
|
+
},
|
|
839
|
+
documents: {
|
|
840
|
+
databases: [],
|
|
841
|
+
scalars: []
|
|
842
|
+
},
|
|
843
|
+
services: {
|
|
844
|
+
databases: [],
|
|
845
|
+
services: [],
|
|
846
|
+
scalars: []
|
|
847
|
+
},
|
|
848
|
+
signal: {
|
|
849
|
+
databases: [],
|
|
850
|
+
services: [],
|
|
851
|
+
scalars: []
|
|
852
|
+
},
|
|
853
|
+
store: {
|
|
854
|
+
databases: [],
|
|
855
|
+
services: [],
|
|
856
|
+
scalars: []
|
|
857
|
+
},
|
|
858
|
+
components: {
|
|
859
|
+
databases: [],
|
|
860
|
+
services: [],
|
|
861
|
+
scalars: []
|
|
862
|
+
}
|
|
863
|
+
});
|
|
814
864
|
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
865
|
+
// pkgs/@akanjs/devkit/src/executors.ts
|
|
866
|
+
var import_child_process = require("child_process");
|
|
867
|
+
var import_fs7 = __toESM(require("fs"));
|
|
868
|
+
var import_promises = __toESM(require("fs/promises"));
|
|
869
|
+
var import_path3 = __toESM(require("path"));
|
|
870
|
+
|
|
871
|
+
// pkgs/@akanjs/devkit/src/dependencyScanner.ts
|
|
872
|
+
var fs7 = __toESM(require("fs"));
|
|
873
|
+
var path3 = __toESM(require("path"));
|
|
874
|
+
var ts2 = __toESM(require("typescript"));
|
|
875
|
+
var TypeScriptDependencyScanner = class {
|
|
876
|
+
constructor(directory) {
|
|
877
|
+
this.directory = directory;
|
|
878
|
+
}
|
|
879
|
+
#fileDependencies = /* @__PURE__ */ new Map();
|
|
880
|
+
#visitedFiles = /* @__PURE__ */ new Set();
|
|
881
|
+
async getImportSets(depSets) {
|
|
882
|
+
const fileDependencies = await this.getDependencies();
|
|
883
|
+
const importedDepSets = new Array(depSets.length);
|
|
884
|
+
for (let i = 0; i < depSets.length; i++)
|
|
885
|
+
importedDepSets[i] = /* @__PURE__ */ new Set();
|
|
886
|
+
fileDependencies.forEach((imps) => {
|
|
887
|
+
imps.forEach((imp) => {
|
|
888
|
+
if (imp.startsWith("."))
|
|
889
|
+
return;
|
|
890
|
+
const moduleName = imp;
|
|
891
|
+
const moduleNameParts = moduleName.split("/");
|
|
892
|
+
const subModuleLength = moduleNameParts.length;
|
|
893
|
+
for (let i = 0; i < subModuleLength; i++) {
|
|
894
|
+
const importName = moduleNameParts.slice(0, i + 1).join("/");
|
|
895
|
+
for (let j = 0; j < depSets.length; j++) {
|
|
896
|
+
if (depSets[j].has(importName)) {
|
|
897
|
+
importedDepSets[j].add(importName);
|
|
898
|
+
return;
|
|
844
899
|
}
|
|
845
900
|
}
|
|
846
|
-
});
|
|
847
|
-
});
|
|
848
|
-
return importedDepSets;
|
|
849
|
-
}
|
|
850
|
-
async getDependencies() {
|
|
851
|
-
this.#fileDependencies.clear();
|
|
852
|
-
this.#visitedFiles.clear();
|
|
853
|
-
const files = await this.#findTypeScriptFiles(this.directory);
|
|
854
|
-
for (const file of files)
|
|
855
|
-
await this.#analyzeFile(file, this.directory);
|
|
856
|
-
return this.#fileDependencies;
|
|
857
|
-
}
|
|
858
|
-
async #findTypeScriptFiles(directory) {
|
|
859
|
-
const files = [];
|
|
860
|
-
const processDirectory = async (dir) => {
|
|
861
|
-
const entries = await fs7.promises.readdir(dir, { withFileTypes: true });
|
|
862
|
-
for (const entry of entries) {
|
|
863
|
-
const fullPath = path3.join(dir, entry.name);
|
|
864
|
-
if (entry.isDirectory()) {
|
|
865
|
-
if (!["node_modules", "dist", "build", ".git", ".next", "public", "ios", "android"].includes(entry.name))
|
|
866
|
-
await processDirectory(fullPath);
|
|
867
|
-
} else if (entry.isFile() && (entry.name.endsWith(".ts") || entry.name.endsWith(".tsx")))
|
|
868
|
-
files.push(fullPath);
|
|
869
901
|
}
|
|
870
|
-
};
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
902
|
+
});
|
|
903
|
+
});
|
|
904
|
+
return importedDepSets;
|
|
905
|
+
}
|
|
906
|
+
async getDependencies() {
|
|
907
|
+
this.#fileDependencies.clear();
|
|
908
|
+
this.#visitedFiles.clear();
|
|
909
|
+
const files = await this.#findTypeScriptFiles(this.directory);
|
|
910
|
+
for (const file of files)
|
|
911
|
+
await this.#analyzeFile(file, this.directory);
|
|
912
|
+
return this.#fileDependencies;
|
|
913
|
+
}
|
|
914
|
+
async #findTypeScriptFiles(directory) {
|
|
915
|
+
const files = [];
|
|
916
|
+
const processDirectory = async (dir) => {
|
|
917
|
+
const entries = await fs7.promises.readdir(dir, { withFileTypes: true });
|
|
918
|
+
for (const entry of entries) {
|
|
919
|
+
const fullPath = path3.join(dir, entry.name);
|
|
920
|
+
if (entry.isDirectory()) {
|
|
921
|
+
if (!["node_modules", "dist", "build", ".git", ".next", "public", "ios", "android"].includes(entry.name))
|
|
922
|
+
await processDirectory(fullPath);
|
|
923
|
+
} else if (entry.isFile() && (entry.name.endsWith(".ts") || entry.name.endsWith(".tsx")))
|
|
924
|
+
files.push(fullPath);
|
|
891
925
|
}
|
|
892
|
-
}
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
const
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
const moduleSpecifier = node.moduleSpecifier;
|
|
908
|
-
if (ts2.isStringLiteral(moduleSpecifier))
|
|
909
|
-
imports.push(moduleSpecifier.text);
|
|
926
|
+
};
|
|
927
|
+
await processDirectory(directory);
|
|
928
|
+
return files;
|
|
929
|
+
}
|
|
930
|
+
async #analyzeFile(filePath, baseDir) {
|
|
931
|
+
if (this.#visitedFiles.has(filePath))
|
|
932
|
+
return;
|
|
933
|
+
this.#visitedFiles.add(filePath);
|
|
934
|
+
try {
|
|
935
|
+
const fileContent = await fs7.promises.readFile(filePath, "utf-8");
|
|
936
|
+
const imports = this.#extractImports(fileContent, filePath);
|
|
937
|
+
const resolvedImports = imports.map((importPath) => {
|
|
938
|
+
if (importPath.startsWith(".")) {
|
|
939
|
+
const resolvedPath = "./" + path3.join(path3.relative(baseDir, filePath), importPath);
|
|
940
|
+
return this.#ensureExtension(resolvedPath);
|
|
910
941
|
}
|
|
911
|
-
|
|
912
|
-
};
|
|
913
|
-
|
|
914
|
-
|
|
942
|
+
return importPath;
|
|
943
|
+
});
|
|
944
|
+
const relativePath = path3.relative(baseDir, filePath);
|
|
945
|
+
this.#fileDependencies.set(relativePath, resolvedImports);
|
|
946
|
+
} catch (error) {
|
|
915
947
|
}
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
948
|
+
}
|
|
949
|
+
#ensureExtension(filePath) {
|
|
950
|
+
if (fs7.existsSync(`${filePath}.ts`))
|
|
951
|
+
return `${filePath}.ts`;
|
|
952
|
+
else if (fs7.existsSync(`${filePath}.tsx`))
|
|
953
|
+
return `${filePath}.tsx`;
|
|
954
|
+
else if (fs7.existsSync(filePath))
|
|
955
|
+
return filePath;
|
|
956
|
+
return `${filePath}.ts`;
|
|
957
|
+
}
|
|
958
|
+
#extractImports(source, filePath) {
|
|
959
|
+
const imports = [];
|
|
960
|
+
const sourceFile = ts2.createSourceFile(filePath, source, ts2.ScriptTarget.Latest, true);
|
|
961
|
+
const visit = (node) => {
|
|
962
|
+
if (ts2.isImportDeclaration(node)) {
|
|
963
|
+
const moduleSpecifier = node.moduleSpecifier;
|
|
964
|
+
if (ts2.isStringLiteral(moduleSpecifier))
|
|
965
|
+
imports.push(moduleSpecifier.text);
|
|
966
|
+
}
|
|
967
|
+
ts2.forEachChild(node, visit);
|
|
968
|
+
};
|
|
969
|
+
visit(sourceFile);
|
|
970
|
+
return imports;
|
|
971
|
+
}
|
|
972
|
+
generateDependencyGraph() {
|
|
973
|
+
let graph = "Dependency Graph:\n\n";
|
|
974
|
+
for (const [file, imports] of this.#fileDependencies.entries()) {
|
|
975
|
+
graph += `${file}:
|
|
920
976
|
`;
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
977
|
+
const projectImports = imports.filter((i) => !i.startsWith("react") && !i.startsWith("@"));
|
|
978
|
+
const externalImports = imports.filter((i) => i.startsWith("react") || i.startsWith("@"));
|
|
979
|
+
if (projectImports.length > 0) {
|
|
980
|
+
graph += " Project dependencies:\n";
|
|
981
|
+
projectImports.forEach((imp) => {
|
|
982
|
+
graph += ` \u2192 ${imp}
|
|
927
983
|
`;
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
984
|
+
});
|
|
985
|
+
}
|
|
986
|
+
if (externalImports.length > 0) {
|
|
987
|
+
graph += " External dependencies:\n";
|
|
988
|
+
externalImports.forEach((imp) => {
|
|
989
|
+
graph += ` \u2192 ${imp}
|
|
934
990
|
`;
|
|
935
|
-
|
|
936
|
-
}
|
|
937
|
-
graph += "\n";
|
|
991
|
+
});
|
|
938
992
|
}
|
|
939
|
-
|
|
993
|
+
graph += "\n";
|
|
940
994
|
}
|
|
941
|
-
|
|
995
|
+
return graph;
|
|
996
|
+
}
|
|
997
|
+
};
|
|
942
998
|
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
});
|
|
968
|
-
});
|
|
969
|
-
}
|
|
970
|
-
spawn(command, args = [], options = {}) {
|
|
971
|
-
const proc = (0, import_child_process.spawn)(command, args, { cwd: this.cwdPath, stdio: "inherit", ...options });
|
|
972
|
-
proc.stderr?.on("data", (data) => {
|
|
973
|
-
Logger.raw(data.toString());
|
|
974
|
-
});
|
|
975
|
-
return new Promise((resolve, reject) => {
|
|
976
|
-
proc.on("exit", (code, signal) => {
|
|
977
|
-
if (!!code || signal)
|
|
978
|
-
reject({ code, signal });
|
|
979
|
-
else
|
|
980
|
-
resolve({ code, signal });
|
|
981
|
-
});
|
|
982
|
-
});
|
|
983
|
-
}
|
|
984
|
-
fork(modulePath, args = [], options = {}) {
|
|
985
|
-
const proc = (0, import_child_process.fork)(modulePath, args, {
|
|
986
|
-
cwd: this.cwdPath,
|
|
987
|
-
stdio: ["ignore", "inherit", "inherit", "ipc"],
|
|
988
|
-
...options
|
|
989
|
-
});
|
|
990
|
-
proc.stdout?.on("data", (data) => {
|
|
991
|
-
Logger.raw(data.toString());
|
|
999
|
+
// pkgs/@akanjs/devkit/src/executors.ts
|
|
1000
|
+
var Executor = class {
|
|
1001
|
+
logger;
|
|
1002
|
+
cwdPath;
|
|
1003
|
+
constructor(name, cwdPath) {
|
|
1004
|
+
this.logger = new Logger(name);
|
|
1005
|
+
this.cwdPath = cwdPath;
|
|
1006
|
+
if (!import_fs7.default.existsSync(cwdPath))
|
|
1007
|
+
import_fs7.default.mkdirSync(cwdPath, { recursive: true });
|
|
1008
|
+
}
|
|
1009
|
+
exec(command, options = {}) {
|
|
1010
|
+
const proc = (0, import_child_process.exec)(command, { cwd: this.cwdPath, ...options });
|
|
1011
|
+
proc.stdout?.on("data", (data) => {
|
|
1012
|
+
Logger.raw(data.toString());
|
|
1013
|
+
});
|
|
1014
|
+
proc.stderr?.on("data", (data) => {
|
|
1015
|
+
Logger.raw(data.toString());
|
|
1016
|
+
});
|
|
1017
|
+
return new Promise((resolve, reject) => {
|
|
1018
|
+
proc.on("exit", (code, signal) => {
|
|
1019
|
+
if (!!code || signal)
|
|
1020
|
+
reject({ code, signal });
|
|
1021
|
+
else
|
|
1022
|
+
resolve({ code, signal });
|
|
992
1023
|
});
|
|
993
|
-
|
|
994
|
-
|
|
1024
|
+
});
|
|
1025
|
+
}
|
|
1026
|
+
spawn(command, args = [], options = {}) {
|
|
1027
|
+
const proc = (0, import_child_process.spawn)(command, args, { cwd: this.cwdPath, stdio: "inherit", ...options });
|
|
1028
|
+
proc.stderr?.on("data", (data) => {
|
|
1029
|
+
Logger.raw(data.toString());
|
|
1030
|
+
});
|
|
1031
|
+
return new Promise((resolve, reject) => {
|
|
1032
|
+
proc.on("exit", (code, signal) => {
|
|
1033
|
+
if (!!code || signal)
|
|
1034
|
+
reject({ code, signal });
|
|
1035
|
+
else
|
|
1036
|
+
resolve({ code, signal });
|
|
995
1037
|
});
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1038
|
+
});
|
|
1039
|
+
}
|
|
1040
|
+
fork(modulePath, args = [], options = {}) {
|
|
1041
|
+
const proc = (0, import_child_process.fork)(modulePath, args, {
|
|
1042
|
+
cwd: this.cwdPath,
|
|
1043
|
+
stdio: ["ignore", "inherit", "inherit", "ipc"],
|
|
1044
|
+
...options
|
|
1045
|
+
});
|
|
1046
|
+
proc.stdout?.on("data", (data) => {
|
|
1047
|
+
Logger.raw(data.toString());
|
|
1048
|
+
});
|
|
1049
|
+
proc.stderr?.on("data", (data) => {
|
|
1050
|
+
Logger.raw(data.toString());
|
|
1051
|
+
});
|
|
1052
|
+
return new Promise((resolve, reject) => {
|
|
1053
|
+
proc.on("exit", (code, signal) => {
|
|
1054
|
+
if (!!code || signal)
|
|
1055
|
+
reject({ code, signal });
|
|
1056
|
+
else
|
|
1057
|
+
resolve({ code, signal });
|
|
1003
1058
|
});
|
|
1004
|
-
}
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
this.logger.verbose(`File ${writePath} is changed`);
|
|
1025
|
-
}
|
|
1026
|
-
} else {
|
|
1059
|
+
});
|
|
1060
|
+
}
|
|
1061
|
+
mkdir(dirPath) {
|
|
1062
|
+
const writePath = import_path3.default.isAbsolute(dirPath) ? dirPath : `${this.cwdPath}/${dirPath}`;
|
|
1063
|
+
if (!import_fs7.default.existsSync(writePath))
|
|
1064
|
+
import_fs7.default.mkdirSync(writePath, { recursive: true });
|
|
1065
|
+
this.logger.verbose(`Make directory ${writePath}`);
|
|
1066
|
+
return this;
|
|
1067
|
+
}
|
|
1068
|
+
writeFile(filePath, content) {
|
|
1069
|
+
const writePath = import_path3.default.isAbsolute(filePath) ? filePath : `${this.cwdPath}/${filePath}`;
|
|
1070
|
+
const dir = import_path3.default.dirname(writePath);
|
|
1071
|
+
if (!import_fs7.default.existsSync(dir))
|
|
1072
|
+
import_fs7.default.mkdirSync(dir, { recursive: true });
|
|
1073
|
+
const contentStr = typeof content === "string" ? content : JSON.stringify(content, null, 2);
|
|
1074
|
+
if (import_fs7.default.existsSync(writePath)) {
|
|
1075
|
+
const currentContent = import_fs7.default.readFileSync(writePath, "utf8");
|
|
1076
|
+
if (currentContent === contentStr)
|
|
1077
|
+
this.logger.verbose(`File ${writePath} is unchanged`);
|
|
1078
|
+
else {
|
|
1027
1079
|
import_fs7.default.writeFileSync(writePath, contentStr, "utf8");
|
|
1028
|
-
this.logger.verbose(`File ${writePath} is
|
|
1029
|
-
}
|
|
1030
|
-
return this;
|
|
1031
|
-
}
|
|
1032
|
-
writeJson(filePath, content) {
|
|
1033
|
-
this.writeFile(filePath, JSON.stringify(content, null, 2));
|
|
1034
|
-
return this;
|
|
1035
|
-
}
|
|
1036
|
-
readFile(filePath) {
|
|
1037
|
-
const readPath = import_path3.default.isAbsolute(filePath) ? filePath : `${this.cwdPath}/${filePath}`;
|
|
1038
|
-
return import_fs7.default.readFileSync(readPath, "utf8");
|
|
1039
|
-
}
|
|
1040
|
-
readJson(filePath) {
|
|
1041
|
-
const readPath = import_path3.default.isAbsolute(filePath) ? filePath : `${this.cwdPath}/${filePath}`;
|
|
1042
|
-
return JSON.parse(import_fs7.default.readFileSync(readPath, "utf8"));
|
|
1043
|
-
}
|
|
1044
|
-
async cp(srcPath, destPath) {
|
|
1045
|
-
const src = import_path3.default.isAbsolute(srcPath) ? srcPath : `${this.cwdPath}/${srcPath}`;
|
|
1046
|
-
const dest = import_path3.default.isAbsolute(destPath) ? destPath : `${this.cwdPath}/${destPath}`;
|
|
1047
|
-
await import_promises.default.cp(src, dest, { recursive: true });
|
|
1048
|
-
}
|
|
1049
|
-
log(msg) {
|
|
1050
|
-
this.logger.info(msg);
|
|
1051
|
-
return this;
|
|
1052
|
-
}
|
|
1053
|
-
verbose(msg) {
|
|
1054
|
-
this.logger.verbose(msg);
|
|
1055
|
-
return this;
|
|
1056
|
-
}
|
|
1057
|
-
getTsConfig(pathname) {
|
|
1058
|
-
const tsconfig = this.readJson(pathname);
|
|
1059
|
-
if (tsconfig.extends) {
|
|
1060
|
-
const extendsTsconfig = this.getTsConfig(tsconfig.extends);
|
|
1061
|
-
return {
|
|
1062
|
-
...extendsTsconfig,
|
|
1063
|
-
...tsconfig,
|
|
1064
|
-
compilerOptions: { ...extendsTsconfig.compilerOptions, ...tsconfig.compilerOptions }
|
|
1065
|
-
};
|
|
1066
|
-
}
|
|
1067
|
-
return tsconfig;
|
|
1068
|
-
}
|
|
1069
|
-
async #applyTemplateFile({
|
|
1070
|
-
templatePath,
|
|
1071
|
-
targetPath,
|
|
1072
|
-
scanResult
|
|
1073
|
-
}, dict = {}) {
|
|
1074
|
-
if (targetPath.endsWith(".js")) {
|
|
1075
|
-
const getContent = await import(templatePath);
|
|
1076
|
-
const content = getContent.default(scanResult ?? null, dict);
|
|
1077
|
-
const convertedTargetPath = Object.entries(dict).reduce(
|
|
1078
|
-
(path5, [key, value]) => path5.replace(new RegExp(`__${key}__`, "g"), value),
|
|
1079
|
-
targetPath.replace(".js", ".ts")
|
|
1080
|
-
);
|
|
1081
|
-
if (content === null)
|
|
1082
|
-
return;
|
|
1083
|
-
this.logger.verbose(`Apply template ${templatePath} to ${convertedTargetPath}`);
|
|
1084
|
-
this.writeFile(convertedTargetPath, content);
|
|
1085
|
-
} else if (targetPath.endsWith(".template")) {
|
|
1086
|
-
const content = await import_promises.default.readFile(templatePath, "utf8");
|
|
1087
|
-
const convertedTargetPath = Object.entries(dict).reduce(
|
|
1088
|
-
(path5, [key, value]) => path5.replace(new RegExp(`__${key}__`, "g"), value),
|
|
1089
|
-
targetPath.slice(0, -9)
|
|
1090
|
-
);
|
|
1091
|
-
const convertedContent = Object.entries(dict).reduce(
|
|
1092
|
-
(content2, [key, value]) => content2.replace(new RegExp(`<%= ${key} %>`, "g"), value),
|
|
1093
|
-
content
|
|
1094
|
-
);
|
|
1095
|
-
this.logger.verbose(`Apply template ${templatePath} to ${convertedTargetPath}`);
|
|
1096
|
-
this.writeFile(convertedTargetPath, convertedContent);
|
|
1097
|
-
}
|
|
1098
|
-
}
|
|
1099
|
-
async applyTemplate({
|
|
1100
|
-
basePath: basePath2,
|
|
1101
|
-
template,
|
|
1102
|
-
scanResult,
|
|
1103
|
-
dict = {}
|
|
1104
|
-
}) {
|
|
1105
|
-
const templatePath = `${__dirname}/src/templates${template ? `/${template}` : ""}`.replace(".ts", ".js");
|
|
1106
|
-
if (import_fs7.default.statSync(templatePath).isFile()) {
|
|
1107
|
-
const filename = import_path3.default.basename(templatePath);
|
|
1108
|
-
await this.#applyTemplateFile({ templatePath, targetPath: import_path3.default.join(basePath2, filename), scanResult }, dict);
|
|
1109
|
-
} else {
|
|
1110
|
-
if (!import_fs7.default.existsSync(basePath2))
|
|
1111
|
-
await import_promises.default.mkdir(basePath2, { recursive: true });
|
|
1112
|
-
const subdirs = await import_promises.default.readdir(templatePath);
|
|
1113
|
-
await Promise.all(
|
|
1114
|
-
subdirs.map(async (subdir) => {
|
|
1115
|
-
const subpath = import_path3.default.join(templatePath, subdir);
|
|
1116
|
-
if (import_fs7.default.statSync(subpath).isFile())
|
|
1117
|
-
await this.#applyTemplateFile(
|
|
1118
|
-
{ templatePath: subpath, targetPath: import_path3.default.join(basePath2, subdir), scanResult },
|
|
1119
|
-
dict
|
|
1120
|
-
);
|
|
1121
|
-
else
|
|
1122
|
-
await this.applyTemplate({
|
|
1123
|
-
basePath: import_path3.default.join(basePath2, subdir),
|
|
1124
|
-
template: import_path3.default.join(template, subdir),
|
|
1125
|
-
scanResult,
|
|
1126
|
-
dict
|
|
1127
|
-
});
|
|
1128
|
-
})
|
|
1129
|
-
);
|
|
1080
|
+
this.logger.verbose(`File ${writePath} is changed`);
|
|
1130
1081
|
}
|
|
1131
|
-
}
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
)
|
|
1167
|
-
]);
|
|
1082
|
+
} else {
|
|
1083
|
+
import_fs7.default.writeFileSync(writePath, contentStr, "utf8");
|
|
1084
|
+
this.logger.verbose(`File ${writePath} is created`);
|
|
1085
|
+
}
|
|
1086
|
+
return this;
|
|
1087
|
+
}
|
|
1088
|
+
writeJson(filePath, content) {
|
|
1089
|
+
this.writeFile(filePath, JSON.stringify(content, null, 2));
|
|
1090
|
+
return this;
|
|
1091
|
+
}
|
|
1092
|
+
readFile(filePath) {
|
|
1093
|
+
const readPath = import_path3.default.isAbsolute(filePath) ? filePath : `${this.cwdPath}/${filePath}`;
|
|
1094
|
+
return import_fs7.default.readFileSync(readPath, "utf8");
|
|
1095
|
+
}
|
|
1096
|
+
readJson(filePath) {
|
|
1097
|
+
const readPath = import_path3.default.isAbsolute(filePath) ? filePath : `${this.cwdPath}/${filePath}`;
|
|
1098
|
+
return JSON.parse(import_fs7.default.readFileSync(readPath, "utf8"));
|
|
1099
|
+
}
|
|
1100
|
+
async cp(srcPath, destPath) {
|
|
1101
|
+
const src = import_path3.default.isAbsolute(srcPath) ? srcPath : `${this.cwdPath}/${srcPath}`;
|
|
1102
|
+
const dest = import_path3.default.isAbsolute(destPath) ? destPath : `${this.cwdPath}/${destPath}`;
|
|
1103
|
+
await import_promises.default.cp(src, dest, { recursive: true });
|
|
1104
|
+
}
|
|
1105
|
+
log(msg) {
|
|
1106
|
+
this.logger.info(msg);
|
|
1107
|
+
return this;
|
|
1108
|
+
}
|
|
1109
|
+
verbose(msg) {
|
|
1110
|
+
this.logger.verbose(msg);
|
|
1111
|
+
return this;
|
|
1112
|
+
}
|
|
1113
|
+
getTsConfig(pathname) {
|
|
1114
|
+
const tsconfig = this.readJson(pathname);
|
|
1115
|
+
if (tsconfig.extends) {
|
|
1116
|
+
const extendsTsconfig = this.getTsConfig(tsconfig.extends);
|
|
1168
1117
|
return {
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
apps: Object.fromEntries(appScanResults.map((app) => [app.name, app])),
|
|
1173
|
-
libs: Object.fromEntries(libScanResults.map((lib) => [lib.name, lib])),
|
|
1174
|
-
pkgs: Object.fromEntries(pkgScanResults.map((pkg) => [pkg.name, pkg]))
|
|
1118
|
+
...extendsTsconfig,
|
|
1119
|
+
...tsconfig,
|
|
1120
|
+
compilerOptions: { ...extendsTsconfig.compilerOptions, ...tsconfig.compilerOptions }
|
|
1175
1121
|
};
|
|
1176
1122
|
}
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
async #getDirHasFile(basePath2, targetFilename) {
|
|
1191
|
-
const AVOID_DIRS = ["node_modules", "dist", "public", "./next"];
|
|
1192
|
-
const getDirs = async (dirname, maxDepth = 3, results = [], prefix = "") => {
|
|
1193
|
-
const dirs = await import_promises.default.readdir(dirname);
|
|
1194
|
-
await Promise.all(
|
|
1195
|
-
dirs.map(async (dir) => {
|
|
1196
|
-
if (AVOID_DIRS.includes(dir))
|
|
1197
|
-
return;
|
|
1198
|
-
const dirPath = import_path3.default.join(dirname, dir);
|
|
1199
|
-
if (import_fs7.default.lstatSync(dirPath).isDirectory()) {
|
|
1200
|
-
const hasTargetFile = import_fs7.default.existsSync(import_path3.default.join(dirPath, targetFilename));
|
|
1201
|
-
if (hasTargetFile)
|
|
1202
|
-
results.push(`${prefix}${dir}`);
|
|
1203
|
-
if (maxDepth > 0)
|
|
1204
|
-
await getDirs(dirPath, maxDepth - 1, results, `${prefix}${dir}/`);
|
|
1205
|
-
}
|
|
1206
|
-
})
|
|
1207
|
-
);
|
|
1208
|
-
return results;
|
|
1209
|
-
};
|
|
1210
|
-
return await getDirs(basePath2);
|
|
1211
|
-
}
|
|
1212
|
-
};
|
|
1213
|
-
var SysExecutor = class extends Executor {
|
|
1214
|
-
workspace;
|
|
1215
|
-
name;
|
|
1216
|
-
type;
|
|
1217
|
-
constructor({ workspace = WorkspaceExecutor.fromRoot(), name, type }) {
|
|
1218
|
-
super(`${name} Sys Executor`, `${workspace.workspaceRoot}/${type}s/${name}`);
|
|
1219
|
-
this.workspace = workspace;
|
|
1220
|
-
this.name = name;
|
|
1221
|
-
this.type = type;
|
|
1222
|
-
}
|
|
1223
|
-
async getConfig(command) {
|
|
1224
|
-
return this.type === "app" ? await getAppConfig(this.cwdPath, { ...baseDevEnv, appName: this.name, command }) : await getLibConfig(this.cwdPath, { ...baseDevEnv, appName: this.name, command });
|
|
1225
|
-
}
|
|
1226
|
-
async scan({
|
|
1227
|
-
tsconfig = this.getTsConfig(`${this.cwdPath}/tsconfig.json`),
|
|
1228
|
-
akanConfig
|
|
1229
|
-
}, libScanResults = {}) {
|
|
1230
|
-
if (libScanResults[this.name])
|
|
1231
|
-
return libScanResults[this.name];
|
|
1232
|
-
const rootPackageJson = this.readJson(`${this.workspace.workspaceRoot}/package.json`);
|
|
1233
|
-
const scanner = new TypeScriptDependencyScanner(this.cwdPath);
|
|
1234
|
-
const npmSet = new Set(Object.keys({ ...rootPackageJson.dependencies, ...rootPackageJson.devDependencies }));
|
|
1235
|
-
const pkgPathSet = new Set(
|
|
1236
|
-
Object.keys(tsconfig.compilerOptions.paths).filter((path5) => tsconfig.compilerOptions.paths[path5].some((resolve) => resolve.startsWith("pkgs/"))).map((path5) => path5.replace("/*", ""))
|
|
1123
|
+
return tsconfig;
|
|
1124
|
+
}
|
|
1125
|
+
async #applyTemplateFile({
|
|
1126
|
+
templatePath,
|
|
1127
|
+
targetPath,
|
|
1128
|
+
scanResult
|
|
1129
|
+
}, dict = {}) {
|
|
1130
|
+
if (targetPath.endsWith(".js")) {
|
|
1131
|
+
const getContent = await import(templatePath);
|
|
1132
|
+
const content = getContent.default(scanResult ?? null, dict);
|
|
1133
|
+
const convertedTargetPath = Object.entries(dict).reduce(
|
|
1134
|
+
(path5, [key, value]) => path5.replace(new RegExp(`__${key}__`, "g"), value),
|
|
1135
|
+
targetPath.replace(".js", ".ts")
|
|
1237
1136
|
);
|
|
1238
|
-
|
|
1239
|
-
|
|
1137
|
+
if (content === null)
|
|
1138
|
+
return;
|
|
1139
|
+
this.logger.verbose(`Apply template ${templatePath} to ${convertedTargetPath}`);
|
|
1140
|
+
this.writeFile(convertedTargetPath, content);
|
|
1141
|
+
} else if (targetPath.endsWith(".template")) {
|
|
1142
|
+
const content = await import_promises.default.readFile(templatePath, "utf8");
|
|
1143
|
+
const convertedTargetPath = Object.entries(dict).reduce(
|
|
1144
|
+
(path5, [key, value]) => path5.replace(new RegExp(`__${key}__`, "g"), value),
|
|
1145
|
+
targetPath.slice(0, -9)
|
|
1240
1146
|
);
|
|
1241
|
-
const
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
return tsconfig.compilerOptions.paths[path5][0].split("/").slice(1, 1 + pathSplitLength).join("/");
|
|
1245
|
-
});
|
|
1246
|
-
const libDeps = [...libPathDepSet].map((path5) => {
|
|
1247
|
-
const pathSplitLength = path5.split("/").length;
|
|
1248
|
-
return tsconfig.compilerOptions.paths[path5][0].split("/").slice(1, 1 + pathSplitLength).join("/");
|
|
1249
|
-
}).filter((libName) => libName !== this.name);
|
|
1250
|
-
if (!import_fs7.default.existsSync(`${this.cwdPath}/lib/__scalar`))
|
|
1251
|
-
import_fs7.default.mkdirSync(`${this.cwdPath}/lib/__scalar`, { recursive: true });
|
|
1252
|
-
const files = getDefaultFileScan();
|
|
1253
|
-
const dirnames = (await import_promises.default.readdir(`${this.cwdPath}/lib`)).filter(
|
|
1254
|
-
(name) => import_fs7.default.lstatSync(`${this.cwdPath}/lib/${name}`).isDirectory()
|
|
1147
|
+
const convertedContent = Object.entries(dict).reduce(
|
|
1148
|
+
(content2, [key, value]) => content2.replace(new RegExp(`<%= ${key} %>`, "g"), value),
|
|
1149
|
+
content
|
|
1255
1150
|
);
|
|
1256
|
-
|
|
1257
|
-
|
|
1151
|
+
this.logger.verbose(`Apply template ${templatePath} to ${convertedTargetPath}`);
|
|
1152
|
+
this.writeFile(convertedTargetPath, convertedContent);
|
|
1153
|
+
}
|
|
1154
|
+
}
|
|
1155
|
+
async applyTemplate({
|
|
1156
|
+
basePath: basePath2,
|
|
1157
|
+
template,
|
|
1158
|
+
scanResult,
|
|
1159
|
+
dict = {}
|
|
1160
|
+
}) {
|
|
1161
|
+
const templatePath = `${__dirname}/src/templates${template ? `/${template}` : ""}`.replace(".ts", ".js");
|
|
1162
|
+
if (import_fs7.default.statSync(templatePath).isFile()) {
|
|
1163
|
+
const filename = import_path3.default.basename(templatePath);
|
|
1164
|
+
await this.#applyTemplateFile({ templatePath, targetPath: import_path3.default.join(basePath2, filename), scanResult }, dict);
|
|
1165
|
+
} else {
|
|
1166
|
+
if (!import_fs7.default.existsSync(basePath2))
|
|
1167
|
+
await import_promises.default.mkdir(basePath2, { recursive: true });
|
|
1168
|
+
const subdirs = await import_promises.default.readdir(templatePath);
|
|
1258
1169
|
await Promise.all(
|
|
1259
|
-
|
|
1260
|
-
const
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
files.store.databases.push(name);
|
|
1274
|
-
else if (filename === "index.tsx")
|
|
1275
|
-
files.components.databases.push(name);
|
|
1276
|
-
});
|
|
1170
|
+
subdirs.map(async (subdir) => {
|
|
1171
|
+
const subpath = import_path3.default.join(templatePath, subdir);
|
|
1172
|
+
if (import_fs7.default.statSync(subpath).isFile())
|
|
1173
|
+
await this.#applyTemplateFile(
|
|
1174
|
+
{ templatePath: subpath, targetPath: import_path3.default.join(basePath2, subdir), scanResult },
|
|
1175
|
+
dict
|
|
1176
|
+
);
|
|
1177
|
+
else
|
|
1178
|
+
await this.applyTemplate({
|
|
1179
|
+
basePath: import_path3.default.join(basePath2, subdir),
|
|
1180
|
+
template: import_path3.default.join(template, subdir),
|
|
1181
|
+
scanResult,
|
|
1182
|
+
dict
|
|
1183
|
+
});
|
|
1277
1184
|
})
|
|
1278
1185
|
);
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1186
|
+
}
|
|
1187
|
+
}
|
|
1188
|
+
};
|
|
1189
|
+
var WorkspaceExecutor = class _WorkspaceExecutor extends Executor {
|
|
1190
|
+
workspaceRoot;
|
|
1191
|
+
repoName;
|
|
1192
|
+
constructor({ workspaceRoot, repoName }) {
|
|
1193
|
+
super(`${repoName} Executor`, workspaceRoot);
|
|
1194
|
+
this.workspaceRoot = workspaceRoot;
|
|
1195
|
+
this.repoName = repoName;
|
|
1196
|
+
}
|
|
1197
|
+
static fromRoot() {
|
|
1198
|
+
const repoName = import_path3.default.basename(process.cwd());
|
|
1199
|
+
return new _WorkspaceExecutor({ workspaceRoot: process.cwd(), repoName });
|
|
1200
|
+
}
|
|
1201
|
+
async scan() {
|
|
1202
|
+
const [appNames, libNames, pkgNames] = await Promise.all([this.getApps(), this.getLibs(), this.getPkgs()]);
|
|
1203
|
+
const [appScanResults, libScanResults, pkgScanResults] = await Promise.all([
|
|
1204
|
+
Promise.all(
|
|
1205
|
+
appNames.map(async (appName) => {
|
|
1206
|
+
const app = AppExecutor.from(this, appName);
|
|
1207
|
+
const akanConfig = await app.getConfig("scan");
|
|
1208
|
+
return await app.scan({ akanConfig });
|
|
1295
1209
|
})
|
|
1296
|
-
)
|
|
1297
|
-
|
|
1298
|
-
(
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
const filenames = await import_promises.default.readdir(import_path3.default.join(this.cwdPath, "lib/__scalar", name));
|
|
1303
|
-
filenames.forEach((filename) => {
|
|
1304
|
-
if (filename.endsWith(".constant.ts"))
|
|
1305
|
-
files.constants.scalars.push(name);
|
|
1306
|
-
else if (filename.endsWith(".dictionary.ts"))
|
|
1307
|
-
files.dictionary.scalars.push(name);
|
|
1308
|
-
else if (filename.endsWith(".document.ts"))
|
|
1309
|
-
files.documents.scalars.push(name);
|
|
1310
|
-
else if (filename.endsWith(".service.ts"))
|
|
1311
|
-
files.services.scalars.push(name);
|
|
1312
|
-
else if (filename.endsWith(".signal.ts"))
|
|
1313
|
-
files.signal.scalars.push(name);
|
|
1314
|
-
else if (filename.endsWith(".store.ts"))
|
|
1315
|
-
files.store.scalars.push(name);
|
|
1316
|
-
else if (filename === "index.ts")
|
|
1317
|
-
files.components.scalars.push(name);
|
|
1318
|
-
});
|
|
1210
|
+
),
|
|
1211
|
+
Promise.all(
|
|
1212
|
+
libNames.map(async (libName) => {
|
|
1213
|
+
const lib = LibExecutor.from(this, libName);
|
|
1214
|
+
const akanConfig = await lib.getConfig("scan");
|
|
1215
|
+
return await lib.scan({ akanConfig });
|
|
1319
1216
|
})
|
|
1320
|
-
)
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
return scanResult;
|
|
1354
|
-
}
|
|
1355
|
-
async getDatabaseModules() {
|
|
1356
|
-
const databaseModules = (await import_promises.default.readdir(`${this.cwdPath}/lib`)).filter((name) => !name.startsWith("_")).filter((name) => import_fs7.default.existsSync(`${this.cwdPath}/lib/${name}/${name}.constant.ts`));
|
|
1357
|
-
return databaseModules;
|
|
1358
|
-
}
|
|
1359
|
-
async getServiceModules() {
|
|
1360
|
-
const serviceModules = (await import_promises.default.readdir(`${this.cwdPath}/lib`)).filter((name) => name.startsWith("_") && !name.startsWith("__")).filter((name) => import_fs7.default.existsSync(`${this.cwdPath}/lib/${name}/${name}.service.ts`));
|
|
1361
|
-
return serviceModules;
|
|
1362
|
-
}
|
|
1363
|
-
async getScalarModules() {
|
|
1364
|
-
const scalarModules = (await import_promises.default.readdir(`${this.cwdPath}/lib/__scalar`)).filter((name) => !name.startsWith("_")).filter((name) => import_fs7.default.existsSync(`${this.cwdPath}/lib/__scalar/${name}/${name}.constant.ts`));
|
|
1365
|
-
return scalarModules;
|
|
1366
|
-
}
|
|
1367
|
-
};
|
|
1368
|
-
var AppExecutor = class _AppExecutor extends SysExecutor {
|
|
1369
|
-
constructor({ workspace, name }) {
|
|
1370
|
-
super({ workspace, name, type: "app" });
|
|
1371
|
-
}
|
|
1372
|
-
static from(executor, name) {
|
|
1373
|
-
if (executor instanceof WorkspaceExecutor)
|
|
1374
|
-
return new _AppExecutor({ workspace: executor, name });
|
|
1375
|
-
return new _AppExecutor({ workspace: executor.workspace, name });
|
|
1376
|
-
}
|
|
1377
|
-
async getConfig(command) {
|
|
1378
|
-
return await getAppConfig(this.cwdPath, { ...baseDevEnv, appName: this.name, command });
|
|
1379
|
-
}
|
|
1380
|
-
async syncAssets(libDeps) {
|
|
1381
|
-
const projectPublicLibPath = `${this.cwdPath}/public/libs`;
|
|
1382
|
-
if (import_fs7.default.existsSync(projectPublicLibPath))
|
|
1383
|
-
await import_promises.default.rm(projectPublicLibPath, { recursive: true });
|
|
1384
|
-
const targetDeps = libDeps.filter((dep) => import_fs7.default.existsSync(`${this.workspace.workspaceRoot}/libs/${dep}/public`));
|
|
1385
|
-
await Promise.all(targetDeps.map((dep) => import_promises.default.mkdir(`${projectPublicLibPath}/${dep}`, { recursive: true })));
|
|
1217
|
+
),
|
|
1218
|
+
Promise.all(
|
|
1219
|
+
pkgNames.map(async (pkgName) => {
|
|
1220
|
+
return await PkgExecutor.from(this, pkgName).scan();
|
|
1221
|
+
})
|
|
1222
|
+
)
|
|
1223
|
+
]);
|
|
1224
|
+
return {
|
|
1225
|
+
appNames,
|
|
1226
|
+
libNames,
|
|
1227
|
+
pkgNames,
|
|
1228
|
+
apps: Object.fromEntries(appScanResults.map((app) => [app.name, app])),
|
|
1229
|
+
libs: Object.fromEntries(libScanResults.map((lib) => [lib.name, lib])),
|
|
1230
|
+
pkgs: Object.fromEntries(pkgScanResults.map((pkg) => [pkg.name, pkg]))
|
|
1231
|
+
};
|
|
1232
|
+
}
|
|
1233
|
+
async getApps() {
|
|
1234
|
+
return await this.#getDirHasFile(`${this.workspaceRoot}/apps`, "akan.config.ts");
|
|
1235
|
+
}
|
|
1236
|
+
async getLibs() {
|
|
1237
|
+
return await this.#getDirHasFile(`${this.workspaceRoot}/libs`, "akan.config.ts");
|
|
1238
|
+
}
|
|
1239
|
+
async getSyss() {
|
|
1240
|
+
const [appNames, libNames] = await Promise.all([this.getApps(), this.getLibs()]);
|
|
1241
|
+
return [appNames, libNames];
|
|
1242
|
+
}
|
|
1243
|
+
async getPkgs() {
|
|
1244
|
+
return await this.#getDirHasFile(`${this.workspaceRoot}/pkgs`, "package.json");
|
|
1245
|
+
}
|
|
1246
|
+
async #getDirHasFile(basePath2, targetFilename) {
|
|
1247
|
+
const AVOID_DIRS = ["node_modules", "dist", "public", "./next"];
|
|
1248
|
+
const getDirs = async (dirname, maxDepth = 3, results = [], prefix = "") => {
|
|
1249
|
+
const dirs = await import_promises.default.readdir(dirname);
|
|
1386
1250
|
await Promise.all(
|
|
1387
|
-
|
|
1388
|
-
(
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1251
|
+
dirs.map(async (dir) => {
|
|
1252
|
+
if (AVOID_DIRS.includes(dir))
|
|
1253
|
+
return;
|
|
1254
|
+
const dirPath = import_path3.default.join(dirname, dir);
|
|
1255
|
+
if (import_fs7.default.lstatSync(dirPath).isDirectory()) {
|
|
1256
|
+
const hasTargetFile = import_fs7.default.existsSync(import_path3.default.join(dirPath, targetFilename));
|
|
1257
|
+
if (hasTargetFile)
|
|
1258
|
+
results.push(`${prefix}${dir}`);
|
|
1259
|
+
if (maxDepth > 0)
|
|
1260
|
+
await getDirs(dirPath, maxDepth - 1, results, `${prefix}${dir}/`);
|
|
1261
|
+
}
|
|
1262
|
+
})
|
|
1392
1263
|
);
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
}
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
return
|
|
1417
|
-
}
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
this.
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1264
|
+
return results;
|
|
1265
|
+
};
|
|
1266
|
+
return await getDirs(basePath2);
|
|
1267
|
+
}
|
|
1268
|
+
};
|
|
1269
|
+
var SysExecutor = class extends Executor {
|
|
1270
|
+
workspace;
|
|
1271
|
+
name;
|
|
1272
|
+
type;
|
|
1273
|
+
constructor({ workspace = WorkspaceExecutor.fromRoot(), name, type }) {
|
|
1274
|
+
super(`${name} Sys Executor`, `${workspace.workspaceRoot}/${type}s/${name}`);
|
|
1275
|
+
this.workspace = workspace;
|
|
1276
|
+
this.name = name;
|
|
1277
|
+
this.type = type;
|
|
1278
|
+
}
|
|
1279
|
+
async getConfig(command) {
|
|
1280
|
+
return this.type === "app" ? await getAppConfig(this.cwdPath, { ...getBaseDevEnv(), appName: this.name, command }) : await getLibConfig(this.cwdPath, { ...getBaseDevEnv(), appName: this.name, command });
|
|
1281
|
+
}
|
|
1282
|
+
async scan({
|
|
1283
|
+
tsconfig = this.getTsConfig(`${this.cwdPath}/tsconfig.json`),
|
|
1284
|
+
akanConfig
|
|
1285
|
+
}, libScanResults = {}) {
|
|
1286
|
+
if (libScanResults[this.name])
|
|
1287
|
+
return libScanResults[this.name];
|
|
1288
|
+
const rootPackageJson = this.readJson(`${this.workspace.workspaceRoot}/package.json`);
|
|
1289
|
+
const scanner = new TypeScriptDependencyScanner(this.cwdPath);
|
|
1290
|
+
const npmSet = new Set(Object.keys({ ...rootPackageJson.dependencies, ...rootPackageJson.devDependencies }));
|
|
1291
|
+
const pkgPathSet = new Set(
|
|
1292
|
+
Object.keys(tsconfig.compilerOptions.paths).filter((path5) => tsconfig.compilerOptions.paths[path5].some((resolve) => resolve.startsWith("pkgs/"))).map((path5) => path5.replace("/*", ""))
|
|
1293
|
+
);
|
|
1294
|
+
const libPathSet = new Set(
|
|
1295
|
+
Object.keys(tsconfig.compilerOptions.paths).filter((path5) => tsconfig.compilerOptions.paths[path5].some((resolve) => resolve.startsWith("libs/"))).map((path5) => path5.replace("/*", ""))
|
|
1296
|
+
);
|
|
1297
|
+
const [npmDepSet, pkgPathDepSet, libPathDepSet] = await scanner.getImportSets([npmSet, pkgPathSet, libPathSet]);
|
|
1298
|
+
const pkgDeps = [...pkgPathDepSet].map((path5) => {
|
|
1299
|
+
const pathSplitLength = path5.split("/").length;
|
|
1300
|
+
return tsconfig.compilerOptions.paths[path5][0].split("/").slice(1, 1 + pathSplitLength).join("/");
|
|
1301
|
+
});
|
|
1302
|
+
const libDeps = [...libPathDepSet].map((path5) => {
|
|
1303
|
+
const pathSplitLength = path5.split("/").length;
|
|
1304
|
+
return tsconfig.compilerOptions.paths[path5][0].split("/").slice(1, 1 + pathSplitLength).join("/");
|
|
1305
|
+
}).filter((libName) => libName !== this.name);
|
|
1306
|
+
if (!import_fs7.default.existsSync(`${this.cwdPath}/lib/__scalar`))
|
|
1307
|
+
import_fs7.default.mkdirSync(`${this.cwdPath}/lib/__scalar`, { recursive: true });
|
|
1308
|
+
const files = getDefaultFileScan();
|
|
1309
|
+
const dirnames = (await import_promises.default.readdir(`${this.cwdPath}/lib`)).filter(
|
|
1310
|
+
(name) => import_fs7.default.lstatSync(`${this.cwdPath}/lib/${name}`).isDirectory()
|
|
1311
|
+
);
|
|
1312
|
+
const databaseDirs = dirnames.filter((name) => !name.startsWith("_"));
|
|
1313
|
+
const serviceDirs = dirnames.filter((name) => name.startsWith("_") && !name.startsWith("__"));
|
|
1314
|
+
await Promise.all(
|
|
1315
|
+
databaseDirs.map(async (name) => {
|
|
1316
|
+
const filenames = await import_promises.default.readdir(import_path3.default.join(this.cwdPath, "lib", name));
|
|
1317
|
+
filenames.forEach((filename) => {
|
|
1318
|
+
if (filename.endsWith(".constant.ts"))
|
|
1319
|
+
files.constants.databases.push(name);
|
|
1320
|
+
else if (filename.endsWith(".dictionary.ts"))
|
|
1321
|
+
files.dictionary.databases.push(name);
|
|
1322
|
+
else if (filename.endsWith(".document.ts"))
|
|
1323
|
+
files.documents.databases.push(name);
|
|
1324
|
+
else if (filename.endsWith(".service.ts"))
|
|
1325
|
+
files.services.databases.push(name);
|
|
1326
|
+
else if (filename.endsWith(".signal.ts"))
|
|
1327
|
+
files.signal.databases.push(name);
|
|
1328
|
+
else if (filename.endsWith(".store.ts"))
|
|
1329
|
+
files.store.databases.push(name);
|
|
1330
|
+
else if (filename === "index.tsx")
|
|
1331
|
+
files.components.databases.push(name);
|
|
1332
|
+
});
|
|
1333
|
+
})
|
|
1334
|
+
);
|
|
1335
|
+
await Promise.all(
|
|
1336
|
+
serviceDirs.map(async (dirname) => {
|
|
1337
|
+
const name = dirname.slice(1);
|
|
1338
|
+
const filenames = await import_promises.default.readdir(import_path3.default.join(this.cwdPath, "lib", dirname));
|
|
1339
|
+
filenames.forEach((filename) => {
|
|
1340
|
+
if (filename.endsWith(".dictionary.ts"))
|
|
1341
|
+
files.dictionary.services.push(name);
|
|
1342
|
+
else if (filename.endsWith(".service.ts"))
|
|
1343
|
+
files.services.services.push(name);
|
|
1344
|
+
else if (filename.endsWith(".signal.ts"))
|
|
1345
|
+
files.signal.services.push(name);
|
|
1346
|
+
else if (filename.endsWith(".store.ts"))
|
|
1347
|
+
files.store.services.push(name);
|
|
1348
|
+
else if (filename === "index.tsx")
|
|
1349
|
+
files.components.services.push(name);
|
|
1350
|
+
});
|
|
1351
|
+
})
|
|
1352
|
+
);
|
|
1353
|
+
const scalarDirs = (await import_promises.default.readdir(`${this.cwdPath}/lib/__scalar`)).filter(
|
|
1354
|
+
(name) => !name.startsWith("_")
|
|
1355
|
+
);
|
|
1356
|
+
await Promise.all(
|
|
1357
|
+
scalarDirs.map(async (name) => {
|
|
1358
|
+
const filenames = await import_promises.default.readdir(import_path3.default.join(this.cwdPath, "lib/__scalar", name));
|
|
1359
|
+
filenames.forEach((filename) => {
|
|
1360
|
+
if (filename.endsWith(".constant.ts"))
|
|
1361
|
+
files.constants.scalars.push(name);
|
|
1362
|
+
else if (filename.endsWith(".dictionary.ts"))
|
|
1363
|
+
files.dictionary.scalars.push(name);
|
|
1364
|
+
else if (filename.endsWith(".document.ts"))
|
|
1365
|
+
files.documents.scalars.push(name);
|
|
1366
|
+
else if (filename.endsWith(".service.ts"))
|
|
1367
|
+
files.services.scalars.push(name);
|
|
1368
|
+
else if (filename.endsWith(".signal.ts"))
|
|
1369
|
+
files.signal.scalars.push(name);
|
|
1370
|
+
else if (filename.endsWith(".store.ts"))
|
|
1371
|
+
files.store.scalars.push(name);
|
|
1372
|
+
else if (filename === "index.ts")
|
|
1373
|
+
files.components.scalars.push(name);
|
|
1374
|
+
});
|
|
1375
|
+
})
|
|
1376
|
+
);
|
|
1377
|
+
const missingLibDeps = [];
|
|
1378
|
+
libDeps.forEach((libName) => {
|
|
1379
|
+
if (!akanConfig.libs.includes(libName))
|
|
1380
|
+
missingLibDeps.push(libName);
|
|
1381
|
+
});
|
|
1382
|
+
if (missingLibDeps.length)
|
|
1383
|
+
throw new Error(
|
|
1384
|
+
`Missing libs: ${missingLibDeps.join(", ")}, add these dependencies in akan.config.ts as { libs: [...other deps, ${missingLibDeps.join(", ")}] }`
|
|
1456
1385
|
);
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
this.
|
|
1479
|
-
}
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1386
|
+
for (const libName of libDeps) {
|
|
1387
|
+
if (libScanResults[libName])
|
|
1388
|
+
continue;
|
|
1389
|
+
const lib = new LibExecutor({ workspace: this.workspace, name: libName });
|
|
1390
|
+
const akanConfig2 = await lib.getConfig();
|
|
1391
|
+
libScanResults[libName] = await lib.scan({ akanConfig: akanConfig2 }, libScanResults);
|
|
1392
|
+
}
|
|
1393
|
+
const scanResult = {
|
|
1394
|
+
name: this.name,
|
|
1395
|
+
type: this.type,
|
|
1396
|
+
akanConfig,
|
|
1397
|
+
files,
|
|
1398
|
+
libDeps,
|
|
1399
|
+
pkgDeps,
|
|
1400
|
+
dependencies: [...npmDepSet],
|
|
1401
|
+
libs: Object.fromEntries(libDeps.map((libName) => [libName, libScanResults[libName]]))
|
|
1402
|
+
};
|
|
1403
|
+
await this.applyTemplate({ basePath: "lib", template: "lib", scanResult });
|
|
1404
|
+
await this.applyTemplate({ basePath: ".", template: "server.ts", scanResult });
|
|
1405
|
+
await this.applyTemplate({ basePath: ".", template: "client.ts", scanResult });
|
|
1406
|
+
if (this.type === "lib")
|
|
1407
|
+
await this.applyTemplate({ basePath: ".", template: "index.ts", scanResult });
|
|
1408
|
+
this.writeJson(`akan.${this.type}.json`, scanResult);
|
|
1409
|
+
return scanResult;
|
|
1410
|
+
}
|
|
1411
|
+
async getDatabaseModules() {
|
|
1412
|
+
const databaseModules = (await import_promises.default.readdir(`${this.cwdPath}/lib`)).filter((name) => !name.startsWith("_")).filter((name) => import_fs7.default.existsSync(`${this.cwdPath}/lib/${name}/${name}.constant.ts`));
|
|
1413
|
+
return databaseModules;
|
|
1414
|
+
}
|
|
1415
|
+
async getServiceModules() {
|
|
1416
|
+
const serviceModules = (await import_promises.default.readdir(`${this.cwdPath}/lib`)).filter((name) => name.startsWith("_") && !name.startsWith("__")).filter((name) => import_fs7.default.existsSync(`${this.cwdPath}/lib/${name}/${name}.service.ts`));
|
|
1417
|
+
return serviceModules;
|
|
1418
|
+
}
|
|
1419
|
+
async getScalarModules() {
|
|
1420
|
+
const scalarModules = (await import_promises.default.readdir(`${this.cwdPath}/lib/__scalar`)).filter((name) => !name.startsWith("_")).filter((name) => import_fs7.default.existsSync(`${this.cwdPath}/lib/__scalar/${name}/${name}.constant.ts`));
|
|
1421
|
+
return scalarModules;
|
|
1422
|
+
}
|
|
1423
|
+
};
|
|
1424
|
+
var AppExecutor = class _AppExecutor extends SysExecutor {
|
|
1425
|
+
constructor({ workspace, name }) {
|
|
1426
|
+
super({ workspace, name, type: "app" });
|
|
1427
|
+
}
|
|
1428
|
+
static from(executor, name) {
|
|
1429
|
+
if (executor instanceof WorkspaceExecutor)
|
|
1430
|
+
return new _AppExecutor({ workspace: executor, name });
|
|
1431
|
+
return new _AppExecutor({ workspace: executor.workspace, name });
|
|
1432
|
+
}
|
|
1433
|
+
async getConfig(command) {
|
|
1434
|
+
return await getAppConfig(this.cwdPath, { ...getBaseDevEnv(), appName: this.name, command });
|
|
1435
|
+
}
|
|
1436
|
+
async syncAssets(libDeps) {
|
|
1437
|
+
const projectPublicLibPath = `${this.cwdPath}/public/libs`;
|
|
1438
|
+
if (import_fs7.default.existsSync(projectPublicLibPath))
|
|
1439
|
+
await import_promises.default.rm(projectPublicLibPath, { recursive: true });
|
|
1440
|
+
const targetDeps = libDeps.filter((dep) => import_fs7.default.existsSync(`${this.workspace.workspaceRoot}/libs/${dep}/public`));
|
|
1441
|
+
await Promise.all(targetDeps.map((dep) => import_promises.default.mkdir(`${projectPublicLibPath}/${dep}`, { recursive: true })));
|
|
1442
|
+
await Promise.all(
|
|
1443
|
+
targetDeps.map(
|
|
1444
|
+
(dep) => import_promises.default.cp(`${this.workspace.workspaceRoot}/libs/${dep}/public`, `${projectPublicLibPath}/${dep}`, {
|
|
1445
|
+
recursive: true
|
|
1446
|
+
})
|
|
1447
|
+
)
|
|
1448
|
+
);
|
|
1449
|
+
}
|
|
1450
|
+
};
|
|
1451
|
+
var DistAppExecutor = class _DistAppExecutor extends Executor {
|
|
1452
|
+
name;
|
|
1453
|
+
constructor({ workspace, name }) {
|
|
1454
|
+
super(`${name} Dist App Executor`, `${workspace.workspaceRoot}/dist/apps/${name}`);
|
|
1455
|
+
this.name = name;
|
|
1456
|
+
}
|
|
1457
|
+
static from(executor, name) {
|
|
1458
|
+
if (executor instanceof WorkspaceExecutor)
|
|
1459
|
+
return new _DistAppExecutor({ workspace: executor, name });
|
|
1460
|
+
return new _DistAppExecutor({ workspace: executor.workspace, name });
|
|
1461
|
+
}
|
|
1462
|
+
};
|
|
1463
|
+
var LibExecutor = class _LibExecutor extends SysExecutor {
|
|
1464
|
+
workspaceRoot;
|
|
1465
|
+
repoName;
|
|
1466
|
+
constructor({ workspace, name }) {
|
|
1467
|
+
super({ workspace, name, type: "lib" });
|
|
1468
|
+
}
|
|
1469
|
+
static from(executor, name) {
|
|
1470
|
+
if (executor instanceof WorkspaceExecutor)
|
|
1471
|
+
return new _LibExecutor({ workspace: executor, name });
|
|
1472
|
+
return new _LibExecutor({ workspace: executor.workspace, name });
|
|
1473
|
+
}
|
|
1474
|
+
async getConfig(command) {
|
|
1475
|
+
return await getLibConfig(this.cwdPath, { ...getBaseDevEnv(), appName: this.name, command });
|
|
1476
|
+
}
|
|
1477
|
+
};
|
|
1478
|
+
var DistLibExecutor = class _DistLibExecutor extends Executor {
|
|
1479
|
+
name;
|
|
1480
|
+
constructor({ workspace, name }) {
|
|
1481
|
+
super(`${name} Dist Lib Executor`, `${workspace.workspaceRoot}/dist/libs/${name}`);
|
|
1482
|
+
this.name = name;
|
|
1483
|
+
}
|
|
1484
|
+
static from(executor, name) {
|
|
1485
|
+
if (executor instanceof WorkspaceExecutor)
|
|
1486
|
+
return new DistAppExecutor({ workspace: executor, name });
|
|
1487
|
+
return new _DistLibExecutor({ workspace: executor.workspace, name });
|
|
1488
|
+
}
|
|
1489
|
+
};
|
|
1490
|
+
var PkgExecutor = class _PkgExecutor extends Executor {
|
|
1491
|
+
workspace;
|
|
1492
|
+
name;
|
|
1493
|
+
constructor({ workspace = WorkspaceExecutor.fromRoot(), name }) {
|
|
1494
|
+
super(`${name} Pkg Executor`, `${workspace.workspaceRoot}/pkgs/${name}`);
|
|
1495
|
+
this.workspace = workspace;
|
|
1496
|
+
this.name = name;
|
|
1497
|
+
}
|
|
1498
|
+
static from(executor, name) {
|
|
1499
|
+
if (executor instanceof WorkspaceExecutor)
|
|
1500
|
+
return new _PkgExecutor({ workspace: executor, name });
|
|
1501
|
+
return new _PkgExecutor({ workspace: executor.workspace, name });
|
|
1502
|
+
}
|
|
1503
|
+
async scan({
|
|
1504
|
+
packageJson = this.readJson(`${this.cwdPath}/package.json`),
|
|
1505
|
+
tsconfig = this.getTsConfig(`${this.cwdPath}/tsconfig.json`)
|
|
1506
|
+
} = {}) {
|
|
1507
|
+
const rootPackageJson = this.readJson(`${this.workspace.workspaceRoot}/package.json`);
|
|
1508
|
+
const scanner = new TypeScriptDependencyScanner(this.cwdPath);
|
|
1509
|
+
const npmSet = new Set(Object.keys({ ...rootPackageJson.dependencies, ...rootPackageJson.devDependencies }));
|
|
1510
|
+
const pkgPathSet = new Set(
|
|
1511
|
+
Object.keys(tsconfig.compilerOptions.paths).filter((path5) => tsconfig.compilerOptions.paths[path5].some((resolve) => resolve.startsWith("pkgs/"))).map((path5) => path5.replace("/*", ""))
|
|
1512
|
+
);
|
|
1513
|
+
const [npmDepSet, pkgPathDepSet] = await scanner.getImportSets([npmSet, pkgPathSet]);
|
|
1514
|
+
const pkgDeps = [...pkgPathDepSet].map((path5) => {
|
|
1515
|
+
const pathSplitLength = path5.split("/").length;
|
|
1516
|
+
return tsconfig.compilerOptions.paths[path5][0].split("/").slice(1, 1 + pathSplitLength).join("/");
|
|
1517
|
+
}).filter((pkg) => pkg !== this.name);
|
|
1518
|
+
const pkgScanResult = {
|
|
1519
|
+
name: this.name,
|
|
1520
|
+
pkgDeps,
|
|
1521
|
+
dependencies: [...npmDepSet]
|
|
1522
|
+
};
|
|
1523
|
+
return pkgScanResult;
|
|
1524
|
+
}
|
|
1525
|
+
};
|
|
1526
|
+
var DistPkgExecutor = class _DistPkgExecutor extends Executor {
|
|
1527
|
+
workspaceRoot;
|
|
1528
|
+
repoName;
|
|
1529
|
+
name;
|
|
1530
|
+
constructor({ workspaceRoot, repoName, name }) {
|
|
1531
|
+
super(`${name} Dist Pkg Executor`, `${workspaceRoot}/dist/pkgs/${name}`);
|
|
1532
|
+
this.workspaceRoot = workspaceRoot;
|
|
1533
|
+
this.repoName = repoName;
|
|
1534
|
+
this.name = name;
|
|
1535
|
+
}
|
|
1536
|
+
static from(workspaceExecutor, name) {
|
|
1537
|
+
return new _DistPkgExecutor({
|
|
1538
|
+
workspaceRoot: workspaceExecutor.workspaceRoot,
|
|
1539
|
+
repoName: workspaceExecutor.repoName,
|
|
1540
|
+
name
|
|
1541
|
+
});
|
|
1542
|
+
}
|
|
1543
|
+
};
|
|
1488
1544
|
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1545
|
+
// pkgs/@akanjs/devkit/src/constants.ts
|
|
1546
|
+
var import_os = require("os");
|
|
1547
|
+
var basePath = `${(0, import_os.homedir)()}/.akan`;
|
|
1548
|
+
var configPath = `${basePath}/config.json`;
|
|
1549
|
+
var akanCloudHost = process.env.NEXT_PUBLIC_OPERATION_MODE === "local" ? "http://localhost" : "https://akasys-debug.akamir.com";
|
|
1550
|
+
var akanCloudBackendUrl = `${akanCloudHost}${process.env.NEXT_PUBLIC_OPERATION_MODE === "local" ? ":8080" : ""}/backend`;
|
|
1551
|
+
var akanCloudClientUrl = `${akanCloudHost}${process.env.NEXT_PUBLIC_OPERATION_MODE === "local" ? ":4200" : ""}`;
|
|
1552
|
+
var defaultHostConfig = {};
|
|
1553
|
+
var defaultAkanGlobalConfig = {};
|
|
1498
1554
|
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1555
|
+
// pkgs/@akanjs/devkit/src/auth.ts
|
|
1556
|
+
var import_fs8 = __toESM(require("fs"));
|
|
1557
|
+
var getAkanGlobalConfig = () => {
|
|
1558
|
+
const akanConfig = import_fs8.default.existsSync(configPath) ? JSON.parse(import_fs8.default.readFileSync(configPath, "utf8")) : defaultAkanGlobalConfig;
|
|
1559
|
+
return akanConfig;
|
|
1560
|
+
};
|
|
1561
|
+
var setAkanGlobalConfig = (akanConfig) => {
|
|
1562
|
+
import_fs8.default.mkdirSync(basePath, { recursive: true });
|
|
1563
|
+
import_fs8.default.writeFileSync(configPath, JSON.stringify(akanConfig, null, 2));
|
|
1564
|
+
};
|
|
1565
|
+
var getHostConfig = (host = akanCloudHost) => {
|
|
1566
|
+
const akanConfig = getAkanGlobalConfig();
|
|
1567
|
+
return akanConfig[host] ?? defaultHostConfig;
|
|
1568
|
+
};
|
|
1569
|
+
var setHostConfig = (host = akanCloudHost, config = {}) => {
|
|
1570
|
+
const akanConfig = getAkanGlobalConfig();
|
|
1571
|
+
akanConfig[host] = config;
|
|
1572
|
+
setAkanGlobalConfig(akanConfig);
|
|
1573
|
+
};
|
|
1574
|
+
var getSelf = async (token) => {
|
|
1575
|
+
try {
|
|
1576
|
+
const res = await fetch(`${akanCloudBackendUrl}/user/getSelf`, { headers: { Authorization: `Bearer ${token}` } });
|
|
1577
|
+
const user = await res.json();
|
|
1578
|
+
return user;
|
|
1579
|
+
} catch (e) {
|
|
1580
|
+
return null;
|
|
1581
|
+
}
|
|
1582
|
+
};
|
|
1527
1583
|
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1584
|
+
// pkgs/@akanjs/devkit/src/capacitorApp.ts
|
|
1585
|
+
var import_project = require("@trapezedev/project");
|
|
1586
|
+
var import_fs9 = __toESM(require("fs"));
|
|
1587
|
+
var CapacitorApp = class {
|
|
1588
|
+
constructor(app) {
|
|
1589
|
+
this.app = app;
|
|
1590
|
+
}
|
|
1591
|
+
project;
|
|
1592
|
+
iosTargetName = "App";
|
|
1593
|
+
async init() {
|
|
1594
|
+
const project = new import_project.MobileProject(this.app.cwdPath, {
|
|
1595
|
+
android: { path: "android" },
|
|
1596
|
+
ios: { path: "ios/App" }
|
|
1597
|
+
});
|
|
1598
|
+
await project.load();
|
|
1599
|
+
if (!project.android)
|
|
1600
|
+
throw new Error(`Android is not added, Please add platform first
|
|
1545
1601
|
akan serve-android ${this.app.name}`);
|
|
1546
|
-
|
|
1547
|
-
|
|
1602
|
+
if (!project.ios)
|
|
1603
|
+
throw new Error(`iOS is not added, Please add platform first
|
|
1548
1604
|
akan serve-ios ${this.app.name}`);
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
}
|
|
1610
|
-
this.app.logger.info(`Adding ${feature} to android`);
|
|
1611
|
-
this.project.android.getAndroidManifest().injectFragment("manifest", `<uses-feature android:name="${feature}" />`);
|
|
1605
|
+
this.project = project;
|
|
1606
|
+
return this;
|
|
1607
|
+
}
|
|
1608
|
+
async save() {
|
|
1609
|
+
await this.project.commit();
|
|
1610
|
+
}
|
|
1611
|
+
async releaseIos() {
|
|
1612
|
+
const isAdded = import_fs9.default.existsSync(`${this.app.cwdPath}/ios/App/Podfile`);
|
|
1613
|
+
if (!isAdded) {
|
|
1614
|
+
await this.app.spawn("npx cap add ios");
|
|
1615
|
+
await this.app.spawn("npx @capacitor/assets generate");
|
|
1616
|
+
} else
|
|
1617
|
+
this.app.log(`iOS already added, skip adding process`);
|
|
1618
|
+
await this.app.spawn("cross-env", ["APP_OPERATION_MODE=release", "npx", "cap", "sync", "ios"]);
|
|
1619
|
+
}
|
|
1620
|
+
async releaseAndroid() {
|
|
1621
|
+
const isAdded = import_fs9.default.existsSync(`${this.app.cwdPath}/android/app/build.gradle`);
|
|
1622
|
+
if (!isAdded) {
|
|
1623
|
+
await this.app.spawn("npx cap add android");
|
|
1624
|
+
await this.app.spawn("npx @capacitor/assets generate");
|
|
1625
|
+
} else
|
|
1626
|
+
this.app.log(`android already added, skip adding process`);
|
|
1627
|
+
await this.app.spawn("cross-env", ["APP_OPERATION_MODE=release", "npx", "cap", "sync", "android"]);
|
|
1628
|
+
}
|
|
1629
|
+
async addCamera() {
|
|
1630
|
+
await this.#setPermissionInIos({
|
|
1631
|
+
cameraUsageDescription: "$(PRODUCT_NAME) requires access to the camera to take photos.",
|
|
1632
|
+
photoAddUsageDescription: "$(PRODUCT_NAME) requires access to the photo library to take photos.",
|
|
1633
|
+
photoUsageDescription: "$(PRODUCT_NAME) requires access to the photo library to take photos."
|
|
1634
|
+
});
|
|
1635
|
+
this.#setPermissionsInAndroid(["READ_MEDIA_IMAGES", "READ_EXTERNAL_STORAGE", "WRITE_EXTERNAL_STORAGE"]);
|
|
1636
|
+
}
|
|
1637
|
+
async addContact() {
|
|
1638
|
+
await this.#setPermissionInIos({
|
|
1639
|
+
contactsUsageDescription: "$(PRODUCT_NAME) requires access to the contacts to add new contacts."
|
|
1640
|
+
});
|
|
1641
|
+
this.#setPermissionsInAndroid(["READ_CONTACTS", "WRITE_CONTACTS"]);
|
|
1642
|
+
}
|
|
1643
|
+
async addLocation() {
|
|
1644
|
+
await this.#setPermissionInIos({
|
|
1645
|
+
locationAlwaysUsageDescription: "$(PRODUCT_NAME) requires access to the location to get the user's location.",
|
|
1646
|
+
locationWhenInUseUsageDescription: "$(PRODUCT_NAME) requires access to the location to get the user's location."
|
|
1647
|
+
});
|
|
1648
|
+
this.#setPermissionsInAndroid(["ACCESS_COARSE_LOCATION", "ACCESS_FINE_LOCATION"]);
|
|
1649
|
+
this.#setFeaturesInAndroid(["android.hardware.location.gps"]);
|
|
1650
|
+
}
|
|
1651
|
+
async #setPermissionInIos(permissions) {
|
|
1652
|
+
const updateNs = Object.fromEntries(
|
|
1653
|
+
Object.entries(permissions).map(([key, value]) => [`NS${capitalize(key)}`, value])
|
|
1654
|
+
);
|
|
1655
|
+
await Promise.all([
|
|
1656
|
+
this.project.ios.updateInfoPlist(this.iosTargetName, "Debug", updateNs),
|
|
1657
|
+
this.project.ios.updateInfoPlist(this.iosTargetName, "Release", updateNs)
|
|
1658
|
+
]);
|
|
1659
|
+
}
|
|
1660
|
+
#setFeaturesInAndroid(features) {
|
|
1661
|
+
for (const feature of features) {
|
|
1662
|
+
if (this.#hasFeatureInAndroid(feature)) {
|
|
1663
|
+
this.app.logger.info(`${feature} already exists in android`);
|
|
1664
|
+
return this;
|
|
1612
1665
|
}
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
this.app.logger.info(
|
|
1633
|
-
this
|
|
1666
|
+
this.app.logger.info(`Adding ${feature} to android`);
|
|
1667
|
+
this.project.android.getAndroidManifest().injectFragment("manifest", `<uses-feature android:name="${feature}" />`);
|
|
1668
|
+
}
|
|
1669
|
+
return this;
|
|
1670
|
+
}
|
|
1671
|
+
#getFeaturesInAndroid() {
|
|
1672
|
+
const androidManifest = this.project.android.getAndroidManifest();
|
|
1673
|
+
const element = androidManifest.getDocumentElement();
|
|
1674
|
+
if (!element)
|
|
1675
|
+
throw new Error("manifest not found");
|
|
1676
|
+
const usesFeature = element.getElementsByTagName("uses-feature");
|
|
1677
|
+
return Array.from(usesFeature).map((feature) => feature.getAttribute("android:name"));
|
|
1678
|
+
}
|
|
1679
|
+
#hasFeatureInAndroid(feature) {
|
|
1680
|
+
return this.#getFeaturesInAndroid().includes(feature);
|
|
1681
|
+
}
|
|
1682
|
+
#setPermissionsInAndroid(permissions) {
|
|
1683
|
+
for (const permission of permissions) {
|
|
1684
|
+
if (this.#hasPermissionInAndroid(permission)) {
|
|
1685
|
+
this.app.logger.info(`${permission} already exists in android`);
|
|
1686
|
+
return this;
|
|
1634
1687
|
}
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1688
|
+
this.app.logger.info(`Adding ${permission} to android`);
|
|
1689
|
+
this.project.android.getAndroidManifest().injectFragment("manifest", `<uses-permission android:name="android.permission.${permission}" />`);
|
|
1690
|
+
}
|
|
1691
|
+
return this;
|
|
1692
|
+
}
|
|
1693
|
+
#getPermissionsInAndroid() {
|
|
1694
|
+
const androidManifest = this.project.android.getAndroidManifest();
|
|
1695
|
+
const element = androidManifest.getDocumentElement();
|
|
1696
|
+
if (!element)
|
|
1697
|
+
throw new Error("manifest not found");
|
|
1698
|
+
const usesPermission = element.getElementsByTagName("uses-permission");
|
|
1699
|
+
return Array.from(usesPermission).map((permission) => permission.getAttribute("android:name"));
|
|
1700
|
+
}
|
|
1701
|
+
#hasPermissionInAndroid(permission) {
|
|
1702
|
+
return this.#getPermissionsInAndroid().includes(permission);
|
|
1703
|
+
}
|
|
1704
|
+
};
|
|
1649
1705
|
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1706
|
+
// pkgs/@akanjs/devkit/src/extractDeps.ts
|
|
1707
|
+
var fs11 = __toESM(require("fs"));
|
|
1708
|
+
var NODE_NATIVE_MODULE_SET = /* @__PURE__ */ new Set([
|
|
1709
|
+
"assert",
|
|
1710
|
+
"async_hooks",
|
|
1711
|
+
"buffer",
|
|
1712
|
+
"child_process",
|
|
1713
|
+
"cluster",
|
|
1714
|
+
"console",
|
|
1715
|
+
"constants",
|
|
1716
|
+
"crypto",
|
|
1717
|
+
"dgram",
|
|
1718
|
+
"dns",
|
|
1719
|
+
"domain",
|
|
1720
|
+
"events",
|
|
1721
|
+
"fs",
|
|
1722
|
+
"http",
|
|
1723
|
+
"http2",
|
|
1724
|
+
"https",
|
|
1725
|
+
"inspector",
|
|
1726
|
+
"module",
|
|
1727
|
+
"net",
|
|
1728
|
+
"os",
|
|
1729
|
+
"path",
|
|
1730
|
+
"perf_hooks",
|
|
1731
|
+
"process",
|
|
1732
|
+
"punycode",
|
|
1733
|
+
"querystring",
|
|
1734
|
+
"readline",
|
|
1735
|
+
"repl",
|
|
1736
|
+
"stream",
|
|
1737
|
+
"string_decoder",
|
|
1738
|
+
"timers",
|
|
1739
|
+
"tls",
|
|
1740
|
+
"trace_events",
|
|
1741
|
+
"tty",
|
|
1742
|
+
"url",
|
|
1743
|
+
"util",
|
|
1744
|
+
"v8",
|
|
1745
|
+
"vm",
|
|
1746
|
+
"wasi",
|
|
1747
|
+
"worker_threads",
|
|
1748
|
+
"zlib"
|
|
1749
|
+
]);
|
|
1750
|
+
var extractDependencies = (bundlePath, pacakgeJson, defaultDependencies = []) => {
|
|
1751
|
+
if (!pacakgeJson.dependencies)
|
|
1752
|
+
throw new Error("No dependencies found in package.json");
|
|
1753
|
+
const code = fs11.readFileSync(bundlePath, "utf8");
|
|
1754
|
+
const dependencies = new Set(defaultDependencies);
|
|
1755
|
+
const existingDependencies = /* @__PURE__ */ new Set([
|
|
1756
|
+
...Object.keys(pacakgeJson.dependencies ?? {}),
|
|
1757
|
+
...Object.keys(pacakgeJson.devDependencies ?? {})
|
|
1693
1758
|
]);
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
const code = fs11.readFileSync(bundlePath, "utf8");
|
|
1698
|
-
const dependencies = new Set(defaultDependencies);
|
|
1699
|
-
const existingDependencies = /* @__PURE__ */ new Set([
|
|
1700
|
-
...Object.keys(pacakgeJson.dependencies ?? {}),
|
|
1701
|
-
...Object.keys(pacakgeJson.devDependencies ?? {})
|
|
1702
|
-
]);
|
|
1703
|
-
const versionObj = {
|
|
1704
|
-
...pacakgeJson.dependencies ?? {},
|
|
1705
|
-
...pacakgeJson.devDependencies ?? {}
|
|
1706
|
-
};
|
|
1707
|
-
const requireRegex = /require\s*\(\s*['"`]([^'"`]+)['"`]\s*\)/g;
|
|
1708
|
-
let requireMatch;
|
|
1709
|
-
while ((requireMatch = requireRegex.exec(code)) !== null) {
|
|
1710
|
-
const moduleName = requireMatch[1];
|
|
1711
|
-
const moduleNameParts = moduleName.split("/");
|
|
1712
|
-
const subModuleLength = moduleNameParts.length;
|
|
1713
|
-
for (let i = 0; i < subModuleLength; i++) {
|
|
1714
|
-
const libName = moduleNameParts.slice(0, i + 1).join("/");
|
|
1715
|
-
if (!NODE_NATIVE_MODULE_SET.has(libName) && existingDependencies.has(libName))
|
|
1716
|
-
dependencies.add(libName);
|
|
1717
|
-
}
|
|
1718
|
-
}
|
|
1719
|
-
return Object.fromEntries(
|
|
1720
|
-
[...dependencies].sort().map((dep) => {
|
|
1721
|
-
const version = versionObj[dep];
|
|
1722
|
-
if (!version)
|
|
1723
|
-
throw new Error(`No version found for ${dep}`);
|
|
1724
|
-
return [dep, version];
|
|
1725
|
-
})
|
|
1726
|
-
);
|
|
1759
|
+
const versionObj = {
|
|
1760
|
+
...pacakgeJson.dependencies ?? {},
|
|
1761
|
+
...pacakgeJson.devDependencies ?? {}
|
|
1727
1762
|
};
|
|
1763
|
+
const requireRegex = /require\s*\(\s*['"`]([^'"`]+)['"`]\s*\)/g;
|
|
1764
|
+
let requireMatch;
|
|
1765
|
+
while ((requireMatch = requireRegex.exec(code)) !== null) {
|
|
1766
|
+
const moduleName = requireMatch[1];
|
|
1767
|
+
const moduleNameParts = moduleName.split("/");
|
|
1768
|
+
const subModuleLength = moduleNameParts.length;
|
|
1769
|
+
for (let i = 0; i < subModuleLength; i++) {
|
|
1770
|
+
const libName = moduleNameParts.slice(0, i + 1).join("/");
|
|
1771
|
+
if (!NODE_NATIVE_MODULE_SET.has(libName) && existingDependencies.has(libName))
|
|
1772
|
+
dependencies.add(libName);
|
|
1773
|
+
}
|
|
1774
|
+
}
|
|
1775
|
+
return Object.fromEntries(
|
|
1776
|
+
[...dependencies].sort().map((dep) => {
|
|
1777
|
+
const version = versionObj[dep];
|
|
1778
|
+
if (!version)
|
|
1779
|
+
throw new Error(`No version found for ${dep}`);
|
|
1780
|
+
return [dep, version];
|
|
1781
|
+
})
|
|
1782
|
+
);
|
|
1783
|
+
};
|
|
1728
1784
|
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1785
|
+
// pkgs/@akanjs/devkit/src/commandDecorators/argMeta.ts
|
|
1786
|
+
var import_reflect_metadata = require("reflect-metadata");
|
|
1787
|
+
var argTypes = ["Option"];
|
|
1788
|
+
var internalArgTypes = ["Workspace", "App", "Lib", "Sys", "Pkg"];
|
|
1789
|
+
var getArgMetas = (command, key) => {
|
|
1790
|
+
const allArgMetas = getArgMetasOnPrototype(command.prototype, key);
|
|
1791
|
+
const argMetas = allArgMetas.filter((argMeta) => argMeta.type === "Option");
|
|
1792
|
+
const internalArgMetas = allArgMetas.filter((argMeta) => argMeta.type !== "Option");
|
|
1793
|
+
return [allArgMetas, argMetas, internalArgMetas];
|
|
1794
|
+
};
|
|
1795
|
+
var getArgMetasOnPrototype = (prototype, key) => {
|
|
1796
|
+
return Reflect.getMetadata("args", prototype, key) ?? [];
|
|
1797
|
+
};
|
|
1798
|
+
var setArgMetasOnPrototype = (prototype, key, argMetas) => {
|
|
1799
|
+
Reflect.defineMetadata("args", argMetas, prototype, key);
|
|
1800
|
+
};
|
|
1801
|
+
var getArg = (type) => function(name, argsOption = {}) {
|
|
1802
|
+
return function(prototype, key, idx) {
|
|
1803
|
+
const argMetas = getArgMetasOnPrototype(prototype, key);
|
|
1804
|
+
argMetas[idx] = { name, argsOption, key, idx, type };
|
|
1805
|
+
setArgMetasOnPrototype(prototype, key, argMetas);
|
|
1741
1806
|
};
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1807
|
+
};
|
|
1808
|
+
var Option = getArg("Option");
|
|
1809
|
+
var createArgMetaDecorator = (type) => {
|
|
1810
|
+
return function(option = {}) {
|
|
1746
1811
|
return function(prototype, key, idx) {
|
|
1747
1812
|
const argMetas = getArgMetasOnPrototype(prototype, key);
|
|
1748
|
-
argMetas[idx] = {
|
|
1813
|
+
argMetas[idx] = { key, idx, type, option };
|
|
1749
1814
|
setArgMetasOnPrototype(prototype, key, argMetas);
|
|
1750
1815
|
};
|
|
1751
1816
|
};
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
setArgMetasOnPrototype(prototype, key, argMetas);
|
|
1759
|
-
};
|
|
1760
|
-
};
|
|
1761
|
-
};
|
|
1762
|
-
var App = createArgMetaDecorator("App");
|
|
1763
|
-
var Lib = createArgMetaDecorator("Lib");
|
|
1764
|
-
var Sys = createArgMetaDecorator("Sys");
|
|
1765
|
-
var Pkg = createArgMetaDecorator("Pkg");
|
|
1766
|
-
var Workspace = createArgMetaDecorator("Workspace");
|
|
1817
|
+
};
|
|
1818
|
+
var App = createArgMetaDecorator("App");
|
|
1819
|
+
var Lib = createArgMetaDecorator("Lib");
|
|
1820
|
+
var Sys = createArgMetaDecorator("Sys");
|
|
1821
|
+
var Pkg = createArgMetaDecorator("Pkg");
|
|
1822
|
+
var Workspace = createArgMetaDecorator("Workspace");
|
|
1767
1823
|
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
};
|
|
1824
|
+
// pkgs/@akanjs/devkit/src/commandDecorators/commandMeta.ts
|
|
1825
|
+
var Commands = () => {
|
|
1826
|
+
return function(target) {
|
|
1772
1827
|
};
|
|
1828
|
+
};
|
|
1773
1829
|
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
};
|
|
1798
|
-
};
|
|
1799
|
-
var Target = {
|
|
1800
|
-
Public: getTarget("public"),
|
|
1801
|
-
Cloud: getTarget("cloud"),
|
|
1802
|
-
Dev: getTarget("dev")
|
|
1830
|
+
// pkgs/@akanjs/devkit/src/commandDecorators/targetMeta.ts
|
|
1831
|
+
var getTargetMetas = (command) => {
|
|
1832
|
+
const targetMetaMap = Reflect.getMetadata("target", command.prototype);
|
|
1833
|
+
if (!targetMetaMap)
|
|
1834
|
+
throw new Error(`TargetMeta is not defined for ${command.name}`);
|
|
1835
|
+
return [...targetMetaMap.values()];
|
|
1836
|
+
};
|
|
1837
|
+
var getTargetMetaMapOnPrototype = (prototype) => {
|
|
1838
|
+
const targetMetaMap = Reflect.getMetadata("target", prototype);
|
|
1839
|
+
return targetMetaMap ?? /* @__PURE__ */ new Map();
|
|
1840
|
+
};
|
|
1841
|
+
var setTargetMetaMapOnPrototype = (prototype, targetMetaMap) => {
|
|
1842
|
+
Reflect.defineMetadata("target", targetMetaMap, prototype);
|
|
1843
|
+
};
|
|
1844
|
+
var getTarget = (type) => (targetOption = {}) => {
|
|
1845
|
+
return (prototype, key, descriptor) => {
|
|
1846
|
+
const metadataMap = getTargetMetaMapOnPrototype(prototype);
|
|
1847
|
+
metadataMap.set(key, {
|
|
1848
|
+
key,
|
|
1849
|
+
descriptor,
|
|
1850
|
+
targetOption: { ...targetOption, type }
|
|
1851
|
+
});
|
|
1852
|
+
setTargetMetaMapOnPrototype(prototype, metadataMap);
|
|
1803
1853
|
};
|
|
1854
|
+
};
|
|
1855
|
+
var Target = {
|
|
1856
|
+
Public: getTarget("public"),
|
|
1857
|
+
Cloud: getTarget("cloud"),
|
|
1858
|
+
Dev: getTarget("dev")
|
|
1859
|
+
};
|
|
1804
1860
|
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1861
|
+
// pkgs/@akanjs/devkit/src/commandDecorators/command.ts
|
|
1862
|
+
var import_prompts3 = require("@inquirer/prompts");
|
|
1863
|
+
var import_commander = require("commander");
|
|
1864
|
+
var import_dotenv = __toESM(require("dotenv"));
|
|
1865
|
+
var camelToKebabCase = (str) => str.replace(/([A-Z])/g, "-$1").toLowerCase();
|
|
1866
|
+
var handleOption = (programCommand, argMeta) => {
|
|
1867
|
+
const {
|
|
1868
|
+
type,
|
|
1869
|
+
flag = argMeta.name.slice(0, 1).toLowerCase(),
|
|
1870
|
+
desc = argMeta.name,
|
|
1871
|
+
example,
|
|
1872
|
+
enum: choices,
|
|
1873
|
+
ask
|
|
1874
|
+
} = argMeta.argsOption;
|
|
1875
|
+
const kebabName = camelToKebabCase(argMeta.name);
|
|
1876
|
+
programCommand.option(
|
|
1877
|
+
`-${flag}, --${kebabName} <${kebabName}>`,
|
|
1878
|
+
`${desc}${ask ? ` (${ask})` : ""}${example ? ` (example: ${example})` : ""}${choices ? ` (choices: ${choices.join(", ")})` : ""}`
|
|
1879
|
+
);
|
|
1880
|
+
return programCommand;
|
|
1881
|
+
};
|
|
1882
|
+
var convertOptionValue = (value, type) => {
|
|
1883
|
+
if (type === "string")
|
|
1884
|
+
return value;
|
|
1885
|
+
else if (type === "number")
|
|
1886
|
+
return Number(value);
|
|
1887
|
+
else
|
|
1888
|
+
return value === "true";
|
|
1889
|
+
};
|
|
1890
|
+
var getOptionValue = async (argMeta, opt) => {
|
|
1891
|
+
const {
|
|
1892
|
+
name,
|
|
1893
|
+
argsOption: { enum: choices, default: defaultValue, type, desc, nullable, example, ask }
|
|
1894
|
+
} = argMeta;
|
|
1895
|
+
if (opt[argMeta.name] !== void 0)
|
|
1896
|
+
return convertOptionValue(opt[argMeta.name], type ?? "string");
|
|
1897
|
+
else if (defaultValue !== void 0)
|
|
1898
|
+
return defaultValue;
|
|
1899
|
+
else if (nullable)
|
|
1900
|
+
return null;
|
|
1901
|
+
if (choices) {
|
|
1902
|
+
const choice = await (0, import_prompts3.select)({
|
|
1903
|
+
message: ask ?? `Select the ${name} value`,
|
|
1904
|
+
choices: choices.map((choice2) => choice2.toString())
|
|
1905
|
+
});
|
|
1906
|
+
return choice;
|
|
1907
|
+
} else if (type === "boolean") {
|
|
1908
|
+
const message = ask ?? `Do you want to set ${name}? ${desc ? ` (${desc})` : ""}: `;
|
|
1909
|
+
return await (0, import_prompts3.confirm)({ message });
|
|
1910
|
+
} else {
|
|
1911
|
+
const message = ask ?? `Enter the ${name} value${example ? ` (example: ${example})` : ""}: `;
|
|
1912
|
+
if (argMeta.argsOption.nullable)
|
|
1913
|
+
return await (0, import_prompts3.input)({ message });
|
|
1831
1914
|
else
|
|
1832
|
-
return
|
|
1833
|
-
}
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
if (
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
}
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
const
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
for (const targetMeta of targetMetas) {
|
|
1903
|
-
const kebabKey = camelToKebabCase(targetMeta.key);
|
|
1904
|
-
const commandNames = targetMeta.targetOption.short === true ? [
|
|
1905
|
-
kebabKey,
|
|
1906
|
-
typeof targetMeta.targetOption.short === "string" ? targetMeta.targetOption.short : kebabKey.split("-").map((s) => s.slice(0, 1)).join("")
|
|
1907
|
-
] : [kebabKey];
|
|
1908
|
-
for (const commandName of commandNames) {
|
|
1909
|
-
let programCommand = import_commander.program.command(commandName, {
|
|
1910
|
-
hidden: targetMeta.targetOption.devOnly
|
|
1911
|
-
});
|
|
1912
|
-
const [allArgMetas] = getArgMetas(command, targetMeta.key);
|
|
1915
|
+
return convertOptionValue(await (0, import_prompts3.input)({ message }), type ?? "string");
|
|
1916
|
+
}
|
|
1917
|
+
};
|
|
1918
|
+
var getArgumentValue = async (argMeta, value, workspace) => {
|
|
1919
|
+
if (argMeta.type === "Workspace")
|
|
1920
|
+
return workspace;
|
|
1921
|
+
const sysType = argMeta.type.toLowerCase();
|
|
1922
|
+
if (sysType === "sys") {
|
|
1923
|
+
const [appNames, libNames] = await workspace.getSyss();
|
|
1924
|
+
const sysName = await (0, import_prompts3.select)({
|
|
1925
|
+
message: `Select the App or Lib name`,
|
|
1926
|
+
choices: [...appNames, ...libNames]
|
|
1927
|
+
});
|
|
1928
|
+
if (appNames.includes(sysName))
|
|
1929
|
+
return AppExecutor.from(workspace, sysName);
|
|
1930
|
+
else
|
|
1931
|
+
return LibExecutor.from(workspace, sysName);
|
|
1932
|
+
} else if (sysType === "app") {
|
|
1933
|
+
if (value)
|
|
1934
|
+
return AppExecutor.from(workspace, value);
|
|
1935
|
+
const apps = await workspace.getApps();
|
|
1936
|
+
const appName = await (0, import_prompts3.select)({ message: `Select the ${sysType} name`, choices: apps });
|
|
1937
|
+
return AppExecutor.from(workspace, appName);
|
|
1938
|
+
} else if (sysType === "lib") {
|
|
1939
|
+
if (value)
|
|
1940
|
+
return LibExecutor.from(workspace, value);
|
|
1941
|
+
const libs = await workspace.getLibs();
|
|
1942
|
+
const libName = await (0, import_prompts3.select)({ message: `Select the ${sysType} name`, choices: libs });
|
|
1943
|
+
return LibExecutor.from(workspace, libName);
|
|
1944
|
+
} else if (sysType === "pkg") {
|
|
1945
|
+
if (value)
|
|
1946
|
+
return PkgExecutor.from(workspace, value);
|
|
1947
|
+
const pkgs = await workspace.getPkgs();
|
|
1948
|
+
const pkgName = await (0, import_prompts3.select)({ message: `Select the ${sysType} name`, choices: pkgs });
|
|
1949
|
+
return PkgExecutor.from(workspace, pkgName);
|
|
1950
|
+
} else
|
|
1951
|
+
throw new Error(`Invalid system type: ${argMeta.type}`);
|
|
1952
|
+
};
|
|
1953
|
+
var runCommands = async (...commands) => {
|
|
1954
|
+
import_dotenv.default.config();
|
|
1955
|
+
import_commander.program.version("0.0.1").description("An example CLI for managing a directory");
|
|
1956
|
+
for (const command of commands) {
|
|
1957
|
+
const targetMetas = getTargetMetas(command);
|
|
1958
|
+
for (const targetMeta of targetMetas) {
|
|
1959
|
+
const kebabKey = camelToKebabCase(targetMeta.key);
|
|
1960
|
+
const commandNames = targetMeta.targetOption.short === true ? [
|
|
1961
|
+
kebabKey,
|
|
1962
|
+
typeof targetMeta.targetOption.short === "string" ? targetMeta.targetOption.short : kebabKey.split("-").map((s) => s.slice(0, 1)).join("")
|
|
1963
|
+
] : [kebabKey];
|
|
1964
|
+
for (const commandName of commandNames) {
|
|
1965
|
+
let programCommand = import_commander.program.command(commandName, {
|
|
1966
|
+
hidden: targetMeta.targetOption.devOnly
|
|
1967
|
+
});
|
|
1968
|
+
const [allArgMetas] = getArgMetas(command, targetMeta.key);
|
|
1969
|
+
for (const argMeta of allArgMetas) {
|
|
1970
|
+
if (argMeta.type === "Option")
|
|
1971
|
+
programCommand = handleOption(programCommand, argMeta);
|
|
1972
|
+
else if (argMeta.type === "Workspace")
|
|
1973
|
+
continue;
|
|
1974
|
+
const sysType = argMeta.type.toLowerCase();
|
|
1975
|
+
programCommand = programCommand.argument(
|
|
1976
|
+
`[${sysType}]`,
|
|
1977
|
+
`${sysType} in this workspace ${sysType}s/<${sysType}Name>`
|
|
1978
|
+
);
|
|
1979
|
+
}
|
|
1980
|
+
programCommand.action(async (...args) => {
|
|
1981
|
+
const cmdArgs = args.slice(0, args.length - 2);
|
|
1982
|
+
const opt = args[args.length - 2];
|
|
1983
|
+
const commandArgs = [];
|
|
1984
|
+
const workspace = WorkspaceExecutor.fromRoot();
|
|
1913
1985
|
for (const argMeta of allArgMetas) {
|
|
1914
1986
|
if (argMeta.type === "Option")
|
|
1915
|
-
|
|
1916
|
-
else
|
|
1917
|
-
|
|
1918
|
-
const sysType = argMeta.type.toLowerCase();
|
|
1919
|
-
programCommand = programCommand.argument(
|
|
1920
|
-
`[${sysType}]`,
|
|
1921
|
-
`${sysType} in this workspace ${sysType}s/<${sysType}Name>`
|
|
1922
|
-
);
|
|
1987
|
+
commandArgs[argMeta.idx] = await getOptionValue(argMeta, opt);
|
|
1988
|
+
else
|
|
1989
|
+
commandArgs[argMeta.idx] = await getArgumentValue(argMeta, cmdArgs[argMeta.idx], workspace);
|
|
1923
1990
|
}
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
const commandArgs = [];
|
|
1928
|
-
const workspace = WorkspaceExecutor.fromRoot();
|
|
1929
|
-
for (const argMeta of allArgMetas) {
|
|
1930
|
-
if (argMeta.type === "Option")
|
|
1931
|
-
commandArgs[argMeta.idx] = await getOptionValue(argMeta, opt);
|
|
1932
|
-
else
|
|
1933
|
-
commandArgs[argMeta.idx] = await getArgumentValue(argMeta, cmdArgs[argMeta.idx], workspace);
|
|
1934
|
-
}
|
|
1935
|
-
const cmd = new command();
|
|
1936
|
-
await cmd[targetMeta.key](...commandArgs);
|
|
1937
|
-
});
|
|
1938
|
-
}
|
|
1991
|
+
const cmd = new command();
|
|
1992
|
+
await cmd[targetMeta.key](...commandArgs);
|
|
1993
|
+
});
|
|
1939
1994
|
}
|
|
1940
1995
|
}
|
|
1941
|
-
|
|
1942
|
-
|
|
1996
|
+
}
|
|
1997
|
+
await import_commander.program.parseAsync(process.argv);
|
|
1998
|
+
};
|
|
1943
1999
|
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
})();
|
|
2000
|
+
// pkgs/@akanjs/devkit/src/installExternalLib.ts
|
|
2001
|
+
var installExternalLib = async (libName, workspace) => {
|
|
2002
|
+
workspace.log(`Installing ${libName} library as git subtree...`);
|
|
2003
|
+
await workspace.exec(`git remote add ${libName} git@github.com:akan-team/${libName}.git`);
|
|
2004
|
+
await workspace.exec(`git subtree add --prefix=libs/${libName} ${libName} main`);
|
|
2005
|
+
};
|
|
1951
2006
|
//!Field.Prop 거르기가 빡세네.
|
|
1952
2007
|
//! Temp
|