@akanjs/devkit 0.0.102 → 0.0.103

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 (65) hide show
  1. package/index.js +21 -1
  2. package/index.mjs +1 -0
  3. package/package.json +4 -4
  4. package/src/aiEditor.js +56 -22
  5. package/src/{aiEditor.cjs → aiEditor.mjs} +22 -56
  6. package/src/auth.js +48 -18
  7. package/src/auth.mjs +42 -0
  8. package/src/builder.js +42 -9
  9. package/src/{builder.cjs → builder.mjs} +9 -42
  10. package/src/capacitorApp.js +42 -9
  11. package/src/{capacitorApp.cjs → capacitorApp.mjs} +9 -42
  12. package/src/commandDecorators/argMeta.js +34 -3
  13. package/src/commandDecorators/{argMeta.cjs → argMeta.mjs} +3 -34
  14. package/src/commandDecorators/command.js +70 -37
  15. package/src/commandDecorators/{command.cjs → command.mjs} +37 -70
  16. package/src/commandDecorators/commandMeta.js +25 -2
  17. package/src/commandDecorators/commandMeta.mjs +7 -0
  18. package/src/commandDecorators/index.js +29 -5
  19. package/src/commandDecorators/index.mjs +5 -0
  20. package/src/commandDecorators/targetMeta.js +26 -2
  21. package/src/commandDecorators/targetMeta.mjs +33 -0
  22. package/src/commandDecorators/types.js +15 -0
  23. package/src/commandDecorators/types.mjs +0 -0
  24. package/src/constants.js +33 -4
  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 +1 -1
  31. package/src/executors.js +123 -89
  32. package/src/{executors.cjs → executors.mjs} +89 -123
  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.js +48 -9
  40. package/src/{getRelatedCnsts.cjs → getRelatedCnsts.mjs} +9 -48
  41. package/src/index.js +53 -17
  42. package/src/index.mjs +17 -0
  43. package/src/selectModel.js +39 -6
  44. package/src/selectModel.mjs +13 -0
  45. package/src/streamAi.js +30 -7
  46. package/src/streamAi.mjs +39 -0
  47. package/src/types.js +15 -0
  48. package/src/types.mjs +0 -0
  49. package/src/uploadRelease.js +48 -15
  50. package/src/uploadRelease.mjs +52 -0
  51. package/index.cjs +0 -21
  52. package/src/auth.cjs +0 -72
  53. package/src/commandDecorators/commandMeta.cjs +0 -30
  54. package/src/commandDecorators/index.cjs +0 -29
  55. package/src/commandDecorators/targetMeta.cjs +0 -57
  56. package/src/commandDecorators/types.cjs +0 -15
  57. package/src/constants.cjs +0 -47
  58. package/src/createTunnel.cjs +0 -49
  59. package/src/getCredentials.cjs +0 -44
  60. package/src/getModelFileData.cjs +0 -66
  61. package/src/index.cjs +0 -53
  62. package/src/selectModel.cjs +0 -46
  63. package/src/streamAi.cjs +0 -62
  64. package/src/types.cjs +0 -15
  65. package/src/uploadRelease.cjs +0 -85
package/index.js CHANGED
@@ -1 +1,21 @@
1
- export * from "./src";
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 devkit_exports = {};
16
+ module.exports = __toCommonJS(devkit_exports);
17
+ __reExport(devkit_exports, require("./src"), module.exports);
18
+ // Annotate the CommonJS export names for ESM import in node:
19
+ 0 && (module.exports = {
20
+ ...require("./src")
21
+ });
package/index.mjs ADDED
@@ -0,0 +1 @@
1
+ export * from "./src";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@akanjs/devkit",
3
- "version": "0.0.102",
4
- "type": "module",
3
+ "version": "0.0.103",
4
+ "type": "commonjs",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -34,8 +34,8 @@
34
34
  },
35
35
  "exports": {
36
36
  ".": {
37
- "require": "./index.cjs",
38
- "import": "./index.js"
37
+ "require": "./index.js",
38
+ "import": "./index.mjs"
39
39
  }
40
40
  },
41
41
  "esbuild": {
package/src/aiEditor.js CHANGED
@@ -1,9 +1,42 @@
1
- import { Logger } from "@akanjs/common";
2
- import { input, select } from "@inquirer/prompts";
3
- import { AIMessage, HumanMessage } from "@langchain/core/messages";
4
- import { ChatOpenAI } from "@langchain/openai";
5
- import chalk from "chalk";
6
- import { getAkanGlobalConfig, setAkanGlobalConfig } from "./auth";
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 aiEditor_exports = {};
29
+ __export(aiEditor_exports, {
30
+ AiSession: () => AiSession,
31
+ supportedLlmModels: () => supportedLlmModels
32
+ });
33
+ module.exports = __toCommonJS(aiEditor_exports);
34
+ var import_common = require("@akanjs/common");
35
+ var import_prompts = require("@inquirer/prompts");
36
+ var import_messages = require("@langchain/core/messages");
37
+ var import_openai = require("@langchain/openai");
38
+ var import_chalk = __toESM(require("chalk"));
39
+ var import_auth = require("./auth");
7
40
  const MAX_ASK_TRY = 300;
8
41
  const supportedLlmModels = ["deepseek-chat", "deepseek-reasoner"];
9
42
  class AiSession {
@@ -20,7 +53,7 @@ class AiSession {
20
53
  return this.#setChatModel(model, apiKey, { temperature }).setLlmConfig({ model, apiKey });
21
54
  }
22
55
  static #setChatModel(model, apiKey, { temperature = 0.7 } = {}) {
23
- this.#chat = new ChatOpenAI({
56
+ this.#chat = new import_openai.ChatOpenAI({
24
57
  modelName: model,
25
58
  temperature,
26
59
  streaming: true,
@@ -29,22 +62,22 @@ class AiSession {
29
62
  return this;
30
63
  }
31
64
  static getLlmConfig() {
32
- const akanConfig = getAkanGlobalConfig();
65
+ const akanConfig = (0, import_auth.getAkanGlobalConfig)();
33
66
  return akanConfig.llm ?? null;
34
67
  }
35
68
  static setLlmConfig(llmConfig) {
36
- const akanConfig = getAkanGlobalConfig();
69
+ const akanConfig = (0, import_auth.getAkanGlobalConfig)();
37
70
  akanConfig.llm = llmConfig;
38
- setAkanGlobalConfig(akanConfig);
71
+ (0, import_auth.setAkanGlobalConfig)(akanConfig);
39
72
  return this;
40
73
  }
41
74
  static async #requestLlmConfig() {
42
- const model = await select({ message: "Select a LLM model", choices: supportedLlmModels });
43
- const apiKey = await input({ message: "Enter your API key" });
75
+ const model = await (0, import_prompts.select)({ message: "Select a LLM model", choices: supportedLlmModels });
76
+ const apiKey = await (0, import_prompts.input)({ message: "Enter your API key" });
44
77
  return { model, apiKey };
45
78
  }
46
79
  static async #validateApiKey(modelName, apiKey) {
47
- const chat = new ChatOpenAI({
80
+ const chat = new import_openai.ChatOpenAI({
48
81
  modelName,
49
82
  temperature: 0,
50
83
  configuration: { baseURL: "https://api.deepseek.com/v1", apiKey }
@@ -53,8 +86,8 @@ class AiSession {
53
86
  await chat.invoke("Hi, and just say 'ok'");
54
87
  return true;
55
88
  } catch (error) {
56
- Logger.rawLog(
57
- chalk.red(
89
+ import_common.Logger.rawLog(
90
+ import_chalk.default.red(
58
91
  `LLM API key is invalid. Please check your API key and try again. You can set it again by running "akan set-llm" or reset by running "akan reset-llm"`
59
92
  )
60
93
  );
@@ -67,13 +100,13 @@ class AiSession {
67
100
  }
68
101
  async ask(question, {
69
102
  onChunk = (chunk) => {
70
- Logger.raw(chunk);
103
+ import_common.Logger.raw(chunk);
71
104
  }
72
105
  } = {}) {
73
106
  if (!AiSession.#chat)
74
107
  throw new Error("Please initialize the AI session first");
75
108
  try {
76
- const humanMessage = new HumanMessage(question);
109
+ const humanMessage = new import_messages.HumanMessage(question);
77
110
  this.messageHistory.push(humanMessage);
78
111
  const stream = await AiSession.#chat.stream(this.messageHistory);
79
112
  let fullResponse = "";
@@ -86,7 +119,7 @@ class AiSession {
86
119
  }
87
120
  fullResponse += "\n";
88
121
  onChunk("\n");
89
- this.messageHistory.push(new AIMessage(fullResponse));
122
+ this.messageHistory.push(new import_messages.AIMessage(fullResponse));
90
123
  return { content: fullResponse, messageHistory: this.messageHistory };
91
124
  } catch (error) {
92
125
  throw new Error("Failed to stream response");
@@ -95,7 +128,7 @@ class AiSession {
95
128
  async edit(question, { onChunk, maxTry = MAX_ASK_TRY } = {}) {
96
129
  for (let tryCount = 0; tryCount < maxTry; tryCount++) {
97
130
  const response = await this.ask(question, { onChunk });
98
- const isConfirmed = await select({
131
+ const isConfirmed = await (0, import_prompts.select)({
99
132
  message: "Do you want to edit the response?",
100
133
  choices: [
101
134
  { name: "\u2705 Yes, confirm and apply this result", value: true },
@@ -104,7 +137,7 @@ class AiSession {
104
137
  });
105
138
  if (isConfirmed)
106
139
  return response.content;
107
- question = await input({ message: "What do you want to change?" });
140
+ question = await (0, import_prompts.input)({ message: "What do you want to change?" });
108
141
  tryCount++;
109
142
  }
110
143
  throw new Error("Failed to edit");
@@ -118,7 +151,8 @@ class AiSession {
118
151
  return code ? code[2] : content;
119
152
  }
120
153
  }
121
- export {
154
+ // Annotate the CommonJS export names for ESM import in node:
155
+ 0 && (module.exports = {
122
156
  AiSession,
123
157
  supportedLlmModels
124
- };
158
+ });
@@ -1,42 +1,9 @@
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 aiEditor_exports = {};
29
- __export(aiEditor_exports, {
30
- AiSession: () => AiSession,
31
- supportedLlmModels: () => supportedLlmModels
32
- });
33
- module.exports = __toCommonJS(aiEditor_exports);
34
- var import_common = require("@akanjs/common");
35
- var import_prompts = require("@inquirer/prompts");
36
- var import_messages = require("@langchain/core/messages");
37
- var import_openai = require("@langchain/openai");
38
- var import_chalk = __toESM(require("chalk"), 1);
39
- var import_auth = require("./auth");
1
+ import { Logger } from "@akanjs/common";
2
+ import { input, select } from "@inquirer/prompts";
3
+ import { AIMessage, HumanMessage } from "@langchain/core/messages";
4
+ import { ChatOpenAI } from "@langchain/openai";
5
+ import chalk from "chalk";
6
+ import { getAkanGlobalConfig, setAkanGlobalConfig } from "./auth";
40
7
  const MAX_ASK_TRY = 300;
41
8
  const supportedLlmModels = ["deepseek-chat", "deepseek-reasoner"];
42
9
  class AiSession {
@@ -53,7 +20,7 @@ class AiSession {
53
20
  return this.#setChatModel(model, apiKey, { temperature }).setLlmConfig({ model, apiKey });
54
21
  }
55
22
  static #setChatModel(model, apiKey, { temperature = 0.7 } = {}) {
56
- this.#chat = new import_openai.ChatOpenAI({
23
+ this.#chat = new ChatOpenAI({
57
24
  modelName: model,
58
25
  temperature,
59
26
  streaming: true,
@@ -62,22 +29,22 @@ class AiSession {
62
29
  return this;
63
30
  }
64
31
  static getLlmConfig() {
65
- const akanConfig = (0, import_auth.getAkanGlobalConfig)();
32
+ const akanConfig = getAkanGlobalConfig();
66
33
  return akanConfig.llm ?? null;
67
34
  }
68
35
  static setLlmConfig(llmConfig) {
69
- const akanConfig = (0, import_auth.getAkanGlobalConfig)();
36
+ const akanConfig = getAkanGlobalConfig();
70
37
  akanConfig.llm = llmConfig;
71
- (0, import_auth.setAkanGlobalConfig)(akanConfig);
38
+ setAkanGlobalConfig(akanConfig);
72
39
  return this;
73
40
  }
74
41
  static async #requestLlmConfig() {
75
- const model = await (0, import_prompts.select)({ message: "Select a LLM model", choices: supportedLlmModels });
76
- const apiKey = await (0, import_prompts.input)({ message: "Enter your API key" });
42
+ const model = await select({ message: "Select a LLM model", choices: supportedLlmModels });
43
+ const apiKey = await input({ message: "Enter your API key" });
77
44
  return { model, apiKey };
78
45
  }
79
46
  static async #validateApiKey(modelName, apiKey) {
80
- const chat = new import_openai.ChatOpenAI({
47
+ const chat = new ChatOpenAI({
81
48
  modelName,
82
49
  temperature: 0,
83
50
  configuration: { baseURL: "https://api.deepseek.com/v1", apiKey }
@@ -86,8 +53,8 @@ class AiSession {
86
53
  await chat.invoke("Hi, and just say 'ok'");
87
54
  return true;
88
55
  } catch (error) {
89
- import_common.Logger.rawLog(
90
- import_chalk.default.red(
56
+ Logger.rawLog(
57
+ chalk.red(
91
58
  `LLM API key is invalid. Please check your API key and try again. You can set it again by running "akan set-llm" or reset by running "akan reset-llm"`
92
59
  )
93
60
  );
@@ -100,13 +67,13 @@ class AiSession {
100
67
  }
101
68
  async ask(question, {
102
69
  onChunk = (chunk) => {
103
- import_common.Logger.raw(chunk);
70
+ Logger.raw(chunk);
104
71
  }
105
72
  } = {}) {
106
73
  if (!AiSession.#chat)
107
74
  throw new Error("Please initialize the AI session first");
108
75
  try {
109
- const humanMessage = new import_messages.HumanMessage(question);
76
+ const humanMessage = new HumanMessage(question);
110
77
  this.messageHistory.push(humanMessage);
111
78
  const stream = await AiSession.#chat.stream(this.messageHistory);
112
79
  let fullResponse = "";
@@ -119,7 +86,7 @@ class AiSession {
119
86
  }
120
87
  fullResponse += "\n";
121
88
  onChunk("\n");
122
- this.messageHistory.push(new import_messages.AIMessage(fullResponse));
89
+ this.messageHistory.push(new AIMessage(fullResponse));
123
90
  return { content: fullResponse, messageHistory: this.messageHistory };
124
91
  } catch (error) {
125
92
  throw new Error("Failed to stream response");
@@ -128,7 +95,7 @@ class AiSession {
128
95
  async edit(question, { onChunk, maxTry = MAX_ASK_TRY } = {}) {
129
96
  for (let tryCount = 0; tryCount < maxTry; tryCount++) {
130
97
  const response = await this.ask(question, { onChunk });
131
- const isConfirmed = await (0, import_prompts.select)({
98
+ const isConfirmed = await select({
132
99
  message: "Do you want to edit the response?",
133
100
  choices: [
134
101
  { name: "\u2705 Yes, confirm and apply this result", value: true },
@@ -137,7 +104,7 @@ class AiSession {
137
104
  });
138
105
  if (isConfirmed)
139
106
  return response.content;
140
- question = await (0, import_prompts.input)({ message: "What do you want to change?" });
107
+ question = await input({ message: "What do you want to change?" });
141
108
  tryCount++;
142
109
  }
143
110
  throw new Error("Failed to edit");
@@ -151,8 +118,7 @@ class AiSession {
151
118
  return code ? code[2] : content;
152
119
  }
153
120
  }
154
- // Annotate the CommonJS export names for ESM import in node:
155
- 0 && (module.exports = {
121
+ export {
156
122
  AiSession,
157
123
  supportedLlmModels
158
- });
124
+ };
package/src/auth.js CHANGED
@@ -1,42 +1,72 @@
1
- import fs from "fs";
2
- import {
3
- akanCloudBackendUrl,
4
- akanCloudHost,
5
- basePath,
6
- configPath,
7
- defaultAkanGlobalConfig,
8
- defaultHostConfig
9
- } from "./constants";
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"));
38
+ var import_constants = require("./constants");
10
39
  const getAkanGlobalConfig = () => {
11
- const akanConfig = fs.existsSync(configPath) ? JSON.parse(fs.readFileSync(configPath, "utf8")) : defaultAkanGlobalConfig;
40
+ const akanConfig = import_fs.default.existsSync(import_constants.configPath) ? JSON.parse(import_fs.default.readFileSync(import_constants.configPath, "utf8")) : import_constants.defaultAkanGlobalConfig;
12
41
  return akanConfig;
13
42
  };
14
43
  const setAkanGlobalConfig = (akanConfig) => {
15
- fs.mkdirSync(basePath, { recursive: true });
16
- fs.writeFileSync(configPath, JSON.stringify(akanConfig, null, 2));
44
+ import_fs.default.mkdirSync(import_constants.basePath, { recursive: true });
45
+ import_fs.default.writeFileSync(import_constants.configPath, JSON.stringify(akanConfig, null, 2));
17
46
  };
18
- const getHostConfig = (host = akanCloudHost) => {
47
+ const getHostConfig = (host = import_constants.akanCloudHost) => {
19
48
  const akanConfig = getAkanGlobalConfig();
20
- return akanConfig.cloudHost[host] ?? defaultHostConfig;
49
+ return akanConfig.cloudHost[host] ?? import_constants.defaultHostConfig;
21
50
  };
22
- const setHostConfig = (host = akanCloudHost, config = {}) => {
51
+ const setHostConfig = (host = import_constants.akanCloudHost, config = {}) => {
23
52
  const akanConfig = getAkanGlobalConfig();
24
53
  akanConfig[host] = config;
25
54
  setAkanGlobalConfig(akanConfig);
26
55
  };
27
56
  const getSelf = async (token) => {
28
57
  try {
29
- const res = await fetch(`${akanCloudBackendUrl}/user/getSelf`, { headers: { Authorization: `Bearer ${token}` } });
58
+ const res = await fetch(`${import_constants.akanCloudBackendUrl}/user/getSelf`, { headers: { Authorization: `Bearer ${token}` } });
30
59
  const user = await res.json();
31
60
  return user;
32
61
  } catch (e) {
33
62
  return null;
34
63
  }
35
64
  };
36
- export {
65
+ // Annotate the CommonJS export names for ESM import in node:
66
+ 0 && (module.exports = {
37
67
  getAkanGlobalConfig,
38
68
  getHostConfig,
39
69
  getSelf,
40
70
  setAkanGlobalConfig,
41
71
  setHostConfig
42
- };
72
+ });
package/src/auth.mjs ADDED
@@ -0,0 +1,42 @@
1
+ import fs from "fs";
2
+ import {
3
+ akanCloudBackendUrl,
4
+ akanCloudHost,
5
+ basePath,
6
+ configPath,
7
+ defaultAkanGlobalConfig,
8
+ defaultHostConfig
9
+ } from "./constants";
10
+ const getAkanGlobalConfig = () => {
11
+ const akanConfig = fs.existsSync(configPath) ? JSON.parse(fs.readFileSync(configPath, "utf8")) : defaultAkanGlobalConfig;
12
+ return akanConfig;
13
+ };
14
+ const setAkanGlobalConfig = (akanConfig) => {
15
+ fs.mkdirSync(basePath, { recursive: true });
16
+ fs.writeFileSync(configPath, JSON.stringify(akanConfig, null, 2));
17
+ };
18
+ const getHostConfig = (host = akanCloudHost) => {
19
+ const akanConfig = getAkanGlobalConfig();
20
+ return akanConfig.cloudHost[host] ?? defaultHostConfig;
21
+ };
22
+ const setHostConfig = (host = akanCloudHost, config = {}) => {
23
+ const akanConfig = getAkanGlobalConfig();
24
+ akanConfig[host] = config;
25
+ setAkanGlobalConfig(akanConfig);
26
+ };
27
+ const getSelf = async (token) => {
28
+ try {
29
+ const res = await fetch(`${akanCloudBackendUrl}/user/getSelf`, { headers: { Authorization: `Bearer ${token}` } });
30
+ const user = await res.json();
31
+ return user;
32
+ } catch (e) {
33
+ return null;
34
+ }
35
+ };
36
+ export {
37
+ getAkanGlobalConfig,
38
+ getHostConfig,
39
+ getSelf,
40
+ setAkanGlobalConfig,
41
+ setHostConfig
42
+ };
package/src/builder.js CHANGED
@@ -1,7 +1,39 @@
1
- import * as esbuild from "esbuild";
2
- import { dtsPlugin } from "esbuild-plugin-d.ts";
3
- import fs from "fs";
4
- import { extractDependencies } from "./extractDeps";
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 builder_exports = {};
29
+ __export(builder_exports, {
30
+ Builder: () => Builder
31
+ });
32
+ module.exports = __toCommonJS(builder_exports);
33
+ var esbuild = __toESM(require("esbuild"));
34
+ var import_esbuild_plugin_d = require("esbuild-plugin-d.ts");
35
+ var import_fs = __toESM(require("fs"));
36
+ var import_extractDeps = require("./extractDeps");
5
37
  class Builder {
6
38
  #executor;
7
39
  #distExecutor;
@@ -45,16 +77,16 @@ class Builder {
45
77
  };
46
78
  }
47
79
  async build(options = {}) {
48
- if (fs.existsSync(this.#distExecutor.cwdPath))
80
+ if (import_fs.default.existsSync(this.#distExecutor.cwdPath))
49
81
  await this.#distExecutor.exec(`rm -rf ${this.#distExecutor.cwdPath}`);
50
- const plugins = [dtsPlugin({ tsconfig: `${this.#executor.cwdPath}/tsconfig.json` })];
82
+ const plugins = [(0, import_esbuild_plugin_d.dtsPlugin)({ tsconfig: `${this.#executor.cwdPath}/tsconfig.json` })];
51
83
  const [buildResult] = await Promise.all([
52
84
  esbuild.build({ ...this.#getBuildOptions("cjs", options), write: false, plugins }),
53
85
  esbuild.build({ write: true, ...this.#getBuildOptions("esm", options) }),
54
86
  esbuild.build({ ...this.#getAssetBuildOptions() })
55
87
  ]);
56
88
  const existingDeps = Object.keys(this.#pkgJson.dependencies ?? {});
57
- const dependencies = extractDependencies(buildResult.outputFiles, this.#rootPackageJson, existingDeps);
89
+ const dependencies = (0, import_extractDeps.extractDependencies)(buildResult.outputFiles, this.#rootPackageJson, existingDeps);
58
90
  const pkgPackageJson = {
59
91
  ...this.#pkgJson,
60
92
  main: "./index.js",
@@ -72,6 +104,7 @@ class Builder {
72
104
  this.#distExecutor.writeJson("package.json", pkgPackageJson);
73
105
  }
74
106
  }
75
- export {
107
+ // Annotate the CommonJS export names for ESM import in node:
108
+ 0 && (module.exports = {
76
109
  Builder
77
- };
110
+ });
@@ -1,39 +1,7 @@
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 builder_exports = {};
29
- __export(builder_exports, {
30
- Builder: () => Builder
31
- });
32
- module.exports = __toCommonJS(builder_exports);
33
- var esbuild = __toESM(require("esbuild"), 1);
34
- var import_esbuild_plugin_d = require("esbuild-plugin-d.ts");
35
- var import_fs = __toESM(require("fs"), 1);
36
- var import_extractDeps = require("./extractDeps");
1
+ import * as esbuild from "esbuild";
2
+ import { dtsPlugin } from "esbuild-plugin-d.ts";
3
+ import fs from "fs";
4
+ import { extractDependencies } from "./extractDeps";
37
5
  class Builder {
38
6
  #executor;
39
7
  #distExecutor;
@@ -77,16 +45,16 @@ class Builder {
77
45
  };
78
46
  }
79
47
  async build(options = {}) {
80
- if (import_fs.default.existsSync(this.#distExecutor.cwdPath))
48
+ if (fs.existsSync(this.#distExecutor.cwdPath))
81
49
  await this.#distExecutor.exec(`rm -rf ${this.#distExecutor.cwdPath}`);
82
- const plugins = [(0, import_esbuild_plugin_d.dtsPlugin)({ tsconfig: `${this.#executor.cwdPath}/tsconfig.json` })];
50
+ const plugins = [dtsPlugin({ tsconfig: `${this.#executor.cwdPath}/tsconfig.json` })];
83
51
  const [buildResult] = await Promise.all([
84
52
  esbuild.build({ ...this.#getBuildOptions("cjs", options), write: false, plugins }),
85
53
  esbuild.build({ write: true, ...this.#getBuildOptions("esm", options) }),
86
54
  esbuild.build({ ...this.#getAssetBuildOptions() })
87
55
  ]);
88
56
  const existingDeps = Object.keys(this.#pkgJson.dependencies ?? {});
89
- const dependencies = (0, import_extractDeps.extractDependencies)(buildResult.outputFiles, this.#rootPackageJson, existingDeps);
57
+ const dependencies = extractDependencies(buildResult.outputFiles, this.#rootPackageJson, existingDeps);
90
58
  const pkgPackageJson = {
91
59
  ...this.#pkgJson,
92
60
  main: "./index.js",
@@ -104,7 +72,6 @@ class Builder {
104
72
  this.#distExecutor.writeJson("package.json", pkgPackageJson);
105
73
  }
106
74
  }
107
- // Annotate the CommonJS export names for ESM import in node:
108
- 0 && (module.exports = {
75
+ export {
109
76
  Builder
110
- });
77
+ };