@akanjs/cli 2.1.0-rc.11 → 2.1.0-rc.12
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/index.js +259 -54
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -10286,6 +10286,7 @@ class PackageScript extends script("package", [PackageRunner]) {
|
|
|
10286
10286
|
}
|
|
10287
10287
|
|
|
10288
10288
|
// pkgs/@akanjs/cli/cloud/cloud.runner.ts
|
|
10289
|
+
import path38 from "path";
|
|
10289
10290
|
import { confirm as confirm3 } from "@inquirer/prompts";
|
|
10290
10291
|
import { Logger as Logger15, sleep } from "akanjs/common";
|
|
10291
10292
|
import chalk7 from "chalk";
|
|
@@ -10309,6 +10310,24 @@ async function getLatestPackageVersion(packageName, tag = "latest", registryUrl)
|
|
|
10309
10310
|
|
|
10310
10311
|
// pkgs/@akanjs/cli/cloud/cloud.runner.ts
|
|
10311
10312
|
class CloudRunner extends runner("cloud") {
|
|
10313
|
+
#akanFrameworkPackages = new Set(["akanjs", "@akanjs/devkit", "@akanjs/cli", "create-akan-workspace"]);
|
|
10314
|
+
#getRegistryArgs(registryUrl) {
|
|
10315
|
+
return registryUrl ? ["--registry", getNpmRegistryUrl(registryUrl)] : [];
|
|
10316
|
+
}
|
|
10317
|
+
#getLocalRegistryAuthArgs(registryUrl) {
|
|
10318
|
+
if (!registryUrl)
|
|
10319
|
+
return [];
|
|
10320
|
+
const { host, pathname } = new URL(getNpmRegistryUrl(registryUrl));
|
|
10321
|
+
const registryPath = pathname === "/" ? "/" : `${pathname.replace(/\/+$/, "")}/`;
|
|
10322
|
+
return [`--//${host}${registryPath}:_authToken=akan-local-registry`];
|
|
10323
|
+
}
|
|
10324
|
+
#getRegistryEnv(registryUrl) {
|
|
10325
|
+
return registryUrl ? {
|
|
10326
|
+
...process.env,
|
|
10327
|
+
AKAN_NPM_REGISTRY: getNpmRegistryUrl(registryUrl),
|
|
10328
|
+
NPM_CONFIG_REGISTRY: getNpmRegistryUrl(registryUrl)
|
|
10329
|
+
} : process.env;
|
|
10330
|
+
}
|
|
10312
10331
|
async login() {
|
|
10313
10332
|
const config = await getHostConfig();
|
|
10314
10333
|
const self = config.auth ? await getSelf(config.auth.token) : null;
|
|
@@ -10387,15 +10406,16 @@ ${chalk7.green("\u27A4")} Authentication Required`));
|
|
|
10387
10406
|
const pkgs = await workspace.getPkgs();
|
|
10388
10407
|
return pkgs.filter((pkg) => pkg === "akanjs" || pkg === "create-akan-workspace" || pkg.startsWith("@akanjs/"));
|
|
10389
10408
|
}
|
|
10390
|
-
async deployAkan(workspace, akanPkgs) {
|
|
10409
|
+
async deployAkan(workspace, akanPkgs, { registryUrl, confirmPublish = true, tag: distTag } = {}) {
|
|
10410
|
+
const registry = registryUrl ? getNpmRegistryUrl(registryUrl) : undefined;
|
|
10391
10411
|
const akanPackageJson2 = await workspace.readJson("pkgs/akanjs/package.json");
|
|
10392
10412
|
const [majorVersion, minorVersion, patchVersion, devPatchVersion] = akanPackageJson2.version.split(".");
|
|
10393
10413
|
const isOfficialRelease = !devPatchVersion;
|
|
10394
10414
|
const targetVersionPrefix = isOfficialRelease ? `${majorVersion}.${minorVersion}` : `${majorVersion}.${minorVersion}.${patchVersion}`;
|
|
10395
|
-
const tag = isOfficialRelease ? "latest" : patchVersion.split("-").at(1) ?? "dev";
|
|
10415
|
+
const tag = distTag ?? (isOfficialRelease ? "latest" : patchVersion.split("-").at(1) ?? "dev");
|
|
10396
10416
|
const getNextVersion = async (prefix, tag2) => {
|
|
10397
10417
|
try {
|
|
10398
|
-
const latestPublishedVersion2 = await getLatestPackageVersion("akanjs", tag2);
|
|
10418
|
+
const latestPublishedVersion2 = await getLatestPackageVersion("akanjs", tag2, registry);
|
|
10399
10419
|
const latestPatch = latestPublishedVersion2.startsWith(prefix) ? parseInt(latestPublishedVersion2.split(".").at(-1) ?? "-1") : -1;
|
|
10400
10420
|
const nextVersion2 = `${prefix}.${latestPatch + 1}`;
|
|
10401
10421
|
return { nextVersion: nextVersion2, latestPublishedVersion: latestPublishedVersion2 };
|
|
@@ -10408,37 +10428,46 @@ ${chalk7.green("\u27A4")} Authentication Required`));
|
|
|
10408
10428
|
Logger15.info(`Next version of akanjs: ${nextVersion}`);
|
|
10409
10429
|
for (const library of akanPkgs) {
|
|
10410
10430
|
const packageJson = await workspace.readJson(`pkgs/${library}/package.json`);
|
|
10411
|
-
const newPackageJsonStr = JSON.stringify(
|
|
10431
|
+
const newPackageJsonStr = JSON.stringify(this.#normalizeAkanPackageJson(packageJson, library, nextVersion), null, 2);
|
|
10412
10432
|
await workspace.writeFile(`pkgs/${library}/package.json`, newPackageJsonStr);
|
|
10413
10433
|
const distPackageJson = await workspace.readJson(`dist/pkgs/${library}/package.json`);
|
|
10414
|
-
const newDistPackageJson =
|
|
10434
|
+
const newDistPackageJson = this.#normalizeAkanPackageJson(distPackageJson, library, nextVersion);
|
|
10415
10435
|
await workspace.writeJson(`dist/pkgs/${library}/package.json`, newDistPackageJson);
|
|
10416
10436
|
}
|
|
10417
|
-
|
|
10418
|
-
|
|
10419
|
-
|
|
10420
|
-
|
|
10421
|
-
|
|
10422
|
-
|
|
10437
|
+
if (confirmPublish) {
|
|
10438
|
+
const isDeployConfirmed = await confirm3({
|
|
10439
|
+
message: "Are you sure you want to deploy the libraries?"
|
|
10440
|
+
});
|
|
10441
|
+
if (!isDeployConfirmed) {
|
|
10442
|
+
Logger15.error("Deployment cancelled");
|
|
10443
|
+
return;
|
|
10444
|
+
}
|
|
10423
10445
|
}
|
|
10424
10446
|
await Promise.all(akanPkgs.map(async (library) => {
|
|
10425
|
-
Logger15.info(`Publishing ${library}@${nextVersion} to npm...`);
|
|
10426
|
-
await workspace.
|
|
10427
|
-
|
|
10447
|
+
Logger15.info(`Publishing ${library}@${nextVersion} to ${registry ?? "npm"}...`);
|
|
10448
|
+
await workspace.spawn("npm", ["publish", "--tag", tag, ...this.#getRegistryArgs(registry), ...this.#getLocalRegistryAuthArgs(registry)], {
|
|
10449
|
+
cwd: path38.join(workspace.workspaceRoot, "dist/pkgs", library),
|
|
10450
|
+
env: this.#getRegistryEnv(registry),
|
|
10451
|
+
stdio: "inherit"
|
|
10452
|
+
});
|
|
10453
|
+
Logger15.info(`${library}@${nextVersion} is published to ${registry ?? "npm"}`);
|
|
10428
10454
|
}));
|
|
10429
|
-
Logger15.info(
|
|
10455
|
+
Logger15.info(`All libraries are published to ${registry ?? "npm"}`);
|
|
10430
10456
|
}
|
|
10431
|
-
async update(workspace, tag = "latest") {
|
|
10457
|
+
async update(workspace, tag = "latest", { registryUrl } = {}) {
|
|
10458
|
+
const registry = registryUrl ? getNpmRegistryUrl(registryUrl) : undefined;
|
|
10459
|
+
const registryArgs = this.#getRegistryArgs(registry);
|
|
10460
|
+
const env = this.#getRegistryEnv(registry);
|
|
10432
10461
|
if (!await workspace.exists("package.json"))
|
|
10433
|
-
await workspace.spawn("bun", ["update", "-g", "akanjs", "--latest", `--tag=${tag}
|
|
10462
|
+
await workspace.spawn("bun", ["update", "-g", "akanjs", "--latest", `--tag=${tag}`, ...registryArgs], { env });
|
|
10434
10463
|
else
|
|
10435
10464
|
await Promise.all([
|
|
10436
|
-
workspace.spawn("bun", ["update", "-g", "akanjs", "--latest", `--tag=${tag}
|
|
10437
|
-
this.#updateAkanPkgs(workspace, tag)
|
|
10465
|
+
workspace.spawn("bun", ["update", "-g", "akanjs", "--latest", `--tag=${tag}`, ...registryArgs], { env }),
|
|
10466
|
+
this.#updateAkanPkgs(workspace, tag, registry)
|
|
10438
10467
|
]);
|
|
10439
10468
|
}
|
|
10440
|
-
async#updateAkanPkgs(workspace, tag = "latest") {
|
|
10441
|
-
const latestPublishedVersion = await getLatestPackageVersion("akanjs", tag);
|
|
10469
|
+
async#updateAkanPkgs(workspace, tag = "latest", registryUrl) {
|
|
10470
|
+
const latestPublishedVersion = await getLatestPackageVersion("akanjs", tag, registryUrl);
|
|
10442
10471
|
const rootPackageJson = await workspace.getPackageJson();
|
|
10443
10472
|
if (!rootPackageJson.dependencies)
|
|
10444
10473
|
throw new Error("No dependencies found in package.json");
|
|
@@ -10450,8 +10479,23 @@ ${chalk7.green("\u27A4")} Authentication Required`));
|
|
|
10450
10479
|
rootPackageJson.dependencies["@akanjs/devkit"] = latestPublishedVersion;
|
|
10451
10480
|
if (rootPackageJson.devDependencies?.["@akanjs/devkit"])
|
|
10452
10481
|
rootPackageJson.devDependencies["@akanjs/devkit"] = latestPublishedVersion;
|
|
10453
|
-
workspace.setPackageJson(rootPackageJson);
|
|
10454
|
-
await workspace.spawn("bun", ["install"]
|
|
10482
|
+
await workspace.setPackageJson(rootPackageJson);
|
|
10483
|
+
await workspace.spawn("bun", ["install", ...this.#getRegistryArgs(registryUrl)], {
|
|
10484
|
+
env: this.#getRegistryEnv(registryUrl)
|
|
10485
|
+
});
|
|
10486
|
+
}
|
|
10487
|
+
#normalizeAkanPackageJson(packageJson, packageName, version) {
|
|
10488
|
+
const normalized = { ...packageJson, version };
|
|
10489
|
+
for (const field of ["dependencies", "devDependencies", "peerDependencies", "optionalDependencies"]) {
|
|
10490
|
+
const dependencies = normalized[field];
|
|
10491
|
+
if (!dependencies)
|
|
10492
|
+
continue;
|
|
10493
|
+
normalized[field] = Object.fromEntries(Object.entries(dependencies).map(([dep, depVersion]) => [
|
|
10494
|
+
dep,
|
|
10495
|
+
dep !== packageName && this.#akanFrameworkPackages.has(dep) ? version : depVersion
|
|
10496
|
+
]));
|
|
10497
|
+
}
|
|
10498
|
+
return normalized;
|
|
10455
10499
|
}
|
|
10456
10500
|
}
|
|
10457
10501
|
|
|
@@ -10473,7 +10517,7 @@ class CloudScript extends script("cloud", [CloudRunner, ApplicationScript, Packa
|
|
|
10473
10517
|
const session = new AiSession("general", { workspace, isContinued: true });
|
|
10474
10518
|
await session.ask(question);
|
|
10475
10519
|
}
|
|
10476
|
-
async deployAkan(workspace, { test = true } = {}) {
|
|
10520
|
+
async deployAkan(workspace, { test = true, registryUrl } = {}) {
|
|
10477
10521
|
const akanPkgs = await this.cloudRunner.getAkanPkgs(workspace);
|
|
10478
10522
|
await this.packageScript.updateWorskpaceRootPackageJson(workspace);
|
|
10479
10523
|
const pkgs = akanPkgs.map((pkgName) => PkgExecutor.from(workspace, pkgName));
|
|
@@ -10482,11 +10526,11 @@ class CloudScript extends script("cloud", [CloudRunner, ApplicationScript, Packa
|
|
|
10482
10526
|
await this.applicationScript.test(pkg);
|
|
10483
10527
|
for (const pkg of pkgs)
|
|
10484
10528
|
await this.packageScript.buildPackage(pkg);
|
|
10485
|
-
await this.cloudRunner.deployAkan(workspace, akanPkgs);
|
|
10529
|
+
await this.cloudRunner.deployAkan(workspace, akanPkgs, { registryUrl });
|
|
10486
10530
|
}
|
|
10487
|
-
async update(workspace, tag = "latest") {
|
|
10531
|
+
async update(workspace, tag = "latest", { registryUrl } = {}) {
|
|
10488
10532
|
const spinner2 = workspace.spinning("Updating Akan.js packages and CLI...");
|
|
10489
|
-
await this.cloudRunner.update(workspace, tag);
|
|
10533
|
+
await this.cloudRunner.update(workspace, tag, { registryUrl });
|
|
10490
10534
|
spinner2.succeed("Akan.js packages and CLI updated, global version is below");
|
|
10491
10535
|
Logger16.raw("> Akan version: ");
|
|
10492
10536
|
await workspace.spawn("akan", ["--version"], { stdio: "inherit" });
|
|
@@ -10494,6 +10538,9 @@ class CloudScript extends script("cloud", [CloudRunner, ApplicationScript, Packa
|
|
|
10494
10538
|
}
|
|
10495
10539
|
|
|
10496
10540
|
// pkgs/@akanjs/cli/cloud/cloud.command.ts
|
|
10541
|
+
var localRegistryUrl = () => process.env.AKAN_NPM_REGISTRY ?? "http://127.0.0.1:4873";
|
|
10542
|
+
var resolveRegistryUrl = (registry) => registry === "local" ? localRegistryUrl() : undefined;
|
|
10543
|
+
|
|
10497
10544
|
class CloudCommand extends command("cloud", [CloudScript], ({ public: target }) => ({
|
|
10498
10545
|
login: target({ desc: "Login to Akan Cloud services" }).with(Workspace).exec(async function(workspace) {
|
|
10499
10546
|
await this.cloudScript.login(workspace);
|
|
@@ -10510,15 +10557,32 @@ class CloudCommand extends command("cloud", [CloudScript], ({ public: target })
|
|
|
10510
10557
|
ask: target({ desc: "Ask AI assistant a question about your project" }).option("question", String, { ask: "question to ask" }).with(Workspace).exec(async function(question, workspace) {
|
|
10511
10558
|
await this.cloudScript.ask(question, workspace);
|
|
10512
10559
|
}),
|
|
10513
|
-
deployAkan: target({ devOnly: true, desc: "Deploy Akan.js framework to cloud (internal use)" }).option("test", Boolean, { desc: "test the deployment", default: true }).
|
|
10514
|
-
|
|
10560
|
+
deployAkan: target({ devOnly: true, desc: "Deploy Akan.js framework to cloud (internal use)" }).option("test", Boolean, { desc: "test the deployment", default: true }).option("registry", String, {
|
|
10561
|
+
desc: "registry target for publishing Akan packages",
|
|
10562
|
+
ask: "Select a registry target",
|
|
10563
|
+
enum: [
|
|
10564
|
+
{ label: "local", value: "local" },
|
|
10565
|
+
{ label: "npm", value: "npm" }
|
|
10566
|
+
]
|
|
10567
|
+
}).with(Workspace).exec(async function(test, registry, workspace) {
|
|
10568
|
+
await this.cloudScript.deployAkan(workspace, {
|
|
10569
|
+
test,
|
|
10570
|
+
registryUrl: resolveRegistryUrl(registry)
|
|
10571
|
+
});
|
|
10515
10572
|
}),
|
|
10516
10573
|
update: target({ desc: "Update Akan.js framework to the latest version" }).with(Workspace).option("tag", String, {
|
|
10517
10574
|
desc: "tag of the update",
|
|
10518
10575
|
default: "latest",
|
|
10519
10576
|
enum: ["latest", "dev", "canary", "beta", "rc", "alpha"]
|
|
10520
|
-
}).
|
|
10521
|
-
|
|
10577
|
+
}).option("registry", String, {
|
|
10578
|
+
desc: "registry target for resolving Akan packages",
|
|
10579
|
+
ask: "Select a registry target",
|
|
10580
|
+
enum: [
|
|
10581
|
+
{ label: "npm", value: "npm" },
|
|
10582
|
+
{ label: "local", value: "local" }
|
|
10583
|
+
]
|
|
10584
|
+
}).exec(async function(workspace, tag, registry) {
|
|
10585
|
+
await this.cloudScript.update(workspace, tag, { registryUrl: resolveRegistryUrl(registry) });
|
|
10522
10586
|
})
|
|
10523
10587
|
})) {
|
|
10524
10588
|
}
|
|
@@ -10544,14 +10608,14 @@ class GuidelinePrompt extends Prompter {
|
|
|
10544
10608
|
async#getScanFilePaths(matchPattern, { avoidDirs = ["node_modules", ".next"], filterText } = {}) {
|
|
10545
10609
|
const glob = new Bun.Glob(matchPattern);
|
|
10546
10610
|
const paths = [];
|
|
10547
|
-
for await (const
|
|
10548
|
-
if (avoidDirs.some((dir) =>
|
|
10611
|
+
for await (const path39 of glob.scan({ cwd: this.workspace.workspaceRoot, absolute: true })) {
|
|
10612
|
+
if (avoidDirs.some((dir) => path39.includes(dir)))
|
|
10549
10613
|
continue;
|
|
10550
|
-
const fileContent = await FileSys.readText(
|
|
10614
|
+
const fileContent = await FileSys.readText(path39);
|
|
10551
10615
|
const textFilter = filterText ? new RegExp(filterText) : null;
|
|
10552
10616
|
if (filterText && !textFilter?.test(fileContent))
|
|
10553
10617
|
continue;
|
|
10554
|
-
paths.push(
|
|
10618
|
+
paths.push(path39);
|
|
10555
10619
|
}
|
|
10556
10620
|
return paths;
|
|
10557
10621
|
}
|
|
@@ -10846,6 +10910,147 @@ class LibraryCommand extends command("library", [LibraryScript], ({ public: targ
|
|
|
10846
10910
|
})) {
|
|
10847
10911
|
}
|
|
10848
10912
|
|
|
10913
|
+
// pkgs/@akanjs/cli/localRegistry/localRegistry.runner.ts
|
|
10914
|
+
import { mkdir as mkdir11, rm as rm5 } from "fs/promises";
|
|
10915
|
+
import path39 from "path";
|
|
10916
|
+
import { Logger as Logger17 } from "akanjs/common";
|
|
10917
|
+
var defaultLocalRegistryUrl = "http://127.0.0.1:4873";
|
|
10918
|
+
var containerName = "akan-verdaccio";
|
|
10919
|
+
var smokeRepoName = "akan-local-smoke";
|
|
10920
|
+
var smokeAppName = "demo";
|
|
10921
|
+
|
|
10922
|
+
class LocalRegistryRunner extends runner("localRegistry") {
|
|
10923
|
+
getRegistryUrl(registryUrl = process.env.AKAN_NPM_REGISTRY ?? defaultLocalRegistryUrl) {
|
|
10924
|
+
return getNpmRegistryUrl(registryUrl);
|
|
10925
|
+
}
|
|
10926
|
+
async start(workspace, { registryUrl } = {}) {
|
|
10927
|
+
const registry = this.getRegistryUrl(registryUrl);
|
|
10928
|
+
try {
|
|
10929
|
+
await workspace.spawn("docker", ["inspect", containerName]);
|
|
10930
|
+
Logger17.info(`Local registry is already running at ${registry}`);
|
|
10931
|
+
return registry;
|
|
10932
|
+
} catch {}
|
|
10933
|
+
const configPath2 = path39.join(workspace.workspaceRoot, "pkgs/@akanjs/cli/localRegistry/verdaccio.yaml");
|
|
10934
|
+
const storagePath = path39.join(workspace.workspaceRoot, ".akan/verdaccio/storage");
|
|
10935
|
+
await mkdir11(storagePath, { recursive: true });
|
|
10936
|
+
await workspace.spawn("docker", [
|
|
10937
|
+
"run",
|
|
10938
|
+
"--rm",
|
|
10939
|
+
"-d",
|
|
10940
|
+
"--name",
|
|
10941
|
+
containerName,
|
|
10942
|
+
"-p",
|
|
10943
|
+
"4873:4873",
|
|
10944
|
+
"-v",
|
|
10945
|
+
`${configPath2}:/verdaccio/conf/config.yaml:ro`,
|
|
10946
|
+
"-v",
|
|
10947
|
+
`${storagePath}:/verdaccio/storage`,
|
|
10948
|
+
"verdaccio/verdaccio:6"
|
|
10949
|
+
], { stdio: "inherit" });
|
|
10950
|
+
Logger17.info(`Local registry is running at ${registry}`);
|
|
10951
|
+
return registry;
|
|
10952
|
+
}
|
|
10953
|
+
async reset(workspace) {
|
|
10954
|
+
try {
|
|
10955
|
+
await workspace.spawn("docker", ["rm", "-f", containerName], { stdio: "inherit" });
|
|
10956
|
+
} catch {}
|
|
10957
|
+
await rm5(path39.join(workspace.workspaceRoot, ".akan/verdaccio"), { recursive: true, force: true });
|
|
10958
|
+
Logger17.info("Local registry storage has been reset");
|
|
10959
|
+
}
|
|
10960
|
+
async smoke(workspace, { registryUrl } = {}) {
|
|
10961
|
+
const registry = this.getRegistryUrl(registryUrl);
|
|
10962
|
+
const smokeRoot = path39.join(workspace.workspaceRoot, ".akan/e2e");
|
|
10963
|
+
await rm5(path39.join(smokeRoot, smokeRepoName), { recursive: true, force: true });
|
|
10964
|
+
await workspace.spawn(process.execPath, [
|
|
10965
|
+
"dist/pkgs/create-akan-workspace/index.js",
|
|
10966
|
+
smokeRepoName,
|
|
10967
|
+
"--app",
|
|
10968
|
+
smokeAppName,
|
|
10969
|
+
"--dir",
|
|
10970
|
+
".akan/e2e",
|
|
10971
|
+
"--init",
|
|
10972
|
+
"true",
|
|
10973
|
+
"--registry",
|
|
10974
|
+
registry
|
|
10975
|
+
], {
|
|
10976
|
+
env: { ...process.env, AKAN_NPM_REGISTRY: registry, NPM_CONFIG_REGISTRY: registry },
|
|
10977
|
+
stdio: "inherit"
|
|
10978
|
+
});
|
|
10979
|
+
await workspace.spawn("akan", ["build", smokeAppName], {
|
|
10980
|
+
cwd: path39.join(smokeRoot, smokeRepoName),
|
|
10981
|
+
env: { ...process.env, AKAN_NPM_REGISTRY: registry, NPM_CONFIG_REGISTRY: registry },
|
|
10982
|
+
stdio: "inherit"
|
|
10983
|
+
});
|
|
10984
|
+
Logger17.info(`Local registry smoke test completed for ${smokeRepoName}/${smokeAppName}`);
|
|
10985
|
+
}
|
|
10986
|
+
}
|
|
10987
|
+
|
|
10988
|
+
// pkgs/@akanjs/cli/localRegistry/localRegistry.script.ts
|
|
10989
|
+
class LocalRegistryScript extends script("localRegistry", [
|
|
10990
|
+
LocalRegistryRunner,
|
|
10991
|
+
CloudRunner,
|
|
10992
|
+
ApplicationScript,
|
|
10993
|
+
PackageScript
|
|
10994
|
+
]) {
|
|
10995
|
+
async start(workspace, { registryUrl } = {}) {
|
|
10996
|
+
const spinner2 = workspace.spinning("Starting local npm registry...");
|
|
10997
|
+
const registry = await this.localRegistryRunner.start(workspace, { registryUrl });
|
|
10998
|
+
spinner2.succeed(`Local npm registry is ready at ${registry}`);
|
|
10999
|
+
}
|
|
11000
|
+
async reset(workspace) {
|
|
11001
|
+
const spinner2 = workspace.spinning("Resetting local npm registry...");
|
|
11002
|
+
await this.localRegistryRunner.reset(workspace);
|
|
11003
|
+
spinner2.succeed("Local npm registry reset");
|
|
11004
|
+
}
|
|
11005
|
+
async smoke(workspace, { tag = "rc", test = true, registryUrl } = {}) {
|
|
11006
|
+
const registry = await this.localRegistryRunner.start(workspace, { registryUrl });
|
|
11007
|
+
const akanPkgs = await this.cloudRunner.getAkanPkgs(workspace);
|
|
11008
|
+
await this.#preparePackages(workspace, akanPkgs, { test });
|
|
11009
|
+
await this.cloudRunner.deployAkan(workspace, akanPkgs, {
|
|
11010
|
+
registryUrl: registry,
|
|
11011
|
+
confirmPublish: false,
|
|
11012
|
+
tag
|
|
11013
|
+
});
|
|
11014
|
+
await this.localRegistryRunner.smoke(workspace, { registryUrl: registry });
|
|
11015
|
+
}
|
|
11016
|
+
async#preparePackages(workspace, akanPkgs, { test = true } = {}) {
|
|
11017
|
+
await this.packageScript.updateWorskpaceRootPackageJson(workspace);
|
|
11018
|
+
const pkgs = akanPkgs.map((pkgName) => PkgExecutor.from(workspace, pkgName));
|
|
11019
|
+
if (test)
|
|
11020
|
+
for (const pkg of pkgs)
|
|
11021
|
+
await this.applicationScript.test(pkg);
|
|
11022
|
+
for (const pkg of pkgs)
|
|
11023
|
+
await this.packageScript.buildPackage(pkg, { showSpinner: false });
|
|
11024
|
+
}
|
|
11025
|
+
}
|
|
11026
|
+
|
|
11027
|
+
// pkgs/@akanjs/cli/localRegistry/localRegistry.command.ts
|
|
11028
|
+
class LocalRegistryCommand extends command("local-registry", [LocalRegistryScript], ({ public: target }) => ({
|
|
11029
|
+
startRegistry: target({ devOnly: true, desc: "Start the local Verdaccio npm registry" }).with(Workspace).option("registry", String, {
|
|
11030
|
+
desc: "local npm registry URL",
|
|
11031
|
+
default: process.env.AKAN_NPM_REGISTRY ?? "http://127.0.0.1:4873"
|
|
11032
|
+
}).exec(async function(workspace, registry) {
|
|
11033
|
+
await this.localRegistryScript.start(workspace, { registryUrl: registry });
|
|
11034
|
+
}),
|
|
11035
|
+
resetRegistry: target({ devOnly: true, desc: "Stop and clear the local Verdaccio npm registry" }).with(Workspace).exec(async function(workspace) {
|
|
11036
|
+
await this.localRegistryScript.reset(workspace);
|
|
11037
|
+
}),
|
|
11038
|
+
smokeRegistry: target({ devOnly: true, desc: "Publish to local registry and build a generated workspace" }).with(Workspace).option("tag", String, {
|
|
11039
|
+
flag: "g",
|
|
11040
|
+
desc: "dist-tag for local registry publish",
|
|
11041
|
+
default: "rc"
|
|
11042
|
+
}).option("test", Boolean, {
|
|
11043
|
+
desc: "run package tests before publishing",
|
|
11044
|
+
default: true
|
|
11045
|
+
}).option("registry", String, {
|
|
11046
|
+
desc: "local npm registry URL",
|
|
11047
|
+
default: process.env.AKAN_NPM_REGISTRY
|
|
11048
|
+
}).exec(async function(workspace, tag, test, registry) {
|
|
11049
|
+
await this.localRegistryScript.smoke(workspace, { tag, test, registryUrl: registry });
|
|
11050
|
+
})
|
|
11051
|
+
})) {
|
|
11052
|
+
}
|
|
11053
|
+
|
|
10849
11054
|
// pkgs/@akanjs/cli/module/module.command.ts
|
|
10850
11055
|
import { lowerlize } from "akanjs/common";
|
|
10851
11056
|
|
|
@@ -11641,11 +11846,11 @@ class ScalarCommand extends command("scalar", [ScalarScript], ({ public: target
|
|
|
11641
11846
|
}
|
|
11642
11847
|
|
|
11643
11848
|
// pkgs/@akanjs/cli/workspace/workspace.script.ts
|
|
11644
|
-
import
|
|
11645
|
-
import { Logger as
|
|
11849
|
+
import path41 from "path";
|
|
11850
|
+
import { Logger as Logger18 } from "akanjs/common";
|
|
11646
11851
|
|
|
11647
11852
|
// pkgs/@akanjs/cli/workspace/workspace.runner.ts
|
|
11648
|
-
import
|
|
11853
|
+
import path40 from "path";
|
|
11649
11854
|
var defaultWorkspacePeerDependencies = new Set([
|
|
11650
11855
|
"@radix-ui/react-dialog",
|
|
11651
11856
|
"@react-spring/web",
|
|
@@ -11672,7 +11877,7 @@ class WorkspaceRunner extends runner("workspace") {
|
|
|
11672
11877
|
registryUrl
|
|
11673
11878
|
}) {
|
|
11674
11879
|
const cwdPath = process.cwd();
|
|
11675
|
-
const workspaceRoot =
|
|
11880
|
+
const workspaceRoot = path40.join(cwdPath, dirname3, repoName);
|
|
11676
11881
|
const normalizedRegistryUrl = registryUrl ? getNpmRegistryUrl(registryUrl) : undefined;
|
|
11677
11882
|
const workspace = WorkspaceExecutor.fromRoot({ workspaceRoot, repoName });
|
|
11678
11883
|
const templateSpinner = workspace.spinning(`Creating workspace template files in ${dirname3}/${repoName}...`);
|
|
@@ -11728,9 +11933,9 @@ class WorkspaceRunner extends runner("workspace") {
|
|
|
11728
11933
|
}
|
|
11729
11934
|
async#getCliPackageJson() {
|
|
11730
11935
|
const packageJsonCandidates = [
|
|
11731
|
-
|
|
11732
|
-
|
|
11733
|
-
|
|
11936
|
+
path40.join(import.meta.dir, "../package.json"),
|
|
11937
|
+
path40.join(import.meta.dir, "package.json"),
|
|
11938
|
+
path40.join(path40.dirname(Bun.main), "package.json")
|
|
11734
11939
|
];
|
|
11735
11940
|
try {
|
|
11736
11941
|
packageJsonCandidates.unshift(Bun.resolveSync("@akanjs/cli/package.json", import.meta.dir));
|
|
@@ -11746,9 +11951,9 @@ class WorkspaceRunner extends runner("workspace") {
|
|
|
11746
11951
|
}
|
|
11747
11952
|
async#getAkanPackageJson() {
|
|
11748
11953
|
const packageJsonCandidates = [
|
|
11749
|
-
|
|
11750
|
-
|
|
11751
|
-
|
|
11954
|
+
path40.join(import.meta.dir, "../../../akanjs/package.json"),
|
|
11955
|
+
path40.join(process.cwd(), "pkgs/akanjs/package.json"),
|
|
11956
|
+
path40.join(path40.dirname(Bun.main), "node_modules/akanjs/package.json")
|
|
11752
11957
|
];
|
|
11753
11958
|
try {
|
|
11754
11959
|
packageJsonCandidates.unshift(Bun.resolveSync("akanjs/package.json", import.meta.dir));
|
|
@@ -11762,13 +11967,13 @@ class WorkspaceRunner extends runner("workspace") {
|
|
|
11762
11967
|
}
|
|
11763
11968
|
let current = import.meta.dir;
|
|
11764
11969
|
for (let depth = 0;depth < 6; depth++) {
|
|
11765
|
-
const packageJsonPath =
|
|
11970
|
+
const packageJsonPath = path40.join(current, "package.json");
|
|
11766
11971
|
if (await Bun.file(packageJsonPath).exists()) {
|
|
11767
11972
|
const packageJson = await FileSys.readJson(packageJsonPath);
|
|
11768
11973
|
if (packageJson.name === "akanjs")
|
|
11769
11974
|
return packageJson;
|
|
11770
11975
|
}
|
|
11771
|
-
const parent =
|
|
11976
|
+
const parent = path40.dirname(current);
|
|
11772
11977
|
if (parent === current)
|
|
11773
11978
|
break;
|
|
11774
11979
|
current = parent;
|
|
@@ -11803,7 +12008,7 @@ class WorkspaceScript extends script("workspace", [
|
|
|
11803
12008
|
dirname: dirname3,
|
|
11804
12009
|
init,
|
|
11805
12010
|
akanVersion,
|
|
11806
|
-
registryUrl
|
|
12011
|
+
...registryUrl ? { registryUrl } : {}
|
|
11807
12012
|
});
|
|
11808
12013
|
if (installLibs) {
|
|
11809
12014
|
await this.libraryScript.installLibrary(workspace, "util");
|
|
@@ -11817,11 +12022,11 @@ class WorkspaceScript extends script("workspace", [
|
|
|
11817
12022
|
} catch (_) {
|
|
11818
12023
|
gitSpinner.fail("Git repository initialization failed. It's not fatal, you can commit manually");
|
|
11819
12024
|
}
|
|
11820
|
-
const workspacePath =
|
|
11821
|
-
|
|
12025
|
+
const workspacePath = path41.join(dirname3, repoName);
|
|
12026
|
+
Logger18.rawLog(`
|
|
11822
12027
|
\uD83C\uDF89 Welcome aboard! Workspace created in ${dirname3}/${repoName}`);
|
|
11823
|
-
|
|
11824
|
-
|
|
12028
|
+
Logger18.rawLog(`\uD83D\uDE80 Run \`cd ${workspacePath} && akan start ${appName}\` to start the development server.`);
|
|
12029
|
+
Logger18.rawLog(`
|
|
11825
12030
|
\uD83D\uDC4B Happy coding!`);
|
|
11826
12031
|
}
|
|
11827
12032
|
async lint(exec2, workspace, { fix = true } = {}) {
|
|
@@ -11881,7 +12086,7 @@ class WorkspaceCommand extends command("workspace", [WorkspaceScript], ({ public
|
|
|
11881
12086
|
default: process.env.AKAN_NPM_REGISTRY
|
|
11882
12087
|
}).exec(async function(workspaceName, app, dir, libs, init, registry) {
|
|
11883
12088
|
const appName = app || "app";
|
|
11884
|
-
await this.workspaceScript.createWorkspace(workspaceName.toLowerCase().replace(/ /g, "-"), appName.toLowerCase().replace(/ /g, "-"), { dirname: dir, installLibs: libs, init, registryUrl: registry });
|
|
12089
|
+
await this.workspaceScript.createWorkspace(workspaceName.toLowerCase().replace(/ /g, "-"), appName.toLowerCase().replace(/ /g, "-"), { dirname: dir, installLibs: libs, init, ...registry ? { registryUrl: registry } : {} });
|
|
11885
12090
|
}),
|
|
11886
12091
|
lint: target({ desc: "Lint and fix code in a specific app/lib/pkg" }).with(Exec).option("fix", Boolean, { default: true }).with(Workspace).exec(async function(exec2, fix, workspace) {
|
|
11887
12092
|
await this.workspaceScript.lint(exec2, workspace, { fix });
|
|
@@ -11896,4 +12101,4 @@ class WorkspaceCommand extends command("workspace", [WorkspaceScript], ({ public
|
|
|
11896
12101
|
}
|
|
11897
12102
|
|
|
11898
12103
|
// pkgs/@akanjs/cli/index.ts
|
|
11899
|
-
runCommands(WorkspaceCommand, ApplicationCommand, LibraryCommand, PackageCommand, ModuleCommand, PageCommand, CloudCommand, GuidelineCommand, ScalarCommand);
|
|
12104
|
+
runCommands(WorkspaceCommand, ApplicationCommand, LibraryCommand, LocalRegistryCommand, PackageCommand, ModuleCommand, PageCommand, CloudCommand, GuidelineCommand, ScalarCommand);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@akanjs/cli",
|
|
3
|
-
"version": "2.1.0-rc.
|
|
3
|
+
"version": "2.1.0-rc.12",
|
|
4
4
|
"sourceType": "module",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"publishConfig": {
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"@langchain/deepseek": "^1.0.26",
|
|
35
35
|
"@langchain/openai": "^1.4.6",
|
|
36
36
|
"@trapezedev/project": "^7.1.4",
|
|
37
|
-
"akanjs": "2.1.0-rc.
|
|
37
|
+
"akanjs": "2.1.0-rc.12",
|
|
38
38
|
"chalk": "^5.6.2",
|
|
39
39
|
"commander": "^14.0.3",
|
|
40
40
|
"daisyui": "^5.5.20",
|