@akanjs/cli 0.9.32 → 0.9.33
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/cjs/index.js +70 -58
- package/cjs/src/templates/app/app/[lang]/{(__appName__)/layout.js → layout.js} +1 -1
- package/cjs/src/templates/app/app/[lang]/{(__appName__)/(public)/page.js → page.js} +1 -1
- package/cjs/src/templates/app/app/[lang]/{(__appName__)/(public)/unknown → unknown}/page.js +1 -1
- package/cjs/src/templates/crudPages/[__model__Id]/edit/page.js +1 -1
- package/cjs/src/templates/crudPages/[__model__Id]/page.js +2 -3
- package/cjs/src/templates/crudPages/new/page.js +2 -2
- package/cjs/src/templates/crudPages/page.js +2 -2
- package/esm/index.js +70 -58
- package/esm/src/templates/app/app/[lang]/{(__appName__)/layout.js → layout.js} +1 -1
- package/esm/src/templates/app/app/[lang]/{(__appName__)/(public)/page.js → page.js} +1 -1
- package/esm/src/templates/app/app/[lang]/{(__appName__)/(public)/unknown → unknown}/page.js +1 -1
- package/esm/src/templates/crudPages/[__model__Id]/edit/page.js +1 -1
- package/esm/src/templates/crudPages/[__model__Id]/page.js +2 -3
- package/esm/src/templates/crudPages/new/page.js +2 -2
- package/esm/src/templates/crudPages/page.js +2 -2
- package/package.json +1 -1
- package/src/module/module.command.d.ts +1 -1
- package/src/module/module.script.d.ts +9 -5
- package/src/page/page.command.d.ts +2 -2
- package/src/page/page.runner.d.ts +6 -2
- package/src/page/page.script.d.ts +6 -2
- package/cjs/src/templates/app/app/[lang]/admin/layout.js +0 -54
- package/esm/src/templates/app/app/[lang]/admin/layout.js +0 -34
- package/src/templates/app/app/[lang]/admin/layout.d.ts +0 -9
- /package/cjs/src/templates/app/app/[lang]/{(__appName__)/styles.css.template → styles.css.template} +0 -0
- /package/esm/src/templates/app/app/[lang]/{(__appName__)/styles.css.template → styles.css.template} +0 -0
- /package/src/templates/app/app/[lang]/{(__appName__)/layout.d.ts → layout.d.ts} +0 -0
- /package/src/templates/app/app/[lang]/{(__appName__)/(public)/page.d.ts → page.d.ts} +0 -0
- /package/src/templates/app/app/[lang]/{(__appName__)/(public)/unknown → unknown}/page.d.ts +0 -0
package/cjs/index.js
CHANGED
|
@@ -5218,6 +5218,25 @@ LibraryCommand = __decorateClass([
|
|
|
5218
5218
|
// pkgs/@akanjs/cli/src/module/module.script.ts
|
|
5219
5219
|
var import_fs11 = __toESM(require("fs"), 1);
|
|
5220
5220
|
|
|
5221
|
+
// pkgs/@akanjs/cli/src/page/page.runner.ts
|
|
5222
|
+
var PageRunner = class {
|
|
5223
|
+
async createCrudPage(module2, { app, basePath: basePath2, single = false }) {
|
|
5224
|
+
await app.applyTemplate({
|
|
5225
|
+
basePath: basePath2 ?? `app/[lang]/(${app.name})/(public)/${module2.name}`,
|
|
5226
|
+
template: single ? "crudSinglePage" : "crudPages",
|
|
5227
|
+
dict: { model: module2.name, appName: module2.sys.name }
|
|
5228
|
+
});
|
|
5229
|
+
}
|
|
5230
|
+
};
|
|
5231
|
+
|
|
5232
|
+
// pkgs/@akanjs/cli/src/page/page.script.ts
|
|
5233
|
+
var PageScript = class {
|
|
5234
|
+
#runner = new PageRunner();
|
|
5235
|
+
async createCrudPage(module2, { app, basePath: basePath2, single = false }) {
|
|
5236
|
+
await this.#runner.createCrudPage(module2, { app, basePath: basePath2, single });
|
|
5237
|
+
}
|
|
5238
|
+
};
|
|
5239
|
+
|
|
5221
5240
|
// pkgs/@akanjs/cli/src/module/module.prompt.ts
|
|
5222
5241
|
var componentDefaultDescription = ({
|
|
5223
5242
|
modelName,
|
|
@@ -5592,10 +5611,13 @@ var ModuleRunner = class {
|
|
|
5592
5611
|
|
|
5593
5612
|
// pkgs/@akanjs/cli/src/module/module.script.ts
|
|
5594
5613
|
var ModuleScript = class {
|
|
5614
|
+
pageScript = new PageScript();
|
|
5595
5615
|
#runner = new ModuleRunner();
|
|
5596
|
-
async createModuleTemplate(sys3, name) {
|
|
5597
|
-
const
|
|
5598
|
-
await this.#runner.createModuleTemplate(
|
|
5616
|
+
async createModuleTemplate(sys3, name, { page = false } = {}) {
|
|
5617
|
+
const mod = ModuleExecutor.from(sys3, name);
|
|
5618
|
+
await this.#runner.createModuleTemplate(mod);
|
|
5619
|
+
if (page && sys3.type === "app")
|
|
5620
|
+
await this.pageScript.createCrudPage(mod, { app: sys3, basePath: null, single: false });
|
|
5599
5621
|
const akanConfig = await sys3.getConfig();
|
|
5600
5622
|
await sys3.scan({ akanConfig });
|
|
5601
5623
|
}
|
|
@@ -5646,25 +5668,25 @@ var ModuleScript = class {
|
|
|
5646
5668
|
await this.createTemplate(executor);
|
|
5647
5669
|
sys3.log(`Module ${name} created in ${sys3.type}s/${sys3.name}/lib/${name}`);
|
|
5648
5670
|
}
|
|
5649
|
-
removeModule(
|
|
5650
|
-
this.#runner.removeModule(
|
|
5671
|
+
removeModule(mod) {
|
|
5672
|
+
this.#runner.removeModule(mod);
|
|
5651
5673
|
}
|
|
5652
5674
|
async createService(workspace, name) {
|
|
5653
5675
|
}
|
|
5654
5676
|
async createTest(workspace, name) {
|
|
5655
5677
|
}
|
|
5656
|
-
async createTemplate(
|
|
5657
|
-
const { component: template } = await this.#runner.createComponentTemplate(
|
|
5658
|
-
const templateExampleFiles = (await
|
|
5659
|
-
(f) => !f.filePath.includes(`${
|
|
5678
|
+
async createTemplate(mod) {
|
|
5679
|
+
const { component: template } = await this.#runner.createComponentTemplate(mod, "template");
|
|
5680
|
+
const templateExampleFiles = (await mod.sys.getTemplatesSourceCode()).filter(
|
|
5681
|
+
(f) => !f.filePath.includes(`${mod.name}.Template.tsx`)
|
|
5660
5682
|
);
|
|
5661
|
-
const Name = capitalize(
|
|
5662
|
-
const relatedCnsts = getRelatedCnsts(`${
|
|
5663
|
-
const constant = import_fs11.default.readFileSync(`${
|
|
5664
|
-
const session = new AiSession("createTemplate", { workspace:
|
|
5683
|
+
const Name = capitalize(mod.name);
|
|
5684
|
+
const relatedCnsts = getRelatedCnsts(`${mod.sys.cwdPath}/lib/${mod.name}/${mod.name}.constant.ts`);
|
|
5685
|
+
const constant = import_fs11.default.readFileSync(`${mod.sys.cwdPath}/lib/${mod.name}/${mod.name}.constant.ts`, "utf-8");
|
|
5686
|
+
const session = new AiSession("createTemplate", { workspace: mod.sys.workspace, cacheKey: mod.name });
|
|
5665
5687
|
const promptRst = requestTemplate({
|
|
5666
|
-
sysName:
|
|
5667
|
-
modelName:
|
|
5688
|
+
sysName: mod.sys.name,
|
|
5689
|
+
modelName: mod.name,
|
|
5668
5690
|
ModelName: Name,
|
|
5669
5691
|
constant,
|
|
5670
5692
|
boilerplate: template.content,
|
|
@@ -5672,20 +5694,20 @@ var ModuleScript = class {
|
|
|
5672
5694
|
exampleFiles: randomPicks(templateExampleFiles, Math.min(20, templateExampleFiles.length))
|
|
5673
5695
|
});
|
|
5674
5696
|
const content = await session.editTypescript(promptRst);
|
|
5675
|
-
|
|
5697
|
+
mod.writeFile(`${Name}.Template.tsx`, content);
|
|
5676
5698
|
}
|
|
5677
|
-
async createUnit(
|
|
5678
|
-
const { component: unit } = await this.#runner.createComponentTemplate(
|
|
5679
|
-
const Name = capitalize(
|
|
5680
|
-
const unitExampleFiles = (await
|
|
5681
|
-
(f) => !f.filePath.includes(`${
|
|
5699
|
+
async createUnit(mod) {
|
|
5700
|
+
const { component: unit } = await this.#runner.createComponentTemplate(mod, "unit");
|
|
5701
|
+
const Name = capitalize(mod.name);
|
|
5702
|
+
const unitExampleFiles = (await mod.sys.getUnitsSourceCode()).filter(
|
|
5703
|
+
(f) => !f.filePath.includes(`${mod.name}.Unit.tsx`)
|
|
5682
5704
|
);
|
|
5683
|
-
const relatedCnsts = getRelatedCnsts(`${
|
|
5684
|
-
const constant = import_fs11.default.readFileSync(`${
|
|
5685
|
-
const session = new AiSession("createUnit", { workspace:
|
|
5705
|
+
const relatedCnsts = getRelatedCnsts(`${mod.sys.cwdPath}/lib/${mod.name}/${mod.name}.constant.ts`);
|
|
5706
|
+
const constant = import_fs11.default.readFileSync(`${mod.sys.cwdPath}/lib/${mod.name}/${mod.name}.constant.ts`, "utf-8");
|
|
5707
|
+
const session = new AiSession("createUnit", { workspace: mod.sys.workspace, cacheKey: mod.name });
|
|
5686
5708
|
const promptRst = requestUnit({
|
|
5687
|
-
sysName:
|
|
5688
|
-
modelName:
|
|
5709
|
+
sysName: mod.sys.name,
|
|
5710
|
+
modelName: mod.name,
|
|
5689
5711
|
ModelName: Name,
|
|
5690
5712
|
constant,
|
|
5691
5713
|
properties: relatedCnsts.map((r) => ({ key: r.key, source: r.source })),
|
|
@@ -5693,20 +5715,20 @@ var ModuleScript = class {
|
|
|
5693
5715
|
boilerplate: unit.content
|
|
5694
5716
|
});
|
|
5695
5717
|
const content = await session.editTypescript(promptRst);
|
|
5696
|
-
|
|
5718
|
+
mod.writeFile(`${Name}.Unit.tsx`, content);
|
|
5697
5719
|
}
|
|
5698
|
-
async createView(
|
|
5699
|
-
const { component: view } = await this.#runner.createComponentTemplate(
|
|
5700
|
-
const viewExampleFiles = (await
|
|
5701
|
-
(f) => !f.filePath.includes(`${
|
|
5720
|
+
async createView(mod) {
|
|
5721
|
+
const { component: view } = await this.#runner.createComponentTemplate(mod, "view");
|
|
5722
|
+
const viewExampleFiles = (await mod.sys.getViewsSourceCode()).filter(
|
|
5723
|
+
(f) => !f.filePath.includes(`${mod.name}.View.tsx`)
|
|
5702
5724
|
);
|
|
5703
|
-
const Name = capitalize(
|
|
5704
|
-
const relatedCnsts = getRelatedCnsts(`${
|
|
5705
|
-
const constant = import_fs11.default.readFileSync(`${
|
|
5706
|
-
const session = new AiSession("createView", { workspace:
|
|
5725
|
+
const Name = capitalize(mod.name);
|
|
5726
|
+
const relatedCnsts = getRelatedCnsts(`${mod.sys.cwdPath}/lib/${mod.name}/${mod.name}.constant.ts`);
|
|
5727
|
+
const constant = import_fs11.default.readFileSync(`${mod.sys.cwdPath}/lib/${mod.name}/${mod.name}.constant.ts`, "utf-8");
|
|
5728
|
+
const session = new AiSession("createView", { workspace: mod.sys.workspace, cacheKey: mod.name });
|
|
5707
5729
|
const promptRst = requestView({
|
|
5708
|
-
sysName:
|
|
5709
|
-
modelName:
|
|
5730
|
+
sysName: mod.sys.name,
|
|
5731
|
+
modelName: mod.name,
|
|
5710
5732
|
ModelName: Name,
|
|
5711
5733
|
constant,
|
|
5712
5734
|
boilerplate: view.content,
|
|
@@ -5714,16 +5736,16 @@ var ModuleScript = class {
|
|
|
5714
5736
|
exampleFiles: randomPicks(viewExampleFiles, Math.min(20, viewExampleFiles.length))
|
|
5715
5737
|
});
|
|
5716
5738
|
const content = await session.editTypescript(promptRst);
|
|
5717
|
-
|
|
5739
|
+
mod.writeFile(`${Name}.View.tsx`, content);
|
|
5718
5740
|
}
|
|
5719
5741
|
};
|
|
5720
5742
|
|
|
5721
5743
|
// pkgs/@akanjs/cli/src/module/module.command.ts
|
|
5722
5744
|
var ModuleCommand = class {
|
|
5723
5745
|
moduleScript = new ModuleScript();
|
|
5724
|
-
async createModule(moduleName, sys3) {
|
|
5746
|
+
async createModule(moduleName, sys3, page) {
|
|
5725
5747
|
const name = lowerlize(moduleName.replace(/ /g, ""));
|
|
5726
|
-
await this.moduleScript.createModuleTemplate(sys3, name);
|
|
5748
|
+
await this.moduleScript.createModuleTemplate(sys3, name, { page });
|
|
5727
5749
|
}
|
|
5728
5750
|
removeModule(module2) {
|
|
5729
5751
|
this.moduleScript.removeModule(module2);
|
|
@@ -5741,7 +5763,8 @@ var ModuleCommand = class {
|
|
|
5741
5763
|
__decorateClass([
|
|
5742
5764
|
Target.Public(),
|
|
5743
5765
|
__decorateParam(0, Argument("moduleName", { desc: "name of module" })),
|
|
5744
|
-
__decorateParam(1, Sys())
|
|
5766
|
+
__decorateParam(1, Sys()),
|
|
5767
|
+
__decorateParam(2, Option("page", { type: "boolean", desc: "create page", default: false }))
|
|
5745
5768
|
], ModuleCommand.prototype, "createModule", 1);
|
|
5746
5769
|
__decorateClass([
|
|
5747
5770
|
Target.Public(),
|
|
@@ -5807,31 +5830,20 @@ PackageCommand = __decorateClass([
|
|
|
5807
5830
|
Commands()
|
|
5808
5831
|
], PackageCommand);
|
|
5809
5832
|
|
|
5810
|
-
// pkgs/@akanjs/cli/src/page/page.runner.ts
|
|
5811
|
-
var PageRunner = class {
|
|
5812
|
-
async createPage(app, name) {
|
|
5813
|
-
}
|
|
5814
|
-
};
|
|
5815
|
-
|
|
5816
|
-
// pkgs/@akanjs/cli/src/page/page.script.ts
|
|
5817
|
-
var PageScript = class {
|
|
5818
|
-
#runner = new PageRunner();
|
|
5819
|
-
async createPage(app, name) {
|
|
5820
|
-
await this.#runner.createPage(app, name);
|
|
5821
|
-
}
|
|
5822
|
-
};
|
|
5823
|
-
|
|
5824
5833
|
// pkgs/@akanjs/cli/src/page/page.command.ts
|
|
5825
5834
|
var PageCommand = class {
|
|
5826
5835
|
pageScript = new PageScript();
|
|
5827
|
-
async
|
|
5836
|
+
async createCrudPage(app, module2, basePath2, single) {
|
|
5837
|
+
await this.pageScript.createCrudPage(module2, { app, basePath: basePath2, single });
|
|
5828
5838
|
}
|
|
5829
5839
|
};
|
|
5830
5840
|
__decorateClass([
|
|
5831
5841
|
Target.Public(),
|
|
5832
5842
|
__decorateParam(0, App()),
|
|
5833
|
-
__decorateParam(1,
|
|
5834
|
-
|
|
5843
|
+
__decorateParam(1, Module()),
|
|
5844
|
+
__decorateParam(2, Option("basePath", { desc: "base path", nullable: true })),
|
|
5845
|
+
__decorateParam(3, Option("single", { desc: "single page", default: false }))
|
|
5846
|
+
], PageCommand.prototype, "createCrudPage", 1);
|
|
5835
5847
|
PageCommand = __decorateClass([
|
|
5836
5848
|
Commands()
|
|
5837
5849
|
], PageCommand);
|
|
@@ -16,7 +16,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
};
|
|
17
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
18
|
|
|
19
|
-
// pkgs/@akanjs/cli/src/templates/app/app/[lang]/
|
|
19
|
+
// pkgs/@akanjs/cli/src/templates/app/app/[lang]/layout.tsx
|
|
20
20
|
var layout_exports = {};
|
|
21
21
|
__export(layout_exports, {
|
|
22
22
|
default: () => getContent
|
|
@@ -16,7 +16,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
};
|
|
17
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
18
|
|
|
19
|
-
// pkgs/@akanjs/cli/src/templates/app/app/[lang]/
|
|
19
|
+
// pkgs/@akanjs/cli/src/templates/app/app/[lang]/page.tsx
|
|
20
20
|
var page_exports = {};
|
|
21
21
|
__export(page_exports, {
|
|
22
22
|
default: () => getContent
|
|
@@ -16,7 +16,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
};
|
|
17
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
18
|
|
|
19
|
-
// pkgs/@akanjs/cli/src/templates/app/app/[lang]/
|
|
19
|
+
// pkgs/@akanjs/cli/src/templates/app/app/[lang]/unknown/page.tsx
|
|
20
20
|
var page_exports = {};
|
|
21
21
|
__export(page_exports, {
|
|
22
22
|
default: () => getContent
|
|
@@ -27,8 +27,7 @@ function getContent(scanResult, dict) {
|
|
|
27
27
|
filename: "page.tsx",
|
|
28
28
|
content: `
|
|
29
29
|
import { ${dict.Model}, fetch, usePage } from "${dict.appName}/client";
|
|
30
|
-
import { Link } from "@akanjs/ui";
|
|
31
|
-
import { Load } from "@akanjs/ui";
|
|
30
|
+
import { Link, Load } from "@akanjs/ui";
|
|
32
31
|
import type { CsrConfig } from "@akanjs/client";
|
|
33
32
|
|
|
34
33
|
interface PageProps {
|
|
@@ -61,7 +60,7 @@ export default function Page({ params }: PageProps) {
|
|
|
61
60
|
render={({ ${dict.model}, ${dict.model}View }) => (
|
|
62
61
|
<div className="container flex flex-col gap-4">
|
|
63
62
|
<div className="flex gap-4 font-bold text-lg items-center">
|
|
64
|
-
|
|
63
|
+
<${dict.Model}.Zone.View view={${dict.model}View} />
|
|
65
64
|
<Link href={\`/${dict.model}/\${${dict.model}.id}/edit\`}>
|
|
66
65
|
<button className="btn">
|
|
67
66
|
{l("shared.updateModel", { model: l("${dict.model}.modelName") })}
|
|
@@ -27,7 +27,7 @@ function getContent(scanResult, dict) {
|
|
|
27
27
|
filename: "page.tsx",
|
|
28
28
|
content: `
|
|
29
29
|
import { Load } from "@akanjs/ui";
|
|
30
|
-
import { cnst, fetch, usePage, ${dict.Model} } from "
|
|
30
|
+
import { cnst, fetch, usePage, ${dict.Model} } from "@${dict.appName}/client";
|
|
31
31
|
import type { CsrConfig } from "@akanjs/client";
|
|
32
32
|
|
|
33
33
|
export default function Page() {
|
|
@@ -54,7 +54,7 @@ export default function Page() {
|
|
|
54
54
|
onCancel="back"
|
|
55
55
|
onSubmit="/${dict.model}"
|
|
56
56
|
>
|
|
57
|
-
|
|
57
|
+
<${dict.Model}.Template.General />
|
|
58
58
|
</Load.Edit>
|
|
59
59
|
</div>
|
|
60
60
|
)}
|
|
@@ -26,7 +26,7 @@ function getContent(scanResult, dict) {
|
|
|
26
26
|
return {
|
|
27
27
|
filename: "page.tsx",
|
|
28
28
|
content: `
|
|
29
|
-
import { ${dict.Model}, fetch, usePage } from "
|
|
29
|
+
import { ${dict.Model}, fetch, usePage } from "@${dict.appName}/client";
|
|
30
30
|
import { Link, Load } from "@akanjs/ui";
|
|
31
31
|
import type { CsrConfig } from "@akanjs/client";
|
|
32
32
|
|
|
@@ -51,7 +51,7 @@ export default function Page() {
|
|
|
51
51
|
</div>
|
|
52
52
|
<div>{l("${dict.model}.modelDesc")}</div>
|
|
53
53
|
<div className="flex px-6 mt-3 gap-4">
|
|
54
|
-
|
|
54
|
+
<${dict.Model}.Zone.Card
|
|
55
55
|
className="animate-fadeIn grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 2xl:grid-cols-5 justify-center gap-4 w-full"
|
|
56
56
|
init={${dict.model}InitInPublic}
|
|
57
57
|
/>
|
package/esm/index.js
CHANGED
|
@@ -5200,6 +5200,25 @@ LibraryCommand = __decorateClass([
|
|
|
5200
5200
|
// pkgs/@akanjs/cli/src/module/module.script.ts
|
|
5201
5201
|
import fs15 from "fs";
|
|
5202
5202
|
|
|
5203
|
+
// pkgs/@akanjs/cli/src/page/page.runner.ts
|
|
5204
|
+
var PageRunner = class {
|
|
5205
|
+
async createCrudPage(module, { app, basePath: basePath2, single = false }) {
|
|
5206
|
+
await app.applyTemplate({
|
|
5207
|
+
basePath: basePath2 ?? `app/[lang]/(${app.name})/(public)/${module.name}`,
|
|
5208
|
+
template: single ? "crudSinglePage" : "crudPages",
|
|
5209
|
+
dict: { model: module.name, appName: module.sys.name }
|
|
5210
|
+
});
|
|
5211
|
+
}
|
|
5212
|
+
};
|
|
5213
|
+
|
|
5214
|
+
// pkgs/@akanjs/cli/src/page/page.script.ts
|
|
5215
|
+
var PageScript = class {
|
|
5216
|
+
#runner = new PageRunner();
|
|
5217
|
+
async createCrudPage(module, { app, basePath: basePath2, single = false }) {
|
|
5218
|
+
await this.#runner.createCrudPage(module, { app, basePath: basePath2, single });
|
|
5219
|
+
}
|
|
5220
|
+
};
|
|
5221
|
+
|
|
5203
5222
|
// pkgs/@akanjs/cli/src/module/module.prompt.ts
|
|
5204
5223
|
var componentDefaultDescription = ({
|
|
5205
5224
|
modelName,
|
|
@@ -5574,10 +5593,13 @@ var ModuleRunner = class {
|
|
|
5574
5593
|
|
|
5575
5594
|
// pkgs/@akanjs/cli/src/module/module.script.ts
|
|
5576
5595
|
var ModuleScript = class {
|
|
5596
|
+
pageScript = new PageScript();
|
|
5577
5597
|
#runner = new ModuleRunner();
|
|
5578
|
-
async createModuleTemplate(sys3, name) {
|
|
5579
|
-
const
|
|
5580
|
-
await this.#runner.createModuleTemplate(
|
|
5598
|
+
async createModuleTemplate(sys3, name, { page = false } = {}) {
|
|
5599
|
+
const mod = ModuleExecutor.from(sys3, name);
|
|
5600
|
+
await this.#runner.createModuleTemplate(mod);
|
|
5601
|
+
if (page && sys3.type === "app")
|
|
5602
|
+
await this.pageScript.createCrudPage(mod, { app: sys3, basePath: null, single: false });
|
|
5581
5603
|
const akanConfig = await sys3.getConfig();
|
|
5582
5604
|
await sys3.scan({ akanConfig });
|
|
5583
5605
|
}
|
|
@@ -5628,25 +5650,25 @@ var ModuleScript = class {
|
|
|
5628
5650
|
await this.createTemplate(executor);
|
|
5629
5651
|
sys3.log(`Module ${name} created in ${sys3.type}s/${sys3.name}/lib/${name}`);
|
|
5630
5652
|
}
|
|
5631
|
-
removeModule(
|
|
5632
|
-
this.#runner.removeModule(
|
|
5653
|
+
removeModule(mod) {
|
|
5654
|
+
this.#runner.removeModule(mod);
|
|
5633
5655
|
}
|
|
5634
5656
|
async createService(workspace, name) {
|
|
5635
5657
|
}
|
|
5636
5658
|
async createTest(workspace, name) {
|
|
5637
5659
|
}
|
|
5638
|
-
async createTemplate(
|
|
5639
|
-
const { component: template } = await this.#runner.createComponentTemplate(
|
|
5640
|
-
const templateExampleFiles = (await
|
|
5641
|
-
(f) => !f.filePath.includes(`${
|
|
5660
|
+
async createTemplate(mod) {
|
|
5661
|
+
const { component: template } = await this.#runner.createComponentTemplate(mod, "template");
|
|
5662
|
+
const templateExampleFiles = (await mod.sys.getTemplatesSourceCode()).filter(
|
|
5663
|
+
(f) => !f.filePath.includes(`${mod.name}.Template.tsx`)
|
|
5642
5664
|
);
|
|
5643
|
-
const Name = capitalize(
|
|
5644
|
-
const relatedCnsts = getRelatedCnsts(`${
|
|
5645
|
-
const constant = fs15.readFileSync(`${
|
|
5646
|
-
const session = new AiSession("createTemplate", { workspace:
|
|
5665
|
+
const Name = capitalize(mod.name);
|
|
5666
|
+
const relatedCnsts = getRelatedCnsts(`${mod.sys.cwdPath}/lib/${mod.name}/${mod.name}.constant.ts`);
|
|
5667
|
+
const constant = fs15.readFileSync(`${mod.sys.cwdPath}/lib/${mod.name}/${mod.name}.constant.ts`, "utf-8");
|
|
5668
|
+
const session = new AiSession("createTemplate", { workspace: mod.sys.workspace, cacheKey: mod.name });
|
|
5647
5669
|
const promptRst = requestTemplate({
|
|
5648
|
-
sysName:
|
|
5649
|
-
modelName:
|
|
5670
|
+
sysName: mod.sys.name,
|
|
5671
|
+
modelName: mod.name,
|
|
5650
5672
|
ModelName: Name,
|
|
5651
5673
|
constant,
|
|
5652
5674
|
boilerplate: template.content,
|
|
@@ -5654,20 +5676,20 @@ var ModuleScript = class {
|
|
|
5654
5676
|
exampleFiles: randomPicks(templateExampleFiles, Math.min(20, templateExampleFiles.length))
|
|
5655
5677
|
});
|
|
5656
5678
|
const content = await session.editTypescript(promptRst);
|
|
5657
|
-
|
|
5679
|
+
mod.writeFile(`${Name}.Template.tsx`, content);
|
|
5658
5680
|
}
|
|
5659
|
-
async createUnit(
|
|
5660
|
-
const { component: unit } = await this.#runner.createComponentTemplate(
|
|
5661
|
-
const Name = capitalize(
|
|
5662
|
-
const unitExampleFiles = (await
|
|
5663
|
-
(f) => !f.filePath.includes(`${
|
|
5681
|
+
async createUnit(mod) {
|
|
5682
|
+
const { component: unit } = await this.#runner.createComponentTemplate(mod, "unit");
|
|
5683
|
+
const Name = capitalize(mod.name);
|
|
5684
|
+
const unitExampleFiles = (await mod.sys.getUnitsSourceCode()).filter(
|
|
5685
|
+
(f) => !f.filePath.includes(`${mod.name}.Unit.tsx`)
|
|
5664
5686
|
);
|
|
5665
|
-
const relatedCnsts = getRelatedCnsts(`${
|
|
5666
|
-
const constant = fs15.readFileSync(`${
|
|
5667
|
-
const session = new AiSession("createUnit", { workspace:
|
|
5687
|
+
const relatedCnsts = getRelatedCnsts(`${mod.sys.cwdPath}/lib/${mod.name}/${mod.name}.constant.ts`);
|
|
5688
|
+
const constant = fs15.readFileSync(`${mod.sys.cwdPath}/lib/${mod.name}/${mod.name}.constant.ts`, "utf-8");
|
|
5689
|
+
const session = new AiSession("createUnit", { workspace: mod.sys.workspace, cacheKey: mod.name });
|
|
5668
5690
|
const promptRst = requestUnit({
|
|
5669
|
-
sysName:
|
|
5670
|
-
modelName:
|
|
5691
|
+
sysName: mod.sys.name,
|
|
5692
|
+
modelName: mod.name,
|
|
5671
5693
|
ModelName: Name,
|
|
5672
5694
|
constant,
|
|
5673
5695
|
properties: relatedCnsts.map((r) => ({ key: r.key, source: r.source })),
|
|
@@ -5675,20 +5697,20 @@ var ModuleScript = class {
|
|
|
5675
5697
|
boilerplate: unit.content
|
|
5676
5698
|
});
|
|
5677
5699
|
const content = await session.editTypescript(promptRst);
|
|
5678
|
-
|
|
5700
|
+
mod.writeFile(`${Name}.Unit.tsx`, content);
|
|
5679
5701
|
}
|
|
5680
|
-
async createView(
|
|
5681
|
-
const { component: view } = await this.#runner.createComponentTemplate(
|
|
5682
|
-
const viewExampleFiles = (await
|
|
5683
|
-
(f) => !f.filePath.includes(`${
|
|
5702
|
+
async createView(mod) {
|
|
5703
|
+
const { component: view } = await this.#runner.createComponentTemplate(mod, "view");
|
|
5704
|
+
const viewExampleFiles = (await mod.sys.getViewsSourceCode()).filter(
|
|
5705
|
+
(f) => !f.filePath.includes(`${mod.name}.View.tsx`)
|
|
5684
5706
|
);
|
|
5685
|
-
const Name = capitalize(
|
|
5686
|
-
const relatedCnsts = getRelatedCnsts(`${
|
|
5687
|
-
const constant = fs15.readFileSync(`${
|
|
5688
|
-
const session = new AiSession("createView", { workspace:
|
|
5707
|
+
const Name = capitalize(mod.name);
|
|
5708
|
+
const relatedCnsts = getRelatedCnsts(`${mod.sys.cwdPath}/lib/${mod.name}/${mod.name}.constant.ts`);
|
|
5709
|
+
const constant = fs15.readFileSync(`${mod.sys.cwdPath}/lib/${mod.name}/${mod.name}.constant.ts`, "utf-8");
|
|
5710
|
+
const session = new AiSession("createView", { workspace: mod.sys.workspace, cacheKey: mod.name });
|
|
5689
5711
|
const promptRst = requestView({
|
|
5690
|
-
sysName:
|
|
5691
|
-
modelName:
|
|
5712
|
+
sysName: mod.sys.name,
|
|
5713
|
+
modelName: mod.name,
|
|
5692
5714
|
ModelName: Name,
|
|
5693
5715
|
constant,
|
|
5694
5716
|
boilerplate: view.content,
|
|
@@ -5696,16 +5718,16 @@ var ModuleScript = class {
|
|
|
5696
5718
|
exampleFiles: randomPicks(viewExampleFiles, Math.min(20, viewExampleFiles.length))
|
|
5697
5719
|
});
|
|
5698
5720
|
const content = await session.editTypescript(promptRst);
|
|
5699
|
-
|
|
5721
|
+
mod.writeFile(`${Name}.View.tsx`, content);
|
|
5700
5722
|
}
|
|
5701
5723
|
};
|
|
5702
5724
|
|
|
5703
5725
|
// pkgs/@akanjs/cli/src/module/module.command.ts
|
|
5704
5726
|
var ModuleCommand = class {
|
|
5705
5727
|
moduleScript = new ModuleScript();
|
|
5706
|
-
async createModule(moduleName, sys3) {
|
|
5728
|
+
async createModule(moduleName, sys3, page) {
|
|
5707
5729
|
const name = lowerlize(moduleName.replace(/ /g, ""));
|
|
5708
|
-
await this.moduleScript.createModuleTemplate(sys3, name);
|
|
5730
|
+
await this.moduleScript.createModuleTemplate(sys3, name, { page });
|
|
5709
5731
|
}
|
|
5710
5732
|
removeModule(module) {
|
|
5711
5733
|
this.moduleScript.removeModule(module);
|
|
@@ -5723,7 +5745,8 @@ var ModuleCommand = class {
|
|
|
5723
5745
|
__decorateClass([
|
|
5724
5746
|
Target.Public(),
|
|
5725
5747
|
__decorateParam(0, Argument("moduleName", { desc: "name of module" })),
|
|
5726
|
-
__decorateParam(1, Sys())
|
|
5748
|
+
__decorateParam(1, Sys()),
|
|
5749
|
+
__decorateParam(2, Option("page", { type: "boolean", desc: "create page", default: false }))
|
|
5727
5750
|
], ModuleCommand.prototype, "createModule", 1);
|
|
5728
5751
|
__decorateClass([
|
|
5729
5752
|
Target.Public(),
|
|
@@ -5789,31 +5812,20 @@ PackageCommand = __decorateClass([
|
|
|
5789
5812
|
Commands()
|
|
5790
5813
|
], PackageCommand);
|
|
5791
5814
|
|
|
5792
|
-
// pkgs/@akanjs/cli/src/page/page.runner.ts
|
|
5793
|
-
var PageRunner = class {
|
|
5794
|
-
async createPage(app, name) {
|
|
5795
|
-
}
|
|
5796
|
-
};
|
|
5797
|
-
|
|
5798
|
-
// pkgs/@akanjs/cli/src/page/page.script.ts
|
|
5799
|
-
var PageScript = class {
|
|
5800
|
-
#runner = new PageRunner();
|
|
5801
|
-
async createPage(app, name) {
|
|
5802
|
-
await this.#runner.createPage(app, name);
|
|
5803
|
-
}
|
|
5804
|
-
};
|
|
5805
|
-
|
|
5806
5815
|
// pkgs/@akanjs/cli/src/page/page.command.ts
|
|
5807
5816
|
var PageCommand = class {
|
|
5808
5817
|
pageScript = new PageScript();
|
|
5809
|
-
async
|
|
5818
|
+
async createCrudPage(app, module, basePath2, single) {
|
|
5819
|
+
await this.pageScript.createCrudPage(module, { app, basePath: basePath2, single });
|
|
5810
5820
|
}
|
|
5811
5821
|
};
|
|
5812
5822
|
__decorateClass([
|
|
5813
5823
|
Target.Public(),
|
|
5814
5824
|
__decorateParam(0, App()),
|
|
5815
|
-
__decorateParam(1,
|
|
5816
|
-
|
|
5825
|
+
__decorateParam(1, Module()),
|
|
5826
|
+
__decorateParam(2, Option("basePath", { desc: "base path", nullable: true })),
|
|
5827
|
+
__decorateParam(3, Option("single", { desc: "single page", default: false }))
|
|
5828
|
+
], PageCommand.prototype, "createCrudPage", 1);
|
|
5817
5829
|
PageCommand = __decorateClass([
|
|
5818
5830
|
Commands()
|
|
5819
5831
|
], PageCommand);
|
|
@@ -4,8 +4,7 @@ function getContent(scanResult, dict) {
|
|
|
4
4
|
filename: "page.tsx",
|
|
5
5
|
content: `
|
|
6
6
|
import { ${dict.Model}, fetch, usePage } from "${dict.appName}/client";
|
|
7
|
-
import { Link } from "@akanjs/ui";
|
|
8
|
-
import { Load } from "@akanjs/ui";
|
|
7
|
+
import { Link, Load } from "@akanjs/ui";
|
|
9
8
|
import type { CsrConfig } from "@akanjs/client";
|
|
10
9
|
|
|
11
10
|
interface PageProps {
|
|
@@ -38,7 +37,7 @@ export default function Page({ params }: PageProps) {
|
|
|
38
37
|
render={({ ${dict.model}, ${dict.model}View }) => (
|
|
39
38
|
<div className="container flex flex-col gap-4">
|
|
40
39
|
<div className="flex gap-4 font-bold text-lg items-center">
|
|
41
|
-
|
|
40
|
+
<${dict.Model}.Zone.View view={${dict.model}View} />
|
|
42
41
|
<Link href={\`/${dict.model}/\${${dict.model}.id}/edit\`}>
|
|
43
42
|
<button className="btn">
|
|
44
43
|
{l("shared.updateModel", { model: l("${dict.model}.modelName") })}
|
|
@@ -4,7 +4,7 @@ function getContent(scanResult, dict) {
|
|
|
4
4
|
filename: "page.tsx",
|
|
5
5
|
content: `
|
|
6
6
|
import { Load } from "@akanjs/ui";
|
|
7
|
-
import { cnst, fetch, usePage, ${dict.Model} } from "
|
|
7
|
+
import { cnst, fetch, usePage, ${dict.Model} } from "@${dict.appName}/client";
|
|
8
8
|
import type { CsrConfig } from "@akanjs/client";
|
|
9
9
|
|
|
10
10
|
export default function Page() {
|
|
@@ -31,7 +31,7 @@ export default function Page() {
|
|
|
31
31
|
onCancel="back"
|
|
32
32
|
onSubmit="/${dict.model}"
|
|
33
33
|
>
|
|
34
|
-
|
|
34
|
+
<${dict.Model}.Template.General />
|
|
35
35
|
</Load.Edit>
|
|
36
36
|
</div>
|
|
37
37
|
)}
|
|
@@ -3,7 +3,7 @@ function getContent(scanResult, dict) {
|
|
|
3
3
|
return {
|
|
4
4
|
filename: "page.tsx",
|
|
5
5
|
content: `
|
|
6
|
-
import { ${dict.Model}, fetch, usePage } from "
|
|
6
|
+
import { ${dict.Model}, fetch, usePage } from "@${dict.appName}/client";
|
|
7
7
|
import { Link, Load } from "@akanjs/ui";
|
|
8
8
|
import type { CsrConfig } from "@akanjs/client";
|
|
9
9
|
|
|
@@ -28,7 +28,7 @@ export default function Page() {
|
|
|
28
28
|
</div>
|
|
29
29
|
<div>{l("${dict.model}.modelDesc")}</div>
|
|
30
30
|
<div className="flex px-6 mt-3 gap-4">
|
|
31
|
-
|
|
31
|
+
<${dict.Model}.Zone.Card
|
|
32
32
|
className="animate-fadeIn grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 2xl:grid-cols-5 justify-center gap-4 w-full"
|
|
33
33
|
init={${dict.model}InitInPublic}
|
|
34
34
|
/>
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@ import { Module, Sys } from "@akanjs/devkit";
|
|
|
2
2
|
import { ModuleScript } from "./module.script";
|
|
3
3
|
export declare class ModuleCommand {
|
|
4
4
|
moduleScript: ModuleScript;
|
|
5
|
-
createModule(moduleName: string, sys: Sys): Promise<void>;
|
|
5
|
+
createModule(moduleName: string, sys: Sys, page: boolean): Promise<void>;
|
|
6
6
|
removeModule(module: Module): void;
|
|
7
7
|
createView(module: Module): Promise<void>;
|
|
8
8
|
createUnit(module: Module): Promise<void>;
|
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
import { type Module, type Sys, Workspace } from "@akanjs/devkit";
|
|
2
|
+
import { PageScript } from "../page/page.script";
|
|
2
3
|
export declare class ModuleScript {
|
|
3
4
|
#private;
|
|
4
|
-
|
|
5
|
+
pageScript: PageScript;
|
|
6
|
+
createModuleTemplate(sys: Sys, name: string, { page }?: {
|
|
7
|
+
page?: boolean;
|
|
8
|
+
}): Promise<void>;
|
|
5
9
|
createModule(sys: Sys, name: string, description?: string, schemaDescription?: string): Promise<void>;
|
|
6
10
|
createModule_(sys: Sys, name: string, description: string, schemaDescription: string): Promise<void>;
|
|
7
|
-
removeModule(
|
|
11
|
+
removeModule(mod: Module): void;
|
|
8
12
|
createService(workspace: Workspace, name: string): Promise<void>;
|
|
9
13
|
createTest(workspace: Workspace, name: string): Promise<void>;
|
|
10
|
-
createTemplate(
|
|
11
|
-
createUnit(
|
|
12
|
-
createView(
|
|
14
|
+
createTemplate(mod: Module): Promise<void>;
|
|
15
|
+
createUnit(mod: Module): Promise<void>;
|
|
16
|
+
createView(mod: Module): Promise<void>;
|
|
13
17
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { App } from "@akanjs/devkit";
|
|
1
|
+
import { App, Module } from "@akanjs/devkit";
|
|
2
2
|
import { PageScript } from "./page.script";
|
|
3
3
|
export declare class PageCommand {
|
|
4
4
|
pageScript: PageScript;
|
|
5
|
-
|
|
5
|
+
createCrudPage(app: App, module: Module, basePath: string | null, single: boolean): Promise<void>;
|
|
6
6
|
}
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import { App } from "@akanjs/devkit";
|
|
1
|
+
import { App, Module } from "@akanjs/devkit";
|
|
2
2
|
export declare class PageRunner {
|
|
3
|
-
|
|
3
|
+
createCrudPage(module: Module, { app, basePath, single }: {
|
|
4
|
+
app: App;
|
|
5
|
+
basePath: string | null;
|
|
6
|
+
single: boolean;
|
|
7
|
+
}): Promise<void>;
|
|
4
8
|
}
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
import { App } from "@akanjs/devkit";
|
|
1
|
+
import { App, Module } from "@akanjs/devkit";
|
|
2
2
|
export declare class PageScript {
|
|
3
3
|
#private;
|
|
4
|
-
|
|
4
|
+
createCrudPage(module: Module, { app, basePath, single }: {
|
|
5
|
+
app: App;
|
|
6
|
+
basePath: string | null;
|
|
7
|
+
single: boolean;
|
|
8
|
+
}): Promise<void>;
|
|
5
9
|
}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
|
|
19
|
-
// pkgs/@akanjs/cli/src/templates/app/app/[lang]/admin/layout.tsx
|
|
20
|
-
var layout_exports = {};
|
|
21
|
-
__export(layout_exports, {
|
|
22
|
-
default: () => getContent
|
|
23
|
-
});
|
|
24
|
-
module.exports = __toCommonJS(layout_exports);
|
|
25
|
-
function getContent(scanResult, dict) {
|
|
26
|
-
return {
|
|
27
|
-
filename: "layout.tsx",
|
|
28
|
-
content: `
|
|
29
|
-
import "../(${dict.appName})/styles.css";
|
|
30
|
-
import { System } from "@akanjs/ui";
|
|
31
|
-
import { env } from "@${dict.appName}/env/env.client";
|
|
32
|
-
import { fetch } from "@${dict.appName}/client";
|
|
33
|
-
import type { RootLayoutProps } from "@akanjs/client";
|
|
34
|
-
|
|
35
|
-
export const metadata = { title: "${dict.appName}" };
|
|
36
|
-
|
|
37
|
-
export default function Layout({ children, params }: RootLayoutProps) {
|
|
38
|
-
return (
|
|
39
|
-
<System.Provider
|
|
40
|
-
of={Layout}
|
|
41
|
-
appName="${dict.appName}"
|
|
42
|
-
params={params}
|
|
43
|
-
head={<link rel="icon" href="/favicon.ico" />}
|
|
44
|
-
// className="bg-base-100"
|
|
45
|
-
env={env}
|
|
46
|
-
fetch={fetch}
|
|
47
|
-
>
|
|
48
|
-
{children}
|
|
49
|
-
</System.Provider>
|
|
50
|
-
);
|
|
51
|
-
}
|
|
52
|
-
`
|
|
53
|
-
};
|
|
54
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
// pkgs/@akanjs/cli/src/templates/app/app/[lang]/admin/layout.tsx
|
|
2
|
-
function getContent(scanResult, dict) {
|
|
3
|
-
return {
|
|
4
|
-
filename: "layout.tsx",
|
|
5
|
-
content: `
|
|
6
|
-
import "../(${dict.appName})/styles.css";
|
|
7
|
-
import { System } from "@akanjs/ui";
|
|
8
|
-
import { env } from "@${dict.appName}/env/env.client";
|
|
9
|
-
import { fetch } from "@${dict.appName}/client";
|
|
10
|
-
import type { RootLayoutProps } from "@akanjs/client";
|
|
11
|
-
|
|
12
|
-
export const metadata = { title: "${dict.appName}" };
|
|
13
|
-
|
|
14
|
-
export default function Layout({ children, params }: RootLayoutProps) {
|
|
15
|
-
return (
|
|
16
|
-
<System.Provider
|
|
17
|
-
of={Layout}
|
|
18
|
-
appName="${dict.appName}"
|
|
19
|
-
params={params}
|
|
20
|
-
head={<link rel="icon" href="/favicon.ico" />}
|
|
21
|
-
// className="bg-base-100"
|
|
22
|
-
env={env}
|
|
23
|
-
fetch={fetch}
|
|
24
|
-
>
|
|
25
|
-
{children}
|
|
26
|
-
</System.Provider>
|
|
27
|
-
);
|
|
28
|
-
}
|
|
29
|
-
`
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
export {
|
|
33
|
-
getContent as default
|
|
34
|
-
};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { AppScanResult, LibScanResult } from "@akanjs/config";
|
|
2
|
-
interface Dict {
|
|
3
|
-
appName: string;
|
|
4
|
-
}
|
|
5
|
-
export default function getContent(scanResult: AppScanResult | LibScanResult | null, dict: Dict): {
|
|
6
|
-
filename: string;
|
|
7
|
-
content: string;
|
|
8
|
-
};
|
|
9
|
-
export {};
|
/package/cjs/src/templates/app/app/[lang]/{(__appName__)/styles.css.template → styles.css.template}
RENAMED
|
File without changes
|
/package/esm/src/templates/app/app/[lang]/{(__appName__)/styles.css.template → styles.css.template}
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|