@akanjs/devkit 0.0.91 → 0.0.93
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/README.md +11 -0
- package/package.json +6 -1
- package/src/builder.d.ts +18 -0
- package/src/builder.js +110 -0
- package/src/builder.mjs +77 -0
- package/src/commandDecorators/command.js +13 -6
- package/src/commandDecorators/command.mjs +13 -6
- package/src/executors.d.ts +1 -1
- package/src/executors.js +4 -3
- package/src/executors.mjs +4 -3
- package/src/extractDeps.d.ts +1 -0
- package/src/extractDeps.js +1 -1
- package/src/extractDeps.mjs +1 -1
- package/src/index.d.ts +1 -0
- package/src/index.js +3 -1
- package/src/index.mjs +1 -0
- package/src/types.d.ts +3 -0
package/README.md
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@akanjs/devkit",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.93",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -23,6 +23,8 @@
|
|
|
23
23
|
"chalk": "^5.4.1",
|
|
24
24
|
"commander": "^13.1.0",
|
|
25
25
|
"dotenv": "^16.4.7",
|
|
26
|
+
"esbuild": "^0.19.2",
|
|
27
|
+
"esbuild-plugin-d.ts": "^1.3.1",
|
|
26
28
|
"form-data": "^4.0.1",
|
|
27
29
|
"js-yaml": "^4.1.0",
|
|
28
30
|
"ora": "^3.4.0",
|
|
@@ -35,5 +37,8 @@
|
|
|
35
37
|
"require": "./index.js",
|
|
36
38
|
"import": "./index.mjs"
|
|
37
39
|
}
|
|
40
|
+
},
|
|
41
|
+
"esbuild": {
|
|
42
|
+
"platform": "node"
|
|
38
43
|
}
|
|
39
44
|
}
|
package/src/builder.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Executor } from "./executors";
|
|
2
|
+
import { PackageJson } from "./types";
|
|
3
|
+
interface BuildOptions {
|
|
4
|
+
bundle?: boolean;
|
|
5
|
+
additionalEntryPoints?: string[];
|
|
6
|
+
}
|
|
7
|
+
interface BuilderOptions {
|
|
8
|
+
executor: Executor;
|
|
9
|
+
distExecutor: Executor;
|
|
10
|
+
pkgJson: PackageJson;
|
|
11
|
+
rootPackageJson: PackageJson;
|
|
12
|
+
}
|
|
13
|
+
export declare class Builder {
|
|
14
|
+
#private;
|
|
15
|
+
constructor({ executor, distExecutor, pkgJson, rootPackageJson }: BuilderOptions);
|
|
16
|
+
build(options?: BuildOptions): Promise<void>;
|
|
17
|
+
}
|
|
18
|
+
export {};
|
package/src/builder.js
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
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");
|
|
37
|
+
class Builder {
|
|
38
|
+
#executor;
|
|
39
|
+
#distExecutor;
|
|
40
|
+
#pkgJson;
|
|
41
|
+
#rootPackageJson;
|
|
42
|
+
constructor({ executor, distExecutor, pkgJson, rootPackageJson }) {
|
|
43
|
+
this.#executor = executor;
|
|
44
|
+
this.#distExecutor = distExecutor;
|
|
45
|
+
this.#pkgJson = pkgJson;
|
|
46
|
+
this.#rootPackageJson = rootPackageJson;
|
|
47
|
+
}
|
|
48
|
+
#getBuildOptions(format, { bundle = false, additionalEntryPoints = [] } = {}) {
|
|
49
|
+
return {
|
|
50
|
+
entryPoints: [
|
|
51
|
+
...bundle ? [`${this.#executor.cwdPath}/index.ts`] : [`${this.#executor.cwdPath}/**/*.ts`, `${this.#executor.cwdPath}/**/*.tsx`],
|
|
52
|
+
...additionalEntryPoints
|
|
53
|
+
],
|
|
54
|
+
bundle,
|
|
55
|
+
packages: "external",
|
|
56
|
+
splitting: false,
|
|
57
|
+
platform: this.#pkgJson.esbuild?.platform,
|
|
58
|
+
format,
|
|
59
|
+
outdir: this.#distExecutor.cwdPath,
|
|
60
|
+
outExtension: format === "cjs" ? { ".js": this.#pkgJson.type === "module" ? ".cjs" : ".js" } : { ".js": this.#pkgJson.type === "module" ? ".js" : ".mjs" },
|
|
61
|
+
logLevel: "error"
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
#getAssetBuildOptions() {
|
|
65
|
+
return {
|
|
66
|
+
write: true,
|
|
67
|
+
bundle: false,
|
|
68
|
+
entryPoints: [
|
|
69
|
+
`${this.#executor.cwdPath}/**/*.css`,
|
|
70
|
+
`${this.#executor.cwdPath}/**/*.md`,
|
|
71
|
+
`${this.#executor.cwdPath}/**/*.template`,
|
|
72
|
+
`${this.#executor.cwdPath}/**/*.js`
|
|
73
|
+
],
|
|
74
|
+
outdir: this.#distExecutor.cwdPath,
|
|
75
|
+
logLevel: "error",
|
|
76
|
+
loader: { ".css": "copy", ".md": "copy", ".template": "copy", ".js": "copy" }
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
async build(options = {}) {
|
|
80
|
+
if (import_fs.default.existsSync(this.#distExecutor.cwdPath))
|
|
81
|
+
await this.#distExecutor.exec(`rm -rf ${this.#distExecutor.cwdPath}`);
|
|
82
|
+
const plugins = [(0, import_esbuild_plugin_d.dtsPlugin)({ tsconfig: `${this.#executor.cwdPath}/tsconfig.json` })];
|
|
83
|
+
const [buildResult] = await Promise.all([
|
|
84
|
+
esbuild.build({ ...this.#getBuildOptions("cjs", options), write: false, plugins }),
|
|
85
|
+
esbuild.build({ write: true, ...this.#getBuildOptions("esm", options) }),
|
|
86
|
+
esbuild.build({ ...this.#getAssetBuildOptions() })
|
|
87
|
+
]);
|
|
88
|
+
const existingDeps = Object.keys(this.#pkgJson.dependencies ?? {});
|
|
89
|
+
const dependencies = (0, import_extractDeps.extractDependencies)(buildResult.outputFiles, this.#rootPackageJson, existingDeps);
|
|
90
|
+
const pkgPackageJson = {
|
|
91
|
+
...this.#pkgJson,
|
|
92
|
+
main: "./index.js",
|
|
93
|
+
engines: { node: ">=22" },
|
|
94
|
+
dependencies,
|
|
95
|
+
exports: {
|
|
96
|
+
".": {
|
|
97
|
+
require: this.#pkgJson.type === "module" ? "./index.cjs" : "./index.js",
|
|
98
|
+
import: this.#pkgJson.type === "module" ? "./index.js" : "./index.mjs"
|
|
99
|
+
},
|
|
100
|
+
...this.#pkgJson.exports ?? {}
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
buildResult.outputFiles.map((file) => this.#distExecutor.writeFile(file.path, file.text));
|
|
104
|
+
this.#distExecutor.writeJson("package.json", pkgPackageJson);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
108
|
+
0 && (module.exports = {
|
|
109
|
+
Builder
|
|
110
|
+
});
|
package/src/builder.mjs
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import * as esbuild from "esbuild";
|
|
2
|
+
import { dtsPlugin } from "esbuild-plugin-d.ts";
|
|
3
|
+
import fs from "fs";
|
|
4
|
+
import { extractDependencies } from "./extractDeps";
|
|
5
|
+
class Builder {
|
|
6
|
+
#executor;
|
|
7
|
+
#distExecutor;
|
|
8
|
+
#pkgJson;
|
|
9
|
+
#rootPackageJson;
|
|
10
|
+
constructor({ executor, distExecutor, pkgJson, rootPackageJson }) {
|
|
11
|
+
this.#executor = executor;
|
|
12
|
+
this.#distExecutor = distExecutor;
|
|
13
|
+
this.#pkgJson = pkgJson;
|
|
14
|
+
this.#rootPackageJson = rootPackageJson;
|
|
15
|
+
}
|
|
16
|
+
#getBuildOptions(format, { bundle = false, additionalEntryPoints = [] } = {}) {
|
|
17
|
+
return {
|
|
18
|
+
entryPoints: [
|
|
19
|
+
...bundle ? [`${this.#executor.cwdPath}/index.ts`] : [`${this.#executor.cwdPath}/**/*.ts`, `${this.#executor.cwdPath}/**/*.tsx`],
|
|
20
|
+
...additionalEntryPoints
|
|
21
|
+
],
|
|
22
|
+
bundle,
|
|
23
|
+
packages: "external",
|
|
24
|
+
splitting: false,
|
|
25
|
+
platform: this.#pkgJson.esbuild?.platform,
|
|
26
|
+
format,
|
|
27
|
+
outdir: this.#distExecutor.cwdPath,
|
|
28
|
+
outExtension: format === "cjs" ? { ".js": this.#pkgJson.type === "module" ? ".cjs" : ".js" } : { ".js": this.#pkgJson.type === "module" ? ".js" : ".mjs" },
|
|
29
|
+
logLevel: "error"
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
#getAssetBuildOptions() {
|
|
33
|
+
return {
|
|
34
|
+
write: true,
|
|
35
|
+
bundle: false,
|
|
36
|
+
entryPoints: [
|
|
37
|
+
`${this.#executor.cwdPath}/**/*.css`,
|
|
38
|
+
`${this.#executor.cwdPath}/**/*.md`,
|
|
39
|
+
`${this.#executor.cwdPath}/**/*.template`,
|
|
40
|
+
`${this.#executor.cwdPath}/**/*.js`
|
|
41
|
+
],
|
|
42
|
+
outdir: this.#distExecutor.cwdPath,
|
|
43
|
+
logLevel: "error",
|
|
44
|
+
loader: { ".css": "copy", ".md": "copy", ".template": "copy", ".js": "copy" }
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
async build(options = {}) {
|
|
48
|
+
if (fs.existsSync(this.#distExecutor.cwdPath))
|
|
49
|
+
await this.#distExecutor.exec(`rm -rf ${this.#distExecutor.cwdPath}`);
|
|
50
|
+
const plugins = [dtsPlugin({ tsconfig: `${this.#executor.cwdPath}/tsconfig.json` })];
|
|
51
|
+
const [buildResult] = await Promise.all([
|
|
52
|
+
esbuild.build({ ...this.#getBuildOptions("cjs", options), write: false, plugins }),
|
|
53
|
+
esbuild.build({ write: true, ...this.#getBuildOptions("esm", options) }),
|
|
54
|
+
esbuild.build({ ...this.#getAssetBuildOptions() })
|
|
55
|
+
]);
|
|
56
|
+
const existingDeps = Object.keys(this.#pkgJson.dependencies ?? {});
|
|
57
|
+
const dependencies = extractDependencies(buildResult.outputFiles, this.#rootPackageJson, existingDeps);
|
|
58
|
+
const pkgPackageJson = {
|
|
59
|
+
...this.#pkgJson,
|
|
60
|
+
main: "./index.js",
|
|
61
|
+
engines: { node: ">=22" },
|
|
62
|
+
dependencies,
|
|
63
|
+
exports: {
|
|
64
|
+
".": {
|
|
65
|
+
require: this.#pkgJson.type === "module" ? "./index.cjs" : "./index.js",
|
|
66
|
+
import: this.#pkgJson.type === "module" ? "./index.js" : "./index.mjs"
|
|
67
|
+
},
|
|
68
|
+
...this.#pkgJson.exports ?? {}
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
buildResult.outputFiles.map((file) => this.#distExecutor.writeFile(file.path, file.text));
|
|
72
|
+
this.#distExecutor.writeJson("package.json", pkgPackageJson);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
export {
|
|
76
|
+
Builder
|
|
77
|
+
};
|
|
@@ -30,7 +30,9 @@ __export(command_exports, {
|
|
|
30
30
|
runCommands: () => runCommands
|
|
31
31
|
});
|
|
32
32
|
module.exports = __toCommonJS(command_exports);
|
|
33
|
+
var import_common = require("@akanjs/common");
|
|
33
34
|
var import_prompts = require("@inquirer/prompts");
|
|
35
|
+
var import_chalk = __toESM(require("chalk"));
|
|
34
36
|
var import_commander = require("commander");
|
|
35
37
|
var import_fs = __toESM(require("fs"));
|
|
36
38
|
var import_executors = require("../executors");
|
|
@@ -48,7 +50,7 @@ const handleOption = (programCommand, argMeta) => {
|
|
|
48
50
|
} = argMeta.argsOption;
|
|
49
51
|
const kebabName = camelToKebabCase(argMeta.name);
|
|
50
52
|
programCommand.option(
|
|
51
|
-
`-${flag}, --${kebabName} <${kebabName}
|
|
53
|
+
`-${flag}, --${kebabName}${type === "boolean" ? " [boolean]" : ` <${kebabName}>`}`,
|
|
52
54
|
`${desc}${ask ? ` (${ask})` : ""}${example ? ` (example: ${example})` : ""}${choices ? ` (choices: ${choices.join(", ")})` : ""}`
|
|
53
55
|
);
|
|
54
56
|
return programCommand;
|
|
@@ -59,7 +61,7 @@ const convertOptionValue = (value, type) => {
|
|
|
59
61
|
else if (type === "number")
|
|
60
62
|
return Number(value);
|
|
61
63
|
else
|
|
62
|
-
return value === "true";
|
|
64
|
+
return value === true || value === "true";
|
|
63
65
|
};
|
|
64
66
|
const getOptionValue = async (argMeta, opt) => {
|
|
65
67
|
const {
|
|
@@ -74,15 +76,15 @@ const getOptionValue = async (argMeta, opt) => {
|
|
|
74
76
|
return null;
|
|
75
77
|
if (choices) {
|
|
76
78
|
const choice = await (0, import_prompts.select)({
|
|
77
|
-
message: ask ?? `Select the ${name} value`,
|
|
79
|
+
message: ask ?? desc ?? `Select the ${name} value`,
|
|
78
80
|
choices: choices.map((choice2) => choice2.toString())
|
|
79
81
|
});
|
|
80
82
|
return choice;
|
|
81
83
|
} else if (type === "boolean") {
|
|
82
|
-
const message = ask ?? `Do you want to set ${name}? ${desc ? ` (${desc})` : ""}: `;
|
|
84
|
+
const message = ask ?? desc ?? `Do you want to set ${name}? ${desc ? ` (${desc})` : ""}: `;
|
|
83
85
|
return await (0, import_prompts.confirm)({ message });
|
|
84
86
|
} else {
|
|
85
|
-
const message = ask ? `${ask}: ` : `Enter the ${name} value${example ? ` (example: ${example})` : ""}: `;
|
|
87
|
+
const message = ask ? `${ask}: ` : desc ? `${desc}: ` : `Enter the ${name} value${example ? ` (example: ${example})` : ""}: `;
|
|
86
88
|
if (argMeta.argsOption.nullable)
|
|
87
89
|
return await (0, import_prompts.input)({ message });
|
|
88
90
|
else
|
|
@@ -170,7 +172,12 @@ const runCommands = async (...commands) => {
|
|
|
170
172
|
commandArgs[argMeta.idx] = await getArgumentValue(argMeta, cmdArgs[argMeta.idx], workspace);
|
|
171
173
|
}
|
|
172
174
|
const cmd = new command();
|
|
173
|
-
|
|
175
|
+
try {
|
|
176
|
+
await cmd[targetMeta.key](...commandArgs);
|
|
177
|
+
} catch (e) {
|
|
178
|
+
const errMsg = e instanceof Error ? e.message : typeof e === "string" ? e : JSON.stringify(e);
|
|
179
|
+
import_common.Logger.error(`Command Error: ${import_chalk.default.red(errMsg)}`);
|
|
180
|
+
}
|
|
174
181
|
});
|
|
175
182
|
}
|
|
176
183
|
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { Logger } from "@akanjs/common";
|
|
1
2
|
import { confirm, input, select } from "@inquirer/prompts";
|
|
3
|
+
import chalk from "chalk";
|
|
2
4
|
import { program } from "commander";
|
|
3
5
|
import fs from "fs";
|
|
4
6
|
import { AppExecutor, LibExecutor, PkgExecutor, WorkspaceExecutor } from "../executors";
|
|
@@ -16,7 +18,7 @@ const handleOption = (programCommand, argMeta) => {
|
|
|
16
18
|
} = argMeta.argsOption;
|
|
17
19
|
const kebabName = camelToKebabCase(argMeta.name);
|
|
18
20
|
programCommand.option(
|
|
19
|
-
`-${flag}, --${kebabName} <${kebabName}
|
|
21
|
+
`-${flag}, --${kebabName}${type === "boolean" ? " [boolean]" : ` <${kebabName}>`}`,
|
|
20
22
|
`${desc}${ask ? ` (${ask})` : ""}${example ? ` (example: ${example})` : ""}${choices ? ` (choices: ${choices.join(", ")})` : ""}`
|
|
21
23
|
);
|
|
22
24
|
return programCommand;
|
|
@@ -27,7 +29,7 @@ const convertOptionValue = (value, type) => {
|
|
|
27
29
|
else if (type === "number")
|
|
28
30
|
return Number(value);
|
|
29
31
|
else
|
|
30
|
-
return value === "true";
|
|
32
|
+
return value === true || value === "true";
|
|
31
33
|
};
|
|
32
34
|
const getOptionValue = async (argMeta, opt) => {
|
|
33
35
|
const {
|
|
@@ -42,15 +44,15 @@ const getOptionValue = async (argMeta, opt) => {
|
|
|
42
44
|
return null;
|
|
43
45
|
if (choices) {
|
|
44
46
|
const choice = await select({
|
|
45
|
-
message: ask ?? `Select the ${name} value`,
|
|
47
|
+
message: ask ?? desc ?? `Select the ${name} value`,
|
|
46
48
|
choices: choices.map((choice2) => choice2.toString())
|
|
47
49
|
});
|
|
48
50
|
return choice;
|
|
49
51
|
} else if (type === "boolean") {
|
|
50
|
-
const message = ask ?? `Do you want to set ${name}? ${desc ? ` (${desc})` : ""}: `;
|
|
52
|
+
const message = ask ?? desc ?? `Do you want to set ${name}? ${desc ? ` (${desc})` : ""}: `;
|
|
51
53
|
return await confirm({ message });
|
|
52
54
|
} else {
|
|
53
|
-
const message = ask ? `${ask}: ` : `Enter the ${name} value${example ? ` (example: ${example})` : ""}: `;
|
|
55
|
+
const message = ask ? `${ask}: ` : desc ? `${desc}: ` : `Enter the ${name} value${example ? ` (example: ${example})` : ""}: `;
|
|
54
56
|
if (argMeta.argsOption.nullable)
|
|
55
57
|
return await input({ message });
|
|
56
58
|
else
|
|
@@ -138,7 +140,12 @@ const runCommands = async (...commands) => {
|
|
|
138
140
|
commandArgs[argMeta.idx] = await getArgumentValue(argMeta, cmdArgs[argMeta.idx], workspace);
|
|
139
141
|
}
|
|
140
142
|
const cmd = new command();
|
|
141
|
-
|
|
143
|
+
try {
|
|
144
|
+
await cmd[targetMeta.key](...commandArgs);
|
|
145
|
+
} catch (e) {
|
|
146
|
+
const errMsg = e instanceof Error ? e.message : typeof e === "string" ? e : JSON.stringify(e);
|
|
147
|
+
Logger.error(`Command Error: ${chalk.red(errMsg)}`);
|
|
148
|
+
}
|
|
142
149
|
});
|
|
143
150
|
}
|
|
144
151
|
}
|
package/src/executors.d.ts
CHANGED
|
@@ -52,7 +52,7 @@ export declare class WorkspaceExecutor extends Executor {
|
|
|
52
52
|
getBaseDevEnv(): {
|
|
53
53
|
repoName: string;
|
|
54
54
|
serveDomain: string;
|
|
55
|
-
env: "
|
|
55
|
+
env: "testing" | "local" | "debug" | "develop" | "main";
|
|
56
56
|
name?: string | undefined;
|
|
57
57
|
};
|
|
58
58
|
scan(): Promise<WorkspaceScanResult>;
|
package/src/executors.js
CHANGED
|
@@ -37,6 +37,7 @@ __export(executors_exports, {
|
|
|
37
37
|
module.exports = __toCommonJS(executors_exports);
|
|
38
38
|
var import_common = require("@akanjs/common");
|
|
39
39
|
var import_config = require("@akanjs/config");
|
|
40
|
+
var import_chalk = __toESM(require("chalk"));
|
|
40
41
|
var import_child_process = require("child_process");
|
|
41
42
|
var import_dotenv = __toESM(require("dotenv"));
|
|
42
43
|
var import_fs = __toESM(require("fs"));
|
|
@@ -58,7 +59,7 @@ class Executor {
|
|
|
58
59
|
import_common.Logger.raw(data.toString());
|
|
59
60
|
});
|
|
60
61
|
proc.stderr?.on("data", (data) => {
|
|
61
|
-
import_common.Logger.raw(data.toString());
|
|
62
|
+
import_common.Logger.raw(import_chalk.default.red(data.toString()));
|
|
62
63
|
});
|
|
63
64
|
return new Promise((resolve, reject) => {
|
|
64
65
|
proc.on("exit", (code, signal) => {
|
|
@@ -72,7 +73,7 @@ class Executor {
|
|
|
72
73
|
spawn(command, args = [], options = {}) {
|
|
73
74
|
const proc = (0, import_child_process.spawn)(command, args, { cwd: this.cwdPath, stdio: "inherit", ...options });
|
|
74
75
|
proc.stderr?.on("data", (data) => {
|
|
75
|
-
import_common.Logger.raw(data.toString());
|
|
76
|
+
import_common.Logger.raw(import_chalk.default.red(data.toString()));
|
|
76
77
|
});
|
|
77
78
|
return new Promise((resolve, reject) => {
|
|
78
79
|
proc.on("exit", (code, signal) => {
|
|
@@ -187,7 +188,7 @@ class Executor {
|
|
|
187
188
|
overwrite = true
|
|
188
189
|
}, dict = {}) {
|
|
189
190
|
if (targetPath.endsWith(".js") || targetPath.endsWith(".jsx")) {
|
|
190
|
-
const getContent =
|
|
191
|
+
const getContent = require(templatePath);
|
|
191
192
|
const result = getContent.default(scanResult ?? null, dict);
|
|
192
193
|
if (result === null)
|
|
193
194
|
return;
|
package/src/executors.mjs
CHANGED
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
getDefaultFileScan,
|
|
5
5
|
getLibConfig
|
|
6
6
|
} from "@akanjs/config";
|
|
7
|
+
import chalk from "chalk";
|
|
7
8
|
import { exec, fork, spawn } from "child_process";
|
|
8
9
|
import dotenv from "dotenv";
|
|
9
10
|
import fs from "fs";
|
|
@@ -25,7 +26,7 @@ class Executor {
|
|
|
25
26
|
Logger.raw(data.toString());
|
|
26
27
|
});
|
|
27
28
|
proc.stderr?.on("data", (data) => {
|
|
28
|
-
Logger.raw(data.toString());
|
|
29
|
+
Logger.raw(chalk.red(data.toString()));
|
|
29
30
|
});
|
|
30
31
|
return new Promise((resolve, reject) => {
|
|
31
32
|
proc.on("exit", (code, signal) => {
|
|
@@ -39,7 +40,7 @@ class Executor {
|
|
|
39
40
|
spawn(command, args = [], options = {}) {
|
|
40
41
|
const proc = spawn(command, args, { cwd: this.cwdPath, stdio: "inherit", ...options });
|
|
41
42
|
proc.stderr?.on("data", (data) => {
|
|
42
|
-
Logger.raw(data.toString());
|
|
43
|
+
Logger.raw(chalk.red(data.toString()));
|
|
43
44
|
});
|
|
44
45
|
return new Promise((resolve, reject) => {
|
|
45
46
|
proc.on("exit", (code, signal) => {
|
|
@@ -154,7 +155,7 @@ class Executor {
|
|
|
154
155
|
overwrite = true
|
|
155
156
|
}, dict = {}) {
|
|
156
157
|
if (targetPath.endsWith(".js") || targetPath.endsWith(".jsx")) {
|
|
157
|
-
const getContent =
|
|
158
|
+
const getContent = require(templatePath);
|
|
158
159
|
const result = getContent.default(scanResult ?? null, dict);
|
|
159
160
|
if (result === null)
|
|
160
161
|
return;
|
package/src/extractDeps.d.ts
CHANGED
package/src/extractDeps.js
CHANGED
|
@@ -75,7 +75,7 @@ const extractDependencies = (filepaths, pacakgeJson, defaultDependencies = []) =
|
|
|
75
75
|
...pacakgeJson.devDependencies ?? {}
|
|
76
76
|
};
|
|
77
77
|
const requireRegex = /require\s*\(\s*['"`]([^'"`]+)['"`]\s*\)/g;
|
|
78
|
-
for (const { text } of filepaths) {
|
|
78
|
+
for (const { text } of filepaths.filter(({ path }) => path.endsWith(".js"))) {
|
|
79
79
|
let requireMatch;
|
|
80
80
|
while ((requireMatch = requireRegex.exec(text)) !== null) {
|
|
81
81
|
const moduleName = requireMatch[1];
|
package/src/extractDeps.mjs
CHANGED
|
@@ -53,7 +53,7 @@ const extractDependencies = (filepaths, pacakgeJson, defaultDependencies = []) =
|
|
|
53
53
|
...pacakgeJson.devDependencies ?? {}
|
|
54
54
|
};
|
|
55
55
|
const requireRegex = /require\s*\(\s*['"`]([^'"`]+)['"`]\s*\)/g;
|
|
56
|
-
for (const { text } of filepaths) {
|
|
56
|
+
for (const { text } of filepaths.filter(({ path }) => path.endsWith(".js"))) {
|
|
57
57
|
let requireMatch;
|
|
58
58
|
while ((requireMatch = requireRegex.exec(text)) !== null) {
|
|
59
59
|
const moduleName = requireMatch[1];
|
package/src/index.d.ts
CHANGED
package/src/index.js
CHANGED
|
@@ -30,6 +30,7 @@ __reExport(src_exports, require("./capacitorApp"), module.exports);
|
|
|
30
30
|
__reExport(src_exports, require("./extractDeps"), module.exports);
|
|
31
31
|
__reExport(src_exports, require("./commandDecorators"), module.exports);
|
|
32
32
|
__reExport(src_exports, require("./aiEditor"), module.exports);
|
|
33
|
+
__reExport(src_exports, require("./builder"), module.exports);
|
|
33
34
|
// Annotate the CommonJS export names for ESM import in node:
|
|
34
35
|
0 && (module.exports = {
|
|
35
36
|
...require("./createTunnel"),
|
|
@@ -47,5 +48,6 @@ __reExport(src_exports, require("./aiEditor"), module.exports);
|
|
|
47
48
|
...require("./capacitorApp"),
|
|
48
49
|
...require("./extractDeps"),
|
|
49
50
|
...require("./commandDecorators"),
|
|
50
|
-
...require("./aiEditor")
|
|
51
|
+
...require("./aiEditor"),
|
|
52
|
+
...require("./builder")
|
|
51
53
|
});
|
package/src/index.mjs
CHANGED
package/src/types.d.ts
CHANGED
|
@@ -10,6 +10,9 @@ export interface PackageJson {
|
|
|
10
10
|
peerDependencies?: Record<string, string>;
|
|
11
11
|
engines?: Record<string, string>;
|
|
12
12
|
exports?: Record<string, Record<string, string>>;
|
|
13
|
+
esbuild?: {
|
|
14
|
+
platform?: "node" | "browser" | "neutral";
|
|
15
|
+
};
|
|
13
16
|
}
|
|
14
17
|
export interface TsConfigJson {
|
|
15
18
|
extends?: string;
|