@akanjs/cli 3.2.0-rc.0 → 3.2.0-rc.2
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/.build-stamp +1 -1
- package/{CodeAgent-h6g8dg3a.js → CodeAgent-6cpjtj25.js} +3 -3
- package/{CodeTui-n9gacepn.js → CodeTui-zyc7zaq6.js} +1 -1
- package/TunnelShare-zkfkrw8w.js +14 -0
- package/{agent.command-2f657613.js → agent.command-kf1g3nh4.js} +17 -17
- package/akanCode.js +6 -6
- package/{application.command-yb8v177e.js → application.command-vb278qnq.js} +13 -13
- package/{applicationBuildRunner-sctcmkyx.js → applicationBuildRunner-bqbyeg84.js} +6 -6
- package/buildBatch.proc.js +6 -6
- package/{cloud.command-et06ja22.js → cloud.command-ca777ee2.js} +19 -19
- package/cloud.script-agpxzq6j.js +30 -0
- package/{code.command-7m67c7zc.js → code.command-j08txqcd.js} +6 -6
- package/{context.command-569z0rqf.js → context.command-2fa6egp9.js} +19 -19
- package/context.runner-ftv8373t.js +29 -0
- package/{devTui-evr3b35y.js → devTui-w38ch13a.js} +1 -1
- package/{guideline.command-gnv3e8p8.js → guideline.command-w6yqpdec.js} +2 -2
- package/incrementalBuilder.proc.js +7 -7
- package/{index-jdamtr7e.js → index-0fj9ra3q.js} +7 -7
- package/{index-thckcabc.js → index-0mqga3h9.js} +18 -3
- package/{index-abgh0jve.js → index-1cb9apzn.js} +1 -1
- package/{index-ed6ea0qp.js → index-20wvskt8.js} +1 -1
- package/{index-tenw3mah.js → index-23860fej.js} +16 -6
- package/{index-5w9my9qe.js → index-2gees180.js} +8 -8
- package/{index-93ewzmp6.js → index-386canwe.js} +21 -14
- package/{index-fjr4d6yd.js → index-466z5931.js} +5 -5
- package/{index-d4n1wmrz.js → index-65b6ms4c.js} +4 -4
- package/{index-6wpaq392.js → index-6h775rv3.js} +4 -4
- package/{index-aj3ehkcx.js → index-7kmbqp0b.js} +1 -1
- package/{index-1q1cjn8s.js → index-84c2pgak.js} +93 -53
- package/{index-sy481q2x.js → index-8jpc5fqv.js} +1 -1
- package/{index-ryrm5z2c.js → index-8nbx607g.js} +10 -10
- package/{index-3wjbhj2n.js → index-abfbf01s.js} +1 -1
- package/{index-zxsygkda.js → index-annxfpgz.js} +7 -7
- package/{index-8g7tdsk4.js → index-bdmgqzb5.js} +4 -4
- package/{index-vkzfk7qt.js → index-c5ymqb05.js} +40 -30
- package/{index-0fb3cpbt.js → index-cbcwxp5v.js} +5 -5
- package/{index-zpv14wpy.js → index-djc5nxpy.js} +3 -3
- package/{index-s2grpzef.js → index-dk4g0x0d.js} +3 -3
- package/{index-drz9e84d.js → index-e22zedc2.js} +2 -2
- package/{index-w639tvkd.js → index-ebwkh7bt.js} +7 -4
- package/{index-8ts9774g.js → index-htxck0pn.js} +4 -4
- package/{index-9tbgb4d8.js → index-j1hjb477.js} +1 -1
- package/{index-kpdv34rq.js → index-j7p0jgaq.js} +10 -7
- package/{index-ktb3wcqz.js → index-kcpk2d20.js} +8 -8
- package/{index-7y5yghjg.js → index-m5sg5spm.js} +932 -431
- package/{index-rc5fvqj2.js → index-mvwvxgtd.js} +28 -26
- package/{index-e3vmjtph.js → index-pq5rjkch.js} +2 -2
- package/{index-48d5qsj3.js → index-qgazn58x.js} +4 -4
- package/{index-eajbmk10.js → index-v50xjbbe.js} +1 -1
- package/{index-7xdpww43.js → index-vbhx60x5.js} +323 -129
- package/{index-sr5da35e.js → index-wfmpxke3.js} +2 -2
- package/{index-mmym5xmb.js → index-wr9magsr.js} +5 -3
- package/{index-mqntfzv5.js → index-xa0289eg.js} +2 -2
- package/{index-8pb9yvp8.js → index-xq97me1h.js} +49 -12
- package/{index-p6hjwt2d.js → index-y725zb1a.js} +1 -1
- package/{index-hqrkqxx2.js → index-ygrdw6jw.js} +1 -1
- package/index.js +23 -23
- package/{library.command-1gp5qe3r.js → library.command-8d03a0pq.js} +4 -4
- package/{localRegistry.command-v3g21rex.js → localRegistry.command-vyv5k6t0.js} +18 -18
- package/{module.command-4xz9he6h.js → module.command-vy3kg965.js} +7 -7
- package/{package.command-s7qpnn1g.js → package.command-qjh13rs9.js} +7 -7
- package/package.json +2 -2
- package/{page.command-fan34c49.js → page.command-t0nx1jat.js} +3 -3
- package/{pipeline.command-ph4fnn9w.js → pipeline.command-2yjeas7m.js} +2 -2
- package/{primitive.command-3fqh8emf.js → primitive.command-8vm49279.js} +7 -7
- package/{projectTypecheck-vkb40hjc.js → projectTypecheck-s9hhe5sa.js} +1 -1
- package/{quality.command-ecj6exsh.js → quality.command-v76fev72.js} +6 -6
- package/{repair.command-fe9jw719.js → repair.command-fp4m3w03.js} +6 -6
- package/{scalar.command-cnvfhk0n.js → scalar.command-hxe6try8.js} +6 -6
- package/skills/akan-scaffold/SKILL.md +2 -1
- package/{subspace.command-yxtt3v3e.js → subspace.command-q42n1844.js} +8 -8
- package/{tunnel.command-ggj38mqf.js → tunnel.command-22g11n0x.js} +7 -7
- package/{verify.command-w9ttxkdz.js → verify.command-rx43bha1.js} +14 -14
- package/{workflow.command-ss8devj0.js → workflow.command-yg0d8mmq.js} +30 -15
- package/{workspace.command-rw1p0xeq.js → workspace.command-fcfztvn5.js} +34 -34
- package/TunnelShare-k3ja4w9x.js +0 -14
- package/cloud.script-s6rbrwer.js +0 -30
- package/context.runner-ms8v1rxy.js +0 -29
|
@@ -8,10 +8,10 @@ class PreviewChrome2 {
|
|
|
8
8
|
static pathEnvKey = "BUN_CHROME_PATH";
|
|
9
9
|
static backendEnvKey = "AKAN_CODE_WEBVIEW_BACKEND";
|
|
10
10
|
static executables = [
|
|
11
|
-
"chromium",
|
|
12
|
-
"chromium-browser",
|
|
13
11
|
"google-chrome-stable",
|
|
14
12
|
"google-chrome",
|
|
13
|
+
"chromium-browser",
|
|
14
|
+
"chromium",
|
|
15
15
|
"brave-browser",
|
|
16
16
|
"microsoft-edge",
|
|
17
17
|
"chrome"
|
|
@@ -79,6 +79,8 @@ class PreviewChrome2 {
|
|
|
79
79
|
|
|
80
80
|
// pkgs/@akanjs/devkit/preview/PreviewView.ts
|
|
81
81
|
class PreviewView2 {
|
|
82
|
+
static startTimeoutMs = 120000;
|
|
83
|
+
static #stalled = new Set;
|
|
82
84
|
static get available() {
|
|
83
85
|
return PreviewView2.isAvailable();
|
|
84
86
|
}
|
|
@@ -95,14 +97,22 @@ class PreviewView2 {
|
|
|
95
97
|
width = 1280,
|
|
96
98
|
height = 800,
|
|
97
99
|
engine = PreviewChrome2.backend,
|
|
100
|
+
startTimeoutMs = PreviewView2.startTimeoutMs,
|
|
98
101
|
timeoutMs = 30000,
|
|
99
102
|
settleMs = 0
|
|
100
103
|
} = {}) {
|
|
101
104
|
const logs = [];
|
|
102
|
-
const deadline = Date.now() + timeoutMs;
|
|
103
|
-
const within = (work, what) => PreviewView2.#within(work, deadline, `${what} ${url}`);
|
|
104
105
|
const view = PreviewView2.#open({ width, height, engine, onConsole: (line) => logs.push(line) });
|
|
105
106
|
try {
|
|
107
|
+
const startMs = PreviewView2.#stalled.has(engine) ? Math.min(startTimeoutMs, timeoutMs) : startTimeoutMs;
|
|
108
|
+
const stalled = new Error(`Timed out starting the ${engine} browser after ${startMs / 1000} s.`);
|
|
109
|
+
await PreviewView2.#within(view.navigate("about:blank"), Date.now() + startMs, stalled).then(() => PreviewView2.#stalled.delete(engine), (error) => {
|
|
110
|
+
if (error === stalled)
|
|
111
|
+
PreviewView2.#stalled.add(engine);
|
|
112
|
+
throw error;
|
|
113
|
+
});
|
|
114
|
+
const deadline = Date.now() + timeoutMs;
|
|
115
|
+
const within = (work, what) => PreviewView2.#within(work, deadline, new Error(`Timed out ${what} ${url}; the dev server may be rebuilding or stuck.`));
|
|
106
116
|
let page = await PreviewView2.#load(view, url, settleMs, within);
|
|
107
117
|
if (page.empty) {
|
|
108
118
|
logs.length = 0;
|
|
@@ -146,10 +156,10 @@ class PreviewView2 {
|
|
|
146
156
|
const response = await fetch(href, { redirect: "manual", signal: AbortSignal.timeout(left) }).catch(() => null);
|
|
147
157
|
return response?.status ?? null;
|
|
148
158
|
}
|
|
149
|
-
static async#within(work, deadline,
|
|
159
|
+
static async#within(work, deadline, expiry) {
|
|
150
160
|
let timer;
|
|
151
161
|
const expired = new Promise((_, reject) => {
|
|
152
|
-
timer = setTimeout(() => reject(
|
|
162
|
+
timer = setTimeout(() => reject(expiry), Math.max(0, deadline - Date.now()));
|
|
153
163
|
});
|
|
154
164
|
try {
|
|
155
165
|
return await Promise.race([work, expired]);
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
script,
|
|
5
5
|
ExitCodeError,
|
|
6
6
|
markCliErrorPrinted
|
|
7
|
-
} from "./index-
|
|
7
|
+
} from "./index-386canwe.js";
|
|
8
8
|
import {
|
|
9
9
|
AGENT_BLOCK_START,
|
|
10
10
|
AGENT_BLOCK_END,
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
CLAUDE_COMMENT_RULE,
|
|
16
16
|
AppExecutor,
|
|
17
17
|
LibExecutor
|
|
18
|
-
} from "./index-
|
|
18
|
+
} from "./index-wfmpxke3.js";
|
|
19
19
|
import {
|
|
20
20
|
akanCodePaths2
|
|
21
21
|
} from "./index-35j83zkd.js";
|
|
@@ -23,25 +23,25 @@ import {
|
|
|
23
23
|
ConventionSet,
|
|
24
24
|
Prompter2
|
|
25
25
|
} from "./index-j6eeh5d7.js";
|
|
26
|
+
import {
|
|
27
|
+
AkanContextAnalyzer
|
|
28
|
+
} from "./index-0mqga3h9.js";
|
|
26
29
|
import {
|
|
27
30
|
collectRecipeSources2,
|
|
28
31
|
scanRecipes2
|
|
29
32
|
} from "./index-hj6w4ka1.js";
|
|
30
|
-
import {
|
|
31
|
-
AkanContextAnalyzer
|
|
32
|
-
} from "./index-thckcabc.js";
|
|
33
33
|
import {
|
|
34
34
|
ApplicationRunner,
|
|
35
35
|
VerifyScope
|
|
36
|
-
} from "./index-
|
|
36
|
+
} from "./index-kcpk2d20.js";
|
|
37
37
|
import {
|
|
38
38
|
WorkspaceRunner
|
|
39
|
-
} from "./index-
|
|
39
|
+
} from "./index-466z5931.js";
|
|
40
40
|
import {
|
|
41
41
|
VerifyComments,
|
|
42
42
|
VerifyPipeline,
|
|
43
43
|
VerifyReport
|
|
44
|
-
} from "./index-
|
|
44
|
+
} from "./index-dk4g0x0d.js";
|
|
45
45
|
|
|
46
46
|
// pkgs/@akanjs/cli/agent/agent.script.ts
|
|
47
47
|
import { Logger as Logger3 } from "akanjs/common";
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
LibExecutor,
|
|
11
11
|
PkgExecutor,
|
|
12
12
|
ModuleExecutor
|
|
13
|
-
} from "./index-
|
|
13
|
+
} from "./index-wfmpxke3.js";
|
|
14
14
|
|
|
15
15
|
// pkgs/@akanjs/devkit/commandDecorators/camelToKebabCase.ts
|
|
16
16
|
var camelToKebabCase = (str) => str.replace(/([A-Z])/g, "-$1").toLowerCase();
|
|
@@ -453,11 +453,12 @@ var assertEnumChoice = (argMeta, value) => {
|
|
|
453
453
|
return;
|
|
454
454
|
throw new Error(`${argLabelOf(argMeta)} argument '${String(value)}' is invalid. Allowed choices are ${choices.map((choice) => choice.name).join(", ")}.`);
|
|
455
455
|
};
|
|
456
|
-
var assertPromptable = (problem,
|
|
456
|
+
var assertPromptable = (problem, refusal = {}) => {
|
|
457
457
|
if (process.stdin.isTTY)
|
|
458
458
|
return;
|
|
459
|
-
throw
|
|
459
|
+
throw refusalOf(problem, "stdin is not a terminal to prompt on", refusal);
|
|
460
460
|
};
|
|
461
|
+
var refusalOf = (problem, reason, { choices = [], remedy = "pass it on the command line" }) => new Error(`${problem}: ${reason}, so ${remedy}${choices.length ? ` (choices: ${choices.join(", ")})` : ""}.`);
|
|
461
462
|
var inputMessageOf = ({ name, argsOption: { desc, example, ask } }) => ask ? `${ask}: ` : desc ? `${desc}: ` : `Enter the ${name} value${example ? ` (example: ${example})` : ""}: `;
|
|
462
463
|
var getOptionValue = async (argMeta, opt, context) => {
|
|
463
464
|
const {
|
|
@@ -581,12 +582,18 @@ var getAppsArgumentValue = async (value, workspace, rerun) => {
|
|
|
581
582
|
await AppSelectionMemory.write(workspace.workspaceRoot, picked);
|
|
582
583
|
return picked.map((name) => AppExecutor.from(workspace, name));
|
|
583
584
|
};
|
|
584
|
-
var getInternalArgumentValue = async (argMeta, value, workspace, rerun) => {
|
|
585
|
+
var getInternalArgumentValue = async (argMeta, value, workspace, rerun, { destructive = false } = {}) => {
|
|
585
586
|
if (argMeta.type === "Workspace")
|
|
586
587
|
return workspace;
|
|
587
588
|
const sysType = argMeta.type.toLowerCase();
|
|
588
589
|
const [appNames, libNames, pkgNames] = await workspace.getExecs();
|
|
589
590
|
const problemOf = (kind) => value ? `Unknown ${kind} '${value}'` : `Missing ${kind}`;
|
|
591
|
+
const assertAskable = (kind, choices, placeholder) => {
|
|
592
|
+
const refusal = { choices, ...rerunRemedyOf(rerun, placeholder) };
|
|
593
|
+
if (destructive)
|
|
594
|
+
throw refusalOf(problemOf(kind), "this command deletes files and never picks its target", refusal);
|
|
595
|
+
assertPromptable(problemOf(kind), refusal);
|
|
596
|
+
};
|
|
590
597
|
if (sysType === "sys" || sysType === "exec") {
|
|
591
598
|
const pkgChoices = sysType === "exec" ? pkgNames : [];
|
|
592
599
|
const execOf = (name) => {
|
|
@@ -601,17 +608,17 @@ var getInternalArgumentValue = async (argMeta, value, workspace, rerun) => {
|
|
|
601
608
|
const found = value ? execOf(value) : null;
|
|
602
609
|
if (found)
|
|
603
610
|
return found;
|
|
604
|
-
if (!value && argMeta.option?.onlyApp && appNames.length === 1 && appNames[0])
|
|
611
|
+
if (!value && !destructive && argMeta.option?.onlyApp && appNames.length === 1 && appNames[0])
|
|
605
612
|
return AppExecutor.from(workspace, appNames[0]);
|
|
606
613
|
const [kind, placeholder] = sysType === "exec" ? ["app, lib or pkg", "<app-lib-or-pkg>"] : ["app or lib", "<app-or-lib>"];
|
|
607
614
|
const choices = [...appNames, ...libNames, ...pkgChoices];
|
|
608
615
|
const only = choices.length === 1 ? execOf(choices[0] ?? "") : null;
|
|
609
|
-
if (!value && only && !process.stdin.isTTY) {
|
|
616
|
+
if (!value && !destructive && only && !process.stdin.isTTY) {
|
|
610
617
|
const how = rerun ? `: ${rerun(only.name)}` : "";
|
|
611
618
|
Logger.rawLog(`No ${kind} named, so this runs on '${only.name}', the only one in this workspace${how}`, undefined, "error");
|
|
612
619
|
return only;
|
|
613
620
|
}
|
|
614
|
-
|
|
621
|
+
assertAskable(kind, choices, placeholder);
|
|
615
622
|
const name = await select({
|
|
616
623
|
message: sysType === "exec" ? `Select the App or Lib or Pkg name` : `Select the App or Lib name`,
|
|
617
624
|
choices
|
|
@@ -623,22 +630,22 @@ var getInternalArgumentValue = async (argMeta, value, workspace, rerun) => {
|
|
|
623
630
|
} else if (sysType === "app") {
|
|
624
631
|
if (value && appNames.includes(value))
|
|
625
632
|
return AppExecutor.from(workspace, value);
|
|
626
|
-
if (!value && appNames.length === 1 && appNames[0])
|
|
633
|
+
if (!value && !destructive && appNames.length === 1 && appNames[0])
|
|
627
634
|
return AppExecutor.from(workspace, appNames[0]);
|
|
628
|
-
|
|
635
|
+
assertAskable("app", appNames, "<app>");
|
|
629
636
|
const appName = await select({ message: `Select the ${sysType} name`, choices: appNames });
|
|
630
637
|
return AppExecutor.from(workspace, appName);
|
|
631
638
|
} else if (sysType === "lib") {
|
|
632
639
|
if (value && libNames.includes(value))
|
|
633
640
|
return LibExecutor.from(workspace, value);
|
|
634
|
-
|
|
641
|
+
assertAskable("lib", libNames, "<lib>");
|
|
635
642
|
const libName = await select({ message: `Select the ${sysType} name`, choices: libNames });
|
|
636
643
|
return LibExecutor.from(workspace, libName);
|
|
637
644
|
} else if (sysType === "pkg") {
|
|
638
645
|
const pkgs = await workspace.getPkgs();
|
|
639
646
|
if (value && pkgs.includes(value))
|
|
640
647
|
return PkgExecutor.from(workspace, value);
|
|
641
|
-
|
|
648
|
+
assertAskable("pkg", pkgs, "<pkg>");
|
|
642
649
|
const pkgName = await select({ message: `Select the ${sysType} name`, choices: pkgs });
|
|
643
650
|
return PkgExecutor.from(workspace, pkgName);
|
|
644
651
|
} else if (sysType === "module") {
|
|
@@ -665,8 +672,8 @@ var getInternalArgumentValue = async (argMeta, value, workspace, rerun) => {
|
|
|
665
672
|
...appNames.map((name) => AppExecutor.from(workspace, name)),
|
|
666
673
|
...libNames.map((name) => LibExecutor.from(workspace, name))
|
|
667
674
|
];
|
|
668
|
-
const choices = process.stdin.isTTY ? [] : (await Promise.all(systems.map(async (sys) => (await sys.getModules()).map((m) => `${sys.name}:${m}`)))).flat();
|
|
669
|
-
|
|
675
|
+
const choices = process.stdin.isTTY && !destructive ? [] : (await Promise.all(systems.map(async (sys) => (await sys.getModules()).map((m) => `${sys.name}:${m}`)))).flat();
|
|
676
|
+
assertAskable("module", choices, "<sys:module>");
|
|
670
677
|
const { type, name } = await select({
|
|
671
678
|
message: `select the App or Lib name`,
|
|
672
679
|
choices: [
|
|
@@ -781,7 +788,7 @@ ${versionWarning}`), undefined, "error");
|
|
|
781
788
|
else if (argMeta.type === "Apps")
|
|
782
789
|
commandArgs[argMeta.idx] = await getAppsArgumentValue(cmdArgs[argMeta.idx], workspace, rerun);
|
|
783
790
|
else
|
|
784
|
-
commandArgs[argMeta.idx] = await getInternalArgumentValue(argMeta, cmdArgs[argMeta.idx], workspace, rerun);
|
|
791
|
+
commandArgs[argMeta.idx] = await getInternalArgumentValue(argMeta, cmdArgs[argMeta.idx], workspace, rerun, { destructive: targetMeta.targetOption.destructive });
|
|
785
792
|
if (commandArgs[argMeta.idx] instanceof AppExecutor)
|
|
786
793
|
process.env.AKAN_PUBLIC_APP_NAME = commandArgs[argMeta.idx].name;
|
|
787
794
|
else if (Array.isArray(commandArgs[argMeta.idx])) {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import {
|
|
3
3
|
camelToKebabCase,
|
|
4
4
|
runner
|
|
5
|
-
} from "./index-
|
|
5
|
+
} from "./index-386canwe.js";
|
|
6
6
|
import {
|
|
7
7
|
FileSys2
|
|
8
8
|
} from "./index-bns3wcpc.js";
|
|
@@ -21,7 +21,7 @@ import {
|
|
|
21
21
|
SysExecutor,
|
|
22
22
|
LibExecutor,
|
|
23
23
|
PkgExecutor
|
|
24
|
-
} from "./index-
|
|
24
|
+
} from "./index-wfmpxke3.js";
|
|
25
25
|
import {
|
|
26
26
|
countBlocking,
|
|
27
27
|
formatStyleContract,
|
|
@@ -32,11 +32,11 @@ import {
|
|
|
32
32
|
} from "./index-ygdbn9jn.js";
|
|
33
33
|
import {
|
|
34
34
|
MaintainabilityBaseline
|
|
35
|
-
} from "./index-
|
|
35
|
+
} from "./index-ygrdw6jw.js";
|
|
36
36
|
import {
|
|
37
37
|
createFactReader,
|
|
38
38
|
createAst
|
|
39
|
-
} from "./index-
|
|
39
|
+
} from "./index-m5sg5spm.js";
|
|
40
40
|
import {
|
|
41
41
|
collectRecipeSources2,
|
|
42
42
|
scanRecipes2
|
|
@@ -48,7 +48,7 @@ import {
|
|
|
48
48
|
import {
|
|
49
49
|
sysInputs,
|
|
50
50
|
workflowSpecs
|
|
51
|
-
} from "./index-
|
|
51
|
+
} from "./index-v50xjbbe.js";
|
|
52
52
|
|
|
53
53
|
// pkgs/@akanjs/cli/workspace/workspace.runner.ts
|
|
54
54
|
import { mkdir, writeFile as writeFile2 } from "fs/promises";
|
|
@@ -2,22 +2,22 @@
|
|
|
2
2
|
import {
|
|
3
3
|
runner,
|
|
4
4
|
script
|
|
5
|
-
} from "./index-
|
|
5
|
+
} from "./index-386canwe.js";
|
|
6
6
|
import {
|
|
7
7
|
FileSys2
|
|
8
8
|
} from "./index-bns3wcpc.js";
|
|
9
9
|
import {
|
|
10
10
|
PkgExecutor
|
|
11
|
-
} from "./index-
|
|
11
|
+
} from "./index-wfmpxke3.js";
|
|
12
12
|
import {
|
|
13
13
|
TypeScriptDependencyScanner2
|
|
14
14
|
} from "./index-qd7xn2bk.js";
|
|
15
15
|
import {
|
|
16
16
|
FrameworkGraph
|
|
17
|
-
} from "./index-
|
|
17
|
+
} from "./index-1cb9apzn.js";
|
|
18
18
|
import {
|
|
19
19
|
MaintainabilityBaseline
|
|
20
|
-
} from "./index-
|
|
20
|
+
} from "./index-ygrdw6jw.js";
|
|
21
21
|
|
|
22
22
|
// pkgs/@akanjs/cli/package/package.runner.ts
|
|
23
23
|
import path2 from "path";
|
|
@@ -6,21 +6,21 @@ import {
|
|
|
6
6
|
CloudApi,
|
|
7
7
|
CloudUpdates,
|
|
8
8
|
PipelineSecrets
|
|
9
|
-
} from "./index-
|
|
9
|
+
} from "./index-e22zedc2.js";
|
|
10
10
|
import {
|
|
11
11
|
resolveMobileTargets
|
|
12
12
|
} from "./index-m9jj544v.js";
|
|
13
13
|
import {
|
|
14
14
|
WorkspaceExecutor,
|
|
15
15
|
AppExecutor
|
|
16
|
-
} from "./index-
|
|
16
|
+
} from "./index-wfmpxke3.js";
|
|
17
17
|
import {
|
|
18
18
|
NativeApp
|
|
19
|
-
} from "./index-
|
|
19
|
+
} from "./index-djc5nxpy.js";
|
|
20
20
|
import {
|
|
21
21
|
runner,
|
|
22
22
|
assertPromptable
|
|
23
|
-
} from "./index-
|
|
23
|
+
} from "./index-386canwe.js";
|
|
24
24
|
import {
|
|
25
25
|
getNpmRegistryUrl,
|
|
26
26
|
getPublishedVersions,
|
|
@@ -3,12 +3,13 @@ import {
|
|
|
3
3
|
AsyncDefaultExportDetector,
|
|
4
4
|
StoreBootstrap,
|
|
5
5
|
resolveSsrPageEntriesForApp
|
|
6
|
-
} from "./index-
|
|
6
|
+
} from "./index-wfmpxke3.js";
|
|
7
7
|
import {
|
|
8
8
|
FileSys2
|
|
9
9
|
} from "./index-bns3wcpc.js";
|
|
10
10
|
|
|
11
11
|
// pkgs/@akanjs/devkit/transforms/barrelAnalyzer.ts
|
|
12
|
+
import fs from "fs";
|
|
12
13
|
import path from "path";
|
|
13
14
|
import { Logger } from "akanjs/common";
|
|
14
15
|
|
|
@@ -53,6 +54,8 @@ class BarrelAnalyzer {
|
|
|
53
54
|
#logger = new Logger("BarrelAnalyzer");
|
|
54
55
|
#opts;
|
|
55
56
|
#cache = new Map;
|
|
57
|
+
#read = new Map;
|
|
58
|
+
#realDirs = new Map;
|
|
56
59
|
#tsTranspiler = new Bun.Transpiler({ loader: "ts" });
|
|
57
60
|
#tsxTranspiler = new Bun.Transpiler({ loader: "tsx" });
|
|
58
61
|
constructor(opts) {
|
|
@@ -66,13 +69,40 @@ class BarrelAnalyzer {
|
|
|
66
69
|
this.#cache.set(pkgName, promise);
|
|
67
70
|
return promise;
|
|
68
71
|
}
|
|
72
|
+
async filesOf(pkgName) {
|
|
73
|
+
await this.analyze(pkgName);
|
|
74
|
+
return [...this.#read.get(pkgName) ?? []];
|
|
75
|
+
}
|
|
76
|
+
forget(files) {
|
|
77
|
+
const dirs = new Set(files.map((file) => realDirOf(file)));
|
|
78
|
+
const forgotten = new Map;
|
|
79
|
+
for (const [pkgName, read] of this.#read) {
|
|
80
|
+
const analysis = this.#cache.get(pkgName);
|
|
81
|
+
if (!analysis || ![...read].some((file) => dirs.has(this.#realDirOf(file))))
|
|
82
|
+
continue;
|
|
83
|
+
forgotten.set(pkgName, analysis);
|
|
84
|
+
this.#cache.delete(pkgName);
|
|
85
|
+
this.#read.delete(pkgName);
|
|
86
|
+
}
|
|
87
|
+
return forgotten;
|
|
88
|
+
}
|
|
89
|
+
#realDirOf(file) {
|
|
90
|
+
let dir = this.#realDirs.get(file);
|
|
91
|
+
if (dir === undefined) {
|
|
92
|
+
dir = realDirOf(file);
|
|
93
|
+
this.#realDirs.set(file, dir);
|
|
94
|
+
}
|
|
95
|
+
return dir;
|
|
96
|
+
}
|
|
69
97
|
async#analyzeSafe(pkgName) {
|
|
70
98
|
try {
|
|
71
99
|
const pkg = await this.#opts.resolvePackage(pkgName);
|
|
72
100
|
if (!pkg)
|
|
73
101
|
return null;
|
|
74
102
|
const map = new Map;
|
|
75
|
-
|
|
103
|
+
const read = new Set;
|
|
104
|
+
this.#read.set(pkgName, read);
|
|
105
|
+
await this.#walk(pkg.entryFile, pkg, map, read);
|
|
76
106
|
return map;
|
|
77
107
|
} catch (err) {
|
|
78
108
|
this.#logger.error(`analyze failed for ${pkgName}: ${err.message}`);
|
|
@@ -180,6 +210,14 @@ class BarrelAnalyzer {
|
|
|
180
210
|
return defaultResolveRelative(fromFile, relSpec);
|
|
181
211
|
}
|
|
182
212
|
}
|
|
213
|
+
var realDirOf = (file) => {
|
|
214
|
+
const dir = path.dirname(path.resolve(file));
|
|
215
|
+
try {
|
|
216
|
+
return fs.realpathSync.native(dir);
|
|
217
|
+
} catch {
|
|
218
|
+
return dir;
|
|
219
|
+
}
|
|
220
|
+
};
|
|
183
221
|
var isRelative = (spec) => {
|
|
184
222
|
return spec.startsWith("./") || spec.startsWith("../") || spec === "." || spec === "..";
|
|
185
223
|
};
|
|
@@ -397,7 +435,8 @@ var resolveFileCandidate = async (candidate) => {
|
|
|
397
435
|
return null;
|
|
398
436
|
};
|
|
399
437
|
var MACRO_ATTR_RE = /with\s*\{\s*type\s*:\s*["']macro["']\s*\}/;
|
|
400
|
-
var
|
|
438
|
+
var workspaceBarrels = (barrels) => barrels.filter((barrel) => /^@(?:apps|libs)\//.test(barrel));
|
|
439
|
+
var rewriteBarrelImports = async (source, barrels, analyzer, { keepLines = false, specifierOf = (subpath) => subpath, onImport } = {}) => {
|
|
401
440
|
if (!barrels.some((barrel) => source.includes(barrel)))
|
|
402
441
|
return null;
|
|
403
442
|
const statements = findImportStatements(source);
|
|
@@ -411,12 +450,19 @@ var rewriteBarrelImports = async (source, barrels, analyzer) => {
|
|
|
411
450
|
continue;
|
|
412
451
|
if (!barrels.includes(stmt.specifier))
|
|
413
452
|
continue;
|
|
453
|
+
const names = valueNamesOf(stmt.clause);
|
|
454
|
+
if (names.length > 0)
|
|
455
|
+
onImport?.(stmt.specifier, names);
|
|
414
456
|
const map = await analyzer.analyze(stmt.specifier);
|
|
415
457
|
if (!map || map.size === 0)
|
|
416
458
|
continue;
|
|
417
|
-
const
|
|
418
|
-
if (
|
|
459
|
+
const lines = rewriteSingleStatement(stmt, map, specifierOf);
|
|
460
|
+
if (lines === null)
|
|
419
461
|
continue;
|
|
462
|
+
const replacement = keepLines ? `${lines.join(" ")}${`
|
|
463
|
+
`.repeat(source.slice(stmt.start, stmt.end).split(`
|
|
464
|
+
`).length - 1)}` : lines.join(`
|
|
465
|
+
`);
|
|
420
466
|
out = out.slice(0, stmt.start) + replacement + out.slice(stmt.end);
|
|
421
467
|
changed = true;
|
|
422
468
|
}
|
|
@@ -436,45 +482,40 @@ var findImportStatements = (source) => {
|
|
|
436
482
|
statements.push({
|
|
437
483
|
start: statement.getStart(sourceFile),
|
|
438
484
|
end: statement.end,
|
|
439
|
-
clause:
|
|
485
|
+
clause: clauseOf(importClause),
|
|
440
486
|
specifier: statement.moduleSpecifier.text
|
|
441
487
|
});
|
|
442
488
|
}
|
|
443
489
|
return statements;
|
|
444
490
|
};
|
|
445
|
-
var
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
}
|
|
452
|
-
const parsed = { typeOnly };
|
|
453
|
-
const commaMatch = /^(\w+)\s*,\s*(.+)$/.exec(rest);
|
|
454
|
-
if (commaMatch) {
|
|
455
|
-
parsed.defaultImport = commaMatch[1];
|
|
456
|
-
rest = commaMatch[2] ?? "";
|
|
457
|
-
} else if (/^\w+$/.test(rest)) {
|
|
458
|
-
parsed.defaultImport = rest;
|
|
491
|
+
var clauseOf = (importClause) => {
|
|
492
|
+
const parsed = { typeOnly: importClause.phaseModifier === ts.SyntaxKind.TypeKeyword };
|
|
493
|
+
if (importClause.name)
|
|
494
|
+
parsed.defaultImport = importClause.name.text;
|
|
495
|
+
const bindings = importClause.namedBindings;
|
|
496
|
+
if (!bindings)
|
|
459
497
|
return parsed;
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
498
|
+
if (ts.isNamespaceImport(bindings))
|
|
499
|
+
return { ...parsed, namespaceImport: bindings.name.text };
|
|
500
|
+
const named = [];
|
|
501
|
+
for (const element of bindings.elements) {
|
|
502
|
+
if (element.propertyName && !ts.isIdentifier(element.propertyName))
|
|
464
503
|
return null;
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
if (close === -1)
|
|
471
|
-
return null;
|
|
472
|
-
parsed.named = parseNamedList(rest.slice(1, close));
|
|
504
|
+
named.push({
|
|
505
|
+
imported: (element.propertyName ?? element.name).text,
|
|
506
|
+
local: element.name.text,
|
|
507
|
+
isType: element.isTypeOnly
|
|
508
|
+
});
|
|
473
509
|
}
|
|
474
|
-
return parsed;
|
|
510
|
+
return { ...parsed, named };
|
|
511
|
+
};
|
|
512
|
+
var valueNamesOf = (clause) => {
|
|
513
|
+
if (!clause || clause.namespaceImport || clause.typeOnly)
|
|
514
|
+
return [];
|
|
515
|
+
return (clause.named ?? []).filter((item) => !item.isType).map((item) => item.imported);
|
|
475
516
|
};
|
|
476
|
-
var rewriteSingleStatement = (stmt, map) => {
|
|
477
|
-
const clause =
|
|
517
|
+
var rewriteSingleStatement = (stmt, map, specifierOf) => {
|
|
518
|
+
const { clause } = stmt;
|
|
478
519
|
if (!clause)
|
|
479
520
|
return null;
|
|
480
521
|
if (clause.namespaceImport)
|
|
@@ -497,7 +538,7 @@ var rewriteSingleStatement = (stmt, map) => {
|
|
|
497
538
|
continue;
|
|
498
539
|
}
|
|
499
540
|
if (target.namespace) {
|
|
500
|
-
namespaceLines.push(`import * as ${item.local} from
|
|
541
|
+
namespaceLines.push(`import * as ${item.local} from ${JSON.stringify(specifierOf(target.subpath))};`);
|
|
501
542
|
continue;
|
|
502
543
|
}
|
|
503
544
|
const list = rewrites.get(target.subpath) ?? [];
|
|
@@ -506,7 +547,7 @@ var rewriteSingleStatement = (stmt, map) => {
|
|
|
506
547
|
}
|
|
507
548
|
if (rewrites.size === 0 && namespaceLines.length === 0)
|
|
508
549
|
return null;
|
|
509
|
-
const lines =
|
|
550
|
+
const lines = (StoreBootstrap.ofClientBarrel(stmt.specifier, map) ?? []).map((specifier) => `import ${JSON.stringify(specifierOf(specifier))};`);
|
|
510
551
|
if (clause.defaultImport || remaining.length > 0) {
|
|
511
552
|
const parts = [];
|
|
512
553
|
if (clause.defaultImport)
|
|
@@ -516,11 +557,10 @@ var rewriteSingleStatement = (stmt, map) => {
|
|
|
516
557
|
lines.push(`import ${parts.join(", ")} from "${stmt.specifier}";`);
|
|
517
558
|
}
|
|
518
559
|
for (const [subpath, items] of rewrites) {
|
|
519
|
-
lines.push(`import { ${items.map(serializeNamedItem).join(", ")} } from
|
|
560
|
+
lines.push(`import { ${items.map(serializeNamedItem).join(", ")} } from ${JSON.stringify(specifierOf(subpath))};`);
|
|
520
561
|
}
|
|
521
562
|
lines.push(...namespaceLines);
|
|
522
|
-
return lines
|
|
523
|
-
`);
|
|
563
|
+
return lines;
|
|
524
564
|
};
|
|
525
565
|
var serializeNamedItem = (item) => {
|
|
526
566
|
const prefix = item.isType ? "type " : "";
|
|
@@ -541,7 +581,7 @@ var bundleDefine = (app, command, renderEnv) => {
|
|
|
541
581
|
};
|
|
542
582
|
|
|
543
583
|
// pkgs/@akanjs/devkit/frontendBuild/csrDevPaths.ts
|
|
544
|
-
import
|
|
584
|
+
import fs2 from "fs";
|
|
545
585
|
import path3 from "path";
|
|
546
586
|
|
|
547
587
|
class CsrDevPaths {
|
|
@@ -572,18 +612,18 @@ class CsrDevPaths {
|
|
|
572
612
|
return /\.[cm]?[jt]sx?$/.test(file);
|
|
573
613
|
}
|
|
574
614
|
static mtimeOf(file) {
|
|
575
|
-
return
|
|
615
|
+
return fs2.statSync(file, { throwIfNoEntry: false })?.mtimeMs ?? -1;
|
|
576
616
|
}
|
|
577
617
|
static async hashOf(file) {
|
|
578
618
|
const source = Bun.file(file);
|
|
579
619
|
return await source.exists() ? Bun.hash(await source.arrayBuffer()).toString(36) : "";
|
|
580
620
|
}
|
|
581
621
|
static realpath(file) {
|
|
582
|
-
return
|
|
622
|
+
return fs2.existsSync(file) ? fs2.realpathSync.native(file) : path3.resolve(file);
|
|
583
623
|
}
|
|
584
624
|
static isNamed(file) {
|
|
585
625
|
try {
|
|
586
|
-
return
|
|
626
|
+
return fs2.realpathSync.native(file) === file;
|
|
587
627
|
} catch {
|
|
588
628
|
return false;
|
|
589
629
|
}
|
|
@@ -601,7 +641,7 @@ class CsrDevPaths {
|
|
|
601
641
|
return folder ? CsrDevPaths.#asFolder(base, kind) : CsrDevPaths.resolveOnDisk(base, kind);
|
|
602
642
|
}
|
|
603
643
|
static #asFile(base, kind) {
|
|
604
|
-
const isFile = (candidate) =>
|
|
644
|
+
const isFile = (candidate) => fs2.statSync(candidate, { throwIfNoEntry: false })?.isFile() ?? false;
|
|
605
645
|
return [base, ...CsrDevPaths.#extensions[kind].map((extension) => `${base}${extension}`)].find(isFile) ?? null;
|
|
606
646
|
}
|
|
607
647
|
static #asFolder(dir, kind) {
|
|
@@ -614,7 +654,7 @@ class CsrDevPaths {
|
|
|
614
654
|
}
|
|
615
655
|
static #packageEntryOf(dir, kind) {
|
|
616
656
|
try {
|
|
617
|
-
const pkg = JSON.parse(
|
|
657
|
+
const pkg = JSON.parse(fs2.readFileSync(path3.join(dir, "package.json"), "utf8"));
|
|
618
658
|
const fields = kind === "require" ? [pkg.browser, pkg.main] : [pkg.browser, pkg.module, pkg.main];
|
|
619
659
|
const entry = fields.find((field) => typeof field === "string");
|
|
620
660
|
return typeof entry === "string" ? entry : null;
|
|
@@ -629,8 +669,8 @@ class CsrDevPaths {
|
|
|
629
669
|
return false;
|
|
630
670
|
for (let dir = path3.resolve(from);; dir = path3.dirname(dir)) {
|
|
631
671
|
const pkgDir = path3.join(dir, "node_modules", name);
|
|
632
|
-
if (
|
|
633
|
-
return (
|
|
672
|
+
if (fs2.existsSync(path3.join(pkgDir, "package.json")))
|
|
673
|
+
return (fs2.statSync(pkgDir, { throwIfNoEntry: false })?.ctimeMs ?? 0) > since;
|
|
634
674
|
if (path3.dirname(dir) === dir)
|
|
635
675
|
return false;
|
|
636
676
|
}
|
|
@@ -674,7 +714,7 @@ class CsrEntryFiles {
|
|
|
674
714
|
}
|
|
675
715
|
|
|
676
716
|
// pkgs/@akanjs/devkit/frontendBuild/pagesBundleBuilder.ts
|
|
677
|
-
import
|
|
717
|
+
import fs4 from "fs";
|
|
678
718
|
import path9 from "path";
|
|
679
719
|
import ts3 from "typescript";
|
|
680
720
|
|
|
@@ -930,14 +970,14 @@ ${entries.join(`
|
|
|
930
970
|
}
|
|
931
971
|
|
|
932
972
|
// pkgs/@akanjs/devkit/frontendBuild/serverGraphFile.ts
|
|
933
|
-
import
|
|
973
|
+
import fs3 from "fs";
|
|
934
974
|
import path8 from "path";
|
|
935
975
|
class ServerGraphFile {
|
|
936
976
|
static fileName = "server-graph.json";
|
|
937
977
|
static #cache = null;
|
|
938
978
|
static async read(artifactDir) {
|
|
939
979
|
const file = path8.join(artifactDir, ServerGraphFile.fileName);
|
|
940
|
-
const stat =
|
|
980
|
+
const stat = fs3.statSync(file, { throwIfNoEntry: false });
|
|
941
981
|
if (!stat)
|
|
942
982
|
return null;
|
|
943
983
|
const stamp = `${stat.ino}:${stat.size}:${stat.mtimeMs}`;
|
|
@@ -1074,7 +1114,7 @@ class PagesBundleBuilder {
|
|
|
1074
1114
|
};
|
|
1075
1115
|
}
|
|
1076
1116
|
#serverGraph(metafile, clientExports) {
|
|
1077
|
-
const inputs = Object.keys(metafile.inputs).filter((input) => !input.includes("node_modules")).map((input) => path9.resolve(input)).filter((input) =>
|
|
1117
|
+
const inputs = Object.keys(metafile.inputs).filter((input) => !input.includes("node_modules")).map((input) => path9.resolve(input)).filter((input) => fs4.existsSync(input)).map((input) => CsrDevPaths.realpath(input));
|
|
1078
1118
|
return { inputs, clientExports };
|
|
1079
1119
|
}
|
|
1080
1120
|
get #artifactDir() {
|
|
@@ -1182,4 +1222,4 @@ class PagesBundleBuilder {
|
|
|
1182
1222
|
}
|
|
1183
1223
|
}
|
|
1184
1224
|
|
|
1185
|
-
export { loaderFor, BarrelAnalyzer, createBarrelImportsPlugin, createTsconfigPackageResolver, rewriteBarrelImports, bundleConditions, bundleDefine, CsrEntryFiles, toClientReferencePath, scanUseClientExports, CsrDevPaths, PagesEntrySourceGenerator, ServerGraphFile, PagesBundleBuilder };
|
|
1225
|
+
export { loaderFor, BarrelAnalyzer, createBarrelImportsPlugin, createTsconfigPackageResolver, workspaceBarrels, rewriteBarrelImports, bundleConditions, bundleDefine, CsrEntryFiles, toClientReferencePath, scanUseClientExports, CsrDevPaths, PagesEntrySourceGenerator, ServerGraphFile, PagesBundleBuilder };
|