@akanjs/cli 2.2.0-rc.3 → 2.2.0-rc.5
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/incrementalBuilder.proc.js +18 -6
- package/index.js +18 -6
- package/package.json +2 -2
- package/templates/lib/dict.ts +2 -5
|
@@ -4515,6 +4515,7 @@ async function appHasStModule(appCwdPath) {
|
|
|
4515
4515
|
return Bun.file(path10.join(appCwdPath, "lib", "st.ts")).exists();
|
|
4516
4516
|
}
|
|
4517
4517
|
var IMPLICIT_LAYOUT_DIR = path10.join(".akan", "generated", "root-layouts");
|
|
4518
|
+
var IMPLICIT_DICT_DIR = path10.join(".akan", "generated", "dict");
|
|
4518
4519
|
function getRootBoundarySegments(key) {
|
|
4519
4520
|
const match = LAYOUT_KEY_RE.exec(key);
|
|
4520
4521
|
if (!match)
|
|
@@ -4531,6 +4532,9 @@ function implicitRootLayoutAbsPath(appCwdPath, segments) {
|
|
|
4531
4532
|
const filename = segments.length ? `${segments.join("__")}__root_layout.tsx` : "__root_layout.tsx";
|
|
4532
4533
|
return path10.join(path10.resolve(appCwdPath), IMPLICIT_LAYOUT_DIR, filename);
|
|
4533
4534
|
}
|
|
4535
|
+
function implicitDictionaryMacroAbsPath(appCwdPath) {
|
|
4536
|
+
return path10.join(path10.resolve(appCwdPath), IMPLICIT_DICT_DIR, "useDict.ts");
|
|
4537
|
+
}
|
|
4534
4538
|
function isRootBoundarySegments(segments, basePaths) {
|
|
4535
4539
|
const firstVisibleIndex = segments.findIndex((segment) => !/^\(.+\)$/.test(segment));
|
|
4536
4540
|
if (firstVisibleIndex === -1)
|
|
@@ -4582,10 +4586,22 @@ async function assertEnvClientConvention(appCwdPath, appName) {
|
|
|
4582
4586
|
throw new Error(`[route-convention] app "${appName}" must provide env/env.client.ts exporting "env" for generated System.Provider`);
|
|
4583
4587
|
}
|
|
4584
4588
|
}
|
|
4589
|
+
async function writeGeneratedDictionaryMacroFile(appCwdPath, appName) {
|
|
4590
|
+
const absPath = implicitDictionaryMacroAbsPath(appCwdPath);
|
|
4591
|
+
await mkdir3(path10.dirname(absPath), { recursive: true });
|
|
4592
|
+
await Bun.write(absPath, `import { getAllDictionary } from "@apps/${appName}/lib/dict" with { type: "macro" };
|
|
4593
|
+
|
|
4594
|
+
export const allDictionary = getAllDictionary();
|
|
4595
|
+
`);
|
|
4596
|
+
return absPath;
|
|
4597
|
+
}
|
|
4585
4598
|
async function writeGeneratedRootLayoutFile(opts) {
|
|
4586
4599
|
await assertEnvClientConvention(opts.appCwdPath, opts.appName);
|
|
4600
|
+
const dictMacroAbsPath = opts.includeSystemProvider ? await writeGeneratedDictionaryMacroFile(opts.appCwdPath, opts.appName) : null;
|
|
4587
4601
|
const absPath = implicitRootLayoutAbsPath(opts.appCwdPath, opts.boundary.segments);
|
|
4588
4602
|
await mkdir3(path10.dirname(absPath), { recursive: true });
|
|
4603
|
+
const dictMacroRel = dictMacroAbsPath ? path10.relative(path10.dirname(absPath), dictMacroAbsPath).split(path10.sep).join("/") : null;
|
|
4604
|
+
const dictMacroSpecifier = dictMacroRel ? dictMacroRel.startsWith(".") ? dictMacroRel : `./${dictMacroRel}` : null;
|
|
4589
4605
|
const sourceRel = opts.boundary.sourceAbsPath ? path10.relative(path10.dirname(absPath), opts.boundary.sourceAbsPath).split(path10.sep).join("/") : null;
|
|
4590
4606
|
const sourceSpecifier = sourceRel ? sourceRel.startsWith(".") ? sourceRel : `./${sourceRel}` : null;
|
|
4591
4607
|
const inheritedSourceAbsPath = opts.rootSourceAbsPath && opts.rootSourceAbsPath !== opts.boundary.sourceAbsPath ? opts.rootSourceAbsPath : null;
|
|
@@ -4607,12 +4623,8 @@ const userLayout = {};
|
|
|
4607
4623
|
import { loadFonts } from "akanjs/client";
|
|
4608
4624
|
import { System } from "akanjs/ui";
|
|
4609
4625
|
import { env } from "@apps/${opts.appName}/env/env.client";
|
|
4626
|
+
import { allDictionary } from ${JSON.stringify(dictMacroSpecifier)};
|
|
4610
4627
|
${clientImport}${inheritedImport}${userImport}
|
|
4611
|
-
// SSR builds (target=bun) load the full dictionary server-side and pass only the active locale to the client.
|
|
4612
|
-
// CSR builds (target=browser) fold this branch to undefined, so the macro-seeded dictionary is used and the
|
|
4613
|
-
// server-only dict module (which pulls @libs/*/server) is dead-code-eliminated out of the browser bundle.
|
|
4614
|
-
const getActiveLocaleDictionary =
|
|
4615
|
-
process.env.AKAN_PUBLIC_RENDER_ENV === "ssr" ? (await import("@apps/${opts.appName}/lib/dict")).getDictionary : undefined;
|
|
4616
4628
|
const userFonts = userLayout.fonts ?? inheritedLayout.fonts ?? [];
|
|
4617
4629
|
const defaultFonts = userFonts.filter((font) => font.default);
|
|
4618
4630
|
if (defaultFonts.length > 1) throw new Error("[route-convention] only one default font is allowed per root layout");
|
|
@@ -4644,7 +4656,7 @@ export default function GeneratedLayout({ children, params, searchParams }: Layo
|
|
|
4644
4656
|
gaTrackingId={userLayout.gaTrackingId ?? inheritedLayout.gaTrackingId}
|
|
4645
4657
|
layoutStyle={userLayout.layoutStyle ?? inheritedLayout.layoutStyle}
|
|
4646
4658
|
reconnect={userLayout.reconnect ?? inheritedLayout.reconnect ?? false}
|
|
4647
|
-
dictionary={
|
|
4659
|
+
dictionary={allDictionary[params.lang]}
|
|
4648
4660
|
>
|
|
4649
4661
|
<UserLayout params={params} searchParams={searchParams}>{children}</UserLayout>
|
|
4650
4662
|
</System.Provider>
|
package/index.js
CHANGED
|
@@ -4513,6 +4513,7 @@ async function appHasStModule(appCwdPath) {
|
|
|
4513
4513
|
return Bun.file(path10.join(appCwdPath, "lib", "st.ts")).exists();
|
|
4514
4514
|
}
|
|
4515
4515
|
var IMPLICIT_LAYOUT_DIR = path10.join(".akan", "generated", "root-layouts");
|
|
4516
|
+
var IMPLICIT_DICT_DIR = path10.join(".akan", "generated", "dict");
|
|
4516
4517
|
function getRootBoundarySegments(key) {
|
|
4517
4518
|
const match = LAYOUT_KEY_RE.exec(key);
|
|
4518
4519
|
if (!match)
|
|
@@ -4529,6 +4530,9 @@ function implicitRootLayoutAbsPath(appCwdPath, segments) {
|
|
|
4529
4530
|
const filename = segments.length ? `${segments.join("__")}__root_layout.tsx` : "__root_layout.tsx";
|
|
4530
4531
|
return path10.join(path10.resolve(appCwdPath), IMPLICIT_LAYOUT_DIR, filename);
|
|
4531
4532
|
}
|
|
4533
|
+
function implicitDictionaryMacroAbsPath(appCwdPath) {
|
|
4534
|
+
return path10.join(path10.resolve(appCwdPath), IMPLICIT_DICT_DIR, "useDict.ts");
|
|
4535
|
+
}
|
|
4532
4536
|
function isRootBoundarySegments(segments, basePaths) {
|
|
4533
4537
|
const firstVisibleIndex = segments.findIndex((segment) => !/^\(.+\)$/.test(segment));
|
|
4534
4538
|
if (firstVisibleIndex === -1)
|
|
@@ -4580,10 +4584,22 @@ async function assertEnvClientConvention(appCwdPath, appName) {
|
|
|
4580
4584
|
throw new Error(`[route-convention] app "${appName}" must provide env/env.client.ts exporting "env" for generated System.Provider`);
|
|
4581
4585
|
}
|
|
4582
4586
|
}
|
|
4587
|
+
async function writeGeneratedDictionaryMacroFile(appCwdPath, appName) {
|
|
4588
|
+
const absPath = implicitDictionaryMacroAbsPath(appCwdPath);
|
|
4589
|
+
await mkdir3(path10.dirname(absPath), { recursive: true });
|
|
4590
|
+
await Bun.write(absPath, `import { getAllDictionary } from "@apps/${appName}/lib/dict" with { type: "macro" };
|
|
4591
|
+
|
|
4592
|
+
export const allDictionary = getAllDictionary();
|
|
4593
|
+
`);
|
|
4594
|
+
return absPath;
|
|
4595
|
+
}
|
|
4583
4596
|
async function writeGeneratedRootLayoutFile(opts) {
|
|
4584
4597
|
await assertEnvClientConvention(opts.appCwdPath, opts.appName);
|
|
4598
|
+
const dictMacroAbsPath = opts.includeSystemProvider ? await writeGeneratedDictionaryMacroFile(opts.appCwdPath, opts.appName) : null;
|
|
4585
4599
|
const absPath = implicitRootLayoutAbsPath(opts.appCwdPath, opts.boundary.segments);
|
|
4586
4600
|
await mkdir3(path10.dirname(absPath), { recursive: true });
|
|
4601
|
+
const dictMacroRel = dictMacroAbsPath ? path10.relative(path10.dirname(absPath), dictMacroAbsPath).split(path10.sep).join("/") : null;
|
|
4602
|
+
const dictMacroSpecifier = dictMacroRel ? dictMacroRel.startsWith(".") ? dictMacroRel : `./${dictMacroRel}` : null;
|
|
4587
4603
|
const sourceRel = opts.boundary.sourceAbsPath ? path10.relative(path10.dirname(absPath), opts.boundary.sourceAbsPath).split(path10.sep).join("/") : null;
|
|
4588
4604
|
const sourceSpecifier = sourceRel ? sourceRel.startsWith(".") ? sourceRel : `./${sourceRel}` : null;
|
|
4589
4605
|
const inheritedSourceAbsPath = opts.rootSourceAbsPath && opts.rootSourceAbsPath !== opts.boundary.sourceAbsPath ? opts.rootSourceAbsPath : null;
|
|
@@ -4605,12 +4621,8 @@ const userLayout = {};
|
|
|
4605
4621
|
import { loadFonts } from "akanjs/client";
|
|
4606
4622
|
import { System } from "akanjs/ui";
|
|
4607
4623
|
import { env } from "@apps/${opts.appName}/env/env.client";
|
|
4624
|
+
import { allDictionary } from ${JSON.stringify(dictMacroSpecifier)};
|
|
4608
4625
|
${clientImport}${inheritedImport}${userImport}
|
|
4609
|
-
// SSR builds (target=bun) load the full dictionary server-side and pass only the active locale to the client.
|
|
4610
|
-
// CSR builds (target=browser) fold this branch to undefined, so the macro-seeded dictionary is used and the
|
|
4611
|
-
// server-only dict module (which pulls @libs/*/server) is dead-code-eliminated out of the browser bundle.
|
|
4612
|
-
const getActiveLocaleDictionary =
|
|
4613
|
-
process.env.AKAN_PUBLIC_RENDER_ENV === "ssr" ? (await import("@apps/${opts.appName}/lib/dict")).getDictionary : undefined;
|
|
4614
4626
|
const userFonts = userLayout.fonts ?? inheritedLayout.fonts ?? [];
|
|
4615
4627
|
const defaultFonts = userFonts.filter((font) => font.default);
|
|
4616
4628
|
if (defaultFonts.length > 1) throw new Error("[route-convention] only one default font is allowed per root layout");
|
|
@@ -4642,7 +4654,7 @@ export default function GeneratedLayout({ children, params, searchParams }: Layo
|
|
|
4642
4654
|
gaTrackingId={userLayout.gaTrackingId ?? inheritedLayout.gaTrackingId}
|
|
4643
4655
|
layoutStyle={userLayout.layoutStyle ?? inheritedLayout.layoutStyle}
|
|
4644
4656
|
reconnect={userLayout.reconnect ?? inheritedLayout.reconnect ?? false}
|
|
4645
|
-
dictionary={
|
|
4657
|
+
dictionary={allDictionary[params.lang]}
|
|
4646
4658
|
>
|
|
4647
4659
|
<UserLayout params={params} searchParams={searchParams}>{children}</UserLayout>
|
|
4648
4660
|
</System.Provider>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@akanjs/cli",
|
|
3
|
-
"version": "2.2.0-rc.
|
|
3
|
+
"version": "2.2.0-rc.5",
|
|
4
4
|
"sourceType": "module",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"publishConfig": {
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"@langchain/openai": "^1.4.6",
|
|
36
36
|
"@tailwindcss/node": "^4.3.0",
|
|
37
37
|
"@trapezedev/project": "^7.1.4",
|
|
38
|
-
"akanjs": "2.2.0-rc.
|
|
38
|
+
"akanjs": "2.2.0-rc.5",
|
|
39
39
|
"chalk": "^5.6.2",
|
|
40
40
|
"commander": "^14.0.3",
|
|
41
41
|
"daisyui": "^5.5.20",
|
package/templates/lib/dict.ts
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import type { AppInfo, LibInfo } from "akanjs";
|
|
2
2
|
|
|
3
3
|
const capitalize = (str: string) => str.charAt(0).toUpperCase() + str.slice(1);
|
|
4
|
-
export default function getContent(
|
|
5
|
-
scanInfo: AppInfo | LibInfo | null,
|
|
6
|
-
dict: { [key: string]: string } = {},
|
|
7
|
-
) {
|
|
4
|
+
export default function getContent(scanInfo: AppInfo | LibInfo | null, dict: { [key: string]: string } = {}) {
|
|
8
5
|
if (!scanInfo) return null;
|
|
9
6
|
const databaseModules = scanInfo.getDatabaseModules();
|
|
10
7
|
const scalarModules = scanInfo.getScalarModules();
|
|
@@ -12,7 +9,7 @@ export default function getContent(
|
|
|
12
9
|
const libs = scanInfo.getLibs();
|
|
13
10
|
return `
|
|
14
11
|
import { makeDictionary, makeTrans, registerScalarTrans, registerServiceTrans, registerModelTrans${libs.length === 0 ? `, dictionary as base` : ""} } from "akanjs/dictionary";
|
|
15
|
-
${libs.length ? libs.map((lib) => `import { dictionary as ${lib} } from "@libs/${lib}/
|
|
12
|
+
${libs.length ? libs.map((lib) => `import { dictionary as ${lib} } from "@libs/${lib}/server";`).join("\n") : ""}
|
|
16
13
|
|
|
17
14
|
${databaseModules.map((module) => `import * as ${module} from "./${module}/${module}.dictionary";`).join("\n")}
|
|
18
15
|
${serviceModules.map((module) => `import * as ${module} from "./_${module}/${module}.dictionary";`).join("\n")}
|