@akanjs/devkit 0.0.54 → 0.0.56

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.
@@ -0,0 +1,52 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var targetMeta_exports = {};
19
+ __export(targetMeta_exports, {
20
+ Target: () => Target,
21
+ getTargetMetas: () => getTargetMetas
22
+ });
23
+ module.exports = __toCommonJS(targetMeta_exports);
24
+ const getTargetMetas = (command) => {
25
+ const targetMetaMap = Reflect.getMetadata("target", command.prototype);
26
+ if (!targetMetaMap)
27
+ throw new Error(`TargetMeta is not defined for ${command.name}`);
28
+ return [...targetMetaMap.values()];
29
+ };
30
+ const getTargetMetaMapOnPrototype = (prototype) => {
31
+ const targetMetaMap = Reflect.getMetadata("target", prototype);
32
+ return targetMetaMap ?? /* @__PURE__ */ new Map();
33
+ };
34
+ const setTargetMetaMapOnPrototype = (prototype, targetMetaMap) => {
35
+ Reflect.defineMetadata("target", targetMetaMap, prototype);
36
+ };
37
+ const getTarget = (type) => (targetOption = {}) => {
38
+ return (prototype, key, descriptor) => {
39
+ const metadataMap = getTargetMetaMapOnPrototype(prototype);
40
+ metadataMap.set(key, {
41
+ key,
42
+ descriptor,
43
+ targetOption: { ...targetOption, type }
44
+ });
45
+ setTargetMetaMapOnPrototype(prototype, metadataMap);
46
+ };
47
+ };
48
+ const Target = {
49
+ Public: getTarget("public"),
50
+ Cloud: getTarget("cloud"),
51
+ Dev: getTarget("dev")
52
+ };
@@ -0,0 +1,15 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __copyProps = (to, from, except, desc) => {
6
+ if (from && typeof from === "object" || typeof from === "function") {
7
+ for (let key of __getOwnPropNames(from))
8
+ if (!__hasOwnProp.call(to, key) && key !== except)
9
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
10
+ }
11
+ return to;
12
+ };
13
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
14
+ var types_exports = {};
15
+ module.exports = __toCommonJS(types_exports);
@@ -0,0 +1,37 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var constants_exports = {};
19
+ __export(constants_exports, {
20
+ akanCloudBackendUrl: () => akanCloudBackendUrl,
21
+ akanCloudClientUrl: () => akanCloudClientUrl,
22
+ akanCloudHost: () => akanCloudHost,
23
+ basePath: () => basePath,
24
+ configPath: () => configPath,
25
+ defaultAkanGlobalConfig: () => defaultAkanGlobalConfig,
26
+ defaultHostConfig: () => defaultHostConfig
27
+ });
28
+ module.exports = __toCommonJS(constants_exports);
29
+ var import_os = require("os");
30
+ const basePath = `${(0, import_os.homedir)()}/.akan`;
31
+ const configPath = `${basePath}/config.json`;
32
+ const akanCloudHost = process.env.NEXT_PUBLIC_OPERATION_MODE === "local" ? "http://localhost" : "https://akasys-debug.akamir.com";
33
+ //! Temp
34
+ const akanCloudBackendUrl = `${akanCloudHost}${process.env.NEXT_PUBLIC_OPERATION_MODE === "local" ? ":8080" : ""}/backend`;
35
+ const akanCloudClientUrl = `${akanCloudHost}${process.env.NEXT_PUBLIC_OPERATION_MODE === "local" ? ":4200" : ""}`;
36
+ const defaultHostConfig = {};
37
+ const defaultAkanGlobalConfig = {};
@@ -0,0 +1,37 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var createTunnel_exports = {};
19
+ __export(createTunnel_exports, {
20
+ createTunnel: () => createTunnel
21
+ });
22
+ module.exports = __toCommonJS(createTunnel_exports);
23
+ var import_tunnel_ssh = require("tunnel-ssh");
24
+ var import_baseDevEnv = require("./baseDevEnv");
25
+ const createTunnel = async ({ appName, environment, port = 27017 }) => {
26
+ const tunnelOptions = { autoClose: true, reconnectOnError: true };
27
+ const sshOptions = (0, import_baseDevEnv.getSshTunnelOptions)(appName, environment);
28
+ const serverOptions = { port };
29
+ const forwardOptions = {
30
+ srcAddr: "0.0.0.0",
31
+ srcPort: port,
32
+ dstAddr: `mongo-0.mongo-svc.${appName}-${environment}`,
33
+ dstPort: 27017
34
+ };
35
+ const [server, client] = await (0, import_tunnel_ssh.createTunnel)(tunnelOptions, serverOptions, sshOptions, forwardOptions);
36
+ return `localhost:${port}`;
37
+ };
@@ -0,0 +1,159 @@
1
+ #!/usr/bin/env ts-node
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var dependencyScanner_exports = {};
30
+ __export(dependencyScanner_exports, {
31
+ TypeScriptDependencyScanner: () => TypeScriptDependencyScanner
32
+ });
33
+ module.exports = __toCommonJS(dependencyScanner_exports);
34
+ var fs = __toESM(require("fs"), 1);
35
+ var path = __toESM(require("path"), 1);
36
+ var ts = __toESM(require("typescript"), 1);
37
+ class TypeScriptDependencyScanner {
38
+ constructor(directory) {
39
+ this.directory = directory;
40
+ }
41
+ #fileDependencies = /* @__PURE__ */ new Map();
42
+ #visitedFiles = /* @__PURE__ */ new Set();
43
+ async getImportSets(depSets) {
44
+ const fileDependencies = await this.getDependencies();
45
+ const importedDepSets = new Array(depSets.length);
46
+ for (let i = 0; i < depSets.length; i++)
47
+ importedDepSets[i] = /* @__PURE__ */ new Set();
48
+ fileDependencies.forEach((imps) => {
49
+ imps.forEach((imp) => {
50
+ if (imp.startsWith("."))
51
+ return;
52
+ const moduleName = imp;
53
+ const moduleNameParts = moduleName.split("/");
54
+ const subModuleLength = moduleNameParts.length;
55
+ for (let i = 0; i < subModuleLength; i++) {
56
+ const importName = moduleNameParts.slice(0, i + 1).join("/");
57
+ for (let j = 0; j < depSets.length; j++) {
58
+ if (depSets[j].has(importName)) {
59
+ importedDepSets[j].add(importName);
60
+ return;
61
+ }
62
+ }
63
+ }
64
+ });
65
+ });
66
+ return importedDepSets;
67
+ }
68
+ async getDependencies() {
69
+ this.#fileDependencies.clear();
70
+ this.#visitedFiles.clear();
71
+ const files = await this.#findTypeScriptFiles(this.directory);
72
+ for (const file of files)
73
+ await this.#analyzeFile(file, this.directory);
74
+ return this.#fileDependencies;
75
+ }
76
+ async #findTypeScriptFiles(directory) {
77
+ const files = [];
78
+ const processDirectory = async (dir) => {
79
+ const entries = await fs.promises.readdir(dir, { withFileTypes: true });
80
+ for (const entry of entries) {
81
+ const fullPath = path.join(dir, entry.name);
82
+ if (entry.isDirectory()) {
83
+ if (!["node_modules", "dist", "build", ".git", ".next", "public", "ios", "android"].includes(entry.name))
84
+ await processDirectory(fullPath);
85
+ } else if (entry.isFile() && (entry.name.endsWith(".ts") || entry.name.endsWith(".tsx")))
86
+ files.push(fullPath);
87
+ }
88
+ };
89
+ await processDirectory(directory);
90
+ return files;
91
+ }
92
+ async #analyzeFile(filePath, baseDir) {
93
+ if (this.#visitedFiles.has(filePath))
94
+ return;
95
+ this.#visitedFiles.add(filePath);
96
+ try {
97
+ const fileContent = await fs.promises.readFile(filePath, "utf-8");
98
+ const imports = this.#extractImports(fileContent, filePath);
99
+ const resolvedImports = imports.map((importPath) => {
100
+ if (importPath.startsWith(".")) {
101
+ const resolvedPath = "./" + path.join(path.relative(baseDir, filePath), importPath);
102
+ return this.#ensureExtension(resolvedPath);
103
+ }
104
+ return importPath;
105
+ });
106
+ const relativePath = path.relative(baseDir, filePath);
107
+ this.#fileDependencies.set(relativePath, resolvedImports);
108
+ } catch (error) {
109
+ }
110
+ }
111
+ #ensureExtension(filePath) {
112
+ if (fs.existsSync(`${filePath}.ts`))
113
+ return `${filePath}.ts`;
114
+ else if (fs.existsSync(`${filePath}.tsx`))
115
+ return `${filePath}.tsx`;
116
+ else if (fs.existsSync(filePath))
117
+ return filePath;
118
+ return `${filePath}.ts`;
119
+ }
120
+ #extractImports(source, filePath) {
121
+ const imports = [];
122
+ const sourceFile = ts.createSourceFile(filePath, source, ts.ScriptTarget.Latest, true);
123
+ const visit = (node) => {
124
+ if (ts.isImportDeclaration(node)) {
125
+ const moduleSpecifier = node.moduleSpecifier;
126
+ if (ts.isStringLiteral(moduleSpecifier))
127
+ imports.push(moduleSpecifier.text);
128
+ }
129
+ ts.forEachChild(node, visit);
130
+ };
131
+ visit(sourceFile);
132
+ return imports;
133
+ }
134
+ generateDependencyGraph() {
135
+ let graph = "Dependency Graph:\n\n";
136
+ for (const [file, imports] of this.#fileDependencies.entries()) {
137
+ graph += `${file}:
138
+ `;
139
+ const projectImports = imports.filter((i) => !i.startsWith("react") && !i.startsWith("@"));
140
+ const externalImports = imports.filter((i) => i.startsWith("react") || i.startsWith("@"));
141
+ if (projectImports.length > 0) {
142
+ graph += " Project dependencies:\n";
143
+ projectImports.forEach((imp) => {
144
+ graph += ` \u2192 ${imp}
145
+ `;
146
+ });
147
+ }
148
+ if (externalImports.length > 0) {
149
+ graph += " External dependencies:\n";
150
+ externalImports.forEach((imp) => {
151
+ graph += ` \u2192 ${imp}
152
+ `;
153
+ });
154
+ }
155
+ graph += "\n";
156
+ }
157
+ return graph;
158
+ }
159
+ }
File without changes