@akanjs/devkit 0.9.9 → 0.9.11
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/cjs/src/commandDecorators/command.js +3 -0
- package/cjs/src/executors.js +23 -20
- package/cjs/src/getDirname.js +38 -0
- package/cjs/src/index.js +5 -1
- package/cjs/src/prompter.js +8 -4
- package/cjs/src/useStdoutDimensions.js +43 -0
- package/esm/src/commandDecorators/command.js +2 -0
- package/esm/src/executors.js +22 -20
- package/esm/src/getDirname.js +5 -0
- package/esm/src/index.js +2 -0
- package/esm/src/prompter.js +7 -4
- package/esm/src/useStdoutDimensions.js +20 -0
- package/package.json +3 -1
- package/src/executors.d.ts +3 -1
- package/src/getDirname.d.ts +1 -0
- package/src/index.d.ts +2 -0
- package/src/useStdoutDimensions.d.ts +1 -0
|
@@ -35,9 +35,11 @@ var import_prompts = require("@inquirer/prompts");
|
|
|
35
35
|
var import_chalk = __toESM(require("chalk"));
|
|
36
36
|
var import_commander = require("commander");
|
|
37
37
|
var import_fs = __toESM(require("fs"));
|
|
38
|
+
var import__ = require("..");
|
|
38
39
|
var import_executors = require("../executors");
|
|
39
40
|
var import_argMeta = require("./argMeta");
|
|
40
41
|
var import_targetMeta = require("./targetMeta");
|
|
42
|
+
const import_meta = {};
|
|
41
43
|
const camelToKebabCase = (str) => str.replace(/([A-Z])/g, "-$1").toLowerCase();
|
|
42
44
|
const handleOption = (programCommand, argMeta) => {
|
|
43
45
|
const {
|
|
@@ -213,6 +215,7 @@ const runCommands = async (...commands) => {
|
|
|
213
215
|
process.on("unhandledRejection", (error) => {
|
|
214
216
|
process.exit(1);
|
|
215
217
|
});
|
|
218
|
+
const __dirname = (0, import__.getDirname)(import_meta.url);
|
|
216
219
|
const hasPackageJson = import_fs.default.existsSync(`${__dirname}/../package.json`);
|
|
217
220
|
const version = hasPackageJson ? JSON.parse(import_fs.default.readFileSync(`${__dirname}/../package.json`, "utf8")).version : "0.0.1";
|
|
218
221
|
import_commander.program.version(version).description("Akan CLI");
|
package/cjs/src/executors.js
CHANGED
|
@@ -46,9 +46,11 @@ var import_fs = __toESM(require("fs"));
|
|
|
46
46
|
var import_promises = __toESM(require("fs/promises"));
|
|
47
47
|
var import_path = __toESM(require("path"));
|
|
48
48
|
var import_dependencyScanner = require("./dependencyScanner");
|
|
49
|
+
var import_getDirname = require("./getDirname");
|
|
49
50
|
var import_linter = require("./linter");
|
|
50
51
|
var import_spinner = require("./spinner");
|
|
51
52
|
var import_typeChecker = require("./typeChecker");
|
|
53
|
+
const import_meta = {};
|
|
52
54
|
const execEmoji = {
|
|
53
55
|
workspace: "\u{1F3E0}",
|
|
54
56
|
app: "\u{1F680}",
|
|
@@ -66,6 +68,7 @@ class Executor {
|
|
|
66
68
|
}
|
|
67
69
|
name;
|
|
68
70
|
logger;
|
|
71
|
+
logs;
|
|
69
72
|
cwdPath;
|
|
70
73
|
emoji = execEmoji.default;
|
|
71
74
|
typeChecker = null;
|
|
@@ -73,6 +76,7 @@ class Executor {
|
|
|
73
76
|
constructor(name, cwdPath) {
|
|
74
77
|
this.name = name;
|
|
75
78
|
this.logger = new import_common.Logger(name);
|
|
79
|
+
this.logs = [];
|
|
76
80
|
this.cwdPath = cwdPath;
|
|
77
81
|
if (!import_fs.default.existsSync(cwdPath))
|
|
78
82
|
import_fs.default.mkdirSync(cwdPath, { recursive: true });
|
|
@@ -111,10 +115,12 @@ class Executor {
|
|
|
111
115
|
let stderr = "";
|
|
112
116
|
proc.stdout?.on("data", (data) => {
|
|
113
117
|
stdout += data;
|
|
118
|
+
this.logs.push(data);
|
|
114
119
|
this.#stdout(data);
|
|
115
120
|
});
|
|
116
121
|
proc.stderr?.on("data", (data) => {
|
|
117
122
|
stderr += data;
|
|
123
|
+
this.logs.push(data);
|
|
118
124
|
this.#stdout(data);
|
|
119
125
|
});
|
|
120
126
|
return new Promise((resolve, reject) => {
|
|
@@ -126,6 +132,14 @@ class Executor {
|
|
|
126
132
|
});
|
|
127
133
|
});
|
|
128
134
|
}
|
|
135
|
+
spawnSync(command, args = [], options = {}) {
|
|
136
|
+
const proc = (0, import_child_process.spawn)(command, args, {
|
|
137
|
+
cwd: this.cwdPath,
|
|
138
|
+
// stdio: "inherit",
|
|
139
|
+
...options
|
|
140
|
+
});
|
|
141
|
+
return proc;
|
|
142
|
+
}
|
|
129
143
|
fork(modulePath, args = [], options = {}) {
|
|
130
144
|
const proc = (0, import_child_process.fork)(modulePath, args, {
|
|
131
145
|
cwd: this.cwdPath,
|
|
@@ -272,7 +286,7 @@ class Executor {
|
|
|
272
286
|
overwrite = true
|
|
273
287
|
}, dict = {}) {
|
|
274
288
|
if (targetPath.endsWith(".js") || targetPath.endsWith(".jsx")) {
|
|
275
|
-
const getContent =
|
|
289
|
+
const getContent = await import(templatePath);
|
|
276
290
|
const result = getContent.default(scanResult ?? null, dict);
|
|
277
291
|
if (result === null)
|
|
278
292
|
return null;
|
|
@@ -307,7 +321,7 @@ class Executor {
|
|
|
307
321
|
dict = {},
|
|
308
322
|
overwrite = true
|
|
309
323
|
}) {
|
|
310
|
-
const templatePath = `${
|
|
324
|
+
const templatePath = `${(0, import_getDirname.getDirname)(import_meta.url)}/src/templates${template ? `/${template}` : ""}`;
|
|
311
325
|
const prefixTemplatePath = templatePath.endsWith(".tsx") ? templatePath : templatePath.replace(".ts", ".js");
|
|
312
326
|
if (import_fs.default.statSync(prefixTemplatePath).isFile()) {
|
|
313
327
|
const filename = import_path.default.basename(prefixTemplatePath);
|
|
@@ -848,28 +862,17 @@ class AppExecutor extends SysExecutor {
|
|
|
848
862
|
}
|
|
849
863
|
async syncAssets(libDeps) {
|
|
850
864
|
const projectPublicLibPath = `${this.cwdPath}/public/libs`;
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
import_fs.default.existsSync(projectPublicLibPath) && import_promises.default.rm(projectPublicLibPath, { recursive: true }),
|
|
854
|
-
import_fs.default.existsSync(projectAssetsLibPath) && import_promises.default.rm(projectAssetsLibPath, { recursive: true })
|
|
855
|
-
]);
|
|
865
|
+
if (import_fs.default.existsSync(projectPublicLibPath))
|
|
866
|
+
await import_promises.default.rm(projectPublicLibPath, { recursive: true });
|
|
856
867
|
const targetDeps = libDeps.filter((dep) => import_fs.default.existsSync(`${this.workspace.workspaceRoot}/libs/${dep}/public`));
|
|
857
|
-
await Promise.all(
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
await Promise.all([
|
|
862
|
-
...targetDeps.map(
|
|
863
|
-
(dep) => import_fs.default.existsSync(`${this.workspace.workspaceRoot}/libs/${dep}/public`) && import_promises.default.cp(`${this.workspace.workspaceRoot}/libs/${dep}/public`, `${projectPublicLibPath}/${dep}`, {
|
|
864
|
-
recursive: true
|
|
865
|
-
})
|
|
866
|
-
),
|
|
867
|
-
...targetDeps.map(
|
|
868
|
-
(dep) => import_fs.default.existsSync(`${this.workspace.workspaceRoot}/libs/${dep}/assets`) && import_promises.default.cp(`${this.workspace.workspaceRoot}/libs/${dep}/assets`, `${projectAssetsLibPath}/${dep}`, {
|
|
868
|
+
await Promise.all(targetDeps.map((dep) => import_promises.default.mkdir(`${projectPublicLibPath}/${dep}`, { recursive: true })));
|
|
869
|
+
await Promise.all(
|
|
870
|
+
targetDeps.map(
|
|
871
|
+
(dep) => import_promises.default.cp(`${this.workspace.workspaceRoot}/libs/${dep}/public`, `${projectPublicLibPath}/${dep}`, {
|
|
869
872
|
recursive: true
|
|
870
873
|
})
|
|
871
874
|
)
|
|
872
|
-
|
|
875
|
+
);
|
|
873
876
|
}
|
|
874
877
|
}
|
|
875
878
|
class LibExecutor extends SysExecutor {
|
|
@@ -0,0 +1,38 @@
|
|
|
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 getDirname_exports = {};
|
|
29
|
+
__export(getDirname_exports, {
|
|
30
|
+
getDirname: () => getDirname
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(getDirname_exports);
|
|
33
|
+
var import_path = __toESM(require("path"));
|
|
34
|
+
const getDirname = (url) => import_path.default.dirname(new URL(url).pathname);
|
|
35
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
36
|
+
0 && (module.exports = {
|
|
37
|
+
getDirname
|
|
38
|
+
});
|
package/cjs/src/index.js
CHANGED
|
@@ -34,6 +34,8 @@ __reExport(src_exports, require("./builder"), module.exports);
|
|
|
34
34
|
__reExport(src_exports, require("./spinner"), module.exports);
|
|
35
35
|
__reExport(src_exports, require("./prompter"), module.exports);
|
|
36
36
|
__reExport(src_exports, require("./guideline"), module.exports);
|
|
37
|
+
__reExport(src_exports, require("./getDirname"), module.exports);
|
|
38
|
+
__reExport(src_exports, require("./useStdoutDimensions"), module.exports);
|
|
37
39
|
// Annotate the CommonJS export names for ESM import in node:
|
|
38
40
|
0 && (module.exports = {
|
|
39
41
|
...require("./createTunnel"),
|
|
@@ -55,5 +57,7 @@ __reExport(src_exports, require("./guideline"), module.exports);
|
|
|
55
57
|
...require("./builder"),
|
|
56
58
|
...require("./spinner"),
|
|
57
59
|
...require("./prompter"),
|
|
58
|
-
...require("./guideline")
|
|
60
|
+
...require("./guideline"),
|
|
61
|
+
...require("./getDirname"),
|
|
62
|
+
...require("./useStdoutDimensions")
|
|
59
63
|
});
|
package/cjs/src/prompter.js
CHANGED
|
@@ -32,18 +32,22 @@ __export(prompter_exports, {
|
|
|
32
32
|
module.exports = __toCommonJS(prompter_exports);
|
|
33
33
|
var import_prompts = require("@inquirer/prompts");
|
|
34
34
|
var import_promises = __toESM(require("fs/promises"));
|
|
35
|
+
var import_getDirname = require("./getDirname");
|
|
36
|
+
const import_meta = {};
|
|
35
37
|
class Prompter {
|
|
36
38
|
static async selectGuideline() {
|
|
37
|
-
const guideNames = (await import_promises.default.readdir(`${
|
|
39
|
+
const guideNames = (await import_promises.default.readdir(`${(0, import_getDirname.getDirname)(import_meta.url)}/src/guidelines`)).filter(
|
|
40
|
+
(name) => !name.startsWith("_")
|
|
41
|
+
);
|
|
38
42
|
return await (0, import_prompts.select)({ message: "Select a guideline", choices: guideNames.map((name) => ({ name, value: name })) });
|
|
39
43
|
}
|
|
40
44
|
static async getGuideJson(guideName) {
|
|
41
|
-
const filePath = `${
|
|
45
|
+
const filePath = `${(0, import_getDirname.getDirname)(import_meta.url)}/src/guidelines/${guideName}/${guideName}.generate.json`;
|
|
42
46
|
const guideJson = await import_promises.default.readFile(filePath, "utf-8");
|
|
43
47
|
return JSON.parse(guideJson);
|
|
44
48
|
}
|
|
45
49
|
static async getInstruction(guideName) {
|
|
46
|
-
const filePath = `${
|
|
50
|
+
const filePath = `${(0, import_getDirname.getDirname)(import_meta.url)}/src/guidelines/${guideName}/${guideName}.instruction.md`;
|
|
47
51
|
const content = await import_promises.default.readFile(filePath, "utf-8");
|
|
48
52
|
return content;
|
|
49
53
|
}
|
|
@@ -67,7 +71,7 @@ ${request}
|
|
|
67
71
|
`;
|
|
68
72
|
}
|
|
69
73
|
async getDocumentation(guideName) {
|
|
70
|
-
const filePath = `${
|
|
74
|
+
const filePath = `${(0, import_getDirname.getDirname)(import_meta.url)}/src/guidelines/${guideName}/${guideName}.instruction.md`;
|
|
71
75
|
const document = await import_promises.default.readFile(filePath, "utf-8");
|
|
72
76
|
return `\`\`\`markdown
|
|
73
77
|
${document}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var useStdoutDimensions_exports = {};
|
|
20
|
+
__export(useStdoutDimensions_exports, {
|
|
21
|
+
useStdoutDimensions: () => useStdoutDimensions
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(useStdoutDimensions_exports);
|
|
24
|
+
var import_ink = require("ink");
|
|
25
|
+
var import_react = require("react");
|
|
26
|
+
const useStdoutDimensions = () => {
|
|
27
|
+
const { stdout } = (0, import_ink.useStdout)();
|
|
28
|
+
const [dimensions, setDimensions] = (0, import_react.useState)([stdout.columns, stdout.rows]);
|
|
29
|
+
(0, import_react.useEffect)(() => {
|
|
30
|
+
const handler = () => {
|
|
31
|
+
setDimensions([stdout.columns, stdout.rows]);
|
|
32
|
+
};
|
|
33
|
+
stdout.on("resize", handler);
|
|
34
|
+
return () => {
|
|
35
|
+
stdout.off("resize", handler);
|
|
36
|
+
};
|
|
37
|
+
}, [stdout]);
|
|
38
|
+
return dimensions;
|
|
39
|
+
};
|
|
40
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
41
|
+
0 && (module.exports = {
|
|
42
|
+
useStdoutDimensions
|
|
43
|
+
});
|
|
@@ -3,6 +3,7 @@ import { confirm, input, select } from "@inquirer/prompts";
|
|
|
3
3
|
import chalk from "chalk";
|
|
4
4
|
import { program } from "commander";
|
|
5
5
|
import fs from "fs";
|
|
6
|
+
import { getDirname } from "..";
|
|
6
7
|
import { AppExecutor, Executor, LibExecutor, ModuleExecutor, PkgExecutor, WorkspaceExecutor } from "../executors";
|
|
7
8
|
import { getArgMetas } from "./argMeta";
|
|
8
9
|
import { getTargetMetas } from "./targetMeta";
|
|
@@ -181,6 +182,7 @@ const runCommands = async (...commands) => {
|
|
|
181
182
|
process.on("unhandledRejection", (error) => {
|
|
182
183
|
process.exit(1);
|
|
183
184
|
});
|
|
185
|
+
const __dirname = getDirname(import.meta.url);
|
|
184
186
|
const hasPackageJson = fs.existsSync(`${__dirname}/../package.json`);
|
|
185
187
|
const version = hasPackageJson ? JSON.parse(fs.readFileSync(`${__dirname}/../package.json`, "utf8")).version : "0.0.1";
|
|
186
188
|
program.version(version).description("Akan CLI");
|
package/esm/src/executors.js
CHANGED
|
@@ -11,6 +11,7 @@ import fs from "fs";
|
|
|
11
11
|
import fsPromise from "fs/promises";
|
|
12
12
|
import path from "path";
|
|
13
13
|
import { TypeScriptDependencyScanner } from "./dependencyScanner";
|
|
14
|
+
import { getDirname } from "./getDirname";
|
|
14
15
|
import { Linter } from "./linter";
|
|
15
16
|
import { Spinner } from "./spinner";
|
|
16
17
|
import { TypeChecker } from "./typeChecker";
|
|
@@ -31,6 +32,7 @@ class Executor {
|
|
|
31
32
|
}
|
|
32
33
|
name;
|
|
33
34
|
logger;
|
|
35
|
+
logs;
|
|
34
36
|
cwdPath;
|
|
35
37
|
emoji = execEmoji.default;
|
|
36
38
|
typeChecker = null;
|
|
@@ -38,6 +40,7 @@ class Executor {
|
|
|
38
40
|
constructor(name, cwdPath) {
|
|
39
41
|
this.name = name;
|
|
40
42
|
this.logger = new Logger(name);
|
|
43
|
+
this.logs = [];
|
|
41
44
|
this.cwdPath = cwdPath;
|
|
42
45
|
if (!fs.existsSync(cwdPath))
|
|
43
46
|
fs.mkdirSync(cwdPath, { recursive: true });
|
|
@@ -76,10 +79,12 @@ class Executor {
|
|
|
76
79
|
let stderr = "";
|
|
77
80
|
proc.stdout?.on("data", (data) => {
|
|
78
81
|
stdout += data;
|
|
82
|
+
this.logs.push(data);
|
|
79
83
|
this.#stdout(data);
|
|
80
84
|
});
|
|
81
85
|
proc.stderr?.on("data", (data) => {
|
|
82
86
|
stderr += data;
|
|
87
|
+
this.logs.push(data);
|
|
83
88
|
this.#stdout(data);
|
|
84
89
|
});
|
|
85
90
|
return new Promise((resolve, reject) => {
|
|
@@ -91,6 +96,14 @@ class Executor {
|
|
|
91
96
|
});
|
|
92
97
|
});
|
|
93
98
|
}
|
|
99
|
+
spawnSync(command, args = [], options = {}) {
|
|
100
|
+
const proc = spawn(command, args, {
|
|
101
|
+
cwd: this.cwdPath,
|
|
102
|
+
// stdio: "inherit",
|
|
103
|
+
...options
|
|
104
|
+
});
|
|
105
|
+
return proc;
|
|
106
|
+
}
|
|
94
107
|
fork(modulePath, args = [], options = {}) {
|
|
95
108
|
const proc = fork(modulePath, args, {
|
|
96
109
|
cwd: this.cwdPath,
|
|
@@ -237,7 +250,7 @@ class Executor {
|
|
|
237
250
|
overwrite = true
|
|
238
251
|
}, dict = {}) {
|
|
239
252
|
if (targetPath.endsWith(".js") || targetPath.endsWith(".jsx")) {
|
|
240
|
-
const getContent =
|
|
253
|
+
const getContent = await import(templatePath);
|
|
241
254
|
const result = getContent.default(scanResult ?? null, dict);
|
|
242
255
|
if (result === null)
|
|
243
256
|
return null;
|
|
@@ -272,7 +285,7 @@ class Executor {
|
|
|
272
285
|
dict = {},
|
|
273
286
|
overwrite = true
|
|
274
287
|
}) {
|
|
275
|
-
const templatePath = `${
|
|
288
|
+
const templatePath = `${getDirname(import.meta.url)}/src/templates${template ? `/${template}` : ""}`;
|
|
276
289
|
const prefixTemplatePath = templatePath.endsWith(".tsx") ? templatePath : templatePath.replace(".ts", ".js");
|
|
277
290
|
if (fs.statSync(prefixTemplatePath).isFile()) {
|
|
278
291
|
const filename = path.basename(prefixTemplatePath);
|
|
@@ -813,28 +826,17 @@ class AppExecutor extends SysExecutor {
|
|
|
813
826
|
}
|
|
814
827
|
async syncAssets(libDeps) {
|
|
815
828
|
const projectPublicLibPath = `${this.cwdPath}/public/libs`;
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
fs.existsSync(projectPublicLibPath) && fsPromise.rm(projectPublicLibPath, { recursive: true }),
|
|
819
|
-
fs.existsSync(projectAssetsLibPath) && fsPromise.rm(projectAssetsLibPath, { recursive: true })
|
|
820
|
-
]);
|
|
829
|
+
if (fs.existsSync(projectPublicLibPath))
|
|
830
|
+
await fsPromise.rm(projectPublicLibPath, { recursive: true });
|
|
821
831
|
const targetDeps = libDeps.filter((dep) => fs.existsSync(`${this.workspace.workspaceRoot}/libs/${dep}/public`));
|
|
822
|
-
await Promise.all(
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
await Promise.all([
|
|
827
|
-
...targetDeps.map(
|
|
828
|
-
(dep) => fs.existsSync(`${this.workspace.workspaceRoot}/libs/${dep}/public`) && fsPromise.cp(`${this.workspace.workspaceRoot}/libs/${dep}/public`, `${projectPublicLibPath}/${dep}`, {
|
|
829
|
-
recursive: true
|
|
830
|
-
})
|
|
831
|
-
),
|
|
832
|
-
...targetDeps.map(
|
|
833
|
-
(dep) => fs.existsSync(`${this.workspace.workspaceRoot}/libs/${dep}/assets`) && fsPromise.cp(`${this.workspace.workspaceRoot}/libs/${dep}/assets`, `${projectAssetsLibPath}/${dep}`, {
|
|
832
|
+
await Promise.all(targetDeps.map((dep) => fsPromise.mkdir(`${projectPublicLibPath}/${dep}`, { recursive: true })));
|
|
833
|
+
await Promise.all(
|
|
834
|
+
targetDeps.map(
|
|
835
|
+
(dep) => fsPromise.cp(`${this.workspace.workspaceRoot}/libs/${dep}/public`, `${projectPublicLibPath}/${dep}`, {
|
|
834
836
|
recursive: true
|
|
835
837
|
})
|
|
836
838
|
)
|
|
837
|
-
|
|
839
|
+
);
|
|
838
840
|
}
|
|
839
841
|
}
|
|
840
842
|
class LibExecutor extends SysExecutor {
|
package/esm/src/index.js
CHANGED
package/esm/src/prompter.js
CHANGED
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
import { input, select } from "@inquirer/prompts";
|
|
2
2
|
import fsPromise from "fs/promises";
|
|
3
|
+
import { getDirname } from "./getDirname";
|
|
3
4
|
class Prompter {
|
|
4
5
|
static async selectGuideline() {
|
|
5
|
-
const guideNames = (await fsPromise.readdir(`${
|
|
6
|
+
const guideNames = (await fsPromise.readdir(`${getDirname(import.meta.url)}/src/guidelines`)).filter(
|
|
7
|
+
(name) => !name.startsWith("_")
|
|
8
|
+
);
|
|
6
9
|
return await select({ message: "Select a guideline", choices: guideNames.map((name) => ({ name, value: name })) });
|
|
7
10
|
}
|
|
8
11
|
static async getGuideJson(guideName) {
|
|
9
|
-
const filePath = `${
|
|
12
|
+
const filePath = `${getDirname(import.meta.url)}/src/guidelines/${guideName}/${guideName}.generate.json`;
|
|
10
13
|
const guideJson = await fsPromise.readFile(filePath, "utf-8");
|
|
11
14
|
return JSON.parse(guideJson);
|
|
12
15
|
}
|
|
13
16
|
static async getInstruction(guideName) {
|
|
14
|
-
const filePath = `${
|
|
17
|
+
const filePath = `${getDirname(import.meta.url)}/src/guidelines/${guideName}/${guideName}.instruction.md`;
|
|
15
18
|
const content = await fsPromise.readFile(filePath, "utf-8");
|
|
16
19
|
return content;
|
|
17
20
|
}
|
|
@@ -35,7 +38,7 @@ ${request}
|
|
|
35
38
|
`;
|
|
36
39
|
}
|
|
37
40
|
async getDocumentation(guideName) {
|
|
38
|
-
const filePath = `${
|
|
41
|
+
const filePath = `${getDirname(import.meta.url)}/src/guidelines/${guideName}/${guideName}.instruction.md`;
|
|
39
42
|
const document = await fsPromise.readFile(filePath, "utf-8");
|
|
40
43
|
return `\`\`\`markdown
|
|
41
44
|
${document}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useStdout } from "ink";
|
|
3
|
+
import { useEffect, useState } from "react";
|
|
4
|
+
const useStdoutDimensions = () => {
|
|
5
|
+
const { stdout } = useStdout();
|
|
6
|
+
const [dimensions, setDimensions] = useState([stdout.columns, stdout.rows]);
|
|
7
|
+
useEffect(() => {
|
|
8
|
+
const handler = () => {
|
|
9
|
+
setDimensions([stdout.columns, stdout.rows]);
|
|
10
|
+
};
|
|
11
|
+
stdout.on("resize", handler);
|
|
12
|
+
return () => {
|
|
13
|
+
stdout.off("resize", handler);
|
|
14
|
+
};
|
|
15
|
+
}, [stdout]);
|
|
16
|
+
return dimensions;
|
|
17
|
+
};
|
|
18
|
+
export {
|
|
19
|
+
useStdoutDimensions
|
|
20
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@akanjs/devkit",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.11",
|
|
4
4
|
"sourceType": "module",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -28,8 +28,10 @@
|
|
|
28
28
|
"esbuild-plugin-d.ts": "^1.3.1",
|
|
29
29
|
"eslint": "^9.19.0",
|
|
30
30
|
"form-data": "^4.0.1",
|
|
31
|
+
"ink": "^5.2.1",
|
|
31
32
|
"js-yaml": "^4.1.0",
|
|
32
33
|
"ora": "^3.4.0",
|
|
34
|
+
"react": "18.3.1",
|
|
33
35
|
"reflect-metadata": "^0.2.2",
|
|
34
36
|
"tunnel-ssh": "^5.2.0",
|
|
35
37
|
"typescript": "5.8.3"
|
package/src/executors.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Logger } from "@akanjs/common";
|
|
2
2
|
import { type AppConfigResult, AppScanResult, type LibConfigResult, LibScanResult, PkgScanResult, WorkspaceScanResult } from "@akanjs/config";
|
|
3
|
-
import { type ExecOptions, type ForkOptions, type SpawnOptions } from "child_process";
|
|
3
|
+
import { ChildProcess, type ExecOptions, type ForkOptions, type SpawnOptions } from "child_process";
|
|
4
4
|
import { Linter } from "./linter";
|
|
5
5
|
import { Spinner } from "./spinner";
|
|
6
6
|
import { TypeChecker } from "./typeChecker";
|
|
@@ -20,6 +20,7 @@ export declare class Executor {
|
|
|
20
20
|
static setVerbose(verbose: boolean): void;
|
|
21
21
|
name: string;
|
|
22
22
|
logger: Logger;
|
|
23
|
+
logs: string[];
|
|
23
24
|
cwdPath: string;
|
|
24
25
|
emoji: string;
|
|
25
26
|
typeChecker: TypeChecker | null;
|
|
@@ -27,6 +28,7 @@ export declare class Executor {
|
|
|
27
28
|
constructor(name: string, cwdPath: string);
|
|
28
29
|
exec(command: string, options?: ExecOptions): Promise<unknown>;
|
|
29
30
|
spawn(command: string, args?: string[], options?: SpawnOptions): Promise<string>;
|
|
31
|
+
spawnSync(command: string, args?: string[], options?: SpawnOptions): ChildProcess;
|
|
30
32
|
fork(modulePath: string, args?: string[], options?: ForkOptions): Promise<unknown>;
|
|
31
33
|
getPath(filePath: string): string;
|
|
32
34
|
mkdir(dirPath: string): this;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getDirname: (url: string) => string;
|
package/src/index.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useStdoutDimensions: () => [number, number];
|