akanjs 2.0.0-beta.2 → 2.0.0-beta.3
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/cli/index.js +24 -26
- package/cli/package/package.command.ts +3 -5
- package/cli/package/package.runner.ts +3 -2
- package/cli/package/package.script.ts +2 -2
- package/cli/workspace/workspace.command.ts +2 -6
- package/cli/workspace/workspace.runner.ts +1 -7
- package/cli/workspace/workspace.script.ts +14 -8
- package/package.json +1 -1
package/cli/index.js
CHANGED
|
@@ -9949,10 +9949,12 @@ class ApplicationCommand extends command("application", [ApplicationScript], ({
|
|
|
9949
9949
|
var {$: $2 } = globalThis.Bun;
|
|
9950
9950
|
|
|
9951
9951
|
class PackageRunner extends runner("package") {
|
|
9952
|
-
async version(
|
|
9952
|
+
async version({ log = true } = {}) {
|
|
9953
9953
|
const pkgJson = await FileSys.readJson("package.json");
|
|
9954
9954
|
const version = pkgJson.version;
|
|
9955
|
-
|
|
9955
|
+
if (log)
|
|
9956
|
+
Logger.rawLog(`${pkgJson.name}@${version}`);
|
|
9957
|
+
return version;
|
|
9956
9958
|
}
|
|
9957
9959
|
async createPackage(workspace, pkgName) {
|
|
9958
9960
|
await workspace.applyTemplate({ basePath: `pkgs/${pkgName}`, template: "pkgRoot", dict: { pkgName } });
|
|
@@ -10003,8 +10005,8 @@ class PackageRunner extends runner("package") {
|
|
|
10003
10005
|
}
|
|
10004
10006
|
|
|
10005
10007
|
class PackageScript extends script("package", [PackageRunner]) {
|
|
10006
|
-
async version(
|
|
10007
|
-
await this.packageRunner.version(
|
|
10008
|
+
async version({ log = true } = {}) {
|
|
10009
|
+
return await this.packageRunner.version({ log });
|
|
10008
10010
|
}
|
|
10009
10011
|
async createPackage(workspace, pkgName) {
|
|
10010
10012
|
const spinner2 = workspace.spinning(`Creating package in pkgs/${pkgName}...`);
|
|
@@ -11050,8 +11052,8 @@ class ModuleCommand extends command("module", [ModuleScript], ({ public: target
|
|
|
11050
11052
|
}
|
|
11051
11053
|
|
|
11052
11054
|
class PackageCommand extends command("package", [PackageScript], ({ public: target }) => ({
|
|
11053
|
-
version: target({ desc: "Show version information for all packages" }).
|
|
11054
|
-
await this.packageScript.version(
|
|
11055
|
+
version: target({ desc: "Show version information for all packages" }).exec(async function() {
|
|
11056
|
+
await this.packageScript.version();
|
|
11055
11057
|
}),
|
|
11056
11058
|
createPackage: target({ desc: "Create a new package in pkgs/akanjs/" }).option("name", String, { desc: "name of package" }).with(Workspace).exec(async function(name, workspace) {
|
|
11057
11059
|
await this.packageScript.createPackage(workspace, name.toLowerCase().replace(/ /g, "-"));
|
|
@@ -11259,13 +11261,8 @@ class ScalarCommand extends command("scalar", [ScalarScript], ({ public: target
|
|
|
11259
11261
|
import path37 from "path";
|
|
11260
11262
|
|
|
11261
11263
|
import path36 from "path";
|
|
11262
|
-
import latestVersion2 from "latest-version";
|
|
11263
|
-
|
|
11264
11264
|
class WorkspaceRunner extends runner("workspace") {
|
|
11265
|
-
async
|
|
11266
|
-
return /^\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.-]+)?$/.test(tag) ? tag : await latestVersion2("akanjs", { version: tag });
|
|
11267
|
-
}
|
|
11268
|
-
async createWorkspace(repoName, appName, { dirname: dirname3 = ".", tag = "latest", init = true }) {
|
|
11265
|
+
async createWorkspace(repoName, appName, { dirname: dirname3 = ".", init = true, akanVersion }) {
|
|
11269
11266
|
const cwdPath = process.cwd();
|
|
11270
11267
|
const workspaceRoot = path36.join(cwdPath, dirname3, repoName);
|
|
11271
11268
|
const workspace = WorkspaceExecutor.fromRoot({ workspaceRoot, repoName });
|
|
@@ -11277,7 +11274,6 @@ class WorkspaceRunner extends runner("workspace") {
|
|
|
11277
11274
|
});
|
|
11278
11275
|
templateSpinner.succeed(`Workspace files created in ${dirname3}/${repoName}`);
|
|
11279
11276
|
const rootPackageJson = await workspace.getPackageJson();
|
|
11280
|
-
const akanVersion = await this.#resolveAkanVersion(tag);
|
|
11281
11277
|
const packageJson = {
|
|
11282
11278
|
...rootPackageJson,
|
|
11283
11279
|
dependencies: {
|
|
@@ -11306,14 +11302,19 @@ class WorkspaceRunner extends runner("workspace") {
|
|
|
11306
11302
|
}
|
|
11307
11303
|
}
|
|
11308
11304
|
|
|
11309
|
-
class WorkspaceScript extends script("workspace", [
|
|
11310
|
-
|
|
11311
|
-
|
|
11312
|
-
|
|
11313
|
-
|
|
11314
|
-
|
|
11315
|
-
}) {
|
|
11316
|
-
const
|
|
11305
|
+
class WorkspaceScript extends script("workspace", [
|
|
11306
|
+
WorkspaceRunner,
|
|
11307
|
+
ApplicationScript,
|
|
11308
|
+
LibraryScript,
|
|
11309
|
+
PackageScript
|
|
11310
|
+
]) {
|
|
11311
|
+
async createWorkspace(repoName, appName, { dirname: dirname3 = ".", installLibs = false, init = true }) {
|
|
11312
|
+
const akanVersion = await this.packageScript.version({ log: false });
|
|
11313
|
+
const workspace = await this.workspaceRunner.createWorkspace(repoName, appName, {
|
|
11314
|
+
dirname: dirname3,
|
|
11315
|
+
init,
|
|
11316
|
+
akanVersion
|
|
11317
|
+
});
|
|
11317
11318
|
if (installLibs) {
|
|
11318
11319
|
await this.libraryScript.installLibrary(workspace, "util");
|
|
11319
11320
|
await this.libraryScript.installLibrary(workspace, "shared");
|
|
@@ -11381,15 +11382,12 @@ class WorkspaceCommand extends command("workspace", [WorkspaceScript], ({ public
|
|
|
11381
11382
|
value: true
|
|
11382
11383
|
}
|
|
11383
11384
|
]
|
|
11384
|
-
}).option("tag", String, {
|
|
11385
|
-
desc: "tag of the update",
|
|
11386
|
-
default: "latest"
|
|
11387
11385
|
}).option("init", Boolean, {
|
|
11388
11386
|
desc: "Do you want to initialize the workspace? (Recommended)",
|
|
11389
11387
|
default: true
|
|
11390
|
-
}).exec(async function(workspaceName, app, dir, libs,
|
|
11388
|
+
}).exec(async function(workspaceName, app, dir, libs, init) {
|
|
11391
11389
|
const appName = app || "app";
|
|
11392
|
-
await this.workspaceScript.createWorkspace(workspaceName.toLowerCase().replace(/ /g, "-"), appName.toLowerCase().replace(/ /g, "-"), { dirname: dir, installLibs: libs,
|
|
11390
|
+
await this.workspaceScript.createWorkspace(workspaceName.toLowerCase().replace(/ /g, "-"), appName.toLowerCase().replace(/ /g, "-"), { dirname: dir, installLibs: libs, init });
|
|
11393
11391
|
}),
|
|
11394
11392
|
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) {
|
|
11395
11393
|
await this.workspaceScript.lint(exec2, workspace, { fix });
|
|
@@ -3,11 +3,9 @@ import { command, Pkg, Workspace } from "akanjs/devkit";
|
|
|
3
3
|
import { PackageScript } from "./package.script";
|
|
4
4
|
|
|
5
5
|
export class PackageCommand extends command("package", [PackageScript], ({ public: target }) => ({
|
|
6
|
-
version: target({ desc: "Show version information for all packages" })
|
|
7
|
-
.
|
|
8
|
-
|
|
9
|
-
await this.packageScript.version(workspace);
|
|
10
|
-
}),
|
|
6
|
+
version: target({ desc: "Show version information for all packages" }).exec(async function () {
|
|
7
|
+
await this.packageScript.version();
|
|
8
|
+
}),
|
|
11
9
|
createPackage: target({ desc: "Create a new package in pkgs/akanjs/" })
|
|
12
10
|
.option("name", String, { desc: "name of package" })
|
|
13
11
|
.with(Workspace)
|
|
@@ -10,10 +10,11 @@ import {
|
|
|
10
10
|
import { $ } from "bun";
|
|
11
11
|
|
|
12
12
|
export class PackageRunner extends runner("package") {
|
|
13
|
-
async version(
|
|
13
|
+
async version({ log = true }: { log?: boolean } = {}) {
|
|
14
14
|
const pkgJson = await FileSys.readJson<PackageJson>("package.json");
|
|
15
15
|
const version = pkgJson.version;
|
|
16
|
-
Logger.rawLog(`${pkgJson.name}@${version}`);
|
|
16
|
+
if (log) Logger.rawLog(`${pkgJson.name}@${version}`);
|
|
17
|
+
return version;
|
|
17
18
|
}
|
|
18
19
|
async createPackage(workspace: Workspace, pkgName: string) {
|
|
19
20
|
await workspace.applyTemplate({ basePath: `pkgs/${pkgName}`, template: "pkgRoot", dict: { pkgName } });
|
|
@@ -3,8 +3,8 @@ import { type Pkg, script, type Workspace } from "akanjs/devkit";
|
|
|
3
3
|
import { PackageRunner } from "./package.runner";
|
|
4
4
|
|
|
5
5
|
export class PackageScript extends script("package", [PackageRunner]) {
|
|
6
|
-
async version(
|
|
7
|
-
await this.packageRunner.version(
|
|
6
|
+
async version({ log = true }: { log?: boolean } = {}) {
|
|
7
|
+
return await this.packageRunner.version({ log });
|
|
8
8
|
}
|
|
9
9
|
async createPackage(workspace: Workspace, pkgName: string) {
|
|
10
10
|
const spinner = workspace.spinning(`Creating package in pkgs/${pkgName}...`);
|
|
@@ -22,20 +22,16 @@ export class WorkspaceCommand extends command("workspace", [WorkspaceScript], ({
|
|
|
22
22
|
},
|
|
23
23
|
],
|
|
24
24
|
})
|
|
25
|
-
.option("tag", String, {
|
|
26
|
-
desc: "tag of the update",
|
|
27
|
-
default: "latest",
|
|
28
|
-
})
|
|
29
25
|
.option("init", Boolean, {
|
|
30
26
|
desc: "Do you want to initialize the workspace? (Recommended)",
|
|
31
27
|
default: true,
|
|
32
28
|
})
|
|
33
|
-
.exec(async function (workspaceName, app, dir, libs,
|
|
29
|
+
.exec(async function (workspaceName, app, dir, libs, init) {
|
|
34
30
|
const appName = app || "app";
|
|
35
31
|
await this.workspaceScript.createWorkspace(
|
|
36
32
|
workspaceName.toLowerCase().replace(/ /g, "-"),
|
|
37
33
|
appName.toLowerCase().replace(/ /g, "-"),
|
|
38
|
-
{ dirname: dir, installLibs: libs,
|
|
34
|
+
{ dirname: dir, installLibs: libs, init },
|
|
39
35
|
);
|
|
40
36
|
}),
|
|
41
37
|
lint: target({ desc: "Lint and fix code in a specific app/lib/pkg" })
|
|
@@ -1,16 +1,11 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
import { type Exec, type PackageJson, runner, type Workspace, WorkspaceExecutor } from "akanjs/devkit";
|
|
3
|
-
import latestVersion from "latest-version";
|
|
4
3
|
|
|
5
4
|
export class WorkspaceRunner extends runner("workspace") {
|
|
6
|
-
async #resolveAkanVersion(tag: string) {
|
|
7
|
-
return /^\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.-]+)?$/.test(tag) ? tag : await latestVersion("akanjs", { version: tag });
|
|
8
|
-
}
|
|
9
|
-
|
|
10
5
|
async createWorkspace(
|
|
11
6
|
repoName: string,
|
|
12
7
|
appName: string,
|
|
13
|
-
{ dirname = ".",
|
|
8
|
+
{ dirname = ".", init = true, akanVersion }: { dirname?: string; init?: boolean; akanVersion: string },
|
|
14
9
|
) {
|
|
15
10
|
const cwdPath = process.cwd();
|
|
16
11
|
const workspaceRoot = path.join(cwdPath, dirname, repoName);
|
|
@@ -25,7 +20,6 @@ export class WorkspaceRunner extends runner("workspace") {
|
|
|
25
20
|
templateSpinner.succeed(`Workspace files created in ${dirname}/${repoName}`);
|
|
26
21
|
|
|
27
22
|
const rootPackageJson = await workspace.getPackageJson();
|
|
28
|
-
const akanVersion = await this.#resolveAkanVersion(tag);
|
|
29
23
|
const packageJson: PackageJson = {
|
|
30
24
|
...rootPackageJson,
|
|
31
25
|
dependencies: {
|
|
@@ -4,20 +4,26 @@ import { AppExecutor, type Exec, LibExecutor, PkgExecutor, script, type Workspac
|
|
|
4
4
|
|
|
5
5
|
import { ApplicationScript } from "../application/application.script";
|
|
6
6
|
import { LibraryScript } from "../library/library.script";
|
|
7
|
+
import { PackageScript } from "../package/package.script";
|
|
7
8
|
import { WorkspaceRunner } from "./workspace.runner";
|
|
8
9
|
|
|
9
|
-
export class WorkspaceScript extends script("workspace", [
|
|
10
|
+
export class WorkspaceScript extends script("workspace", [
|
|
11
|
+
WorkspaceRunner,
|
|
12
|
+
ApplicationScript,
|
|
13
|
+
LibraryScript,
|
|
14
|
+
PackageScript,
|
|
15
|
+
]) {
|
|
10
16
|
async createWorkspace(
|
|
11
17
|
repoName: string,
|
|
12
18
|
appName: string,
|
|
13
|
-
{
|
|
14
|
-
dirname = ".",
|
|
15
|
-
installLibs = false,
|
|
16
|
-
tag = "latest",
|
|
17
|
-
init = true,
|
|
18
|
-
}: { dirname?: string; installLibs?: boolean; tag?: string; init?: boolean },
|
|
19
|
+
{ dirname = ".", installLibs = false, init = true }: { dirname?: string; installLibs?: boolean; init?: boolean },
|
|
19
20
|
) {
|
|
20
|
-
const
|
|
21
|
+
const akanVersion = await this.packageScript.version({ log: false });
|
|
22
|
+
const workspace = await this.workspaceRunner.createWorkspace(repoName, appName, {
|
|
23
|
+
dirname,
|
|
24
|
+
init,
|
|
25
|
+
akanVersion,
|
|
26
|
+
});
|
|
21
27
|
if (installLibs) {
|
|
22
28
|
await this.libraryScript.installLibrary(workspace, "util");
|
|
23
29
|
await this.libraryScript.installLibrary(workspace, "shared");
|