akanjs 2.0.0-beta.2 → 2.0.0-beta.4
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
CHANGED
|
@@ -9946,13 +9946,16 @@ class ApplicationCommand extends command("application", [ApplicationScript], ({
|
|
|
9946
9946
|
})) {
|
|
9947
9947
|
}
|
|
9948
9948
|
|
|
9949
|
+
import path36 from "path";
|
|
9949
9950
|
var {$: $2 } = globalThis.Bun;
|
|
9950
9951
|
|
|
9951
9952
|
class PackageRunner extends runner("package") {
|
|
9952
|
-
async version(workspace) {
|
|
9953
|
-
const pkgJson = await FileSys.readJson("package.json
|
|
9953
|
+
async version(workspace, { log = true } = {}) {
|
|
9954
|
+
const pkgJson = await FileSys.readJson(process.env.USE_AKANJS_PKGS === "true" ? `${workspace.workspaceRoot}/pkgs/akanjs/package.json` : `${path36.dirname(Bun.main)}/package.json`);
|
|
9954
9955
|
const version = pkgJson.version;
|
|
9955
|
-
|
|
9956
|
+
if (log)
|
|
9957
|
+
Logger.rawLog(`${pkgJson.name}@${version}`);
|
|
9958
|
+
return version;
|
|
9956
9959
|
}
|
|
9957
9960
|
async createPackage(workspace, pkgName) {
|
|
9958
9961
|
await workspace.applyTemplate({ basePath: `pkgs/${pkgName}`, template: "pkgRoot", dict: { pkgName } });
|
|
@@ -10003,8 +10006,8 @@ class PackageRunner extends runner("package") {
|
|
|
10003
10006
|
}
|
|
10004
10007
|
|
|
10005
10008
|
class PackageScript extends script("package", [PackageRunner]) {
|
|
10006
|
-
async version(workspace) {
|
|
10007
|
-
await this.packageRunner.version(workspace);
|
|
10009
|
+
async version(workspace, { log = true } = {}) {
|
|
10010
|
+
return await this.packageRunner.version(workspace, { log });
|
|
10008
10011
|
}
|
|
10009
10012
|
async createPackage(workspace, pkgName) {
|
|
10010
10013
|
const spinner2 = workspace.spinning(`Creating package in pkgs/${pkgName}...`);
|
|
@@ -10263,14 +10266,14 @@ class GuidelinePrompt extends Prompter {
|
|
|
10263
10266
|
async#getScanFilePaths(matchPattern, { avoidDirs = ["node_modules", ".next"], filterText } = {}) {
|
|
10264
10267
|
const glob = new Bun.Glob(matchPattern);
|
|
10265
10268
|
const paths = [];
|
|
10266
|
-
for await (const
|
|
10267
|
-
if (avoidDirs.some((dir) =>
|
|
10269
|
+
for await (const path37 of glob.scan({ cwd: this.workspace.workspaceRoot, absolute: true })) {
|
|
10270
|
+
if (avoidDirs.some((dir) => path37.includes(dir)))
|
|
10268
10271
|
continue;
|
|
10269
|
-
const fileContent = await FileSys.readText(
|
|
10272
|
+
const fileContent = await FileSys.readText(path37);
|
|
10270
10273
|
const textFilter = filterText ? new RegExp(filterText) : null;
|
|
10271
10274
|
if (filterText && !textFilter?.test(fileContent))
|
|
10272
10275
|
continue;
|
|
10273
|
-
paths.push(
|
|
10276
|
+
paths.push(path37);
|
|
10274
10277
|
}
|
|
10275
10278
|
return paths;
|
|
10276
10279
|
}
|
|
@@ -11256,18 +11259,13 @@ class ScalarCommand extends command("scalar", [ScalarScript], ({ public: target
|
|
|
11256
11259
|
})) {
|
|
11257
11260
|
}
|
|
11258
11261
|
|
|
11259
|
-
import
|
|
11260
|
-
|
|
11261
|
-
import path36 from "path";
|
|
11262
|
-
import latestVersion2 from "latest-version";
|
|
11262
|
+
import path38 from "path";
|
|
11263
11263
|
|
|
11264
|
+
import path37 from "path";
|
|
11264
11265
|
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 }) {
|
|
11266
|
+
async createWorkspace(repoName, appName, { dirname: dirname3 = ".", init = true, akanVersion }) {
|
|
11269
11267
|
const cwdPath = process.cwd();
|
|
11270
|
-
const workspaceRoot =
|
|
11268
|
+
const workspaceRoot = path37.join(cwdPath, dirname3, repoName);
|
|
11271
11269
|
const workspace = WorkspaceExecutor.fromRoot({ workspaceRoot, repoName });
|
|
11272
11270
|
const templateSpinner = workspace.spinning(`Creating workspace template files in ${dirname3}/${repoName}...`);
|
|
11273
11271
|
await workspace.applyTemplate({
|
|
@@ -11277,7 +11275,6 @@ class WorkspaceRunner extends runner("workspace") {
|
|
|
11277
11275
|
});
|
|
11278
11276
|
templateSpinner.succeed(`Workspace files created in ${dirname3}/${repoName}`);
|
|
11279
11277
|
const rootPackageJson = await workspace.getPackageJson();
|
|
11280
|
-
const akanVersion = await this.#resolveAkanVersion(tag);
|
|
11281
11278
|
const packageJson = {
|
|
11282
11279
|
...rootPackageJson,
|
|
11283
11280
|
dependencies: {
|
|
@@ -11306,14 +11303,19 @@ class WorkspaceRunner extends runner("workspace") {
|
|
|
11306
11303
|
}
|
|
11307
11304
|
}
|
|
11308
11305
|
|
|
11309
|
-
class WorkspaceScript extends script("workspace", [
|
|
11310
|
-
|
|
11311
|
-
|
|
11312
|
-
|
|
11313
|
-
|
|
11314
|
-
|
|
11315
|
-
}) {
|
|
11316
|
-
const
|
|
11306
|
+
class WorkspaceScript extends script("workspace", [
|
|
11307
|
+
WorkspaceRunner,
|
|
11308
|
+
ApplicationScript,
|
|
11309
|
+
LibraryScript,
|
|
11310
|
+
PackageScript
|
|
11311
|
+
]) {
|
|
11312
|
+
async createWorkspace(repoName, appName, { dirname: dirname3 = ".", installLibs = false, init = true }) {
|
|
11313
|
+
const akanVersion = await this.packageScript.version({ log: false });
|
|
11314
|
+
const workspace = await this.workspaceRunner.createWorkspace(repoName, appName, {
|
|
11315
|
+
dirname: dirname3,
|
|
11316
|
+
init,
|
|
11317
|
+
akanVersion
|
|
11318
|
+
});
|
|
11317
11319
|
if (installLibs) {
|
|
11318
11320
|
await this.libraryScript.installLibrary(workspace, "util");
|
|
11319
11321
|
await this.libraryScript.installLibrary(workspace, "shared");
|
|
@@ -11326,7 +11328,7 @@ class WorkspaceScript extends script("workspace", [WorkspaceRunner, ApplicationS
|
|
|
11326
11328
|
} catch (_) {
|
|
11327
11329
|
gitSpinner.fail("Git repository initialization failed. It's not fatal, you can commit manually");
|
|
11328
11330
|
}
|
|
11329
|
-
const workspacePath =
|
|
11331
|
+
const workspacePath = path38.join(dirname3, repoName);
|
|
11330
11332
|
Logger.rawLog(`
|
|
11331
11333
|
\uD83C\uDF89 Welcome aboard! Workspace created in ${dirname3}/${repoName}`);
|
|
11332
11334
|
Logger.rawLog(`\uD83D\uDE80 Run \`cd ${workspacePath} && akan start ${appName}\` to start the development server.`);
|
|
@@ -11381,15 +11383,12 @@ class WorkspaceCommand extends command("workspace", [WorkspaceScript], ({ public
|
|
|
11381
11383
|
value: true
|
|
11382
11384
|
}
|
|
11383
11385
|
]
|
|
11384
|
-
}).option("tag", String, {
|
|
11385
|
-
desc: "tag of the update",
|
|
11386
|
-
default: "latest"
|
|
11387
11386
|
}).option("init", Boolean, {
|
|
11388
11387
|
desc: "Do you want to initialize the workspace? (Recommended)",
|
|
11389
11388
|
default: true
|
|
11390
|
-
}).exec(async function(workspaceName, app, dir, libs,
|
|
11389
|
+
}).exec(async function(workspaceName, app, dir, libs, init) {
|
|
11391
11390
|
const appName = app || "app";
|
|
11392
|
-
await this.workspaceScript.createWorkspace(workspaceName.toLowerCase().replace(/ /g, "-"), appName.toLowerCase().replace(/ /g, "-"), { dirname: dir, installLibs: libs,
|
|
11391
|
+
await this.workspaceScript.createWorkspace(workspaceName.toLowerCase().replace(/ /g, "-"), appName.toLowerCase().replace(/ /g, "-"), { dirname: dir, installLibs: libs, init });
|
|
11393
11392
|
}),
|
|
11394
11393
|
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
11394
|
await this.workspaceScript.lint(exec2, workspace, { fix });
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import path from "node:path";
|
|
1
2
|
import { Logger } from "akanjs/common";
|
|
2
3
|
import {
|
|
3
4
|
FileSys,
|
|
@@ -10,10 +11,15 @@ import {
|
|
|
10
11
|
import { $ } from "bun";
|
|
11
12
|
|
|
12
13
|
export class PackageRunner extends runner("package") {
|
|
13
|
-
async version(workspace: Workspace) {
|
|
14
|
-
const pkgJson = await FileSys.readJson<PackageJson>(
|
|
14
|
+
async version(workspace: Workspace, { log = true }: { log?: boolean } = {}) {
|
|
15
|
+
const pkgJson = await FileSys.readJson<PackageJson>(
|
|
16
|
+
process.env.USE_AKANJS_PKGS === "true"
|
|
17
|
+
? `${workspace.workspaceRoot}/pkgs/akanjs/package.json`
|
|
18
|
+
: `${path.dirname(Bun.main)}/package.json`,
|
|
19
|
+
);
|
|
15
20
|
const version = pkgJson.version;
|
|
16
|
-
Logger.rawLog(`${pkgJson.name}@${version}`);
|
|
21
|
+
if (log) Logger.rawLog(`${pkgJson.name}@${version}`);
|
|
22
|
+
return version;
|
|
17
23
|
}
|
|
18
24
|
async createPackage(workspace: Workspace, pkgName: string) {
|
|
19
25
|
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(workspace: Workspace) {
|
|
7
|
-
await this.packageRunner.version(workspace);
|
|
6
|
+
async version(workspace: Workspace, { log = true }: { log?: boolean } = {}) {
|
|
7
|
+
return await this.packageRunner.version(workspace, { 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");
|