@akanjs/devkit 0.0.92 → 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 +4 -1
- package/src/builder.d.ts +7 -5
- package/src/builder.js +38 -39
- package/src/builder.mjs +38 -39
- package/src/commandDecorators/command.js +2 -2
- package/src/commandDecorators/command.mjs +2 -2
- package/src/executors.d.ts +1 -1
- package/src/executors.js +2 -2
- package/src/executors.mjs +2 -2
- 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"
|
|
@@ -37,5 +37,8 @@
|
|
|
37
37
|
"require": "./index.js",
|
|
38
38
|
"import": "./index.mjs"
|
|
39
39
|
}
|
|
40
|
+
},
|
|
41
|
+
"esbuild": {
|
|
42
|
+
"platform": "node"
|
|
40
43
|
}
|
|
41
44
|
}
|
package/src/builder.d.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
import { PackageJson } from "./types";
|
|
2
1
|
import { Executor } from "./executors";
|
|
2
|
+
import { PackageJson } from "./types";
|
|
3
|
+
interface BuildOptions {
|
|
4
|
+
bundle?: boolean;
|
|
5
|
+
additionalEntryPoints?: string[];
|
|
6
|
+
}
|
|
3
7
|
interface BuilderOptions {
|
|
4
|
-
name: string;
|
|
5
8
|
executor: Executor;
|
|
6
9
|
distExecutor: Executor;
|
|
7
10
|
pkgJson: PackageJson;
|
|
@@ -9,8 +12,7 @@ interface BuilderOptions {
|
|
|
9
12
|
}
|
|
10
13
|
export declare class Builder {
|
|
11
14
|
#private;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
build(): Promise<void>;
|
|
15
|
+
constructor({ executor, distExecutor, pkgJson, rootPackageJson }: BuilderOptions);
|
|
16
|
+
build(options?: BuildOptions): Promise<void>;
|
|
15
17
|
}
|
|
16
18
|
export {};
|
package/src/builder.js
CHANGED
|
@@ -32,61 +32,61 @@ __export(builder_exports, {
|
|
|
32
32
|
module.exports = __toCommonJS(builder_exports);
|
|
33
33
|
var esbuild = __toESM(require("esbuild"));
|
|
34
34
|
var import_esbuild_plugin_d = require("esbuild-plugin-d.ts");
|
|
35
|
+
var import_fs = __toESM(require("fs"));
|
|
35
36
|
var import_extractDeps = require("./extractDeps");
|
|
36
37
|
class Builder {
|
|
37
|
-
name;
|
|
38
38
|
#executor;
|
|
39
39
|
#distExecutor;
|
|
40
40
|
#pkgJson;
|
|
41
41
|
#rootPackageJson;
|
|
42
|
-
constructor({
|
|
43
|
-
this.name = name;
|
|
42
|
+
constructor({ executor, distExecutor, pkgJson, rootPackageJson }) {
|
|
44
43
|
this.#executor = executor;
|
|
45
44
|
this.#distExecutor = distExecutor;
|
|
46
45
|
this.#pkgJson = pkgJson;
|
|
47
46
|
this.#rootPackageJson = rootPackageJson;
|
|
48
47
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
"@akanjs/server",
|
|
57
|
-
"@akanjs/service"
|
|
58
|
-
].includes(this.name) ? "node" : ["@akanjs/client", "@akanjs/next", "@akanjs/store", "@akanjs/ui"].includes(this.name) ? "browser" : "neutral";
|
|
59
|
-
buildResult = await esbuild.build({
|
|
60
|
-
write: false,
|
|
61
|
-
entryPoints: [`${this.#executor.cwdPath}/**/*.ts`, `${this.#executor.cwdPath}/**/*.tsx`],
|
|
62
|
-
bundle: false,
|
|
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,
|
|
63
55
|
packages: "external",
|
|
64
56
|
splitting: false,
|
|
65
|
-
platform,
|
|
66
|
-
format
|
|
57
|
+
platform: this.#pkgJson.esbuild?.platform,
|
|
58
|
+
format,
|
|
67
59
|
outdir: this.#distExecutor.cwdPath,
|
|
68
|
-
outExtension: { ".js": this.#pkgJson.type === "module" ? ".cjs" : ".js" },
|
|
69
|
-
logLevel: "error"
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
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 {
|
|
73
66
|
write: true,
|
|
74
|
-
entryPoints: [`${this.#executor.cwdPath}/**/*.ts`, `${this.#executor.cwdPath}/**/*.tsx`],
|
|
75
67
|
bundle: false,
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
68
|
+
entryPoints: [
|
|
69
|
+
`${this.#executor.cwdPath}/**/*.css`,
|
|
70
|
+
`${this.#executor.cwdPath}/**/*.md`,
|
|
71
|
+
`${this.#executor.cwdPath}/**/*.template`,
|
|
72
|
+
`${this.#executor.cwdPath}/**/*.js`
|
|
73
|
+
],
|
|
80
74
|
outdir: this.#distExecutor.cwdPath,
|
|
81
|
-
outExtension: { ".js": this.#pkgJson.type === "module" ? ".js" : ".mjs" },
|
|
82
75
|
logLevel: "error",
|
|
83
|
-
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
) : {};
|
|
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
90
|
const pkgPackageJson = {
|
|
91
91
|
...this.#pkgJson,
|
|
92
92
|
main: "./index.js",
|
|
@@ -100,8 +100,7 @@ class Builder {
|
|
|
100
100
|
...this.#pkgJson.exports ?? {}
|
|
101
101
|
}
|
|
102
102
|
};
|
|
103
|
-
|
|
104
|
-
buildResult.outputFiles.map((file) => this.#distExecutor.writeFile(file.path, file.text));
|
|
103
|
+
buildResult.outputFiles.map((file) => this.#distExecutor.writeFile(file.path, file.text));
|
|
105
104
|
this.#distExecutor.writeJson("package.json", pkgPackageJson);
|
|
106
105
|
}
|
|
107
106
|
}
|
package/src/builder.mjs
CHANGED
|
@@ -1,60 +1,60 @@
|
|
|
1
1
|
import * as esbuild from "esbuild";
|
|
2
2
|
import { dtsPlugin } from "esbuild-plugin-d.ts";
|
|
3
|
+
import fs from "fs";
|
|
3
4
|
import { extractDependencies } from "./extractDeps";
|
|
4
5
|
class Builder {
|
|
5
|
-
name;
|
|
6
6
|
#executor;
|
|
7
7
|
#distExecutor;
|
|
8
8
|
#pkgJson;
|
|
9
9
|
#rootPackageJson;
|
|
10
|
-
constructor({
|
|
11
|
-
this.name = name;
|
|
10
|
+
constructor({ executor, distExecutor, pkgJson, rootPackageJson }) {
|
|
12
11
|
this.#executor = executor;
|
|
13
12
|
this.#distExecutor = distExecutor;
|
|
14
13
|
this.#pkgJson = pkgJson;
|
|
15
14
|
this.#rootPackageJson = rootPackageJson;
|
|
16
15
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
"@akanjs/server",
|
|
25
|
-
"@akanjs/service"
|
|
26
|
-
].includes(this.name) ? "node" : ["@akanjs/client", "@akanjs/next", "@akanjs/store", "@akanjs/ui"].includes(this.name) ? "browser" : "neutral";
|
|
27
|
-
buildResult = await esbuild.build({
|
|
28
|
-
write: false,
|
|
29
|
-
entryPoints: [`${this.#executor.cwdPath}/**/*.ts`, `${this.#executor.cwdPath}/**/*.tsx`],
|
|
30
|
-
bundle: false,
|
|
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,
|
|
31
23
|
packages: "external",
|
|
32
24
|
splitting: false,
|
|
33
|
-
platform,
|
|
34
|
-
format
|
|
25
|
+
platform: this.#pkgJson.esbuild?.platform,
|
|
26
|
+
format,
|
|
35
27
|
outdir: this.#distExecutor.cwdPath,
|
|
36
|
-
outExtension: { ".js": this.#pkgJson.type === "module" ? ".cjs" : ".js" },
|
|
37
|
-
logLevel: "error"
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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 {
|
|
41
34
|
write: true,
|
|
42
|
-
entryPoints: [`${this.#executor.cwdPath}/**/*.ts`, `${this.#executor.cwdPath}/**/*.tsx`],
|
|
43
35
|
bundle: false,
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
36
|
+
entryPoints: [
|
|
37
|
+
`${this.#executor.cwdPath}/**/*.css`,
|
|
38
|
+
`${this.#executor.cwdPath}/**/*.md`,
|
|
39
|
+
`${this.#executor.cwdPath}/**/*.template`,
|
|
40
|
+
`${this.#executor.cwdPath}/**/*.js`
|
|
41
|
+
],
|
|
48
42
|
outdir: this.#distExecutor.cwdPath,
|
|
49
|
-
outExtension: { ".js": this.#pkgJson.type === "module" ? ".js" : ".mjs" },
|
|
50
43
|
logLevel: "error",
|
|
51
|
-
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
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
58
|
const pkgPackageJson = {
|
|
59
59
|
...this.#pkgJson,
|
|
60
60
|
main: "./index.js",
|
|
@@ -68,8 +68,7 @@ class Builder {
|
|
|
68
68
|
...this.#pkgJson.exports ?? {}
|
|
69
69
|
}
|
|
70
70
|
};
|
|
71
|
-
|
|
72
|
-
buildResult.outputFiles.map((file) => this.#distExecutor.writeFile(file.path, file.text));
|
|
71
|
+
buildResult.outputFiles.map((file) => this.#distExecutor.writeFile(file.path, file.text));
|
|
73
72
|
this.#distExecutor.writeJson("package.json", pkgPackageJson);
|
|
74
73
|
}
|
|
75
74
|
}
|
|
@@ -30,14 +30,14 @@ __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
|
-
var import_chalk = __toESM(require("chalk"));
|
|
37
38
|
var import_executors = require("../executors");
|
|
38
39
|
var import_argMeta = require("./argMeta");
|
|
39
40
|
var import_targetMeta = require("./targetMeta");
|
|
40
|
-
var import_common = require("@akanjs/common");
|
|
41
41
|
const camelToKebabCase = (str) => str.replace(/([A-Z])/g, "-$1").toLowerCase();
|
|
42
42
|
const handleOption = (programCommand, argMeta) => {
|
|
43
43
|
const {
|
|
@@ -1,11 +1,11 @@
|
|
|
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
|
-
import chalk from "chalk";
|
|
5
6
|
import { AppExecutor, LibExecutor, PkgExecutor, WorkspaceExecutor } from "../executors";
|
|
6
7
|
import { getArgMetas } from "./argMeta";
|
|
7
8
|
import { getTargetMetas } from "./targetMeta";
|
|
8
|
-
import { Logger } from "@akanjs/common";
|
|
9
9
|
const camelToKebabCase = (str) => str.replace(/([A-Z])/g, "-$1").toLowerCase();
|
|
10
10
|
const handleOption = (programCommand, argMeta) => {
|
|
11
11
|
const {
|
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,12 +37,12 @@ __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"));
|
|
43
44
|
var import_promises = __toESM(require("fs/promises"));
|
|
44
45
|
var import_path = __toESM(require("path"));
|
|
45
|
-
var import_chalk = __toESM(require("chalk"));
|
|
46
46
|
var import_dependencyScanner = require("./dependencyScanner");
|
|
47
47
|
class Executor {
|
|
48
48
|
logger;
|
|
@@ -188,7 +188,7 @@ class Executor {
|
|
|
188
188
|
overwrite = true
|
|
189
189
|
}, dict = {}) {
|
|
190
190
|
if (targetPath.endsWith(".js") || targetPath.endsWith(".jsx")) {
|
|
191
|
-
const getContent =
|
|
191
|
+
const getContent = require(templatePath);
|
|
192
192
|
const result = getContent.default(scanResult ?? null, dict);
|
|
193
193
|
if (result === null)
|
|
194
194
|
return;
|
package/src/executors.mjs
CHANGED
|
@@ -4,12 +4,12 @@ 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";
|
|
10
11
|
import fsPromise from "fs/promises";
|
|
11
12
|
import path from "path";
|
|
12
|
-
import chalk from "chalk";
|
|
13
13
|
import { TypeScriptDependencyScanner } from "./dependencyScanner";
|
|
14
14
|
class Executor {
|
|
15
15
|
logger;
|
|
@@ -155,7 +155,7 @@ class Executor {
|
|
|
155
155
|
overwrite = true
|
|
156
156
|
}, dict = {}) {
|
|
157
157
|
if (targetPath.endsWith(".js") || targetPath.endsWith(".jsx")) {
|
|
158
|
-
const getContent =
|
|
158
|
+
const getContent = require(templatePath);
|
|
159
159
|
const result = getContent.default(scanResult ?? null, dict);
|
|
160
160
|
if (result === null)
|
|
161
161
|
return;
|
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;
|