@akanjs/devkit 0.0.89 → 0.0.90

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/index.js +21 -1
  2. package/index.mjs +1 -0
  3. package/package.json +5 -4
  4. package/src/aiEditor.d.ts +14 -0
  5. package/src/aiEditor.js +110 -21
  6. package/src/aiEditor.mjs +124 -0
  7. package/src/auth.js +48 -18
  8. package/src/auth.mjs +42 -0
  9. package/src/capacitorApp.js +42 -9
  10. package/src/{capacitorApp.cjs → capacitorApp.mjs} +9 -42
  11. package/src/commandDecorators/argMeta.js +34 -3
  12. package/src/commandDecorators/{argMeta.cjs → argMeta.mjs} +3 -34
  13. package/src/commandDecorators/command.js +68 -35
  14. package/src/commandDecorators/{command.cjs → command.mjs} +35 -68
  15. package/src/commandDecorators/commandMeta.js +25 -2
  16. package/src/commandDecorators/commandMeta.mjs +7 -0
  17. package/src/commandDecorators/index.js +29 -5
  18. package/src/commandDecorators/index.mjs +5 -0
  19. package/src/commandDecorators/targetMeta.js +26 -2
  20. package/src/commandDecorators/targetMeta.mjs +33 -0
  21. package/src/commandDecorators/types.js +15 -0
  22. package/src/commandDecorators/types.mjs +0 -0
  23. package/src/constants.d.ts +8 -1
  24. package/src/constants.js +34 -5
  25. package/src/constants.mjs +18 -0
  26. package/src/createTunnel.js +27 -4
  27. package/src/createTunnel.mjs +26 -0
  28. package/src/dependencyScanner.js +38 -5
  29. package/src/{dependencyScanner.cjs → dependencyScanner.mjs} +5 -38
  30. package/src/executors.d.ts +21 -1
  31. package/src/executors.js +172 -84
  32. package/src/{executors.cjs → executors.mjs} +138 -118
  33. package/src/extractDeps.js +25 -2
  34. package/src/{extractDeps.cjs → extractDeps.mjs} +2 -25
  35. package/src/getCredentials.js +39 -6
  36. package/src/getCredentials.mjs +11 -0
  37. package/src/getModelFileData.js +39 -6
  38. package/src/getModelFileData.mjs +33 -0
  39. package/src/getRelatedCnsts.d.ts +52 -8
  40. package/src/getRelatedCnsts.js +205 -54
  41. package/src/getRelatedCnsts.mjs +221 -0
  42. package/src/index.js +51 -16
  43. package/src/index.mjs +16 -0
  44. package/src/selectModel.js +39 -6
  45. package/src/selectModel.mjs +13 -0
  46. package/src/streamAi.js +30 -7
  47. package/src/streamAi.mjs +39 -0
  48. package/src/types.js +15 -0
  49. package/src/types.mjs +0 -0
  50. package/src/uploadRelease.js +48 -15
  51. package/src/uploadRelease.mjs +52 -0
  52. package/index.cjs +0 -21
  53. package/src/aiEditor.cjs +0 -92
  54. package/src/auth.cjs +0 -72
  55. package/src/commandDecorators/commandMeta.cjs +0 -30
  56. package/src/commandDecorators/index.cjs +0 -29
  57. package/src/commandDecorators/targetMeta.cjs +0 -57
  58. package/src/commandDecorators/types.cjs +0 -15
  59. package/src/constants.cjs +0 -47
  60. package/src/createTunnel.cjs +0 -49
  61. package/src/getCredentials.cjs +0 -44
  62. package/src/getModelFileData.cjs +0 -66
  63. package/src/getRelatedCnsts.cjs +0 -142
  64. package/src/index.cjs +0 -51
  65. package/src/selectModel.cjs +0 -46
  66. package/src/streamAi.cjs +0 -62
  67. package/src/types.cjs +0 -15
  68. package/src/uploadRelease.cjs +0 -85
package/src/aiEditor.cjs DELETED
@@ -1,92 +0,0 @@
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 aiEditor_exports = {};
19
- __export(aiEditor_exports, {
20
- AiSession: () => AiSession
21
- });
22
- module.exports = __toCommonJS(aiEditor_exports);
23
- var import_common = require("@akanjs/common");
24
- var import_prompts = require("@inquirer/prompts");
25
- var import_messages = require("@langchain/core/messages");
26
- var import_openai = require("@langchain/openai");
27
- const MAX_ASK_TRY = 300;
28
- class AiSession {
29
- static #chat = new import_openai.ChatOpenAI({
30
- modelName: "deepseek-chat",
31
- temperature: 0.7,
32
- streaming: true,
33
- // Enable streaming
34
- configuration: { baseURL: "https://api.deepseek.com/v1", apiKey: process.env.DEEPSEEK_API_KEY }
35
- });
36
- messageHistory = [];
37
- constructor(messageHistory = []) {
38
- this.messageHistory = messageHistory;
39
- }
40
- async ask(question, {
41
- onChunk = (chunk) => {
42
- import_common.Logger.raw(chunk);
43
- }
44
- } = {}) {
45
- try {
46
- const humanMessage = new import_messages.HumanMessage(question);
47
- this.messageHistory.push(humanMessage);
48
- const stream = await AiSession.#chat.stream(this.messageHistory);
49
- let fullResponse = "";
50
- for await (const chunk of stream) {
51
- const content = chunk.content;
52
- if (typeof content === "string") {
53
- fullResponse += content;
54
- onChunk(content);
55
- }
56
- }
57
- this.messageHistory.push(new import_messages.AIMessage(fullResponse));
58
- return { content: fullResponse, messageHistory: this.messageHistory };
59
- } catch (error) {
60
- throw new Error("Failed to stream response");
61
- }
62
- }
63
- async edit(question, { onChunk, maxTry = MAX_ASK_TRY } = {}) {
64
- for (let tryCount = 0; tryCount < maxTry; tryCount++) {
65
- const response = await this.ask(question, { onChunk });
66
- const isConfirmed = await (0, import_prompts.select)({
67
- message: "Do you want to edit the response?",
68
- choices: [
69
- { name: "\u2705 Yes, confirm and apply this result", value: true },
70
- { name: "\u{1F504} No, I want to edit it more", value: false }
71
- ]
72
- });
73
- if (isConfirmed)
74
- return response.content;
75
- question = await (0, import_prompts.input)({ message: "What do you want to change?" });
76
- tryCount++;
77
- }
78
- throw new Error("Failed to edit");
79
- }
80
- async editTypescript(question, options = {}) {
81
- const content = await this.edit(question, options);
82
- return this.#getTypescriptCode(content);
83
- }
84
- #getTypescriptCode(content) {
85
- const code = /```typescript([\s\S]*?)```/.exec(content);
86
- return code ? code[1] : content;
87
- }
88
- }
89
- // Annotate the CommonJS export names for ESM import in node:
90
- 0 && (module.exports = {
91
- AiSession
92
- });
package/src/auth.cjs DELETED
@@ -1,72 +0,0 @@
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);
28
- var auth_exports = {};
29
- __export(auth_exports, {
30
- getAkanGlobalConfig: () => getAkanGlobalConfig,
31
- getHostConfig: () => getHostConfig,
32
- getSelf: () => getSelf,
33
- setAkanGlobalConfig: () => setAkanGlobalConfig,
34
- setHostConfig: () => setHostConfig
35
- });
36
- module.exports = __toCommonJS(auth_exports);
37
- var import_fs = __toESM(require("fs"), 1);
38
- var import_constants = require("./constants");
39
- const getAkanGlobalConfig = () => {
40
- const akanConfig = import_fs.default.existsSync(import_constants.configPath) ? JSON.parse(import_fs.default.readFileSync(import_constants.configPath, "utf8")) : import_constants.defaultAkanGlobalConfig;
41
- return akanConfig;
42
- };
43
- const setAkanGlobalConfig = (akanConfig) => {
44
- import_fs.default.mkdirSync(import_constants.basePath, { recursive: true });
45
- import_fs.default.writeFileSync(import_constants.configPath, JSON.stringify(akanConfig, null, 2));
46
- };
47
- const getHostConfig = (host = import_constants.akanCloudHost) => {
48
- const akanConfig = getAkanGlobalConfig();
49
- return akanConfig[host] ?? import_constants.defaultHostConfig;
50
- };
51
- const setHostConfig = (host = import_constants.akanCloudHost, config = {}) => {
52
- const akanConfig = getAkanGlobalConfig();
53
- akanConfig[host] = config;
54
- setAkanGlobalConfig(akanConfig);
55
- };
56
- const getSelf = async (token) => {
57
- try {
58
- const res = await fetch(`${import_constants.akanCloudBackendUrl}/user/getSelf`, { headers: { Authorization: `Bearer ${token}` } });
59
- const user = await res.json();
60
- return user;
61
- } catch (e) {
62
- return null;
63
- }
64
- };
65
- // Annotate the CommonJS export names for ESM import in node:
66
- 0 && (module.exports = {
67
- getAkanGlobalConfig,
68
- getHostConfig,
69
- getSelf,
70
- setAkanGlobalConfig,
71
- setHostConfig
72
- });
@@ -1,30 +0,0 @@
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 commandMeta_exports = {};
19
- __export(commandMeta_exports, {
20
- Commands: () => Commands
21
- });
22
- module.exports = __toCommonJS(commandMeta_exports);
23
- const Commands = () => {
24
- return function(target) {
25
- };
26
- };
27
- // Annotate the CommonJS export names for ESM import in node:
28
- 0 && (module.exports = {
29
- Commands
30
- });
@@ -1,29 +0,0 @@
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 __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
14
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
- var commandDecorators_exports = {};
16
- module.exports = __toCommonJS(commandDecorators_exports);
17
- __reExport(commandDecorators_exports, require("./argMeta"), module.exports);
18
- __reExport(commandDecorators_exports, require("./commandMeta"), module.exports);
19
- __reExport(commandDecorators_exports, require("./targetMeta"), module.exports);
20
- __reExport(commandDecorators_exports, require("./types"), module.exports);
21
- __reExport(commandDecorators_exports, require("./command"), module.exports);
22
- // Annotate the CommonJS export names for ESM import in node:
23
- 0 && (module.exports = {
24
- ...require("./argMeta"),
25
- ...require("./commandMeta"),
26
- ...require("./targetMeta"),
27
- ...require("./types"),
28
- ...require("./command")
29
- });
@@ -1,57 +0,0 @@
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
- };
53
- // Annotate the CommonJS export names for ESM import in node:
54
- 0 && (module.exports = {
55
- Target,
56
- getTargetMetas
57
- });
@@ -1,15 +0,0 @@
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);
package/src/constants.cjs DELETED
@@ -1,47 +0,0 @@
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 = {};
38
- // Annotate the CommonJS export names for ESM import in node:
39
- 0 && (module.exports = {
40
- akanCloudBackendUrl,
41
- akanCloudClientUrl,
42
- akanCloudHost,
43
- basePath,
44
- configPath,
45
- defaultAkanGlobalConfig,
46
- defaultHostConfig
47
- });
@@ -1,49 +0,0 @@
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
- const getSshTunnelOptions = (app, environment) => {
25
- const { serveDomain, repoName } = app.workspace.getBaseDevEnv();
26
- return {
27
- host: `${app.name}-${environment}.${serveDomain}`,
28
- port: process.env.SSH_TUNNEL_PORT ? parseInt(process.env.SSH_TUNNEL_PORT) : 32767,
29
- username: process.env.SSH_TUNNEL_USERNAME ?? "root",
30
- password: process.env.SSH_TUNNEL_PASSWORD ?? repoName
31
- };
32
- };
33
- const createTunnel = async ({ app, environment, port = 27017 }) => {
34
- const tunnelOptions = { autoClose: true, reconnectOnError: true };
35
- const sshOptions = getSshTunnelOptions(app, environment);
36
- const serverOptions = { port };
37
- const forwardOptions = {
38
- srcAddr: "0.0.0.0",
39
- srcPort: port,
40
- dstAddr: `mongo-0.mongo-svc.${app.name}-${environment}`,
41
- dstPort: 27017
42
- };
43
- const [server, client] = await (0, import_tunnel_ssh.createTunnel)(tunnelOptions, serverOptions, sshOptions, forwardOptions);
44
- return `localhost:${port}`;
45
- };
46
- // Annotate the CommonJS export names for ESM import in node:
47
- 0 && (module.exports = {
48
- createTunnel
49
- });
@@ -1,44 +0,0 @@
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);
28
- var getCredentials_exports = {};
29
- __export(getCredentials_exports, {
30
- getCredentials: () => getCredentials
31
- });
32
- module.exports = __toCommonJS(getCredentials_exports);
33
- var import_fs = __toESM(require("fs"), 1);
34
- var import_js_yaml = __toESM(require("js-yaml"), 1);
35
- const getCredentials = (app, environment) => {
36
- const secret = import_js_yaml.default.load(
37
- import_fs.default.readFileSync(`${app.workspace.workspaceRoot}/infra/app/values/${app.name}-secret.yaml`, "utf-8")
38
- );
39
- return secret[environment];
40
- };
41
- // Annotate the CommonJS export names for ESM import in node:
42
- 0 && (module.exports = {
43
- getCredentials
44
- });
@@ -1,66 +0,0 @@
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);
28
- var getModelFileData_exports = {};
29
- __export(getModelFileData_exports, {
30
- getModelFileData: () => getModelFileData
31
- });
32
- module.exports = __toCommonJS(getModelFileData_exports);
33
- var import_fs = __toESM(require("fs"), 1);
34
- const getModelFileData = (modulePath, modelName) => {
35
- const moduleType = modulePath.startsWith("apps") ? "app" : "lib";
36
- const moduleName = modulePath.split("/")[1];
37
- const constantFilePath = `${modulePath}/lib/${modelName}/${modelName}.constant.ts`;
38
- const unitFilePath = `${modulePath}/lib/${modelName}/${modelName}.Unit.tsx`;
39
- const viewFilePath = `${modulePath}/lib/${modelName}/${modelName}.View.tsx`;
40
- const constantFileStr = import_fs.default.readFileSync(constantFilePath, "utf8");
41
- const unitFileStr = import_fs.default.readFileSync(unitFilePath, "utf8");
42
- const viewFileStr = import_fs.default.readFileSync(viewFilePath, "utf8");
43
- const constantFileLines = constantFileStr.split("\n");
44
- const importLibNames = constantFileLines.filter((line) => line.startsWith("import { cnst as ")).map((line) => line.split("cnst as ")[1].split(" ")[0]);
45
- const importLocalPaths = constantFileLines.filter((line) => line.startsWith("import { ") && line.includes('from "../')).map((line) => line.split("from ")[1].split('"')[1]);
46
- const importModelNames = importLocalPaths.map((path) => path.split("/")[1]).filter((name) => !name.startsWith("_"));
47
- const hasImportScalar = !!importLocalPaths.map((path) => path.split("/")[1]).filter((name) => name.startsWith("_")).length;
48
- return {
49
- moduleType,
50
- moduleName,
51
- modelName,
52
- constantFilePath,
53
- unitFilePath,
54
- viewFilePath,
55
- importModelNames,
56
- hasImportScalar,
57
- importLibNames,
58
- constantFileStr,
59
- unitFileStr,
60
- viewFileStr
61
- };
62
- };
63
- // Annotate the CommonJS export names for ESM import in node:
64
- 0 && (module.exports = {
65
- getModelFileData
66
- });
@@ -1,142 +0,0 @@
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);
28
- var getRelatedCnsts_exports = {};
29
- __export(getRelatedCnsts_exports, {
30
- getRelatedCnsts: () => getRelatedCnsts
31
- });
32
- module.exports = __toCommonJS(getRelatedCnsts_exports);
33
- var import_fs = __toESM(require("fs"), 1);
34
- var import_ora = __toESM(require("ora"), 1);
35
- var ts = __toESM(require("typescript"), 1);
36
- const getRelatedCnsts = (constantFilePath) => {
37
- const tsConfigPath = `./tsconfig.json`;
38
- const configFile = ts.readConfigFile(tsConfigPath, (path) => {
39
- return ts.sys.readFile(path);
40
- });
41
- const parsedConfig = ts.parseJsonConfigFileContent(
42
- configFile.config,
43
- ts.sys,
44
- import_fs.default.realpathSync(tsConfigPath).replace(/[^/\\]+$/, "")
45
- );
46
- const propertyMap = /* @__PURE__ */ new Map();
47
- function findPropertyOriginAll(filePath) {
48
- const program = ts.createProgram([filePath], parsedConfig.options);
49
- const checker = program.getTypeChecker();
50
- const source = program.getSourceFile(filePath);
51
- if (!source)
52
- return null;
53
- function visit(node) {
54
- if (!source)
55
- return;
56
- if (ts.isPropertyAccessExpression(node)) {
57
- const left = node.expression;
58
- const right = node.name;
59
- const { line } = ts.getLineAndCharacterOfPosition(source, node.getStart());
60
- //!Field.Prop 거르기가 빡세네.
61
- const sourceLines = source.getFullText().split("\n");
62
- if (ts.isIdentifier(left) && sourceLines.length && (sourceLines[line].includes(`@Field.Prop(() => ${left.text}.${right.text}`) || sourceLines[line].includes(`base.Filter(${left.text}.${right.text},`))) {
63
- const symbol = checker.getSymbolAtLocation(right);
64
- if (symbol?.declarations && symbol.declarations.length > 0) {
65
- const key = symbol.declarations[0].getSourceFile().fileName.split("/").pop()?.split(".")[0] ?? "";
66
- const property = propertyMap.get(key);
67
- const isScalar = symbol.declarations[0].getSourceFile().fileName.includes("_");
68
- const filePath2 = symbol.declarations[0].getSourceFile().fileName.replace(`${ts.sys.getCurrentDirectory()}/`, "");
69
- if (property) {
70
- propertyMap.set(`${left.text}.${right.text}`, {
71
- filePath: filePath2,
72
- isLibModule: true,
73
- isImport: false,
74
- libName: left.text,
75
- isScalar
76
- });
77
- } else
78
- propertyMap.set(key, {
79
- filePath: filePath2,
80
- isLibModule: true,
81
- isImport: false,
82
- libName: left.text,
83
- isScalar
84
- });
85
- findPropertyOriginAll(filePath2);
86
- }
87
- }
88
- } else if (ts.isImportDeclaration(node)) {
89
- const importPath = node.moduleSpecifier.getText().slice(1, -1);
90
- if (importPath.startsWith(".")) {
91
- const resolved = ts.resolveModuleName(importPath, filePath, parsedConfig.options, ts.sys).resolvedModule?.resolvedFileName;
92
- const moduleName = importPath.split("/").pop()?.split(".")[0] ?? "";
93
- const property = propertyMap.get(moduleName);
94
- const isScalar = importPath.includes("_");
95
- if (moduleName && resolved && (!property || property.filePath !== resolved)) {
96
- propertyMap.set(moduleName, {
97
- filePath: resolved,
98
- isLibModule: false,
99
- isImport: true,
100
- isScalar
101
- });
102
- findPropertyOriginAll(resolved);
103
- }
104
- }
105
- }
106
- ts.forEachChild(node, visit);
107
- }
108
- visit(source);
109
- return propertyMap;
110
- }
111
- function findPropertyOrigin(filePath, aliasName, libName) {
112
- const program = ts.createProgram([filePath], parsedConfig.options);
113
- const checker = program.getTypeChecker();
114
- const source = program.getSourceFile(filePath);
115
- const propertyMap2 = /* @__PURE__ */ new Map();
116
- if (!source)
117
- return null;
118
- function visit(node) {
119
- if (ts.isPropertyAccessExpression(node)) {
120
- const left = node.expression;
121
- const right = node.name;
122
- if (ts.isIdentifier(left) && left.text === aliasName && right.text === libName) {
123
- const symbol = checker.getSymbolAtLocation(right);
124
- if (symbol?.declarations && symbol.declarations.length > 0) {
125
- return symbol.declarations[0].getSourceFile().fileName;
126
- }
127
- }
128
- }
129
- return ts.forEachChild(node, visit) || null;
130
- }
131
- return visit(source);
132
- }
133
- const spinner = (0, import_ora.default)("Finding property origin...");
134
- spinner.start();
135
- const paths = findPropertyOriginAll(constantFilePath);
136
- spinner.succeed("property origin found.");
137
- return { paths };
138
- };
139
- // Annotate the CommonJS export names for ESM import in node:
140
- 0 && (module.exports = {
141
- getRelatedCnsts
142
- });