@akanjs/cli 3.1.1-rc.0 → 3.1.1-rc.10
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-4pnxwptq.js → CodeAgent-8d5qs787.js} +2 -2
- package/{CodeTui-hhndze8h.js → CodeTui-z5vkm9ea.js} +1 -1
- package/TunnelShare-qkm8zp03.js +14 -0
- package/{agent.command-p02330r6.js → agent.command-ydftceda.js} +5 -5
- package/akanCode.js +2 -2
- package/{application.command-ywks5ywm.js → application.command-wthg8nn9.js} +18 -13
- package/{applicationBuildRunner-9cnnsdm5.js → applicationBuildRunner-t2r84sz6.js} +72 -26
- package/buildBatch.proc.js +5 -5
- package/{cloud.command-1tzkvje1.js → cloud.command-sz11hpre.js} +22 -17
- package/cloud.script-nqevg5qw.js +24 -0
- package/{code.command-16pm1p2v.js → code.command-9h3yrzhe.js} +6 -6
- package/{context.command-6ys86sqf.js → context.command-15j9b7c0.js} +16 -16
- package/context.runner-8gg030b0.js +25 -0
- package/{guideline.command-3zay3d8g.js → guideline.command-snh85ctf.js} +2 -2
- package/guidelines/agentRule/agentRule.instruction.md +21 -4
- package/guidelines/conventions/conventions.instruction.md +17 -10
- package/guidelines/mcpRule/mcpRule.instruction.md +13 -6
- package/guidelines/pageRule/pageRule.instruction.md +21 -5
- package/guidelines/queryRule/queryRule.instruction.md +13 -1
- package/guidelines/runtimeRule/runtimeRule.instruction.md +20 -2
- package/guidelines/ssrRule/ssrRule.instruction.md +6 -1
- package/guidelines/transportRule/transportRule.instruction.md +12 -5
- package/guidelines/workspaceOnboarding/workspaceOnboarding.instruction.md +2 -1
- package/incrementalBuilder.proc.js +3 -3
- package/{index-jgs8z8xb.js → index-0fz95kxe.js} +1 -1
- package/{index-1f33g2z5.js → index-2azahjaw.js} +81 -28
- package/{index-kcbq2qcf.js → index-2mwc0g0d.js} +1 -1
- package/{index-qkcwsg6r.js → index-2xcc2ax5.js} +2 -2
- package/{index-68c3gzvg.js → index-301pdbzz.js} +56 -9
- package/{index-z6v7k9sb.js → index-31es1yev.js} +24 -2
- package/{index-p4dnj2wc.js → index-3wypz6xj.js} +59 -8
- package/{index-e9e9cebg.js → index-40brg4px.js} +3 -3
- package/{index-tk3jg2bm.js → index-42j4a8zq.js} +2 -2
- package/{index-1mfyyxh5.js → index-4vgbysa0.js} +3 -3
- package/{index-9hbhm6cs.js → index-55j120r8.js} +1 -1
- package/{index-vg28jsf9.js → index-6txx6a9p.js} +214 -71
- package/{index-zn6bn1s2.js → index-74tjjsnc.js} +4 -4
- package/{index-g2s33373.js → index-905qdgqp.js} +1 -1
- package/{index-qtkycaqn.js → index-9th4gszy.js} +38 -21
- package/{index-bb4hj03s.js → index-a58emady.js} +10 -10
- package/{index-4w3skd33.js → index-a5dhqkdr.js} +3 -3
- package/{index-sh9mmp5v.js → index-b70zct19.js} +7 -7
- package/{index-z9xepn8t.js → index-bt438yxm.js} +556 -142
- package/{index-ngpn9hzy.js → index-espk51ah.js} +2 -2
- package/{index-b5vptvnt.js → index-hmt54t45.js} +4 -4
- package/{index-qfzfaq96.js → index-j9vyj3dj.js} +3 -3
- package/{index-ekpp5tax.js → index-js6geqjn.js} +4 -97
- package/{index-fmder14z.js → index-pcwzkdqb.js} +1 -1
- package/{index-jaa81e9r.js → index-qfp55x1y.js} +4 -4
- package/{index-sng3vt0p.js → index-skk9zc1x.js} +2 -2
- package/{index-rr7jk14m.js → index-wcej7g4z.js} +13 -10
- package/{index-q8age5az.js → index-xb8809yb.js} +2 -2
- package/{index-ynqxpwx6.js → index-xjf5j657.js} +1 -1
- package/index.js +22 -22
- package/{library.command-a8n9h8j4.js → library.command-gycrwhf1.js} +3 -3
- package/{localRegistry.command-1e6m7w2f.js → localRegistry.command-jtd8gaes.js} +12 -12
- package/{module.command-b6f1p1xa.js → module.command-v6hgs1bc.js} +5 -5
- package/{package.command-tc27ftmy.js → package.command-shzpcfph.js} +3 -3
- package/package.json +2 -2
- package/{page.command-m5wyqfkd.js → page.command-ptxn5kqk.js} +3 -3
- package/{pipeline.command-4qxyafpz.js → pipeline.command-zz31pgax.js} +2 -2
- package/{primitive.command-9yaatk0d.js → primitive.command-a1vse91z.js} +6 -6
- package/{projectTypecheck-87k6z6ab.js → projectTypecheck-2ztky9cf.js} +1 -1
- package/{quality.command-ht1wjhv8.js → quality.command-ah8qcakd.js} +387 -73
- package/{repair.command-evg9g911.js → repair.command-cvazbz99.js} +5 -5
- package/{scalar.command-xsejjeq1.js → scalar.command-0acvyp26.js} +4 -4
- package/{subspace.command-ps12q5y7.js → subspace.command-822qx2bx.js} +8 -8
- package/templates/app/tsconfig.json.template +2 -7
- package/templates/env/_env.server.type.ts +10 -5
- package/templates/facetIndex/index.ts +2 -2
- package/templates/workspaceRoot/bunfig.toml.template +0 -4
- package/{tunnel.command-khzgvrj8.js → tunnel.command-ycmja19q.js} +7 -7
- package/{workflow.command-qpyq0ya5.js → workflow.command-abb1d5xy.js} +10 -10
- package/{workspace.command-3dq7e9g2.js → workspace.command-qm7cw29v.js} +33 -32
- package/TunnelShare-zmq6bbar.js +0 -14
- package/cloud.script-8g83xqdg.js +0 -24
- package/context.runner-3jrypwe3.js +0 -25
|
@@ -1,19 +1,26 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import {
|
|
3
|
+
CloudHttpError,
|
|
3
4
|
getDefaultHostConfig,
|
|
4
5
|
GlobalConfig,
|
|
5
6
|
CloudApi,
|
|
6
7
|
CloudUpdates,
|
|
7
8
|
PipelineSecrets
|
|
8
|
-
} from "./index-
|
|
9
|
+
} from "./index-2azahjaw.js";
|
|
10
|
+
import {
|
|
11
|
+
resolveMobileTargets
|
|
12
|
+
} from "./index-m9jj544v.js";
|
|
9
13
|
import {
|
|
10
14
|
WorkspaceExecutor,
|
|
11
15
|
AppExecutor
|
|
12
|
-
} from "./index-
|
|
16
|
+
} from "./index-wcej7g4z.js";
|
|
17
|
+
import {
|
|
18
|
+
NativeApp
|
|
19
|
+
} from "./index-bt438yxm.js";
|
|
13
20
|
import {
|
|
14
21
|
runner,
|
|
15
22
|
assertPromptable
|
|
16
|
-
} from "./index-
|
|
23
|
+
} from "./index-3wypz6xj.js";
|
|
17
24
|
import {
|
|
18
25
|
SubspaceConfig
|
|
19
26
|
} from "./index-4pf8g7ff.js";
|
|
@@ -675,9 +682,136 @@ class PlatformTestRun {
|
|
|
675
682
|
|
|
676
683
|
// pkgs/@akanjs/cli/cloud/cloud.runner.ts
|
|
677
684
|
import { confirm, input, select } from "@inquirer/prompts";
|
|
678
|
-
import { Logger
|
|
685
|
+
import { Logger as Logger2 } from "akanjs/common";
|
|
686
|
+
import chalk3 from "chalk";
|
|
687
|
+
|
|
688
|
+
// pkgs/@akanjs/cli/cloud/remoteLogin.ts
|
|
689
|
+
import { Backoff, Logger, RemoteAuthCode, sleep } from "akanjs/common";
|
|
679
690
|
import chalk2 from "chalk";
|
|
680
691
|
import * as QRcode from "qrcode";
|
|
692
|
+
class RemoteLogin {
|
|
693
|
+
#api;
|
|
694
|
+
#pollMs;
|
|
695
|
+
#limitMs;
|
|
696
|
+
#maxBackoffMs;
|
|
697
|
+
#selfAttempts;
|
|
698
|
+
#open;
|
|
699
|
+
#wait;
|
|
700
|
+
#now;
|
|
701
|
+
constructor(api, {
|
|
702
|
+
pollMs = 2000,
|
|
703
|
+
limitMs = 10 * 60000,
|
|
704
|
+
maxBackoffMs = 30000,
|
|
705
|
+
selfAttempts = 5,
|
|
706
|
+
open = openBrowser,
|
|
707
|
+
wait = sleep,
|
|
708
|
+
now = Date.now
|
|
709
|
+
} = {}) {
|
|
710
|
+
this.#api = api;
|
|
711
|
+
this.#pollMs = pollMs;
|
|
712
|
+
this.#limitMs = limitMs;
|
|
713
|
+
this.#maxBackoffMs = maxBackoffMs;
|
|
714
|
+
this.#selfAttempts = selfAttempts;
|
|
715
|
+
this.#open = open;
|
|
716
|
+
this.#wait = wait;
|
|
717
|
+
this.#now = now;
|
|
718
|
+
}
|
|
719
|
+
async signIn(remoteId = crypto.randomUUID()) {
|
|
720
|
+
const loginId = await RemoteAuthCode.loginIdOf(remoteId);
|
|
721
|
+
await this.#prompt(remoteId, loginId);
|
|
722
|
+
const accessToken = await this.#awaitApproval(remoteId, loginId);
|
|
723
|
+
const { host } = this.#api;
|
|
724
|
+
await GlobalConfig.setHostConfig({ host, auth: { accessToken } });
|
|
725
|
+
const self = await this.#readSelf();
|
|
726
|
+
if (self)
|
|
727
|
+
await GlobalConfig.setHostConfig({ host, auth: { accessToken, self } });
|
|
728
|
+
return self;
|
|
729
|
+
}
|
|
730
|
+
async#prompt(remoteId, loginId) {
|
|
731
|
+
const signinUrl = `${this.#api.host}/remoteAuth?remoteId=${encodeURIComponent(loginId)}`;
|
|
732
|
+
Logger.rawLog(chalk2.bold(`
|
|
733
|
+
${chalk2.green("\u27A4")} Authentication Required`));
|
|
734
|
+
Logger.rawLog(chalk2.dim("Please visit or click the following URL:"));
|
|
735
|
+
Logger.rawLog(`${chalk2.cyan.underline(signinUrl)}
|
|
736
|
+
`);
|
|
737
|
+
try {
|
|
738
|
+
Logger.rawLog(await QRcode.toString(signinUrl, { type: "terminal", small: true }));
|
|
739
|
+
await this.#open(signinUrl);
|
|
740
|
+
Logger.rawLog(chalk2.dim("Opening browser..."));
|
|
741
|
+
} catch {
|
|
742
|
+
Logger.rawLog(chalk2.yellow("Could not open browser. Please visit the URL manually."));
|
|
743
|
+
}
|
|
744
|
+
Logger.rawLog(`
|
|
745
|
+
${chalk2.bold("Your code:")} ${chalk2.bold.inverse(` ${await RemoteAuthCode.of(remoteId)} `)}`);
|
|
746
|
+
Logger.rawLog(chalk2.dim(`Enter this code on the sign-in page, and approve only if it matches what this terminal shows.
|
|
747
|
+
`));
|
|
748
|
+
}
|
|
749
|
+
async#awaitApproval(remoteId, loginId) {
|
|
750
|
+
Logger.rawLog(chalk2.dim("Waiting for authentication..."));
|
|
751
|
+
const deadline = this.#now() + this.#limitMs;
|
|
752
|
+
const ids = [remoteId, loginId];
|
|
753
|
+
let failures = 0;
|
|
754
|
+
while (this.#now() < deadline) {
|
|
755
|
+
const answers = await Promise.allSettled(ids.map((id) => this.#api.getRemoteAuthToken(id)));
|
|
756
|
+
for (const answer of answers)
|
|
757
|
+
if (answer.status === "fulfilled" && answer.value)
|
|
758
|
+
return answer.value;
|
|
759
|
+
const [device, legacy] = answers.map((answer) => answer.status === "rejected" ? answer.reason : null);
|
|
760
|
+
if (RemoteLogin.#isFinal(device))
|
|
761
|
+
throw this.#refusal(device);
|
|
762
|
+
if (RemoteLogin.#isFinal(legacy))
|
|
763
|
+
ids.pop();
|
|
764
|
+
const errors = [device, legacy].filter((error) => error && !RemoteLogin.#isFinal(error));
|
|
765
|
+
const retryAfterMs = Math.max(0, ...errors.map((error) => (error instanceof CloudHttpError ? error.retryAfterMs : null) ?? 0));
|
|
766
|
+
let waitMs = Math.max(this.#pollMs, retryAfterMs);
|
|
767
|
+
if (answers.some((answer) => answer.status === "fulfilled"))
|
|
768
|
+
failures = 0;
|
|
769
|
+
else {
|
|
770
|
+
if (failures++ === 0)
|
|
771
|
+
Logger.rawLog(chalk2.yellow(`Could not check the sign-in (${RemoteLogin.#reasonOf(errors[0])}); retrying...`));
|
|
772
|
+
waitMs = Math.max(retryAfterMs, Backoff.delay(failures + 1, { min: this.#pollMs, max: this.#maxBackoffMs }));
|
|
773
|
+
}
|
|
774
|
+
await this.#wait(Math.min(waitMs, Math.max(0, deadline - this.#now())));
|
|
775
|
+
}
|
|
776
|
+
throw new Error(chalk2.red(`\u2716 Authentication timed out after ${Math.round(this.#limitMs / 60000)} minutes. Please try again.`));
|
|
777
|
+
}
|
|
778
|
+
async#readSelf() {
|
|
779
|
+
let reason = "";
|
|
780
|
+
for (let attempt = 1;attempt <= this.#selfAttempts; attempt++) {
|
|
781
|
+
try {
|
|
782
|
+
const self = await this.#api.getRemoteSelf();
|
|
783
|
+
if (self)
|
|
784
|
+
return self;
|
|
785
|
+
reason = "the server did not take the new session";
|
|
786
|
+
break;
|
|
787
|
+
} catch (error) {
|
|
788
|
+
reason = RemoteLogin.#reasonOf(error);
|
|
789
|
+
}
|
|
790
|
+
if (attempt < this.#selfAttempts)
|
|
791
|
+
await this.#wait(Backoff.delay(attempt, { min: 1000, max: 8000 }));
|
|
792
|
+
}
|
|
793
|
+
Logger.rawLog(chalk2.yellow(`Could not read the signed-in account (${reason}).`));
|
|
794
|
+
return null;
|
|
795
|
+
}
|
|
796
|
+
static #isFinal(error) {
|
|
797
|
+
return error instanceof CloudHttpError && error.status < 500 && error.status !== 408 && error.status !== 429;
|
|
798
|
+
}
|
|
799
|
+
#refusal(error) {
|
|
800
|
+
const { host } = this.#api;
|
|
801
|
+
if (error.status === 404 && !error.errKey)
|
|
802
|
+
return new Error(chalk2.red(`\u2716 ${host} does not serve Akan CLI sign-ins (HTTP 404): check --host.`), {
|
|
803
|
+
cause: error
|
|
804
|
+
});
|
|
805
|
+
return new Error(chalk2.red(`\u2716 ${host} refused this sign-in (${error.errKey ?? `HTTP ${error.status}`}). Run akan login to start over.`), { cause: error });
|
|
806
|
+
}
|
|
807
|
+
static #reasonOf(error) {
|
|
808
|
+
if (error instanceof CloudHttpError)
|
|
809
|
+
return error.errKey ?? `HTTP ${error.status}`;
|
|
810
|
+
return error instanceof Error ? error.message : String(error);
|
|
811
|
+
}
|
|
812
|
+
}
|
|
813
|
+
|
|
814
|
+
// pkgs/@akanjs/cli/cloud/cloud.runner.ts
|
|
681
815
|
var addRemoteEnvServerValue = "__addRemoteEnvServer";
|
|
682
816
|
var removeRemoteEnvServerValue = "__removeRemoteEnvServer";
|
|
683
817
|
|
|
@@ -726,7 +860,7 @@ class CloudRunner extends runner("cloud") {
|
|
|
726
860
|
const servers = await GlobalConfig.getRemoteEnvServers();
|
|
727
861
|
const serverEntries = Object.entries(servers).sort(([nameA], [nameB]) => nameA.localeCompare(nameB));
|
|
728
862
|
if (serverEntries.length === 0) {
|
|
729
|
-
|
|
863
|
+
Logger2.info("No remote env servers configured. Add the first remote server for SCP mode.");
|
|
730
864
|
return await this.#addRemoteEnvServer();
|
|
731
865
|
}
|
|
732
866
|
const selectedName = await select({
|
|
@@ -756,7 +890,7 @@ class CloudRunner extends runner("cloud") {
|
|
|
756
890
|
if (!await confirm({ message: `Remove remote env server "${selectedName}"?`, default: false }))
|
|
757
891
|
return;
|
|
758
892
|
await GlobalConfig.removeRemoteEnvServer(selectedName);
|
|
759
|
-
|
|
893
|
+
Logger2.info(`Removed remote env server "${selectedName}"`);
|
|
760
894
|
}
|
|
761
895
|
#serverChoice([name, config]) {
|
|
762
896
|
return { name: `${name} (${this.#getSshTarget(config)}${config.port ? `:${config.port}` : ""})`, value: name };
|
|
@@ -792,67 +926,41 @@ class CloudRunner extends runner("cloud") {
|
|
|
792
926
|
}
|
|
793
927
|
async login(host, workspace) {
|
|
794
928
|
const cloudApi = await CloudApi.fromHost(workspace, host);
|
|
795
|
-
const
|
|
796
|
-
if (
|
|
797
|
-
|
|
798
|
-
\u2713 Already logged in akan cloud as ${
|
|
929
|
+
const signedIn = await cloudApi.getRemoteSelf().catch(() => null);
|
|
930
|
+
if (signedIn) {
|
|
931
|
+
Logger2.rawLog(chalk3.green(`
|
|
932
|
+
\u2713 Already logged in akan cloud as ${signedIn.nickname}
|
|
799
933
|
`));
|
|
800
934
|
return true;
|
|
801
935
|
}
|
|
802
|
-
const
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
`);
|
|
809
|
-
try {
|
|
810
|
-
const qrcode = await new Promise((resolve, reject) => {
|
|
811
|
-
QRcode.toString(signinUrl, { type: "terminal", small: true }, (err, data) => {
|
|
812
|
-
if (err)
|
|
813
|
-
reject(err);
|
|
814
|
-
resolve(data);
|
|
815
|
-
});
|
|
816
|
-
});
|
|
817
|
-
Logger.rawLog(qrcode);
|
|
818
|
-
await openBrowser(signinUrl);
|
|
819
|
-
Logger.rawLog(chalk2.dim("Opening browser..."));
|
|
820
|
-
} catch {
|
|
821
|
-
Logger.rawLog(chalk2.yellow("Could not open browser. Please visit the URL manually."));
|
|
936
|
+
const self = await new RemoteLogin(cloudApi).signIn();
|
|
937
|
+
Logger2.rawLog(chalk3.green(`\r\u2713 Authentication successful!`));
|
|
938
|
+
if (!self) {
|
|
939
|
+
Logger2.rawLog(chalk3.yellow(`The session is saved; run akan login again to check which account it signed in.
|
|
940
|
+
`));
|
|
941
|
+
return true;
|
|
822
942
|
}
|
|
823
|
-
|
|
824
|
-
const MAX_RETRY = 300;
|
|
825
|
-
for (let i = 0;i < MAX_RETRY; i++) {
|
|
826
|
-
const accessToken = await cloudApi.getRemoteAuthToken(remoteId);
|
|
827
|
-
const self = await cloudApi.getRemoteSelf();
|
|
828
|
-
if (accessToken && self) {
|
|
829
|
-
await GlobalConfig.setHostConfig({ host: cloudApi.host, auth: { accessToken, self } });
|
|
830
|
-
Logger.rawLog(chalk2.green(`\r\u2713 Authentication successful!`));
|
|
831
|
-
Logger.rawLog(chalk2.green.bold(`
|
|
943
|
+
Logger2.rawLog(chalk3.green.bold(`
|
|
832
944
|
\u2728 Welcome aboard, ${self.nickname ?? "anonymous"}!`));
|
|
833
|
-
|
|
945
|
+
Logger2.rawLog(chalk3.dim(`You're now ready to use Akan CLI!
|
|
834
946
|
`));
|
|
835
|
-
|
|
836
|
-
}
|
|
837
|
-
await sleep(2000);
|
|
838
|
-
}
|
|
839
|
-
throw new Error(chalk2.red("\u2716 Authentication timed out after 10 minutes. Please try again."));
|
|
947
|
+
return true;
|
|
840
948
|
}
|
|
841
949
|
async logout(host) {
|
|
842
950
|
const config = await GlobalConfig.getHostConfig(host);
|
|
843
|
-
if (config.auth?.self) {
|
|
951
|
+
if (config.auth?.self || config.auth?.accessToken) {
|
|
844
952
|
await GlobalConfig.setHostConfig(getDefaultHostConfig(config.host));
|
|
845
|
-
|
|
846
|
-
\uD83D\uDC4B Goodbye, ${config.auth.self
|
|
847
|
-
|
|
953
|
+
Logger2.rawLog(chalk3.magenta.bold(`
|
|
954
|
+
\uD83D\uDC4B Goodbye, ${config.auth.self?.nickname ?? "anonymous"}!`));
|
|
955
|
+
Logger2.rawLog(chalk3.dim(`\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
|
|
848
956
|
`));
|
|
849
|
-
|
|
850
|
-
|
|
957
|
+
Logger2.rawLog(chalk3.cyan("You have been successfully logged out."));
|
|
958
|
+
Logger2.rawLog(chalk3.dim(`Thank you for using Akan CLI. Come back soon! \uD83C\uDF1F
|
|
851
959
|
`));
|
|
852
960
|
} else {
|
|
853
|
-
|
|
961
|
+
Logger2.rawLog(chalk3.yellow.bold(`
|
|
854
962
|
\u26A0\uFE0F No active session found`));
|
|
855
|
-
|
|
963
|
+
Logger2.rawLog(chalk3.dim(`You were not logged in to begin with
|
|
856
964
|
`));
|
|
857
965
|
}
|
|
858
966
|
}
|
|
@@ -862,24 +970,24 @@ ${chalk2.green("\u27A4")} Authentication Required`));
|
|
|
862
970
|
targets.windows = await this.#askWindowsTestTarget();
|
|
863
971
|
await GlobalConfig.setTestTargets({ windows: targets.windows });
|
|
864
972
|
}
|
|
865
|
-
|
|
973
|
+
Logger2.info(`Testing ${pkgs.join(", ")} on ${platforms.join(", ")} in the background...`);
|
|
866
974
|
return await PlatformTestRun.start({
|
|
867
975
|
workspaceRoot: workspace.workspaceRoot,
|
|
868
976
|
platforms,
|
|
869
977
|
pkgs,
|
|
870
978
|
targets,
|
|
871
|
-
onProgress: (message) =>
|
|
979
|
+
onProgress: (message) => Logger2.info(message)
|
|
872
980
|
});
|
|
873
981
|
}
|
|
874
982
|
async settlePlatformTests(run, { interactive, recordStreaks, checkDrift }) {
|
|
875
983
|
const results = await run.results();
|
|
876
|
-
|
|
984
|
+
Logger2.rawLog(`
|
|
877
985
|
${run.format(results)}
|
|
878
986
|
`);
|
|
879
987
|
if (recordStreaks) {
|
|
880
988
|
const streak = await PlatformTestRun.recordStreaks(results);
|
|
881
989
|
if (streak?.promoted)
|
|
882
|
-
|
|
990
|
+
Logger2.info(`${streak.platform} passed ${streak.greenStreak} deploys in a row and now gates every deploy`);
|
|
883
991
|
}
|
|
884
992
|
const { blocking, warning } = PlatformTestRun.verdict(results);
|
|
885
993
|
const unreachable = blocking.filter((result) => result.infraError && !result.packages.length);
|
|
@@ -914,7 +1022,7 @@ ${run.format(results)}
|
|
|
914
1022
|
assertPromptable("No Windows test target is configured", {
|
|
915
1023
|
remedy: "run it once in a terminal, which saves the target to ~/.akan/config.json"
|
|
916
1024
|
});
|
|
917
|
-
|
|
1025
|
+
Logger2.info("No Windows test target is configured yet; it is saved to ~/.akan/config.json once entered.");
|
|
918
1026
|
const required = (value) => !!value.trim();
|
|
919
1027
|
const host = await this.#ask("Windows host (ip or name): ", required);
|
|
920
1028
|
const user = await this.#ask("SSH user: ", required);
|
|
@@ -944,8 +1052,8 @@ ${run.format(results)}
|
|
|
944
1052
|
const latestPublishedVersion = await getLatestPackageVersion("akanjs", tag, registry).catch(() => null);
|
|
945
1053
|
const latestPatch = latestPublishedVersion?.startsWith(targetVersionPrefix) ? parseInt(latestPublishedVersion.split(".").at(-1) ?? "-1") : -1;
|
|
946
1054
|
const nextVersion = `${targetVersionPrefix}.${latestPatch + 1}`;
|
|
947
|
-
|
|
948
|
-
|
|
1055
|
+
Logger2.info(`Latest published version of akanjs: ${latestPublishedVersion ?? "none"}`);
|
|
1056
|
+
Logger2.info(`Next version of akanjs: ${nextVersion}`);
|
|
949
1057
|
for (const library of akanPkgs) {
|
|
950
1058
|
const packageJson = await workspace.readJson(`pkgs/${library}/package.json`);
|
|
951
1059
|
const newPackageJson = this.#normalizeAkanPackageJson(packageJson, library, nextVersion);
|
|
@@ -959,24 +1067,24 @@ ${run.format(results)}
|
|
|
959
1067
|
remedy: "run it in a terminal"
|
|
960
1068
|
});
|
|
961
1069
|
if (confirmPublish && !await confirm({ message: "Are you sure you want to deploy the libraries?" })) {
|
|
962
|
-
|
|
1070
|
+
Logger2.error("Deployment cancelled");
|
|
963
1071
|
return;
|
|
964
1072
|
}
|
|
965
1073
|
if (!registry) {
|
|
966
|
-
|
|
1074
|
+
Logger2.info("Logging in to npm...");
|
|
967
1075
|
await workspace.spawn("npm", ["login"], { stdio: "inherit" });
|
|
968
|
-
|
|
1076
|
+
Logger2.info("Logged in to npm");
|
|
969
1077
|
}
|
|
970
1078
|
for (const library of akanPkgs) {
|
|
971
|
-
|
|
1079
|
+
Logger2.info(`Publishing ${library}@${nextVersion} to ${registry ?? "npm"}...`);
|
|
972
1080
|
await workspace.spawn("npm", ["publish", "--tag", tag, ...this.#getRegistryArgs(registry), ...this.#getLocalRegistryAuthArgs(registry)], {
|
|
973
1081
|
cwd: path7.join(workspace.workspaceRoot, "dist/pkgs", library),
|
|
974
1082
|
env: this.#getRegistryEnv(registry),
|
|
975
1083
|
stdio: "inherit"
|
|
976
1084
|
});
|
|
977
|
-
|
|
1085
|
+
Logger2.info(`${library}@${nextVersion} is published to ${registry ?? "npm"}`);
|
|
978
1086
|
}
|
|
979
|
-
|
|
1087
|
+
Logger2.info(`All libraries are published to ${registry ?? "npm"}`);
|
|
980
1088
|
}
|
|
981
1089
|
async update(workspace, tag = "latest", { registryUrl } = {}) {
|
|
982
1090
|
const registry = registryUrl ? getNpmRegistryUrl(registryUrl) : undefined;
|
|
@@ -996,7 +1104,7 @@ ${run.format(results)}
|
|
|
996
1104
|
const rootPackageJson = await workspace.getPackageJson();
|
|
997
1105
|
if (!rootPackageJson.dependencies)
|
|
998
1106
|
throw new Error("No dependencies found in package.json");
|
|
999
|
-
for (const name of ["akanjs", "@akanjs/devkit"]) {
|
|
1107
|
+
for (const name of ["akanjs", "@akanjs/devkit", "@akanjs/cli"]) {
|
|
1000
1108
|
if (rootPackageJson.dependencies[name])
|
|
1001
1109
|
rootPackageJson.dependencies[name] = latestPublishedVersion;
|
|
1002
1110
|
if (rootPackageJson.devDependencies?.[name])
|
|
@@ -1043,7 +1151,7 @@ ${run.format(results)}
|
|
|
1043
1151
|
await workspace.mkdir("local");
|
|
1044
1152
|
await workspace.remove(envArchivePath);
|
|
1045
1153
|
try {
|
|
1046
|
-
|
|
1154
|
+
Logger2.info(`Downloading env archive from remote server "${remoteServer.name}"...`);
|
|
1047
1155
|
await workspace.spawn("scp", this.#getScpArgs(remoteServer.config, remoteTarget, envArchivePath), {
|
|
1048
1156
|
cwd: workspace.workspaceRoot,
|
|
1049
1157
|
stdio: "inherit"
|
|
@@ -1064,7 +1172,7 @@ ${run.format(results)}
|
|
|
1064
1172
|
cwd: workspace.workspaceRoot,
|
|
1065
1173
|
stdio: "inherit"
|
|
1066
1174
|
});
|
|
1067
|
-
|
|
1175
|
+
Logger2.info(`Uploading env archive to remote server "${remoteServer.name}"...`);
|
|
1068
1176
|
await workspace.spawn("scp", this.#getScpArgs(remoteServer.config, filePath, remoteTarget), {
|
|
1069
1177
|
cwd: workspace.workspaceRoot,
|
|
1070
1178
|
stdio: "inherit"
|
|
@@ -1091,7 +1199,7 @@ ${run.format(results)}
|
|
|
1091
1199
|
if (envFilePaths.length === 0)
|
|
1092
1200
|
throw new Error(scope ? `No environment files found to archive for ${appNames.join(", ") || "(no apps)"}` : "No environment files found to archive");
|
|
1093
1201
|
await workspace.spawn("tar", ["-cf", archivePath, ...envFilePaths], { cwd: workspace.workspaceRoot });
|
|
1094
|
-
|
|
1202
|
+
Logger2.info(`Archived ${envFilePaths.length} environment files to ${archivePath}`);
|
|
1095
1203
|
return { files: envFilePaths, path: archivePath };
|
|
1096
1204
|
}
|
|
1097
1205
|
async#gatherCustomSecretFiles(workspace, appNames) {
|
|
@@ -1140,6 +1248,41 @@ ${run.format(results)}
|
|
|
1140
1248
|
async pushUpdate(cloudApi, devProjectId, pack, options) {
|
|
1141
1249
|
return await new CloudUpdates(cloudApi, devProjectId).push(pack, options);
|
|
1142
1250
|
}
|
|
1251
|
+
async readRelease(app, {
|
|
1252
|
+
platform,
|
|
1253
|
+
arch,
|
|
1254
|
+
target,
|
|
1255
|
+
env,
|
|
1256
|
+
channel
|
|
1257
|
+
}) {
|
|
1258
|
+
const targets = await resolveMobileTargets(app, target ?? undefined);
|
|
1259
|
+
const [mobileTarget] = targets;
|
|
1260
|
+
if (!mobileTarget || targets.length > 1)
|
|
1261
|
+
throw new Error("push-update uploads one native target's release at a time; pass --target <name>.");
|
|
1262
|
+
const { release, url, exeName } = await new NativeApp(app, mobileTarget, env).publishedRelease(platform, {
|
|
1263
|
+
arch,
|
|
1264
|
+
channel
|
|
1265
|
+
});
|
|
1266
|
+
const { signer, unread } = await release.signer({ exeName });
|
|
1267
|
+
if (unread)
|
|
1268
|
+
app.logger.warn(`release.json names no signer: ${unread}.`);
|
|
1269
|
+
return { release, url, signer, target: mobileTarget.name };
|
|
1270
|
+
}
|
|
1271
|
+
async pushRelease(cloudApi, devProjectId, app, {
|
|
1272
|
+
release,
|
|
1273
|
+
url,
|
|
1274
|
+
signer,
|
|
1275
|
+
target,
|
|
1276
|
+
notes
|
|
1277
|
+
}) {
|
|
1278
|
+
return await new CloudUpdates(cloudApi, devProjectId).pushRelease(release, {
|
|
1279
|
+
appName: app.name,
|
|
1280
|
+
target,
|
|
1281
|
+
notes,
|
|
1282
|
+
signer,
|
|
1283
|
+
url
|
|
1284
|
+
});
|
|
1285
|
+
}
|
|
1143
1286
|
async registerBinary(cloudApi, devProjectId, app, pack, options) {
|
|
1144
1287
|
return await new CloudUpdates(cloudApi, devProjectId).registerBinary(app, pack, options);
|
|
1145
1288
|
}
|
|
@@ -1154,7 +1297,7 @@ ${run.format(results)}
|
|
|
1154
1297
|
if (nextContent === existing)
|
|
1155
1298
|
return;
|
|
1156
1299
|
await workspace.writeFile(".gitignore", nextContent);
|
|
1157
|
-
|
|
1300
|
+
Logger2.info(uniquePatterns.length ? `Synced ${uniquePatterns.length} secret pattern(s) from akan.config.ts to .gitignore` : "Removed managed secret patterns from .gitignore");
|
|
1158
1301
|
}
|
|
1159
1302
|
#applySecretGitignoreBlock(content, patterns) {
|
|
1160
1303
|
const beginMarker = "# akan:secrets (managed by akan.config.ts \u2014 do not edit)";
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import {
|
|
3
3
|
script
|
|
4
|
-
} from "./index-
|
|
4
|
+
} from "./index-3wypz6xj.js";
|
|
5
5
|
import {
|
|
6
6
|
AppExecutor,
|
|
7
7
|
LibExecutor,
|
|
8
8
|
ModuleExecutor
|
|
9
|
-
} from "./index-
|
|
9
|
+
} from "./index-wcej7g4z.js";
|
|
10
10
|
import {
|
|
11
11
|
workflowStatus,
|
|
12
12
|
compactDiagnostics,
|
|
@@ -41,10 +41,10 @@ import {
|
|
|
41
41
|
hasSignalFactoryEntry,
|
|
42
42
|
insertSignalFactoryEntry,
|
|
43
43
|
addFieldUiPolicyForType
|
|
44
|
-
} from "./index-
|
|
44
|
+
} from "./index-xjf5j657.js";
|
|
45
45
|
import {
|
|
46
46
|
ModuleScript
|
|
47
|
-
} from "./index-
|
|
47
|
+
} from "./index-hmt54t45.js";
|
|
48
48
|
|
|
49
49
|
// pkgs/@akanjs/cli/primitive/primitive.script.ts
|
|
50
50
|
import { capitalize, lowerlize } from "akanjs/common";
|
|
@@ -41,38 +41,39 @@ import {
|
|
|
41
41
|
script,
|
|
42
42
|
markCliErrorPrinted,
|
|
43
43
|
assertPromptable
|
|
44
|
-
} from "./index-
|
|
44
|
+
} from "./index-3wypz6xj.js";
|
|
45
45
|
import {
|
|
46
46
|
AppInfo,
|
|
47
47
|
CommandExecutionError,
|
|
48
48
|
WorkspaceExecutor,
|
|
49
|
+
SysExecutor,
|
|
49
50
|
AppExecutor,
|
|
50
51
|
LibExecutor,
|
|
51
52
|
PkgExecutor
|
|
52
|
-
} from "./index-
|
|
53
|
+
} from "./index-wcej7g4z.js";
|
|
53
54
|
import {
|
|
54
|
-
|
|
55
|
-
UpdateUploader
|
|
56
|
-
|
|
55
|
+
UpdatePackFolder,
|
|
56
|
+
UpdateUploader,
|
|
57
|
+
NativePublicEnv,
|
|
58
|
+
NativeApp
|
|
59
|
+
} from "./index-bt438yxm.js";
|
|
60
|
+
import {
|
|
61
|
+
DesktopServerStage
|
|
62
|
+
} from "./index-js6geqjn.js";
|
|
57
63
|
import {
|
|
58
64
|
resolveMobileTargets,
|
|
59
65
|
resolveAppId
|
|
60
66
|
} from "./index-m9jj544v.js";
|
|
61
|
-
import {
|
|
62
|
-
NativePublicEnv,
|
|
63
|
-
UpdatePackFolder,
|
|
64
|
-
NativeApp
|
|
65
|
-
} from "./index-z9xepn8t.js";
|
|
66
67
|
import {
|
|
67
68
|
LibraryScript
|
|
68
|
-
} from "./index-
|
|
69
|
+
} from "./index-2xcc2ax5.js";
|
|
69
70
|
import {
|
|
70
71
|
stripAnsi
|
|
71
72
|
} from "./index-7md2g9vw.js";
|
|
72
73
|
import {
|
|
73
74
|
SlicePlanner,
|
|
74
75
|
formatSlicePlan
|
|
75
|
-
} from "./index-
|
|
76
|
+
} from "./index-pcwzkdqb.js";
|
|
76
77
|
import {
|
|
77
78
|
openBrowser
|
|
78
79
|
} from "./index-9dp031by.js";
|
|
@@ -82,7 +83,7 @@ import { confirm } from "@inquirer/prompts";
|
|
|
82
83
|
import { Logger as Logger6, toError as toError2 } from "akanjs/common";
|
|
83
84
|
|
|
84
85
|
// pkgs/@akanjs/cli/application/application.runner.ts
|
|
85
|
-
import { realpathSync } from "fs";
|
|
86
|
+
import { existsSync, realpathSync } from "fs";
|
|
86
87
|
import path5 from "path";
|
|
87
88
|
|
|
88
89
|
// pkgs/@akanjs/devkit/akanApp/akanApp.host.ts
|
|
@@ -1899,7 +1900,7 @@ ${uniqueCandidates.map((candidate) => ` - ${candidate}`).join(`
|
|
|
1899
1900
|
|
|
1900
1901
|
// pkgs/@akanjs/cli/application/application.runner.ts
|
|
1901
1902
|
import { Logger as Logger3, toError } from "akanjs/common";
|
|
1902
|
-
var loadBuildRunner = async () => (await import("./applicationBuildRunner-
|
|
1903
|
+
var loadBuildRunner = async () => (await import("./applicationBuildRunner-t2r84sz6.js")).ApplicationBuildRunner;
|
|
1903
1904
|
var loadPrompts = async () => await import("@inquirer/prompts");
|
|
1904
1905
|
|
|
1905
1906
|
class ApplicationRunner extends runner("application") {
|
|
@@ -2100,7 +2101,7 @@ if (loaded) process.exitCode = await loaded.migrations.command(loaded.server, ar
|
|
|
2100
2101
|
await new (await loadBuildRunner())(app).typecheck(options);
|
|
2101
2102
|
}
|
|
2102
2103
|
async typecheckLibrary(lib, options = {}) {
|
|
2103
|
-
const { ProjectTypecheck } = await import("./projectTypecheck-
|
|
2104
|
+
const { ProjectTypecheck } = await import("./projectTypecheck-2ztky9cf.js");
|
|
2104
2105
|
const root = lib.workspace.workspaceRoot;
|
|
2105
2106
|
await new ProjectTypecheck(lib.cwdPath, root, { ...process.env, AKAN_WORKSPACE_ROOT: root }).run([
|
|
2106
2107
|
"../../server.ts",
|
|
@@ -2111,7 +2112,20 @@ if (loaded) process.exitCode = await loaded.migrations.command(loaded.server, ar
|
|
|
2111
2112
|
"../../../../pkgs/akanjs/*/types/**/*.d.ts"
|
|
2112
2113
|
], options);
|
|
2113
2114
|
}
|
|
2114
|
-
|
|
2115
|
+
resolveTestPaths(exec, files) {
|
|
2116
|
+
const root = exec instanceof SysExecutor || exec instanceof PkgExecutor ? exec.workspace.workspaceRoot : process.cwd();
|
|
2117
|
+
const target = path5.relative(root, exec.cwdPath).split(path5.sep).join("/");
|
|
2118
|
+
const isInside = (relative) => relative !== ".." && !relative.startsWith(`..${path5.sep}`) && !path5.isAbsolute(relative);
|
|
2119
|
+
return files.map((file) => {
|
|
2120
|
+
const candidates = path5.isAbsolute(file) ? [file] : [path5.resolve(exec.cwdPath, file), path5.resolve(root, file)];
|
|
2121
|
+
const existing = candidates.filter((candidate) => existsSync(candidate)).map((candidate) => path5.relative(exec.cwdPath, candidate));
|
|
2122
|
+
const found = existing.find(isInside);
|
|
2123
|
+
if (found === undefined)
|
|
2124
|
+
throw new Error(existing.length ? `${file} is outside ${target}: akan test ${exec.name} runs its own tests only` : `${file} names no file or folder in ${target}`);
|
|
2125
|
+
return `./${found.split(path5.sep).join("/")}`;
|
|
2126
|
+
});
|
|
2127
|
+
}
|
|
2128
|
+
async test(exec, testPaths = []) {
|
|
2115
2129
|
const isSignalTarget = exec instanceof AppExecutor || exec instanceof LibExecutor;
|
|
2116
2130
|
const preloadPath = isSignalTarget ? await resolveSignalTestPreloadPath(exec) : null;
|
|
2117
2131
|
const env = isSignalTarget ? {
|
|
@@ -2121,7 +2135,7 @@ if (loaded) process.exitCode = await loaded.migrations.command(loaded.server, ar
|
|
|
2121
2135
|
AKAN_TEST_LIBS: exec.getScanInfo({ allowEmpty: true })?.getLibs().join(",") ?? "",
|
|
2122
2136
|
AKAN_RUNTIME_DIR: path5.join(exec.workspace.workspaceRoot, "local", `${exec.type}s`, exec.name, "runtime")
|
|
2123
2137
|
} : {};
|
|
2124
|
-
const args =
|
|
2138
|
+
const args = ["test", "--isolate", ...preloadPath ? ["--preload", preloadPath] : [], ...testPaths];
|
|
2125
2139
|
await exec.spawn("bun", args, {
|
|
2126
2140
|
...isSignalTarget ? { env: { ...process.env, ...env } } : {},
|
|
2127
2141
|
stdio: "inherit"
|
|
@@ -2295,6 +2309,8 @@ if (loaded) process.exitCode = await loaded.migrations.command(loaded.server, ar
|
|
|
2295
2309
|
const { publicKey, keyId, keyPath, created } = await new NativeApp(app, mobileTarget).updateKeygen(nativePlatform);
|
|
2296
2310
|
app.log(`${appId}: ${created ? "made" : "read"} ${keyPath}${created ? " (keep it private and backed up: without it, installed apps take no more updates)" : ""}`);
|
|
2297
2311
|
app.log(` native: { updates: { url: "https://\u2026/${app.name}", publicKeys: [${JSON.stringify(publicKey)}] } }`);
|
|
2312
|
+
if (platform === "desktop")
|
|
2313
|
+
app.log(" url: hosted on Akan Cloud, register this public key as an external key on the release screen and use the URL it gives; self-hosted, the public address you upload the release to");
|
|
2298
2314
|
app.log(` keyId ${keyId}: what publish-update --revoke and updates.revokedKeys name this key by`);
|
|
2299
2315
|
const { publicKey: one, publicKeys } = mobileTarget.config.updates ?? {};
|
|
2300
2316
|
const declared = publicKeys ?? (one ? [one] : null);
|
|
@@ -3437,14 +3453,15 @@ class ApplicationScript extends script("application", [ApplicationRunner, Librar
|
|
|
3437
3453
|
throw error;
|
|
3438
3454
|
}
|
|
3439
3455
|
}
|
|
3440
|
-
async test(exec, { write = true } = {}) {
|
|
3456
|
+
async test(exec, { write = true, files = [] } = {}) {
|
|
3457
|
+
const testPaths = this.applicationRunner.resolveTestPaths(exec, files);
|
|
3441
3458
|
if (exec instanceof LibExecutor) {
|
|
3442
3459
|
if (write)
|
|
3443
3460
|
await this.libraryScript.syncLibrary(exec);
|
|
3444
3461
|
else
|
|
3445
3462
|
await exec.scan({ write: false });
|
|
3446
3463
|
exec.spinning(`Preparing ${exec.name}...`).succeed(`${exec.name} prepared`);
|
|
3447
|
-
await this.applicationRunner.test(exec);
|
|
3464
|
+
await this.applicationRunner.test(exec, testPaths);
|
|
3448
3465
|
return;
|
|
3449
3466
|
}
|
|
3450
3467
|
const spinner = exec.spinning(`Preparing ${exec.name}...`);
|
|
@@ -3458,7 +3475,7 @@ class ApplicationScript extends script("application", [ApplicationRunner, Librar
|
|
|
3458
3475
|
spinner.fail(`${exec.name} prepare failed`);
|
|
3459
3476
|
throw error;
|
|
3460
3477
|
}
|
|
3461
|
-
await this.applicationRunner.test(exec);
|
|
3478
|
+
await this.applicationRunner.test(exec, testPaths);
|
|
3462
3479
|
}
|
|
3463
3480
|
async start(apps, {
|
|
3464
3481
|
open = false,
|
|
@@ -3691,7 +3708,7 @@ class ApplicationScript extends script("application", [ApplicationRunner, Librar
|
|
|
3691
3708
|
await Promise.all(shares.map(async (share) => await share.close()));
|
|
3692
3709
|
}, "Abandoning the tunnel release; the shares expire on their own.");
|
|
3693
3710
|
await Promise.all(apps.map(async (app) => {
|
|
3694
|
-
const { TunnelShare } = await import("./TunnelShare-
|
|
3711
|
+
const { TunnelShare } = await import("./TunnelShare-qkm8zp03.js");
|
|
3695
3712
|
const share = await TunnelShare.open(app, { workspace: app.workspace });
|
|
3696
3713
|
shares.push(share);
|
|
3697
3714
|
urls.set(app.name, share.url);
|