@akanjs/cli 0.0.64 → 0.0.65
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 +79 -11
- package/package.json +2 -1
- package/pkgs/@akanjs/cli/src/library/library.runner.d.ts +3 -2
- package/pkgs/@akanjs/cli/src/library/library.script.d.ts +1 -1
- package/pkgs/@akanjs/cli/src/package/package.command.d.ts +1 -0
- package/pkgs/@akanjs/cli/src/package/package.runner.d.ts +1 -0
- package/pkgs/@akanjs/cli/src/package/package.script.d.ts +1 -0
package/index.js
CHANGED
|
@@ -1375,6 +1375,25 @@ var SysExecutor = class extends Executor {
|
|
|
1375
1375
|
if (this.type === "lib")
|
|
1376
1376
|
await this.applyTemplate({ basePath: ".", template: "index.ts", scanResult });
|
|
1377
1377
|
this.writeJson(`akan.${this.type}.json`, scanResult);
|
|
1378
|
+
if (this.type === "app")
|
|
1379
|
+
return scanResult;
|
|
1380
|
+
const libPackageJson = this.readJson("package.json");
|
|
1381
|
+
const libPkgJsonWithDeps = {
|
|
1382
|
+
...libPackageJson,
|
|
1383
|
+
dependencies: {
|
|
1384
|
+
...libPackageJson.dependencies,
|
|
1385
|
+
...Object.fromEntries(
|
|
1386
|
+
scanResult.dependencies.filter((dep) => rootPackageJson.dependencies?.[dep]).sort().map((dep) => [dep, rootPackageJson.dependencies?.[dep]])
|
|
1387
|
+
)
|
|
1388
|
+
},
|
|
1389
|
+
devDependencies: {
|
|
1390
|
+
...libPackageJson.devDependencies,
|
|
1391
|
+
...Object.fromEntries(
|
|
1392
|
+
scanResult.dependencies.filter((dep) => rootPackageJson.devDependencies?.[dep]).sort().map((dep) => [dep, rootPackageJson.devDependencies?.[dep]])
|
|
1393
|
+
)
|
|
1394
|
+
}
|
|
1395
|
+
};
|
|
1396
|
+
this.writeJson("package.json", libPkgJsonWithDeps);
|
|
1378
1397
|
return scanResult;
|
|
1379
1398
|
}
|
|
1380
1399
|
getLocalFile(filePath) {
|
|
@@ -2039,6 +2058,7 @@ var AiSession = class _AiSession {
|
|
|
2039
2058
|
};
|
|
2040
2059
|
|
|
2041
2060
|
// pkgs/@akanjs/cli/src/library/library.runner.ts
|
|
2061
|
+
var import_compare_versions = require("compare-versions");
|
|
2042
2062
|
var LibraryRunner = class {
|
|
2043
2063
|
async scanSync(lib) {
|
|
2044
2064
|
const akanConfig = await lib.getConfig();
|
|
@@ -2051,13 +2071,43 @@ var LibraryRunner = class {
|
|
|
2051
2071
|
await workspace.cp(`libs/${libName}/env/env.server.example.ts`, `libs/${libName}/env/env.server.testing.ts`);
|
|
2052
2072
|
workspace.setTsPaths("lib", libName);
|
|
2053
2073
|
await workspace.commit(`Add ${libName} library`);
|
|
2074
|
+
return LibExecutor.from(workspace, libName);
|
|
2075
|
+
}
|
|
2076
|
+
async mergeLibraryDependencies(lib) {
|
|
2077
|
+
const libPackageJson = lib.readJson("package.json");
|
|
2078
|
+
const rootPackageJson = lib.workspace.readJson("package.json");
|
|
2079
|
+
const dependencies = {};
|
|
2080
|
+
const devDependencies = {};
|
|
2081
|
+
const libDependencies = { ...libPackageJson.dependencies, ...libPackageJson.devDependencies };
|
|
2082
|
+
const rootDependencies = { ...rootPackageJson.dependencies, ...rootPackageJson.devDependencies };
|
|
2083
|
+
const allDependencies = Object.fromEntries(
|
|
2084
|
+
Object.keys({ ...libDependencies, ...rootDependencies }).map((dep) => {
|
|
2085
|
+
const libVersion = libDependencies[dep] ?? "0.0.0";
|
|
2086
|
+
const rootVersion = rootDependencies[dep] ?? "0.0.0";
|
|
2087
|
+
const newerVersion = (0, import_compare_versions.compareVersions)(rootVersion, libVersion) > 0 ? rootVersion : libVersion;
|
|
2088
|
+
return [dep, newerVersion];
|
|
2089
|
+
})
|
|
2090
|
+
);
|
|
2091
|
+
Object.keys(allDependencies).sort().forEach((dep) => {
|
|
2092
|
+
if (!!rootDependencies[dep] || !!libDependencies[dep])
|
|
2093
|
+
dependencies[dep] = allDependencies[dep];
|
|
2094
|
+
else
|
|
2095
|
+
devDependencies[dep] = allDependencies[dep];
|
|
2096
|
+
});
|
|
2097
|
+
const newRootPackageJson = { ...rootPackageJson, dependencies, devDependencies };
|
|
2098
|
+
lib.workspace.writeJson("package.json", newRootPackageJson);
|
|
2099
|
+
await lib.workspace.spawn("pnpm", ["install"]);
|
|
2054
2100
|
}
|
|
2055
2101
|
async pushLibrary(lib, branch) {
|
|
2056
|
-
await lib.workspace.exec(
|
|
2102
|
+
await lib.workspace.exec(
|
|
2103
|
+
`git subtree push --prefix=libs/${lib.name} git@github.com:akan-team/${lib.name}.git ${branch}`
|
|
2104
|
+
);
|
|
2057
2105
|
lib.logger.log(`${lib.name} library pushed to ${branch} branch`);
|
|
2058
2106
|
}
|
|
2059
2107
|
async pullLibrary(lib, branch) {
|
|
2060
|
-
await lib.workspace.exec(
|
|
2108
|
+
await lib.workspace.exec(
|
|
2109
|
+
`git subtree pull --prefix=libs/${lib.name} git@github.com:akan-team/${lib.name}.git ${branch}`
|
|
2110
|
+
);
|
|
2061
2111
|
lib.logger.log(`${lib.name} library pulled from ${branch} branch`);
|
|
2062
2112
|
}
|
|
2063
2113
|
};
|
|
@@ -2065,20 +2115,23 @@ var LibraryRunner = class {
|
|
|
2065
2115
|
// pkgs/@akanjs/cli/src/library/library.script.ts
|
|
2066
2116
|
var LibraryScript = class {
|
|
2067
2117
|
#runner = new LibraryRunner();
|
|
2068
|
-
async scanLibrary(lib) {
|
|
2118
|
+
async scanLibrary(lib, verbose = false) {
|
|
2069
2119
|
const scanResult = await this.#runner.scanSync(lib);
|
|
2070
|
-
|
|
2120
|
+
if (verbose)
|
|
2121
|
+
lib.logger.rawLog(JSON.stringify(scanResult, null, 2));
|
|
2122
|
+
return scanResult;
|
|
2071
2123
|
}
|
|
2072
2124
|
async syncLibrary(lib, { recursive = true } = {}) {
|
|
2073
|
-
const scanResult = await this
|
|
2074
|
-
if (recursive)
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2125
|
+
const scanResult = await this.scanLibrary(lib);
|
|
2126
|
+
if (!recursive)
|
|
2127
|
+
return;
|
|
2128
|
+
for (const libName of scanResult.akanConfig.libs)
|
|
2129
|
+
await this.syncLibrary(LibExecutor.from(lib.workspace, libName), { recursive: false });
|
|
2078
2130
|
}
|
|
2079
2131
|
async installLibrary(workspace, libName) {
|
|
2080
|
-
await this.#runner.installLibrary(workspace, libName);
|
|
2132
|
+
const lib = await this.#runner.installLibrary(workspace, libName);
|
|
2081
2133
|
workspace.log(`${libName} library installed`);
|
|
2134
|
+
await this.#runner.mergeLibraryDependencies(lib);
|
|
2082
2135
|
}
|
|
2083
2136
|
async pushLibrary(lib, branch) {
|
|
2084
2137
|
await this.#runner.pushLibrary(lib, branch);
|
|
@@ -3860,6 +3913,11 @@ var esbuild2 = __toESM(require("esbuild"));
|
|
|
3860
3913
|
var import_esbuild_plugin_d = require("esbuild-plugin-d.ts");
|
|
3861
3914
|
var import_promises3 = __toESM(require("fs/promises"));
|
|
3862
3915
|
var PackageRunner = class {
|
|
3916
|
+
async version(workspace) {
|
|
3917
|
+
const pkgJson = JSON.parse(await import_promises3.default.readFile("package.json", "utf-8"));
|
|
3918
|
+
const version = pkgJson.version;
|
|
3919
|
+
Logger.rawLog(`${pkgJson.name}@${version}`);
|
|
3920
|
+
}
|
|
3863
3921
|
async createPackage(workspace, pkgName) {
|
|
3864
3922
|
await workspace.applyTemplate({
|
|
3865
3923
|
basePath: `pkgs/${pkgName}`,
|
|
@@ -3974,6 +4032,9 @@ var PackageRunner = class {
|
|
|
3974
4032
|
// pkgs/@akanjs/cli/src/package/package.script.ts
|
|
3975
4033
|
var PackageScript = class {
|
|
3976
4034
|
#runner = new PackageRunner();
|
|
4035
|
+
async version(workspace) {
|
|
4036
|
+
await this.#runner.version(workspace);
|
|
4037
|
+
}
|
|
3977
4038
|
async createPackage(workspace, pkgName) {
|
|
3978
4039
|
await this.#runner.createPackage(workspace, pkgName);
|
|
3979
4040
|
}
|
|
@@ -4162,7 +4223,7 @@ var LibraryCommand = class {
|
|
|
4162
4223
|
async removeLibrary(lib, workspace) {
|
|
4163
4224
|
}
|
|
4164
4225
|
async scanLibrary(lib) {
|
|
4165
|
-
await this.libraryScript.scanLibrary(lib);
|
|
4226
|
+
await this.libraryScript.scanLibrary(lib, true);
|
|
4166
4227
|
}
|
|
4167
4228
|
async buildLibrary(lib) {
|
|
4168
4229
|
}
|
|
@@ -4459,6 +4520,9 @@ ModuleCommand = __decorateClass([
|
|
|
4459
4520
|
// pkgs/@akanjs/cli/src/package/package.command.ts
|
|
4460
4521
|
var PackageCommand = class {
|
|
4461
4522
|
packageScript = new PackageScript();
|
|
4523
|
+
async version(workspace) {
|
|
4524
|
+
await this.packageScript.version(workspace);
|
|
4525
|
+
}
|
|
4462
4526
|
async createPackage(name, workspace) {
|
|
4463
4527
|
await this.packageScript.createPackage(workspace, name);
|
|
4464
4528
|
}
|
|
@@ -4471,6 +4535,10 @@ var PackageCommand = class {
|
|
|
4471
4535
|
await this.packageScript.buildPackage(pkg);
|
|
4472
4536
|
}
|
|
4473
4537
|
};
|
|
4538
|
+
__decorateClass([
|
|
4539
|
+
Target.Public(),
|
|
4540
|
+
__decorateParam(0, Workspace())
|
|
4541
|
+
], PackageCommand.prototype, "version", 1);
|
|
4474
4542
|
__decorateClass([
|
|
4475
4543
|
Target.Public(),
|
|
4476
4544
|
__decorateParam(0, Option("name", { desc: "name of package" })),
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "commonjs",
|
|
3
3
|
"name": "@akanjs/cli",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.65",
|
|
5
5
|
"bin": {
|
|
6
6
|
"akan": "index.js"
|
|
7
7
|
},
|
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
"axios": "^1.7.9",
|
|
29
29
|
"chalk": "^5.4.1",
|
|
30
30
|
"commander": "^13.1.0",
|
|
31
|
+
"compare-versions": "^6.1.1",
|
|
31
32
|
"dayjs": "^1.11.13",
|
|
32
33
|
"dotenv": "^16.4.7",
|
|
33
34
|
"esbuild": "^0.19.2",
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { Lib, Workspace } from "@akanjs/devkit";
|
|
1
|
+
import { Lib, LibExecutor, Workspace } from "@akanjs/devkit";
|
|
2
2
|
export declare class LibraryRunner {
|
|
3
3
|
scanSync(lib: Lib): Promise<import("@akanjs/config").AppScanResult | import("@akanjs/config").LibScanResult>;
|
|
4
|
-
installLibrary(workspace: Workspace, libName: string): Promise<
|
|
4
|
+
installLibrary(workspace: Workspace, libName: string): Promise<LibExecutor>;
|
|
5
|
+
mergeLibraryDependencies(lib: Lib): Promise<void>;
|
|
5
6
|
pushLibrary(lib: Lib, branch: string): Promise<void>;
|
|
6
7
|
pullLibrary(lib: Lib, branch: string): Promise<void>;
|
|
7
8
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Lib, Workspace } from "@akanjs/devkit";
|
|
2
2
|
export declare class LibraryScript {
|
|
3
3
|
#private;
|
|
4
|
-
scanLibrary(lib: Lib): Promise<
|
|
4
|
+
scanLibrary(lib: Lib, verbose?: boolean): Promise<import("@akanjs/config").AppScanResult | import("@akanjs/config").LibScanResult>;
|
|
5
5
|
syncLibrary(lib: Lib, { recursive }?: {
|
|
6
6
|
recursive?: boolean;
|
|
7
7
|
}): Promise<void>;
|
|
@@ -2,6 +2,7 @@ import { Pkg, Workspace } from "@akanjs/devkit";
|
|
|
2
2
|
import { PackageScript } from "./package.script";
|
|
3
3
|
export declare class PackageCommand {
|
|
4
4
|
packageScript: PackageScript;
|
|
5
|
+
version(workspace: Workspace): Promise<void>;
|
|
5
6
|
createPackage(name: string, workspace: Workspace): Promise<void>;
|
|
6
7
|
removePackage(name: string, workspace: Workspace): Promise<void>;
|
|
7
8
|
scanPackage(pkg: Pkg): Promise<void>;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type DistPkgExecutor, type Pkg, type Workspace } from "@akanjs/devkit";
|
|
2
2
|
export declare class PackageRunner {
|
|
3
|
+
version(workspace: Workspace): Promise<void>;
|
|
3
4
|
createPackage(workspace: Workspace, pkgName: string): Promise<void>;
|
|
4
5
|
scanSync(pkg: Pkg): Promise<import("@akanjs/config").PkgScanResult>;
|
|
5
6
|
buildPackage(pkg: Pkg, distPkg: DistPkgExecutor): Promise<void>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { DistPkgExecutor, type Pkg, type Workspace } from "@akanjs/devkit";
|
|
2
2
|
export declare class PackageScript {
|
|
3
3
|
#private;
|
|
4
|
+
version(workspace: Workspace): Promise<void>;
|
|
4
5
|
createPackage(workspace: Workspace, pkgName: string): Promise<void>;
|
|
5
6
|
scanPackage(pkg: Pkg): Promise<void>;
|
|
6
7
|
buildPackage(pkg: Pkg, distPkg?: DistPkgExecutor): Promise<void>;
|